Example usage for javax.swing JPopupMenu add

List of usage examples for javax.swing JPopupMenu add

Introduction

In this page you can find the example usage for javax.swing JPopupMenu add.

Prototype

public JMenuItem add(Action a) 

Source Link

Document

Appends a new menu item to the end of the menu which dispatches the specified Action object.

Usage

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private JPopupMenu getStructMapMenu() { // For the root item only
    if (!entityRootSet) {
        return null; // Don't want to have a menu unless we are editing an
        // entity
    }//from ww w .  j a v  a  2 s  .  c  o m
    final JPopupMenu menu = new JPopupMenu();
    JMenuItem item = new JMenuItem("Add Structure Item");
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            itmAddStructure(evt);
        }
    });
    menu.add(item);
    return menu;
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private JPopupMenu getStructMapMenu(StructMap map) {
    if (!entityRootSet) {
        return null; // Don't want to have a menu unless we are editing an
        // entity
    }//  www  .  j  a v a  2 s.  co m
    final JPopupMenu menu = new JPopupMenu();
    JMenuItem item = new JMenuItem("Rename Structure Item");
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            itmRenameStructMap(evt);
        }
    });
    menu.add(item);
    item = new JMenuItem("Add Structure Item");
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            itmAddStructure(evt);
        }
    });
    menu.add(item);
    menu.addSeparator();
    item = new JMenuItem("Delete Structure Item");
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            itmDeleteStructure(evt);
        }
    });
    menu.add(item);
    return menu;
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private JPopupMenu getStructMapMenu(FileSystemObject fso) {
    if (!entityRootSet) {
        return null; // Don't want to have a menu unless we are editing an
        // entity
    }//from w w w  .j  a v a 2  s.com
    final JPopupMenu menu = new JPopupMenu();
    ArrayList<FileGroupCollection> entities = getEntities();
    if (entities.size() == 1) {
        JMenuItem item = new JMenuItem("Delete File");
        item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itmDeleteStructure(evt);
            }
        });
        menu.add(item);
    }
    return menu;
}

From source file:op.tools.SYSCalendar.java

public static JPopupMenu getMinutesMenu(int[] mins, final Closure action) {
    JPopupMenu timemenu = new JPopupMenu(SYSTools.xx("misc.commands.changeeffort"));

    for (int min : mins) {
        String title = "";
        if (min % 60 == 0) {
            title = min / 60 + " " + SYSTools.xx("misc.msg.Hour(s)");
        } else {//from   ww  w  . j a  v a2s.  c  om
            title = min + " " + SYSTools.xx("misc.msg.Minute(s)");
        }

        JMenuItem item = new JMenuItem(title);
        final int minutes = min;
        item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                action.execute(minutes);
            }
        });
        timemenu.add(item);
    }

    return timemenu;
}

From source file:org.accretegb.modules.phenotype.PhenotypeInfoPanel.java

/**
 * populates parameter names from database
 *//*from w  w  w  .ja va2s.  c o m*/
public void populateParameterNames() {
    parameterName = new JButton();
    parametersCheckBoxes = new ArrayList<JCheckBox>();
    List<String> parameters = new ArrayList<String>();
    List<MeasurementParameter> results = MeasurementParameterDAO.getInstance().findAll();
    for (MeasurementParameter obj : results) {
        parameters.add(obj.getParameterName());
        parameter_id.put(obj.getParameterName(), String.valueOf(obj.getMeasurementParameterId()));
    }
    final JPopupMenu columnsPopupMenu = new JPopupMenu();
    final JCheckBox[] columnNameCheckBox = new JCheckBox[parameters.size()];
    JPanel columnsPopupPanel = new JPanel(new MigLayout("insets 0, gap 0"));
    JScrollPane scrollPane = new JScrollPane(columnsPopupPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    for (int columnCounter = 0; columnCounter < columnNameCheckBox.length; ++columnCounter) {
        columnNameCheckBox[columnCounter] = new JCheckBox(parameters.get(columnCounter));
        parametersCheckBoxes.add(columnNameCheckBox[columnCounter]);
        columnsPopupPanel.add(columnNameCheckBox[columnCounter], "wrap");
    }
    scrollPane.setPreferredSize(new Dimension(150, 300));

    columnsPopupMenu.add(scrollPane);
    parameterName.setAction(new AbstractAction("select") {
        public void actionPerformed(ActionEvent e) {
            columnsPopupMenu.show(parameterName, 0, parameterName.getHeight());
        }
    });
}

From source file:org.apache.cayenne.modeler.editor.AbstractCallbackMethodsTab.java

private JPopupMenu createPopup() {
    JPopupMenu popup = new JPopupMenu();

    popup.add(getRemoveCallbackMethodAction().buildMenu());
    popup.addSeparator();//from   w w w .  j a  va  2s  .c  om
    popup.add(getCopyCallbackMethodAction().buildMenu());
    popup.add(getCutCallbackMethodAction().buildMenu());
    popup.add(getPasteCallbackMethodAction().buildMenu());

    return popup;
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipPanel.java

private void init() {
    this.setLayout(new BorderLayout());

    ActionManager actionManager = Application.getInstance().getActionManager();

    table = new CayenneTable();
    table.setDefaultRenderer(String.class, new StringRenderer());
    table.setDefaultRenderer(ObjEntity.class, new EntityRenderer());
    tablePreferences = new TableColumnPreferences(ObjRelationshipTableModel.class,
            "objEntity/relationshipTable");

    /**//from   www .j  av a  2 s. c o m
     * Create and install a popup
     */
    Icon ico = ModelerUtil.buildIcon("icon-info.gif");
    resolveMenu = new JMenuItem("Database Mapping", ico);

    JPopupMenu popup = new JPopupMenu();
    popup.add(resolveMenu);
    popup.add(actionManager.getAction(RemoveAttributeRelationshipAction.class).buildMenu());

    popup.addSeparator();
    popup.add(actionManager.getAction(CutAttributeRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyAttributeRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());

    TablePopupHandler.install(table, popup);
    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipTab.java

private void init() {
    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(ObjEntitySyncAction.class).buildButton());
    toolBar.add(actionManager.getAction(ObjEntityCounterpartAction.class).buildButton());

    toolBar.addSeparator();/*from ww w. j a v  a  2s .com*/

    Icon ico = ModelerUtil.buildIcon("icon-info.gif");

    resolve = new JButton();
    resolve.setIcon(ico);
    resolve.setToolTipText("Edit Relationship");
    toolBar.add(resolve);

    toolBar.addSeparator();

    toolBar.add(actionManager.getAction(RemoveRelationshipAction.class).buildButton());

    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(CutRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(CopyRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton());

    add(toolBar, BorderLayout.NORTH);

    table = new CayenneTable();
    table.setDefaultRenderer(String.class, new StringRenderer());
    table.setDefaultRenderer(ObjEntity.class, new EntityRenderer());

    tablePreferences = new TableColumnPreferences(ObjRelationshipTableModel.class,
            "objEntity/relationshipTable");

    /**
     * Create and install a popup
     */
    resolveMenu = new JMenuItem("Database Mapping", ico);

    JPopupMenu popup = new JPopupMenu();
    popup.add(resolveMenu);
    popup.add(actionManager.getAction(RemoveRelationshipAction.class).buildMenu());

    popup.addSeparator();
    popup.add(actionManager.getAction(CutRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());

    TablePopupHandler.install(table, popup);

    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}

From source file:org.apache.cayenne.modeler.ProjectTreeView.java

/**
 * Creates JPopupMenu containing main functions
 *//*from  w w  w  .  ja  va 2s  . c o  m*/
private JPopupMenu createJPopupMenu() {
    JPopupMenu popup = new JPopupMenu();

    popup.add(buildMenu(CreateNodeAction.class));
    popup.add(buildMenu(CreateDataMapAction.class));

    popup.add(buildMenu(CreateObjEntityAction.class));
    popup.add(buildMenu(CreateEmbeddableAction.class));
    popup.add(buildMenu(CreateDbEntityAction.class));

    popup.add(buildMenu(CreateProcedureAction.class));
    popup.add(buildMenu(CreateQueryAction.class));
    popup.addSeparator();
    popup.add(buildMenu(ObjEntitySyncAction.class));
    popup.addSeparator();
    popup.add(buildMenu(LinkDataMapsAction.class));
    popup.addSeparator();
    popup.add(buildMenu(RemoveAction.class));
    popup.addSeparator();
    popup.add(buildMenu(CutAction.class));
    popup.add(buildMenu(CopyAction.class));
    popup.add(buildMenu(PasteAction.class));

    return popup;
}

From source file:org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel.java

private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)

    // register the right click menu
    JTable table = getTable();//from  w w  w.j ava  2s  .  co  m
    final JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem variabilizeItem = new JMenuItem(JMeterUtils.getResString("transform_into_variable"));
    variabilizeItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            transformNameIntoVariable();
        }
    });
    popupMenu.add(variabilizeItem);
    table.setComponentPopupMenu(popupMenu);
}