List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:org.nuclos.client.ui.collect.component.CollectableOptionGroup.java
@Override public JPopupMenu newJPopupMenu() { // Note that the default entries (as specified in AbstractCollectableComponent) are ignored. final JPopupMenu result = new JPopupMenu(); final JMenuItem miClear = CollectableOptionGroup.this.newClearEntry(); if (CollectableOptionGroup.this.isSearchComponent()) { miClear.setText(SpringLocaleDelegate.getInstance().getMessage("RootNode.2", "<Alle>")); }/* w ww .ja v a 2s.c o m*/ result.add(miClear); return result; }
From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java
/** * @param treenode/*from ww w . jav a2s .c o m*/ * @param tree the tree that is to contain the popup menu * @return the popupmenu, if any, for the given treenode * @precondition treenode != null */ private JPopupMenu getPopupMenu(SearchConditionTreeNode treenode, JTree tree) { if (treenode == null) { throw new NullArgumentException("treenode"); } if (this.clctfproviderfactory == null) { throw new IllegalStateException( "No CollectableFieldsProviderFactory was defined for the search editor."); } final List<TreeNodeAction> lstaction = treenode.getTreeNodeActions(tree, this.clcteRoot, this.clctfproviderfactory, this.additionalFields); final JPopupMenu result = lstaction.isEmpty() ? null : new JPopupMenu(); if (result != null) { final String sDefaultTreeNodeActionCommand = treenode.getDefaultTreeNodeActionCommand(); for (TreeNodeAction action : lstaction) { if (action == null) { Logger.getLogger(SearchEditorController.class).warn("exploreraction == null"); } else { final boolean bDefault = (sDefaultTreeNodeActionCommand != null) && sDefaultTreeNodeActionCommand.equals(action.getValue(Action.ACTION_COMMAND_KEY)); action.addToMenu(result, bDefault); } } } return result; }
From source file:org.nuclos.client.ui.collect.SubForm.java
/** * @Deprecated Never use this directly, instead use {@link #addToolbarMenuItems(List)}. */// w w w .j a va 2 s .c o m private MouseListener newToolbarContextMenuListener(final JComponent parent, final JTable table) { MouseListener res = new MouseAdapter() { @Override public void mouseClicked(MouseEvent mev) { if (SwingUtilities.isRightMouseButton(mev)) { List<JComponent> items = new ArrayList<JComponent>(); addToolbarMenuItems(items); if (items.isEmpty()) return; JPopupMenu popup = new JPopupMenu(); for (JComponent c : items) popup.add(c); popup.show(parent, mev.getX(), mev.getY()); } if (SwingUtilities.isLeftMouseButton(mev) && mev.getClickCount() == 2) { int row = table.rowAtPoint(mev.getPoint()); int column = table.columnAtPoint(mev.getPoint()); LOG.info(StringUtils.concat("Doubleclick on subform: column=", column, ",row=", row)); if (row == -1 || column == -1) { if (toolbarMenuItems.get(ToolbarFunction.NEW.name()).isEnabled()) { actionPerformed(ToolbarFunction.NEW.name()); } } } } }; return res; }
From source file:org.omegat.gui.issues.IssuesPanelController.java
void showPopupMenu(Component source, Point p, IIssue issue) { List<? extends JMenuItem> items = issue.getMenuComponents(); if (items.isEmpty()) { return;/*from w ww .j a v a 2 s . co m*/ } JPopupMenu menu = new JPopupMenu(); items.forEach(menu::add); menu.show(source, p.x, p.y); }
From source file:org.omegat.gui.properties.SegmentPropertiesArea.java
void showContextMenu(Point p) { JPopupMenu menu = new JPopupMenu(); populateLocalContextMenuOptions(menu, p); // populateGlobalContextMenuOptions(menu); try {/*from www.jav a 2s .c o m*/ menu.show(scrollPane, p.x, p.y); } catch (IllegalComponentStateException ignore) { ignore.printStackTrace(); } }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private void setupRunButtons(JPanel panel) { m_btnRunScript = new JButton(); Mnemonics.setLocalizedText(m_btnRunScript, OStrings.getString("SCW_RUN_SCRIPT")); m_btnRunScript.setAlignmentX(Component.LEFT_ALIGNMENT); m_btnRunScript.setHorizontalAlignment(SwingConstants.LEFT); m_btnRunScript.addActionListener(new ActionListener() { @Override/*from w w w . j ava 2 s . c om*/ public void actionPerformed(ActionEvent a) { runScript(); } }); panel.add(m_btnRunScript); m_btnCancelScript = new JButton(); Mnemonics.setLocalizedText(m_btnCancelScript, OStrings.getString("SCW_CANCEL_SCRIPT")); m_btnCancelScript.setToolTipText(OStrings.getString("SCW_CANCEL_BUTTON_TOOLTIP")); m_btnCancelScript.setAlignmentX(Component.LEFT_ALIGNMENT); m_btnCancelScript.setHorizontalAlignment(SwingConstants.LEFT); m_btnCancelScript.addActionListener(e -> cancelCurrentScript()); panel.add(m_btnCancelScript); for (int i = 0; i < NUMBERS_OF_QUICK_SCRIPTS; i++) { final int index = i; final int scriptKey = scriptKey(index); m_quickScriptButtons[i] = new JButton(String.valueOf(scriptKey)); // Run a script from the quick button bar m_quickScriptButtons[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { if (Preferences.existsPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey)) { runQuickScript(index); } else { logResult(StringUtil.format(OStrings.getString("SCW_NO_SCRIPT_BOUND"), scriptKey)); } } }); JPopupMenu quickScriptPopup = new JPopupMenu(); // Add a script to the quick script button bar final JMenuItem addQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_ADD_SCRIPT")); addQuickScriptMenuItem.addActionListener(new QuickScriptUpdater(index)); quickScriptPopup.add(addQuickScriptMenuItem); // Remove a script from the button bar final JMenuItem removeQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_REMOVE_SCRIPT")); removeQuickScriptMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String scriptName = Preferences .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, "(unknown)"); logResult(StringUtil.format(OStrings.getString("SCW_REMOVED_QUICK_SCRIPT"), scriptName, scriptKey)); Preferences.setPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, ""); m_quickScriptButtons[index].setToolTipText(OStrings.getString("SCW_NO_SCRIPT_SET")); m_quickScriptButtons[index].setText(" " + scriptKey + " "); unsetQuickScriptMenu(index); } }); quickScriptPopup.add(removeQuickScriptMenuItem); quickScriptPopup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // Disable add a script command if script selection empty addQuickScriptMenuItem.setEnabled(!m_scriptList.isSelectionEmpty()); // Disable remove a script command if the quick run button is not bounded String scriptName = Preferences .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, null); removeQuickScriptMenuItem.setEnabled(!StringUtil.isEmpty(scriptName)); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // do nothing } @Override public void popupMenuCanceled(PopupMenuEvent e) { // do nothing } }); m_quickScriptButtons[i].setComponentPopupMenu(quickScriptPopup); panel.add(m_quickScriptButtons[i]); } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
private void actionDroitOnglet(final int index, final MouseEvent e) { JPopupMenu pop = new JPopupMenu(); pop.add(new AbstractAction("Ajouter un axe") { public void actionPerformed(ActionEvent e) { if (ajoutAxeFrame == null) { ajoutAxeFrame = new AjouterAxeAnalytiqueFrame(a); }/*ww w .ja v a2s. c om*/ ajoutAxeFrame.pack(); ajoutAxeFrame.setVisible(true); } }); // si un onglet est selectionn if (index != -1) { pop.add(new AbstractAction("Supprimer l'axe") { public void actionPerformed(ActionEvent e) { supprimerAxe(index); } }); pop.add(new AbstractAction("Modifier le nom") { public void actionPerformed(ActionEvent aE) { actionModifierAxe(e, index); } }); } pop.show(e.getComponent(), e.getX(), e.getY()); System.out.println("Click droit onglet"); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;// www . java 2s . c om c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
/** * Cree un JTable contenant les ecritures du compte pass en argument * //from ww w . j a va2 s .co m * @param compte * @return null si aucune ecriture */ private JTable createJTableCompte(Compte compte) { // on cree la JTable final JTable tableTmp = creerJTable(compte); if (tableTmp != null) { // On met en place le renderer EcritureGrandLivreRenderer ecritureRenderer = new EcritureGrandLivreRenderer( ((TableSorter) tableTmp.getModel())); for (int j = 0; j < tableTmp.getColumnCount(); j++) { tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer); } // Gestion de la souris sur la JTable tableTmp.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent mE) { if (mE.getButton() == MouseEvent.BUTTON3) { JPopupMenu menuDroit = new JPopupMenu(); menuDroit.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { int row = tableTmp.rowAtPoint(mE.getPoint()); TableSorter s = (TableSorter) tableTmp.getModel(); int modelIndex = s.modelIndex(row); ConsultCompteModel consultCompteModel = ((ConsultCompteModel) s.getTableModel()); Ecriture ecriture = consultCompteModel.getEcritures().get(modelIndex); MouvementSQLElement.showSource(ecriture.getIdMvt()); } }); menuDroit.show(mE.getComponent(), mE.getX(), mE.getY()); } } }); } return tableTmp; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.PlanComptableGPanel.java
private void actionDroitTable(MouseEvent e, final JTable table) { JPopupMenu menuDroit = new JPopupMenu(); for (int i = 0; i < this.actionClickDroit.size(); i++) { menuDroit.add((AbstractAction) this.actionClickDroit.get(i)); }//from ww w .ja v a 2 s. c o m menuDroit.add(new AbstractAction("Tout slectionner") { public void actionPerformed(ActionEvent e) { table.selectAll(); } }); menuDroit.show(e.getComponent(), e.getX(), e.getY()); System.out.println("Click droit sur JTable"); }