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 org
.jetbrains
.plugins
.groovy
.compiler
;
19 import com
.intellij
.compiler
.CompilerSettingsFactory
;
20 import com
.intellij
.openapi
.compiler
.options
.ExcludedEntriesConfigurable
;
21 import com
.intellij
.openapi
.compiler
.options
.ExcludedEntriesConfiguration
;
22 import com
.intellij
.openapi
.fileChooser
.FileChooserDescriptor
;
23 import com
.intellij
.openapi
.module
.Module
;
24 import com
.intellij
.openapi
.module
.ModuleManager
;
25 import com
.intellij
.openapi
.options
.Configurable
;
26 import com
.intellij
.openapi
.options
.ConfigurationException
;
27 import com
.intellij
.openapi
.options
.SearchableConfigurable
;
28 import com
.intellij
.openapi
.project
.Project
;
29 import com
.intellij
.openapi
.roots
.ModuleRootManager
;
30 import com
.intellij
.openapi
.roots
.ProjectFileIndex
;
31 import com
.intellij
.openapi
.roots
.ProjectRootManager
;
32 import com
.intellij
.openapi
.util
.Comparing
;
33 import com
.intellij
.openapi
.vfs
.VirtualFile
;
34 import org
.jetbrains
.annotations
.Nls
;
35 import org
.jetbrains
.plugins
.groovy
.GroovyIcons
;
42 public class GroovyCompilerConfigurable
implements SearchableConfigurable
, CompilerSettingsFactory
{
43 private JTextField myHeapSize
;
44 private JPanel myMainPanel
;
45 private JPanel myExcludesPanel
;
46 private JCheckBox myUseGroovycStubs
;
47 private ExcludedEntriesConfigurable myExcludes
;
48 private final GroovyCompilerConfiguration myConfig
;
51 public GroovyCompilerConfigurable(Project project
) {
52 myConfig
= GroovyCompilerConfiguration
.getInstance(project
);
53 myExcludes
= createExcludedConfigurable(project
);
56 public ExcludedEntriesConfigurable
getExcludes() {
60 private ExcludedEntriesConfigurable
createExcludedConfigurable(final Project project
) {
61 final ExcludedEntriesConfiguration configuration
= myConfig
.getExcludeFromStubGeneration();
62 final ProjectFileIndex index
= ProjectRootManager
.getInstance(project
).getFileIndex();
63 final FileChooserDescriptor descriptor
= new FileChooserDescriptor(true, true, false, false, false, true) {
64 public boolean isFileVisible(VirtualFile file
, boolean showHiddenFiles
) {
65 return super.isFileVisible(file
, showHiddenFiles
) && !index
.isIgnored(file
);
68 for (final Module module
: ModuleManager
.getInstance(project
).getModules()) {
69 for (VirtualFile file
: ModuleRootManager
.getInstance(module
).getSourceRoots()) {
70 descriptor
.addRoot(file
);
73 return new ExcludedEntriesConfigurable(project
, descriptor
, configuration
);
77 public String
getId() {
78 return "Groovy compiler";
81 public Runnable
enableSearch(String option
) {
86 public String
getDisplayName() {
87 return "Groovy Compiler";
90 public Icon
getIcon() {
91 return GroovyIcons
.GROOVY_ICON_16x16
;
94 public String
getHelpTopic() {
95 return "reference.projectsettings.compiler.groovy";
98 public JComponent
createComponent() {
99 myExcludesPanel
.add(myExcludes
.createComponent());
103 public boolean isModified() {
104 return !Comparing
.equal(myConfig
.getHeapSize(), myHeapSize
.getText()) ||
105 myExcludes
.isModified() ||
106 myConfig
.isUseGroovycStubs() != myUseGroovycStubs
.isSelected();
109 public void apply() throws ConfigurationException
{
111 myConfig
.setHeapSize(myHeapSize
.getText());
112 myConfig
.setUseGroovycStubs(myUseGroovycStubs
.isSelected());
115 public void reset() {
116 myHeapSize
.setText(myConfig
.getHeapSize());
117 myUseGroovycStubs
.setSelected(myConfig
.isUseGroovycStubs());
121 public void disposeUIResources() {
122 myExcludes
.disposeUIResources();
125 public Configurable
create(Project project
) {