Exemplo n.º 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);
   }
 }
Exemplo n.º 3
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);
  }
 public void addTask(BeforeRunTask task) {
   myModel.add(task);
 }