Ejemplo n.º 1
0
  public boolean isDropped() {
    if (droppedMethod != null) {
      try {
        return (Boolean) droppedMethod.invoke(combo, ReflectUtil.NO_ARGUMENTS);
      } catch (Exception ex) {
        OM.LOG.error(ex);
      }
    }

    return false;
  }
Ejemplo n.º 2
0
  public HistoryText(Composite parent, int style, IHistory<String> history) {
    this.history = history;
    history.addListener(historyListener);

    combo = new CCombo(parent, style);
    combo.setLayoutData(UIUtil.createGridData());
    combo.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            HistoryText.this.history.removeListener(historyListener);
          }
        });

    // TODO Can't get traversal working when keyListener is added ;-(
    // combo.addKeyListener(new KeyAdapter()
    // {
    // @Override
    // public void keyPressed(KeyEvent event)
    // {
    // if (event.character == SWT.DEL && event.stateMask == 0 && isDropped())
    // {
    // int index = combo.getSelectionIndex();
    // if (index != -1)
    // {
    // HistoryText.this.history.remove(index);
    // }
    // }
    // }
    // });

    try {
      droppedMethod =
          combo.getClass().getDeclaredMethod("isDropped", ReflectUtil.NO_PARAMETERS); // $NON-NLS-1$
      droppedMethod.setAccessible(true);
    } catch (Exception ex) {
      OM.LOG.error(ex);
    }

    historyChanged();
  }