mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show library level in 'Configure Library' dialog
This commit is contained in:
+10
-9
@@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ModuleLibraryTable;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
@@ -33,6 +32,7 @@ import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.configuration.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.dependencyAnalysis.AnalyzeDependenciesDialog;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.EditExistingLibraryDialog;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.FindUsagesInProjectStructureActionBase;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
|
||||
@@ -206,15 +206,14 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
myEntryTable);
|
||||
actionGroup.add(navigateAction);
|
||||
actionGroup.add(new MyFindUsagesAction());
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTablesRegistrar.PROJECT_LEVEL,
|
||||
LibraryTablesRegistrar.getInstance().getLibraryTable(getProject()).getPresentation());
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTablesRegistrar.APPLICATION_LEVEL,
|
||||
LibraryTablesRegistrar.getInstance().getLibraryTable().getPresentation());
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTableImplUtil.MODULE_LEVEL, ModuleLibraryTable.MODULE_LIBRARY_TABLE_PRESENTATION);
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTablesRegistrar.PROJECT_LEVEL);
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTablesRegistrar.APPLICATION_LEVEL);
|
||||
addChangeLibraryLevelAction(actionGroup, LibraryTableImplUtil.MODULE_LEVEL);
|
||||
PopupHandler.installPopupHandler(myEntryTable, actionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
|
||||
}
|
||||
|
||||
private void addChangeLibraryLevelAction(DefaultActionGroup actionGroup, String tableLevel, LibraryTablePresentation presentation) {
|
||||
private void addChangeLibraryLevelAction(DefaultActionGroup actionGroup, String tableLevel) {
|
||||
final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
|
||||
actionGroup.add(new ChangeLibraryLevelInClasspathAction(this, presentation.getDisplayName(true), tableLevel));
|
||||
}
|
||||
|
||||
@@ -353,8 +352,10 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
return;
|
||||
}
|
||||
final LibraryTable table = library.getTable();
|
||||
final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL);
|
||||
EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(ClasspathPanelImpl.this, provider, library, myState.getProject());
|
||||
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);
|
||||
dialog.setContextModule(getRootModel().getModule());
|
||||
dialog.show();
|
||||
myEntryTable.repaint();
|
||||
|
||||
+18
@@ -16,17 +16,24 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.libraries;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.ModuleLibraryTable;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
|
||||
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.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -37,6 +44,8 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public class LibraryEditingUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil");
|
||||
|
||||
private LibraryEditingUtil() {
|
||||
}
|
||||
|
||||
@@ -127,4 +136,13 @@ public class LibraryEditingUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static LibraryTablePresentation getLibraryTablePresentation(@NotNull Project project, @NotNull String level) {
|
||||
if (level.equals(LibraryTableImplUtil.MODULE_LEVEL)) {
|
||||
return ModuleLibraryTable.MODULE_LIBRARY_TABLE_PRESENTATION;
|
||||
}
|
||||
final LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, project);
|
||||
LOG.assertTrue(table != null, level);
|
||||
return table.getPresentation();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
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.configuration.LibraryTableModifiableModelProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -37,7 +38,7 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
|
||||
public static EditExistingLibraryDialog createDialog(Component parent,
|
||||
LibraryTableModifiableModelProvider modelProvider,
|
||||
Library library,
|
||||
@Nullable Project project) {
|
||||
@Nullable Project project, LibraryTablePresentation presentation) {
|
||||
LibraryTable.ModifiableModel modifiableModel = modelProvider.getModifiableModel();
|
||||
boolean commitChanges = false;
|
||||
ExistingLibraryEditor libraryEditor;
|
||||
@@ -48,13 +49,17 @@ public class EditExistingLibraryDialog extends LibraryEditorDialogBase {
|
||||
libraryEditor = new ExistingLibraryEditor(library, null);
|
||||
commitChanges = true;
|
||||
}
|
||||
return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges);
|
||||
return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges, presentation);
|
||||
}
|
||||
|
||||
private EditExistingLibraryDialog(Component parent,
|
||||
LibraryTable.ModifiableModel tableModifiableModel,
|
||||
@Nullable Project project, ExistingLibraryEditor libraryEditor, boolean commitChanges) {
|
||||
LibraryTable.ModifiableModel tableModifiableModel,
|
||||
@Nullable Project project,
|
||||
ExistingLibraryEditor libraryEditor,
|
||||
boolean commitChanges,
|
||||
LibraryTablePresentation presentation) {
|
||||
super(parent, new LibraryRootsComponent(project, libraryEditor));
|
||||
setTitle(presentation.getLibraryTableEditorTitle());
|
||||
myTableModifiableModel = tableModifiableModel;
|
||||
myLibraryEditor = libraryEditor;
|
||||
myCommitChanges = commitChanges;
|
||||
|
||||
Reference in New Issue
Block a user