Example #1
0
 public List<String> getHistory() {
   final int itemsCount = myModel.getSize();
   List<String> history = new ArrayList<String>(itemsCount);
   for (int i = 0; i < itemsCount; i++) {
     history.add((String) myModel.getElementAt(i));
   }
   return history;
 }
Example #2
0
 private void updateMenu() {
   if (myNativeSearchPopup != null) {
     myNativeSearchPopup.removeAll();
     final int itemsCount = myModel.getSize();
     if (itemsCount == 0) {
       myNativeSearchPopup.add(myNoItems);
     } else {
       for (int i = 0; i < itemsCount; i++) {
         String item = (String) myModel.getElementAt(i);
         addMenuItem(item);
       }
     }
   }
 }
  private void rebuildPopup(
      @NotNull final UsageViewImpl usageView,
      @NotNull final List<Usage> usages,
      @NotNull List<UsageNode> nodes,
      @NotNull final JTable table,
      @NotNull final JBPopup popup,
      @NotNull final UsageViewPresentation presentation,
      @NotNull final RelativePoint popupPosition,
      boolean findUsagesInProgress) {
    ApplicationManager.getApplication().assertIsDispatchThread();

    boolean shouldShowMoreSeparator = usages.contains(MORE_USAGES_SEPARATOR);
    if (shouldShowMoreSeparator) {
      nodes.add(MORE_USAGES_SEPARATOR_NODE);
    }

    String title = presentation.getTabText();
    String fullTitle =
        getFullTitle(
            usages,
            title,
            shouldShowMoreSeparator,
            nodes.size() - (shouldShowMoreSeparator ? 1 : 0),
            findUsagesInProgress);

    ((AbstractPopup) popup).setCaption(fullTitle);

    List<UsageNode> data = collectData(usages, nodes, usageView, presentation);
    MyModel tableModel = setTableModel(table, usageView, data);
    List<UsageNode> existingData = tableModel.getItems();

    int row = table.getSelectedRow();

    int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row);
    if (newSelection < 0 || newSelection >= tableModel.getRowCount()) {
      TableScrollingUtil.ensureSelectionExists(table);
      newSelection = table.getSelectedRow();
    } else {
      table.getSelectionModel().setSelectionInterval(newSelection, newSelection);
    }
    TableScrollingUtil.ensureIndexIsVisible(table, newSelection, 0);

    setSizeAndDimensions(table, popup, popupPosition, data);
  }
  private void reset(
      final Keymap keymap,
      final QuickList[] allQuickLists,
      String filter,
      @Nullable KeyboardShortcut shortcut) {
    myKeymap = keymap;

    final PathsKeeper pathsKeeper = new PathsKeeper();
    pathsKeeper.storePaths();

    myRoot.removeAllChildren();

    ActionManager actionManager = ActionManager.getInstance();
    Project project =
        CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent));
    Group mainGroup =
        ActionsTreeUtil.createMainGroup(
            project,
            myKeymap,
            allQuickLists,
            filter,
            true,
            ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut, filter, true));
    if ((filter != null && filter.length() > 0 || shortcut != null)
        && mainGroup.initIds().isEmpty()) {
      mainGroup =
          ActionsTreeUtil.createMainGroup(
              project,
              myKeymap,
              allQuickLists,
              filter,
              false,
              ActionsTreeUtil.isActionFiltered(actionManager, myKeymap, shortcut, filter, false));
    }
    myRoot = ActionsTreeUtil.createNode(mainGroup);
    myMainGroup = mainGroup;
    MyModel model = (MyModel) myTree.getModel();
    model.setRoot(myRoot);
    model.nodeStructureChanged(myRoot);

    pathsKeeper.restorePaths();
  }
  @NotNull
  private static MyModel setTableModel(
      @NotNull JTable table,
      @NotNull UsageViewImpl usageView,
      @NotNull final List<UsageNode> data) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final int columnCount = calcColumnCount(data);
    MyModel model = table.getModel() instanceof MyModel ? (MyModel) table.getModel() : null;
    if (model == null || model.getColumnCount() != columnCount) {
      model = new MyModel(data, columnCount);
      table.setModel(model);

      ShowUsagesTableCellRenderer renderer = new ShowUsagesTableCellRenderer(usageView);
      for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
        TableColumn column = table.getColumnModel().getColumn(i);
        column.setCellRenderer(renderer);
      }
    }
    return model;
  }
Example #6
0
 public void addCurrentTextToHistory() {
   final String item = getText();
   myModel.addElement(item);
 }
Example #7
0
 public void setHistory(List<String> aHistory) {
   myModel.setItems(aHistory);
 }