2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.facet
.impl
.autodetecting
;
19 import com
.intellij
.util
.xmlb
.annotations
.AbstractCollection
;
20 import com
.intellij
.util
.xmlb
.annotations
.Tag
;
21 import org
.jetbrains
.annotations
.NotNull
;
22 import org
.jetbrains
.annotations
.Nullable
;
24 import java
.util
.ArrayList
;
25 import java
.util
.List
;
26 import java
.util
.Iterator
;
31 public class DisabledAutodetectionInfo
{
32 private List
<DisabledAutodetectionByTypeElement
> myElements
= new ArrayList
<DisabledAutodetectionByTypeElement
>();
34 @Tag("autodetection-disabled")
35 @AbstractCollection(surroundWithTag
= false)
36 public List
<DisabledAutodetectionByTypeElement
> getElements() {
40 public void setElements(final List
<DisabledAutodetectionByTypeElement
> elements
) {
41 myElements
= elements
;
44 public boolean isDisabled(final @NotNull String facetType
, final @NotNull String moduleName
, String url
) {
45 DisabledAutodetectionByTypeElement element
= findElement(facetType
);
46 return element
!= null && element
.isDisabled(moduleName
, url
);
49 public void replaceElement(@NotNull String facetTypeId
, @Nullable DisabledAutodetectionByTypeElement element
) {
50 Iterator
<DisabledAutodetectionByTypeElement
> iterator
= myElements
.iterator();
51 while (iterator
.hasNext()) {
52 DisabledAutodetectionByTypeElement typeElement
= iterator
.next();
53 if (typeElement
.getFacetTypeId().equals(facetTypeId
)) {
58 if (element
!= null) {
59 myElements
.add(element
);
64 public DisabledAutodetectionByTypeElement
findElement(@NotNull String facetTypeId
) {
65 for (DisabledAutodetectionByTypeElement element
: myElements
) {
66 if (facetTypeId
.equals(element
.getFacetTypeId())) {
73 public void addDisabled(final @NotNull String facetTypeId
) {
74 DisabledAutodetectionByTypeElement element
= findElement(facetTypeId
);
75 if (element
!= null) {
76 element
.disableInProject();
79 myElements
.add(new DisabledAutodetectionByTypeElement(facetTypeId
));
83 public void addDisabled(final @NotNull String facetTypeId
, final @NotNull String moduleName
) {
84 DisabledAutodetectionByTypeElement element
= findElement(facetTypeId
);
85 if (element
!= null) {
86 element
.addDisabled(moduleName
);
89 myElements
.add(new DisabledAutodetectionByTypeElement(facetTypeId
, moduleName
));
93 public void addDisabled(final @NotNull String facetTypeId
, final @NotNull String moduleName
, String url
, final boolean recursively
) {
94 DisabledAutodetectionByTypeElement element
= findElement(facetTypeId
);
95 if (element
!= null) {
96 element
.addDisabled(moduleName
, url
, recursively
);
99 myElements
.add(new DisabledAutodetectionByTypeElement(facetTypeId
, moduleName
, url
, recursively
));
103 public void addDisabled(final @NotNull String facetTypeId
, final @NotNull String moduleName
, final @NotNull String
... urls
) {
104 for (String url
: urls
) {
105 addDisabled(facetTypeId
, moduleName
, url
, false);