private <T> T getAction(String actionId) { T action = (T) app.getCommandManager().getCommand(actionId); if (action == null) { throw new IllegalStateException("Action not found: actionId=" + actionId); } return action; }
private static void addCommand(CommandManager commandManager, Command command, Map<String, Command> commandMap) { String parentId = command.getParent(); if (parentId != null && commandManager.getCommandGroup(parentId) == null) { Command parentCommand = commandMap.get(parentId); if (parentCommand != null) { // solve dependencies to other command groups addCommand(commandManager, parentCommand, commandMap); } } Command existingCommand = commandManager.getCommand(command.getCommandID()); if (existingCommand == null) { commandManager.addCommand(command); } }
protected void insertCommandMenuItems() { for (int i = 0; i < commandManager.getNumCommands(); i++) { insertCommandMenuItem(commandManager.getCommandAt(i)); } }
@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); } }
/** * 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"); }
private String findRootParent(Command command) { String parent = command.getParent(); if (parent != null) { CommandGroup commandGroup = commandManager.getCommandGroup(parent); if (commandGroup != null) { return findRootParent(commandGroup); } } return parent; }
/** * Updates the appication's (UI-) state. The default implementation calls <code>updateState</code> on each * registered command. */ public final void updateState() { Debug.trace("BasicApp: updating application state..."); commandManager.updateState(); }
action.setToggle(true); action.setSelected(true); getCommandManager().addCommand(action); JMenu toolBarsMenu = findMenu("toolBars"); toolBarsMenu.add(action.createMenuItem());
/** * Called after the look & feel has changed. The method simply calls <code>SwingUtilities.updateComponentTreeUI(getMainFrame())</code> * in order to reflect changes of the look-and-feel. * <p/> * <p>You might want to override this method in order to call <code>SwingUtilities.updateComponentTreeUI()</code> on * other top-level containers beside the main frame. */ @Override protected void updateComponentTreeUI() { super.updateComponentTreeUI(); if (preferencesDialog != null) { SwingUtilities.updateComponentTreeUI(preferencesDialog.getJDialog()); } plugInManager.updatePluginsComponentTreeUI(); getCommandManager().updateComponentTreeUI(); }
@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 Command createShowViewCommand(final ApplicationPage applicationPage) { final String commandId = getId() + ".showCmd"; final ExecCommand command = applicationPage.getCommandManager().createExecCommand(commandId, new CommandAdapter() { @Override public void updateState(CommandEvent event) {
private static Command getCommandForMenu(JMenu menu, CommandManager manager) { final String name = menu.getName(); return name != null ? manager.getCommand(name) : null; }
protected final void configureCommandsByResourceBundle() { ResourceBundle resourceBundle = getResourceBundle(); if (resourceBundle == null) { return; } for (int i = 0; i < commandManager.getNumCommands(); i++) { commandManager.getCommandAt(i).configure(resourceBundle); } }
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); } }
private void openSession(VisatApp app, String sessionFile) { if (sessionFile != null && !(sessionFile.trim().isEmpty())) { final OpenSessionAction action = (OpenSessionAction) app.getCommandManager().getCommand(OpenSessionAction.ID); action.openSession(app, new File(sessionFile)); } }
protected final void insertCommandToolBarButtons(JToolBar toolbar) { String[] toolBarGroups = getToolBarGroups(); if (toolBarGroups == null) { return; } boolean toolAdded = false; for (String toolBarGroup : toolBarGroups) { if (toolAdded) { toolbar.addSeparator(); toolAdded = false; } for (int j = 0; j < commandManager.getNumCommands(); j++) { Command command = commandManager.getCommandAt(j); // @todo 2 nf/nf - ask whether location=toolbar or not if (command instanceof ExecCommand && command.getLargeIcon() != null) { String rootParent = findRootParent(command); if ((rootParent == null && toolBarGroup == null) || (rootParent != null && rootParent.equalsIgnoreCase(toolBarGroup))) { AbstractButton button = command.createToolBarButton(); if (button != null) { toolbar.add(button); } toolAdded = true; } } } } }
command = commandManager.getExecCommand("showToolBar"); if (command != null) { command.setSelected(bV); command = commandManager.getExecCommand("showStatusBar"); if (command != null) { command.setSelected(bV);
/** * Creates a new product scene view and opens an internal frame for it. */ public void openProductSceneView(final RasterDataNode raster) { final ShowImageViewAction command = (ShowImageViewAction) getCommandManager().getCommand( ShowImageViewAction.ID); command.openProductSceneView(raster); }
final int numCommands = _commandManager.getNumCommands(); for (int i = 0; i < numCommands; i++) { final Command command = _commandManager.getCommandAt(i); final String commandID = command.getCommandID(); if (command.containsContext(context) &&
/** * Asks the user to select or define a RGB profile from which the product scene view will be * created and opend as internal frame. */ public void openProductSceneViewRGB(final Product product, final String helpId) { final ShowImageViewRGBAction command = (ShowImageViewRGBAction) getCommandManager().getCommand( ShowImageViewRGBAction.ID); command.openProductSceneViewRGB(product, helpId); }