static Command createCommand(String name, Anchor anchor, String relativeId) { ExecCommand command = new ExecCommand(name); command.setText(name); if (anchor != null) { if (anchor == FIRST) { command.setPlaceFirst(true); } if (anchor == LAST) { command.setPlaceLast(true); } if (anchor == BEFORE) { command.setPlaceBefore(relativeId); } if (anchor == AFTER) { command.setPlaceAfter(relativeId); } } return command; }
public ExecCommand(String commandID, CommandListener listener) { super(commandID); addCommandListener(listener); }
@Override public void componentOpened() { final CommandManager commandManager = visatApp.getCommandManager(); final String layerCommandId = placemarkDescriptor.getShowLayerCommandId(); ExecCommand command = (ExecCommand) commandManager.getCommand(layerCommandId); command.setSelected(true); command.execute(); }
private static ExecCommand createCommand(String commandId) { ExecCommand command = new ExecCommand(); command.setCommandID(commandId); return command; }
command.setParent("showToolViews"); command.setSmallIcon(getSmallIcon()); command.setLargeIcon(getLargeIcon()); command.setShortDescription(getDescription()); command.setLongDescription(getDescription()); command.setText(getTabTitle()); KeyStroke accelerator = getAccelerator(); if (accelerator != null) { command.setAccelerator(accelerator); command.setMnemonic(mnemonic);
/** * Called by VISAT after the plug-in instance has been registered in VISAT's plug-in manager. * * @param visatApp a reference to the VISAT application instance. */ public void start(VisatApp visatApp) { if (!isVersionCheckQuestionSuppressed() || isVersionCheckEnabled()) { final Timer timer = new Timer(DELAY_MILLIS, new ActionListener() { public void actionPerformed(ActionEvent e) { runAuto(); } }); timer.setRepeats(false); timer.start(); } CommandAdapter versionCheckerAction = new CommandAdapter() { @Override public void actionPerformed(CommandEvent event) { runManual(); } }; CommandManager commandManager = visatApp.getCommandManager(); ExecCommand versionCheckerCommand = commandManager.createExecCommand("checkForUpdate", versionCheckerAction); versionCheckerCommand.setText("Check for New Release..."); versionCheckerCommand.setShortDescription("Checks for a new release"); versionCheckerCommand.setParent("help"); versionCheckerCommand.setPlaceAfter("showUpdateDialog"); versionCheckerCommand.setPlaceBefore("about"); }
/** * Executes this command. */ public void execute() { execute(null); }
@Test public void testPlaceAtContextTop() { DefaultCommandManager manager = new DefaultCommandManager(); ExecCommand standardCommand1 = createCommand("com1", manager); ExecCommand standardCommand2 = createCommand("com2", manager); ExecCommand topCommand = createCommand("com3", manager); standardCommand1.setProperty(Command.ACTION_KEY_CONTEXT, "band"); standardCommand2.setProperty(Command.ACTION_KEY_CONTEXT, "band"); topCommand.setProperty(Command.ACTION_KEY_CONTEXT, "band"); topCommand.setPlaceAtContextTop(true); DefaultCommandUIFactory uiFactory = new DefaultCommandUIFactory(); uiFactory.setCommandManager(manager); JPopupMenu popup = new JPopupMenu(); uiFactory.addContextDependentMenuItems("band", popup); assertEquals(3, popup.getComponentCount()); String[] expectedOrder = new String[]{"com3", "com1", "com2",}; assertEquals(expectedOrder[0], popup.getComponent(0).getName()); assertEquals(expectedOrder[1], popup.getComponent(1).getName()); assertEquals(expectedOrder[2], popup.getComponent(2).getName()); }
public void setToggle(boolean toggle) { setProperty(TOGGLE_ACTION_KEY, toggle); }
/** * Creates a new executable command for the given unique command ID and the given command listener. * Finally the created command is added to internal list of registered commands. * * @param commandID a unique command ID * @param listener the command listener which executes the command and updates its state * * @return a new executable command * * @see #createToolCommand * @see #createCommandGroup * @see #addCommand(Command) */ @Override public ExecCommand createExecCommand(String commandID, CommandListener listener) { Guardian.assertNotNullOrEmpty("commandID", commandID); ExecCommand command = new ExecCommand(commandID, listener); addCommand(command); return command; }
command = commandManager.getExecCommand("showToolBar"); if (command != null) { command.setSelected(bV); command = commandManager.getExecCommand("showStatusBar"); if (command != null) { command.setSelected(bV);
private static ExecCommand createCommand(String commandId, DefaultCommandManager manager) { ExecCommand command = new ExecCommand(); command.setCommandID(commandId); manager.addCommand(command); return command; } }
@Override public void metadataElementSelected(final MetadataElement metadataElement, final int clickCount) { setSelectedProductNode(metadataElement); final JInternalFrame frame = visatApp.findInternalFrame(metadataElement); if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } return; } if (clickCount == 2) { final ExecCommand command = visatApp.getCommandManager().getExecCommand(ShowMetadataViewAction.ID); command.execute(metadataElement); } }
private void addCommand(String commandId) { ExecCommand command1 = new ExecCommand(); command1.setCommandID(commandId); _manager.addCommand(command1); }
@Override public void vectorDataSelected(final VectorDataNode vectorDataNode, int clickCount) { setSelectedProductNode(vectorDataNode); setSelectedVectorDataNode(vectorDataNode); final JInternalFrame frame = visatApp.findInternalFrame(vectorDataNode); if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } return; } if (clickCount == 2) { final ExecCommand command = visatApp.getCommandManager().getExecCommand(ShowPlacemarkViewAction.ID); command.execute(vectorDataNode); } }
public void testCreateCommandWithConstraintsAndListener() { final CommandListener listener = new CommandListener() { public void actionPerformed(CommandEvent event) { } public void updateState(CommandEvent event) { } }; ExecCommand command = createCommand("test"); command.addCommandListener(listener); _manager.addCommand(command); final Command commandAt = _manager.getCommandAt(0); final CommandListener[] listeners = (CommandListener[]) commandAt.getEventListenerList().getListeners( CommandListener.class); assertEquals(1, listeners.length); assertSame(listener, listeners[0]); }
private void rasterDataNodeSelected(final RasterDataNode raster, final int clickCount) { setSelectedProductNode(raster); final JInternalFrame[] internalFrames = visatApp.findInternalFrames(raster); JInternalFrame frame = null; for (final JInternalFrame internalFrame : internalFrames) { final int numRasters = ((ProductSceneView) internalFrame.getContentPane()).getNumRasters(); if (numRasters == 1) { frame = internalFrame; break; } } if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } } else if (clickCount == 2) { final ExecCommand command = visatApp.getCommandManager().getExecCommand("showImageView"); command.execute(clickCount); } }