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();
 }
 protected void onSelectByMnemonic(Object value) {
   if (myListModel.isVisible(value)) {
     myList.setSelectedValue(value, true);
     myList.repaint();
     handleSelect(true);
   }
 }
  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;
    }
  }
  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;
  }
 protected void onAutoSelectionTimer() {
   if (myList.getModel().getSize() > 0 && !myList.isSelectionEmpty()) {
     handleSelect(false);
   } else {
     disposeChildren();
     setIndexForShowingChild(-1);
   }
 }
  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;
  }
  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
  /**
   * 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
 /**
  * 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;
 }
 private void selectFirstSelectableItem() {
   for (int i = 0; i < myListModel.getSize(); i++) {
     if (getListStep().isSelectable(myListModel.getElementAt(i))) {
       myList.setSelectedIndex(i);
       break;
     }
   }
 }
  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);
  }
 protected void onChildSelectedFor(Object value) {
   if (myList.getSelectedValue() != value) {
     myList.setSelectedValue(value, false);
   }
 }
 protected void process(KeyEvent aEvent) {
   myList.processKeyEvent(aEvent);
 }
  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;
  }
 public Object[] getSelectedValues() {
   return myList.getSelectedValues();
 }
 @Override
 public void addListSelectionListener(ListSelectionListener listSelectionListener) {
   myList.addListSelectionListener(listSelectionListener);
 }
 protected ActionMap getActionMap() {
   return myList.getActionMap();
 }
 protected Rectangle getCellBounds(int i) {
   return myList.getCellBounds(i, i);
 }
 protected int getSelectedIndex() {
   return myList.getSelectedIndex();
 }
 public void dispose() {
   myList.removeMouseMotionListener(myMouseMotionListener);
   myList.removeMouseListener(myMouseListener);
   super.dispose();
 }
 protected InputMap getInputMap() {
   return myList.getInputMap();
 }