LibraryType/LibraryKind refactoring: move UI-independent stuff from LibraryType to LibraryKind, use it whenever possible

This commit is contained in:
Dmitry Jemerov
2012-05-17 13:04:27 +02:00
parent 87b01fcb81
commit 4874535d59
48 changed files with 309 additions and 239 deletions
@@ -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<? extends LibraryKind<?>> libraryKinds = myLibraryDescription.getSuitableLibraryKinds();
final Set<? extends LibraryKind> libraryKinds = myLibraryDescription.getSuitableLibraryKinds();
final Ref<Boolean> found = Ref.create(false);
myContext.getRootModel().orderEntries().using(myContext.getModulesProvider()).recursively().librariesOnly().forEachLibrary(new Processor<Library>() {
@Override
@@ -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<LibraryVersionPropertie
private final String myLibraryCategoryName;
private final DownloadableLibraryDescription myLibraryDescription;
public DownloadableLibraryType(@NotNull LibraryKind<LibraryVersionProperties> kind, @NotNull String libraryCategoryName,
public DownloadableLibraryType(@NotNull PersistentLibraryKind<LibraryVersionProperties> kind, @NotNull String libraryCategoryName,
@NotNull DownloadableLibraryDescription description) {
super(kind);
myLibraryCategoryName = libraryCategoryName;
@@ -69,12 +69,6 @@ public class DownloadableLibraryType extends LibraryType<LibraryVersionPropertie
return StringUtil.capitalize(myLibraryCategoryName) + " library" + (versionString != null ? " of version " + versionString : "");
}
@NotNull
@Override
public LibraryVersionProperties createDefaultProperties() {
return new LibraryVersionProperties();
}
@Override
public LibraryPropertiesEditor createPropertiesEditor(@NotNull LibraryEditorComponent<LibraryVersionProperties> editorComponent) {
return DownloadableLibraryService.getInstance().createDownloadableLibraryEditor(myLibraryDescription, editorComponent, this);
@@ -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<LibraryVersionProperties>(libraryTypeId), libraryCategoryName,
super(new PersistentLibraryKind<LibraryVersionProperties>(libraryTypeId, false) {
@NotNull
@Override
public LibraryVersionProperties createDefaultProperties() {
return new LibraryVersionProperties();
}
}, libraryCategoryName,
DownloadableLibraryService.getInstance().createLibraryDescription(groupId, localUrls));
myIcon = icon;
}
@@ -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<? extends LibraryKind<?>> getSuitableLibraryKinds() {
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
return Collections.singleton(myLibraryType.getKind());
}
@@ -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<? extends LibraryKind<?>> getSuitableLibraryKinds() {
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
return Collections.emptySet();
}
@@ -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);
@@ -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<Libra
private final JComponent myParentComponent;
private final Module myModule;
private final LibraryTable.ModifiableModel myModuleLibrariesModel;
@Nullable private final Function<LibraryType, LibraryProperties> myDefaultPropertiesFactory;
private final HashMap<LibraryRootsComponentDescriptor,LibraryType> 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<? extends LibraryType> libraryTypes, JComponent parentComponent,
Module module,
final LibraryTable.ModifiableModel moduleLibrariesModel) {
final LibraryTable.ModifiableModel moduleLibrariesModel,
@Nullable final Function<LibraryType, LibraryProperties> defaultPropertiesFactory) {
myParentComponent = parentComponent;
myModule = module;
myModuleLibrariesModel = moduleLibrariesModel;
myDefaultPropertiesFactory = defaultPropertiesFactory;
myLibraryTypes = new HashMap<LibraryRootsComponentDescriptor, LibraryType>();
myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor();
for (LibraryType<?> libraryType : libraryTypes) {
@@ -76,8 +83,11 @@ public class CreateModuleLibraryChooser implements ClasspathElementChooser<Libra
}
private Library createLibraryFromRoots(List<OrderRoot> 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());
@@ -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<? extends LibraryKind<?>> getSuitableLibraryKinds();
public abstract Set<? extends LibraryKind> getSuitableLibraryKinds();
@Nullable
public abstract NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory);
@@ -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<Module> getSuitableModules(@NotNull ModuleStructureConfigurable rootConfigurable,
final @Nullable LibraryType type, @Nullable Library library) {
final @Nullable LibraryKind kind, @Nullable Library library) {
final List<Module> modules = new ArrayList<Module>();
LibraryType type = kind == null ? null : LibraryType.findByKind(kind);
for (Module module : rootConfigurable.getModules()) {
if (type != null && !type.isSuitableModule(module, rootConfigurable.getFacetConfigurator())) {
continue;
@@ -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<String> getDescriptions(@NotNull Library library, StructureConfigurableContext context);
@NotNull
public abstract List<String> getDescriptions(@NotNull VirtualFile[] classRoots, Set<LibraryKind<?>> excludedKinds);
public abstract List<String> getDescriptions(@NotNull VirtualFile[] classRoots, Set<LibraryKind> excludedKinds);
public abstract List<Library> getLibraries(@NotNull Set<LibraryKind<?>> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context);
public abstract List<Library> getLibraries(@NotNull Set<LibraryKind> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context);
public abstract boolean isLibraryOfKind(@NotNull List<VirtualFile> files, @NotNull LibraryKind<?> kind);
public abstract boolean isLibraryOfKind(@NotNull List<VirtualFile> files, @NotNull LibraryKind kind);
public abstract boolean isLibraryOfKind(@NotNull Library library, @NotNull LibrariesContainer librariesContainer,
@NotNull Set<? extends LibraryKind<?>> acceptedKinds);
@NotNull Set<? extends LibraryKind> acceptedKinds);
}
@@ -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<LibraryKind<?>, LibraryPresentationProvider<?>> myPresentationProviders;
private Map<LibraryKind, LibraryPresentationProvider<?>> myPresentationProviders;
private <P extends LibraryProperties> LibraryPresentationProvider<P> getPresentationProvider(LibraryKind<P> kind) {
private <P extends LibraryProperties> LibraryPresentationProvider<P> getPresentationProvider(LibraryKind kind) {
if (myPresentationProviders == null) {
final Map<LibraryKind<?>, LibraryPresentationProvider<?>> providers = new HashMap<LibraryKind<?>, LibraryPresentationProvider<?>>();
final Map<LibraryKind, LibraryPresentationProvider<?>> providers = new HashMap<LibraryKind, LibraryPresentationProvider<?>>();
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<Icon> icons = getCustomIcons(library, context);
if (icons.size() == 1) {
@@ -80,7 +80,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
final List<Icon> icons = new SmartList<Icon>();
LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() {
@Override
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> kind, @NotNull P properties) {
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
final LibraryPresentationProvider<P> 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<VirtualFile> files, @NotNull final LibraryKind<?> kind) {
public boolean isLibraryOfKind(@NotNull List<VirtualFile> files, @NotNull final LibraryKind kind) {
return !LibraryDetectionManager.getInstance().processProperties(files, new LibraryDetectionManager.LibraryPropertiesProcessor() {
@Override
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> processedKind, @NotNull P properties) {
public <P extends LibraryProperties> 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<? extends LibraryKind<?>> acceptedKinds) {
final LibraryType<?> type = ((LibraryEx)library).getType();
if (type != null && acceptedKinds.contains(type.getKind())) return true;
@NotNull final Set<? extends LibraryKind> 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 <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> processedKind, @NotNull P properties) {
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind processedKind, @NotNull P properties) {
return !acceptedKinds.contains(processedKind);
}
});
}
public static List<LibraryKind<?>> getLibraryKinds(@NotNull Library library, @Nullable StructureConfigurableContext context) {
final List<LibraryKind<?>> result = new SmartList<LibraryKind<?>>();
final LibraryType<?> type = ((LibraryEx)library).getType();
if (type != null) {
result.add(type.getKind());
public static List<LibraryKind> getLibraryKinds(@NotNull Library library, @Nullable StructureConfigurableContext context) {
final List<LibraryKind> result = new SmartList<LibraryKind>();
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 <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> kind, @NotNull P properties) {
public <P extends LibraryProperties> 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<String> getDescriptions(@NotNull Library library, StructureConfigurableContext context) {
final VirtualFile[] files = getLibraryFiles(library, context);
return getDescriptions(files, Collections.<LibraryKind<?>>emptySet());
return getDescriptions(files, Collections.<LibraryKind>emptySet());
}
@NotNull
@@ -151,11 +151,11 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
@NotNull
@Override
public List<String> getDescriptions(@NotNull VirtualFile[] classRoots, final Set<LibraryKind<?>> excludedKinds) {
public List<String> getDescriptions(@NotNull VirtualFile[] classRoots, final Set<LibraryKind> excludedKinds) {
final SmartList<String> result = new SmartList<String>();
LibraryDetectionManager.getInstance().processProperties(Arrays.asList(classRoots), new LibraryDetectionManager.LibraryPropertiesProcessor() {
@Override
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> kind, @NotNull P properties) {
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
if (!excludedKinds.contains(kind)) {
final LibraryPresentationProvider<P> provider = getPresentationProvider(kind);
if (provider != null) {
@@ -169,7 +169,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
}
@Override
public List<Library> getLibraries(@NotNull Set<LibraryKind<?>> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) {
public List<Library> getLibraries(@NotNull Set<LibraryKind> kinds, @NotNull Project project, @Nullable StructureConfigurableContext context) {
List<Library> libraries = new ArrayList<Library>();
if (context != null) {
Collections.addAll(libraries, context.getProjectLibrariesProvider().getModifiableModel().getLibraries());
@@ -184,7 +184,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
final Iterator<Library> iterator = libraries.iterator();
while (iterator.hasNext()) {
Library library = iterator.next();
final List<LibraryKind<?>> libraryKinds = getLibraryKinds(library, context);
final List<LibraryKind> libraryKinds = getLibraryKinds(library, context);
if (!ContainerUtil.intersects(libraryKinds, kinds)) {
iterator.remove();
}
@@ -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<UsageDescriptor> getProjectUsages(@Nullable Project project) {
if (project == null) return Collections.emptySet();
final Set<LibraryKind<?>> usedKinds = new HashSet<LibraryKind<?>>();
final Set<LibraryKind> usedKinds = new HashSet<LibraryKind>();
final Processor<Library> processor = new Processor<Library>() {
@Override
public boolean process(Library library) {
@@ -57,7 +58,7 @@ public class LibraryUsageCollector extends AbstractApplicationUsagesCollector {
}
final HashSet<UsageDescriptor> usageDescriptors = new HashSet<UsageDescriptor>();
for (LibraryKind<?> kind : usedKinds) {
for (LibraryKind kind : usedKinds) {
usageDescriptors.add(new UsageDescriptor(kind.getKindId(), 1));
}
return usageDescriptors;
@@ -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);
}
}
@@ -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() {
@@ -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());
}
@@ -121,8 +121,8 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
public void updatePropertiesLabel() {
StringBuilder text = new StringBuilder();
final LibraryType<?> type = getLibraryEditor().getType();
final Set<LibraryKind<?>> excluded =
type != null ? Collections.<LibraryKind<?>>singleton(type.getKind()) : Collections.<LibraryKind<?>>emptySet();
final Set<LibraryKind> excluded =
type != null ? Collections.<LibraryKind>singleton(type.getKind()) : Collections.<LibraryKind>emptySet();
for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES),
excluded)) {
if (text.length() > 0) {
@@ -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);
}
@@ -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.<String, String>emptyMap(), model);
}
@@ -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);
@@ -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);
@@ -63,7 +63,7 @@ public abstract class ProjectStructureValidator {
}
final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
final List<Module> modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getType(), library);
final List<Module> 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"),
@@ -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<LibraryGroupElement> {
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) {
@@ -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<OrderRootType, VirtualFilePointerContainer> 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<OrderRootType> getAllRootTypes() {
Set<OrderRootType> rootTypes = new HashSet<OrderRootType>();
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<VirtualFile> 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<OrderRootType> storableRootTypes = new ArrayList<OrderRootType>();
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;
@@ -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);
}
}
@@ -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 <P extends LibraryProperties<?>> NewLibraryConfiguration doCreate(final LibraryType<P> type, final String name, final List<OrderRoot> 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);
@@ -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<LibraryType<?>, LibraryProperties<?>> detectType(@NotNull List<VirtualFile> files);
public interface LibraryPropertiesProcessor {
<P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind<P> kind, @NotNull P properties);
<P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties);
}
}
@@ -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<P extends LibraryProperties> {
public static final ExtensionPointName<LibraryPresentationProvider> EP_NAME = ExtensionPointName.create("com.intellij.library.presentationProvider");
private final LibraryKind<P> myKind;
private final LibraryKind myKind;
protected LibraryPresentationProvider(@NotNull LibraryKind<P> kind) {
protected LibraryPresentationProvider(@NotNull LibraryKind kind) {
myKind = kind;
}
@NotNull
public final LibraryKind<P> getKind() {
public LibraryKind getKind() {
return myKind;
}
@@ -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<P extends LibraryProperties> extends LibraryPr
public final static OrderRootType[] DEFAULT_EXTERNAL_ROOT_TYPES = {OrderRootType.CLASSES};
protected LibraryType(@NotNull LibraryKind<P> libraryKind) {
protected LibraryType(@NotNull PersistentLibraryKind<P> libraryKind) {
super(libraryKind);
}
@NotNull
@Override
public PersistentLibraryKind<P> getKind() {
return (PersistentLibraryKind<P>) 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<P extends LibraryProperties> 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<P extends LibraryProperties> 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");
}
}
@@ -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,
@@ -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;
}
}
@@ -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;
@@ -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);
@@ -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();
}
@@ -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();
}
@@ -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();
}
}
@@ -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<Eleme
}
public interface ModifiableModelEx extends ModifiableModel {
Library createLibrary(String name, @Nullable LibraryType type);
Library createLibrary(String name, @Nullable PersistentLibraryKind type);
}
public class LibraryModel implements ModifiableModelEx, JDOMExternalizable {
@@ -244,9 +244,9 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
}
@Override
public Library createLibrary(String name, @Nullable LibraryType type) {
public Library createLibrary(String name, @Nullable PersistentLibraryKind kind) {
assertWritable();
final LibraryImpl library = new LibraryImpl(name, type, LibraryTableBase.this, null);
final LibraryImpl library = new LibraryImpl(name, kind, LibraryTableBase.this, null);
myLibraries.add(library);
return library;
}
@@ -21,11 +21,11 @@ import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class LibraryKind<P extends LibraryProperties> {
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<P extends LibraryProperties> {
* @param kindId must be unique among all {@link LibraryType} and {@link LibraryPresentationProvider} implementations
* @return new {@link LibraryKind} instance
*/
public static <P extends LibraryProperties> LibraryKind<P> create(@NotNull @NonNls String kindId) {
return new LibraryKind<P>(kindId);
public static LibraryKind create(@NotNull @NonNls String kindId) {
return new LibraryKind(kindId);
}
}
@@ -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<P extends LibraryProperties> 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];
}
}
@@ -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<GroovyLibraryProperties> GRADLE_KIND = LibraryKind.create(GradleConstants.EXTENSION);
private static final LibraryKind GRADLE_KIND = LibraryKind.create(GradleConstants.EXTENSION);
private final GradleLibraryManager myLibraryManager;
@@ -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<? extends LibraryKind<?>> myLibraryKinds;
private final Set<? extends LibraryKind> myLibraryKinds;
private final String myFrameworkName;
public GroovyLibraryDescription() {
this("GROOVY_HOME", getAllGroovyKinds(), GROOVY_FRAMEWORK_NAME);
}
public static Set<? extends LibraryKind<?>> getAllGroovyKinds() {
final HashSet<LibraryKind<?>> kinds = new HashSet<LibraryKind<?>>();
public static Set<? extends LibraryKind> getAllGroovyKinds() {
final HashSet<LibraryKind> kinds = new HashSet<LibraryKind>();
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<? extends LibraryKind<?>> libraryKinds, String frameworkName) {
private GroovyLibraryDescription(@NotNull String envVariable, @NotNull final Set<? extends LibraryKind> libraryKinds, String frameworkName) {
myEnvVariable = envVariable;
myLibraryKinds = libraryKinds;
myFrameworkName = frameworkName;
@@ -88,7 +88,7 @@ public class GroovyLibraryDescription extends CustomLibraryDescription {
@NotNull
@Override
public Set<? extends LibraryKind<?>> getSuitableLibraryKinds() {
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
return myLibraryKinds;
}
@@ -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<GroovyLibraryProperties> GROOVY_KIND = LibraryKind.create("groovy");
public static final LibraryKind GROOVY_KIND = LibraryKind.create("groovy");
public GroovyLibraryPresentationProvider() {
super(GROOVY_KIND);
@@ -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<GroovyLibraryProperties> {
public GroovyLibraryPresentationProviderBase(LibraryKind<GroovyLibraryProperties> kind) {
public GroovyLibraryPresentationProviderBase(LibraryKind kind) {
super(kind);
}
@@ -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<GroovyLibraryProperties> GANT_KIND = LibraryKind.create("gant");
private static final LibraryKind GANT_KIND = LibraryKind.create("gant");
public GantLibraryPresentationProvider() {
super(GANT_KIND);
@@ -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<GroovyLibraryProperties> 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");
@@ -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;
}
@@ -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<GroovyLibraryProperties> 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() {
@@ -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();
@@ -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<RepositoryLibraryProperties> {
private static final LibraryKind<RepositoryLibraryProperties> LIBRARY_KIND = LibraryKind.create("repository");
private static final PersistentLibraryKind<RepositoryLibraryProperties> LIBRARY_KIND = new PersistentLibraryKind<RepositoryLibraryProperties>("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<RepositoryLibraryProperti
return RepositoryAttachHandler.chooseLibraryAndDownload(project, null);
}
@NotNull
@Override
public RepositoryLibraryProperties createDefaultProperties() {
return new RepositoryLibraryProperties();
}
@Override
public LibraryPropertiesEditor createPropertiesEditor(@NotNull LibraryEditorComponent<RepositoryLibraryProperties> component) {
return new RepositoryLibraryEditor(component, this);