private void doEdit() {
    final OrderEntry entry = getSelectedEntry();
    if (!(entry instanceof LibraryOrderEntry)) return;

    final Library library = ((LibraryOrderEntry) entry).getLibrary();
    if (library == null) {
      return;
    }
    final LibraryTable table = library.getTable();
    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(
            this,
            provider,
            library,
            myState.getProject(),
            presentation,
            getStructureConfigurableContext());
    dialog.setContextModule(getRootModel().getModule());
    dialog.show();
    myEntryTable.repaint();
    ModuleStructureConfigurable.getInstance(myState.getProject()).getTree().repaint();
  }
  public static void showDialogAndAddLibraryToDependencies(
      final Library library, final Project project, boolean allowEmptySelection) {
    for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
      if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
        return;
      }
    }

    final ModuleStructureConfigurable moduleStructureConfigurable =
        ModuleStructureConfigurable.getInstance(project);
    final List<Module> modules =
        LibraryEditingUtil.getSuitableModules(
            moduleStructureConfigurable, ((LibraryEx) library).getKind(), library);
    if (modules.isEmpty()) return;
    final ChooseModulesDialog dlg =
        new ChooseModulesDialog(
            moduleStructureConfigurable.getProject(),
            modules,
            ProjectBundle.message("choose.modules.dialog.title"),
            ProjectBundle.message("choose.modules.dialog.description", library.getName()));
    if (dlg.showAndGet()) {
      final List<Module> chosenModules = dlg.getChosenElements();
      for (Module module : chosenModules) {
        moduleStructureConfigurable.addLibraryOrderEntry(module, library);
      }
    }
  }
 private void addChangeLibraryLevelAction(DefaultActionGroup actionGroup, String tableLevel) {
   final LibraryTablePresentation presentation =
       LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
   actionGroup.add(
       new ChangeLibraryLevelInClasspathAction(
           this, presentation.getDisplayName(true), tableLevel));
 }
 protected boolean validateAndApply() {
   String newName = myNameField.getText().trim();
   if (newName.length() == 0) {
     newName = null;
   }
   if (shouldCheckName(newName)) {
     final LibraryTable.ModifiableModel tableModifiableModel = getTableModifiableModel();
     if (tableModifiableModel != null && !(tableModifiableModel instanceof ModuleLibraryTable)) {
       if (newName == null) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.not.specified.error", newName),
             ProjectBundle.message("library.name.not.specified.title"));
         return false;
       }
       if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.already.exists.error", newName),
             ProjectBundle.message("library.name.already.exists.title"));
         return false;
       }
     }
     myLibraryRootsComponent.renameLibrary(newName);
   }
   myLibraryRootsComponent.applyProperties();
   return true;
 }
예제 #5
0
 @Override
 @NotNull
 public List<Library> chooseElements() {
   final Predicate<Library> condition =
       LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());
   ProjectStructureChooseLibrariesDialog dialog =
       new ProjectStructureChooseLibrariesDialog(myClasspathPanel, myContext, condition);
   dialog.show();
   return dialog.getSelectedLibraries();
 }
예제 #6
0
 @Override
 public PopupStep createSubStep() {
   return LibraryEditingUtil.createChooseTypeStep(
       myClasspathPanel,
       new ParameterizedRunnable<LibraryType>() {
         @Override
         public void run(LibraryType libraryType) {
           new AddNewLibraryDependencyAction(myClasspathPanel, myContext, libraryType).execute();
         }
       });
 }
예제 #7
0
 private boolean hasLibraries() {
   final Predicate<Library> condition =
       LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());
   for (LibraryTable table :
       ChooseLibrariesFromTablesDialog.getLibraryTables(myClasspathPanel.getProject(), true)) {
     final LibrariesModifiableModel model = myContext.myLevel2Providers.get(table.getTableLevel());
     if (model != null) {
       for (Library library : model.getLibraries()) {
         if (condition.apply(library)) {
           return true;
         }
       }
     }
   }
   return false;
 }
예제 #8
0
 @Override
 public boolean hasSubStep() {
   return !hasLibraries() && LibraryEditingUtil.hasSuitableTypes(myClasspathPanel);
 }