Пример #1
0
 private void handle(MouseEvent e) {
   if (e.isPopupTrigger()) {
     ActionManager mgr = getContext().getActions();
     JPopupMenu menu =
         mgr.createPopup(
             getContext().getResources().getStringArray(ElementNavigator.class, "popupActions"));
     menu.show((JComponent) e.getSource(), e.getX(), e.getY());
   }
 }
Пример #2
0
  void constructComponent() {
    setLayout(new BorderLayout());

    m_popupMenu = new JPopupMenu();
    mi_add = new JMenuItem("Add...");
    mi_add.addActionListener(this);
    m_popupMenu.add(mi_add);
    mi_edit = new JMenuItem("Edit...");
    mi_edit.addActionListener(this);
    m_popupMenu.add(mi_edit);
    mi_delete = new JMenuItem("Delete");
    mi_delete.addActionListener(this);
    m_popupMenu.addSeparator();
    m_popupMenu.add(mi_delete);

    m_tree = new OrganizationTree(m_conn, m_sessionid);
    m_tree.addMouseListener(new TreeMouseAdapter());

    add(new JScrollPane(m_tree), BorderLayout.CENTER);
  }
Пример #3
0
    private void createMenus() {
      menubar = new JMenuBar();
      operationsMenu = new JMenu("Operations");
      AddNodeAction addNode = new AddNodeAction();
      addNode.putValue(AbstractAction.NAME, "Add to this node");
      RemoveNodeAction removeNode = new RemoveNodeAction();
      removeNode.putValue(AbstractAction.NAME, "Remove this node");
      AddModifyDataForNodeAction addModAction = new AddModifyDataForNodeAction();
      addModAction.putValue(AbstractAction.NAME, "Add/Modify data");
      ExitAction exitAction = new ExitAction();
      exitAction.putValue(AbstractAction.NAME, "Exit");
      operationsMenu.add(addNode);
      operationsMenu.add(removeNode);
      operationsMenu.add(addModAction);
      operationsMenu.add(exitAction);
      menubar.add(operationsMenu);
      setJMenuBar(menubar);

      operationsPopup = new JPopupMenu();
      operationsPopup.add(addNode);
      operationsPopup.add(removeNode);
      operationsPopup.add(addModAction);
    }
Пример #4
0
 public void show(Component invoker, int x, int y) {
   Object o = getTree().getClosestPathForLocation(x, y).getLastPathComponent();
   if (null != o) {
     node = (Node) o;
     if ((node instanceof AttrConfig) || (node instanceof Config)) {
       newAttribute.setEnabled(true);
       duplicate.setEnabled(true);
       delete.setEnabled(true);
     } else {
       newAttribute.setEnabled(false);
       duplicate.setEnabled(false);
       delete.setEnabled(false);
     }
     super.show(invoker, x, y);
   }
 }
  /**
   * Shows the appropriate user interface that would allow the user to add the given
   * <tt>SourceUIContact</tt> to their contact list.
   *
   * @param contact the contact to add
   */
  private void addContact(SourceUIContact contact) {
    SourceContact sourceContact = (SourceContact) contact.getDescriptor();

    List<ContactDetail> details =
        sourceContact.getContactDetails(OperationSetPersistentPresence.class);
    int detailsCount = details.size();

    if (detailsCount > 1) {
      JMenuItem addContactMenu =
          TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor());

      JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();

      // Add a title label.
      JLabel infoLabel = new JLabel();
      infoLabel.setText(
          "<html><b>"
              + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")
              + "</b></html>");

      popupMenu.insert(infoLabel, 0);
      popupMenu.insert(new Separator(), 1);

      popupMenu.setFocusable(true);
      popupMenu.setInvoker(treeContactList);

      Point location =
          new Point(
              addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight());

      SwingUtilities.convertPointToScreen(location, treeContactList);

      location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;

      popupMenu.setLocation(location.x + 8, location.y - 8);
      popupMenu.setVisible(true);
    } else if (details.size() == 1) {
      TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName());
    }
  }
Пример #6
0
    // {{{ showPopupMenu method
    private void showPopupMenu(MouseEvent evt) {
      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      popupMenu = new JPopupMenu();
      Object userObj = node.getUserObject();
      if (userObj instanceof HyperSearchFileNode || userObj instanceof HyperSearchResult) {
        popupMenu.add(new GoToNodeAction("hypersearch-results.open", M_OPEN));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-view", M_OPEN_NEW_VIEW));
        popupMenu.add(
            new GoToNodeAction("hypersearch-results.open-plain-view", M_OPEN_NEW_PLAIN_VIEW));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-split", M_OPEN_NEW_SPLIT));
      }
      if (!(userObj instanceof HyperSearchFolderNode)) popupMenu.add(new RemoveTreeNodeAction());
      popupMenu.add(new ExpandChildTreeNodesAction());
      if (userObj instanceof HyperSearchFolderNode || userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new CollapseChildTreeNodesAction());
        if (userObj instanceof HyperSearchFolderNode) popupMenu.add(new NewSearchAction());
      }
      if (userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new JPopupMenu.Separator());
        HyperSearchOperationNode resultNode = (HyperSearchOperationNode) userObj;
        JCheckBoxMenuItem chkItem =
            new JCheckBoxMenuItem(
                jEdit.getProperty("hypersearch-results.tree-view"),
                resultNode.isTreeViewDisplayed());
        chkItem.addActionListener(new TreeDisplayAction());
        popupMenu.add(chkItem);

        popupMenu.add(new RedoSearchAction((HyperSearchOperationNode) userObj));
      }
      popupMenu.add(new CopyToClipboardAction());

      GUIUtilities.showPopupMenu(popupMenu, evt.getComponent(), evt.getX(), evt.getY());
      evt.consume();
    } // }}}