List of usage examples for org.eclipse.jface.action IAction getId
String getId();
null if it has none. From source file:article.imageviewer.actions.PushActionDelegate.java
License:Open Source License
public void run(IAction action) { String id = action.getId(); SWTImageCanvas imageCanvas = view.imageCanvas; if (id.equals("toolbar.open")) { imageCanvas.onFileOpen();//from w ww. ja v a 2 s .c o m return; } if (imageCanvas.getSourceImage() == null) return; if (id.equals("toolbar.zoomin")) { imageCanvas.zoomIn(); return; } else if (id.equals("toolbar.zoomout")) { imageCanvas.zoomOut(); return; } else if (id.equals("toolbar.fit")) { imageCanvas.fitCanvas(); return; } else if (id.equals("toolbar.rotate")) { /* rotate image anti-clockwise */ ImageData src = imageCanvas.getImageData(); if (src == null) return; PaletteData srcPal = src.palette; PaletteData destPal; ImageData dest; /* construct a new ImageData */ if (srcPal.isDirect) { destPal = new PaletteData(srcPal.redMask, srcPal.greenMask, srcPal.blueMask); } else { destPal = new PaletteData(srcPal.getRGBs()); } dest = new ImageData(src.height, src.width, src.depth, destPal); /* rotate by rearranging the pixels */ for (int i = 0; i < src.width; i++) { for (int j = 0; j < src.height; j++) { int pixel = src.getPixel(i, j); dest.setPixel(j, src.width - 1 - i, pixel); } } imageCanvas.setImageData(dest); return; } else if (id.equals("toolbar.original")) { imageCanvas.showOriginal(); return; } }
From source file:ca.mcgill.cs.swevo.ppa.ui.actions.PPAOnSnippetAction.java
License:Open Source License
public void run(IAction action) { if (file == null) { return;//from w ww .j av a 2 s . c o m } try { MessageConsole mConsole = new MessageConsole("PPA Console", null); final PrintStream printer = new PrintStream(mConsole.newMessageStream()); IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); manager.addConsoles(new IConsole[] { mConsole }); manager.showConsoleView(mConsole); final boolean isTypeBody = action.getId().equals("ca.mcgill.cs.swevo.ppa.ui.performPPAOnTypeSnippet"); ProgressMonitorDialog dialog = new ProgressMonitorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.beginTask("Visiting AST", 100); CompilationUnit node = (CompilationUnit) PPAUtil.getSnippet(file.getLocation().toFile(), new PPAOptions(), isTypeBody); monitor.worked(50); node.accept(new NameBindingVisitor(printer, monitor)); printer.close(); PPAUtil.cleanUpSnippet(); } catch (Exception e) { e.printStackTrace(); } finally { monitor.done(); } } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:ca.mcgill.sable.graph.GraphEditor.java
License:Open Source License
public void createActions() { super.createActions(); ActionRegistry registry = getActionRegistry(); IAction action = new SimpleSelectAction(this); registry.registerAction(action);//from ww w . j a v a2 s. c o m getSelectionActions().add(action.getId()); }
From source file:ch.elexis.core.ui.laboratory.views.LaborOrderPulldownMenuCreator.java
License:Open Source License
@SuppressWarnings("unchecked") private void init(final Shell shell) { List<IAction> orderActions = Extensions.getClasses( Extensions.getExtensions(ExtensionPointConstantsUi.LABORORDER), "ToolbarAction", //$NON-NLS-1$ //$NON-NLS-2$ false);// ww w. j a va2 s .c o m for (IAction action : orderActions) { if (action.getId() != null && action.getImageDescriptor() != null && action.getText() != null) { this.actions.add(action); } else { log.log(MessageFormat.format("Missing #id, #imagedescriptor or #text for LaborOrder action: {0}", action.getText()), Log.WARNINGS); } } if (this.actions != null && this.actions.size() > 0) { String selectedId = CoreHub.localCfg.get(LAB_ORDER_SELECTED_ACTION_ID, null); if (selectedId != null) { for (IAction action : this.actions) { if (selectedId.equals(action.getId())) { this.selectedAction = action; } } } if (this.selectedAction == null) { this.selectedAction = this.actions.get(0); } } }
From source file:ch.elexis.views.LaborOrderPulldownMenuCreator.java
License:Open Source License
@SuppressWarnings("unchecked") private void init(final Shell shell) { List<IAction> orderActions = Extensions.getClasses(Extensions.getExtensions("ch.elexis.LaborOrder"), //$NON-NLS-1$ "ToolbarAction", //$NON-NLS-1$ false);//from www .j a va 2 s . c o m for (IAction action : orderActions) { if (action.getId() != null && action.getImageDescriptor() != null && action.getText() != null) { this.actions.add(action); } else { log.log(MessageFormat.format("Missing #id, #imagedescriptor or #text for LaborOrder action: {0}", action.getText()), Log.WARNINGS); } } if (this.actions != null && this.actions.size() > 0) { String selectedId = Hub.localCfg.get(LAB_ORDER_SELECTED_ACTION_ID, null); if (selectedId != null) { for (IAction action : this.actions) { if (selectedId.equals(action.getId())) { this.selectedAction = action; } } } if (this.selectedAction == null) { this.selectedAction = this.actions.get(0); } } }
From source file:cn.cstv.wspscm.editor.PSCMonitorDiagramEditor.java
License:Open Source License
@Override @SuppressWarnings("unchecked") protected void createActions() { super.createActions(); ActionRegistry registry = getActionRegistry(); IAction action = new DirectEditAction((IWorkbenchPart) this); registry.registerAction(action);/*from w w w . j a va 2s.c o m*/ getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE); registry.registerAction(action); getSelectionActions().add(action.getId()); action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM); registry.registerAction(action); getSelectionActions().add(action.getId()); }
From source file:cn.edu.pku.ogeditor.ShapesEditor.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w.j a va2 s .com*/ protected void createActions() { super.createActions(); IAction action = new RelocateAction(this); action.setId(ActionConstant.RELOCATE_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new ConceptFilterAction(this); action.setId(ActionConstant.CONCEPTFILTER_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new RelationFilterAction(this); action.setId(ActionConstant.RELATIONFILTER_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new OWLGenerationAction(this); action.setId(ActionConstant.OWLGENERATION_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new SystemGenerationAction(this); action.setId(ActionConstant.SYSTEMGENERATION_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new DeployAction(this); action.setId(ActionConstant.DEPLOY_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new StopDeployAction(this); action.setId(ActionConstant.STOP_DEPLOY_ID); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); }
From source file:com.aerospike.aql.plugin.actions.GenerateSource.java
License:Apache License
public void run(IAction action) { if (selection != null && selection instanceof TreeSelection) { TreeSelection ts = (TreeSelection) selection; Object element = ts.getFirstElement(); if (element instanceof IFile && ((IFile) element).getFileExtension().equalsIgnoreCase("aql")) { final IFile sqlFile = (IFile) element; if (sqlFile == null) return; try { final List<String> errorList = new ArrayList<String>(); final String actionID = action.getId(); final AQLResult results = new AQLResult(); // find the Aerospike console and display it IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW); view.display(results.getConsole()); // set generation language String extension; final com.aerospike.aql.AQL.Language language; if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.java.popup")) { language = com.aerospike.aql.AQL.Language.JAVA; extension = ".java"; } else if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.c.popup")) { language = com.aerospike.aql.AQL.Language.C; extension = ".c"; } else if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.csharp.popup")) { language = com.aerospike.aql.AQL.Language.CSHARP; extension = ".csharp"; } else { return; }//from w ww .j av a 2 s. c o m IProject project = sqlFile.getProject(); IPath outputPath; String sqlFileName = sqlFile.getName(); String outputFileName = sqlFileName.substring(0, sqlFileName.lastIndexOf('.')) + extension; final AsCluster cluster = (AsCluster) project .getSessionProperty(CoreActivator.CLUSTER_PROPERTY); String outputDirectoryString = project .getPersistentProperty(CoreActivator.AQL_GENERATION_DIRECTORY); if (outputDirectoryString == null || outputDirectoryString.isEmpty()) { outputPath = project.getLocation().append(outputFileName); } else { IPath dirPath = project.getLocation().append(outputDirectoryString); if (!dirPath.toFile().exists()) dirPath.toFile().mkdirs(); outputPath = dirPath.append(outputFileName); } final File outputFile = outputPath.toFile(); IPath location = sqlFile.getLocation(); final File file = location.toFile(); final IFile outputIFile = project.getWorkspace().getRoot().getFileForLocation(outputPath); Job job = new Job("Generate source code from AQL: " + sqlFile.getName()) { @Override protected IStatus run(IProgressMonitor monitor) { AQL aql = new AQL(); try { String seedNode = ""; int port = 3000; if (cluster != null) { seedNode = cluster.getSeedHost(); port = cluster.getPort(); } else { IPreferenceStore store = CoreActivator.getDefault().getPreferenceStore(); seedNode = store.getString(PreferenceConstants.SEED_NODE); port = store.getInt(PreferenceConstants.PORT); } aql.compileAndGenerate(file, outputFile, language, seedNode, port); results.report("Completed generation for " + sqlFile.getName()); outputIFile.getParent().refreshLocal(IResource.DEPTH_ONE, null); return Status.OK_STATUS; } catch (Exception e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); return Status.CANCEL_STATUS; } } }; job.setUser(true); job.schedule(); } catch (PartInitException e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); } catch (CoreException e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); } } } }
From source file:com.aptana.ide.core.ui.actions.AbstractWorkbenchWindowPulldownDelegate.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */// w w w . ja va 2s . co m public void run(IAction action) { String id = action.getId(); ToolItem widget = null; WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow(); CoolBarManager manager = window.getCoolBarManager(); CoolBar parent = manager.getControl(); // this returns the list of actionSets groups IContributionItem[] items = manager.getItems(); for (IContributionItem item : items) { if (item instanceof IToolBarContributionItem) { IToolBarContributionItem toolbarItem = (IToolBarContributionItem) item; // this returns the list of actual items for the actions IContributionItem[] children = toolbarItem.getToolBarManager().getItems(); for (IContributionItem child : children) { if (child.getId().equals(id)) { // found the toolbar item that corresponds to the action ActionContributionItem actionItem = (ActionContributionItem) child; if (CoreUIUtils.inEclipse34orHigher) { // uses the 3.4 API widget = (ToolItem) actionItem.getWidget(); } break; } } } } Menu menu = getMenu(parent); if (widget != null) { // sets the location of where the menu is displayed to be the same // as when the dropdown arrow is clicked Rectangle bounds = widget.getBounds(); Point point = widget.getParent().toDisplay(bounds.x, bounds.y + bounds.height); menu.setLocation(point); } menu.setVisible(true); }
From source file:com.aptana.ide.core.ui.actions.HelpAction.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *//*w w w . j av a 2 s . co m*/ public void run(final IAction action) { PlatformUI.getWorkbench().getHelpSystem().displayHelp(action.getId()); }