library types

This commit is contained in:
nik
2010-10-20 12:23:24 +04:00
parent 13734c2cfe
commit e23ceb0916
36 changed files with 544 additions and 121 deletions
@@ -41,7 +41,8 @@ public class EditLibraryDialog extends DialogWrapper {
super(parent, true);
mySettings = settings;
myLibraryEditor = libraryEditor;
myLibraryRootsComponent = LibraryRootsComponent.createComponent(libraryEditor);
myLibraryRootsComponent = new LibraryRootsComponent(null, libraryEditor);
myLibraryRootsComponent.resetProperties();
Disposer.register(getDisposable(), myLibraryRootsComponent);
@@ -63,6 +64,7 @@ public class EditLibraryDialog extends DialogWrapper {
@Override
protected void doOKAction() {
myLibraryEditor.setName(myNameAndLevelPanel.getLibraryName());
myLibraryRootsComponent.applyProperties();
if (myLibraryEditor instanceof NewLibraryEditor) {
mySettings.setNewLibraryLevel(myNameAndLevelPanel.getLibraryLevel());
}
@@ -19,8 +19,8 @@ import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureDialogCellAppearanceUtils;
import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureDialogCellAppearanceUtils;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
@@ -22,9 +22,9 @@ import com.intellij.ide.IdeBundle;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration;
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription;
import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsComponent">
<grid id="e9129" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="6" vgap="-1">
<grid id="e9129" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="6" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="91" y="83" width="403" height="352"/>
@@ -11,7 +11,7 @@
<grid id="1f4da" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="0" vgap="6">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -90,7 +90,7 @@
<xy id="bc98" binding="myTreePanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="300" height="-1"/>
</grid>
</constraints>
@@ -104,6 +104,14 @@
</constraints>
<properties/>
</component>
<grid id="19827" binding="myPropertiesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
@@ -340,12 +340,12 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
}
public ActionCallback selectProjectGeneralSettings(final boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, myProjectConfig);
Place place = createPlaceFor(myProjectConfig);
return navigateTo(place, requestFocus);
}
public ActionCallback select(@Nullable final String moduleToSelect, String tab, final boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, myModulesConfig);
Place place = createPlaceFor(myModulesConfig);
if (moduleToSelect != null) {
final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleToSelect);
assert module != null;
@@ -355,7 +355,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
}
public ActionCallback select(@Nullable final Facet facetToSelect, final boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, myModulesConfig);
Place place = createPlaceFor(myModulesConfig);
if (facetToSelect != null) {
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, facetToSelect);
}
@@ -363,19 +363,19 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
}
public ActionCallback select(@NotNull Sdk sdk, final boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, myJdkListConfig);
Place place = createPlaceFor(myJdkListConfig);
place.putPath(BaseStructureConfigurable.TREE_NAME, sdk.getName());
return navigateTo(place, requestFocus);
}
public ActionCallback selectProjectOrGlobalLibrary(@NotNull Library library, boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, getConfigurableFor(library));
Place place = createPlaceFor(getConfigurableFor(library));
place.putPath(BaseStructureConfigurable.TREE_NAME, library.getName());
return navigateTo(place, requestFocus);
}
public ActionCallback select(@Nullable Artifact artifact, boolean requestFocus) {
Place place = new Place().putPath(CATEGORY, myArtifactsStructureConfigurable);
Place place = createPlaceFor(myArtifactsStructureConfigurable);
if (artifact != null) {
place.putPath(BaseStructureConfigurable.TREE_NAME, artifact.getName());
}
@@ -385,11 +385,11 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
public ActionCallback select(@NotNull LibraryOrderEntry libraryOrderEntry, final boolean requestFocus) {
final Library lib = libraryOrderEntry.getLibrary();
if (lib == null || lib.getTable() == null) {
Place place = new Place().putPath(CATEGORY, myModulesConfig);
Place place = createPlaceFor(myModulesConfig);
place.putPath(BaseStructureConfigurable.TREE_OBJECT, libraryOrderEntry.getOwnerModule());
return navigateTo(place, requestFocus);
}
Place place = new Place().putPath(CATEGORY, getConfigurableFor(lib));
Place place = createPlaceFor(getConfigurableFor(lib));
place.putPath(BaseStructureConfigurable.TREE_NAME, libraryOrderEntry.getLibraryName());
return navigateTo(place, requestFocus);
}
@@ -400,6 +400,9 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
JComponent detailsContent = myDetails.getTargetComponent();
if (mySelectedConfigurable != toSelect) {
if (mySelectedConfigurable instanceof BaseStructureConfigurable) {
((BaseStructureConfigurable)mySelectedConfigurable).onStructureUnselected();
}
saveSideProportion();
removeSelected();
@@ -424,6 +427,10 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
if (toSelect instanceof DetailsComponent.Facade) {
((DetailsComponent.Facade)toSelect).getDetailsComponent().setBannerMinHeight(myToolbarComponent.getPreferredSize().height);
}
if (toSelect instanceof BaseStructureConfigurable) {
((BaseStructureConfigurable)toSelect).onStructureSelected();
}
}
@@ -58,6 +58,10 @@ 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 List<Icon> icons = getCustomIcons(library, context);
if (icons.size() == 1) {
return icons.get(0);
@@ -22,17 +22,17 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryType;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil;
import com.intellij.openapi.roots.ui.configuration.projectRoot.BaseLibrariesConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureLibraryTableModifiableModelProvider;
import com.intellij.openapi.ui.InputValidator;
import com.intellij.openapi.ui.MasterDetailsComponent;
import com.intellij.openapi.ui.Messages;
import com.intellij.util.Icons;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -44,40 +44,21 @@ import java.util.List;
* @author nik
*/
public class CreateNewLibraryAction extends AnAction {
private StructureLibraryTableModifiableModelProvider myModelProvider;
private Project myProject;
private final @Nullable LibraryType myType;
private BaseLibrariesConfigurable myLibrariesConfigurable;
private @Nullable Project myProject;
public CreateNewLibraryAction(String text, StructureLibraryTableModifiableModelProvider modelProvider, final Project project) {
super(text);
myModelProvider = modelProvider;
private CreateNewLibraryAction(@NotNull String text, @Nullable Icon icon, @Nullable LibraryType type, @NotNull BaseLibrariesConfigurable librariesConfigurable, final @Nullable Project project) {
super(text, null, icon);
myType = type;
myLibrariesConfigurable = librariesConfigurable;
myProject = project;
}
@Override
public void actionPerformed(AnActionEvent e) {
final LibrariesModifiableModel modifiableModel = myModelProvider.getModifiableModel();
final String initial = LibraryEditingUtil.suggestNewLibraryName(modifiableModel);
final String prompt = ProjectBundle.message("library.name.prompt");
final String title = ProjectBundle.message("library.create.library.action").replaceAll(String.valueOf(UIUtil.MNEMONIC), "");
final Icon icon = Messages.getQuestionIcon();
final String libraryName = Messages.showInputDialog(myProject, prompt, title, icon, initial, new InputValidator() {
public boolean checkInput(final String inputString) {
return true;
}
public boolean canClose(final String inputString) {
if (inputString.length() == 0) {
Messages.showErrorDialog(ProjectBundle.message("library.name.not.specified.error"), ProjectBundle.message("library.name.not.specified.title"));
return false;
}
if (LibraryEditingUtil.libraryAlreadyExists(modifiableModel, inputString)) {
Messages.showErrorDialog(ProjectBundle.message("library.name.already.exists.error", inputString), ProjectBundle.message("library.name.already.exists.title"));
return false;
}
return true;
}
});
if (libraryName == null) return;
final Library library = modifiableModel.createLibrary(libraryName);
final LibrariesModifiableModel modifiableModel = myLibrariesConfigurable.getModelProvider().getModifiableModel();
final Library library = modifiableModel.createLibrary(LibraryEditingUtil.suggestNewLibraryName(modifiableModel), myType);
if (myProject != null){
final BaseLibrariesConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
final ExistingLibraryEditor libraryEditor = modifiableModel.getLibraryEditor(library);
@@ -105,10 +86,23 @@ public class CreateNewLibraryAction extends AnAction {
.message("choose.modules.dialog.description", libraryToSelect.getName()));
dlg.show();
if (dlg.isOK()) {
final List<Module> choosenModules = dlg.getChosenElements();
for (Module module : choosenModules) {
final List<Module> chosenModules = dlg.getChosenElements();
for (Module module : chosenModules) {
rootConfigurable.addLibraryOrderEntry(module, libraryToSelect);
}
}
}
public static AnAction[] createActionOrGroup(@NotNull String text, @NotNull BaseLibrariesConfigurable librariesConfigurable, final @Nullable Project project) {
final LibraryType<?>[] extensions = LibraryType.EP_NAME.getExtensions();
if (extensions.length == 0) {
return new AnAction[]{new CreateNewLibraryAction(text, Icons.LIBRARY_ICON, null, librariesConfigurable, project)};
}
List<AnAction> actions = new ArrayList<AnAction>();
actions.add(new CreateNewLibraryAction("Java", Icons.LIBRARY_ICON, null, librariesConfigurable, project));
for (LibraryType<?> type : extensions) {
actions.add(new CreateNewLibraryAction(type.getCreateActionName(), type.getIcon(), type, librariesConfigurable, project));
}
return actions.toArray(new AnAction[actions.size()]);
}
}
@@ -44,7 +44,7 @@ public class CreateNewLibraryDialog extends LibraryEditorDialogBase {
public CreateNewLibraryDialog(@NotNull JComponent parent, @Nullable Project project, @NotNull NewLibraryEditor libraryEditor,
@NotNull List<LibraryTable> libraryTables, int selectedTable) {
super(parent, LibraryRootsComponent.createComponent(project, libraryEditor));
super(parent, new LibraryRootsComponent(project, libraryEditor));
myLibraryEditor = libraryEditor;
final DefaultComboBoxModel model = new DefaultComboBoxModel();
for (LibraryTable table : libraryTables) {
@@ -53,7 +53,7 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
private EditExistingLibraryDialog(Component parent,
LibraryTable.ModifiableModel tableModifiableModel,
@Nullable Project project, ExistingLibraryEditor libraryEditor, boolean commitChanges) {
super(parent, LibraryRootsComponent.createComponent(project, libraryEditor));
super(parent, new LibraryRootsComponent(project, libraryEditor));
myTableModifiableModel = tableModifiableModel;
myLibraryEditor = libraryEditor;
myCommitChanges = commitChanges;
@@ -17,18 +17,23 @@ 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.LibraryProperties;
import com.intellij.openapi.roots.libraries.LibraryType;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ExistingLibraryEditor implements LibraryEditor, Disposable {
private final Library myLibrary;
private final LibraryEditorListener myListener;
private String myLibraryName = null;
private LibraryProperties myLibraryProperties;
private Library.ModifiableModel myModel = null;
public ExistingLibraryEditor(Library library, @Nullable LibraryEditorListener listener) {
public ExistingLibraryEditor(@NotNull Library library, @Nullable LibraryEditorListener listener) {
myLibrary = library;
myListener = listener;
}
@@ -45,6 +50,28 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
return myLibrary.getName();
}
@Override
public LibraryType getType() {
return ((LibraryEx)myLibrary).getType();
}
@Override
public LibraryProperties getProperties() {
final LibraryType type = getType();
if (type == null) return null;
if (myLibraryProperties == null) {
myLibraryProperties = type.createDefaultProperties();
//noinspection unchecked
myLibraryProperties.loadState(getOriginalProperties().getState());
}
return myLibraryProperties;
}
private LibraryProperties getOriginalProperties() {
return ((LibraryEx)myLibrary).getProperties();
}
public void dispose() {
if (myModel != null) {
// dispose if wasn't committed
@@ -105,9 +132,13 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
public void commit() {
if (myModel != null) {
if (myLibraryProperties != null) {
((LibraryEx.ModifiableModelEx)myModel).setProperties(myLibraryProperties);
}
myModel.commit();
myModel = null;
myLibraryName = null;
myLibraryProperties = null;
}
}
@@ -120,7 +151,10 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
@Override
public boolean hasChanges() {
return myModel != null && myModel.isChanged();
if (myModel != null && myModel.isChanged()) {
return true;
}
return myLibraryProperties != null && !myLibraryProperties.equals(getOriginalProperties());
}
@Override
@@ -16,7 +16,10 @@
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.LibraryProperties;
import com.intellij.openapi.roots.libraries.LibraryType;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
@@ -45,4 +48,9 @@ public interface LibraryEditor {
boolean isJarDirectory(String url);
boolean isValid(String url, OrderRootType orderRootType);
LibraryProperties getProperties();
@Nullable
LibraryType getType();
}
@@ -40,6 +40,7 @@ public abstract class LibraryEditorDialogBase extends DialogWrapper {
public LibraryEditorDialogBase(final Component parent, final LibraryRootsComponent libraryRootsComponent) {
super(parent, true);
myLibraryRootsComponent = libraryRootsComponent;
libraryRootsComponent.resetProperties();
setTitle(ProjectBundle.message("library.configure.title"));
Disposer.register(getDisposable(), myLibraryRootsComponent);
}
@@ -83,6 +84,7 @@ public abstract class LibraryEditorDialogBase extends DialogWrapper {
}
myLibraryRootsComponent.renameLibrary(newName);
}
myLibraryRootsComponent.applyProperties();
return true;
}
@@ -31,8 +31,9 @@ import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.roots.JavadocOrderRootType;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryUtil;
import com.intellij.openapi.roots.libraries.*;
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor;
import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
import com.intellij.openapi.roots.ui.configuration.PathUIUtils;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
@@ -74,7 +75,7 @@ import java.util.List;
* @author Eugene Zhuravlev
* Date: Jan 11, 2004
*/
public class LibraryRootsComponent implements Disposable {
public class LibraryRootsComponent implements Disposable, LibraryEditorComponent {
static final UrlComparator ourUrlComparator = new UrlComparator();
private JPanel myPanel;
@@ -88,6 +89,8 @@ public class LibraryRootsComponent implements Disposable {
private JButton myAttachAnnotationsButton;
private JButton myAttachMoreButton;
private MultiLineLabel myPropertiesLabel;
private JPanel myPropertiesPanel;
private LibraryPropertiesEditor myPropertiesEditor;
private Tree myTree;
private LibraryTableTreeBuilder myTreeBuilder;
private static final Icon INVALID_ITEM_ICON = IconLoader.getIcon("/nodes/ppInvalid.png");
@@ -97,14 +100,34 @@ public class LibraryRootsComponent implements Disposable {
@Nullable private final Project myProject;
private final Map<DataKey, Object> myFileChooserUserData = new HashMap<DataKey, Object>();
private final Computable<LibraryEditor> myLibraryEditor;
private final Computable<LibraryEditor> myLibraryEditorComputable;
private LibraryRootsComponent(@Nullable Project project, @NotNull Computable<LibraryEditor> libraryEditor) {
public LibraryRootsComponent(@Nullable Project project, @NotNull LibraryEditor libraryEditor) {
this(project, new Computable.PredefinedValueComputable<LibraryEditor>(libraryEditor));
}
public LibraryRootsComponent(@Nullable Project project, @NotNull Computable<LibraryEditor> libraryEditorComputable) {
myProject = project;
myLibraryEditor = libraryEditor;
myLibraryEditorComputable = libraryEditorComputable;
final LibraryEditor editor = getLibraryEditor();
final LibraryType type = editor.getType();
if (type != null) {
//noinspection unchecked
myPropertiesEditor = type.createPropertiesEditor(this);
if (myPropertiesEditor != null) {
myPropertiesPanel.add(myPropertiesEditor.createComponent(), BorderLayout.CENTER);
}
}
init(new LibraryTreeStructure(this));
updateProperties();
}
@NotNull
@Override
public LibraryProperties getProperties() {
return getLibraryEditor().getProperties();
}
private void updateProperties() {
StringBuilder text = new StringBuilder();
for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES))) {
@@ -116,20 +139,6 @@ public class LibraryRootsComponent implements Disposable {
myPropertiesLabel.setText(text.toString());
}
public static LibraryRootsComponent createComponent(final @Nullable Project project, @NotNull LibraryEditor libraryEditor) {
return createComponent(project, new Computable.PredefinedValueComputable<LibraryEditor>(libraryEditor));
}
public static LibraryRootsComponent createComponent(final @Nullable Project project, @NotNull Computable<LibraryEditor> libraryEditor) {
LibraryRootsComponent rootsComponent = new LibraryRootsComponent(project, libraryEditor);
rootsComponent.init(new LibraryTreeStructure(rootsComponent));
return rootsComponent;
}
public static LibraryRootsComponent createComponent(@NotNull LibraryEditor libraryEditor) {
return createComponent(null, libraryEditor);
}
private void init(AbstractTreeStructure treeStructure) {
myTree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode()));
myTree.setRootVisible(false);
@@ -179,10 +188,13 @@ public class LibraryRootsComponent implements Disposable {
}
public LibraryEditor getLibraryEditor() {
return myLibraryEditor.compute();
return myLibraryEditorComputable.compute();
}
public boolean hasChanges() {
if (myPropertiesEditor != null && myPropertiesEditor.isModified()) {
return true;
}
return getLibraryEditor().hasChanges();
}
@@ -229,9 +241,24 @@ public class LibraryRootsComponent implements Disposable {
}
public void dispose() {
if (myPropertiesEditor != null) {
myPropertiesEditor.disposeUIResources();
}
myTreeBuilder = null;
}
public void resetProperties() {
if (myPropertiesEditor != null) {
myPropertiesEditor.reset();
}
}
public void applyProperties() {
if (myPropertiesEditor != null && myPropertiesEditor.isModified()) {
myPropertiesEditor.apply();
}
}
private abstract class AttachItemAction implements ActionListener {
private final FileChooserDescriptor myDescriptor;
private VirtualFile myLastChosen = null;
@@ -18,12 +18,15 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
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.ui.LightFilePointer;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -34,11 +37,30 @@ public class NewLibraryEditor implements LibraryEditor {
private String myLibraryName;
private final MultiMap<OrderRootType, LightFilePointer> myRoots;
private final Map<String, Boolean> myJarDirectories = new HashMap<String, Boolean>();
private final LibraryType myType;
private LibraryProperties myProperties;
public NewLibraryEditor() {
this(null, null);
}
public NewLibraryEditor(LibraryType type, LibraryProperties properties) {
myType = type;
myProperties = properties;
myRoots = new MultiMap<OrderRootType, LightFilePointer>();
}
@Override
@Nullable
public LibraryType getType() {
return myType;
}
@Override
public LibraryProperties getProperties() {
return myProperties;
}
@Override
public String getName() {
return myLibraryName;
@@ -34,6 +34,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
@@ -86,8 +87,7 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
for (final LibrariesModifiableModel provider : myContext.myLevel2Providers.values()) {
isModified |= provider.isChanged();
}
return isModified;
return isModified || super.isModified();
}
public void reset() {
@@ -169,13 +169,9 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
protected AbstractAddGroup createAddAction() {
return new AbstractAddGroup(getAddText()) {
{
setPopup(false);
}
@NotNull
public AnAction[] getChildren(@Nullable final AnActionEvent e) {
return new AnAction[]{new CreateNewLibraryAction(getAddText(), getModelProvider(), myProject)};
return CreateNewLibraryAction.createActionOrGroup(getAddText(), BaseLibrariesConfigurable.this, myProject);
}
};
}
@@ -186,6 +182,32 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
public abstract BaseLibrariesConfigurable getOppositeGroup();
@Override
protected void updateSelection(@Nullable NamedConfigurable configurable) {
boolean selectionChanged = !Comparing.equal(myCurrentConfigurable, configurable);
if (myCurrentConfigurable != null && selectionChanged) {
((LibraryConfigurable)myCurrentConfigurable).onUnselected();
}
super.updateSelection(configurable);
if (myCurrentConfigurable != null && selectionChanged) {
((LibraryConfigurable)myCurrentConfigurable).onSelected();
}
}
@Override
public void onStructureUnselected() {
if (myCurrentConfigurable != null) {
((LibraryConfigurable)myCurrentConfigurable).onUnselected();
}
}
@Override
public void onStructureSelected() {
if (myCurrentConfigurable != null) {
((LibraryConfigurable)myCurrentConfigurable).onSelected();
}
}
protected boolean removeLibrary(final Library library) {
final LibraryTable table = library.getTable();
if (table != null) {
@@ -349,6 +349,12 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
return null;
}
public void onStructureUnselected() {
}
public void onStructureSelected() {
}
@Nullable
protected abstract AbstractAddGroup createAddAction();
@@ -18,14 +18,17 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot;
import com.intellij.openapi.project.Project;
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.ui.configuration.ProjectStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -34,7 +37,7 @@ import java.util.*;
* Date: 04-Jun-2006
*/
public class LibrariesModifiableModel implements LibraryTable.ModifiableModel {
public class LibrariesModifiableModel implements LibraryTableBase.ModifiableModelEx {
private final Map<Library, ExistingLibraryEditor> myLibrary2EditorMap = new HashMap<Library, ExistingLibraryEditor>();
private final Set<Library> myRemovedLibraries = new HashSet<Library>();
@@ -50,8 +53,12 @@ public class LibrariesModifiableModel implements LibraryTable.ModifiableModel {
}
public Library createLibrary(String name) {
final Library library = getLibrariesModifiableModel().createLibrary(name);
//createLibraryEditor(library);
return createLibrary(name, null);
}
public Library createLibrary(String name, @Nullable LibraryType type) {
final Library library = ((LibraryTableBase.ModifiableModelEx)getLibrariesModifiableModel()).createLibrary(name, type);
//createLibraryEditor(library); \
final BaseLibrariesConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
configurable.createLibraryNode(library);
return library;
@@ -16,7 +16,6 @@
package com.intellij.openapi.roots.ui.configuration.projectRoot;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.libraries.Library;
@@ -38,13 +37,14 @@ import javax.swing.*;
* Date: 02-Jun-2006
*/
public class LibraryConfigurable extends ProjectStructureElementConfigurable<Library> {
private LibraryRootsComponent myLibraryEditor;
private LibraryRootsComponent myLibraryEditorComponent;
private final Library myLibrary;
private final StructureLibraryTableModifiableModelProvider myModel;
private final StructureConfigurableContext myContext;
private final Project myProject;
private final LibraryProjectStructureElement myProjectStructureElement;
private boolean myUpdatingName;
private boolean myPropertiesLoaded;
protected LibraryConfigurable(final StructureLibraryTableModifiableModelProvider modelProvider,
final Library library,
@@ -59,23 +59,23 @@ public class LibraryConfigurable extends ProjectStructureElementConfigurable<Lib
}
public JComponent createOptionsPanel() {
myLibraryEditor = LibraryRootsComponent.createComponent(myProject, new Computable<LibraryEditor>() {
myLibraryEditorComponent = new LibraryRootsComponent(myProject, new Computable<LibraryEditor>() {
@Override
public LibraryEditor compute() {
return myModel.getModifiableModel().getLibraryEditor(myLibrary);
return getLibraryEditor();
}
});
final StructureConfigurableContext context = ModuleStructureConfigurable.getInstance(myProject).getContext();
myLibraryEditor.addListener(new Runnable() {
myLibraryEditorComponent.addListener(new Runnable() {
public void run() {
context.getDaemonAnalyzer().queueUpdate(myProjectStructureElement);
}
});
return myLibraryEditor.getComponent();
return myLibraryEditorComponent.getComponent();
}
public boolean isModified() {
return myLibraryEditor != null && myLibraryEditor.hasChanges();
return myLibraryEditorComponent != null && myLibraryEditorComponent.hasChanges();
}
@Override
@@ -83,18 +83,18 @@ public class LibraryConfigurable extends ProjectStructureElementConfigurable<Lib
return myProjectStructureElement;
}
public void apply() throws ConfigurationException {
//do nothing
public void apply() {
applyProperties();
}
public void reset() {
//do nothing
resetProperties();
}
public void disposeUIResources() {
if (myLibraryEditor != null) {
Disposer.dispose(myLibraryEditor);
myLibraryEditor = null;
if (myLibraryEditorComponent != null) {
Disposer.dispose(myLibraryEditorComponent);
myLibraryEditorComponent = null;
}
}
@@ -140,6 +140,28 @@ public class LibraryConfigurable extends ProjectStructureElementConfigurable<Lib
return myLibrary.getName();
}
public void onSelected() {
resetProperties();
}
public void onUnselected() {
applyProperties();
}
private void resetProperties() {
if (myLibraryEditorComponent != null) {
myLibraryEditorComponent.resetProperties();
myPropertiesLoaded = true;
}
}
private void applyProperties() {
if (myLibraryEditorComponent != null && myPropertiesLoaded) {
myLibraryEditorComponent.applyProperties();
myPropertiesLoaded = false;
}
}
public Icon getIcon() {
return LibraryPresentationManager.getInstance().getNamedLibraryIcon(myLibrary, myContext);
}
@@ -21,6 +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.util.Disposer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
@@ -50,13 +51,9 @@ public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl imple
myScope = scope;
}
ModuleLibraryOrderEntryImpl(RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) {
this((String)null, rootModel, projectRootManager);
}
ModuleLibraryOrderEntryImpl(String name, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) {
ModuleLibraryOrderEntryImpl(String name, final LibraryType<?> type, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) {
super(rootModel, projectRootManager);
myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, getRootModel());
myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, type, getRootModel());
doinit();
}
@@ -21,10 +21,12 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ProjectBundle;
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.util.Condition;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ConvertingIterator;
@@ -39,7 +41,7 @@ import java.util.Iterator;
/**
* @author dsl
*/
public class ModuleLibraryTable implements LibraryTable, LibraryTable.ModifiableModel {
public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.ModifiableModelEx {
private static final ModuleLibraryOrderEntryCondition MODULE_LIBRARY_ORDER_ENTRY_FILTER = new ModuleLibraryOrderEntryCondition();
private static final OrderEntryToLibraryConvertor ORDER_ENTRY_TO_LIBRARY_CONVERTOR = new OrderEntryToLibraryConvertor();
private final RootModelImpl myRootModel;
@@ -72,13 +74,16 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTable.Modifiable
}
public Library createLibrary() {
final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(myRootModel, myProjectRootManager);
myRootModel.addOrderEntry(orderEntry);
return orderEntry.getLibrary();
return createLibrary(null);
}
public Library createLibrary(String name) {
final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(name, myRootModel, myProjectRootManager);
return createLibrary(name, null);
}
@Override
public Library createLibrary(String name, @Nullable LibraryType type) {
final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(name, type, myRootModel, myProjectRootManager);
myRootModel.addOrderEntry(orderEntry);
return orderEntry.getLibrary();
}
@@ -19,6 +19,8 @@ package com.intellij.openapi.roots.impl.libraries;
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;
/**
* @author dsl
@@ -30,7 +32,15 @@ public interface LibraryEx extends Library {
boolean isDisposed();
LibraryType<?> getType();
LibraryProperties getProperties();
interface ModifiableModelEx extends ModifiableModel {
boolean allPathsValid(OrderRootType type);
void setProperties(LibraryProperties properties);
LibraryProperties getProperties();
}
}
@@ -93,10 +93,14 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
updateWatchedRoots();
}
LibraryImpl(String name, LibraryTable table, ModifiableRootModel rootModel) {
LibraryImpl(String name, final @Nullable LibraryType<?> type, LibraryTable table, ModifiableRootModel rootModel) {
myName = name;
myLibraryTable = table;
myRootModel = rootModel;
myType = type;
if (type != null) {
myProperties = type.createDefaultProperties();
}
myRoots = initRoots();
mySource = null;
}
@@ -105,6 +109,12 @@ 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();
//noinspection unchecked
myProperties.loadState(from.myProperties.getState());
}
myRoots = initRoots();
mySource = newSource;
myLibraryTable = from.myLibraryTable;
@@ -204,6 +214,12 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
return true;
}
@Override
public void setProperties(LibraryProperties properties) {
LOG.assertTrue(isWritable());
myProperties = properties;
}
@NotNull
public RootProvider getRootProvider() {
return myRootProvider;
@@ -241,9 +257,11 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
myProperties = myType.createDefaultProperties();
final Element propertiesElement = element.getChild(PROPERTIES_ELEMENT);
final Class<?> stateClass = ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(PersistentStateComponent.class.getTypeParameters()[0], myProperties.getClass()));
//noinspection unchecked
myProperties.loadState(XmlSerializer.deserialize(propertiesElement, stateClass));
if (propertiesElement != null) {
final Class<?> stateClass = ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(PersistentStateComponent.class.getTypeParameters()[0], myProperties.getClass()));
//noinspection unchecked
myProperties.loadState(XmlSerializer.deserialize(propertiesElement, stateClass));
}
}
private void readName(Element element) {
@@ -318,6 +336,16 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
return mySource != null;
}
@Override
public LibraryType<?> getType() {
return myType;
}
@Override
public LibraryProperties getProperties() {
return myProperties;
}
public void addRoot(@NotNull String url, @NotNull OrderRootType rootType) {
LOG.assertTrue(isWritable());
assert !isDisposed();
@@ -436,6 +464,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
((LibraryTableBase)myLibraryTable).fireLibraryRenamed(this);
}
}
myProperties = fromModel.myProperties;
if (areRootsChanged(fromModel)) {
disposeMyPointers();
copyRootsFrom(fromModel);
@@ -580,6 +609,8 @@ 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 (myProperties != null ? !myProperties.equals(library.myProperties) : library.myProperties != null) return false;
return true;
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
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.util.*;
import com.intellij.util.EventDispatcher;
import com.intellij.util.containers.ContainerUtil;
@@ -175,7 +176,11 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
myModel.writeExternal(element);
}
public class LibraryModel implements ModifiableModel, JDOMExternalizable {
public interface ModifiableModelEx extends ModifiableModel {
Library createLibrary(String name, @Nullable LibraryType type);
}
public class LibraryModel implements ModifiableModelEx, JDOMExternalizable {
private final ArrayList<Library> myLibraries = new ArrayList<Library>();
private boolean myWritable;
@@ -207,7 +212,7 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
@NonNls final String libraryPrefix = "library.";
final String libPath = System.getProperty(libraryPrefix + name);
if (libPath != null) {
final LibraryImpl library = new LibraryImpl(name, LibraryTableBase.this, null);
final LibraryImpl library = new LibraryImpl(name, null, LibraryTableBase.this, null);
library.addRoot(libPath, OrderRootType.CLASSES);
return library;
}
@@ -224,9 +229,15 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
LOG.assertTrue(myWritable);
}
@Override
public Library createLibrary(String name) {
return createLibrary(name, null);
}
@Override
public Library createLibrary(String name, @Nullable LibraryType type) {
assertWritable();
final LibraryImpl library = new LibraryImpl(name, LibraryTableBase.this, null);
final LibraryImpl library = new LibraryImpl(name, type, LibraryTableBase.this, null);
myLibraries.add(library);
return library;
}
@@ -18,6 +18,7 @@ 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.util.InvalidDataException;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -41,7 +42,9 @@ public class LibraryTableImplUtil {
return new LibraryImpl(null, element, rootModel);
}
public static Library createModuleLevelLibrary(@Nullable String name, RootModelImpl rootModel) {
return new LibraryImpl(name, null, rootModel);
public static Library createModuleLevelLibrary(@Nullable String name,
final LibraryType<?> type,
RootModelImpl rootModel) {
return new LibraryImpl(name, type, null, rootModel);
}
}
@@ -0,0 +1,37 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.impl.libraries;
import com.intellij.openapi.roots.libraries.LibraryType;
import com.intellij.openapi.roots.libraries.LibraryTypeRegistry;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class LibraryTypeRegistryImpl extends LibraryTypeRegistry {
@Nullable
public LibraryType<?> findTypeById(@NotNull String typeId) {
for (LibraryType type : LibraryType.EP_NAME.getExtensions()) {
if (type.getKind().getKindId().equals(typeId)) {
return type;
}
}
return null;
}
}
@@ -29,4 +29,14 @@ public class DummyLibraryProperties extends LibraryProperties<Object> {
@Override
public void loadState(Object state) {
}
@Override
public boolean equals(Object obj) {
return obj instanceof DummyLibraryProperties;
}
@Override
public int hashCode() {
return 0;
}
}
@@ -21,4 +21,9 @@ import com.intellij.openapi.components.PersistentStateComponent;
* @author nik
*/
public abstract class LibraryProperties<T> implements PersistentStateComponent<T> {
@Override
public abstract boolean equals(Object obj);
@Override
public abstract int hashCode();
}
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.libraries;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public abstract class LibraryType<P extends LibraryProperties> extends LibraryPresentationProvider<P> {
public static final ExtensionPointName<LibraryType<?>> EP_NAME = ExtensionPointName.create("com.intellij.library.type");
protected LibraryType(@NotNull LibraryKind<P> libraryKind) {
super(libraryKind);
}
@NotNull
public abstract String getCreateActionName();
@NotNull
public abstract P createDefaultProperties();
@Nullable
public abstract LibraryPropertiesEditor createPropertiesEditor(@NotNull LibraryEditorComponent<P> properties);
}
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.libraries;
import com.intellij.openapi.components.ServiceManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public abstract class LibraryTypeRegistry {
public static LibraryTypeRegistry getInstance() {
return ServiceManager.getService(LibraryTypeRegistry.class);
}
@Nullable
public abstract LibraryType<?> findTypeById(@NotNull String typeId);
}
@@ -0,0 +1,27 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.libraries.ui;
import com.intellij.openapi.roots.libraries.LibraryProperties;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public interface LibraryEditorComponent<P extends LibraryProperties> {
@NotNull
P getProperties();
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.libraries.ui;
import com.intellij.openapi.options.UnnamedConfigurable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author nik
*/
public abstract class LibraryPropertiesEditor implements UnnamedConfigurable {
@NotNull
public abstract JComponent createComponent();
@Override
public abstract void apply();
public void disposeUIResources() {
}
}
@@ -176,7 +176,7 @@ public class SimpleClasspathPanel extends JPanel {
final ArrayList<Library> result = new ArrayList<Library>();
for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
if (!existingFiles.add(file)) continue;
final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null);
final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null, null);
Disposer.register(parentDisposable, newLibrary);
final Library.ModifiableModel libModel = newLibrary.getModifiableModel();
libModel.addRoot(file, OrderRootType.CLASSES);
@@ -387,7 +387,7 @@ public class SimpleClasspathPanel extends JPanel {
}
final List<Library> addedLibraries = new ArrayList<Library>(files.length);
for (VirtualFile file : files) {
final Library library = LibraryTableImplUtil.createModuleLevelLibrary(null, null);
final Library library = LibraryTableImplUtil.createModuleLevelLibrary(null, null, null);
Disposer.register(myParentDisposable, library);
final Library.ModifiableModel libModel = library.getModifiableModel();
libModel.addRoot(file, OrderRootType.CLASSES);
@@ -410,7 +410,7 @@ public class SimpleClasspathPanel extends JPanel {
result.add(library);
}
else {
final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null);
final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null, null);
Disposer.register(disposable, newLibrary);
final Library.ModifiableModel libModel = newLibrary.getModifiableModel();
final String libName = classpathElement.getLibraryName();
@@ -211,12 +211,10 @@ module.toggle.sources.action.description=Mark directory as a Sources root
library.classes.node=Classes
library.javadocs.node=JavaDocs
library.empty.item=<empty library>
library.name.prompt=Library name:
library.name.not.specified.error=Please enter library name
library.name.not.specified.title=Library Name Not Specified
library.name.already.exists.error=Library \"{0}\" already exists
library.name.already.exists.title=Library Already Exists
library.create.library.action=Create &Library...
classpath.add.new.library.action=New Library...
classpath.add.simple.module.library.action=Single-Entry Module Library...
classpath.add.library.action=Library...
@@ -277,6 +277,7 @@
<extensionPoint name="sdkType" interface="com.intellij.openapi.projectRoots.SdkType"/>
<extensionPoint name="library.presentationProvider" interface="com.intellij.openapi.roots.libraries.LibraryPresentationProvider"/>
<extensionPoint name="library.type" interface="com.intellij.openapi.roots.libraries.LibraryType"/>
<extensionPoint name="lang.implementationTextSelectioner"
beanClass="com.intellij.lang.LanguageExtensionPoint"/>
@@ -116,6 +116,9 @@
<applicationService serviceInterface="com.intellij.openapi.roots.libraries.LibraryDetectionManager"
serviceImplementation="com.intellij.openapi.roots.impl.libraries.LibraryDetectionManagerImpl"/>
<applicationService serviceInterface="com.intellij.openapi.roots.libraries.LibraryTypeRegistry"
serviceImplementation="com.intellij.openapi.roots.impl.libraries.LibraryTypeRegistryImpl"/>
<applicationService serviceInterface="com.intellij.usageView.UsageTreeColorsScheme"
serviceImplementation="com.intellij.usageView.UsageTreeColorsScheme"/>
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.groovy.config;
import com.intellij.openapi.roots.libraries.LibraryProperties;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.Nullable;
/**
@@ -41,4 +42,14 @@ public class GroovyLibraryProperties extends LibraryProperties<GroovyLibraryProp
@Override
public void loadState(GroovyLibraryProperties state) {
}
@Override
public boolean equals(Object obj) {
return obj instanceof GroovyLibraryProperties && Comparing.equal(myVersion, ((GroovyLibraryProperties)obj).myVersion);
}
@Override
public int hashCode() {
return myVersion != null ? myVersion.hashCode() : 0;
}
}