List of usage examples for javax.swing JMenuItem setEnabled
@BeanProperty(preferred = true, description = "The enabled state of the component.") public void setEnabled(boolean b)
From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingServiceListJPanel.java
public void adjustListMenuBar() { JMenuItem menuItem; Action act;/*from w w w.ja v a2 s . c om*/ String itemLabel; boolean enableState; boolean inEditState; boolean allowAdds; ICFInternetServiceObj selectedObj = getSwingFocusAsService(); CFJPanel.PanelMode mode = getPanelMode(); if (mode == CFJPanel.PanelMode.Edit) { inEditState = true; if (getSwingContainer() != null) { allowAdds = true; } else { allowAdds = false; } } else { inEditState = false; allowAdds = false; } if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(inEditState && enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(inEditState && enableState); } if (actionAddService != null) { actionAddService.setEnabled(allowAdds); } if (menuAdd != null) { menuAdd.setEnabled(allowAdds); } if (menuSelected != null) { menuSelected.setEnabled(enableState); int itemCount = menuSelected.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuSelected.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(inEditState && enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(inEditState && enableState); } } } } }
From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingServiceTypeListJPanel.java
public void adjustListMenuBar() { JMenuItem menuItem; Action act;/*from www . j a v a 2 s . c o m*/ String itemLabel; boolean enableState; boolean inEditState; boolean allowAdds; ICFInternetServiceTypeObj selectedObj = getSwingFocusAsServiceType(); CFJPanel.PanelMode mode = getPanelMode(); if (mode == CFJPanel.PanelMode.Edit) { inEditState = true; if (getSwingContainer() != null) { allowAdds = true; } else { allowAdds = false; } } else { inEditState = false; allowAdds = false; } if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(inEditState && enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(inEditState && enableState); } if (actionAddServiceType != null) { actionAddServiceType.setEnabled(allowAdds); } if (menuAdd != null) { menuAdd.setEnabled(allowAdds); } if (menuSelected != null) { menuSelected.setEnabled(enableState); int itemCount = menuSelected.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuSelected.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(inEditState && enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(inEditState && enableState); } } } } }
From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingTenantFinderJInternalFrame.java
public void adjustFinderMenuBar() { JMenuItem menuItem; Action act;/* w w w . j a va 2s.c o m*/ String itemLabel; ICFInternetTenantObj selectedObj = getSwingFocusAsTenant(); boolean enableState; if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(enableState); } if (actionAddTenant != null) { actionAddTenant.setEnabled(true); } if (menuFile != null) { int itemCount = menuFile.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuFile.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(enableState); } else if (act == actionAddTenant) { menuItem.setEnabled(true); } } } } }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecuritySwing.CFSecuritySwingClusterFinderJInternalFrame.java
public void adjustFinderMenuBar() { JMenuItem menuItem; Action act;/*from w w w .j a v a 2 s .c o m*/ String itemLabel; ICFSecurityClusterObj selectedObj = getSwingFocusAsCluster(); boolean enableState; if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(enableState); } if (actionAddCluster != null) { actionAddCluster.setEnabled(true); } if (menuFile != null) { int itemCount = menuFile.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuFile.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(enableState); } else if (act == actionAddCluster) { menuItem.setEnabled(true); } } } } }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecuritySwing.CFSecuritySwingClusterListJPanel.java
public void adjustListMenuBar() { JMenuItem menuItem; Action act;// w w w. java 2s . com String itemLabel; boolean enableState; boolean inEditState; boolean allowAdds; ICFSecurityClusterObj selectedObj = getSwingFocusAsCluster(); CFJPanel.PanelMode mode = getPanelMode(); if (mode == CFJPanel.PanelMode.Edit) { inEditState = true; if (getSwingContainer() != null) { allowAdds = true; } else { allowAdds = false; } } else { inEditState = false; allowAdds = false; } if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(inEditState && enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(inEditState && enableState); } if (actionAddCluster != null) { actionAddCluster.setEnabled(allowAdds); } if (menuAdd != null) { menuAdd.setEnabled(allowAdds); } if (menuSelected != null) { menuSelected.setEnabled(enableState); int itemCount = menuSelected.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuSelected.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(inEditState && enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(inEditState && enableState); } } } } }
From source file:net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.CopyWikiTableActionFactory.java
/** * Creates a {@link JMenuItem}, for the case, that no configuration is available. * This menu item is disabled./*ww w . j a v a 2 s .co m*/ * @return A disabled JMenueItem */ private JMenuItem createMenuForEmptyConfigurations() { JMenuItem item = new JMenuItem(s_stringMgr.getString("TablePopupMenu.copyaswikitable")); item.setEnabled(false); return item; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public JPopupMenu getFileSystemMenu(final DefaultMutableTreeNode node) { JPopupMenu menu = null;//w w w . ja va2s.c o m 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:op.care.med.structure.PnlMed.java
private void treeMedMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_treeMedMousePressed if (product == null) return;/*from w w w .jav a2 s. co 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()); } }
From source file:op.care.sysfiles.PnlFiles.java
private void tblFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblFilesMousePressed Point p = evt.getPoint();//from w w w . j a v a 2 s .c om ListSelectionModel lsm = tblFiles.getSelectionModel(); Point p2 = evt.getPoint(); SwingUtilities.convertPointToScreen(p2, tblFiles); final Point screenposition = p2; boolean singleRowSelected = lsm.getMaxSelectionIndex() == lsm.getMinSelectionIndex(); final int row = tblFiles.rowAtPoint(p); final int col = tblFiles.columnAtPoint(p); if (singleRowSelected) { lsm.setSelectionInterval(row, row); } final TMSYSFiles tm = (TMSYSFiles) tblFiles.getModel(); final SYSFiles sysfile = tm.getRow(tblFiles.convertRowIndexToModel(row)); if (SwingUtilities.isRightMouseButton(evt)) { SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); // SELECT JMenuItem itemPopupShow = new JMenuItem(SYSTools.xx("misc.commands.show"), SYSConst.icon22magnify1); itemPopupShow.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }); menu.add(itemPopupShow); if (col == TMSYSFiles.COL_DESCRIPTION && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JMenuItem itemPopupEdit = new JMenuItem(SYSTools.xx("misc.commands.edit"), SYSConst.icon22edit3); itemPopupEdit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { final JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); final JComponent editor = new JTextArea(sysfile.getBeschreibung(), 10, 40); ((JTextArea) editor).setLineWrap(true); ((JTextArea) editor).setWrapStyleWord(true); ((JTextArea) editor).setEditable(true); popup.getContentPane().add(new JScrollPane(editor)); final JButton saveButton = new JButton(SYSConst.icon22apply); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); popup.hidePopup(); SYSFiles mySysfile = em.merge(sysfile); mySysfile.setBeschreibung(((JTextArea) editor).getText().trim()); em.getTransaction().commit(); tm.setSYSFile(tblFiles.convertRowIndexToModel(row), mySysfile); } catch (Exception e) { em.getTransaction().rollback(); OPDE.fatal(e); } finally { em.close(); } } }); saveButton.setHorizontalAlignment(SwingConstants.RIGHT); JPanel pnl = new JPanel(new BorderLayout(10, 10)); JScrollPane pnlEditor = new JScrollPane(editor); pnl.add(pnlEditor, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(saveButton); pnl.setBorder(new EmptyBorder(10, 10, 10, 10)); pnl.add(buttonPanel, BorderLayout.SOUTH); popup.setOwner(tblFiles); popup.removeExcludedComponent(tblFiles); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(editor); popup.showPopup(screenposition.x, screenposition.y); } }); menu.add(itemPopupEdit); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete); itemPopupDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><b>" + sysfile.getFilename() + "</b><br/>" + SYSTools.xx("misc.questions.delete2"), new ImageIcon(getClass().getResource("/artwork/48x48/bw/trashcan_empty.png")), new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { SYSFilesTools.deleteFile(sysfile); reloadTable(); } } }); } }); menu.add(itemPopupDelete); itemPopupDelete.setEnabled(singleRowSelected); } menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY()); } else if (evt.getClickCount() == 2) { SYSFilesTools.handleFile(sysfile, Desktop.Action.OPEN); } }
From source file:org.alex73.skarynka.scan.ui.book.PagePopupMenu.java
public PagePopupMenu(PanelEditController controller, String fromPage, String toPage) { this.controller = controller; this.book = controller.getBook(); if (fromPage == null) { fromPage = toPage;/* ww w. jav a 2 s. c om*/ } if (fromPage.compareTo(toPage) <= 0) { startSelection = fromPage; endSelection = toPage; } else { startSelection = toPage; endSelection = fromPage; } JMenuItem remove; if (startSelection.equals(endSelection)) { remove = new JMenuItem(Messages.getString("PAGE_POPUP_REMOVE", Book2.simplifyPageNumber(endSelection))); } else { remove = new JMenuItem(Messages.getString("PAGE_POPUP_REMOVES", Book2.simplifyPageNumber(startSelection), Book2.simplifyPageNumber(endSelection))); } JMenuItem m1 = new JMenuItem(Messages.getString("PAGE_POPUP_CHANGE_M1")); JMenuItem p1 = new JMenuItem(Messages.getString("PAGE_POPUP_CHANGE_P1")); JMenuItem ma = new JMenuItem(Messages.getString("PAGE_POPUP_CHANGE_MA")); JMenuItem pa = new JMenuItem(Messages.getString("PAGE_POPUP_CHANGE_PA")); JMenuItem rename = new JMenuItem(Messages.getString("PAGE_POPUP_RENAME")); rename.setEnabled(startSelection.equals(endSelection)); rename.addActionListener(renameAction); remove.addActionListener(removeAction); new MoveActionListener(false, -1, m1); new MoveActionListener(false, 1, p1); new MoveActionListener(true, -1, ma); new MoveActionListener(true, 1, pa); add(rename); add(m1); add(p1); add(ma); add(pa); add(remove); }