Example usage for javax.swing JPopupMenu JPopupMenu

List of usage examples for javax.swing JPopupMenu JPopupMenu

Introduction

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

Prototype

public JPopupMenu() 

Source Link

Document

Constructs a JPopupMenu without an "invoker".

Usage

From source file:net.sf.jabref.gui.maintable.MainTableSelectionListener.java

/**
 * Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which
 * external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger
 * handler do its thing instead./*from   w  w  w  .  java  2  s.  co  m*/
 *
 * @param e The mouse event defining this popup trigger.
 * @param row The row where the event occurred.
 * @param column the MainTableColumn associated with this table cell.
 */
private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn column) {
    BibEntry entry = tableRows.get(row);
    JPopupMenu menu = new JPopupMenu();
    boolean showDefaultPopup = true;

    // See if this is a simple file link field, or if it is a file-list
    // field that can specify a list of links:
    if (!column.getBibtexFields().isEmpty()) {
        for (String field : column.getBibtexFields()) {
            if (FieldName.FILE.equals(field)) {
                // We use a FileListTableModel to parse the field content:
                FileListTableModel fileList = new FileListTableModel();
                entry.getFieldOptional(field).ifPresent(fileList::setContent);
                for (int i = 0; i < fileList.getRowCount(); i++) {
                    FileListEntry flEntry = fileList.getEntry(i);
                    if (column.isFileFilter()
                            && (!flEntry.type.get().getName().equalsIgnoreCase(column.getColumnName()))) {
                        continue;
                    }
                    String description = flEntry.description;
                    if ((description == null) || (description.trim().isEmpty())) {
                        description = flEntry.link;
                    }
                    menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.link,
                            flEntry.type.get().getIcon(), panel.getBibDatabaseContext(), flEntry.type));
                    showDefaultPopup = false;
                }
            } else {
                if (SpecialFieldsUtils.isSpecialField(column.getColumnName())) {
                    // full pop should be shown as left click already shows short popup
                    showDefaultPopup = true;
                } else {
                    if (entry.hasField(field)) {
                        String content = entry.getField(field);
                        Icon icon;
                        JLabel iconLabel = GUIGlobals.getTableIcon(field);
                        if (iconLabel == null) {
                            icon = IconTheme.JabRefIcon.FILE.getIcon();
                        } else {
                            icon = iconLabel.getIcon();
                        }
                        menu.add(new ExternalFileMenuItem(panel.frame(), entry, content, content, icon,
                                panel.getBibDatabaseContext(), field));
                        showDefaultPopup = false;
                    }
                }
            }
        }
        if (showDefaultPopup) {
            processPopupTrigger(e, row);
        } else {
            menu.show(table, e.getX(), e.getY());
        }
    }
}

From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java

/**
 * @return Popup-menu on properties./* ww  w  .  j av a 2  s .co m*/
 */
protected JPopupMenu getPropertyPopup() {
    if (myPropertyMenu == null) {
        myPropertyMenu = new JPopupMenu();
        myPropertyMenu.add(getRemoveMenuItem());
    }
    return myPropertyMenu;
}

From source file:net.sf.jabref.gui.MainTableSelectionListener.java

/**
 * Process popup trigger events occurring on an icon cell in the table. Show
 * a menu where the user can choose which external resource to open for the
 * entry. If no relevant external resources exist, let the normal popup trigger
 * handler do its thing instead.//  w ww. j a v  a 2 s .  c om
 * @param e The mouse event defining this popup trigger.
 * @param row The row where the event occurred.
 * @param iconType A string array containing the resource fields associated with
 *  this table cell.
 */
private void showIconRightClickMenu(MouseEvent e, int row, String[] iconType) {
    BibtexEntry entry = tableRows.get(row);
    JPopupMenu menu = new JPopupMenu();
    boolean showDefaultPopup = true;

    // See if this is a simple file link field, or if it is a file-list
    // field that can specify a list of links:
    if (iconType[0].equals(Globals.FILE_FIELD)) {
        // We use a FileListTableModel to parse the field content:
        Object o = entry.getField(iconType[0]);
        FileListTableModel fileList = new FileListTableModel();
        fileList.setContent((String) o);
        // If there are one or more links, open the first one:
        for (int i = 0; i < fileList.getRowCount(); i++) {
            FileListEntry flEntry = fileList.getEntry(i);

            //If file types are specified, ignore files of other types.
            if (iconType.length > 1) {
                boolean correctType = false;
                for (int j = 1; j < iconType.length; j++) {
                    if (flEntry.getType().toString().equals(iconType[j])) {
                        correctType = true;
                    }
                }
                if (!correctType) {
                    continue;
                }
            }

            String description = flEntry.getDescription();
            if ((description == null) || (description.trim().isEmpty())) {
                description = flEntry.getLink();
            }
            menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.getLink(),
                    flEntry.getType().getIcon(), panel.metaData(), flEntry.getType()));
            showDefaultPopup = false;
        }
    } else {
        SpecialField field = SpecialFieldsUtils.getSpecialFieldInstanceFromFieldName(iconType[0]);
        if (field != null) {
            //                for (SpecialFieldValue val: field.getValues()) {
            //                   menu.add(val.getMenuAction(panel.frame()));
            //                }
            // full pop should be shown as left click already shows short popup
            showDefaultPopup = true;
        } else {
            for (String anIconType : iconType) {
                Object o = entry.getField(anIconType);
                if (o != null) {
                    menu.add(new ExternalFileMenuItem(panel.frame(), entry, (String) o, (String) o,
                            GUIGlobals.getTableIcon(anIconType).getIcon(), panel.metaData(), anIconType));
                    showDefaultPopup = false;
                }
            }
        }
    }
    if (showDefaultPopup) {
        processPopupTrigger(e, row);
    } else {
        menu.show(table, e.getX(), e.getY());
    }
}

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_multicastDemand.java

@Override
public void doPopup(final MouseEvent e, final int row, final Object itemId) {
    JPopupMenu popup = new JPopupMenu();
    final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter();
    final List<MulticastDemand> demandRowsInTheTable = getVisibleElementsInTable();

    /* Add the popup menu option of the filters */
    final List<MulticastDemand> selectedDemands = (List<MulticastDemand>) (List<?>) getSelectedElements()
            .getFirst();//from  w w w.  j a va2 s . c  o m
    if (!selectedDemands.isEmpty()) {
        final JMenu submenuFilters = new JMenu("Filters");
        final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem(
                "This layer: Keep elements associated to this demand traffic");
        final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem(
                "All layers: Keep elements associated to this demand traffic");
        submenuFilters.add(filterKeepElementsAffectedThisLayer);
        if (callback.getDesign().getNumberOfLayers() > 1)
            submenuFilters.add(filterKeepElementsAffectedAllLayers);
        filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        popup.add(submenuFilters);
        popup.addSeparator();
    }

    if (callback.getVisualizationState().isNetPlanEditable()) {
        popup.add(getAddOption());
        for (JComponent item : getExtraAddOptions())
            popup.add(item);
    }

    if (!demandRowsInTheTable.isEmpty()) {
        if (callback.getVisualizationState().isNetPlanEditable()) {
            if (row != -1) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();

                if (networkElementType == NetworkElementType.LAYER
                        && callback.getDesign().getNumberOfLayers() == 1) {

                } else {
                    JMenuItem removeItem = new JMenuItem("Remove " + networkElementType);

                    removeItem.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            NetPlan netPlan = callback.getDesign();

                            try {
                                netPlan.getMulticastDemandFromId((long) itemId).remove();
                                callback.getVisualizationState()
                                        .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals();
                                callback.updateVisualizationAfterChanges(
                                        Collections.singleton(NetworkElementType.MULTICAST_DEMAND));
                                callback.getUndoRedoNavigationManager().addNetPlanChange();
                            } catch (Throwable ex) {
                                ErrorHandling.addErrorOrException(ex, getClass());
                                ErrorHandling.showErrorDialog("Unable to remove " + networkElementType);
                            }
                        }
                    });

                    popup.add(removeItem);
                }

                addPopupMenuAttributeOptions(e, row, itemId, popup);
            }
            if (networkElementType != NetworkElementType.LAYER) {
                JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in table");

                removeItems.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        NetPlan netPlan = callback.getDesign();
                        try {
                            if (rf == null)
                                netPlan.removeAllMulticastDemands();
                            else
                                for (MulticastDemand d : demandRowsInTheTable)
                                    d.remove();
                            callback.getVisualizationState()
                                    .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals();
                            callback.updateVisualizationAfterChanges(
                                    Collections.singleton(NetworkElementType.MULTICAST_DEMAND));
                            callback.getUndoRedoNavigationManager().addNetPlanChange();
                        } catch (Throwable ex) {
                            ex.printStackTrace();
                            ErrorHandling.showErrorDialog(ex.getMessage(),
                                    "Unable to remove all " + networkElementType + "s");
                        }
                    }
                });
                popup.add(removeItems);
            }

            List<JComponent> extraOptions = getExtraOptions(row, itemId);
            if (!extraOptions.isEmpty()) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();
                for (JComponent item : extraOptions)
                    popup.add(item);
            }
        }

        List<JComponent> forcedOptions = getForcedOptions();
        if (!forcedOptions.isEmpty()) {
            if (popup.getSubElements().length > 0)
                popup.addSeparator();
            for (JComponent item : forcedOptions)
                popup.add(item);
        }
    }

    popup.show(e.getComponent(), e.getX(), e.getY());
}

From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java

private void creaPopUpMappingTaskTreeSource() {
    this.popUpMenuSource = new JPopupMenu();
    this.popUpMenuSource.add(new ActionViewAllVirtualNode(sourceSchemaTree));
    this.sourceSchemaTree.addMouseListener(new PopUpListenerMappingTaskTreeSource());
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

/**
 * @param destObj// w ww  . j a  v  a2  s.  co m
 * @param textField
 */
public static void addTextFieldPopup(final GetSetValueIFace destObj, final JTextField textField,
        final boolean doAddDate) {
    if (textField != null) {
        JPopupMenu popupMenu = new JPopupMenu();

        if (doAddDate) {
            AbstractAction aa = new AbstractAction("Clear It") {

                @Override
                public void actionPerformed(ActionEvent e) {
                    DateWrapper scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting",
                            "scrdateformat");
                    if (scrDateFormat != null) {
                        destObj.setValue(scrDateFormat.format(Calendar.getInstance()), "");
                    } else {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        destObj.setValue(sdf.format(Calendar.getInstance()), "");
                    }
                }
            };

            UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CURR_DATE", "", "", true, aa);

            KeyStroke ctrlShiftT = KeyStroke.getKeyStroke(KeyEvent.VK_T,
                    InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
            textField.getInputMap().put(ctrlShiftT, "SetCurrentDate");
            textField.getActionMap().put("SetCurrentDate", aa);

        }

        String clearField = "ClearField";
        AbstractAction clearAction = new AbstractAction(clearField) {
            @Override
            public void actionPerformed(ActionEvent e) {
                destObj.setValue("", "");
            }
        };

        UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CLEAR", "", "", true, clearAction);

        textField.getInputMap().put(KeyStroke.getKeyStroke("F3"), clearField);
        textField.getActionMap().put(clearField, clearAction);

        textField.add(popupMenu);
        textField.setComponentPopupMenu(popupMenu);
    }
}

From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java

private void creaPopUpMappingTaskTreeSourceMakeConnection() {
    this.popUpMenuSourceMakeConnection = new JPopupMenu();
    this.popUpMenuSourceMakeConnection
            .add(new ActionMakeSource(sourceSchemaTree, scenario.getMappingTask(), true));
    this.popUpMenuSourceMakeConnection
            .add(new ActionMakeTarget(sourceSchemaTree, this, scenario.getMappingTask(), true));
    this.sourceSchemaTree.addMouseListener(new PopUpListenerMappingTaskTreeSource());
}

From source file:ipnat.skel.Strahler.java

/**
 * Gets the analysis parameters from the user.
 *
 * @return {@code true} if the dialog input is valid and dialog was not
 *         dismissed.// www  . ja  va2  s  . c  o m
 */
boolean getSettings() {

    final EnhancedGenericDialog gd = new EnhancedGenericDialog("Strahler Analysis :: " + IPNAT.getVersion());
    final Font headerFont = new Font("SansSerif", Font.BOLD, 12);
    gd.setSmartRecording(true);

    // Part 1. Main Options
    gd.setInsets(0, 0, 0);
    gd.addMessage("Tree Classification:", headerFont);
    gd.addCheckbox("Infer root end-points from rectangular ROI", protectRoot);
    gd.addCheckbox("Ignore single-point arbors (Isolated pixels)", erodeIsolatedPixels);

    // Part 2: Loop elimination
    gd.setInsets(25, 0, 0);
    gd.addMessage("Elimination of Skeleton Loops:", headerFont);
    gd.addChoice("Method:", AnalyzeSkeleton_.pruneCyclesModes, AnalyzeSkeleton_.pruneCyclesModes[pruneChoice]);

    // 8-bit grayscale is the only image type recognized by
    // AnalyzeSkeleton_,
    // so we'll provide the user with a pre-filtered list of valid choices
    final ArrayList<Integer> validIds = new ArrayList<Integer>();
    final ArrayList<String> validTitles = new ArrayList<String>();
    final int[] ids = WindowManager.getIDList();
    for (int i = 0; i < ids.length; ++i) {
        final ImagePlus imp = WindowManager.getImage(ids[i]);
        if (imp.getBitDepth() == 8) { // TODO: ignore composites?
            validIds.add(ids[i]);
            validTitles.add(imp.getTitle());
        }
    }
    gd.addChoice("8-bit grayscale image:", validTitles.toArray(new String[validTitles.size()]), title);

    // Part 3: Output
    gd.setInsets(25, 0, 0);
    gd.addMessage("Output Options:", headerFont);
    gd.addCheckbox("Display_iteration stack", outIS);
    gd.addCheckbox("Show detailed information", verbose);
    gd.addCheckbox("Tabular data only (no image output)", tabular);

    gd.addDialogListener(this);
    dialogItemChanged(gd, null); // update prompt

    // Add More>> dropdown menu
    final JPopupMenu popup = new JPopupMenu();
    JMenuItem mi;
    mi = new JMenuItem("Online documentation");
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            IJ.runPlugIn("ij.plugin.BrowserLauncher", URL);
        }
    });
    popup.add(mi);
    popup.addSeparator();
    mi = new JMenuItem("List hIPNAT commands...");
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            IJ.runPlugIn("ij.plugin.BrowserLauncher", IPNAT.DOC_URL + "#List_of_commands");
        }
    });
    popup.add(mi);
    mi = new JMenuItem("About hIPNAT plugins...");
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            IJ.runPlugIn("ipnat.Help", "");
        }
    });
    popup.add(mi);
    gd.assignPopupToHelpButton(popup);

    gd.showDialog();

    // Set grayscale image for intensity-based pruning of skel. loops.
    if (pruneChoice == AnalyzeSkeleton_.LOWEST_INTENSITY_VOXEL
            || pruneChoice == AnalyzeSkeleton_.LOWEST_INTENSITY_BRANCH) {
        grayscaleImp = WindowManager.getImage(validIds.get(grayscaleImpChoice));
    } else {
        grayscaleImp = null;
    }

    return gd.wasOKed();

}

From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java

/**
 *
 * @param advanceFocus// w ww  .jav  a2  s .c  o  m
 */
protected void showPopup(final int advanceFocus) {
    final Vector<Integer> idListClosure = (Vector<Integer>) idList.clone();
    if (!isEnabled()) {
        return;
    }

    if (hasNewText || currentText.length() == 0) {
        ActionListener al = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                itemSelected((JMenuItem) e.getSource(), advanceFocus, idListClosure);
            }
        };

        popupMenu = new JPopupMenu();
        if (popupMenuListener != null) {
            popupMenu.addPopupMenuListener(popupMenuListener);
        }

        popupMenu.addPopupMenuListener(new PopupMenuListener() {
            public void popupMenuCanceled(PopupMenuEvent e) {
                isPopupShowing = false;

                cachedPrevText = null;

                if (selectedId == null) {
                    setText(""); //$NON-NLS-1$
                }
            }

            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                isPopupShowing = false;

                cachedPrevText = prevEnteredText;

                if (selectedId == null) {
                    setText(""); //$NON-NLS-1$
                }
                //textField.requestFocus();
            }

            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                cachedPrevText = null;
                isPopupShowing = true;
            }
        });

        if (doAddAddItem) {
            JMenuItem mi = new JMenuItem(UIRegistry.getResourceString("TFWQ_ADD_LABEL")); //$NON-NLS-1$
            setControlSize(mi);

            popupMenu.add(mi);
            mi.addActionListener(al);
        }

        for (String str : list) {
            String label = str;
            if (uiFieldFormatter != null) {
                label = uiFieldFormatter.formatToUI(label).toString();
            }
            JMenuItem mi = new JMenuItem(label);
            setControlSize(mi);

            popupMenu.add(mi);
            mi.addActionListener(al);
        }
    }

    if (popupMenu != null) {
        if (list.size() > 0 || doAddAddItem) {
            UIHelper.addSpecialKeyListenerForPopup(popupMenu);

            final Point location = getLocation();
            final Dimension size = getSize();

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    popupMenu.setInvoker(TextFieldWithQuery.this);
                    popupMenu.show(TextFieldWithQuery.this, location.x, location.y + size.height);
                    Dimension popupSize = popupMenu.getPreferredSize();
                    popupMenu.setPopupSize(Math.max(size.width, popupSize.width), popupSize.height);
                    popupMenu.requestFocus();
                }
            });
        } else {
            popupMenu = null;
        }
    }

}

From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java

/**
 * CReates the popup menu for a cell. (THis really needs to be moved outside of this class).
 * @param pnt the point to pop it up// w w  w. jav  a 2 s . c o m
 * @return the popup menu
 */
protected JPopupMenu createMenuForSelection(final Point pnt) {
    //final int row = rowAtPoint(pnt);

    Class<?> cellClass = getModel().getColumnClass(convertColumnIndexToModel(columnAtPoint(pnt)));
    boolean isImage = cellClass == ImageIcon.class || cellClass == Image.class;

    JPopupMenu pMenu = new JPopupMenu();
    UsageTracker.incrUsageCount("WB.SpreadsheetContextMenu");
    if (getSelectedColumnCount() == 1) {
        final int[] rows = getSelectedRowModelIndexes();
        if (rows.length > 1) {
            //if (row == rows[0])
            //{
            if (!isImage) {
                JMenuItem mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("SpreadSheet.FillDown")));
                mi.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        int selectedUICol = getSelectedColumn();
                        int selectedModelCol = convertColumnIndexToModel(selectedUICol);
                        model.fill(selectedModelCol, rows[0], rows);
                        popupMenu.setVisible(false);
                    }
                });
            }
            //} else if (row == rows[rows.length-1])
            //{
            if (!isImage) {
                JMenuItem mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("Spreadsheet.FillUp")));
                mi.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        int selectedUICol = getSelectedColumn();
                        int selectedModelCol = convertColumnIndexToModel(selectedUICol);
                        model.fill(selectedModelCol, rows[rows.length - 1], rows);
                        popupMenu.setVisible(false);
                    }
                });
            }
            //}
        }
    }

    if (!isImage) {
        JMenuItem mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("SpreadSheet.ClearCells")));
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                int[] rows = getSelectedRowModelIndexes();
                int[] cols = getSelectedColumnModelIndexes();

                model.clearCells(rows, cols);
                popupMenu.setVisible(false);
            }
        });
    }

    if (deleteAction != null) {
        JMenuItem mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("SpreadSheet.DeleteRows")));
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                deleteAction.actionPerformed(ae);
                popupMenu.setVisible(false);
            }
        });
    }

    //add copy, paste, cut
    if (!isImage) //copy, paste currently only implemented for string data
    {
        boolean isSelection = getSelectedColumnCount() > 0 && getSelectedRowCount() > 0;
        if (pMenu.getComponentCount() > 0) {
            pMenu.add(new JPopupMenu.Separator());
        }
        JMenuItem mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("CutMenu")));
        mi.setEnabled(isSelection && !isImage); // copy, paste currently
        // only implemented for
        // string data
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                SwingUtilities.invokeLater(new Runnable() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        cutOrCopy(true);

                    }

                });
            }
        });
        mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("CopyMenu")));
        mi.setEnabled(isSelection && !isImage);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                SwingUtilities.invokeLater(new Runnable() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        cutOrCopy(false);

                    }

                });
            }
        });
        mi = pMenu.add(new JMenuItem(UIRegistry.getResourceString("PasteMenu")));
        mi.setEnabled(isSelection && !isImage && canPasteFromClipboard());
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                SwingUtilities.invokeLater(new Runnable() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        paste();

                    }

                });
            }
        });

    }

    pMenu.setInvoker(this);
    return pMenu;
}