List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.JobQueueManagement.java
public JPopupMenu getJobQueueMenu(final JTable table) { theTableSelected = table;//w w w. j a v a 2 s .c o m final JPopupMenu menu = new JPopupMenu(); boolean sortAscending = false; if (table.equals(theJobQueueRunningTable)) { sortAscending = personalSettings.isSortRunningAscending(); } else if (table.equals(theJobQueuePendingTable)) { sortAscending = personalSettings.isSortPendingAscending(); } else if (table.equals(theJobQueueFailedTable)) { sortAscending = personalSettings.isSortFailedAscending(); } else if (table.equals(theJobQueueDepositedTable)) { sortAscending = personalSettings.isSortDepositedAscending(); } else if (table.equals(theJobQueueInPermanentTable)) { sortAscending = personalSettings.isSortCompleteAscending(); } JMenuItem item; if (sortAscending) { item = new JMenuItem("Sort by date in descending order"); } else { item = new JMenuItem("Sort by date in ascending order"); } item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { resortTable(evt); } }); menu.add(item); if ((table.equals(theJobQueueRunningTable)) || (table.equals(theJobQueuePendingTable)) || (table.equals(theJobQueueFailedTable))) { StringBuffer text = new StringBuffer(); text.append("Cancel job"); if (table.getSelectedRowCount() > 1) { text.append('s'); } item = new JMenuItem(text.toString()); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { try { cancelJobs(evt); } catch (JobQueueException ex) { String message = "Error cancelling jobs"; LOG.error(message, ex); mainFrame.showError("An error occurred", message, ex); } } }); menu.add(item); if (table.equals(theJobQueueFailedTable)) { text = new StringBuffer(); text.append("Resubmit job"); if (table.getSelectedRowCount() > 1) { text.append('s'); } item = new JMenuItem(text.toString()); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { resubmitJob(evt); } }); menu.add(item); } } if (table.equals(theJobQueueInPermanentTable)) { item = new JMenuItem("Clear completed jobs"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { clearFinishedJobs(evt); } }); menu.add(item); } if (menu == null || menu.getComponentCount() == 0) { return null; } else { return menu; } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public JPopupMenu getProducerMenu() { final JPopupMenu menu = new JPopupMenu(); final JMenuItem item = new JMenuItem("Refresh producer list"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmRefreshProducerListActionPerformed(evt); }//from w w w. j ava2 s. c om }); menu.add(item); return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public JPopupMenu getFileSystemMenu(final DefaultMutableTreeNode node) { JPopupMenu menu = null;/* w ww . j a v a 2s . com*/ fsoRootFileTemp = null; if (node.getUserObject() instanceof FileSystemObject) { boolean allowBulkUpload = false; final FileSystemObject fso = (FileSystemObject) node.getUserObject(); menu = new JPopupMenu(); if ((fso != null) && (fso.getFile() != null) && (fso.getFile().exists())) { if (!entityRootSet) { stopEditingMetaData(); allowBulkUpload = applicationProperties.getUserData() .getUser(applicationProperties.getLoggedOnUser()).isAllowBulkLoad(); String addRootText; boolean canAddMultiRoot = false; setCustomizeMetaData(false); if (fso.getIsFile()) { addRootText = "Use file to describe IE root"; final DefaultMutableTreeNode nodeParent = (DefaultMutableTreeNode) node.getParent(); if (nodeParent.getUserObject() instanceof FileSystemObject) { fsoRootTemp = (FileSystemObject) nodeParent.getUserObject(); fsoRootFileTemp = fso; } else { fsoRootTemp = fso; } } else { addRootText = "Set as root of Intellectual Entity"; canAddMultiRoot = (userGroupData != null && userGroupData.isIncludeMultiEntityMenuItem()); fsoRootTemp = fso; } JMenuItem item = new JMenuItem(addRootText); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { manualDepositFrame.setWaitCursor(true); itmSetRootActionPerformed(evt); manualDepositFrame.setWaitCursor(false); } }); menu.add(item); if (canAddMultiRoot) { item = new JMenuItem("Set each file as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmSetMultipleRootActionPerformed(evt); } }); menu.add(item); // Added 5/09/2013 by Ben // New menu option for creating multiple complex IEs item = new JMenuItem("Set each folder as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmSetMultipleRootFolderActionPerformed(evt); } }); menu.add(item); } } if (fso.getIsFile()) { if (menu.getComponentCount() > 0) { menu.addSeparator(); } if (isWindows()) { JMenuItem item = new JMenuItem("Open File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmOpenFile(evt); } }); menu.add(item); item = new JMenuItem("Open File Location"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmOpenFileLocation(evt); } }); menu.add(item); } } else { if (menu.getComponentCount() > 0) { menu.addSeparator(); } JMenuItem item = new JMenuItem("Store this directory as a favourite"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmStoreAsFavourite(evt); } }); menu.add(item); item = new JMenuItem("Refresh directory file list"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmRefreshDirectory(evt); } }); menu.add(item); if (allowBulkUpload) { item = new JMenuItem("Bulk load this directory"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { bulkLoadDirectory(evt); } }); if (!metaDataOkay(false)) { item.setEnabled(false); item.setToolTipText("Meta data incomplete"); } menu.add(item); item = new JMenuItem("Bulk load each file as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { bulkLoadDirectoryAsIEs(evt); } }); if (!metaDataOkay(false)) { item.setEnabled(false); item.setToolTipText("Meta data incomplete"); } menu.add(item); } } } } if (menu == null || menu.getComponentCount() == 0) { return null; } else { return menu; } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileSystemObject fso) { final JPopupMenu menu = new JPopupMenu(); if (fso.getIsFile()) { JMenuItem item;/* w ww.j a v a2 s . c o m*/ ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { item = new JMenuItem("Delete File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } item = new JMenuItem("Rename File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); if (menu.getComponentCount() > 0) { menu.addSeparator(); } item = new JMenuItem("Open File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmOpenFile(evt); } }); menu.add(item); } else { JMenuItem item = new JMenuItem("Delete Directory (and children)"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); item = new JMenuItem("Rename Directory"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); } return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileGroupCollection entitiesClicked) { if (!entityRootSet) { return null; // Don't want to have a menu unless we are editing an // entity }/*from www . ja va2 s . c om*/ final JPopupMenu menu = new JPopupMenu(); JMenuItem item = new JMenuItem("Rename Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { menu.addSeparator(); JMenu addTypes = new JMenu("Add Representation Type"); boolean entityTypesAdded = false; for (int i = 0; i < RepresentationTypes.values().length; i++) { final RepresentationTypes typeToAdd = RepresentationTypes.values()[i]; boolean addType = true; if (!typeToAdd.allowMultiples()) { addType = (!entityTypeAdded(typeToAdd, entities)); } if (addType) { entityTypesAdded = true; JMenuItem subItem = new JMenuItem("Add " + typeToAdd.description()); subItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmAddEntity(evt, typeToAdd); } }); addTypes.add(subItem); } } if (entityTypesAdded) { menu.add(addTypes); } } else { item = new JMenuItem("Delete Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } if (thereAreMissingFiles()) { menu.addSeparator(); item = new JMenuItem("Show Missing Files"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showMissingFiles(); } }); menu.add(item); } return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileGroup entity) { final JPopupMenu menu = new JPopupMenu(); JMenuItem item;//from w w w.j av a2 s . co m ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { item = new JMenuItem("Delete Representation Type"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } return menu; }
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 w w w . j a v a 2s . c om 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 }/*w w w .ja va2 s . c o 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 }// www . ja va2 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.care.med.structure.PnlMed.java
private void treeMedMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_treeMedMousePressed if (product == null) return;//ww w. ja v a 2 s.c o m if (!OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, internalClassID)) return; if (SwingUtilities.isRightMouseButton(evt)) { // Dieses Popupmenu fr den Table SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); // JMenuItem itemdaf = new JMenuItem("Neue Darreichungsform"); // itemdaf.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(java.awt.event.ActionEvent evt) { // btnNeuDAF(evt); // } // }); // menu.add(itemdaf); if (treeMed.getRowForLocation(evt.getX(), evt.getY()) != -1 && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { JMenuItem itemedit = null; JMenuItem itemUPRedit = null; // JMenuItem itemnew = null; // JMenuItem itempack = null; TreePath curPath = treeMed.getPathForLocation(evt.getX(), evt.getY()); final DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) curPath.getLastPathComponent(); treeMed.setSelectionPath(curPath); // final ListElement le = (ListElement) dmtn.getUserObject(); // int nodetype = ((Integer) le.getObject()).intValue(); if (dmtn.getUserObject() instanceof TradeForm) { final TradeForm tradeForm = (TradeForm) dmtn.getUserObject(); itemedit = new JMenuItem(SYSTools.xx("misc.msg.edit")); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgTradeForm(tradeForm); createTree(); } }); itemUPRedit = new JMenuItem(SYSTools.xx("upreditor.tooltip")); itemUPRedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgUPREditor(tradeForm, new Closure() { @Override public void execute(Object o) { reload(); } }); } }); itemUPRedit.setEnabled(tradeForm.getDosageForm().isUPRn()); // itempack = new JMenuItem("Neue Verpackung"); // itempack.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(java.awt.event.ActionEvent evt) { // MedPackage mypack = new MedPackage(tradeForm); // new DlgPack(OPDE.getMainframe(), "Neu", mypack); //// OPDE.getEMF().getCache().evict(Darreichung.class, darreichung.getID()); // createTree(); // } // }); } else if (dmtn.getUserObject() instanceof MedPackage) { final MedPackage packung = (MedPackage) dmtn.getUserObject(); itemedit = new JMenuItem("Bearbeiten"); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgPack(SYSTools.xx("misc.msg.edit"), packung); createTree(); } }); } else if (dmtn.getUserObject() instanceof MedProducts) { itemedit = new JMenuItem("Bearbeiten"); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DlgProduct dlg = new DlgProduct(SYSTools.xx("misc.msg.edit"), (MedProducts) dmtn.getUserObject()); product = dlg.getProduct(); createTree(); } }); } if (itemedit != null) menu.add(itemedit); if (itemUPRedit != null) menu.add(itemUPRedit); } menu.show(evt.getComponent(), evt.getX(), evt.getY()); } }