List of usage examples for org.eclipse.jface.action Action run
@Override public void run()
IAction method does nothing. From source file:ac.soton.fmusim.components.ui.commands.ValidateCommand.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event); // reuse GMF-generated validate action from the diagram Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run(); // // show error markers if added // IResource resource = (IResource) diagramEditor.getEditorInput().getAdapter(IResource.class); // if (resource == null) // return null; // IMarker[] problems = null; // int depth = IResource.DEPTH_INFINITE; // try { // problems = resource.findMarkers(IMarker.PROBLEM, true, depth); // for (IMarker marker : problems) { // System.err.println(marker.getAttribute(IMarker.MESSAGE)); // } // } catch (CoreException e) { // // something went wrong // }/*from w w w. java2 s. c o m*/ return null; }
From source file:ac.soton.multisim.ui.commands.SimulateCommandHandler.java
License:Open Source License
/** * Validates the editor content.//from w w w .j a va 2 s.com * Returns true if validation has found no problems, otherwise false. * * @param diagramEditor */ public static boolean validate(IEditorPart diagramEditor) { Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run(); // show error markers if added IResource resource = (IResource) diagramEditor.getEditorInput().getAdapter(IResource.class); if (resource == null) return false; IMarker[] problems = null; int depth = IResource.DEPTH_INFINITE; try { problems = resource.findMarkers(IMarker.PROBLEM, true, depth); if (problems.length > 0) { new MessageDialog(diagramEditor.getSite().getShell(), "Validation", null, "Fix the validation problems first.", MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return false; } } catch (CoreException e) { return false; } return true; }
From source file:ac.soton.multisim.ui.commands.ValidateCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event); // reuse GMF-generated validate action from the diagram Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run(); // show validation results IFile file = WorkspaceSynchronizer//from w w w . ja v a2 s .com .getFile(((IDiagramWorkbenchPart) diagramEditor).getDiagram().eResource()); List<IMarker> markers = null; try { markers = ValidateAction.getErrorMarkers(file); } catch (CoreException e) { throw new ExecutionException("Validation result retrieval failed", e); } if (markers.isEmpty()) { MessageDialog.openInformation(diagramEditor.getSite().getShell(), "Validation Information", "Validation completed successfully"); } else { final String PID = MultisimDiagramEditorPlugin.ID; MultiStatus errors = new MultiStatus(PID, 1, "Diagram constraints violated", null); for (IMarker marker : markers) { errors.add( SimulationStatus.createErrorStatus(marker.getAttribute(IMarker.MESSAGE, "unknown error"))); } ErrorDialog.openError(diagramEditor.getSite().getShell(), "Validation Problems", "Problems found during validation", errors); } return null; }
From source file:ac.soton.rms.ui.commands.ValidateCommand.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event); // reuse GMF-generated validate action from the diagram Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run(); return null;/* w w w. j a v a2 s. co m*/ }
From source file:com.amazonaws.eclipse.core.ui.overview.Toolkit.java
License:Apache License
/** * Creates and returns a link, which when selected, will run the specified * IActionDelegate./*from w w w .ja va 2 s . com*/ * * @param parent * The parent composite in which to create the new link. * @param text * The text to display for the link. * @param delegate * The delegate object to run when the link is selected. * @return The new link. */ public Link newActionDelegateLink(Composite parent, String text, final IActionDelegate delegate) { final Action proxy = new Action("runAction") { public void run() { delegate.run(this); } }; Link link = new Link(parent, SWT.NONE); link.setText(createAnchor(text, text)); link.setBackground(parent.getBackground()); link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { proxy.run(); } }); return link; }
From source file:com.aptana.ide.intro.browser.CoreURL.java
License:Open Source License
/** * Run an action// w w w . ja v a 2s . c o m */ private boolean runAction(String pluginId, String className, Properties parameters, String standbyState) { Object actionObject = ModelLoaderUtil.createClassInstance(pluginId, className); try { if (actionObject instanceof IIntroAction) { IIntroAction introAction = (IIntroAction) actionObject; introAction.run(null, parameters); } else if (actionObject instanceof IAction) { IAction action = (IAction) actionObject; action.run(); } else if (actionObject instanceof IActionDelegate) { final IActionDelegate delegate = (IActionDelegate) actionObject; if (delegate instanceof IWorkbenchWindowActionDelegate) { ((IWorkbenchWindowActionDelegate) delegate) .init(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } Action proxy = new Action(this.action) { public void run() { delegate.run(this); } }; proxy.run(); } else { // we could not create the class. return false; } } catch (Exception e) { return false; } return true; }
From source file:com.google.gwt.eclipse.oophm.breadcrumbs.BreadcrumbItemDropDown.java
License:Open Source License
public BreadcrumbItemDropDown(BreadcrumbItem parent, Composite composite) { fParent = parent;/* w ww . j a va 2 s .c o m*/ fParentComposite = composite; fMenuIsShown = false; fEnabled = true; fToolBar = new ToolBar(composite, SWT.FLAT); fToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); // SWTUtil.setAccessibilityText( // fToolBar, // BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip); ToolBarManager manager = new ToolBarManager(fToolBar); final Action showDropDownMenuAction = new Action(null, SWT.NONE) { public void run() { Shell shell = fParent.getDropDownShell(); if (shell != null) return; shell = fParent.getViewer().getDropDownShell(); if (shell != null) shell.close(); showMenu(); fShell.setFocus(); } }; showDropDownMenuAction.setImageDescriptor(new AccessibelArrowImage(isLTR())); // showDropDownMenuAction.setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip); manager.add(showDropDownMenuAction); manager.update(true); if (IS_MAC_WORKAROUND) { manager.getControl().addMouseListener(new MouseAdapter() { // see also BreadcrumbItemDetails#addElementListener(Control) public void mouseDown(MouseEvent e) { showDropDownMenuAction.run(); } }); } }
From source file:com.gorillalogic.monkeyconsole.ADBHelper.java
License:Open Source License
/** * Return {@code null} if ADB path is valid, otherwise return error message. * //from www . j a v a 2 s . co m * @return null if valid, otherwise error message */ public static String validate() { String path = getAndroidSdkPref(); if (path == null) { Action action = new Action() { public void run() { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, "com.gorillalogic.monkeyconsole.preferences.FonemonkeyPreferencePage", null, null); dialog.open(); } }; action.run(); return null; } return validateAndroidSdkPath(path); }
From source file:com.jointlogic.breadcrumbs.sampleapp.api.BreadcrumbItemDropDown.java
License:Open Source License
public BreadcrumbItemDropDown(final BreadcrumbItem parent, final Composite composite) { this.fParent = parent; this.fParentComposite = composite; this.fMenuIsShown = false; this.fEnabled = true; this.fToolBar = new ToolBar(composite, SWT.FLAT); this.fToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); this.fToolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override//from w w w . ja v a 2s .co m public void getName(final AccessibleEvent e) { e.result = BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip; } }); final ToolBarManager manager = new ToolBarManager(this.fToolBar); final Action showDropDownMenuAction = new Action(null, SWT.NONE) { @Override public void run() { Shell shell = BreadcrumbItemDropDown.this.fParent.getDropDownShell(); if (shell != null) { return; } shell = BreadcrumbItemDropDown.this.fParent.getViewer().getDropDownShell(); if (shell != null && !shell.isDisposed()) { shell.close(); } showMenu(); BreadcrumbItemDropDown.this.fShell.setFocus(); } }; showDropDownMenuAction.setImageDescriptor(new AccessibelArrowImage(isLeft())); showDropDownMenuAction .setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip); manager.add(showDropDownMenuAction); manager.update(true); if (IS_MAC_WORKAROUND) { manager.getControl().addMouseListener(new MouseAdapter() { // see also BreadcrumbItemDetails#addElementListener(Control) @Override public void mouseDown(final MouseEvent e) { showDropDownMenuAction.run(); } }); } }
From source file:com.liferay.ide.project.ui.wizard.ValidProjectChecker.java
License:Open Source License
public void checkValidProjectTypes() { IProject[] projects = CoreUtil.getAllProjects(); boolean hasValidProjectTypes = false; boolean hasJsfFacet = false; for (IProject project : projects) { if (ProjectUtil.isLiferayFacetedProject(project)) { Set<IProjectFacetVersion> facets = ProjectUtil.getFacetedProject(project).getProjectFacets(); if (validProjectTypes != null && facets != null) { String[] validTypes = validProjectTypes.split(StringPool.COMMA); for (String validProjectType : validTypes) { for (IProjectFacetVersion facet : facets) { String id = facet.getProjectFacet().getId(); if (isJsfPortlet && id.equals("jst.jsf")) //$NON-NLS-1$ {// w w w. j a va 2s.c o m hasJsfFacet = true; } if (id.startsWith("liferay.") && id.equals("liferay." + validProjectType)) //$NON-NLS-1$ //$NON-NLS-2$ { hasValidProjectTypes = true; } } } } } } if (isJsfPortlet) { hasValidProjectTypes = hasJsfFacet && hasValidProjectTypes; } if (!hasValidProjectTypes) { final Shell activeShell = Display.getDefault().getActiveShell(); Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(activeShell, NLS.bind(Msgs.newElement, wizardName), NLS.bind(Msgs.noSuitableLiferayProjects, wizardName)); if (openNewLiferayProjectWizard) { final Action defaultAction = NewPluginProjectDropDownAction.getPluginProjectAction(); if (defaultAction != null) { defaultAction.run(); this.checkValidProjectTypes(); } } } }