From 4874535d59de2aced9de57621ebfdae1061bb3a6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 10 May 2012 18:32:14 +0200 Subject: [PATCH] LibraryType/LibraryKind refactoring: move UI-independent stuff from LibraryType to LibraryKind, use it whenever possible --- .../FrameworkLibraryValidatorImpl.java | 4 +- .../library/DownloadableLibraryType.java | 12 ++--- .../library/DownloadableLibraryTypeBase.java | 25 ++++++++- .../CustomLibraryDescriptionImpl.java | 4 +- .../OldCustomLibraryDescription.java | 4 +- .../ChangeLibraryLevelActionBase.java | 4 +- .../classpath/CreateModuleLibraryChooser.java | 18 +++++-- .../libraries/CustomLibraryDescription.java | 4 +- .../libraries/LibraryEditingUtil.java | 5 +- .../libraries/LibraryPresentationManager.java | 10 ++-- .../impl/LibraryPresentationManagerImpl.java | 50 ++++++++--------- .../libraries/impl/LibraryUsageCollector.java | 11 ++-- .../libraryEditor/CreateNewLibraryAction.java | 6 +-- .../libraryEditor/CreateNewLibraryDialog.java | 6 ++- .../libraryEditor/ExistingLibraryEditor.java | 17 +++--- .../libraryEditor/LibraryRootsComponent.java | 4 +- .../AddLibraryToModuleDependenciesAction.java | 4 +- .../BaseLibrariesConfigurable.java | 4 +- .../LibrariesContainerFactory.java | 9 ++-- .../projectRoot/LibrariesModifiableModel.java | 6 +-- .../daemon/ProjectStructureValidator.java | 2 +- .../impl/nodes/LibraryGroupNode.java | 9 ++-- .../roots/impl/libraries/LibraryImpl.java | 53 ++++++++++--------- .../impl/libraries/LibraryTableImplUtil.java | 10 ++-- .../libraries/LibraryTypeServiceImpl.java | 11 ++-- .../libraries/LibraryDetectionManager.java | 4 +- .../LibraryPresentationProvider.java | 8 +-- .../openapi/roots/libraries/LibraryType.java | 27 +++++----- .../roots/libraries/LibraryTypeService.java | 5 +- .../LibrarySettingsProvider.java | 14 ++--- .../configuration/ProjectSettingsService.java | 10 ++-- .../roots/impl/LibraryOrderEntryImpl.java | 19 +++---- .../impl/ModuleLibraryOrderEntryImpl.java | 6 +-- .../roots/impl/ModuleLibraryTable.java | 9 ++-- .../roots/impl/libraries/LibraryEx.java | 10 ++-- .../impl/libraries/LibraryTableBase.java | 8 +-- .../openapi/roots/libraries/LibraryKind.java | 8 +-- .../libraries/PersistentLibraryKind.java | 48 +++++++++++++++++ .../GradleLibraryPresentationProvider.java | 3 +- .../config/GroovyLibraryDescription.java | 12 ++--- .../GroovyLibraryPresentationProvider.java | 4 +- ...GroovyLibraryPresentationProviderBase.java | 4 +- .../gant/GantLibraryPresentationProvider.java | 5 +- .../gpp/GppLibraryPresentationProvider.java | 5 +- .../groovy/griffon/GriffonFramework.java | 22 ++++---- .../GriffonLibraryPresentationProvider.java | 5 +- .../plugins/groovy/mvc/MvcFramework.java | 2 +- .../utils/library/RepositoryLibraryType.java | 18 +++---- 48 files changed, 309 insertions(+), 239 deletions(-) rename platform/{lang-impl => projectModel-impl}/src/com/intellij/openapi/roots/libraries/LibraryKind.java (78%) create mode 100644 platform/projectModel-impl/src/com/intellij/openapi/roots/libraries/PersistentLibraryKind.java diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FrameworkLibraryValidatorImpl.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FrameworkLibraryValidatorImpl.java index d7e357ed6ef1..56fe2f1a9fb8 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FrameworkLibraryValidatorImpl.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FrameworkLibraryValidatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -53,7 +53,7 @@ public class FrameworkLibraryValidatorImpl extends FrameworkLibraryValidator { @Override public ValidationResult check() { - final Set> libraryKinds = myLibraryDescription.getSuitableLibraryKinds(); + final Set libraryKinds = myLibraryDescription.getSuitableLibraryKinds(); final Ref found = Ref.create(false); myContext.getRootModel().orderEntries().using(myContext.getModulesProvider()).recursively().librariesOnly().forEachLibrary(new Processor() { @Override diff --git a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java index 278afda9fd13..0db89aa9dfc0 100644 --- a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java +++ b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -16,9 +16,9 @@ package com.intellij.framework.library; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.LibraryKind; import com.intellij.openapi.roots.libraries.LibraryType; import com.intellij.openapi.roots.libraries.NewLibraryConfiguration; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent; import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor; import com.intellij.openapi.util.text.StringUtil; @@ -35,7 +35,7 @@ public class DownloadableLibraryType extends LibraryType kind, @NotNull String libraryCategoryName, + public DownloadableLibraryType(@NotNull PersistentLibraryKind kind, @NotNull String libraryCategoryName, @NotNull DownloadableLibraryDescription description) { super(kind); myLibraryCategoryName = libraryCategoryName; @@ -69,12 +69,6 @@ public class DownloadableLibraryType extends LibraryType editorComponent) { return DownloadableLibraryService.getInstance().createDownloadableLibraryEditor(myLibraryDescription, editorComponent, this); diff --git a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryTypeBase.java b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryTypeBase.java index 76f2543465fe..8bb6b82b60f5 100644 --- a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryTypeBase.java +++ b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryTypeBase.java @@ -1,8 +1,23 @@ +/* + * Copyright 2000-2012 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.framework.library; import com.intellij.openapi.roots.libraries.JarVersionDetectionUtil; -import com.intellij.openapi.roots.libraries.LibraryKind; import com.intellij.openapi.roots.libraries.LibraryUtil; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,7 +34,13 @@ public abstract class DownloadableLibraryTypeBase extends DownloadableLibraryTyp @NotNull String groupId, @NotNull Icon icon, @NotNull URL... localUrls) { - super(new LibraryKind(libraryTypeId), libraryCategoryName, + super(new PersistentLibraryKind(libraryTypeId, false) { + @NotNull + @Override + public LibraryVersionProperties createDefaultProperties() { + return new LibraryVersionProperties(); + } + }, libraryCategoryName, DownloadableLibraryService.getInstance().createLibraryDescription(groupId, localUrls)); myIcon = icon; } 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 da2f42c5acd1..8842627171ad 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -35,7 +35,7 @@ public class CustomLibraryDescriptionImpl extends CustomLibraryDescriptionBase { @NotNull @Override - public Set> getSuitableLibraryKinds() { + public Set getSuitableLibraryKinds() { return Collections.singleton(myLibraryType.getKind()); } diff --git a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/OldCustomLibraryDescription.java b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/OldCustomLibraryDescription.java index 27c09e83ddc7..bc2ab2fd62eb 100644 --- a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/OldCustomLibraryDescription.java +++ b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/OldCustomLibraryDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -83,7 +83,7 @@ public class OldCustomLibraryDescription extends CustomLibraryDescriptionBase { @NotNull @Override - public Set> getSuitableLibraryKinds() { + public Set getSuitableLibraryKinds() { return Collections.emptySet(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java index 04aa6af38271..c8f8b9719f69 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -100,7 +100,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction { } } - final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(dialog.getLibraryName(), library.getType()); + final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(dialog.getLibraryName(), library.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)copied.getModifiableModel(); LibraryEditingUtil.copyLibrary(library, copiedFiles, model); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/CreateModuleLibraryChooser.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/CreateModuleLibraryChooser.java index 62890bbc16a1..50e207e796fb 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/CreateModuleLibraryChooser.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/CreateModuleLibraryChooser.java @@ -21,8 +21,10 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.LibraryProperties; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryType; import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor; @@ -33,7 +35,9 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryR import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; +import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.*; @@ -45,20 +49,23 @@ public class CreateModuleLibraryChooser implements ClasspathElementChooser myDefaultPropertiesFactory; private final HashMap myLibraryTypes; private final DefaultLibraryRootsComponentDescriptor myDefaultDescriptor; public CreateModuleLibraryChooser(ClasspathPanel classpathPanel, LibraryTable.ModifiableModel moduleLibraryModel) { this(LibraryEditingUtil.getSuitableTypes(classpathPanel), classpathPanel.getComponent(), classpathPanel.getRootModel().getModule(), - moduleLibraryModel); + moduleLibraryModel, null); } public CreateModuleLibraryChooser(List libraryTypes, JComponent parentComponent, Module module, - final LibraryTable.ModifiableModel moduleLibrariesModel) { + final LibraryTable.ModifiableModel moduleLibrariesModel, + @Nullable final Function defaultPropertiesFactory) { myParentComponent = parentComponent; myModule = module; myModuleLibrariesModel = moduleLibrariesModel; + myDefaultPropertiesFactory = defaultPropertiesFactory; myLibraryTypes = new HashMap(); myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor(); for (LibraryType libraryType : libraryTypes) { @@ -76,8 +83,11 @@ public class CreateModuleLibraryChooser implements ClasspathElementChooser roots, final LibraryType libraryType) { - final Library library = ((LibraryTableBase.ModifiableModelEx)myModuleLibrariesModel).createLibrary(null, libraryType); - final Library.ModifiableModel libModel = library.getModifiableModel(); + final Library library = ((LibraryTableBase.ModifiableModelEx)myModuleLibrariesModel).createLibrary(null, libraryType.getKind()); + final LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); + if (myDefaultPropertiesFactory != null) { + libModel.setProperties(myDefaultPropertiesFactory.fun(libraryType)); + } for (OrderRoot root : roots) { if (root.isJarDirectory()) { libModel.addJarDirectory(root.getFile(), false, root.getType()); 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 963cae23444d..f375edf95f09 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -36,7 +36,7 @@ public abstract class CustomLibraryDescription { } @NotNull - public abstract Set> getSuitableLibraryKinds(); + public abstract Set getSuitableLibraryKinds(); @Nullable public abstract NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java index 311bb86dc10d..88a3aa084d38 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -190,8 +190,9 @@ public class LibraryEditingUtil { } public static List getSuitableModules(@NotNull ModuleStructureConfigurable rootConfigurable, - final @Nullable LibraryType type, @Nullable Library library) { + final @Nullable LibraryKind kind, @Nullable Library library) { final List modules = new ArrayList(); + LibraryType type = kind == null ? null : LibraryType.findByKind(kind); for (Module module : rootConfigurable.getModules()) { if (type != null && !type.isSuitableModule(module, rootConfigurable.getFacetConfigurator())) { continue; 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 23e934f758df..67584fd34732 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -50,12 +50,12 @@ public abstract class LibraryPresentationManager { public abstract List getDescriptions(@NotNull Library library, StructureConfigurableContext context); @NotNull - public abstract List getDescriptions(@NotNull VirtualFile[] classRoots, Set> excludedKinds); + public abstract List getDescriptions(@NotNull VirtualFile[] classRoots, Set excludedKinds); - public abstract List getLibraries(@NotNull Set> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context); + 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 LibraryKind kind); public abstract boolean isLibraryOfKind(@NotNull Library library, @NotNull LibrariesContainer librariesContainer, - @NotNull Set> acceptedKinds); + @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 6e3eeef7ceb0..d5db34bcb5d3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -36,11 +36,11 @@ import java.util.*; * @author nik */ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { - private Map, LibraryPresentationProvider> myPresentationProviders; + private Map> myPresentationProviders; - private

LibraryPresentationProvider

getPresentationProvider(LibraryKind

kind) { + private

LibraryPresentationProvider

getPresentationProvider(LibraryKind kind) { if (myPresentationProviders == null) { - final Map, LibraryPresentationProvider> providers = new HashMap, LibraryPresentationProvider>(); + final Map> providers = new HashMap>(); for (LibraryType type : LibraryType.EP_NAME.getExtensions()) { providers.put(type.getKind(), type); } @@ -62,9 +62,9 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @Override public Icon getCustomIcon(@NotNull Library library, StructureConfigurableContext context) { - final LibraryType type = ((LibraryEx)library).getType(); - if (type != null) { - return type.getIcon(); + final LibraryKind kind = ((LibraryEx)library).getKind(); + if (kind != null) { + return LibraryType.findByKind(kind).getIcon(); } final List icons = getCustomIcons(library, context); if (icons.size() == 1) { @@ -80,7 +80,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { final List icons = new SmartList(); LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override - public

boolean processProperties(@NotNull LibraryKind

kind, @NotNull P properties) { + public

boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) { final LibraryPresentationProvider

provider = getPresentationProvider(kind); if (provider != null) { ContainerUtil.addIfNotNull(icons, provider.getIcon()); @@ -92,10 +92,10 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { } @Override - public boolean isLibraryOfKind(@NotNull List files, @NotNull final LibraryKind kind) { + public boolean isLibraryOfKind(@NotNull List files, @NotNull final LibraryKind kind) { return !LibraryDetectionManager.getInstance().processProperties(files, new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override - public

boolean processProperties(@NotNull LibraryKind

processedKind, @NotNull P properties) { + public

boolean processProperties(@NotNull LibraryKind processedKind, @NotNull P properties) { return !kind.equals(processedKind); } }); @@ -104,29 +104,29 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @Override public boolean isLibraryOfKind(@NotNull Library library, @NotNull LibrariesContainer librariesContainer, - @NotNull final Set> acceptedKinds) { - final LibraryType type = ((LibraryEx)library).getType(); - if (type != null && acceptedKinds.contains(type.getKind())) return true; + @NotNull final Set acceptedKinds) { + final LibraryKind type = ((LibraryEx)library).getKind(); + if (type != null && acceptedKinds.contains(type)) return true; final VirtualFile[] files = librariesContainer.getLibraryFiles(library, OrderRootType.CLASSES); return !LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override - public

boolean processProperties(@NotNull LibraryKind

processedKind, @NotNull P properties) { + public

boolean processProperties(@NotNull LibraryKind processedKind, @NotNull P properties) { return !acceptedKinds.contains(processedKind); } }); } - public static List> getLibraryKinds(@NotNull Library library, @Nullable StructureConfigurableContext context) { - final List> result = new SmartList>(); - final LibraryType type = ((LibraryEx)library).getType(); - if (type != null) { - result.add(type.getKind()); + public static List getLibraryKinds(@NotNull Library library, @Nullable StructureConfigurableContext context) { + final List result = new SmartList(); + final LibraryKind kind = ((LibraryEx)library).getKind(); + if (kind != null) { + result.add(kind); } final VirtualFile[] files = getLibraryFiles(library, context); LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override - public

boolean processProperties(@NotNull LibraryKind

kind, @NotNull P properties) { + public

boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) { result.add(kind); return true; } @@ -138,7 +138,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @Override public List getDescriptions(@NotNull Library library, StructureConfigurableContext context) { final VirtualFile[] files = getLibraryFiles(library, context); - return getDescriptions(files, Collections.>emptySet()); + return getDescriptions(files, Collections.emptySet()); } @NotNull @@ -151,11 +151,11 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @NotNull @Override - public List getDescriptions(@NotNull VirtualFile[] classRoots, final Set> excludedKinds) { + public List getDescriptions(@NotNull VirtualFile[] classRoots, final Set excludedKinds) { final SmartList result = new SmartList(); LibraryDetectionManager.getInstance().processProperties(Arrays.asList(classRoots), new LibraryDetectionManager.LibraryPropertiesProcessor() { @Override - public

boolean processProperties(@NotNull LibraryKind

kind, @NotNull P properties) { + public

boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) { if (!excludedKinds.contains(kind)) { final LibraryPresentationProvider

provider = getPresentationProvider(kind); if (provider != null) { @@ -169,7 +169,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { } @Override - public List getLibraries(@NotNull Set> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) { + public List getLibraries(@NotNull Set kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) { List libraries = new ArrayList(); if (context != null) { Collections.addAll(libraries, context.getProjectLibrariesProvider().getModifiableModel().getLibraries()); @@ -184,7 +184,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { final Iterator iterator = libraries.iterator(); while (iterator.hasNext()) { Library library = iterator.next(); - final List> libraryKinds = getLibraryKinds(library, context); + final List libraryKinds = getLibraryKinds(library, context); if (!ContainerUtil.intersects(libraryKinds, kinds)) { iterator.remove(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java index dad76bc77c8b..d5e5f599553f 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -16,7 +16,6 @@ package com.intellij.openapi.roots.ui.configuration.libraries.impl; import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; -import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; import com.intellij.openapi.module.Module; @@ -30,7 +29,9 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; /** * @author nik @@ -44,7 +45,7 @@ public class LibraryUsageCollector extends AbstractApplicationUsagesCollector { public Set getProjectUsages(@Nullable Project project) { if (project == null) return Collections.emptySet(); - final Set> usedKinds = new HashSet>(); + final Set usedKinds = new HashSet(); final Processor processor = new Processor() { @Override public boolean process(Library library) { @@ -57,7 +58,7 @@ public class LibraryUsageCollector extends AbstractApplicationUsagesCollector { } final HashSet usageDescriptors = new HashSet(); - for (LibraryKind kind : usedKinds) { + for (LibraryKind kind : usedKinds) { usageDescriptors.add(new UsageDescriptor(kind.getKindId(), 1)); } return usageDescriptors; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java index 97fc071ea594..4594d4e33674 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -80,7 +80,7 @@ public class CreateNewLibraryAction extends DumbAwareAction { @NotNull final Project project, @NotNull final LibrariesModifiableModel modifiableModel) { final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project); if (configuration == null) return null; - final Library library = modifiableModel.createLibrary(LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()), configuration.getLibraryType()); + final Library library = modifiableModel.createLibrary(LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()), configuration.getLibraryType().getKind()); final NewLibraryEditor editor = new NewLibraryEditor(configuration.getLibraryType(), configuration.getProperties()); configuration.addRoots(editor); @@ -117,7 +117,7 @@ public class CreateNewLibraryAction extends DumbAwareAction { if (librariesConfigurable instanceof ProjectLibrariesConfigurable) { final ModuleStructureConfigurable configurable = ModuleStructureConfigurable.getInstance(project); for (LibraryType extension : extensions) { - if (!LibraryEditingUtil.getSuitableModules(configurable, extension, null).isEmpty()) { + if (!LibraryEditingUtil.getSuitableModules(configurable, extension.getKind(), null).isEmpty()) { suitableTypes.add(extension); } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java index 6ae56cf0b248..721cbb4ec02b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -22,6 +22,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.roots.libraries.LibraryType; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; import com.intellij.openapi.ui.ComboBox; import com.intellij.util.ui.FormBuilder; @@ -69,7 +70,8 @@ public class CreateNewLibraryDialog extends LibraryEditorDialogBase { @NotNull public Library createLibrary() { final LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx)getTableModifiableModel(); - final Library library = modifiableModel.createLibrary(myLibraryEditor.getName(), myLibraryEditor.getType()); + final LibraryType type = myLibraryEditor.getType(); + final Library library = modifiableModel.createLibrary(myLibraryEditor.getName(), type != null ? type.getKind() : null); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); myLibraryEditor.applyTo(model); new WriteAction() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java index 2e06d3fb8f0a..9a6b446bc189 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -18,10 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.openapi.Disposable; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.impl.libraries.LibraryEx; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryDetectionManager; -import com.intellij.openapi.roots.libraries.LibraryProperties; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; @@ -60,16 +57,16 @@ public class ExistingLibraryEditor extends LibraryEditorBase implements Disposab @Override public LibraryType getType() { - final LibraryType type = ((LibraryEx)myLibrary).getType(); - if (type != null) { - return type; + final LibraryKind kind = ((LibraryEx)myLibrary).getKind(); + if (kind != null) { + return LibraryType.findByKind(kind); } return detectType(); } @Override public void setType(@NotNull LibraryType type) { - ((LibraryEx.ModifiableModelEx)getModel()).setType(type); + ((LibraryEx.ModifiableModelEx)getModel()).setKind(type.getKind()); } private LibraryType detectType() { @@ -94,7 +91,7 @@ public class ExistingLibraryEditor extends LibraryEditorBase implements Disposab } if (myLibraryProperties == null) { - myLibraryProperties = type.createDefaultProperties(); + myLibraryProperties = type.getKind().createDefaultProperties(); //noinspection unchecked myLibraryProperties.loadState(getOriginalProperties().getState()); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java index feefb83654d5..75c265b8514c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java @@ -121,8 +121,8 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent public void updatePropertiesLabel() { StringBuilder text = new StringBuilder(); final LibraryType type = getLibraryEditor().getType(); - final Set> excluded = - type != null ? Collections.>singleton(type.getKind()) : Collections.>emptySet(); + final Set excluded = + type != null ? Collections.singleton(type.getKind()) : Collections.emptySet(); for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES), excluded)) { if (text.length() > 0) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddLibraryToModuleDependenciesAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddLibraryToModuleDependenciesAction.java index 0340df7269c8..03e8e4c59503 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddLibraryToModuleDependenciesAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddLibraryToModuleDependenciesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -44,7 +44,7 @@ public class AddLibraryToModuleDependenciesAction extends DumbAwareAction { boolean visible = false; if (element instanceof LibraryProjectStructureElement) { final LibraryEx library = (LibraryEx)((LibraryProjectStructureElement)element).getLibrary(); - visible = !LibraryEditingUtil.getSuitableModules(ModuleStructureConfigurable.getInstance(myProject), library.getType(), library).isEmpty(); + visible = !LibraryEditingUtil.getSuitableModules(ModuleStructureConfigurable.getInstance(myProject), library.getKind(), library).isEmpty(); } e.getPresentation().setVisible(visible); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java index cff128d2e6a8..b3f5f6fea3c8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -331,7 +331,7 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl LOG.assertTrue(library != null); final LibrariesModifiableModel libsModel = configurable.getModelProvider().getModifiableModel(); - final Library lib = libsModel.createLibrary(newName, library.getType()); + final Library lib = libsModel.createLibrary(newName, library.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)libsModel.getLibraryEditor(lib).getModel(); LibraryEditingUtil.copyLibrary(library, Collections.emptyMap(), model); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java index c63a36e12dd4..7d6775219821 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -25,6 +25,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; 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.LibraryType; import com.intellij.openapi.roots.libraries.ui.OrderRoot; import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider; import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator; @@ -91,7 +92,8 @@ public class LibrariesContainerFactory { private static Library createLibraryInTable(final @NotNull NewLibraryEditor editor, final LibraryTable table) { LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx) table.getModifiableModel(); final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel); - Library library = modifiableModel.createLibrary(name, editor.getType()); + final LibraryType type = editor.getType(); + Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); editor.applyTo(model); model.commit(); @@ -299,7 +301,8 @@ public class LibrariesContainerFactory { } LibraryTableBase.ModifiableModelEx model = (LibraryTableBase.ModifiableModelEx)provider.getModifiableModel(); - Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model), libraryEditor.getType()); + final LibraryType type = libraryEditor.getType(); + Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model), type == null ? null : type.getKind()); ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library); createdLibraryEditor.setProperties(libraryEditor.getProperties()); libraryEditor.applyTo(createdLibraryEditor); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesModifiableModel.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesModifiableModel.java index 7762c4877b7b..cf98d97f7ecc 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesModifiableModel.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesModifiableModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -21,7 +21,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; @@ -60,7 +60,7 @@ public class LibrariesModifiableModel implements LibraryTableBase.ModifiableMode return createLibrary(name, null); } - public Library createLibrary(String name, @Nullable LibraryType type) { + public Library createLibrary(String name, @Nullable PersistentLibraryKind type) { final Library library = ((LibraryTableBase.ModifiableModelEx)getLibrariesModifiableModel()).createLibrary(name, type); //createLibraryEditor(library); \ final BaseLibrariesConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureValidator.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureValidator.java index e7dc8f631487..32eff3a9bae7 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureValidator.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureValidator.java @@ -63,7 +63,7 @@ public abstract class ProjectStructureValidator { } final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project); - final List modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getType(), library); + final List modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library); if (modules.isEmpty()) return; final ChooseModulesDialog dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"), diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/LibraryGroupNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/LibraryGroupNode.java index 1a15dbcbb570..3dbcf534a2d5 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/LibraryGroupNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/LibraryGroupNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -28,6 +28,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -138,9 +139,9 @@ public class LibraryGroupNode extends ProjectViewNode { if (library == null) return VirtualFile.EMPTY_ARRAY; OrderRootType[] rootTypes = LibraryType.DEFAULT_EXTERNAL_ROOT_TYPES; if (library instanceof LibraryEx) { - LibraryType libraryType = ((LibraryEx)library).getType(); - if (libraryType != null) { - rootTypes = libraryType.getExternalRootTypes(); + PersistentLibraryKind libKind = ((LibraryEx)library).getKind(); + if (libKind != null) { + rootTypes = LibraryType.findByKind(libKind).getExternalRootTypes(); } } for (OrderRootType rootType : rootTypes) { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index fb009e39ab73..664d55dd06a1 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -66,7 +66,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { private final Map myRoots; private final JarDirectories myJarDirectories = new JarDirectories(); private final LibraryImpl mySource; - private LibraryType myType; + private PersistentLibraryKind myKind; private LibraryProperties myProperties; private final MyRootProviderImpl myRootProvider = new MyRootProviderImpl(); @@ -93,13 +93,13 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { myRootsWatcher.updateWatchedRoots(); } - LibraryImpl(String name, final @Nullable LibraryType type, LibraryTable table, ModifiableRootModel rootModel) { + LibraryImpl(String name, final @Nullable PersistentLibraryKind kind, LibraryTable table, ModifiableRootModel rootModel) { myName = name; myLibraryTable = table; myRootModel = rootModel; - myType = type; - if (type != null) { - myProperties = type.createDefaultProperties(); + myKind = kind; + if (kind != null) { + myProperties = kind.createDefaultProperties(); } myRoots = initRoots(); mySource = null; @@ -108,8 +108,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { private Set getAllRootTypes() { Set rootTypes = new HashSet(); rootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes())); - if (myType != null) { - rootTypes.addAll(Arrays.asList(myType.getAdditionalRootTypes())); + if (myKind != null) { + rootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes())); } return rootTypes; } @@ -118,9 +118,9 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { assert !from.isDisposed(); myRootModel = rootModel; myName = from.myName; - myType = from.myType; - if (from.myType != null && from.myProperties != null) { - myProperties = myType.createDefaultProperties(); + myKind = from.myKind; + if (from.myKind != null && from.myProperties != null) { + myProperties = myKind.createDefaultProperties(); //noinspection unchecked myProperties.loadState(from.myProperties.getState()); } @@ -169,7 +169,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } expanded.add(file); } - return VfsUtil.toVirtualFileArray(expanded); + return VfsUtilCore.toVirtualFileArray(expanded); } public static void collectJarFiles(final VirtualFile dir, final List container, final boolean recursively) { @@ -257,10 +257,10 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { final String typeId = element.getAttributeValue(LIBRARY_TYPE_ATTR); if (typeId == null) return; - myType = LibraryTypeService.getInstance().findTypeById(typeId); - if (myType == null) return; + myKind = LibraryTypeService.getInstance().findKindById(typeId); + if (myKind == null) return; - myProperties = myType.createDefaultProperties(); + myProperties = myKind.createDefaultProperties(); final Element propertiesElement = element.getChild(PROPERTIES_ELEMENT); if (propertiesElement != null) { final Class stateClass = ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(PersistentStateComponent.class.getTypeParameters()[0], myProperties.getClass())); @@ -313,8 +313,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (myName != null) { element.setAttribute(LIBRARY_NAME_ATTR, myName); } - if (myType != null) { - element.setAttribute(LIBRARY_TYPE_ATTR, myType.getKind().getKindId()); + if (myKind != null) { + element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId()); final Object state = myProperties.getState(); if (state != null) { final Element propertiesElement = XmlSerializer.serialize(state, SERIALIZATION_FILTERS); @@ -325,8 +325,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } ArrayList storableRootTypes = new ArrayList(); storableRootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes())); - if (myType != null) { - storableRootTypes.addAll(Arrays.asList(myType.getAdditionalRootTypes())); + if (myKind != null) { + storableRootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes())); } for (OrderRootType rootType : sortRootTypes(storableRootTypes)) { final VirtualFilePointerContainer roots = myRoots.get(rootType); @@ -343,9 +343,10 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { return mySource != null; } + @Nullable @Override - public LibraryType getType() { - return myType; + public PersistentLibraryKind getKind() { + return myKind; } @Override @@ -354,10 +355,10 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } @Override - public void setType(LibraryType type) { + public void setKind(PersistentLibraryKind kind) { LOG.assertTrue(isWritable()); - LOG.assertTrue(myType == null || myType.equals(type), "Library type cannot be changed from " + myType + " to " + type); - myType = type; + LOG.assertTrue(myKind == null || myKind == kind, "Library kind cannot be changed from " + myKind + " to " + kind); + myKind = kind; } public void addRoot(@NotNull String url, @NotNull OrderRootType rootType) { @@ -490,7 +491,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { ((LibraryTableBase)myLibraryTable).fireLibraryRenamed(this); } } - myType = fromModel.myType; + myKind = fromModel.getKind(); myProperties = fromModel.myProperties; if (areRootsChanged(fromModel)) { disposeMyPointers(); @@ -552,7 +553,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (!myJarDirectories.equals(library.myJarDirectories)) return false; if (myName != null ? !myName.equals(library.myName) : library.myName != null) return false; if (myRoots != null ? !myRoots.equals(library.myRoots) : library.myRoots != null) return false; - if (myType != null ? !myType.equals(library.myType) : library.myType != null) return false; + if (myKind != null ? !myKind.equals(library.myKind) : library.myKind != null) return false; if (myProperties != null ? !myProperties.equals(library.myProperties) : library.myProperties != null) return false; return true; diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableImplUtil.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableImplUtil.java index e1378252e4a8..1127d3ddcaa2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableImplUtil.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -16,9 +16,9 @@ package com.intellij.openapi.roots.impl.libraries; -import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.impl.RootModelImpl; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.util.InvalidDataException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -43,8 +43,8 @@ public class LibraryTableImplUtil { } public static Library createModuleLevelLibrary(@Nullable String name, - final LibraryType type, + final PersistentLibraryKind kind, RootModelImpl rootModel) { - return new LibraryImpl(name, type, null, rootModel); + return new LibraryImpl(name, kind, null, rootModel); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTypeServiceImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTypeServiceImpl.java index dd7027cfef99..51ceba62c389 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTypeServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTypeServiceImpl.java @@ -18,10 +18,7 @@ package com.intellij.openapi.roots.impl.libraries; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.LibraryProperties; -import com.intellij.openapi.roots.libraries.LibraryType; -import com.intellij.openapi.roots.libraries.LibraryTypeService; -import com.intellij.openapi.roots.libraries.NewLibraryConfiguration; +import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor; import com.intellij.openapi.roots.libraries.ui.OrderRoot; import com.intellij.openapi.roots.libraries.ui.impl.RootDetectionUtil; @@ -43,10 +40,10 @@ public class LibraryTypeServiceImpl extends LibraryTypeService { private static final String DEFAULT_LIBRARY_NAME = "Unnamed"; @Nullable - public LibraryType findTypeById(@NotNull String typeId) { + public PersistentLibraryKind findKindById(@NotNull String typeId) { for (LibraryType type : LibraryType.EP_NAME.getExtensions()) { if (type.getKind().getKindId().equals(typeId)) { - return type; + return (PersistentLibraryKind)type.getKind(); } } return null; @@ -72,7 +69,7 @@ public class LibraryTypeServiceImpl extends LibraryTypeService { } private static

> NewLibraryConfiguration doCreate(final LibraryType

type, final String name, final List roots) { - return new NewLibraryConfiguration(name, type, type != null ? type.createDefaultProperties() : null) { + return new NewLibraryConfiguration(name, type, type != null ? type.getKind().createDefaultProperties() : null) { @Override public void addRoots(@NotNull LibraryEditor editor) { editor.addRoots(roots); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java index a4ca382d5783..51e72a2359e0 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryDetectionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -37,6 +37,6 @@ public abstract class LibraryDetectionManager { public abstract Pair, LibraryProperties> detectType(@NotNull List files); public interface LibraryPropertiesProcessor { -

boolean processProperties(@NotNull LibraryKind

kind, @NotNull P properties); +

boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java index 55a1a62a6271..bcb18e9032e6 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -28,14 +28,14 @@ import java.util.List; */ public abstract class LibraryPresentationProvider

{ public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.library.presentationProvider"); - private final LibraryKind

myKind; + private final LibraryKind myKind; - protected LibraryPresentationProvider(@NotNull LibraryKind

kind) { + protected LibraryPresentationProvider(@NotNull LibraryKind kind) { myKind = kind; } @NotNull - public final LibraryKind

getKind() { + public LibraryKind getKind() { return myKind; } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java index 2e521e3cde57..b74779499352 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -44,10 +44,16 @@ public abstract class LibraryType

extends LibraryPr public final static OrderRootType[] DEFAULT_EXTERNAL_ROOT_TYPES = {OrderRootType.CLASSES}; - protected LibraryType(@NotNull LibraryKind

libraryKind) { + protected LibraryType(@NotNull PersistentLibraryKind

libraryKind) { super(libraryKind); } + @NotNull + @Override + public PersistentLibraryKind

getKind() { + return (PersistentLibraryKind

) super.getKind(); + } + /** * @return text to show in 'New Library' popup. Return {@code null} if the type should not be shown in the 'New Library' popup */ @@ -61,9 +67,6 @@ public abstract class LibraryType

extends LibraryPr public abstract NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory, @NotNull Project project); - @NotNull - public abstract P createDefaultProperties(); - /** * @return {@code true} if library of this type can be added as a dependency to {@code module} */ @@ -95,13 +98,13 @@ public abstract class LibraryType

extends LibraryPr public OrderRootType[] getExternalRootTypes() { return DEFAULT_EXTERNAL_ROOT_TYPES; } - - public OrderRootType[] getAdditionalRootTypes() { - return new OrderRootType[0]; - } - public boolean isFileBased() { - return false; + public static LibraryType findByKind(LibraryKind kind) { + for (LibraryType type : EP_NAME.getExtensions()) { + if (type.getKind() == kind) { + return type; + } + } + throw new IllegalArgumentException("Library with kind " + kind + " is not registered"); } - } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryTypeService.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryTypeService.java index 50c07766b4bc..4ec8e06ae0ca 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryTypeService.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryTypeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -32,8 +32,7 @@ public abstract class LibraryTypeService { return ServiceManager.getService(LibraryTypeService.class); } - @Nullable - public abstract LibraryType findTypeById(@NotNull String typeId); + public abstract PersistentLibraryKind findKindById(@NotNull String typeId); @Nullable public abstract NewLibraryConfiguration createLibraryFromFiles(@NotNull LibraryRootsComponentDescriptor descriptor, diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/LibrarySettingsProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/LibrarySettingsProvider.java index 5c4164f54569..3e2515a17c3a 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/LibrarySettingsProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/LibrarySettingsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,7 +19,7 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.LibraryKind; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,20 +32,20 @@ public abstract class LibrarySettingsProvider { ExtensionPointName.create("com.intellij.librarySettingsProvider"); @NotNull - public abstract LibraryType getLibraryType(); + public abstract LibraryKind getLibraryKind(); public abstract Configurable getAdditionalSettingsConfigurable(Project project); @Nullable - public static Configurable getAdditionalSettingsConfigurable(Project project, LibraryType libType) { - LibrarySettingsProvider provider = forLibraryType(libType); + public static Configurable getAdditionalSettingsConfigurable(Project project, LibraryKind libKind) { + LibrarySettingsProvider provider = forLibraryType(libKind); if (provider == null) return null; return provider.getAdditionalSettingsConfigurable(project); } @Nullable - public static LibrarySettingsProvider forLibraryType(LibraryType libType) { + public static LibrarySettingsProvider forLibraryType(LibraryKind libType) { for (LibrarySettingsProvider provider : Extensions.getExtensions(EP_NAME)) { - if (provider.getLibraryType().equals(libType)) { + if (provider.getLibraryKind().equals(libType)) { return provider; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ProjectSettingsService.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ProjectSettingsService.java index 0a0f04fd7f67..c8bee89f66e9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ProjectSettingsService.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ProjectSettingsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -27,7 +27,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,9 +92,9 @@ public class ProjectSettingsService { Library lib = libOrderEntry.getLibrary(); if (lib instanceof LibraryEx) { Project project = libOrderEntry.getOwnerModule().getProject(); - LibraryType libType = ((LibraryEx)lib).getType(); - if (libType != null) { - return LibrarySettingsProvider.getAdditionalSettingsConfigurable(project, libType); + PersistentLibraryKind libKind = ((LibraryEx)lib).getKind(); + if (libKind != null) { + return LibrarySettingsProvider.getAdditionalSettingsConfigurable(project, libKind); } } return null; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryImpl.java index d404283b441d..665071c5c5cc 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryImpl.java @@ -19,10 +19,7 @@ package com.intellij.openapi.roots.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.libraries.LibraryEx; -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.LibraryType; +import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; @@ -47,14 +44,14 @@ class LibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements Library @NonNls private static final String LEVEL_ATTR = "level"; private final MyOrderEntryLibraryTableListener myLibraryListener = new MyOrderEntryLibraryTableListener(); @NonNls private static final String EXPORTED_ATTR = "exported"; - private LibraryType myLibraryType; + private PersistentLibraryKind myLibraryKind; LibraryOrderEntryImpl(@NotNull Library library, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) { super(rootModel, projectRootManager); LOG.assertTrue(library.getTable() != null); myLibrary = library; if (myLibrary instanceof LibraryEx) { - myLibraryType = ((LibraryEx)myLibrary).getType(); + myLibraryKind = ((LibraryEx)myLibrary).getKind(); } addListeners(); init(); @@ -82,7 +79,7 @@ class LibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements Library } else { myLibrary = that.myLibrary; - myLibraryType = that.myLibraryType; + myLibraryKind = that.myLibraryKind; } myExported = that.myExported; myScope = that.myScope; @@ -113,7 +110,7 @@ class LibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements Library myLibraryLevel = null; myLibrary = library; if (library instanceof LibraryEx) { - myLibraryType = ((LibraryEx)library).getType(); + myLibraryKind = ((LibraryEx)library).getKind(); } } } @@ -254,8 +251,8 @@ class LibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements Library myLibrary = newLibrary; myLibraryName = null; myLibraryLevel = null; - if (newLibrary instanceof LibraryEx && myLibraryType == null) { - myLibraryType = ((LibraryEx)newLibrary).getType(); + if (newLibrary instanceof LibraryEx && myLibraryKind == null) { + myLibraryKind = ((LibraryEx)newLibrary).getKind(); } updateFromRootProviderAndSubscribe(); } @@ -297,7 +294,7 @@ class LibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements Library @Override protected VirtualFile[] filterDirectories(@NotNull VirtualFile[] files) { - if (myLibraryType != null && myLibraryType.isFileBased()) { + if (myLibraryKind != null && myLibraryKind.isFileBased()) { return files; } return super.filterDirectories(files); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java index 3f0f5bd8756e..4b70ad4f7600 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java @@ -21,7 +21,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; @@ -51,9 +51,9 @@ public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl imple myScope = scope; } - ModuleLibraryOrderEntryImpl(String name, final LibraryType type, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) { + ModuleLibraryOrderEntryImpl(String name, final PersistentLibraryKind kind, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) { super(rootModel, projectRootManager); - myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, type, getRootModel()); + myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, kind, getRootModel()); doinit(); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java index 69433ddc691f..537e1607f1ec 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java @@ -23,10 +23,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.libraries.LibraryTablePresentation; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.util.Condition; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ConvertingIterator; @@ -82,8 +79,8 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi } @Override - public Library createLibrary(String name, @Nullable LibraryType type) { - final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(name, type, myRootModel, myProjectRootManager); + public Library createLibrary(String name, @Nullable PersistentLibraryKind kind) { + final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(name, kind, myRootModel, myProjectRootManager); myRootModel.addOrderEntry(orderEntry); return orderEntry.getLibrary(); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryEx.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryEx.java index bab7bd23384f..40909bd757ef 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryEx.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryEx.java @@ -20,7 +20,8 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.impl.RootModelImpl; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryProperties; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -34,7 +35,8 @@ public interface LibraryEx extends Library { boolean isDisposed(); - LibraryType getType(); + @Nullable + PersistentLibraryKind getKind(); LibraryProperties getProperties(); @@ -43,8 +45,8 @@ public interface LibraryEx extends Library { LibraryProperties getProperties(); - void setType(LibraryType type); + void setKind(PersistentLibraryKind type); - LibraryType getType(); + PersistentLibraryKind getKind(); } } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java index 383a3d6d6a22..bb03da56ec93 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java @@ -24,7 +24,7 @@ import com.intellij.openapi.roots.DependencyScope; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.util.*; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -186,7 +186,7 @@ public abstract class LibraryTableBase implements PersistentStateComponent { +public class LibraryKind { private final String myKindId; /** - * @param kindId must be unique among all {@link LibraryType} and {@link LibraryPresentationProvider} implementations + * @param kindId must be unique among all {@link com.intellij.openapi.roots.libraries.LibraryType} and {@link com.intellij.openapi.roots.libraries.LibraryPresentationProvider} implementations */ public LibraryKind(@NotNull @NonNls String kindId) { myKindId = kindId; @@ -44,7 +44,7 @@ public class LibraryKind

{ * @param kindId must be unique among all {@link LibraryType} and {@link LibraryPresentationProvider} implementations * @return new {@link LibraryKind} instance */ - public static

LibraryKind

create(@NotNull @NonNls String kindId) { - return new LibraryKind

(kindId); + public static LibraryKind create(@NotNull @NonNls String kindId) { + return new LibraryKind(kindId); } } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/libraries/PersistentLibraryKind.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/libraries/PersistentLibraryKind.java new file mode 100644 index 000000000000..23654c87a5df --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/libraries/PersistentLibraryKind.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2012 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.libraries; + +import com.intellij.openapi.roots.OrderRootType; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * @author yole + */ +public abstract class PersistentLibraryKind

extends LibraryKind { + private final boolean myFileBased; + + /** + * @param kindId must be unique among all {@link com.intellij.openapi.roots.libraries.LibraryType} and {@link com.intellij.openapi.roots.libraries.LibraryPresentationProvider} implementations + * @param based + */ + public PersistentLibraryKind(@NotNull @NonNls String kindId, boolean fileBased) { + super(kindId); + myFileBased = fileBased; + } + + @NotNull + public abstract P createDefaultProperties(); + + + public boolean isFileBased() { + return myFileBased; + } + + public OrderRootType[] getAdditionalRootTypes() { + return new OrderRootType[0]; + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java index 1fc0060b89ac..cd9f1a36649f 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java @@ -29,7 +29,6 @@ import org.jetbrains.plugins.gradle.util.GradleBundle; import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleLibraryManager; import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; -import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; import javax.swing.*; import java.io.File; @@ -40,7 +39,7 @@ import java.util.regex.Matcher; */ public class GradleLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { - private static final LibraryKind GRADLE_KIND = LibraryKind.create(GradleConstants.EXTENSION); + private static final LibraryKind GRADLE_KIND = LibraryKind.create(GradleConstants.EXTENSION); private final GradleLibraryManager myLibraryManager; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java index 242610b1f1a7..b06652ad81b0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java @@ -40,15 +40,15 @@ import java.util.*; public class GroovyLibraryDescription extends CustomLibraryDescription { private static final String GROOVY_FRAMEWORK_NAME = "Groovy"; private String myEnvVariable; - private final Set> myLibraryKinds; + private final Set myLibraryKinds; private final String myFrameworkName; public GroovyLibraryDescription() { this("GROOVY_HOME", getAllGroovyKinds(), GROOVY_FRAMEWORK_NAME); } - public static Set> getAllGroovyKinds() { - final HashSet> kinds = new HashSet>(); + public static Set getAllGroovyKinds() { + final HashSet kinds = new HashSet(); for (LibraryPresentationProvider provider : LibraryPresentationProvider.EP_NAME.getExtensions()) { if (provider instanceof GroovyLibraryPresentationProviderBase) { kinds.add(provider.getKind()); @@ -57,11 +57,11 @@ public class GroovyLibraryDescription extends CustomLibraryDescription { return kinds; } - public GroovyLibraryDescription(@NotNull String envVariable, @NotNull LibraryKind libraryKind, String frameworkName) { + public GroovyLibraryDescription(@NotNull String envVariable, @NotNull LibraryKind libraryKind, String frameworkName) { this(envVariable, Collections.singleton(libraryKind), frameworkName); } - private GroovyLibraryDescription(@NotNull String envVariable, @NotNull final Set> libraryKinds, String frameworkName) { + private GroovyLibraryDescription(@NotNull String envVariable, @NotNull final Set libraryKinds, String frameworkName) { myEnvVariable = envVariable; myLibraryKinds = libraryKinds; myFrameworkName = frameworkName; @@ -88,7 +88,7 @@ public class GroovyLibraryDescription extends CustomLibraryDescription { @NotNull @Override - public Set> getSuitableLibraryKinds() { + public Set getSuitableLibraryKinds() { return myLibraryKinds; } 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 c7c983063523..ac85d9baf56d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -32,7 +32,7 @@ import java.io.File; * @author nik */ public class GroovyLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { - public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy"); + public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy"); public GroovyLibraryPresentationProvider() { super(GROOVY_KIND); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java index ff84a589dcbe..aeb922fb1983 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryPresentationProviderBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -32,7 +32,7 @@ import java.util.List; * @author nik */ public abstract class GroovyLibraryPresentationProviderBase extends LibraryPresentationProvider { - public GroovyLibraryPresentationProviderBase(LibraryKind kind) { + public GroovyLibraryPresentationProviderBase(LibraryKind kind) { super(kind); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java index fe782ae9d3bf..95673852b0ff 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantLibraryPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -23,7 +23,6 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; -import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; import javax.swing.*; import java.io.File; @@ -32,7 +31,7 @@ import java.io.File; * @author nik */ public class GantLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { - private static final LibraryKind GANT_KIND = LibraryKind.create("gant"); + private static final LibraryKind GANT_KIND = LibraryKind.create("gant"); public GantLibraryPresentationProvider() { super(GANT_KIND); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java index 59078924cb87..a927d8e2c101 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppLibraryPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyIcons; import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; -import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; import javax.swing.*; import java.io.File; @@ -38,7 +37,7 @@ import java.util.regex.Pattern; * @author nik */ public class GppLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { - private static final LibraryKind GPP_KIND = LibraryKind.create("gpp"); + private static final LibraryKind GPP_KIND = LibraryKind.create("gpp"); private static final Pattern GROOVYPP_JAR = Pattern.compile("groovypp-([\\d\\.]+)\\.jar"); private static final Pattern GROOVYPP_ALL_JAR = Pattern.compile("groovypp-all-([\\d\\.]+)\\.jar"); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java index c82f8683ddc9..68a243a46d54 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java @@ -1,17 +1,17 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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 + * 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 + * 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. + * 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.griffon; @@ -367,7 +367,7 @@ public class GriffonFramework extends MvcFramework { } @Override - public LibraryKind getLibraryKind() { + public LibraryKind getLibraryKind() { return GriffonLibraryPresentationProvider.GRIFFON_KIND; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonLibraryPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonLibraryPresentationProvider.java index 0aec61490c87..a388dedff57e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonLibraryPresentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonLibraryPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -30,7 +30,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; -import org.jetbrains.plugins.groovy.config.GroovyLibraryProperties; import javax.swing.*; import java.io.File; @@ -41,7 +40,7 @@ import java.util.regex.Pattern; * @author nik */ public class GriffonLibraryPresentationProvider extends GroovyLibraryPresentationProviderBase { - public static final LibraryKind GRIFFON_KIND = LibraryKind.create("griffon"); + public static final LibraryKind GRIFFON_KIND = LibraryKind.create("griffon"); @NonNls private static final Pattern GRIFFON_JAR_FILE_PATTERN = Pattern.compile("griffon-rt-(\\d.*)\\.jar"); public GriffonLibraryPresentationProvider() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java index a645a1bcb3a3..5af78e09db0f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java @@ -522,7 +522,7 @@ public abstract class MvcFramework { public abstract MvcProjectStructure createProjectStructure(@NotNull Module module, boolean auxModule); - public abstract LibraryKind getLibraryKind(); + public abstract LibraryKind getLibraryKind(); public abstract String getSomeFrameworkClass(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryType.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryType.java index a53817dde091..0eff8e964288 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryType.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -16,9 +16,9 @@ package org.jetbrains.idea.maven.utils.library; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.libraries.LibraryKind; import com.intellij.openapi.roots.libraries.LibraryType; import com.intellij.openapi.roots.libraries.NewLibraryConfiguration; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent; import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor; import com.intellij.openapi.vfs.VirtualFile; @@ -32,7 +32,13 @@ import javax.swing.*; * @author nik */ public class RepositoryLibraryType extends LibraryType { - private static final LibraryKind LIBRARY_KIND = LibraryKind.create("repository"); + private static final PersistentLibraryKind LIBRARY_KIND = new PersistentLibraryKind("repository", false) { + @NotNull + @Override + public RepositoryLibraryProperties createDefaultProperties() { + return new RepositoryLibraryProperties(); + } + }; public static RepositoryLibraryType getInstance() { return EP_NAME.findExtension(RepositoryLibraryType.class); @@ -54,12 +60,6 @@ public class RepositoryLibraryType extends LibraryType component) { return new RepositoryLibraryEditor(component, this);