コード例 #1
0
  private void addEmptyItem(CollectionListModel<LookupElement> model) {
    LookupItem<String> item =
        new EmptyLookupItem(
            myCalculating ? " " : LangBundle.message("completion.no.suggestions"), false);
    myMatchers.put(item, new CamelHumpMatcher(""));
    model.add(item);

    updateLookupWidth(item);
    requestResize();
  }
 private void replaceDependency(DependencyOnPlugin original, JBList dependenciesList) {
   DependencyOnPlugin dependency = editPluginDependency(dependenciesList, original);
   if (dependency != null) {
     for (ProjectExternalDependency dependency1 :
         new ArrayList<ProjectExternalDependency>(myListModel.getItems())) {
       if (dependency1 instanceof DependencyOnPlugin
           && ((DependencyOnPlugin) dependency1).getPluginId().equals(dependency.getPluginId())) {
         myListModel.remove(dependency1);
       }
     }
     myListModel.add(dependency);
     dependenciesList.setSelectedValue(dependency, true);
   }
 }
コード例 #3
0
  private static void assertMerge(
      String[] items, int startSelection, int expectedSelection, String... newItems) {
    CollectionListModel<String> model = new CollectionListModel<String>();
    model.add(Arrays.asList(items));
    JBList list = new JBList(model);
    list.setSelectedIndex(startSelection);

    FinderRecursivePanel.mergeListItems(model, Arrays.asList(newItems));
    assertEquals(newItems.length, model.getSize());
    for (int i = 0; i < newItems.length; i++) {
      assertEquals(newItems[i], model.getElementAt(i));
    }
    assertEquals(expectedSelection, list.getSelectedIndex());
  }
コード例 #4
0
  private boolean updateList(boolean onExplicitAction, boolean reused) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      ApplicationManager.getApplication().assertIsDispatchThread();
    }
    checkValid();

    CollectionListModel<LookupElement> listModel = getListModel();

    Pair<List<LookupElement>, Integer> pair;
    synchronized (myList) {
      pair = myPresentableArranger.arrangeItems(this, onExplicitAction || reused);
    }

    List<LookupElement> items = pair.first;
    Integer toSelect = pair.second;
    if (toSelect == null || toSelect < 0 || items.size() > 0 && toSelect >= items.size()) {
      LOG.error(
          "Arranger "
              + myPresentableArranger
              + " returned invalid selection index="
              + toSelect
              + "; items="
              + items);
      toSelect = 0;
    }

    myOffsets.checkMinPrefixLengthChanges(items, this);
    List<LookupElement> oldModel = listModel.toList();

    listModel.removeAll();
    if (!items.isEmpty()) {
      listModel.add(items);
    } else {
      addEmptyItem(listModel);
    }

    updateListHeight(listModel);

    myList.setSelectedIndex(toSelect);
    return !ContainerUtil.equalsIdentity(oldModel, items);
  }
コード例 #5
0
 public void addTask(BeforeRunTask task) {
   myModel.add(task);
 }