Пример #1
0
  private void refreshList() {
    if (getComponent().getItemCount() > 0) getComponent().removeAllItems();

    if (isReadWrite()) {
      if (lookup != null) {
        int size = lookup.getSize();

        boolean found = false;
        for (int i = 0; i < size; i++) {
          Object obj = lookup.getElementAt(i);
          if (obj instanceof KeyNamePair) {
            KeyNamePair lookupKNPair = (KeyNamePair) obj;
            getComponent().appendItem(lookupKNPair.getName(), lookupKNPair.getKey());
            if (!found
                && oldValue != null
                && oldValue instanceof Integer
                && lookupKNPair.getKey() == (Integer) oldValue) {
              found = true;
            }
          } else if (obj instanceof ValueNamePair) {
            ValueNamePair lookupKNPair = (ValueNamePair) obj;
            getComponent().appendItem(lookupKNPair.getName(), lookupKNPair.getValue());
            if (!found && oldValue != null && lookupKNPair.getValue().equals(oldValue.toString())) {
              found = true;
            }
          }
        }
        if (!found && oldValue != null) {
          NamePair pair = lookup.getDirect(oldValue, false, false);
          if (pair != null) {
            if (pair instanceof KeyNamePair) {
              int key = ((KeyNamePair) pair).getKey();
              getComponent().appendItem(pair.getName(), key);
            } else if (pair instanceof ValueNamePair) {
              ValueNamePair valueNamePair = (ValueNamePair) pair;
              getComponent().appendItem(valueNamePair.getName(), valueNamePair.getValue());
            }
          }
        }
      }
    } else {
      if (lookup != null) {
        NamePair pair = lookup.getDirect(oldValue, false, false);
        if (pair != null) {
          if (pair instanceof KeyNamePair) {
            int key = ((KeyNamePair) pair).getKey();
            getComponent().appendItem(pair.getName(), key);
          } else if (pair instanceof ValueNamePair) {
            ValueNamePair valueNamePair = (ValueNamePair) pair;
            getComponent().appendItem(valueNamePair.getName(), valueNamePair.getValue());
          }
        }
      }
    }
    getComponent().setValue(oldValue);
  }
Пример #2
0
  /**
   * Descripción de Método
   *
   * @param e
   * @param rightClick
   */
  private void mouse_clicked(MouseEvent e, boolean rightClick) {
    Point point = e.getPoint();

    log.info("Right=" + rightClick + " - " + point.toString());

    if (rightClick) {
      m_ddQ = m_viewPanel.getDrillDown(point);
      m_daQ = m_viewPanel.getDrillAcross(point);
      m_ddM = null;
      m_daM = null;

      if ((m_ddQ == null) && (m_daQ == null)) {
        return;
      }

      // Create Menu

      JPopupMenu pop = new JPopupMenu();
      Icon wi = Env.getImageIcon("mWindow.gif");

      if (m_ddQ != null) {
        m_ddM = new JMenuItem(m_ddQ.getDisplayName(Env.getCtx()), wi);
        m_ddM.setToolTipText(m_ddQ.toString());
        m_ddM.addActionListener(this);
        pop.add(m_ddM);
      }

      if (m_daQ != null) {
        m_daM = new JMenuItem(m_daQ.getDisplayName(Env.getCtx()), wi);
        m_daM.setToolTipText(m_daQ.toString());
        m_daM.addActionListener(this);
        pop.add(m_daM);
      }

      Point pp = e.getPoint();

      pop.show((Component) e.getSource(), pp.x, pp.y);

      return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    if (m_drillDown) {
      MQuery query = m_viewPanel.getDrillDown(point);

      if (query != null) {
        log.info("Drill Down: " + query.getWhereClause(true));
        executeDrill(query);
      }
    } else if ((comboDrill.getSelectedItem() != null) && (comboDrill.getSelectedIndex() > 0)) {
      MQuery query = m_viewPanel.getDrillAcross(point);

      if (query != null) {
        NamePair pp = (NamePair) comboDrill.getSelectedItem();

        query.setTableName(pp.getID());
        log.info("Drill Accross: " + query.getWhereClause(true));
        executeDrill(query);
      }
    }

    cmd_drill(); // setCursor
  } // mouse_clicked