@Override public void internalFrameActivated(InternalFrameEvent e) { for (int i=2; i < getMenuBar(e).getWindowMenu().getItemCount(); i++) { final JMenuItem item = getMenuBar(e).getWindowMenu().getItem(i); if (((WindowMenuItemAction)item.getAction()).getInternalFrame() == e.getInternalFrame()) { item.setSelected(true); break; } } getActionMap(e).get(ActionCommands.EXPORT.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.REFRESH.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.WATCH.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.ZOOM.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(true); // setSelected() does not fire ActionEvent -> both buttons have to be changed getMenuBar(e).getWatchMenuItem().setSelected(getSelectedGCDocument(e).isWatched()); getToolBar(e).getWatchToggleButton().setSelected(getSelectedGCDocument(e).isWatched()); updateMenuItemState(e); }
@Override public void internalFrameClosing(InternalFrameEvent e) { JInternalFrame internalFrame = e.getInternalFrame(); internalFrame.removeInternalFrameListener(this); internalFrame.getRootPane().remove(internalFrame); if (internalFrame.getRootPane().getComponentCount() == 0) { getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(false); } // remove menuitem from menu and from button group JMenu windowMenu = getMenuBar(e).getWindowMenu(); for (int i = 2; i < windowMenu.getItemCount(); i++) { JMenuItem item = windowMenu.getItem(i); if (((WindowMenuItemAction) item.getAction()).getInternalFrame() == internalFrame) { getMenuBar(e).removeFromWindowMenuGroup(item); break; } } // if this internalFrame is the last to be open, update the menu state // -> otherwise any settings done by the user are lost if (getGCViewerGui(e).getDesktopPane().getComponentCount() == 1) { updateMenuItemState(e); // set same menustate, when the last is closed as is set for deactivated internalFrameDeactivated(e); } // if some thread is still loading, it should stop now getSelectedGCDocument(e).getGCResources().stream().forEach(gcResource -> gcResource.setIsReadCancelled(true)); }
@Override public void mouseEntered (MouseEvent e) { JMenuItem item = (JMenuItem) e.getSource(); InterAction action = (InterAction) item.getAction(); action.publish(); } }
@Override public void mouseEntered (MouseEvent e) { JMenuItem item = (JMenuItem) e.getSource(); RelationAction relationAction = (RelationAction) item.getAction(); relationAction.publish(); }
public static Optional<JMenu> findJMenu(final JMenu jMenu, final String actionCommand) { for (int i = 0; i < jMenu.getItemCount(); i++) { final JMenuItem jMenuItem = jMenu.getItem(i); if (jMenuItem instanceof JMenu) { if (actionCommand.equals(jMenuItem.getAction().getValue(ACTION_COMMAND_KEY))) { return Optional.of((JMenu) jMenuItem); } final Optional<JMenu> candidate = findJMenu((JMenu) jMenuItem, actionCommand); if (candidate.isPresent()) { return candidate; } } } return Optional.empty(); }
private void registerKeyboardActions() { for (JComponent c : new MatrixActions(this, matrixGUIObject, null)) { if (c instanceof JMenuItem) { registerKeyboardAction(((JMenuItem) c).getAction()); } } }
public Action[] getActions() { ArrayList actions = new ArrayList<Action>(); for (Component c : initEditMenu(true).getMenuComponents()) { Action act = null; if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; act = mi.getAction(); } else if (c instanceof AbstractButton) { AbstractButton mi = (AbstractButton) c; act = mi.getAction(); } if (act != null) actions.add(act); } return (Action[]) actions.toArray(new Action[actions.size()]); }
void remove(final Action action) { for (int i = 0; i < getItemCount(); i++) { final JMenuItem item = getItem(i); if (item.getAction().equals(action)) { remove(item); return; } } } }
@Override public JMenuItem add(JMenuItem menuItem) { Action action = menuItem.getAction(); // Action action = menuItem instanceof JMenu? new ActionDropDownMenu((ActionGroup) menuAction): menuAction; AbstractButton b = add( action, menuItem ); b.setHorizontalTextPosition(SwingConstants.LEADING); b.putClientProperty("hideActionText", action.getValue(Action.SMALL_ICON) != null); return menuItem; }
@Override public JMenuItem add(JMenuItem menuItem) { Action action = menuItem.getAction(); // Action action = menuItem instanceof JMenu? new ActionDropDownMenu((ActionGroup) menuAction): menuAction; AbstractButton b = add( action, menuItem ); b.setHorizontalTextPosition(SwingConstants.LEADING); b.putClientProperty("hideActionText", action.getValue(Action.SMALL_ICON) != null); return menuItem; }
public void onTaskFactoryUnregistered(final TaskFactory taskFactory, final Map<?, ?> properties) { final JMenuItem menuItem = taskFactories.remove(taskFactory); if (menuItem != null) { vizMapperMainPanel.getMainMenu().remove(menuItem); vizMapperMainPanel.getEditSubMenu().remove(menuItem); if (menuItem.getAction() instanceof PopupMenuListener) { vizMapperMainPanel.getMainMenu().removePopupMenuListener((PopupMenuListener)menuItem.getAction()); vizMapperMainPanel.getContextMenu().removePopupMenuListener((PopupMenuListener)menuItem.getAction()); } } }
/** * Custom listener for removing unregistered VizMapper CyActions from the main menu. */ public synchronized void onCyActionUnregistered(final CyAction action, final Map<?, ?> properties) { final Component[] arr = vizMapperMainPanel.getEditSubMenu().getComponents(); final List<Component> cList = arr != null ? Arrays.asList(arr) : new ArrayList<Component>(); for (final Component c : cList) { if (c instanceof JMenuItem && ((JMenuItem)c).getAction().equals(action)) { vizMapperMainPanel.getEditSubMenu().remove(c); vizMapperMainPanel.getContextMenu().removePopupMenuListener(action); } } }
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; } } }
private void assertThatMenuItemHasCorrectAction(final JMenuItem menuItem) { final AccelerateableAction itemAction = (AccelerateableAction) menuItem.getAction(); assertThat(itemAction.getOriginalAction(), CoreMatchers.<Action> equalTo(action)); }
@Override public void mouseReleased (MouseEvent e) { JMenuItem item = (JMenuItem) e.getSource(); RelationAction ra = (RelationAction) item.getAction(); SIGraph sig = ra.getInter().getSig(); Relation relation = ra.getRelation(); String relStr = relation.getName(); if (OMR.gui.displayConfirmation("Remove " + relStr + " relation?")) { interController.unlink(sig, relation); } } }
public void adicionaMenu(JMenu submenu, boolean usaToggleButtons) { Action acoes[] = new Action[submenu.getItemCount()]; for (int i = 0; i < submenu.getItemCount(); i++) { acoes[i] = submenu.getItem(i).getAction(); } adicionaGrupoDeItems(submenu.getText(), submenu.getIcon(), acoes, usaToggleButtons); } }
public void intervalRemoved(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { JMenuItem menuItem = i < menu.getMenuComponentCount() ? (JMenuItem) menu.getMenuComponent(i) : null; if (menuItem != null) { MergePositionListAction action = (MergePositionListAction) menuItem.getAction(); action.dispose(); menuItem.setAction(null); } if (menu.getItemCount() > i) menu.remove(i); } menu.setEnabled(formatAndRoutesModel.getSize() > 1); }
public void internalFrameClosed(final InternalFrameEvent e) { if (desktopPane.getAllFrames().length == 0) arrangeAction.setEnabled(false); ((GCDocument)e.getInternalFrame()).getRefreshWatchDog().stop(); // remove menuitem from menu and from button group for (int i=2; i<windowMenu.getItemCount(); i++) { final JMenuItem item = windowMenu.getItem(i); if (((WindowMenuItemAction)item.getAction()).getInternalFrame() == e.getInternalFrame()) { windowMenu.remove(item); windowCheckBoxGroup.remove(item); break; } } }