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);
      }
    }
  }
Пример #3
0
  @Override
  public void addItems(List<ClasspathTableItem<?>> toAdd) {
    for (ClasspathTableItem<?> item : toAdd) {
      myModel.addItem(item);
    }
    myModel.fireTableDataChanged();
    final ListSelectionModel selectionModel = myEntryTable.getSelectionModel();
    selectionModel.setSelectionInterval(
        myModel.getRowCount() - toAdd.size(), myModel.getRowCount() - 1);
    TableUtil.scrollSelectionToVisible(myEntryTable);

    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
  @Override
  public void addItems(List<ClasspathTableItem<?>> toAdd) {
    for (ClasspathTableItem<?> item : toAdd) {
      myModel.addRow(item);
    }
    TIntArrayList toSelect = new TIntArrayList();
    for (int i = myModel.getRowCount() - toAdd.size(); i < myModel.getRowCount(); i++) {
      toSelect.add(myEntryTable.convertRowIndexToView(i));
    }
    TableUtil.selectRows(myEntryTable, toSelect.toNativeArray());
    TableUtil.scrollSelectionToVisible(myEntryTable);

    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
  private void removeSelectedItems(final List removedRows) {
    if (removedRows.isEmpty()) {
      return;
    }
    for (final Object removedRow : removedRows) {
      final ClasspathTableItem<?> item =
          (ClasspathTableItem<?>) ((Object[]) removedRow)[ClasspathTableModel.ITEM_COLUMN];
      final OrderEntry orderEntry = item.getEntry();
      if (orderEntry == null) {
        continue;
      }

      getRootModel().removeOrderEntry(orderEntry);
    }
    final int[] selectedRows = myEntryTable.getSelectedRows();
    myModel.fireTableDataChanged();
    TableUtil.selectRows(myEntryTable, selectedRows);
    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
Пример #6
0
 public ActionCallback selectOrderEntry(
     @NotNull final Module module, @Nullable final OrderEntry orderEntry) {
   return ModuleStructureConfigurable.getInstance(myProject).selectOrderEntry(module, orderEntry);
 }
Пример #7
0
 private void addModulesConfig() {
   myModulesConfig = ModuleStructureConfigurable.getInstance(myProject);
   addConfigurable(myModulesConfig, ConfigurableId.MODULES);
 }