/** * Returns an {@link java.util.Iterator} which traverses the JPopupMenu one MenuElement at a time. * * @param self a JPopupMenu * @return an Iterator for a JPopupMenu * @since 1.6.4 */ public static Iterator<MenuElement> iterator(JPopupMenu self) { return DefaultGroovyMethods.iterator(self.getSubElements()); }
private void createPopup(int xpos, int ypos, JPopupMenu popup) { if (popup.getSubElements().length > 0) { popup.show(TreeView.this, xpos, ypos); } }
private static void addSeparator(JPopupMenu menu) { MenuElement[] elements = menu.getSubElements(); if ((elements.length > 0) && !(elements[elements.length - 1] instanceof JPopupMenu.Separator)) { menu.addSeparator(); } }
private void createPopup(int xpos, int ypos, JPopupMenu popup) { if ((popup != null) && (popup.getSubElements().length > 0)) { popup.show(TreeView.this, xpos, ypos); } }
private void createPopup(int xpos, int ypos, JPopupMenu popup) { if ((popup != null) && (popup.getSubElements().length > 0)) { popup.show(TreeView.this, xpos, ypos); } }
@Override protected String[] executeInEDT() throws Throwable { MenuElement[] subElements = popupMenu.getSubElements(); String[] result = new String[subElements.length]; for (int i = 0; i < subElements.length; i++) { MenuElement subElement = checkNotNull(subElements[i]); result[i] = textOf(subElement); } return result; } });
/** * Returns an {@link java.util.Iterator} which traverses the JPopupMenu one MenuElement at a time. * * @param self a JPopupMenu * @return an Iterator for a JPopupMenu * @since 1.6.4 */ public static Iterator<MenuElement> iterator(JPopupMenu self) { return DefaultGroovyMethods.iterator(self.getSubElements()); }
/** * Returns an {@link java.util.Iterator} which traverses the JPopupMenu one MenuElement at a time. * * @param self a JPopupMenu * @return an Iterator for a JPopupMenu * @since 1.6.4 */ public static Iterator<MenuElement> iterator(JPopupMenu self) { return DefaultGroovyMethods.iterator(self.getSubElements()); }
@Override public boolean isEmpty() { if (menu != null) { return menu.getItemCount()==0; } else if (popup != null) { return popup.getSubElements().length==0; } return true; }
/** * Returns an {@link java.util.Iterator} which traverses the JPopupMenu one MenuElement at a time. * * @param self a JPopupMenu * @return an Iterator for a JPopupMenu * @since 1.6.4 */ public static Iterator<MenuElement> iterator(JPopupMenu self) { return DefaultGroovyMethods.iterator(self.getSubElements()); }
public void setSettingsEnabled(boolean b) { for (MenuElement c : optionsMenu.getSubElements()) { if (c instanceof JComponent) { ((JComponent) c).setEnabled(b); } } }
public void setSettingsEnabled(boolean b) { for (MenuElement c : optionsMenu.getSubElements()) { if (c instanceof JComponent) { ((JComponent) c).setEnabled(b); } } }
/** * Shows popup menu invoked on the table. */ private void showPopup(int xpos, int ypos, final JPopupMenu popup) { if ((popup != null) && (popup.getSubElements().length > 0)) { final PopupMenuListener p = new PopupMenuListener() { public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { popup.removePopupMenuListener(this); table.requestFocus(); } public void popupMenuCanceled(PopupMenuEvent e) { } }; popup.addPopupMenuListener(p); popup.show(this, xpos, ypos); } }
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { int start = editorPane.getSelectionStart(); int end = editorPane.getSelectionEnd(); if (annotationTableModel.spanHasAnnotation(start, end)) { editorPopup.getSubElements()[0].getComponent().setEnabled(true); editorPopup.getSubElements()[1].getComponent().setEnabled(false); } else { editorPopup.getSubElements()[0].getComponent().setEnabled(false); editorPopup.getSubElements()[1].getComponent().setEnabled(true); } } });
private synchronized void updateEnabled() { final ActionListener[] actionListeners = getActionListeners(); setEnabled((actionListeners != null && actionListeners.length > 0) || (popupMenu != null && popupMenu.getSubElements().length > 0)); }
/** Return the contents of the popup menu as a String array. */ public String[] getMenuLabels(Component comp) { JPopupMenu menu = (JPopupMenu)comp; MenuElement[] els = menu.getSubElements(); String[] result = new String[els.length]; for (int i=0;i < els.length;i++) { Component mi = els[i].getComponent(); if (mi instanceof JMenuItem) { result[i] = ((JMenuItem)mi).getText(); } else { result[i] = "-"; } } return result; } }
private int[] getIconPaddings(JMenuItem b) { int[] subFlags = new int[]{0, 0}; if (b != null && (b.getParent() instanceof JPopupMenu)) { JPopupMenu parentMenu = (JPopupMenu) b.getParent(); for (MenuElement item : parentMenu.getSubElements()) { if (item instanceof JCheckBoxMenuItem) { subFlags[0] = 10; } if ((item instanceof JMenuItem) && ((JMenuItem) item).getIcon() != null) { subFlags[1] = Math.max(subFlags[1], ((JMenuItem) item).getIcon().getIconWidth()); } } } return subFlags; }
/** * Forwards <code>Font</code> property * changes to the child gadgets */ public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("font")) { final Font fnt = this.getFont(); final MenuElement[] items = pop.getSubElements(); for (int i = 0; i < items.length; i++) { items[i].getComponent().setFont(fnt); } updatePreferredSize(); } else if (e.getPropertyName().equals("enabled")) { setForeground(isEnabled() ? null : colrLabD); } else if (e.getPropertyName().equals("insets")) { updatePreferredSize(); } }
private void clearChildren() { JPopupMenu popup = getComponentPopupMenu(); if (popup == null) return; MenuElement[] elements = popup.getSubElements(); for (MenuElement e : elements) { if (e instanceof Component) { Component c = (Component) e; popup.remove(c); } if (e instanceof ObserverMenu) { ObserverMenu om = (ObserverMenu) e; om.setMenu(null); } } }
public void popupMenuFilter() { Action cutAction = mediator.getApplication().getActionManager().getAction(CutAction.class); for (MenuElement element : popup.getSubElements()) { JMenuItem item = (JMenuItem) element; if (!item.getAction().equals(cutAction)) { item.setVisible(item.isEnabled()); } else { break; } } }