Search in sources :

Example 81 with JPopupMenu

use of javax.swing.JPopupMenu in project knime-core by knime.

the class AggregationColumnPanel method createTablePopupMenu.

/**
 * {@inheritDoc}
 */
@Override
protected JPopupMenu createTablePopupMenu() {
    final JPopupMenu menu = new JPopupMenu();
    if (getNoOfTableRows() == 0) {
        // the table contains no rows
        final JMenuItem item = new JMenuItem("No column(s) available");
        item.setEnabled(false);
        menu.add(item);
        return menu;
    }
    createColumnSelectionMenu(menu);
    menu.addSeparator();
    appendMissingValuesEntry(menu);
    menu.addSeparator();
    createAggregationSection(menu);
    return menu;
}
Also used : JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 82 with JPopupMenu

use of javax.swing.JPopupMenu in project vcell by virtualcell.

the class PDEDataViewer method getImagejPopupMenu.

private javax.swing.JPopupMenu getImagejPopupMenu() {
    if (imagejPopupMenu == null) {
        try {
            imagejPopupMenu = new JPopupMenu();
            imagejPopupMenu.add(getSendTimePointImageMenuItem());
            imagejPopupMenu.add(getSendDomainImageMenuItem());
            imagejPopupMenu.add(getsendTimeSeriesImageMenuItem());
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return imagejPopupMenu;
}
Also used : JPopupMenu(javax.swing.JPopupMenu)

Example 83 with JPopupMenu

use of javax.swing.JPopupMenu in project vcell by virtualcell.

the class DefaultScrollTableActionManager method constructPopupMenu.

protected void constructPopupMenu() {
    TableModel tableModel = ownerTable.getModel();
    int numColumns = tableModel.getColumnCount();
    boolean[] bEditable = new boolean[numColumns];
    boolean bTableEditable = false;
    for (int c = 0; c < numColumns; c++) {
        for (int r = 0; r < selectedRows.length; r++) {
            if (tableModel.isCellEditable(selectedRows[r], c)) {
                bEditable[c] = true;
                bTableEditable = true;
                break;
            }
        }
    }
    if (!bTableEditable) {
        return;
    }
    if (popupMenu == null) {
        popupMenu = new JPopupMenu();
        columnMenus = new JMenu[numColumns];
        popupLabel = new javax.swing.JLabel();
        popupLabel.setText(" Specify Column Value for Selected Row(s)");
    }
    popupMenu.removeAll();
    popupMenu.add(popupLabel);
    int[] uniqueColumns = getUniqueColumns();
    for (int c = 0; c < numColumns; c++) {
        String columnName = tableModel.getColumnName(c);
        if (disabledColumnPopups.contains(c)) {
            continue;
        }
        if (columnName.equalsIgnoreCase("name")) {
            continue;
        }
        boolean bUnique = false;
        if (uniqueColumns != null) {
            for (int uc : uniqueColumns) {
                if (uc == c) {
                    bUnique = true;
                    break;
                }
            }
        }
        if (bUnique) {
            continue;
        }
        if (bEditable[c]) {
            if (columnMenus[c] == null) {
                Class<?> columnClass = tableModel.getColumnClass(c);
                Component editorComponent = null;
                TableCellEditor cellEditor = ownerTable.getColumnModel().getColumn(c).getCellEditor();
                if (cellEditor == null) {
                    cellEditor = ownerTable.getDefaultEditor(columnClass);
                }
                if (cellEditor instanceof DefaultCellEditor) {
                    editorComponent = ((DefaultCellEditor) cellEditor).getComponent();
                }
                if (editorComponent == null || !(editorComponent instanceof JCheckBox) && !(editorComponent instanceof JTextField)) {
                    continue;
                }
                ScrollTableCellEditorType editorType = editorComponent instanceof JCheckBox ? ScrollTableCellEditorType.jcheckbox : ScrollTableCellEditorType.jtextfield;
                columnMenus[c] = new JMenu(columnName);
                switch(editorType) {
                    case jcheckbox:
                        JMenuItem menuItemCheckSelected = new JMenuItem("Checked");
                        menuItemCheckSelected.addActionListener(this);
                        columnActionComponentList.add(new ColumnActionComponent(c, menuItemCheckSelected, true));
                        JMenuItem menuItemUncheckSelected = new JMenuItem("Unchecked");
                        menuItemUncheckSelected.addActionListener(this);
                        columnActionComponentList.add(new ColumnActionComponent(c, menuItemUncheckSelected, false));
                        columnMenus[c].add(menuItemCheckSelected);
                        columnMenus[c].add(menuItemUncheckSelected);
                        break;
                    case jtextfield:
                        JTextField textField = new JTextField(5);
                        textField.addActionListener(this);
                        textField.setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(2, 4, 2, 4), textField.getBorder()));
                        columnActionComponentList.add(new ColumnActionComponent(c, textField));
                        JLabel label = new JLabel(" (Press Enter to commit) ");
                        label.setFont(label.getFont().deriveFont(label.getFont().getSize2D() - 1));
                        columnMenus[c].add(textField);
                        columnMenus[c].add(label);
                        break;
                }
            }
            columnMenus[c].setEnabled(true);
        } else {
            if (columnMenus[c] != null) {
                columnMenus[c].setEnabled(false);
            }
        }
        if (columnMenus[c] != null) {
            popupMenu.add(columnMenus[c]);
        }
    }
}
Also used : JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JPopupMenu(javax.swing.JPopupMenu) DefaultCellEditor(javax.swing.DefaultCellEditor) JCheckBox(javax.swing.JCheckBox) JLabel(javax.swing.JLabel) TableCellEditor(javax.swing.table.TableCellEditor) JComponent(javax.swing.JComponent) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) EmptyBorder(javax.swing.border.EmptyBorder) TableModel(javax.swing.table.TableModel) JMenu(javax.swing.JMenu)

Example 84 with JPopupMenu

use of javax.swing.JPopupMenu in project vcell by virtualcell.

the class LWButton method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JPopupMenu popup = new JPopupMenu();
    for (JMenuItem mi : LWTopFrame.activeMenuItems()) {
        popup.add(mi);
    }
    Insets insets = owner.getInsets();
    popup.show(owner, getX() + insets.left, getY() + insets.top);
}
Also used : Insets(java.awt.Insets) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 85 with JPopupMenu

use of javax.swing.JPopupMenu in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method getPopupMenu.

private JPopupMenu getPopupMenu() {
    if (popupMenu == null) {
        popupMenu = new JPopupMenu();
        deleteMenuItem = new JMenuItem("Delete");
        deleteMenuItem.addActionListener(eventHandler);
        popupMenu.add(deleteMenuItem);
        selectAllMenuItem = new JMenuItem("Select All");
        selectAllMenuItem.addActionListener(eventHandler);
        popupMenu.add(selectAllMenuItem);
        popupMenu.addSeparator();
        showPhysiologyLinksMenuItem1 = new JMenuItem("Show Linked Physiology Objects");
        showPhysiologyLinksMenuItem1.addActionListener(eventHandler);
        editPhysiologyLinksMenuItem1 = new JMenuItem("Edit Physiology Links...");
        editPhysiologyLinksMenuItem1.addActionListener(eventHandler);
        importIntoModelMenuItem1 = new JMenuItem("Import into Physiology...");
        importIntoModelMenuItem1.addActionListener(eventHandler);
        popupMenu.add(showPhysiologyLinksMenuItem1);
        popupMenu.add(editPhysiologyLinksMenuItem1);
        popupMenu.add(importIntoModelMenuItem1);
        popupMenu.addSeparator();
        collapseMenuItem1 = new JMenuItem("Collapse");
        collapseMenuItem1.addActionListener(eventHandler);
        expandMenuItem1 = new JMenuItem("Expand");
        expandMenuItem1.addActionListener(eventHandler);
        groupMenuItem1 = new JMenuItem("Group");
        groupMenuItem1.addActionListener(eventHandler);
        ungroupMenuItem1 = new JMenuItem("Ungroup");
        ungroupMenuItem1.addActionListener(eventHandler);
        popupMenu.add(collapseMenuItem1);
        popupMenu.add(expandMenuItem1);
        popupMenu.add(groupMenuItem1);
        popupMenu.add(ungroupMenuItem1);
    }
    refreshButtons();
    return popupMenu;
}
Also used : JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

JPopupMenu (javax.swing.JPopupMenu)203 JMenuItem (javax.swing.JMenuItem)105 ActionEvent (java.awt.event.ActionEvent)61 ActionListener (java.awt.event.ActionListener)46 JMenu (javax.swing.JMenu)28 Point (java.awt.Point)24 Component (java.awt.Component)20 JLabel (javax.swing.JLabel)20 JSeparator (javax.swing.JSeparator)19 JScrollPane (javax.swing.JScrollPane)18 MouseEvent (java.awt.event.MouseEvent)17 JButton (javax.swing.JButton)16 AbstractAction (javax.swing.AbstractAction)15 BorderLayout (java.awt.BorderLayout)13 JPanel (javax.swing.JPanel)13 JTable (javax.swing.JTable)13 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)12 MouseAdapter (java.awt.event.MouseAdapter)11 ArrayList (java.util.ArrayList)11 Icon (javax.swing.Icon)11