コード例 #1
0
  public void ensureSelectionVisible(boolean forceTopSelection) {
    if (isSelectionVisible() && !forceTopSelection) {
      return;
    }

    if (!forceTopSelection) {
      ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1);
      return;
    }

    // selected item should be at the top of the visible list
    int top = myList.getSelectedIndex();
    if (top > 0) {
      top--; // show one element above the selected one to give the hint that there are more
             // available via scrolling
    }

    int firstVisibleIndex = myList.getFirstVisibleIndex();
    if (firstVisibleIndex == top) {
      return;
    }

    ListScrollingUtil.ensureRangeIsVisible(
        myList, top, top + myList.getLastVisibleIndex() - firstVisibleIndex);
  }
コード例 #2
0
 void resetSelection() {
   if (myList.getSelectedIndex() != -1) return;
   SelectTemplateSettings settings = SelectTemplateSettings.getInstance();
   if (settings.getLastGroup() == null
       || !setSelectedTemplate(settings.getLastGroup(), settings.getLastTemplate())) {
     myList.setSelectedIndex(0);
   }
 }
コード例 #3
0
 @Nullable
 private Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> getSelection() {
   final int index = myList.getSelectedIndex();
   if (index == -1) return null;
   BeforeRunTask task = myModel.getElementAt(index);
   Key providerId = task.getProviderId();
   BeforeRunTaskProvider<BeforeRunTask> provider =
       BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), providerId);
   return provider != null ? Pair.create(task, provider) : null;
 }
コード例 #4
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());
  }
コード例 #5
0
 private void updateFields() {
   int index = myRulesList.getSelectedIndex();
   if (index >= 0 && index != myLastSelected) {
     final LibraryBundlificationRule rule = myRulesModel.getElementAt(index);
     myLibraryRegex.setText(rule.getRuleRegex());
     UIUtil.invokeLaterIfNeeded(() -> myManifestEditor.setText(rule.getAdditionalProperties()));
     myNeverBundle.setSelected(rule.isDoNotBundle());
     myStopAfterThisRule.setSelected(rule.isStopAfterThisRule());
     myLastSelected = index;
   }
   myLibraryRegex.setEnabled(index >= 0);
   myManifestEditor.setEnabled(index >= 0);
   myNeverBundle.setEnabled(index >= 0);
   myStopAfterThisRule.setEnabled(index >= 0);
 }
コード例 #6
0
 @Override
 public Rectangle getCurrentItemBounds() {
   int index = myList.getSelectedIndex();
   if (index < 0) {
     LOG.error("No selected element, size=" + getListModel().getSize() + "; items" + getItems());
   }
   Rectangle itmBounds = myList.getCellBounds(index, index);
   if (itmBounds == null) {
     LOG.error("No bounds for " + index + "; size=" + getListModel().getSize());
     return null;
   }
   Point layeredPanePoint =
       SwingUtilities.convertPoint(myList, itmBounds.x, itmBounds.y, getComponent());
   itmBounds.x = layeredPanePoint.x;
   itmBounds.y = layeredPanePoint.y;
   return itmBounds;
 }
コード例 #7
0
 private boolean isSelectionVisible() {
   return ListScrollingUtil.isIndexFullyVisible(myList, myList.getSelectedIndex());
 }