コード例 #1
0
 private boolean isOnNextStepButton(MouseEvent e) {
   final int index = myList.getSelectedIndex();
   final Rectangle bounds = myList.getCellBounds(index, index);
   final Point point = e.getPoint();
   return bounds != null
       && point.getX() > bounds.width + bounds.getX() - AllIcons.Icons.Ide.NextStep.getIconWidth();
 }
コード例 #2
0
 protected void onSelectByMnemonic(Object value) {
   if (myListModel.isVisible(value)) {
     myList.setSelectedValue(value, true);
     myList.repaint();
     handleSelect(true);
   }
 }
コード例 #3
0
  private boolean handleNextStep(final PopupStep nextStep, Object parentValue, InputEvent e) {
    if (nextStep != PopupStep.FINAL_CHOICE) {
      final Point point = myList.indexToLocation(myList.getSelectedIndex());
      SwingUtilities.convertPointToScreen(point, myList);
      myChild = createPopup(this, nextStep, parentValue);
      if (myChild instanceof ListPopupImpl) {
        for (ListSelectionListener listener : myList.getListSelectionListeners()) {
          ((ListPopupImpl) myChild).addListSelectionListener(listener);
        }
      }
      final JComponent container = getContent();
      assert container != null : "container == null";

      int y = point.y;
      if (parentValue != null && getListModel().isSeparatorAboveOf(parentValue)) {
        SeparatorWithText swt = new SeparatorWithText();
        swt.setCaption(getListModel().getCaptionAboveOf(parentValue));
        y += swt.getPreferredSize().height - 1;
      }

      myChild.show(container, point.x + container.getWidth() - STEP_X_PADDING, y, true);
      setIndexForShowingChild(myList.getSelectedIndex());
      return false;
    } else {
      setOk(true);
      setFinalRunnable(myStep.getFinalRunnable());
      disposeAllParents(e);
      setIndexForShowingChild(-1);
      return true;
    }
  }
コード例 #4
0
  private boolean tryToAutoSelect(boolean handleFinalChoices) {
    ListPopupStep<Object> listStep = getListStep();
    boolean selected = false;
    if (listStep instanceof MultiSelectionListPopupStep<?>) {
      int[] indices = ((MultiSelectionListPopupStep) listStep).getDefaultOptionIndices();
      if (indices.length > 0) {
        ListScrollingUtil.ensureIndexIsVisible(myList, indices[0], 0);
        myList.setSelectedIndices(indices);
        selected = true;
      }
    } else {
      final int defaultIndex = listStep.getDefaultOptionIndex();
      if (defaultIndex >= 0 && defaultIndex < myList.getModel().getSize()) {
        ListScrollingUtil.selectItem(myList, defaultIndex);
        selected = true;
      }
    }

    if (!selected) {
      selectFirstSelectableItem();
    }

    if (listStep.isAutoSelectionEnabled()) {
      if (!isVisible() && getSelectableCount() == 1) {
        return _handleSelect(handleFinalChoices, null);
      } else if (isVisible() && hasSingleSelectableItemWithSubmenu()) {
        return _handleSelect(handleFinalChoices, null);
      }
    }

    return false;
  }
コード例 #5
0
 protected void onAutoSelectionTimer() {
   if (myList.getModel().getSize() > 0 && !myList.isSelectionEmpty()) {
     handleSelect(false);
   } else {
     disposeChildren();
     setIndexForShowingChild(-1);
   }
 }
コード例 #6
0
  protected boolean beforeShow() {
    myList.addMouseMotionListener(myMouseMotionListener);
    myList.addMouseListener(myMouseListener);

    myList.setVisibleRowCount(Math.min(myMaxRowCount, myListModel.getSize()));

    boolean shouldShow = super.beforeShow();
    if (myAutoHandleBeforeShow) {
      final boolean toDispose = tryToAutoSelect(true);
      shouldShow &= !toDispose;
    }

    return shouldShow;
  }
コード例 #7
0
  protected void onSpeedSearchPatternChanged() {
    myListModel.refilter();
    if (myListModel.getSize() > 0) {
      if (!autoSelectUsingStatistics()) {
        int fullMatchIndex = myListModel.getClosestMatchIndex();
        if (fullMatchIndex != -1) {
          myList.setSelectedIndex(fullMatchIndex);
        }

        if (myListModel.getSize() <= myList.getSelectedIndex()
            || !myListModel.isVisible(myList.getSelectedValue())) {
          myList.setSelectedIndex(0);
        }
      }
    }
  }
コード例 #8
0
ファイル: VizieRPanel.java プロジェクト: jankotek/asterope
  /**
   * submit
   *
   * @param a
   * @param b
   * @return boolean
   */
  public boolean submit(String a, String b) {
    int selected[];
    int i;
    StringBuffer extra = new StringBuffer();

    waitCursor();

    for (int j = 0; j < nSection; j++) {
      selected = lk[j].getSelectedIndices();
      for (i = 0; i < selected.length; i++)
        CDSMethods.append(
            extra,
            (String) vq.getNameKey().elementAt(j),
            (String) lk[j].getModel().getElementAt(selected[i]));
    }

    boolean res =
        vq.submit(
            a,
            b,
            (String) unit.getSelectedItem(),
            (String) coordinate.getSelectedItem(),
            tauthor.getText(),
            extra.toString(),
            outputMode,
            resList.getList());
    defaultCursor();
    return res;
  }
コード例 #9
0
ファイル: VizieRPanel.java プロジェクト: jankotek/asterope
 /**
  * Return the Catalogs data list
  *
  * @return a Vector
  */
 public Vector getResultVector() {
   return resList.getList();
   //      Vector result = new Vector();
   //      for (int i = 0; i < this.resultat.getItemCount(); i++)
   //        result.addElement(this.resultat.getItem(i));
   //      return result;
 }
コード例 #10
0
 private void selectFirstSelectableItem() {
   for (int i = 0; i < myListModel.getSize(); i++) {
     if (getListStep().isSelectable(myListModel.getElementAt(i))) {
       myList.setSelectedIndex(i);
       break;
     }
   }
 }
コード例 #11
0
  private boolean _handleSelect(final boolean handleFinalChoices, InputEvent e) {
    if (myList.getSelectedIndex() == -1) return false;

    if (getSpeedSearch().isHoldingFilter() && myList.getModel().getSize() == 0) return false;

    if (myList.getSelectedIndex() == getIndexForShowingChild()) {
      if (myChild != null && !myChild.isVisible()) setIndexForShowingChild(-1);
      return false;
    }

    final Object[] selectedValues = myList.getSelectedValues();
    final ListPopupStep<Object> listStep = getListStep();
    if (!listStep.isSelectable(selectedValues[0])) return false;

    if ((listStep instanceof MultiSelectionListPopupStep<?>
                && !((MultiSelectionListPopupStep<Object>) listStep)
                    .hasSubstep(Arrays.asList(selectedValues))
            || !listStep.hasSubstep(selectedValues[0]))
        && !handleFinalChoices) return false;

    disposeChildren();

    if (myListModel.getSize() == 0) {
      setFinalRunnable(myStep.getFinalRunnable());
      setOk(true);
      disposeAllParents(e);
      setIndexForShowingChild(-1);
      return true;
    }

    valuesSelected(selectedValues);

    final PopupStep nextStep =
        listStep instanceof MultiSelectionListPopupStep<?>
            ? ((MultiSelectionListPopupStep<Object>) listStep)
                .onChosen(Arrays.asList(selectedValues), handleFinalChoices)
            : listStep.onChosen(selectedValues[0], handleFinalChoices);
    return handleNextStep(nextStep, selectedValues.length == 1 ? selectedValues[0] : null, e);
  }
コード例 #12
0
 protected void onChildSelectedFor(Object value) {
   if (myList.getSelectedValue() != value) {
     myList.setSelectedValue(value, false);
   }
 }
コード例 #13
0
 protected void process(KeyEvent aEvent) {
   myList.processKeyEvent(aEvent);
 }
コード例 #14
0
  protected JComponent createContent() {
    myMouseMotionListener = new MyMouseMotionListener();
    myMouseListener = new MyMouseListener();

    myListModel = new ListPopupModel(this, getSpeedSearch(), getListStep());
    myList = new MyList();
    if (myStep.getTitle() != null) {
      myList.getAccessibleContext().setAccessibleName(myStep.getTitle());
    }
    myList.setSelectionMode(
        isMultiSelectionEnabled()
            ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION);

    myList.setSelectedIndex(0);
    Insets padding = UIUtil.getListViewportPadding();
    myList.setBorder(new EmptyBorder(padding));

    ListScrollingUtil.installActions(myList);

    myList.setCellRenderer(getListElementRenderer());

    myList.getActionMap().get("selectNextColumn").setEnabled(false);
    myList.getActionMap().get("selectPreviousColumn").setEnabled(false);

    registerAction(
        "handleSelection1",
        KeyEvent.VK_ENTER,
        0,
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            handleSelect(true);
          }
        });

    registerAction(
        "handleSelection2",
        KeyEvent.VK_RIGHT,
        0,
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            handleSelect(false);
          }
        });

    registerAction(
        "goBack2",
        KeyEvent.VK_LEFT,
        0,
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (isClosableByLeftArrow()) {
              goBack();
            }
          }
        });

    myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return myList;
  }
コード例 #15
0
 public Object[] getSelectedValues() {
   return myList.getSelectedValues();
 }
コード例 #16
0
 @Override
 public void addListSelectionListener(ListSelectionListener listSelectionListener) {
   myList.addListSelectionListener(listSelectionListener);
 }
コード例 #17
0
 protected ActionMap getActionMap() {
   return myList.getActionMap();
 }
コード例 #18
0
 protected Rectangle getCellBounds(int i) {
   return myList.getCellBounds(i, i);
 }
コード例 #19
0
 protected int getSelectedIndex() {
   return myList.getSelectedIndex();
 }
コード例 #20
0
 public void dispose() {
   myList.removeMouseMotionListener(myMouseMotionListener);
   myList.removeMouseListener(myMouseListener);
   super.dispose();
 }
コード例 #21
0
 protected InputMap getInputMap() {
   return myList.getInputMap();
 }