Java Code Examples for org.eclipse.ui.commands.ICommandService#addExecutionListener()
The following examples show how to use
org.eclipse.ui.commands.ICommandService#addExecutionListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionListenerRegistrant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * setup */ private void setup() { try { // listen for execution events Object service = PlatformUI.getWorkbench().getService(ICommandService.class); if (service instanceof ICommandService) { ICommandService commandService = (ICommandService) service; commandService.addExecutionListener(this); } } catch (IllegalStateException e) { // workbench not yet started, or may be running headless (like in core unit tests) } // listen for element visibility events BundleManager manager = BundleManager.getInstance(); manager.addElementVisibilityListener(this); }
Example 2
Source File: KbdMacroSupport.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Start the definition of a keyboard macro * * @param editor * @param append - if true, append to the current definition */ public void startKbdMacro(ITextEditor editor, boolean append) { if (!isExecuting()) { setEditor(editor); isdefining = true; ics = (ICommandService) editor.getSite().getService(ICommandService.class); // listen for command executions ics.addExecutionListener(this); addDocumentListener(editor); if (!append || kbdMacro == null) { kbdMacro = new KbdMacro(); } setViewer(findSourceViewer(editor)); if (viewer instanceof ITextViewerExtension) { ((ITextViewerExtension) viewer).prependVerifyKeyListener(whileDefining); } else { viewer = null; } // add a listener for ^G Beeper.addBeepListener(KbdMacroBeeper.beeper); currentCommand = null; } }
Example 3
Source File: N4JSExternalLibraryStartup.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void earlyStartup() { // Client code can still clone the repository on demand. (Mind plug-in UI tests.) // TODO this should be a job that we can wait for new Thread(() -> { // trigger index loading which will potentially announce a recovery build on all projects to be // necessary // XXX it is crucial to call isEmpty before isRecoveryBuildRequired is checked, since isEmpty // will set internal state that is afterwards queried by isRecoveryBuildRequired boolean indexIsEmpty = builderState.isEmpty(); // check if this recovery build was really required if (descriptionPersister.isRecoveryBuildRequired() || indexIsEmpty) { // TODO return something like a Future that allows to say // descriptionPersister.scheduleRecoveryBuildOnContributions().andThen(buildManager...) descriptionPersister.scheduleRecoveryBuildOnContributions(); Map<String, String> args = Maps.newHashMap(); IBuildFlag.RECOVERY_BUILD.addToMap(args); builderStateDiscarder.forgetLastBuildState(Arrays.asList(workspace.getRoot().getProjects()), args); } }).start(); // Add listener to monitor Cut and Copy commands ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class); if (commandService != null) { commandService.addExecutionListener(new CheckNodeModulesSyncOnRefresh()); } }
Example 4
Source File: CommandExecutionManager.java From ContentAssist with MIT License | 5 votes |
/** * Registers a command manager with the command service of the workbench. * @param cm the command manager */ public static void register(CommandExecutionManager cm) { ICommandService cs = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class); if (cs != null) { cs.addExecutionListener(cm); } }
Example 5
Source File: StartupJob.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 5 votes |
/** * Runs this job on UI thread. * @param monitor ProgressBar * @return Return Status. */ public IStatus runInUIThread(IProgressMonitor monitor) { CcGlobalConfiguration.getInstance(); try { // TODO: find a better solution... Thread.sleep(WAIT_TIME); } catch (InterruptedException e) { // TODO Auto-generated catch block Logger.log(IStatus.ERROR, e.getMessage()); Logger.log(IStatus.INFO, Logger.getStackTrace(e)); } Logger.log(IStatus.INFO, "adding addResourceChangeListener "); ResourcesPlugin.getWorkspace().addResourceChangeListener(new ResourceChangeListener(), IResourceChangeEvent.POST_BUILD | IResourceDelta.OPEN | IResourceChangeEvent.PRE_DELETE); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); commandService.addExecutionListener(new ISaveCommandExecutionListener()); // check all open projects for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { projectOpened(project); } Logger.log(IStatus.INFO, "CodeChecker reports had been parsed."); // check all open windows IWorkbench wb = PlatformUI.getWorkbench(); for (IWorkbenchWindow win : wb.getWorkbenchWindows()) { addListenerToWorkbenchWindow(win); } return Status.OK_STATUS; }
Example 6
Source File: CompoundEditExitStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void addListeners() { fWidgetEventSource= fViewer.getTextWidget(); if (fWidgetEventSource != null) { fWidgetEventSource.addVerifyKeyListener(fEventListener); fWidgetEventSource.addMouseListener(fEventListener); fWidgetEventSource.addFocusListener(fEventListener); } ICommandService commandService= (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class); if (commandService != null) commandService.addExecutionListener(fEventListener); }
Example 7
Source File: MetaXMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.CompletionMinibuffer#addOtherListeners(IWorkbenchPage, ISourceViewer, StyledText) */ @Override protected void addOtherListeners(IWorkbenchPage page, ISourceViewer viewer, StyledText widget) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class); if (commandService != null) { commandService.addExecutionListener(this); } super.addOtherListeners(page, viewer, widget); }
Example 8
Source File: WakaTime.java From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void earlyStartup() { final IWorkbench workbench = PlatformUI.getWorkbench(); // listen for save file events ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class); executionListener = new CustomExecutionListener(); commandService.addExecutionListener(executionListener); workbench.getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return; // setup wakatime menu //MenuHandler handler = new MenuHandler(); String debug = ConfigFile.get("settings", "debug"); DEBUG = debug != null && debug.trim().equals("true"); WakaTime.log.debug("Initializing WakaTime plugin (https://wakatime.com) v"+VERSION); // prompt for apiKey if not set String apiKey = ConfigFile.get("settings", "api_key"); if (apiKey == "") { promptForApiKey(window); } Dependencies.configureProxy(); if (!Dependencies.isPythonInstalled()) { Dependencies.installPython(); if (!Dependencies.isPythonInstalled()) { MessageDialog dialog = new MessageDialog(window.getShell(), "Warning!", null, "WakaTime needs Python installed. Please install Python from python.org/downloads, then restart Eclipse.", MessageDialog.WARNING, new String[]{IDialogConstants.OK_LABEL}, 0); dialog.open(); } } checkCore(); if (window.getPartService() == null) return; // listen for caret movement if (window.getPartService().getActivePartReference() != null && window.getPartService().getActivePartReference().getPage() != null && window.getPartService().getActivePartReference().getPage().getActiveEditor() != null ) { IEditorPart part = window.getPartService().getActivePartReference().getPage().getActiveEditor(); if (!(part instanceof AbstractTextEditor)) return; ((StyledText)part.getAdapter(Control.class)).addCaretListener(new CustomCaretListener()); } // listen for change of active file window.getPartService().addPartListener(editorListener); if (window.getPartService().getActivePart() == null) return; if (window.getPartService().getActivePart().getSite() == null) return; if (window.getPartService().getActivePart().getSite().getPage() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return; // log file if one is opened by default IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput(); if (input instanceof IURIEditorInput) { URI uri = ((IURIEditorInput)input).getURI(); if (uri != null && uri.getPath() != null) { String currentFile = uri.getPath(); long currentTime = System.currentTimeMillis() / 1000; if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) { WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), false); WakaTime.getDefault().lastFile = currentFile; WakaTime.getDefault().lastTime = currentTime; } } } WakaTime.log.debug("Finished initializing WakaTime plugin (https://wakatime.com) v"+VERSION); } }); }