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); } }
private static Command getCommandForMenu(JMenu menu, CommandManager manager) { final String name = menu.getName(); return name != null ? manager.getCommand(name) : null; }
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)); } }
/** * 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); }
/** * 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); }
private void setSelectToolSelectState(CommandManager commandManager) { Command selectTool = commandManager.getCommand("selectTool"); if (selectTool instanceof ToolCommand) { ToolCommand toolCommand = (ToolCommand) selectTool; selectionInteractor = toolCommand.getInteractor(); setActiveInteractor(selectionInteractor); toolCommand.setSelected(true); } }
@Override public final void actionPerformed(final CommandEvent event) { final SaveSessionAction action = (SaveSessionAction) VisatApp.getApp().getCommandManager().getCommand(SaveSessionAction.ID); action.saveSession(true); }
public RoiMaskSelector(BindingContext bindingContext) { this(bindingContext, VisatApp.getApp().getCommandManager().getCommand("org.esa.beam.visat.toolviews.mask.MaskManagerToolView.showCmd").createToolBarButton()); }
@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(); }
/** * Creates a tool button for the tool-command with the given command ID. * <p/> * <p>A command with the given ID must already been registered using any of the <code>createToolCommand</code> * methods of VisatApp, or directly using the <code>createToolCommand</code> method of VISAT's {@link * CommandManager}. Otherwise an {@link IllegalArgumentException} will be thrown. * <p/> * <p>The new button is which is automatically added to VISAT's tool button group to ensure that a only single tool * is selected. * * @param commandID the command ID * @return a tool button which is automatically added to VISAT's tool button group. * @see #getCommandManager */ public AbstractButton createToolButton(final String commandID) { final Command command = getCommandManager().getCommand(commandID); Guardian.assertNotNull("command", command); return command.createToolBarButton(); }
String commandID = component.getName(); if (commandID != null) { Command command = commandManager.getCommand(commandID); if (command != null) { commandMap.put(commandID, command);
protected void addCommandsToToolBar(final CommandBar toolBar, final String[] commandIDs) { for (final String commandID : commandIDs) { if (commandID == null) { toolBar.add(ToolButtonFactory.createToolBarSeparator()); } else { final Command command = getCommandManager().getCommand(commandID); if (command != null) { final AbstractButton toolBarButton = command.createToolBarButton(); toolBarButton.addMouseListener(getMouseOverActionHandler()); toolBar.add(toolBarButton); } else { getLogger().warning(String.format("Toolbar '%s': No command found for ID = '%s'", toolBar.getName(), commandID)); } } toolBar.add(Box.createHorizontalStrut(1)); } }
protected final JMenu createJMenu(String name, String text, char mnemonic, String... cmdIds) { JideMenu menu = new JideMenu(); menu.setName(name); /*I18N*/ menu.setText(text); menu.setMnemonic(mnemonic); menu.getPopupMenu().addContainerListener(getOrCreatePopupMenuListener()); //TODO make this configurable (mz,nf) 2012-04 for (String cmdId : cmdIds) { Command command = commandManager.getCommand(cmdId); if (command != null) { menu.getPopupMenu().add(command.createMenuItem()); } } return menu; }
topPanel.add(refreshButton, BorderLayout.WEST); AbstractButton showMaskManagerButton = VisatApp.getApp().getCommandManager().getCommand("org.esa.beam.visat.toolviews.mask.MaskManagerToolView.showCmd").createToolBarButton();
private JPanel createButtonPanel() { final Command newTSCommand = VisatApp.getApp().getCommandManager().getCommand(TimeSeriesAssistantAction.ID); final AbstractButton newButton = ToolButtonFactory.createButton(newTSCommand.getAction(), false);