From fff4e60d2cd5ebeb2715894ba00ba9ecd630d5cc Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 1 Oct 2010 17:09:41 +0400 Subject: [PATCH] groovy support configuration panels replaced by new editor --- .../libraries/DownloadingOptionsDialog.java | 7 +- .../FacetLibrariesValidatorImpl.java | 60 +---- .../libraries/LibraryCompositionSettings.java | 37 +-- .../ui/libraries/LibraryOptionsPanel.java | 8 +- .../CustomLibraryDescriptionImpl.java | 19 +- .../FrameworkVersionWithLibrary.java | 35 +++ .../AddSupportForFrameworksPanel.java | 20 +- .../FrameworkSupportNode.java | 6 +- .../libraries/AddCustomLibraryDialog.java | 112 ++++++++ .../AddExistingCustomLibraryAction.java | 22 +- .../libraries/CreateCustomLibraryAction.java | 19 +- .../libraries/CustomLibraryActionBase.java | 88 ++++++ .../libraries/CustomLibraryDescription.java | 11 +- .../libraries/LibraryDownloadDescription.java | 44 +++ .../libraries/LibraryPresentationManager.java | 2 + .../impl/LibraryPresentationManagerImpl.java | 10 + .../FrameworkSupportConfigurable.java | 2 +- .../src/messages/IdeBundle.properties | 2 +- .../intellij/util/ParametrizedRunnable.java | 23 ++ plugins/groovy/src/META-INF/plugin.xml | 3 + .../plugins/groovy/GroovyBundle.properties | 14 +- .../config/AbstractGroovyLibraryManager.java | 125 --------- .../config/GroovyFacetSupportProvider.java | 3 +- .../groovy/config/GroovyLibraryCreator.java | 57 ---- .../config/GroovyLibraryDescription.java | 135 ++++++++++ .../groovy/config/GroovyLibraryManager.java | 5 - .../GroovyLibraryPresentationProvider.java | 29 +- ...GroovyLibraryPresentationProviderBase.java | 59 ++++ .../config/GroovyLibraryProperties.java | 8 +- .../config/GroovySupportConfigurable.java | 138 +--------- .../plugins/groovy/config/LibraryManager.java | 15 -- .../groovy/config/ui/CreateLibraryDialog.form | 46 ---- .../groovy/config/ui/CreateLibraryDialog.java | 50 ---- .../groovy/config/ui/GroovyFacetEditor.form | 73 ----- .../groovy/config/ui/GroovyFacetEditor.java | 254 ------------------ .../groovy/gant/GantLibraryManager.java | 5 - .../gant/GantLibraryPresentationProvider.java | 43 +++ .../gpp/GppLibraryPresentationProvider.java | 43 +++ .../GradleLibraryPresentationProvider.java | 43 +++ 39 files changed, 746 insertions(+), 929 deletions(-) create mode 100644 java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java create mode 100644 java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddCustomLibraryDialog.java create mode 100644 java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryActionBase.java create mode 100644 java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryDownloadDescription.java create mode 100644 platform/util/src/com/intellij/util/ParametrizedRunnable.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.form delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.java delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.form delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleLibraryPresentationProvider.java diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java index 7d06f0346c4e..46e0717a483f 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java @@ -18,6 +18,7 @@ package com.intellij.facet.impl.ui.libraries; import com.intellij.facet.ui.libraries.LibraryDownloadInfo; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.project.ProjectBundle; +import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.ui.CheckBoxList; @@ -45,13 +46,15 @@ public class DownloadingOptionsDialog extends DialogWrapper { private JPanel myNameWrappingPanel; private final LibraryCompositionSettings mySettings; private final LibraryNameAndLevelPanel myNameAndLevelPanel; + private LibraryDownloadDescription myDownloadDescription; protected DownloadingOptionsDialog(Component parent, LibraryCompositionSettings settings) { super(parent, true); setTitle("Downloading Options"); mySettings = settings; - final List downloads = settings.getLibraryDescription().getDownloads(); + myDownloadDescription = settings.getLibraryDescription().getDownloadDescription(); + final List downloads = myDownloadDescription.getDownloads(); myFilesList.setModel(new CollectionListModel(ContainerUtil.map2Array(downloads, JCheckBox.class, new Function() { @Override public JCheckBox fun(LibraryDownloadInfo libraryInfo) { @@ -92,7 +95,7 @@ public class DownloadingOptionsDialog extends DialogWrapper { mySettings.setDirectoryForDownloadedLibrariesPath(myDirectoryField.getText()); List selected = new ArrayList(); - List downloads = mySettings.getLibraryDescription().getDownloads(); + List downloads = myDownloadDescription.getDownloads(); for (int i = 0; i < downloads.size(); i++) { if (myFilesList.isItemSelected(i)) { selected.add(downloads.get(i)); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java index 16390a0dac74..ef42f6c3956a 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java @@ -24,18 +24,12 @@ import com.intellij.facet.ui.libraries.FacetLibrariesValidator; import com.intellij.facet.ui.libraries.FacetLibrariesValidatorDescription; import com.intellij.facet.ui.libraries.LibraryInfo; import com.intellij.ide.IdeBundle; +import com.intellij.openapi.roots.ui.configuration.libraries.AddCustomLibraryDialog; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; import com.intellij.ide.util.frameworkSupport.CustomLibraryDescriptionImpl; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ModuleRootModel; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; @@ -93,10 +87,8 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { String missingJars = IdeBundle.message("label.missed.libraries.prefix") + " " + info.getMissingJarsText(); LibraryInfo[] missingLibraries = info.getLibraryInfos(); - VirtualFile baseDir = myContext.getModule().getProject().getBaseDir(); - final String baseDirPath = baseDir != null ? baseDir.getPath() : ""; CustomLibraryDescription description = new CustomLibraryDescriptionImpl(missingLibraries, myDescription.getDefaultLibraryName()); - return new ValidationResult(missingJars, new LibrariesQuickFix(description, baseDirPath)); + return new ValidationResult(missingJars, new LibrariesQuickFix(description)); } private void onChange() { @@ -126,59 +118,19 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { } private class LibrariesQuickFix extends FacetConfigurationQuickFix { - private String myBaseDirPath; private CustomLibraryDescription myDescription; - public LibrariesQuickFix(CustomLibraryDescription description, String baseDirPath) { + public LibrariesQuickFix(CustomLibraryDescription description) { super(IdeBundle.message("missing.libraries.fix.button")); myDescription = description; - myBaseDirPath = baseDirPath; } public void run(final JComponent place) { - final LibraryCompositionSettings settings = new LibraryCompositionSettings(myDescription, myBaseDirPath); - LibraryOptionsPanel panel = new LibraryOptionsPanel(settings, myContext.getLibrariesContainer(), false); - LibraryCompositionDialog dialog = new LibraryCompositionDialog(place, panel); + AddCustomLibraryDialog dialog = AddCustomLibraryDialog.createDialog(myDescription, myContext.getLibrariesContainer(), + myContext.getModule(), myContext.getModifiableRootModel(), null); dialog.show(); - Disposer.dispose(settings); + myAddedLibraries.addAll(dialog.getAddedLibraries()); onChange(); } } - - private class LibraryCompositionDialog extends DialogWrapper { - private final LibraryOptionsPanel myPanel; - - private LibraryCompositionDialog(final JComponent parent, final LibraryOptionsPanel panel) { - super(parent, true); - setTitle(IdeBundle.message("specify.libraries.dialog.title")); - myPanel = panel; - init(); - } - - protected JComponent createCenterPanel() { - return myPanel.getMainPanel(); - } - - protected void doOKAction() { - myPanel.apply(); - final LibraryCompositionSettings settings = myPanel.getSettings(); - final LibrariesContainer librariesContainer = myContext.getLibrariesContainer(); - if (settings.downloadFiles(myPanel.getMainPanel())) { - ModifiableRootModel rootModel = myContext.getModifiableRootModel(); - if (rootModel == null) { - final ModifiableRootModel model = ModuleRootManager.getInstance(myContext.getModule()).getModifiableModel(); - new WriteAction() { - protected void run(final Result result) { - settings.addLibraries(model, myAddedLibraries, librariesContainer); - model.commit(); - } - }.execute(); - } - else { - settings.addLibraries(rootModel, myAddedLibraries, librariesContainer); - } - super.doOKAction(); - } - } - } } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java index b1d1e30a59c7..e8f04d22cded 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java @@ -16,11 +16,12 @@ package com.intellij.facet.impl.ui.libraries; import com.intellij.facet.ui.libraries.LibraryDownloadInfo; -import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; import com.intellij.openapi.Disposable; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor; import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; @@ -58,8 +59,11 @@ public class LibraryCompositionSettings implements Disposable { final @NotNull String baseDirectoryForDownloadedFiles) { myLibraryDescription = libraryDescription; myBaseDirectoryForDownloadedFiles = baseDirectoryForDownloadedFiles; - myDownloadedLibraryName = libraryDescription.getDefaultLibraryName(); - mySelectedDownloads = myLibraryDescription.getDownloads(); + final LibraryDownloadDescription downloadDescription = myLibraryDescription.getDownloadDescription(); + if (downloadDescription != null) { + myDownloadedLibraryName = downloadDescription.getDefaultLibraryName(); + mySelectedDownloads = downloadDescription.getDownloads(); + } } public ExistingLibraryEditor getOrCreateEditor(@NotNull Library library) { @@ -118,20 +122,19 @@ public class LibraryCompositionSettings implements Disposable { } public boolean downloadFiles(final @NotNull JComponent parent) { - if (myDownloadLibraries) { - if (!myLibraryDescription.getDownloads().isEmpty()) { - LibraryDownloadInfo[] toDownload = mySelectedDownloads.toArray(new LibraryDownloadInfo[mySelectedDownloads.size()]); - LibraryDownloader downloader = new LibraryDownloader(toDownload, null, parent, - getDirectoryForDownloadedLibrariesPath(), myDownloadedLibraryName); - VirtualFile[] files = downloader.download(); - if (files.length != toDownload.length) { - return false; - } - myNewLibraryEditor = new NewLibraryEditor(); - myNewLibraryEditor.setName(myDownloadedLibraryName); - for (VirtualFile file : files) { - myNewLibraryEditor.addRoot(file, OrderRootType.CLASSES); - } + final LibraryDownloadDescription downloadDescription = myLibraryDescription.getDownloadDescription(); + if (myDownloadLibraries && downloadDescription != null) { + LibraryDownloadInfo[] toDownload = mySelectedDownloads.toArray(new LibraryDownloadInfo[mySelectedDownloads.size()]); + LibraryDownloader downloader = new LibraryDownloader(toDownload, null, parent, + getDirectoryForDownloadedLibrariesPath(), myDownloadedLibraryName); + VirtualFile[] files = downloader.download(); + if (files.length != toDownload.length) { + return false; + } + myNewLibraryEditor = new NewLibraryEditor(); + myNewLibraryEditor.setName(myDownloadedLibraryName); + for (VirtualFile file : files) { + myNewLibraryEditor.addRoot(file, OrderRootType.CLASSES); } } return true; diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java index 52bed37b26cb..b25b0093d3e2 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java @@ -20,6 +20,7 @@ import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.ui.configuration.ProjectStructureDialogCellAppearanceUtils; +import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription; import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; @@ -126,7 +127,7 @@ public class LibraryOptionsPanel { }); myExistingLibraryComboBox.setRenderer(new LibraryListCellRenderer()); - boolean canDownload = !mySettings.getLibraryDescription().getDownloads().isEmpty(); + boolean canDownload = mySettings.getLibraryDescription().getDownloadDescription() != null; myDownloadRadioButton.setVisible(canDownload); myButtonEnumModel.setSelected(libraries.isEmpty() && canDownload ? Choice.DOWNLOAD : Choice.USE_LIBRARY); @@ -241,7 +242,7 @@ public class LibraryOptionsPanel { showConfigurePanel = false; } - if (!showConfigurePanel) { + if (!showConfigurePanel && mySettings.getLibraryDescription().getDownloadDescription() != null) { //show the longest message on the hidden card to ensure that dialog won't jump if user selects another option message = getDownloadFilesMessage(); } @@ -259,9 +260,10 @@ public class LibraryOptionsPanel { else { path = PathUtil.getFileName(downloadPath); } + final LibraryDownloadDescription downloadDescription = mySettings.getLibraryDescription().getDownloadDescription(); return MessageFormat.format("{0} jar(s) will be downloaded into {1} directory
" + "{2} library {3} will be created", - mySettings.getLibraryDescription().getDownloads().size(), + downloadDescription.getDownloads().size(), path, mySettings.getLibraryLevel(), mySettings.getDownloadedLibraryName()); diff --git a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java index 8e74086bb224..b3b49964aae7 100644 --- a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java +++ b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java @@ -23,6 +23,7 @@ import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription; import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; import com.intellij.openapi.util.Condition; @@ -40,16 +41,17 @@ import java.util.List; public class CustomLibraryDescriptionImpl extends CustomLibraryDescription { private final LibraryInfo[] myLibraryInfos; private String myDefaultLibraryName; - private final List myDownloads; + private final LibraryDownloadDescription myDownloadDescription; private final Condition> mySuitableLibraryCondition; public CustomLibraryDescriptionImpl(@NotNull LibraryInfo[] libraryInfos, @NotNull String defaultLibraryName) { myLibraryInfos = libraryInfos; myDefaultLibraryName = defaultLibraryName; - myDownloads = new ArrayList(); + List downloads = new ArrayList(); for (LibraryInfo info : libraryInfos) { - ContainerUtil.addIfNotNull(myDownloads, info.getDownloadingInfo()); + ContainerUtil.addIfNotNull(downloads, info.getDownloadingInfo()); } + myDownloadDescription = !downloads.isEmpty() ? new LibraryDownloadDescription(defaultLibraryName, downloads) : null; mySuitableLibraryCondition = new Condition>() { @Override public boolean value(List virtualFiles) { @@ -59,16 +61,9 @@ public class CustomLibraryDescriptionImpl extends CustomLibraryDescription { }; } - @NotNull @Override - public String getDefaultLibraryName() { - return myDefaultLibraryName; - } - - @NotNull - @Override - public List getDownloads() { - return myDownloads; + public LibraryDownloadDescription getDownloadDescription() { + return myDownloadDescription; } @NotNull diff --git a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java new file mode 100644 index 000000000000..d3f0414f4293 --- /dev/null +++ b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.util.frameworkSupport; + +import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import org.jetbrains.annotations.NotNull; + +/** + * @author nik + */ +public class FrameworkVersionWithLibrary extends FrameworkVersion { + private CustomLibraryDescription myLibraryDescription; + + public FrameworkVersionWithLibrary(@NotNull String versionName, boolean isDefault, CustomLibraryDescription libraryDescription) { + super(versionName, isDefault); + myLibraryDescription = libraryDescription; + } + + public CustomLibraryDescription getLibraryDescription() { + return myLibraryDescription; + } +} diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index 06371ae1b9af..9e0233c5beaf 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -173,29 +173,35 @@ public class AddSupportForFrameworksPanel implements Disposable { optionsPanel.add(separator); final FrameworkSupportConfigurable configurable = node.getConfigurable(); - optionsPanel.add(configurable.getComponent()); + final JComponent component = configurable.getComponent(); + if (component != null) { + optionsPanel.add(component); + } + final boolean addSeparator = component != null; final JPanel librariesOptionsPanelWrapper = new JPanel(new BorderLayout()); optionsPanel.add(librariesOptionsPanelWrapper); configurable.addListener(new FrameworkSupportConfigurableListener() { public void frameworkVersionChanged() { librariesOptionsPanelWrapper.removeAll(); - addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper); + addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper, addSeparator); librariesOptionsPanelWrapper.revalidate(); } }); - addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper); + addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper, addSeparator); myOptionsPanel.add(id, optionsPanel); myInitializedOptionsPanelIds.add(id); } } - private void addLibrariesOptionsPanel(FrameworkSupportNode node, JPanel librariesOptionsPanelWrapper) { + private void addLibrariesOptionsPanel(FrameworkSupportNode node, JPanel librariesOptionsPanelWrapper, boolean addSeparator) { final LibraryOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer); if (libraryOptionsPanel != null) { - JComponent separator = SeparatorFactory.createSeparator("Libraries", null); - separator.setBorder(IdeBorderFactory.createEmptyBorder(5, 0, 5, 5)); - librariesOptionsPanelWrapper.add(BorderLayout.NORTH, separator); + if (addSeparator) { + JComponent separator = SeparatorFactory.createSeparator("Libraries", null); + separator.setBorder(IdeBorderFactory.createEmptyBorder(5, 0, 5, 5)); + librariesOptionsPanelWrapper.add(BorderLayout.NORTH, separator); + } librariesOptionsPanelWrapper.add(BorderLayout.CENTER, libraryOptionsPanel.getMainPanel()); } } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java index bf3d233d97e3..35d7590628af 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java @@ -76,6 +76,10 @@ public class FrameworkSupportNode extends CheckedTreeNode { FrameworkVersion version = myConfigurable.getSelectedVersion(); if (version == null) return null; + if (version instanceof FrameworkVersionWithLibrary) { + return ((FrameworkVersionWithLibrary)version).getLibraryDescription(); + } + CustomLibraryDescription description = myLibraryDescriptions.get(version); if (description == null) { description = new CustomLibraryDescriptionImpl(version.getLibraries(), StringUtil.notNullize(version.getLibraryName())); @@ -89,7 +93,7 @@ public class FrameworkSupportNode extends CheckedTreeNode { final LibraryCompositionSettings libraryCompositionSettings = getLibraryCompositionSettings(); if (myLibraryCompositionOptionsPanel == null || !myLibraryCompositionOptionsPanel.getSettings().equals(libraryCompositionSettings)) { if (libraryCompositionSettings != null) { - myLibraryCompositionOptionsPanel = new LibraryOptionsPanel(libraryCompositionSettings, librariesContainer, true); + myLibraryCompositionOptionsPanel = new LibraryOptionsPanel(libraryCompositionSettings, librariesContainer, myConfigurable.getComponent() != null); } else { myLibraryCompositionOptionsPanel = null; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddCustomLibraryDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddCustomLibraryDialog.java new file mode 100644 index 000000000000..bf126b2f4436 --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddCustomLibraryDialog.java @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.ui.configuration.libraries; + +import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings; +import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel; +import com.intellij.ide.IdeBundle; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; +import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory; +import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.ParametrizedRunnable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; + +/** +* @author nik +*/ +public class AddCustomLibraryDialog extends DialogWrapper { + private final LibraryOptionsPanel myPanel; + private final LibrariesContainer myLibrariesContainer; + private final Module myModule; + private final ModifiableRootModel myModifiableRootModel; + private final @Nullable ParametrizedRunnable myBeforeLibraryAdded; + private final List myAddedLibraries = new ArrayList(); + + private AddCustomLibraryDialog(CustomLibraryDescription description, LibrariesContainer librariesContainer, + Module module, + ModifiableRootModel modifiableRootModel, + @Nullable ParametrizedRunnable beforeLibraryAdded) { + super(module.getProject(), true); + myLibrariesContainer = librariesContainer; + myModule = module; + myModifiableRootModel = modifiableRootModel; + myBeforeLibraryAdded = beforeLibraryAdded; + setTitle(IdeBundle.message("setup.library.dialog.title")); + VirtualFile baseDir = myModule.getProject().getBaseDir(); + final String baseDirPath = baseDir != null ? baseDir.getPath() : ""; + myPanel = new LibraryOptionsPanel(new LibraryCompositionSettings(description, baseDirPath), myLibrariesContainer, false); + init(); + } + + public static AddCustomLibraryDialog createDialog(@NotNull CustomLibraryDescription description, + final @NotNull Module module, + final ParametrizedRunnable beforeLibraryAdded) { + return createDialog(description, LibrariesContainerFactory.createContainer(module), module, null, beforeLibraryAdded); + } + + public static AddCustomLibraryDialog createDialog(CustomLibraryDescription description, + final @NotNull LibrariesContainer librariesContainer, final @NotNull Module module, + final @Nullable ModifiableRootModel modifiableRootModel, + @Nullable ParametrizedRunnable beforeLibraryAdded) { + return new AddCustomLibraryDialog(description, librariesContainer, module, modifiableRootModel, beforeLibraryAdded); + } + + protected JComponent createCenterPanel() { + return myPanel.getMainPanel(); + } + + protected void doOKAction() { + myPanel.apply(); + if (myPanel.getSettings().downloadFiles(myPanel.getMainPanel())) { + if (myModifiableRootModel == null) { + final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel(); + new WriteAction() { + protected void run(final Result result) { + addLibraries(model); + model.commit(); + } + }.execute(); + } + else { + addLibraries(myModifiableRootModel); + } + super.doOKAction(); + } + } + + private void addLibraries(ModifiableRootModel model) { + if (myBeforeLibraryAdded != null) { + myBeforeLibraryAdded.run(model); + } + myPanel.getSettings().addLibraries(model, myAddedLibraries, myLibrariesContainer); + } + + public List getAddedLibraries() { + return myAddedLibraries; + } +} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddExistingCustomLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddExistingCustomLibraryAction.java index e87e18facf94..763d6df14404 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddExistingCustomLibraryAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddExistingCustomLibraryAction.java @@ -17,7 +17,6 @@ package com.intellij.openapi.roots.ui.configuration.libraries; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.libraries.Library; @@ -29,24 +28,25 @@ import javax.swing.*; /** * @author nik */ -public class AddExistingCustomLibraryAction extends DumbAwareAction { +public class AddExistingCustomLibraryAction extends CustomLibraryActionBase { private Library myLibrary; - private StructureConfigurableContext myContext; - private ModuleStructureConfigurable myModuleStructureConfigurable; - private Module myModule; - public AddExistingCustomLibraryAction(Library library, Icon icon, StructureConfigurableContext context, - ModuleStructureConfigurable moduleStructureConfigurable, Module module) { - super(library.getName(), null, icon); + public AddExistingCustomLibraryAction(Library library, + Icon icon, + CustomLibraryCreator creator, + StructureConfigurableContext context, + ModuleStructureConfigurable moduleStructureConfigurable, + Module module) { + super(library.getName(), null, icon, context, moduleStructureConfigurable, creator, module); myLibrary = library; - myContext = context; - myModuleStructureConfigurable = moduleStructureConfigurable; - myModule = module; } @Override public void actionPerformed(AnActionEvent e) { final ModifiableRootModel rootModel = myContext.getModulesConfigurator().getOrCreateModuleEditor(myModule).getModifiableRootModelProxy(); + if (!askAndRemoveDuplicatedLibraryEntry(myCreator.getDescription(), rootModel)) { + return; + } final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(myLibrary); myModuleStructureConfigurable.selectOrderEntry(myModule, orderEntry); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CreateCustomLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CreateCustomLibraryAction.java index d3df40c6bbf8..6fab61fa26ba 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CreateCustomLibraryAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CreateCustomLibraryAction.java @@ -22,7 +22,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.ModifiableRootModel; @@ -44,20 +43,11 @@ import java.util.*; /** * @author nik */ -public class CreateCustomLibraryAction extends DumbAwareAction { - private final CustomLibraryCreator myCreator; - private StructureConfigurableContext myContext; - private ModuleStructureConfigurable myModuleStructureConfigurable; - private Module myModule; - +public class CreateCustomLibraryAction extends CustomLibraryActionBase { public CreateCustomLibraryAction(final String name, CustomLibraryCreator creator, StructureConfigurableContext context, ModuleStructureConfigurable moduleStructureConfigurable, Module module) { - super(name, null, creator.getIcon()); - myCreator = creator; - myContext = context; - myModuleStructureConfigurable = moduleStructureConfigurable; - myModule = module; + super(name, null, creator.getIcon(), context, moduleStructureConfigurable, creator, module); } @Override @@ -79,6 +69,9 @@ public class CreateCustomLibraryAction extends DumbAwareAction { if (dialog.isOK()) { final Library library = dialog.createLibrary(myContext.getModifiableLibraryTable(dialog.getSelectedTable())); final ModifiableRootModel rootModel = myContext.getModulesConfigurator().getOrCreateModuleEditor(myModule).getModifiableRootModelProxy(); + if (!askAndRemoveDuplicatedLibraryEntry(myCreator.getDescription(), rootModel)) { + return; + } final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(library); myModuleStructureConfigurable.selectOrderEntry(myModule, orderEntry); } @@ -112,7 +105,7 @@ public class CreateCustomLibraryAction extends DumbAwareAction { group.add(new CreateCustomLibraryAction("New...", creator, context, moduleStructureConfigurable, module)); for (Library library : librariesToAdd) { Icon icon = LibraryPresentationManager.getInstance().getNamedLibraryIcon(library, context); - group.add(new AddExistingCustomLibraryAction(library, icon, context, moduleStructureConfigurable, module)); + group.add(new AddExistingCustomLibraryAction(library, icon, creator, context, moduleStructureConfigurable, module)); } actions.add(group); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryActionBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryActionBase.java new file mode 100644 index 000000000000..c72d71e0a3d2 --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryActionBase.java @@ -0,0 +1,88 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.ui.configuration.libraries; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.roots.LibraryOrderEntry; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.OrderEntry; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author nik + */ +public abstract class CustomLibraryActionBase extends DumbAwareAction { + protected final CustomLibraryCreator myCreator; + protected final StructureConfigurableContext myContext; + protected final ModuleStructureConfigurable myModuleStructureConfigurable; + protected Module myModule; + + protected CustomLibraryActionBase(String text, String description, Icon icon, StructureConfigurableContext context, + ModuleStructureConfigurable moduleStructureConfigurable, CustomLibraryCreator creator, Module module) { + super(text, description, icon); + myContext = context; + myModuleStructureConfigurable = moduleStructureConfigurable; + myCreator = creator; + myModule = module; + } + + protected boolean askAndRemoveDuplicatedLibraryEntry(@NotNull CustomLibraryDescription description, @NotNull ModifiableRootModel rootModel) { + List existingEntries = new ArrayList(); + for (OrderEntry entry : rootModel.getOrderEntries()) { + if (!(entry instanceof LibraryOrderEntry)) continue; + final Library library = ((LibraryOrderEntry)entry).getLibrary(); + if (library == null) continue; + + final VirtualFile[] files = myContext.getLibraryFiles(library, OrderRootType.CLASSES); + if (description.getSuitableLibraryCondition().value(Arrays.asList(files))) { + existingEntries.add(entry); + } + } + + if (!existingEntries.isEmpty()) { + String message; + if (existingEntries.size() > 1) { + message = "There are already " + existingEntries.size() + " " + myCreator.getDisplayName() + " libraries.\n Do you want to replace they?"; + } + else { + final String name = existingEntries.get(0).getPresentableName(); + message = "There is already a " + myCreator.getDisplayName() + " library '" + name + "'.\n Do you want to replace it?"; + } + final int result = Messages.showDialog(rootModel.getProject(), message, "Library Already Exists", new String[]{"&Replace", "&Add", "&Cancel"}, 0, null); + if (result == 0) { + for (OrderEntry entry : existingEntries) { + rootModel.removeOrderEntry(entry); + } + } + else if (result != 1) { + return false; + } + } + return true; + } +} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryDescription.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryDescription.java index 680db3b23ae7..c63eefb73239 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryDescription.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryDescription.java @@ -15,26 +15,21 @@ */ package com.intellij.openapi.roots.ui.configuration.libraries; -import com.intellij.facet.ui.libraries.LibraryDownloadInfo; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.Collections; import java.util.List; /** * @author nik */ public abstract class CustomLibraryDescription { - @NotNull - public abstract String getDefaultLibraryName(); - - @NotNull - public List getDownloads() { - return Collections.emptyList(); + @Nullable + public LibraryDownloadDescription getDownloadDescription() { + return null; } @NotNull diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryDownloadDescription.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryDownloadDescription.java new file mode 100644 index 000000000000..10d8bcb6eb3f --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryDownloadDescription.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.ui.configuration.libraries; + +import com.intellij.facet.ui.libraries.LibraryDownloadInfo; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author nik + */ +public class LibraryDownloadDescription { + private final String myDefaultLibraryName; + private final List myDownloads; + + public LibraryDownloadDescription(@NotNull String defaultLibraryName, @NotNull List downloads) { + myDefaultLibraryName = defaultLibraryName; + myDownloads = downloads; + } + + @NotNull + public String getDefaultLibraryName() { + return myDefaultLibraryName; + } + + @NotNull + public List getDownloads() { + return myDownloads; + } +} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java index c0699a7c99c2..ed56d1f747f8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationManager.java @@ -54,4 +54,6 @@ public abstract class LibraryPresentationManager { public abstract List getLibraries(@NotNull Set> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context); public abstract boolean isLibraryOfKind(@NotNull List files, @NotNull LibraryKind kind); + + public abstract boolean isLibraryOfKind(@NotNull List files, @NotNull Set> acceptedKinds); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java index 88d0b7b2202c..1e00ecdfd78d 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java @@ -92,6 +92,16 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { }); } + @Override + public boolean isLibraryOfKind(@NotNull List files, @NotNull final Set> acceptedKinds) { + return !LibraryDetectionManager.getInstance().processProperties(files, new LibraryDetectionManager.LibraryPropertiesProcessor() { + @Override + public

boolean processProperties(@NotNull LibraryKind

processedKind, @NotNull P properties) { + return !acceptedKinds.contains(processedKind); + } + }); + } + public static List> getLibraryKinds(@NotNull Library library, StructureConfigurableContext context) { final List> result = new SmartList>(); final VirtualFile[] files = getLibraryFiles(library, context); diff --git a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurable.java b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurable.java index b4374ea7dec4..38376933a182 100644 --- a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurable.java +++ b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurable.java @@ -37,8 +37,8 @@ public abstract class FrameworkSupportConfigurable implements Disposable { public abstract void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, final @Nullable Library library); - @SuppressWarnings({"ConstantConditions"}) public FrameworkVersion getSelectedVersion() { + //noinspection ConstantConditions return null; } diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 337c558e427f..cbd0908d87e9 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -977,7 +977,7 @@ error.library.download.failed=Library downloading failed: {0} label.missed.libraries.prefix=The following libraries are missing: label.missed.libraries.text={0}.
Class ''{1}'' not found missing.libraries.fix.button=Fix... -specify.libraries.dialog.title=Specify Libraries +setup.library.dialog.title=Setup Library new.library.file.chooser.title=New Library Files new.library.file.chooser.description=Select jar files in which library classes are located file.chooser.show.path=Show path diff --git a/platform/util/src/com/intellij/util/ParametrizedRunnable.java b/platform/util/src/com/intellij/util/ParametrizedRunnable.java new file mode 100644 index 000000000000..84b449456a40 --- /dev/null +++ b/platform/util/src/com/intellij/util/ParametrizedRunnable.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util; + +/** + * @author nik + */ +public interface ParametrizedRunnable { + void run(T t); +} diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 72f4e8d8ada7..36cd6d203e5f 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -108,6 +108,9 @@ + + + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties index abf41cac5b34..d9fe9da204c5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties @@ -309,20 +309,8 @@ continue.outside.loop=The continue statement is only allowed inside loops break.outside.loop.or.switch=The break statement is only allowed inside loops or switches label.already.used=Label ''{0}'' is already in use break.outside.loop=The break statement with named labels is only allowed inside loops -######################################################################################################################## -# Facet configuration -######################################################################################################################## -new.button.label=New -groovy.sdk.configuration.label=Groovy SDK:
Choose Groovy SDK specific for this module -add.new.groovy.lib=New SDK -invalid.groovy.sdk.path.message=Invalid path to Groovy SDK -invalid.groovy.sdk.path.text=Wrong path specified -duplicate.groovy.lib.version=Duplicate Groovy SDK version -duplicate.groovy.lib.version.add=Add one more Groovy SDK of version {0}? -groovy.sdk.combo.box.project.item= + Constructor=Constructor -facet.create.project.lib=Create &Project Groovy library ''{0}'' -facet.create.application.lib=Create Glob&al Groovy library ''{0}'' groovy.like.library.found=Groovy library found groovy.like.library.found.text=Do you want to set up Groovy for module ''{0}'' \n\ with found library ''{1}'' (Groovy version {2})? diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/AbstractGroovyLibraryManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/AbstractGroovyLibraryManager.java index 14094ce5f3e2..ee95865323cc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/AbstractGroovyLibraryManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/AbstractGroovyLibraryManager.java @@ -15,34 +15,8 @@ */ package org.jetbrains.plugins.groovy.config; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; -import com.intellij.openapi.roots.libraries.LibraryUtil; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; -import com.intellij.openapi.roots.ui.configuration.projectRoot.GlobalLibrariesConfigurable; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectLibrariesConfigurable; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.CollectionFactory; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.config.ui.CreateLibraryDialog; - -import javax.swing.*; -import java.util.List; -import java.util.Set; /** * @author peter @@ -50,104 +24,5 @@ import java.util.Set; public abstract class AbstractGroovyLibraryManager extends LibraryManager { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("org.intellij.groovy.libraryManager"); - @NotNull - private static String generatePointerName(final String defaultName, final Set usedLibraryNames) { - String newName = defaultName; - int index = 1; - while (usedLibraryNames.contains(newName)) { - newName = defaultName + " (" + index + ")"; - index++; - } - return newName; - } - - public Icon getDialogIcon() { - return getIcon(); - } - - private void fillLibrary(String path, Library.ModifiableModel model) { - NewLibraryEditor editor = new NewLibraryEditor(); - editor.setName(model.getName()); - fillLibrary(path, editor); - editor.apply(model); - } - protected abstract void fillLibrary(String path, LibraryEditor libraryEditor); - - @Nullable - private Library createSDKLibrary(final String path, - final String name, - final Project project, - final boolean inModuleSettings, - final boolean inProject) { - Library library; - final Library.ModifiableModel model; - LibraryTable.ModifiableModel globalModel = null; - if (inModuleSettings) { - globalModel = project != null && inProject ? - ProjectLibrariesConfigurable.getInstance(project).getModelProvider().getModifiableModel() : - GlobalLibrariesConfigurable.getInstance(project).getModelProvider().getModifiableModel(); - assert globalModel != null; - library = globalModel.createLibrary(name); - model = ((LibrariesModifiableModel)globalModel).getLibraryEditor(library).getModel(); - } else { - LibraryTable table = - project != null && inProject ? ProjectLibraryTable.getInstance(project) : LibraryTablesRegistrar.getInstance().getLibraryTable(); - library = LibraryUtil.createLibrary(table, name); - model = library.getModifiableModel(); - } - - assert library != null; - - - fillLibrary(path, model); - - - if (!inModuleSettings) { - model.commit(); - } - else { - globalModel.commit(); - } - - return library; - } - - @Nullable - public Library createLibrary(@NotNull final String path, final LibrariesContainer container, final boolean inModuleSettings) { - final List versions = CollectionFactory.arrayList(); - final Set usedLibraryNames = CollectionFactory.newTroveSet(); - for (Library library : container.getAllLibraries()) { - usedLibraryNames.add(library.getName()); - final VirtualFile[] libraryFiles = container.getLibraryFiles(library, OrderRootType.CLASSES); - if (managesLibrary(libraryFiles)) { - ContainerUtil.addIfNotNull(getLibraryVersion(libraryFiles), versions); - } - } - - final String newVersion = getSDKVersion(path); - final String libraryKind = getLibraryCategoryName(); - - boolean addVersion = !versions.contains(newVersion) || - Messages.showOkCancelDialog("Add one more " + libraryKind + " library of version " + newVersion + "?", - "Duplicate library version", getDialogIcon()) == 0; - - if (addVersion && !AbstractConfigUtils.UNDEFINED_VERSION.equals(newVersion)) { - final Project project = container.getProject(); - final String name = generatePointerName(getLibraryPrefix() + "-" + newVersion, usedLibraryNames); - final CreateLibraryDialog dialog = new CreateLibraryDialog(project, "Create " + libraryKind + " library", - "Create Project " + libraryKind + " library '" + name + "'", - "Create Global " + libraryKind + " library '" + name + "'"); - dialog.show(); - if (dialog.isOK()) { - return ApplicationManager.getApplication().runWriteAction(new Computable() { - @Nullable - public Library compute() { - return createSDKLibrary(path, name, project, inModuleSettings, dialog.isInProject()); - } - }); - } - } - return null; - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyFacetSupportProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyFacetSupportProvider.java index 30077b3a474f..972888068745 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyFacetSupportProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyFacetSupportProvider.java @@ -22,7 +22,6 @@ import com.intellij.ide.util.projectWizard.ModuleBuilder; import com.intellij.openapi.module.ModuleType; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyIcons; -import org.jetbrains.plugins.groovy.config.ui.GroovyFacetEditor; import org.jetbrains.plugins.groovy.util.GroovyUtils; import javax.swing.*; @@ -47,7 +46,7 @@ public class GroovyFacetSupportProvider extends FrameworkSupportProvider { @NotNull public FrameworkSupportConfigurable createConfigurable(final @NotNull FrameworkSupportModel model) { - return new GroovySupportConfigurable(new GroovyFacetEditor(model.getProject())); + return new GroovySupportConfigurable(); } public boolean isEnabledForModuleType(@NotNull ModuleType moduleType) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java index ec67b3ac419d..6077a9dea5c4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryCreator.java @@ -15,21 +15,12 @@ */ package org.jetbrains.plugins.groovy.config; -import com.intellij.openapi.fileChooser.FileChooser; -import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryCreator; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; -import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager; -import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; -import com.intellij.openapi.util.Condition; -import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyIcons; -import org.jetbrains.plugins.groovy.config.ui.GroovyFacetEditor; import javax.swing.*; -import java.util.List; /** * @author nik @@ -56,52 +47,4 @@ public class GroovyLibraryCreator extends CustomLibraryCreator { public CustomLibraryDescription getDescription() { return myDescription; } - - private static class GroovyLibraryDescription extends CustomLibraryDescription { - private final Condition> myCondition; - - public GroovyLibraryDescription() { - myCondition = new Condition>() { - @Override - public boolean value(List virtualFiles) { - return LibraryPresentationManager.getInstance().isLibraryOfKind(virtualFiles, GroovyLibraryPresentationProvider.GROOVY_KIND); - } - }; - } - - @NotNull - @Override - public String getDefaultLibraryName() { - return "xxx"; - } - - @NotNull - @Override - public Condition> getSuitableLibraryCondition() { - return myCondition; - } - - @Override - public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) { - final VirtualFile[] files = FileChooser.chooseFiles(parentComponent, FileChooserDescriptorFactory.createSingleFolderDescriptor()); - if (files.length != 1) return null; - - final VirtualFile dir = files[0]; - final AbstractGroovyLibraryManager manager = GroovyFacetEditor.findManager(dir); - if (manager == null) return null; - - final String path = dir.getPath(); - final String sdkVersion = manager.getSDKVersion(path); - if (AbstractConfigUtils.UNDEFINED_VERSION.equals(sdkVersion)) { - return null; - } - - return new NewLibraryConfiguration(manager.getLibraryPrefix() + "-" + sdkVersion) { - @Override - public void addRoots(@NotNull LibraryEditor editor) { - manager.fillLibrary(path, editor); - } - }; - } - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java new file mode 100644 index 000000000000..36acf4a3b6a7 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java @@ -0,0 +1,135 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.config; + +import com.intellij.openapi.fileChooser.FileChooser; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.openapi.roots.libraries.LibraryKind; +import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; +import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager; +import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration; +import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.util.GroovyUtils; + +import javax.swing.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** +* @author nik +*/ +public class GroovyLibraryDescription extends CustomLibraryDescription { + private final Condition> myCondition; + private String myEnvVariable; + + public GroovyLibraryDescription() { + this("GROOVY_HOME", getAllGroovyKinds()); + } + + private static Set> getAllGroovyKinds() { + final HashSet> kinds = new HashSet>(); + for (LibraryPresentationProvider provider : LibraryPresentationProvider.EP_NAME.getExtensions()) { + if (provider instanceof GroovyLibraryPresentationProviderBase) { + kinds.add(provider.getKind()); + } + } + return kinds; + } + + public GroovyLibraryDescription(@NotNull String envVariable, @NotNull LibraryKind libraryKind) { + this(envVariable, Collections.singleton(libraryKind)); + } + + public GroovyLibraryDescription(@NotNull String envVariable, @NotNull final Set> libraryKinds) { + myEnvVariable = envVariable; + myCondition = new Condition>() { + @Override + public boolean value(List virtualFiles) { + return LibraryPresentationManager.getInstance().isLibraryOfKind(virtualFiles, libraryKinds); + } + }; + } + + @Nullable + public static AbstractGroovyLibraryManager findManager(VirtualFile dir) { + if (GroovyUtils.getFilesInDirectoryByPattern(dir.getPath() + "/lib", "groovy.*\\.jar").length == 0) { + return null; + } + + final String name = dir.getName(); + + final AbstractGroovyLibraryManager[] managers = AbstractGroovyLibraryManager.EP_NAME.getExtensions(); + for (final AbstractGroovyLibraryManager manager : managers) { + if (manager.managesName(name) && manager.isSDKHome(dir)) { + return manager; + } + } + + for (final AbstractGroovyLibraryManager manager : managers) { + if (manager.isSDKHome(dir)) { + return manager; + } + } + return null; + } + + @NotNull + @Override + public Condition> getSuitableLibraryCondition() { + return myCondition; + } + + @Override + public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) { + final String envHome = System.getenv(myEnvVariable); + VirtualFile initial = null; + if (envHome != null && envHome.length() > 0) { + initial = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(envHome)); + } + + final VirtualFile[] files = FileChooser.chooseFiles(parentComponent, FileChooserDescriptorFactory.createSingleFolderDescriptor(), initial); + if (files.length != 1) return null; + + final VirtualFile dir = files[0]; + final AbstractGroovyLibraryManager manager = findManager(dir); + if (manager == null) { + //todo[nik,peter] show error message in file chooser + return null; + } + + final String path = dir.getPath(); + final String sdkVersion = manager.getSDKVersion(path); + if (AbstractConfigUtils.UNDEFINED_VERSION.equals(sdkVersion)) { + return null; + } + + return new NewLibraryConfiguration(manager.getLibraryPrefix() + "-" + sdkVersion) { + @Override + public void addRoots(@NotNull LibraryEditor editor) { + manager.fillLibrary(path, editor); + } + }; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryManager.java index 048465413d82..389af4793dc4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryManager.java @@ -82,11 +82,6 @@ public class GroovyLibraryManager extends AbstractGroovyLibraryManager { return GroovyConfigUtils.getInstance().getSDKVersion(path); } - @Override - public Icon getDialogIcon() { - return GroovyIcons.GROOVY_ICON_32x32; - } - @Nls @NotNull @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java index 45cd17473487..10b2c94680dc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java @@ -16,42 +16,25 @@ package org.jetbrains.plugins.groovy.config; import com.intellij.openapi.roots.libraries.LibraryKind; -import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.List; /** * @author nik */ -public class GroovyLibraryPresentationProvider extends LibraryPresentationProvider { +public class GroovyLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy"); + private GroovyLibraryManager myManager = new GroovyLibraryManager(); public GroovyLibraryPresentationProvider() { super(GROOVY_KIND); } @Override - public Icon getIcon(GroovyLibraryProperties properties) { - return properties.getManager().getIcon(); + public LibraryManager getLibraryManager() { + return myManager; } @Override - public String getDescription(@NotNull GroovyLibraryProperties properties) { - final String version = properties.getVersion(); - return properties.getManager().getLibraryCategoryName() + " library" + (version != null ? " of version " + version : ":"); - } - - @Override - public GroovyLibraryProperties detect(@NotNull List classesRoots) { - final VirtualFile[] libraryFiles = classesRoots.toArray(new VirtualFile[classesRoots.size()]); - final LibraryManager manager = LibraryManager.findManagerFor(AbstractGroovyLibraryManager.EP_NAME.getExtensions(), libraryFiles); - if (manager != null) { - final String version = manager.getLibraryVersion(libraryFiles); - return new GroovyLibraryProperties(manager, version); - } - return null; + protected boolean acceptManager(LibraryManager manager) { + return manager instanceof GroovyLibraryManager; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java new file mode 100644 index 000000000000..9e430e163910 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.config; + +import com.intellij.openapi.roots.libraries.LibraryKind; +import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.List; + +/** + * @author nik + */ +public abstract class GroovyLibraryPresentationProviderBase extends LibraryPresentationProvider { + public GroovyLibraryPresentationProviderBase(LibraryKind kind) { + super(kind); + } + + public abstract LibraryManager getLibraryManager(); + + @Override + public Icon getIcon(GroovyLibraryProperties properties) { + return getLibraryManager().getIcon(); + } + + @Override + public String getDescription(@NotNull GroovyLibraryProperties properties) { + final String version = properties.getVersion(); + return getLibraryManager().getLibraryCategoryName() + " library" + (version != null ? " of version " + version : ":"); + } + + @Override + public GroovyLibraryProperties detect(@NotNull List classesRoots) { + final VirtualFile[] libraryFiles = classesRoots.toArray(new VirtualFile[classesRoots.size()]); + final LibraryManager manager = LibraryManager.findManagerFor(AbstractGroovyLibraryManager.EP_NAME.getExtensions(), libraryFiles); + if (manager != null && acceptManager(manager)) { + final String version = manager.getLibraryVersion(libraryFiles); + return new GroovyLibraryProperties(version); + } + return null; + } + + protected abstract boolean acceptManager(LibraryManager manager); +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryProperties.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryProperties.java index b3625bf5d354..df1b9d63fb71 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryProperties.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryProperties.java @@ -22,18 +22,12 @@ import org.jetbrains.annotations.Nullable; * @author nik */ public class GroovyLibraryProperties extends LibraryProperties { - private LibraryManager myManager; private String myVersion; - public GroovyLibraryProperties(LibraryManager manager, String version) { - myManager = manager; + public GroovyLibraryProperties(String version) { myVersion = version; } - public LibraryManager getManager() { - return myManager; - } - @Nullable public String getVersion() { return myVersion; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovySupportConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovySupportConfigurable.java index 73d6cc455979..afe817da9f3d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovySupportConfigurable.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovySupportConfigurable.java @@ -16,147 +16,37 @@ package org.jetbrains.plugins.groovy.config; import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.ide.util.frameworkSupport.FrameworkVersion; +import com.intellij.ide.util.frameworkSupport.FrameworkVersionWithLibrary; import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.CollectionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.config.ui.GroovyFacetEditor; -import org.jetbrains.plugins.groovy.util.LibrariesUtil; import javax.swing.*; -import java.util.List; /** * @author peter */ public class GroovySupportConfigurable extends FrameworkSupportConfigurable { - private final GroovyFacetEditor facetEditor; + private FrameworkVersionWithLibrary myVersion; - public GroovySupportConfigurable(final GroovyFacetEditor facetEditor) { - this.facetEditor = facetEditor; + public GroovySupportConfigurable() { + } + + @Override + public FrameworkVersion getSelectedVersion() { + if (myVersion == null) { + myVersion = new FrameworkVersionWithLibrary("", true, new GroovyLibraryDescription()); + } + return myVersion; } - @NotNull public JComponent getComponent() { - return facetEditor.getComponent(); + return null; } public void addSupport(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel, @Nullable Library library) { - addGroovySupport(module, rootModel); - } - - private boolean cleanDuplicates(List managers, ModifiableRootModel rootModel, final LibrariesContainer container) { - if (managers.isEmpty()) return true; - - for (OrderEntry entry : rootModel.getOrderEntries()) { - if (entry instanceof LibraryOrderEntry) { - final Library library = ((LibraryOrderEntry)entry).getLibrary(); - if (library == null) { - cleanUndefinedGroovyLibrary(rootModel, (LibraryOrderEntry)entry); - } else { - final LibraryManager manager = LibraryManager.findManagerFor(library, managers.toArray(new LibraryManager[managers.size()]), container); - if (manager != null) { - @SuppressWarnings({"NonConstantStringShouldBeStringBuffer"}) - String message = "There is already a " + manager.getLibraryCategoryName() + " library"; - final String version = manager.getLibraryVersion(container.getLibraryFiles(library, OrderRootType.CLASSES)); - if (StringUtil.isNotEmpty(version)) { - message += " of version " + version; - } - message += ".\n Do you want to replace the existing one?"; - final String replace = "&Replace"; - final int result = - Messages - .showDialog(rootModel.getProject(), message, "Library already exists", new String[]{replace, "&Add", "&Cancel"}, 0, null); - if (result == 2 || result < 0) { - return false; //cancel or escape - } - - if (result == 0) { - rootModel.removeOrderEntry(entry); - } - } - } - } - } - return true; - } - - private static void cleanUndefinedGroovyLibrary(ModifiableRootModel rootModel, LibraryOrderEntry entry) { - final String libraryName = entry.getLibraryName(); - if (libraryName == null) { - return; - } - - for (AbstractGroovyLibraryManager each : AbstractGroovyLibraryManager.EP_NAME.getExtensions()) { - if (each.managesName(libraryName)) { - rootModel.removeOrderEntry(entry); - return; - } - } - } - - public void addGroovySupport(final Module module, ModifiableRootModel rootModel) { - final LibrariesContainer container = LibrariesContainerFactory.createContainer(rootModel); - - if (!facetEditor.addNewSdk()) { - final Library selectedLibrary = facetEditor.getSelectedLibrary(); - if (selectedLibrary != null) { - List suitable = CollectionFactory.arrayList(); - for (final LibraryManager manager : AbstractGroovyLibraryManager.EP_NAME.getExtensions()) { - if (manager.managesLibrary(container.getLibraryFiles(selectedLibrary, OrderRootType.CLASSES))) { - suitable.add(manager); - } - } - if (cleanDuplicates(suitable, rootModel, container)) { - LibrariesUtil.placeEntryToCorrectPlace(rootModel, rootModel.addLibraryEntry(selectedLibrary)); - } - } - return; - } - - final String path = facetEditor.getNewSdkPath(); - final AbstractGroovyLibraryManager libraryManager = facetEditor.getChosenManager(); - if (path != null && libraryManager != null) { - List suitable = CollectionFactory.arrayList(); - suitable.add(libraryManager); - final VirtualFile vfile = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(path)); - if (vfile != null) { - for (final LibraryManager manager : AbstractGroovyLibraryManager.EP_NAME.getExtensions()) { - if (manager != libraryManager && manager.isSDKHome(vfile)) { - suitable.add(manager); - } - } - } - - if (!cleanDuplicates(suitable, rootModel, container)) return; - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - if (module.isDisposed()) { - return; - } - - final Library lib = libraryManager.createLibrary(path, LibrariesContainerFactory.createContainer(module), false); - if (lib != null) { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel(); - LibrariesUtil.placeEntryToCorrectPlace(rootModel, rootModel.addLibraryEntry(lib)); - rootModel.commit(); - } - }); - } - } - }); - } } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/LibraryManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/LibraryManager.java index ba7ee6a3c1a8..0f111ce66037 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/LibraryManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/LibraryManager.java @@ -15,9 +15,6 @@ */ package org.jetbrains.plugins.groovy.config; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; @@ -31,18 +28,6 @@ import javax.swing.*; */ public abstract class LibraryManager { - @Nullable - public static LibraryManager findManagerFor(@NotNull Library library, final LibraryManager[] managers, final LibrariesContainer container) { - for (final LibraryManager manager : managers) { - final String name = library.getName(); - if (name != null && manager.managesName(name) && manager.managesLibrary(container.getLibraryFiles(library, OrderRootType.CLASSES))) { - return manager; - } - } - - return findManagerFor(managers, container.getLibraryFiles(library, OrderRootType.CLASSES)); - } - @Nullable public static LibraryManager findManagerFor(LibraryManager[] managers, final VirtualFile[] libraryFiles) { for (final LibraryManager manager : managers) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.form deleted file mode 100644 index 4f86e87f0d1d..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.form +++ /dev/null @@ -1,46 +0,0 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.java deleted file mode 100644 index 0eb9aade60f9..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/CreateLibraryDialog.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.groovy.config.ui; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; - -import javax.swing.*; -import java.awt.event.KeyEvent; - -public class CreateLibraryDialog extends DialogWrapper { - private JPanel contentPane; - private JRadioButton myInProject; - private JRadioButton myGlobal; - - public CreateLibraryDialog(Project project, final String title, final String inProjectText, final String isGlobalText) { - super(project, true); - setModal(true); - setTitle(title); - myInProject.setSelected(true); - myInProject.setMnemonic(KeyEvent.VK_P); - myGlobal.setMnemonic(KeyEvent.VK_G); - - myInProject.setText(inProjectText); - myGlobal.setText(isGlobalText); - init(); - } - - protected JComponent createCenterPanel() { - return contentPane; - } - - public boolean isInProject() { - return myInProject.isSelected(); - } - -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.form deleted file mode 100644 index fbc01c2741d4..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.form +++ /dev/null @@ -1,73 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java deleted file mode 100644 index 7acdb5043e85..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.plugins.groovy.config.ui; - -import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.fileChooser.FileChooserDialog; -import com.intellij.openapi.fileChooser.FileChooserFactory; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.config.AbstractGroovyLibraryManager; -import org.jetbrains.plugins.groovy.config.LibraryManager; -import org.jetbrains.plugins.groovy.util.GroovyUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -/** - * @author ilyas - */ -public class GroovyFacetEditor { - @NonNls private static final String GROOVY_HOME = "GROOVY_HOME"; - private static final Comparator> LIBRARY_COMPARATOR = new Comparator>() { - public int compare(Pair o1, Pair o2) { - final String name1 = o1.first.getName(); - final String name2 = o2.first.getName(); - if (name1 == null || name2 == null) return 1; - return -name1.compareToIgnoreCase(name2); - } - }; - - private TextFieldWithBrowseButton mySdkPath; - private JPanel myPanel; - private JComboBox myComboBox; - private JRadioButton myExistingSdk; - private JRadioButton myNewSdk; - private JLabel myNewSdkLabel; - private final Class myAcceptableManager; - - public GroovyFacetEditor(@Nullable Project project) { - this(project, LibraryManager.class, GROOVY_HOME); - } - - public GroovyFacetEditor(@Nullable Project project, @NotNull Class acceptableManager, final String envHome) { - myAcceptableManager = acceptableManager; - Set> libs = configureComboBox(project); - configureSdkPathField(project); - boolean hasVersions = !libs.isEmpty(); - myNewSdk.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - boolean status = myNewSdk.isSelected(); - mySdkPath.setEnabled(status); - myComboBox.setEnabled(!status); - } - }); - - if (hasVersions) { - myExistingSdk.setSelected(true); - mySdkPath.setEnabled(false); - myNewSdkLabel.setVisible(false); - } else { - myExistingSdk.setVisible(false); - myNewSdk.setVisible(false); - myNewSdk.setSelected(true); - myNewSdkLabel.setVisible(true); - - mySdkPath.setEnabled(true); - - myComboBox.setEnabled(false); - myComboBox.setVisible(false); - } - - final String s = System.getenv(envHome); - if (s != null && s.length() > 0) { - mySdkPath.setText(s); - } - } - - private Set> configureComboBox(Project project) { - final LibrariesContainer container = LibrariesContainerFactory.createContainer(project); - final AbstractGroovyLibraryManager[] managers = AbstractGroovyLibraryManager.EP_NAME.getExtensions(); - Set> libs = new TreeSet>(LIBRARY_COMPARATOR); - for (Library library : container.getAllLibraries()) { - final LibraryManager manager = LibraryManager.findManagerFor(library, managers, container); - if (myAcceptableManager.isInstance(manager)) { - libs.add(Pair.create(library, manager)); - } - } - if (!libs.isEmpty()) { - myComboBox.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Pair) { - final Pair pair = (Pair) value; - setIcon(pair.second.getIcon()); - setText(pair.first.getName()); - } - return this; - } - }); - - Pair maxValue = libs.iterator().next(); - for (final Pair lib : libs) { - myComboBox.addItem(lib); - final String version = lib.first.getName(); - FontMetrics fontMetrics = myComboBox.getFontMetrics(myComboBox.getFont()); - if (fontMetrics.stringWidth(version) > fontMetrics.stringWidth(maxValue.getFirst().getName())) { - maxValue = lib; - } - } - myComboBox.setPrototypeDisplayValue(maxValue); - } - else { - myComboBox.setEnabled(false); - myComboBox.setVisible(false); - } - return libs; - } - - @Nullable - public Library getSelectedLibrary() { - final Object selectedItem = myComboBox.getSelectedItem(); - if (selectedItem != null && selectedItem instanceof Pair) { - return ((Pair)selectedItem).first; - } - return null; - } - - @Nullable - public String getNewSdkPath() { - return mySdkPath.getText(); - } - - @Nullable - public AbstractGroovyLibraryManager getChosenManager() { - if (addNewSdk()) { - final String path = getNewSdkPath(); - if (path != null) { - final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(path)); - if (file != null && file.isDirectory()) { - return findManager(file); - } - } - - return null; - } - final Object selectedItem = myComboBox.getSelectedItem(); - if (selectedItem != null && selectedItem instanceof Pair) { - return (AbstractGroovyLibraryManager)((Pair)selectedItem).second; - } - return null; - } - - public boolean addNewSdk() { - return !myNewSdk.isVisible() || myNewSdk.isSelected(); - } - - private void configureSdkPathField(@Nullable final Project project) { - mySdkPath.getButton().addActionListener(new ActionListener() { - - public void actionPerformed(final ActionEvent e) { - final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) { - public boolean isFileSelectable(VirtualFile file) { - if (!super.isFileSelectable(file)) { - return false; - } - - return findManager(file) != null; - } - }; - final FileChooserDialog dialog = FileChooserFactory.getInstance().createFileChooser(descriptor, project); - final VirtualFile[] files = dialog.choose(null, project); - if (files.length > 0) { - final VirtualFile dir = files[0]; - mySdkPath.setText(FileUtil.toSystemDependentName(dir.getPath())); - } - } - }); - - } - - @Nullable - public static AbstractGroovyLibraryManager findManager(VirtualFile dir) { - if (GroovyUtils.getFilesInDirectoryByPattern(dir.getPath() + "/lib", "groovy.*\\.jar").length == 0) { - return null; - } - - final String name = dir.getName(); - - final AbstractGroovyLibraryManager[] managers = AbstractGroovyLibraryManager.EP_NAME.getExtensions(); - for (final AbstractGroovyLibraryManager manager : managers) { - if (manager.managesName(name) && manager.isSDKHome(dir)) { - return manager; - } - } - - for (final AbstractGroovyLibraryManager manager : managers) { - if (manager.isSDKHome(dir)) { - return manager; - } - } - return null; - } - - public JComponent getComponent() { - return myPanel; - } - - private void createUIComponents() { - myComboBox = new JComboBox() { - public void setEnabled(boolean enabled) { - super.setEnabled(!myNewSdk.isSelected() && enabled); - } - }; - mySdkPath = new TextFieldWithBrowseButton() { - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(addNewSdk() && enabled); - } - }; - } - -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryManager.java index ff529b738279..05b50bd67ccd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryManager.java @@ -56,11 +56,6 @@ public class GantLibraryManager extends AbstractGroovyLibraryManager { return GantUtils.getGantVersion(path); } - @Override - public Icon getDialogIcon() { - return GantIcons.GANT_ICON_16x16; - } - @Nls @NotNull @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java new file mode 100644 index 000000000000..a550d09c2603 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.gant; + +import com.intellij.openapi.roots.libraries.LibraryKind; +import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; +import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; +import org.jetbrains.plugins.groovy.config.LibraryManager; + +/** + * @author nik + */ +public class GantLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { + private static final LibraryKind GANT_KIND = LibraryKind.create("gant"); + private GantLibraryManager myLibraryManager = new GantLibraryManager(); + + public GantLibraryPresentationProvider() { + super(GANT_KIND); + } + + @Override + public LibraryManager getLibraryManager() { + return myLibraryManager; + } + + @Override + protected boolean acceptManager(LibraryManager manager) { + return manager instanceof GantLibraryManager; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java new file mode 100644 index 000000000000..a5e2d51e1083 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.gpp; + +import com.intellij.openapi.roots.libraries.LibraryKind; +import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; +import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; +import org.jetbrains.plugins.groovy.config.LibraryManager; + +/** + * @author nik + */ +public class GppLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { + private static final LibraryKind GPP_KIND = LibraryKind.create("gpp"); + private GppLibraryManager myLibraryManager = new GppLibraryManager(); + + public GppLibraryPresentationProvider() { + super(GPP_KIND); + } + + @Override + public LibraryManager getLibraryManager() { + return myLibraryManager; + } + + @Override + protected boolean acceptManager(LibraryManager manager) { + return manager instanceof GppLibraryManager; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleLibraryPresentationProvider.java new file mode 100644 index 000000000000..f0d6240451ab --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleLibraryPresentationProvider.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.gradle; + +import com.intellij.openapi.roots.libraries.LibraryKind; +import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; +import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; +import org.jetbrains.plugins.groovy.config.LibraryManager; + +/** + * @author nik + */ +public class GradleLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { + private static final LibraryKind GRADLE_KIND = LibraryKind.create("gradle"); + private GradleLibraryManager myLibraryManager = new GradleLibraryManager(); + + public GradleLibraryPresentationProvider() { + super(GRADLE_KIND); + } + + @Override + public LibraryManager getLibraryManager() { + return myLibraryManager; + } + + @Override + protected boolean acceptManager(LibraryManager manager) { + return manager instanceof GradleLibraryManager; + } +}