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.
16 package org
.jetbrains
.idea
.maven
.project
;
18 import com
.intellij
.ide
.util
.ElementsChooser
;
19 import com
.intellij
.openapi
.options
.Configurable
;
20 import com
.intellij
.openapi
.options
.ConfigurationException
;
21 import com
.intellij
.openapi
.util
.io
.FileUtil
;
22 import org
.jetbrains
.annotations
.Nls
;
23 import org
.jetbrains
.annotations
.NonNls
;
24 import org
.jetbrains
.annotations
.Nullable
;
25 import org
.jetbrains
.idea
.maven
.utils
.MavenUIUtil
;
26 import org
.jetbrains
.idea
.maven
.utils
.MavenUtil
;
27 import org
.jetbrains
.idea
.maven
.utils
.Strings
;
30 import java
.util
.Collection
;
31 import java
.util
.Comparator
;
33 public class MavenIgnoredFilesConfigurable
implements Configurable
{
34 private static final char SEPARATOR
= ',';
36 private final MavenProjectsManager myManager
;
38 private Collection
<String
> myOriginallyIgnoredFilesPaths
;
39 private String myOriginallyIgnoredFilesPatterns
;
41 private JPanel myMainPanel
;
42 private ElementsChooser
<String
> myIgnoredFilesPathsChooser
;
43 private JTextArea myIgnoredFilesPattersEditor
;
45 public MavenIgnoredFilesConfigurable(MavenProjectsManager manager
) {
49 private void createUIComponents() {
50 myIgnoredFilesPathsChooser
= new ElementsChooser
<String
>(true);
53 public JComponent
createComponent() {
57 public void disposeUIResources() {
60 public boolean isModified() {
61 return !MavenUtil
.equalAsSets(myOriginallyIgnoredFilesPaths
, myIgnoredFilesPathsChooser
.getMarkedElements()) ||
62 !myOriginallyIgnoredFilesPatterns
.equals(myIgnoredFilesPattersEditor
.getText());
65 public void apply() throws ConfigurationException
{
66 myManager
.setIgnoredFilesPaths(myIgnoredFilesPathsChooser
.getMarkedElements());
67 myManager
.setIgnoredFilesPatterns(Strings
.tokenize(myIgnoredFilesPattersEditor
.getText(), Strings
.WHITESPACE
+ SEPARATOR
));
71 myOriginallyIgnoredFilesPaths
= myManager
.getIgnoredFilesPaths();
72 myOriginallyIgnoredFilesPatterns
= Strings
.detokenize(myManager
.getIgnoredFilesPatterns(), SEPARATOR
);
74 MavenUIUtil
.setElements(myIgnoredFilesPathsChooser
,
75 MavenUtil
.collectPaths(myManager
.getProjectsFiles()),
76 myOriginallyIgnoredFilesPaths
,
77 new Comparator
<String
>() {
78 public int compare(String o1
, String o2
) {
79 return FileUtil
.comparePaths(o1
, o2
);
82 myIgnoredFilesPattersEditor
.setText(myOriginallyIgnoredFilesPatterns
);
86 public String
getDisplayName() {
87 return ProjectBundle
.message("maven.tab.ignored.files");
91 public Icon
getIcon() {
97 public String
getHelpTopic() {
98 return "reference.settings.project.maven.ignored.files";