コード例 #1
0
ファイル: JopButtonset.java プロジェクト: jordibrus/proview
  public void actionPerformed(ActionEvent e) {
    boolean engine_found = false;
    Container parent = getParent();
    while (parent != null) {
      if (parent instanceof JopFrame) {
        en = ((JopFrame) parent).engine;
        if (!en.isReady()) break;
        en.add(this);
        root = parent;
        session = ((JopFrame) root).session;
        engine_found = true;
        break;
      }
      parent = parent.getParent();
    }
    if (!engine_found) {
      parent = getParent();
      while (parent != null) {
        if (parent instanceof JopApplet) {
          en = ((JopApplet) parent).engine;
          if (!en.isReady()) break;
          en.add(this);
          root = parent;
          session = ((JopApplet) root).session;
          engine_found = true;
          break;
        }
        parent = parent.getParent();
      }
    }
    if (engine_found) {
      timer.stop();
      timer = null;
      if (en.gdh.isAuthorized(access)) {
        this.addMouseListener(
            new MouseAdapter() {
              public void mouseClicked(MouseEvent e) {
                PwrtStatus sts;
                if (confirm) {
                  JopConfirmDialog.open(component, confirmText);
                } else if (clickAction == Jop.BUTTON_ACTION_SET) {
                  sts = en.gdh.setObjectInfo(pwrAttribute, true);
                  if (sts.evenSts()) System.out.println("setObjectInfoError " + sts);
                } else if (clickAction == Jop.BUTTON_ACTION_RESET) {
                  sts = en.gdh.setObjectInfo(pwrAttribute, false);
                  if (sts.evenSts()) System.out.println("setObjectInfoError " + sts);
                } else if (clickAction == Jop.BUTTON_ACTION_TOGGLE) {
                  sts = en.gdh.toggleObjectInfo(pwrAttribute);
                  if (sts.evenSts()) System.out.println("setObjectInfoError " + sts);
                } else if (clickAction == Jop.BUTTON_ACTION_COMMAND) {
                  Jop.executeCommand(session, command);
                }
              }

              public void mousePressed(MouseEvent e) {
                colorInverse = 1;
                repaint();
              }

              public void mouseReleased(MouseEvent e) {
                colorInverse = 0;
                repaint();
              }
            });
      }
    }
  }