Beispiel #1
0
 /**
  * constructor
  *
  * @param values list of values, ArrayList
  */
 public MPopButton(ArrayList values) {
   this();
   for (int i = 0; i < values.size(); i++) {
     JMenuItem item = popup.add((String) values.get(i));
     item.addActionListener(popActionListener);
     popup.add(item);
   }
   m_aListValues = values;
   setDefaultText();
 } // MPopButton()
Beispiel #2
0
 /**
  * constructor
  *
  * @param values list of values, String[]
  */
 public MPopButton(String[] values) {
   this();
   for (int i = 0; i < values.length; i++) {
     JMenuItem item = popup.add(values[i]);
     item.addActionListener(popActionListener);
     popup.add(item);
     m_aListValues.add(values[i]);
   }
   setDefaultText();
 } // MPopButton()
Beispiel #3
0
  /** constructor */
  public MPopButton() {
    popListeners = new Vector();

    popup = new JPopupMenu();
    popActionListener = new MPopActionListener(this);

    addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            popup.show(MPopButton.this, 6, getSize().height - 6);
          }
        });

    popup.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Util.setMenuUp(true);
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            Util.setMenuUp(false);
          }

          public void popupMenuCanceled(PopupMenuEvent e) {}
        });
  } // MPopButton()
Beispiel #4
0
    public void mouseClicked(MouseEvent evt) {
      int btn = evt.getButton();
      if (btn == MouseEvent.BUTTON3) {
        JPopupMenu helpMenu = new JPopupMenu();
        String helpLabel = Util.getLabel("CSHMenu");
        JMenuItem helpMenuItem = new JMenuItem(helpLabel);
        helpMenuItem.setActionCommand("help");
        helpMenu.add(helpMenuItem);

        ActionListener alMenuItem =
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                String topic = "";
                try {
                  JComponent c1 = (JComponent) tabbedPane.getSelectedComponent();
                  // This component should contain the following embedded items.
                  // We want m_helplink out of the top VGroup.
                  //   PushpinObj
                  //     XMLToolPanel
                  //       JScrollpane
                  //         JViewport
                  //           JPanel
                  //             VGroup
                  // Work down to the VGroup, checking for class type along
                  // the way.
                  if (c1 instanceof PushpinObj) {
                    Component c2[] = c1.getComponents();
                    int cnt;
                    for (cnt = 0; cnt < c2.length; cnt++) {
                      // The PushpinObj can have multiple items, find the one we want
                      if (c2[cnt] instanceof XMLToolPanel) break;
                    }
                    if (cnt < c2.length && c2[cnt] instanceof XMLToolPanel) {
                      Component c3[] = ((JComponent) c2[cnt]).getComponents();
                      if (c3[0] instanceof JScrollPane) {
                        Component c4[] = ((JComponent) c3[0]).getComponents();
                        if (c4[0] instanceof JViewport) {
                          Component c5[] = ((JComponent) c4[0]).getComponents();
                          if (c5[0] instanceof JPanel) {
                            Component c6[] = ((JComponent) c5[0]).getComponents();
                            if (c6[0] instanceof VGroup) {
                              // Get the helplink info from the VGroup
                              topic = ((VGroup) c6[0]).getAttribute(VObjDef.HELPLINK);
                            }
                          }
                        }
                      }
                    }
                  }
                  // If no helplink found, try the Tab's name
                  if (topic == null || topic.length() == 0) {
                    topic = c1.getName();
                    if (topic.equals("Locator")) topic = getLocatorName();
                    topic = topic.replace(" ", "_");
                  }
                } catch (Exception ex) {
                }
                // Get the ID and display the help content
                CSH_Util.displayCSHelp(topic);
              }
            };
        helpMenuItem.addActionListener(alMenuItem);

        Point pt = evt.getPoint();
        helpMenu.show(VTabbedToolPanel.this, (int) pt.getX(), (int) pt.getY());
      }
    }
Beispiel #5
0
 /**
  * set text to the specified item index
  *
  * @param index index
  */
 public void setText(int index) {
   JMenuItem item = (JMenuItem) popup.getComponent(index);
   setText(item.getText());
 } // setText()
Beispiel #6
0
 public void setEnabled(int index, boolean bEnabled) {
   JMenuItem item = (JMenuItem) popup.getComponent(index);
   if (item != null) item.setEnabled(bEnabled);
 }
Beispiel #7
0
 /** set default text */
 public void setDefaultText() {
   JMenuItem item = (JMenuItem) popup.getComponent(0);
   if (item != null) setText(item.getText());
 } // setDefaultText()