diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java index 02bedf24aec5..9b1195c24bba 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java @@ -2,7 +2,6 @@ package com.intellij.packaging.impl.elements; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ui.configuration.artifacts.ChooseArtifactsDialog; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactPointerManager; import com.intellij.packaging.elements.CompositePackagingElement; @@ -40,14 +39,10 @@ public class ArtifactElementType extends PackagingElementType chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement parent) { final Project project = context.getProject(); - ChooseArtifactsDialog dialog = new ChooseArtifactsDialog(project, getAvailableArtifacts(context, artifact), - CompilerBundle.message("dialog.title.choose.artifacts"), ""); - dialog.show(); + List artifacts = context.chooseArtifacts(getAvailableArtifacts(context, artifact), CompilerBundle.message("dialog.title.choose.artifacts")); final List elements = new ArrayList(); - if (dialog.isOK()) { - for (Artifact selected : dialog.getChosenElements()) { - elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).create(selected.getName()))); - } + for (Artifact selected : artifacts) { + elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).create(selected.getName()))); } return elements; } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/FacetBasedPackagingElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/FacetBasedPackagingElementType.java index 7d900c65ad76..e655141d15d6 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/FacetBasedPackagingElementType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/FacetBasedPackagingElementType.java @@ -5,7 +5,7 @@ import com.intellij.facet.FacetTypeId; import com.intellij.facet.FacetTypeRegistry; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseElementsDialog; +import com.intellij.ide.util.ChooseElementsDialog; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElement; @@ -44,14 +44,13 @@ public abstract class FacetBasedPackagingElementType chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement parent) { - final Project project = context.getProject(); final List facets = getFacets(context); ChooseFacetsDialog dialog = new ChooseFacetsDialog(context.getProject(), facets, getDialogTitle(), getDialogDescription()); dialog.show(); if (dialog.isOK()) { final List elements = new ArrayList(); for (F facet : dialog.getChosenElements()) { - elements.add(createElement(project, facet)); + elements.add(createElement(context.getProject(), facet)); } return elements; } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java index 7e40f597cf40..f089dc695ce7 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java @@ -5,7 +5,6 @@ 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.LibraryTablesRegistrar; -import com.intellij.openapi.roots.ui.configuration.packaging.ChooseLibrariesDialog; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElementType; @@ -41,15 +40,10 @@ public class LibraryElementType extends PackagingElementType chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement parent) { - ChooseLibrariesDialog dialog = new ChooseLibrariesDialog(context.getProject(), getAllLibraries(context), - ProjectBundle.message("dialog.title.packaging.choose.library"), ""); - dialog.show(); - final List selected = dialog.getChosenElements(); + final List selected = context.chooseLibraries(getAllLibraries(context), ProjectBundle.message("dialog.title.packaging.choose.library")); final List elements = new ArrayList(); - if (dialog.isOK()) { - for (Library library : selected) { - elements.add(new LibraryPackagingElement(library.getTable().getTableLevel(), library.getName())); - } + for (Library library : selected) { + elements.add(new LibraryPackagingElement(library.getTable().getTableLevel(), library.getName())); } return elements; } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryPackagingElement.java index a862dc9727ff..42886565d8fc 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryPackagingElement.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryPackagingElement.java @@ -1,7 +1,6 @@ package com.intellij.packaging.impl.elements; import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems.LibrarySourceItem; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -56,7 +55,7 @@ public class LibraryPackagingElement extends ComplexPackagingElement chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement parent) { - List modules = chooseModules(context, artifact); + List modules = chooseModules(context); final List elements = new ArrayList(); for (Module module : modules) { elements.add(new ModuleOutputPackagingElement(module.getName())); @@ -49,14 +47,8 @@ public class ModuleOutputElementType extends PackagingElementType chooseModules(ArtifactEditorContext context, Artifact artifact) { - ChooseModulesDialog dialog = new ChooseModulesDialog(context.getProject(), Arrays.asList(context.getModulesProvider().getModules()), ProjectBundle.message("dialog.title.packaging.choose.module"), ""); - dialog.show(); - List modules = dialog.getChosenElements(); - if (!dialog.isOK()) { - modules = Collections.emptyList(); - } - return modules; + public static List chooseModules(ArtifactEditorContext context) { + return context.chooseModules(Arrays.asList(context.getModulesProvider().getModules()), ProjectBundle.message("dialog.title.packaging.choose.module")); } @NotNull diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleOutputPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleOutputPackagingElement.java index 4acf0f780d71..f6bbe9ed7b4d 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleOutputPackagingElement.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleOutputPackagingElement.java @@ -35,7 +35,7 @@ public class ModuleOutputPackagingElement extends PackagingElement chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement parent) { - final List modules = ModuleOutputElementType.chooseModules(context, artifact); + final List modules = ModuleOutputElementType.chooseModules(context); final List elements = new ArrayList(); for (Module module : modules) { elements.add(new ModuleWithDependenciesPackagingElement(module.getName())); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java index 2898f108e513..c72a612da626 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java @@ -70,7 +70,7 @@ public class ModuleWithDependenciesPackagingElement extends ComplexPackagingElem } public PackagingElementPresentation createPresentation(@NotNull ArtifactEditorContext context) { - return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModuleName, findModule(context)) { + return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModuleName, findModule(context), context) { @Override protected String getNodeText() { return CompilerBundle.message("node.text.0.with.dependencies", getPresentableName()); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/ArtifactElementPresentation.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/ArtifactElementPresentation.java index 5e1323721c66..1cb56c618df7 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/ArtifactElementPresentation.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/ArtifactElementPresentation.java @@ -1,7 +1,6 @@ package com.intellij.packaging.impl.ui; import com.intellij.ide.projectView.PresentationData; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactPointer; import com.intellij.packaging.impl.artifacts.PlainArtifactType; @@ -36,7 +35,7 @@ public class ArtifactElementPresentation extends TreeNodePresentation { @Override public void navigateToSource() { - ProjectStructureConfigurable.getInstance(myContext.getProject()).select(myArtifact, true); + myContext.selectArtifact(myArtifact); } public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/LibraryElementPresentation.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/LibraryElementPresentation.java index 4ee5423a233c..0582cc93af1d 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/LibraryElementPresentation.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/LibraryElementPresentation.java @@ -2,8 +2,11 @@ package com.intellij.packaging.impl.ui; import com.intellij.ide.projectView.PresentationData; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorUtil; +import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.roots.libraries.LibraryTablePresentation; +import com.intellij.openapi.roots.impl.ModuleLibraryTable; +import com.intellij.openapi.roots.impl.libraries.LibraryImpl; +import com.intellij.openapi.module.Module; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.PackagingElementPresentation; import com.intellij.packaging.ui.PackagingElementWeights; @@ -41,14 +44,14 @@ public class LibraryElementPresentation extends PackagingElementPresentation { @Override public void navigateToSource() { - ProjectStructureConfigurable.getInstance(myContext.getProject()).selectProjectOrGlobalLibrary(myLibrary, true); + myContext.selectLibrary(myLibrary); } public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { if (myLibrary != null) { presentationData.setIcons(Icons.LIBRARY_ICON); presentationData.addText(myName, mainAttributes); - presentationData.addText(PackagingEditorUtil.getLibraryTableComment(myLibrary), commentAttributes); + presentationData.addText(getLibraryTableComment(myLibrary), commentAttributes); } else { presentationData.addText(myName, SimpleTextAttributes.ERROR_ATTRIBUTES); @@ -60,4 +63,23 @@ public class LibraryElementPresentation extends PackagingElementPresentation { return PackagingElementWeights.LIBRARY; } + public static String getLibraryTableDisplayName(final Library library) { + LibraryTable table = library.getTable(); + LibraryTablePresentation presentation = table != null ? table.getPresentation() : ModuleLibraryTable.MODULE_LIBRARY_TABLE_PRESENTATION; + return presentation.getDisplayName(false); + } + + public static String getLibraryTableComment(final Library library) { + LibraryTable libraryTable = library.getTable(); + String displayName; + if (libraryTable != null) { + displayName = libraryTable.getPresentation().getDisplayName(false); + } + else { + Module module = ((LibraryImpl)library).getModule(); + String tableName = getLibraryTableDisplayName(library); + displayName = module != null ? "'" + module.getName() + "' " + tableName : tableName; + } + return " (" + displayName + ")"; + } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/ModuleElementPresentation.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/ModuleElementPresentation.java index b11f1eaca87e..6d8d0bd532b8 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/ModuleElementPresentation.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/ModuleElementPresentation.java @@ -3,9 +3,9 @@ package com.intellij.packaging.impl.ui; import com.intellij.ide.projectView.PresentationData; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; import com.intellij.packaging.ui.PackagingElementWeights; import com.intellij.packaging.ui.TreeNodePresentation; +import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,11 +15,13 @@ import org.jetbrains.annotations.Nullable; */ public class ModuleElementPresentation extends TreeNodePresentation { private final String myName; + private final ArtifactEditorContext myContext; private final Module myModule; - public ModuleElementPresentation(@NotNull String name, @Nullable Module module) { + public ModuleElementPresentation(@NotNull String name, @Nullable Module module, ArtifactEditorContext context) { myModule = module; myName = name; + myContext = context; } public String getPresentableName() { @@ -38,7 +40,7 @@ public class ModuleElementPresentation extends TreeNodePresentation { @Override public void navigateToSource() { - ProjectStructureConfigurable.getInstance(myModule.getProject()).select(myModule.getName(), null, true); + myContext.selectModule(myModule); } public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { diff --git a/java/compiler/openapi/src/com/intellij/packaging/ui/ArtifactEditorContext.java b/java/compiler/openapi/src/com/intellij/packaging/ui/ArtifactEditorContext.java index f8a055352917..76b142febcd8 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/ui/ArtifactEditorContext.java +++ b/java/compiler/openapi/src/com/intellij/packaging/ui/ArtifactEditorContext.java @@ -1,12 +1,17 @@ package com.intellij.packaging.ui; +import com.intellij.facet.Facet; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactType; import com.intellij.packaging.artifacts.ModifiableArtifactModel; -import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElementResolvingContext; import org.jetbrains.annotations.NotNull; +import java.util.List; + /** * @author nik */ @@ -28,4 +33,20 @@ public interface ArtifactEditorContext extends PackagingElementResolvingContext void ensureRootIsWritable(@NotNull Artifact originalArtifact); ArtifactEditor getOrCreateEditor(Artifact originalArtifact); + + + void selectArtifact(@NotNull Artifact artifact); + + void selectFacet(@NotNull Facet facet); + + void selectModule(@NotNull Module module); + + void selectLibrary(@NotNull Library library); + + + List chooseArtifacts(List artifacts, String title); + + List chooseModules(List modules, final String title); + + List chooseLibraries(List libraries, String title); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorContextImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorContextImpl.java index 29749020e213..fd272c567f70 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorContextImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorContextImpl.java @@ -3,6 +3,11 @@ package com.intellij.openapi.roots.ui.configuration.artifacts; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.FacetsProvider; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; +import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.packaging.ChooseLibrariesDialog; +import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseModulesDialog; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.module.Module; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactModel; import com.intellij.packaging.artifacts.ArtifactType; @@ -11,8 +16,12 @@ import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.ui.ArtifactEditor; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.ManifestFileConfiguration; +import com.intellij.facet.Facet; import org.jetbrains.annotations.NotNull; +import java.util.List; +import java.util.Collections; + /** * @author nik */ @@ -53,6 +62,29 @@ public class ArtifactEditorContextImpl implements ArtifactEditorContext { return myParent.getOrCreateEditor(artifact); } + public void selectArtifact(@NotNull Artifact artifact) { + ProjectStructureConfigurable.getInstance(getProject()).select(artifact, true); + } + + public void selectFacet(@NotNull Facet facet) { + ProjectStructureConfigurable.getInstance(getProject()).select(facet, true); + } + + public void selectModule(@NotNull Module module) { + ProjectStructureConfigurable.getInstance(getProject()).select(module.getName(), null, true); + } + + public void selectLibrary(@NotNull Library library) { + ProjectStructureConfigurable.getInstance(getProject()).selectProjectOrGlobalLibrary(library, true); + } + + public List chooseArtifacts(final List artifacts, final String title) { + ChooseArtifactsDialog dialog = new ChooseArtifactsDialog(getProject(), artifacts, title, ""); + dialog.show(); + return dialog.isOK() ? dialog.getChosenElements() : Collections.emptyList(); + } + + @NotNull public ArtifactModel getArtifactModel() { return myParent.getArtifactModel(); @@ -84,4 +116,18 @@ public class ArtifactEditorContextImpl implements ArtifactEditorContext { public void setValidationMananger(ArtifactValidationManagerImpl validationManager) { myValidationManager = validationManager; } + + public List chooseModules(final List modules, final String title) { + ChooseModulesDialog dialog = new ChooseModulesDialog(getProject(), modules, title, ""); + dialog.show(); + List selected = dialog.getChosenElements(); + return dialog.isOK() ? selected : Collections.emptyList(); + } + + public List chooseLibraries(final List libraries, final String title) { + ChooseLibrariesDialog dialog = new ChooseLibrariesDialog(getProject(), libraries, title, ""); + dialog.show(); + return dialog.isOK() ? dialog.getChosenElements() : Collections.emptyList(); + } + } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ChooseArtifactsDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ChooseArtifactsDialog.java index c97365f7432f..23da2268b333 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ChooseArtifactsDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ChooseArtifactsDialog.java @@ -1,7 +1,7 @@ package com.intellij.openapi.roots.ui.configuration.artifacts; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseElementsDialog; +import com.intellij.ide.util.ChooseElementsDialog; import com.intellij.packaging.artifacts.Artifact; import javax.swing.*; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/LibrarySourceItem.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/LibrarySourceItem.java index 71fcd44fc958..e8a27b172805 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/LibrarySourceItem.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/LibrarySourceItem.java @@ -3,12 +3,13 @@ package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems; import com.intellij.ide.projectView.PresentationData; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.elements.PackagingElement; import com.intellij.packaging.elements.PackagingElementFactory; import com.intellij.packaging.elements.PackagingElementOutputKind; import com.intellij.packaging.ui.*; +import com.intellij.packaging.impl.ui.LibraryElementPresentation; +import com.intellij.packaging.impl.elements.LibraryPackagingElement; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.Icons; import org.jetbrains.annotations.NotNull; @@ -46,21 +47,7 @@ public class LibrarySourceItem extends PackagingSourceItem { @NotNull @Override public PackagingElementOutputKind getKindOfProducedElements() { - return getKindForLibrary(myLibrary); - } - - public static PackagingElementOutputKind getKindForLibrary(final Library library) { - boolean containsDirectories = false; - boolean containsJars = false; - for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) { - if (file.isInLocalFileSystem()) { - containsDirectories = true; - } - else { - containsJars = true; - } - } - return new PackagingElementOutputKind(containsDirectories, containsJars); + return LibraryPackagingElement.getKindForLibrary(myLibrary); } @NotNull @@ -92,7 +79,7 @@ public class LibrarySourceItem extends PackagingSourceItem { if (name != null) { presentationData.setIcons(Icons.LIBRARY_ICON); presentationData.addText(name, mainAttributes); - presentationData.addText(PackagingEditorUtil.getLibraryTableComment(myLibrary), commentAttributes); + presentationData.addText(LibraryElementPresentation.getLibraryTableComment(myLibrary), commentAttributes); } else { final VirtualFile[] files = myLibrary.getFiles(OrderRootType.CLASSES); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ModuleOutputSourceItem.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ModuleOutputSourceItem.java index c7dea3a1e04f..957bf0ee0531 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ModuleOutputSourceItem.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ModuleOutputSourceItem.java @@ -31,7 +31,7 @@ public class ModuleOutputSourceItem extends PackagingSourceItem { @Override public SourceItemPresentation createPresentation(@NotNull ArtifactEditorContext context) { - return new DelegatedSourceItemPresentation(new ModuleElementPresentation(myModule.getName(), myModule)) { + return new DelegatedSourceItemPresentation(new ModuleElementPresentation(myModule.getName(), myModule, context)) { @Override public int getWeight() { return SourceItemWeights.MODULE_OUTPUT_WEIGHT; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java index 696ed71b5e11..82141c6dea4d 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java @@ -12,6 +12,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; +import com.intellij.ide.util.ChooseElementsDialog; import javax.swing.*; import java.awt.*; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ChooseLibrariesDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ChooseLibrariesDialog.java index 87f46b200b83..b95c2d57e156 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ChooseLibrariesDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ChooseLibrariesDialog.java @@ -2,7 +2,7 @@ package com.intellij.openapi.roots.ui.configuration.packaging; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseElementsDialog; +import com.intellij.ide.util.ChooseElementsDialog; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.project.Project; import com.intellij.util.Icons; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java index 1bdde8c54d83..e558b47793e9 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java @@ -3,17 +3,16 @@ package com.intellij.openapi.roots.ui.configuration.packaging; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.ModuleLibraryTable; import com.intellij.openapi.roots.impl.OrderEntryUtil; import com.intellij.openapi.roots.impl.libraries.LibraryImpl; 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.ui.util.OrderEntryCellAppearanceUtils; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.Icons; +import com.intellij.packaging.impl.ui.LibraryElementPresentation; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -27,19 +26,13 @@ public class PackagingEditorUtil { private PackagingEditorUtil() { } - private static String getLibraryTableDisplayName(final Library library) { - LibraryTable table = library.getTable(); - LibraryTablePresentation presentation = table != null ? table.getPresentation() : ModuleLibraryTable.MODULE_LIBRARY_TABLE_PRESENTATION; - return presentation.getDisplayName(false); - } - public static void renderLibraryNode(final ColoredTreeCellRenderer renderer, final Library library, final SimpleTextAttributes mainAttributes, final SimpleTextAttributes commentAttributes) { String name = library.getName(); if (name != null) { renderer.setIcon(Icons.LIBRARY_ICON); renderer.append(name, mainAttributes); - renderer.append(getLibraryTableComment(library), commentAttributes); + renderer.append(LibraryElementPresentation.getLibraryTableComment(library), commentAttributes); } else { VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); @@ -47,7 +40,7 @@ public class PackagingEditorUtil { VirtualFile file = files[0]; renderer.setIcon(file.getIcon()); renderer.append(file.getName(), mainAttributes); - renderer.append(getLibraryTableComment(library), commentAttributes); + renderer.append(LibraryElementPresentation.getLibraryTableComment(library), commentAttributes); } else { OrderEntryCellAppearanceUtils.forLibrary(library).customize(renderer); @@ -55,20 +48,6 @@ public class PackagingEditorUtil { } } - public static String getLibraryTableComment(final Library library) { - LibraryTable libraryTable = library.getTable(); - String displayName; - if (libraryTable != null) { - displayName = libraryTable.getPresentation().getDisplayName(false); - } - else { - Module module = ((LibraryImpl)library).getModule(); - String tableName = getLibraryTableDisplayName(library); - displayName = module != null ? "'" + module.getName() + "' " + tableName : tableName; - } - return " (" + displayName + ")"; - } - public static void renderLibraryFile(final ColoredTreeCellRenderer renderer, final Library library, final VirtualFile file, final SimpleTextAttributes mainAttributes, final SimpleTextAttributes commentAttributes) { renderer.setIcon(file.getIcon()); @@ -78,7 +57,7 @@ public class PackagingEditorUtil { if (name != null) { StringBuilder comment = new StringBuilder(); comment.append(" ('").append(name).append("' "); - comment.append(getLibraryTableDisplayName(library)); + comment.append(LibraryElementPresentation.getLibraryTableDisplayName(library)); comment.append(")"); renderer.append(comment.toString(), commentAttributes); } @@ -86,7 +65,7 @@ public class PackagingEditorUtil { Module module = ((LibraryImpl)library).getModule(); String comment; if (module == null) { - comment = " (" + getLibraryTableDisplayName(library) + ")"; + comment = " (" + LibraryElementPresentation.getLibraryTableDisplayName(library) + ")"; } else { comment = " " + ProjectBundle.message("node.text.library.of.module", module.getName()); @@ -99,13 +78,13 @@ public class PackagingEditorUtil { String name = library.getName(); VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); if (name != null) { - return "'" + name + "' " + getLibraryTableDisplayName(library); + return "'" + name + "' " + LibraryElementPresentation.getLibraryTableDisplayName(library); } else if (files.length > 0) { Module module = ((LibraryImpl)library).getModule(); final String description; if (module == null) { - description = "(" + getLibraryTableDisplayName(library) + ")"; + description = "(" + LibraryElementPresentation.getLibraryTableDisplayName(library) + ")"; } else { description = ProjectBundle.message("node.text.library.of.module", module.getName()); @@ -121,10 +100,10 @@ public class PackagingEditorUtil { String name = library.getName(); VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); if (name != null) { - return name + (includeTableName ? getLibraryTableComment(library) : ""); + return name + (includeTableName ? LibraryElementPresentation.getLibraryTableComment(library) : ""); } else if (files.length > 0) { - return files[0].getName() + (includeTableName ? getLibraryTableComment(library) : ""); + return files[0].getName() + (includeTableName ? LibraryElementPresentation.getLibraryTableComment(library) : ""); } else { return ProjectBundle.message("library.empty.item"); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseElementsDialog.java b/platform/platform-impl/src/com/intellij/ide/util/ChooseElementsDialog.java similarity index 96% rename from java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseElementsDialog.java rename to platform/platform-impl/src/com/intellij/ide/util/ChooseElementsDialog.java index ed7170c0fede..c862c8e85c48 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseElementsDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/util/ChooseElementsDialog.java @@ -1,19 +1,18 @@ -package com.intellij.openapi.roots.ui.configuration.libraryEditor; +package com.intellij.ide.util; -import com.intellij.ide.util.ElementsChooser; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.ScrollPaneFactory; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Comparator; +import java.util.List; /** * @author nik