diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
index c118873b27c2..2c0b6686ddb9 100644
--- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
+++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
@@ -345,7 +345,7 @@ public class LibraryOptionsPanel implements Disposable {
else {
path = PathUtil.getFileName(downloadPath);
}
- return MessageFormat.format("{0} jar(s) will be downloaded into {1} directory
" +
+ return MessageFormat.format("{0} {0, choice, 1#jar|2#jars} will be downloaded into {1} directory
" +
"{2} library {3} will be created",
downloadSettings.getSelectedDownloads().size(),
path,
diff --git a/java/idea-ui/src/com/intellij/framework/library/FrameworkSupportWithLibrary.java b/java/idea-ui/src/com/intellij/framework/library/FrameworkSupportWithLibrary.java
new file mode 100644
index 000000000000..dce7da5e3f85
--- /dev/null
+++ b/java/idea-ui/src/com/intellij/framework/library/FrameworkSupportWithLibrary.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2011 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.ui.configuration.libraries.CustomLibraryDescription;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public interface FrameworkSupportWithLibrary {
+
+ @NotNull
+ CustomLibraryDescription createLibraryDescription();
+
+ boolean isLibraryOnly();
+}
diff --git a/java/idea-ui/src/com/intellij/framework/library/impl/DownloadableLibraryEditor.java b/java/idea-ui/src/com/intellij/framework/library/impl/DownloadableLibraryEditor.java
index 69533153692d..a52040e9758d 100644
--- a/java/idea-ui/src/com/intellij/framework/library/impl/DownloadableLibraryEditor.java
+++ b/java/idea-ui/src/com/intellij/framework/library/impl/DownloadableLibraryEditor.java
@@ -25,6 +25,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor;
+import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBase;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -54,7 +55,7 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
myDescription = description;
myEditorComponent = editorComponent;
myLibraryType = libraryType;
- myDescriptionLabel.setText(libraryType.getDescription(editorComponent.getProperties()));
+ updateDescription();
myCurrentVersionString = myEditorComponent.getProperties().getVersionString();
myChangeVersionButton.addActionListener(new ActionListener() {
@Override
@@ -64,6 +65,10 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
});
}
+ private void updateDescription() {
+ myDescriptionLabel.setText(myLibraryType.getDescription(myEditorComponent.getProperties()));
+ }
+
private void changeVersion() {
final ModalityState current = ModalityState.current();
myDescription.fetchLibraryVersions(new DownloadableLibraryDescription.LibraryVersionsCallback() {
@@ -91,9 +96,11 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
final NewLibraryEditor editor = settings.download(myMainPanel);
if (editor != null) {
myEditorComponent.getLibraryEditor().removeAllRoots();
- editor.copyRoots(myEditorComponent.getLibraryEditor());
+ myEditorComponent.getLibraryEditor().setName(editor.getName());
+ editor.applyTo((LibraryEditorBase)myEditorComponent.getLibraryEditor());
myEditorComponent.updateRootsTree();
myCurrentVersionString = settings.getVersion().getVersionString();
+ updateDescription();
myModified = true;
}
}
@@ -130,5 +137,6 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
@Override
public void reset() {
+ updateDescription();
}
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java
index 72f9d9ecc484..1b862cb1abca 100644
--- a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java
+++ b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/CustomLibraryDescriptionImpl.java
@@ -17,7 +17,7 @@ package com.intellij.ide.util.frameworkSupport;
import com.intellij.framework.library.DownloadableLibraryDescription;
import com.intellij.framework.library.DownloadableLibraryType;
-import com.intellij.openapi.roots.libraries.LibraryProperties;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.roots.libraries.LibraryType;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryFilter;
import com.intellij.openapi.vfs.VirtualFile;
@@ -30,6 +30,7 @@ import java.util.List;
* @author nik
*/
public class CustomLibraryDescriptionImpl extends CustomLibraryDescriptionBase {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.frameworkSupport.CustomLibraryDescriptionImpl");
private final DownloadableLibraryType myLibraryType;
public CustomLibraryDescriptionImpl(@NotNull DownloadableLibraryType downloadableLibraryType) {
@@ -58,4 +59,10 @@ public class CustomLibraryDescriptionImpl extends CustomLibraryDescriptionBase {
}
};
}
+
+ public static CustomLibraryDescriptionImpl createDescription(Class extends DownloadableLibraryType> typeClass) {
+ final DownloadableLibraryType libraryType = LibraryType.EP_NAME.findExtension(typeClass);
+ LOG.assertTrue(libraryType != null, typeClass);
+ return new CustomLibraryDescriptionImpl(libraryType);
+ }
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java b/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java
deleted file mode 100644
index 7bc8daffb984..000000000000
--- a/java/idea-ui/src/com/intellij/ide/util/frameworkSupport/FrameworkVersionWithLibrary.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2000-2010 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.util.frameworkSupport;
-
-import com.intellij.framework.library.DownloadableLibraryType;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.roots.libraries.LibraryType;
-import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author nik
- */
-public class FrameworkVersionWithLibrary extends FrameworkVersion {
- private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.frameworkSupport.FrameworkVersionWithLibrary");
- private CustomLibraryDescription myLibraryDescription;
-
- public FrameworkVersionWithLibrary(@NotNull String versionName, boolean isDefault, CustomLibraryDescription libraryDescription) {
- super(versionName, isDefault);
- myLibraryDescription = libraryDescription;
- }
-
- public CustomLibraryDescription getLibraryDescription() {
- return myLibraryDescription;
- }
-
- public static FrameworkVersionWithLibrary createVersion(Class extends DownloadableLibraryType> typeClass) {
- final DownloadableLibraryType libraryType = LibraryType.EP_NAME.findExtension(typeClass);
- LOG.assertTrue(libraryType != null, typeClass);
- CustomLibraryDescription description = new CustomLibraryDescriptionImpl(libraryType);
- return new FrameworkVersionWithLibrary("latest", true, description);
- }
-}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
index d7beaa460580..b32593454936 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
@@ -17,6 +17,7 @@ package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel;
+import com.intellij.framework.library.FrameworkSupportWithLibrary;
import com.intellij.ide.util.frameworkSupport.*;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.openapi.Disposable;
@@ -77,8 +78,9 @@ public class FrameworkSupportOptionsComponent {
final CustomLibraryDescription description = createLibraryDescription();
if (description != null) {
+ final boolean libraryOnly = myConfigurable instanceof FrameworkSupportWithLibrary && ((FrameworkSupportWithLibrary)myConfigurable).isLibraryOnly();
myLibraryOptionsPanel = new LibraryOptionsPanel(description, myModel.getBaseDirectoryForLibrariesPath(), myConfigurable.getSelectedVersion(),
- container, !myConfigurable.isLibraryOnly());
+ container, !libraryOnly);
Disposer.register(myConfigurable, myLibraryOptionsPanel);
if (addSeparator) {
JComponent separator1 = SeparatorFactory.createSeparator("Libraries", null);
@@ -99,13 +101,12 @@ public class FrameworkSupportOptionsComponent {
@Nullable
private CustomLibraryDescription createLibraryDescription() {
- List extends FrameworkVersion> versions = myConfigurable.getVersions();
- if (versions.isEmpty()) return null;
-
- if (versions.get(0) instanceof FrameworkVersionWithLibrary) {
- return ((FrameworkVersionWithLibrary)versions.get(0)).getLibraryDescription();
+ if (myConfigurable instanceof FrameworkSupportWithLibrary) {
+ return ((FrameworkSupportWithLibrary)myConfigurable).createLibraryDescription();
}
+ List extends FrameworkVersion> versions = myConfigurable.getVersions();
+ if (versions.isEmpty()) return null;
return OldCustomLibraryDescription.createByVersions(versions);
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form
index 0be7e0298846..059094879905 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form
@@ -3,7 +3,7 @@
-
+
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java
index 5d5a225eaac8..a06b07bc2d35 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java
@@ -355,7 +355,8 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
final String tableLevel = table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL;
final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(tableLevel);
- EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(ClasspathPanelImpl.this, provider, library, myState.getProject(), presentation);
+ EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(ClasspathPanelImpl.this, provider, library, myState.getProject(),
+ presentation, getStructureConfigurableContext());
dialog.setContextModule(getRootModel().getModule());
dialog.show();
myEntryTable.repaint();
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
index 7cd65f35618b..a3ee2385cb75 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
+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;
@@ -68,7 +69,7 @@ public class CreateNewLibraryDialog extends LibraryEditorDialogBase {
public Library createLibrary() {
final LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx)getTableModifiableModel();
final Library library = modifiableModel.createLibrary(myLibraryEditor.getName(), myLibraryEditor.getType());
- final Library.ModifiableModel model = library.getModifiableModel();
+ final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
myLibraryEditor.apply(model);
new WriteAction() {
protected void run(final Result result) {
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/EditExistingLibraryDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/EditExistingLibraryDialog.java
index dd780c4f2e9a..c14cc6f8a48c 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/EditExistingLibraryDialog.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/EditExistingLibraryDialog.java
@@ -21,8 +21,10 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
+import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -38,7 +40,9 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
public static EditExistingLibraryDialog createDialog(Component parent,
LibraryTableModifiableModelProvider modelProvider,
Library library,
- @Nullable Project project, LibraryTablePresentation presentation) {
+ @Nullable Project project,
+ LibraryTablePresentation presentation,
+ StructureConfigurableContext context) {
LibraryTable.ModifiableModel modifiableModel = modelProvider.getModifiableModel();
boolean commitChanges = false;
ExistingLibraryEditor libraryEditor;
@@ -49,7 +53,7 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
libraryEditor = new ExistingLibraryEditor(library, null);
commitChanges = true;
}
- return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges, presentation);
+ return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges, presentation, context);
}
private EditExistingLibraryDialog(Component parent,
@@ -57,15 +61,23 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
@Nullable Project project,
ExistingLibraryEditor libraryEditor,
boolean commitChanges,
- LibraryTablePresentation presentation) {
+ LibraryTablePresentation presentation, StructureConfigurableContext context) {
super(parent, new LibraryRootsComponent(project, libraryEditor));
- setTitle(presentation.getLibraryTableEditorTitle());
+ setTitle("Configure " + presentation.getDisplayName(false));
myTableModifiableModel = tableModifiableModel;
myLibraryEditor = libraryEditor;
myCommitChanges = commitChanges;
if (commitChanges) {
Disposer.register(getDisposable(), libraryEditor);
}
+ context.addLibraryEditorListener(new LibraryEditorListener() {
+ @Override
+ public void libraryRenamed(@NotNull Library library, String oldName, String newName) {
+ if (library.equals(myLibraryEditor.getLibrary())) {
+ myNameField.setText(newName);
+ }
+ }
+ });
init();
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
index 0376bc640dca..ad7111334f7b 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
@@ -71,6 +71,7 @@ public class ExistingLibraryEditor extends LibraryEditorBase implements Disposab
return myLibraryProperties;
}
+ @Override
public void setProperties(LibraryProperties properties) {
myLibraryProperties = properties;
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorBase.java
index 07eece0c67e7..39ad9fbf1430 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorBase.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorBase.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.roots.libraries.LibraryProperties;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,4 +43,6 @@ public abstract class LibraryEditorBase implements LibraryEditor {
}
protected abstract Collection getOrderRootTypes();
+
+ public abstract void setProperties(LibraryProperties properties);
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorDialogBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorDialogBase.java
index 4272ace878e7..e376fbbaf736 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorDialogBase.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditorDialogBase.java
@@ -33,7 +33,7 @@ import java.awt.*;
* @author nik
*/
public abstract class LibraryEditorDialogBase extends DialogWrapper {
- private JTextField myNameField;
+ protected JTextField myNameField;
private LibraryRootsComponent myLibraryRootsComponent;
public LibraryEditorDialogBase(final Component parent, final LibraryRootsComponent libraryRootsComponent) {
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
index bd77588edae2..6fd95fc5b1f9 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
@@ -116,7 +116,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
myDescriptor = new DefaultLibraryRootsComponentDescriptor();
}
init(new LibraryTreeStructure(this, myDescriptor));
- updateProperties();
+ updatePropertiesLabel();
}
@NotNull
@@ -125,7 +125,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
return getLibraryEditor().getProperties();
}
- private void updateProperties() {
+ public void updatePropertiesLabel() {
StringBuilder text = new StringBuilder();
for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES))) {
if (text.length() > 0) {
@@ -343,7 +343,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
}
}
});
- updateProperties();
+ updatePropertiesLabel();
myTreeBuilder.queueUpdate();
}
return filesToAttach;
@@ -383,7 +383,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
}
protected void librariesChanged(boolean putFocusIntoTree) {
- updateProperties();
+ updatePropertiesLabel();
myTreeBuilder.queueUpdate();
if (putFocusIntoTree) {
myTree.requestFocus();
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java
index 7d10ca2706e6..7020888eacb8 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java
@@ -17,8 +17,8 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.impl.libraries.JarDirectories;
+import com.intellij.openapi.roots.impl.libraries.LibraryEx;
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;
@@ -69,6 +69,11 @@ public class NewLibraryEditor extends LibraryEditorBase {
return myProperties;
}
+ @Override
+ public void setProperties(LibraryProperties properties) {
+ myProperties = properties;
+ }
+
@Override
public String getName() {
return myLibraryName;
@@ -168,12 +173,13 @@ public class NewLibraryEditor extends LibraryEditorBase {
return false;
}
- public void apply(@NotNull Library.ModifiableModel model) {
+ public void apply(@NotNull LibraryEx.ModifiableModelEx model) {
model.setName(myLibraryName);
- applyRoots(model);
+ applyTo(model);
}
- public void applyRoots(Library.ModifiableModel model) {
+ public void applyTo(LibraryEx.ModifiableModelEx model) {
+ model.setProperties(myProperties);
for (OrderRootType type : myRoots.keySet()) {
for (LightFilePointer pointer : myRoots.get(type)) {
model.addRoot(pointer.getUrl(), type);
@@ -186,7 +192,8 @@ public class NewLibraryEditor extends LibraryEditorBase {
}
}
- public void copyRoots(LibraryEditor editor) {
+ public void applyTo(LibraryEditorBase editor) {
+ editor.setProperties(myProperties);
for (OrderRootType type : myRoots.keySet()) {
for (LightFilePointer pointer : myRoots.get(type)) {
editor.addRoot(pointer.getUrl(), type);
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java
index 06153b62ad84..c6a3e76dbf97 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java
@@ -30,7 +30,10 @@ import com.intellij.openapi.roots.ui.configuration.artifacts.UsageInArtifact;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.CreateNewLibraryAction;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.*;
-import com.intellij.openapi.ui.*;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.ui.NamedConfigurable;
+import com.intellij.openapi.ui.NonEmptyInputValidator;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java
index bb387ff53768..2ef075fcd9e3 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java
@@ -38,7 +38,9 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
/**
* @author nik
@@ -85,9 +87,8 @@ public class LibrariesContainerFactory {
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 Library.ModifiableModel model = library.getModifiableModel();
- editor.applyRoots(model);
- ((LibraryEx.ModifiableModelEx)model).setProperties(editor.getProperties());
+ final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
+ editor.applyTo(model);
model.commit();
modifiableModel.commit();
return library;
@@ -273,7 +274,7 @@ public class LibrariesContainerFactory {
Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model), libraryEditor.getType());
ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library);
createdLibraryEditor.setProperties(libraryEditor.getProperties());
- libraryEditor.copyRoots(createdLibraryEditor);
+ libraryEditor.applyTo(createdLibraryEditor);
return library;
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibraryConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibraryConfigurable.java
index d3b7fa5e27e2..49bcf8ca57c2 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibraryConfigurable.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibraryConfigurable.java
@@ -150,6 +150,7 @@ public class LibraryConfigurable extends ProjectStructureElementConfigurable