@NotNull
public List<? extends LibraryPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact,
@NotNull CompositePackagingElement<?> parent) {
- final List<Library> selected = context.chooseLibraries(getAllLibraries(context), ProjectBundle.message("dialog.title.packaging.choose.library"));
+ final List<Library> selected = context.chooseLibraries(ProjectBundle.message("dialog.title.packaging.choose.library"));
final List<LibraryPackagingElement> elements = new ArrayList<LibraryPackagingElement>();
for (Library library : selected) {
elements.add(new LibraryPackagingElement(library.getTable().getTableLevel(), library.getName(), null));
List<Module> chooseModules(List<Module> modules, final String title);
- List<Library> chooseLibraries(List<Library> libraries, String title);
+ List<Library> chooseLibraries(String title);
Artifact getArtifact();
}
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseModulesDialog;
-import com.intellij.openapi.roots.ui.configuration.packaging.ChooseLibrariesDialog;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactModel;
import com.intellij.packaging.ui.ArtifactEditor;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.packaging.ui.ManifestFileConfiguration;
+import com.intellij.util.ui.classpath.ChooseLibrariesFromTablesDialog;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
return dialog.isOK() ? selected : Collections.<Module>emptyList();
}
- public List<Library> chooseLibraries(final List<Library> libraries, final String title) {
- ChooseLibrariesDialog dialog = new ChooseLibrariesDialog(getProject(), libraries, title, null);
+ public List<Library> chooseLibraries(final String title) {
+ final ChooseLibrariesFromTablesDialog dialog = ChooseLibrariesFromTablesDialog.createDialog(title, getProject(), false);
dialog.show();
- return dialog.isOK() ? dialog.getChosenElements() : Collections.<Library>emptyList();
+ return dialog.isOK() ? dialog.getSelectedLibraries() : Collections.<Library>emptyList();
}
public Artifact getArtifact() {
@Nullable Project project,
StructureConfigurableContext context,
Collection<Library> alreadyAddedLibraries) {
- super(parentComponent, "Choose Libraries", project);
+ super(parentComponent, "Choose Libraries", project, true);
myContext = context;
myAlreadyAddedLibraries = alreadyAddedLibraries;
init();
+++ /dev/null
-/*
- * Copyright 2000-2009 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.ui.configuration.packaging;
-
-import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.libraries.Library;
-import com.intellij.ide.util.ChooseElementsDialog;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.project.Project;
-import com.intellij.util.Icons;
-
-import javax.swing.*;
-import java.util.List;
-
-/**
- * @author nik
- */
-public class ChooseLibrariesDialog extends ChooseElementsDialog<Library> {
-
- public ChooseLibrariesDialog(Project project, List<? extends Library> items, String title, String description) {
- super(project, items, title, description, true);
- }
-
- protected String getItemText(final Library item) {
- return item != null ? PackagingEditorUtil.getLibraryItemText(item, true) : "";
- }
-
- protected Icon getItemIcon(final Library item) {
- if (item.getName() != null) {
- return Icons.LIBRARY_ICON;
- }
- VirtualFile[] files = item.getFiles(OrderRootType.CLASSES);
- if (files.length == 1) {
- return files[0].getFileType().getIcon();
- }
- return Icons.LIBRARY_ICON;
- }
-}
private List<Library> myResult;
private final Map<Object, Object> myParentsMap = new THashMap<Object, Object>();
- public ChooseLibrariesDialogBase(final JComponent parentComponent, final String title) {
+ protected ChooseLibrariesDialogBase(final JComponent parentComponent, final String title) {
super(parentComponent, false);
setTitle(title);
}
+ protected ChooseLibrariesDialogBase(Project project, String title) {
+ super(project, false);
+ setTitle(title);
+ }
+
@Override
protected void init() {
super.init();
*/
public class ChooseLibrariesFromTablesDialog extends ChooseLibrariesDialogBase {
private @Nullable Project myProject;
+ private boolean myShowCustomLibraryTables;
- public ChooseLibrariesFromTablesDialog(JComponent parentComponent, String title, @Nullable Project project) {
+ private ChooseLibrariesFromTablesDialog(@NotNull String title, @NotNull Project project, final boolean showCustomLibraryTables) {
+ super(project, title);
+ myShowCustomLibraryTables = showCustomLibraryTables;
+ myProject = project;
+ }
+
+ protected ChooseLibrariesFromTablesDialog(@NotNull JComponent parentComponent,
+ @NotNull String title,
+ @Nullable Project project,
+ final boolean showCustomLibraryTables) {
super(parentComponent, title);
+ myShowCustomLibraryTables = showCustomLibraryTables;
myProject = project;
}
+ public static ChooseLibrariesFromTablesDialog createDialog(@NotNull String title,
+ @NotNull Project project,
+ final boolean showCustomLibraryTables) {
+ final ChooseLibrariesFromTablesDialog dialog = new ChooseLibrariesFromTablesDialog(title, project, showCustomLibraryTables);
+ dialog.init();
+ return dialog;
+ }
+
@NotNull
@Override
protected Project getProject() {
addLibraryTable(result, registrar.getLibraryTable(myProject));
}
addLibraryTable(result, registrar.getLibraryTable());
- for (LibraryTable table : registrar.getCustomLibraryTables()) {
- addLibraryTable(result, table);
+ if (myShowCustomLibraryTables) {
+ for (LibraryTable table : registrar.getCustomLibraryTables()) {
+ addLibraryTable(result, table);
+ }
}
}
else if (element instanceof LibraryTable) {