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();
  }
 @Override
 public void navigate(boolean openLibraryEditor) {
   final OrderEntry entry = getSelectedEntry();
   final ProjectStructureConfigurable rootConfigurable =
       ProjectStructureConfigurable.getInstance(myState.getProject());
   if (entry instanceof ModuleOrderEntry) {
     Module module = ((ModuleOrderEntry) entry).getModule();
     if (module != null) {
       rootConfigurable.select(module.getName(), null, true);
     }
   } else if (entry instanceof LibraryOrderEntry) {
     if (!openLibraryEditor
         && !((LibraryOrderEntry) entry)
             .getLibraryLevel()
             .equals(LibraryTableImplUtil.MODULE_LEVEL)) {
       rootConfigurable.select((LibraryOrderEntry) entry, true);
     } else {
       doEdit();
     }
   } else if (entry instanceof JdkOrderEntry) {
     Sdk jdk = ((JdkOrderEntry) entry).getJdk();
     if (jdk != null) {
       rootConfigurable.select(jdk, true);
     }
   }
 }
 public void selectOrderEntry(@NotNull OrderEntry entry) {
   for (int row = 0; row < myModel.getRowCount(); row++) {
     final OrderEntry orderEntry = getItemAt(row).getEntry();
     if (orderEntry != null
         && entry.getPresentableName().equals(orderEntry.getPresentableName())) {
       myEntryTable.getSelectionModel().setSelectionInterval(row, row);
       TableUtil.scrollSelectionToVisible(myEntryTable);
     }
   }
   IdeFocusManager.getInstance(myState.getProject()).requestFocus(myEntryTable, true);
 }
  @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()));
  }
 @Override
 public void navigate(boolean openLibraryEditor) {
   final OrderEntry entry = getSelectedEntry();
   final ProjectStructureConfigurable rootConfigurable =
       ProjectStructureConfigurable.getInstance(myState.getProject());
   if (entry instanceof ModuleOrderEntry) {
     Module module = ((ModuleOrderEntry) entry).getModule();
     if (module != null) {
       rootConfigurable.select(module.getName(), null, true);
     }
   } else if (entry instanceof LibraryOrderEntry) {
     if (!openLibraryEditor) {
       rootConfigurable.select((LibraryOrderEntry) entry, true);
     } else {
       myEditButton.actionPerformed(null);
     }
   } else if (entry instanceof SdkOrderEntry) {
     Sdk jdk = ((SdkOrderEntry) entry).getSdk();
     if (jdk != null) {
       rootConfigurable.select(jdk, true);
     }
   }
 }
 private StructureConfigurableContext getStructureConfigurableContext() {
   return ProjectStructureConfigurable.getInstance(myState.getProject()).getContext();
 }
 @Override
 public Project getProject() {
   return myState.getProject();
 }