Java Code Examples for org.eclipse.core.runtime.jobs.Job#schedule()
The following examples show how to use
org.eclipse.core.runtime.jobs.Job#schedule() .
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: UIPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void start(BundleContext context) throws Exception { super.start(context); plugin = this; Job job = new Job("Initializing UI Plugin") //$NON-NLS-1$ { @Override protected IStatus run(IProgressMonitor monitor) { updateInitialPerspectiveVersion(); addPerspectiveListener(); addAutoBuildListener(); return Status.OK_STATUS; } }; EclipseUtil.setSystemForJob(job); job.schedule(); // force usage plugin to start UsagePlugin.getDefault(); }
Example 2
Source File: DeployDiagramHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void runInJob(DiagramFileStore diagramFileStore, DeployProcessOperation deployOperation) { Job deployJob = new Job(String.format(Messages.deployingProcessesFrom, diagramFileStore.getName())) { @Override protected IStatus run(IProgressMonitor monitor) { return deployOperation.run(monitor); } }; deployJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { Display.getDefault().syncExec(() -> displayDeployResult(event.getResult())); } }); deployJob.setUser(true); deployJob.schedule(); }
Example 3
Source File: AbapGitStagingService.java From ADT_Frontend with MIT License | 5 votes |
/** * Utility method for opening the text editor for abapgit files. All * <i>xml</i> files will be opened in the xml editor if available and the * other source files will be opened in the default text editor. * * @param file * AbapGit file to be opened * @param project * Abap project */ private void openAbapGitFile(IAbapGitFile file, IProject project, IExternalRepositoryInfoRequest credentials) { if (!isFetchFileContentSupported(file)) { IAbapGitObject abapObject = (IAbapGitObject) file.eContainer(); if (abapObject.getType() == null) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.AbapGitStaging_open_file_editor_not_supported_dialog_title, NLS.bind(Messages.AbapGitStaging_open_file_editor_not_supported_xmg, file.getName())); } else { openAbapObject((IAbapGitObject) file.eContainer(), project); } return; } if (!checkIfOpenFileEditorSupportedForObject(file)) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.AbapGitStaging_open_file_editor_not_supported_dialog_title, NLS.bind(Messages.AbapGitStaging_open_file_editor_not_supported_xmg, file.getName())); return; } Job openEditor = new Job(Messages.AbapGitStaging_open_file_editor_job_title) { @Override protected IStatus run(IProgressMonitor monitor) { try { String fileContents = FileServiceFactory.createFileService().readLocalFileContents(file, credentials, getDestination(project)); openFileEditor(file, fileContents); return Status.OK_STATUS; } catch (IOException e) { AbapGitUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, AbapGitUIPlugin.PLUGIN_ID, e.getMessage(), e)); return Status.CANCEL_STATUS; } } }; openEditor.schedule(); }
Example 4
Source File: EclipseRemoteProgressIndicatorImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void start() { if (started) return; started = true; final Job job = new Job(CoreUtils.format(Messages.RemoteProgress_observing_progress_for, remoteUser)) { @Override protected IStatus run(IProgressMonitor monitor) { try { mainloop(monitor); return Status.OK_STATUS; } catch (Exception e) { log.error(e); return Status.CANCEL_STATUS; } finally { rpm.progressIndicatorStopped(EclipseRemoteProgressIndicatorImpl.this); } } }; job.setPriority(Job.SHORT); job.setUser(true); job.schedule(); running = true; }
Example 5
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void scheduleJob(final IBaseClosure<Void, CoreException> jobRunnable, ISchedulingRule rule, String jobCaption, boolean user) { Job job = new Job(jobCaption) { public IStatus run(IProgressMonitor monitor) { try { jobRunnable.execute(null); } catch (CoreException e) { LogHelper.logError(e); } return Status.OK_STATUS; } }; job.setRule(rule); job.setUser(user); job.schedule(); }
Example 6
Source File: PydevConsoleFactory.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void createConsole(final PydevConsoleInterpreter interpreter, final String additionalInitialComands) { Job job = new Job("Create Interactive Console") { @Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask("Create Interactive Console", 4); try { sayHello(interpreter, new SubProgressMonitor(monitor, 1)); connectDebugger(interpreter, additionalInitialComands, new SubProgressMonitor(monitor, 2)); enableGuiEvents(interpreter, new SubProgressMonitor(monitor, 1)); return Status.OK_STATUS; } catch (Exception e) { try { interpreter.close(); } catch (Exception e_inner) { // ignore, but log nested exception Log.log(e_inner); } if (e instanceof UserCanceledException) { return Status.CANCEL_STATUS; } else { Log.log(e); return PydevDebugPlugin.makeStatus(IStatus.ERROR, "Error initializing console.", e); } } finally { monitor.done(); } } }; job.setUser(true); job.schedule(); }
Example 7
Source File: CallGraphTableViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) { Iterable<CallStackAnalysis> csModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class); @Nullable CallStackAnalysis csModule = Iterables.getFirst(csModules, null); if (csModule == null) { return null; } csModule.schedule(); ICallGraphProvider cgModule = csModule.getCallGraph(); if (!(cgModule instanceof CallGraphAnalysis)) { return null; } CallGraphAnalysis module = (CallGraphAnalysis) cgModule; Job job = new Job(Messages.CallGraphAnalysis) { @Override protected IStatus run(IProgressMonitor monitor) { // The callgraph module will be scheduled by the callstack analysis, but we need // to wait for its specific termination module.waitForCompletion(Objects.requireNonNull((monitor))); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; job.schedule(); return csModule; }
Example 8
Source File: NewSpecHandler.java From tlaplus with MIT License | 5 votes |
/** * This triggers a build which might even be blocked due to the job * scheduling rule, hence decouple and let the UI thread continue. * @param lock */ private void createModuleAndSpecInNonUIThread(final String rootFilename, final boolean importExisting, final String specName) { Assert.isNotNull(rootFilename); Assert.isNotNull(specName); final Job job = new NewSpecHandlerJob(specName, rootFilename, importExisting); job.schedule(); }
Example 9
Source File: DockerRmLaunchShortcut.java From doclipser with Eclipse Public License 1.0 | 5 votes |
private void launch(final IFile dockerfile, final IPath dockerfilePath) { Job job = new Job("Docker Build Job") { @Override protected IStatus run(IProgressMonitor monitor) { DockerClient dockerClient = DockerClientFactory .makeDockerClient(); dockerClient.defaultRmCommand( dockerfile.getProject().getName(), dockerfilePath.toOSString()); return Status.OK_STATUS; } }; job.schedule(); }
Example 10
Source File: ImportTemplateWizard.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override public boolean performFinish() { final Job job = new ImportTemplateJob(creationPage.getContainerFullPath(), creationPage.getFileName()); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(); return true; }
Example 11
Source File: FactoryEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void insertEntry ( final String value ) { final Job job = this.factoryInput.createCreateJob ( value ); job.addJobChangeListener ( new JobChangeAdapter () { @Override public void done ( final IJobChangeEvent event ) { refresh (); } } ); job.schedule (); }
Example 12
Source File: Utils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static void schedule(Job job, IWorkbenchSite site) { if (site != null) { IWorkbenchSiteProgressService siteProgress = (IWorkbenchSiteProgressService) site.getAdapter(IWorkbenchSiteProgressService.class); if (siteProgress != null) { siteProgress.schedule(job, 0, true /* use half-busy cursor */); return; } } job.schedule(); }
Example 13
Source File: AbstractTmfTreeViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Requests an update of the viewer's content in a given time range or * selection time range. An extra parameter defines whether these times * correspond to the selection or the visible range, as the viewer may * update differently in those cases. * * @param start * The start time of the requested content * @param end * The end time of the requested content * @param isSelection * <code>true</code> if this time range is for a selection, * <code>false</code> for the visible time range */ protected void updateContent(final long start, final long end, final boolean isSelection) { ITmfTrace trace = getTrace(); if (trace == null) { return; } Job thread = new Job("") { //$NON-NLS-1$ @Override public IStatus run(IProgressMonitor monitor) { final ITmfTreeViewerEntry newRootEntry = updateElements(trace, start, end, isSelection); /* Set the input in main thread only if it changed */ if (newRootEntry != null) { Display.getDefault().asyncExec(() -> { if (fTreeViewer.getControl().isDisposed()) { return; } Object currentRootEntry = fTreeViewer.getInput(); if (newRootEntry != currentRootEntry) { updateTreeUI(fTreeViewer, newRootEntry); } else { fTreeViewer.refresh(); } // FIXME should add a bit of padding for (TreeColumn column : fTreeViewer.getTree().getColumns()) { column.pack(); } }); } return Status.OK_STATUS; } }; thread.setSystem(true); thread.schedule(); }
Example 14
Source File: UpdateCheck.java From cppcheclipse with Apache License 2.0 | 5 votes |
public Job check(String binaryPath) { Job job = new UpdateCheckJob(binaryPath); job.setUser(true); // execute job asynchronously job.schedule(); return job; }
Example 15
Source File: ConversionTests.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void bare_Java8_Web25() throws CoreException, IOException, InterruptedException, SAXException, AppEngineException { IFacetedProject project = projectCreator .withFacets(JavaFacet.VERSION_1_8, WebFacetUtils.WEB_25).getFacetedProject(); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); // ensure facet versions haven't been downgraded assertFacetVersions(project, JavaFacet.VERSION_1_8, WebFacetUtils.WEB_25, AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8); assertJava8Runtime(project); }
Example 16
Source File: CloudSdkManager.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Triggers the installation of a Cloud SDK, if the preferences are configured to auto-manage the * SDK. */ public void installManagedSdkAsync() { if (CloudSdkPreferences.isAutoManaging()) { // Keep installation failure as ERROR so that failures are reported Job installJob = new CloudSdkInstallJob(null /* no console output */, modifyLock); installJob.setUser(false); installJob.schedule(); } }
Example 17
Source File: Shutdown.java From offspring with MIT License | 4 votes |
public static boolean execute(Shell shell, IEventBroker broker, UISynchronize sync, final INxtService nxt, final IDataProviderPool pool) { if (!MessageDialog.openConfirm(shell, "Shutdown Offspring", "Are you sure you want to shutdown Offspring?")) { return false; } final StartupDialog dialog = new StartupDialog(shell, sync); dialog.setBlockOnOpen(true); dialog.showOKButton(false); dialog.create(); Job startupJob = new Job("Startup Job") { volatile boolean DONE = false; @Override protected IStatus run(final IProgressMonitor monitor) { Thread cancelThread = new Thread(new Runnable() { @Override public void run() { while (!DONE) { try { Thread.sleep(500); if (monitor.isCanceled()) { System.exit(-1); return; } } catch (InterruptedException e) { return; } } } }); cancelThread.start(); try { monitor.beginTask("Shutting down dataprovider pools", IProgressMonitor.UNKNOWN); pool.destroy(); monitor.setTaskName("Shutting down NXT"); nxt.shutdown(); monitor.done(); } finally { DONE = true; } return Status.OK_STATUS; } }; Job.getJobManager().setProgressProvider(new ProgressProvider() { @Override public IProgressMonitor createMonitor(Job job) { return dialog.getProgressMonitor(); } }); startupJob.schedule(); dialog.open(); // // // BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { // // @Override // public void run() { // nxt.shutdown(); // pool.destroy(); // } // }); return true; }
Example 18
Source File: CommonEditorPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Hook up a listener for theme changes, and change the PHP occurrence colors! */ private void listenForThemeChanges() { Job job = new UIJob("Set occurrence colors to theme") //$NON-NLS-1$ { private void setOccurrenceColors() { IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors"); //$NON-NLS-1$ Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme(); prefs.put("OccurrenceIndicationColor", StringConverter.asString(theme.getSearchResultColor())); //$NON-NLS-1$ try { prefs.flush(); } catch (BackingStoreException e) { // ignore } } @Override public IStatus runInUIThread(IProgressMonitor monitor) { fThemeChangeListener = new IPreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent event) { if (event.getKey().equals(IThemeManager.THEME_CHANGED)) { setOccurrenceColors(); } } }; setOccurrenceColors(); EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID) .addPreferenceChangeListener(fThemeChangeListener); return Status.OK_STATUS; } }; EclipseUtil.setSystemForJob(job); job.schedule(2000); }
Example 19
Source File: DeleteResourceAndCloseEditorAction.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public void run() { final IResource[] resources = getSelectedResourcesArray(); if (!fTestingMode) { if (LTKLauncher.openDeleteWizard(getStructuredSelection())) { return; } } // WARNING: do not query the selected resources more than once // since the selection may change during the run, // e.g. due to window activation when the prompt dialog is dismissed. // For more details, see Bug 60606 [Navigator] (data loss) Navigator // deletes/moves the wrong file if (!confirmDelete(resources)) { return; } Job deletionCheckJob = new Job(IDEWorkbenchMessages.DeleteResourceAction_checkJobName) { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ protected IStatus run(IProgressMonitor monitor) { if (resources.length == 0) return Status.CANCEL_STATUS; closeRelatedEditors(); scheduleDeleteJob(resources); return Status.OK_STATUS; } /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) */ public boolean belongsTo(Object family) { if (IDEWorkbenchMessages.DeleteResourceAction_jobName.equals(family)) { return true; } return super.belongsTo(family); } }; deletionCheckJob.schedule(); }
Example 20
Source File: AbstractSelectTreeViewer.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override protected void updateContent(long start, long end, boolean isSelection) { try (FlowScopeLog scope = new FlowScopeLogBuilder(LOGGER, Level.FINE, UPDATE_CONTENT_JOB_NAME) .setCategory(fLogCategory).build()) { ITmfTrace trace = getTrace(); if (trace == null) { return; } Job thread = new Job(UPDATE_CONTENT_JOB_NAME) { @Override public IStatus run(IProgressMonitor monitor) { try (FlowScopeLog runScope = new FlowScopeLogBuilder(LOGGER, Level.FINE, UPDATE_CONTENT_JOB_NAME + " run") //$NON-NLS-1$ .setParentScope(scope).build()) { ITmfTreeDataProvider<@NonNull ITmfTreeDataModel> provider = getProvider(trace); if (provider == null) { return Status.OK_STATUS; } Map<String, Object> parameters = getParameters(start, end, isSelection); if (parameters.isEmpty()) { return Status.OK_STATUS; } boolean isComplete = false; do { TmfModelResponse<@NonNull TmfTreeModel<@NonNull ITmfTreeDataModel>> response; try (FlowScopeLog iterScope = new FlowScopeLogBuilder(LOGGER, Level.FINE, UPDATE_CONTENT_JOB_NAME + " query") //$NON-NLS-1$ .setParentScope(scope).build()) { response = provider.fetchTree(parameters, monitor); TmfTreeModel<@NonNull ITmfTreeDataModel> model = response.getModel(); if (model != null) { updateTree(trace, start, end, model.getEntries()); } } ITmfResponse.Status status = response.getStatus(); if (status == ITmfResponse.Status.COMPLETED) { /* Model is complete, no need to request again the data provider */ isComplete = true; } else if (status == ITmfResponse.Status.FAILED || status == ITmfResponse.Status.CANCELLED) { /* Error occurred, return */ isComplete = true; } else { /** * Status is RUNNING. Sleeping current thread to wait before request data * provider again **/ try { Thread.sleep(BUILD_UPDATE_TIMEOUT); } catch (InterruptedException e) { /** * InterruptedException is throw by Thread.Sleep and we should retry querying * the data provider **/ runScope.addData(FAILED_TO_SLEEP_PREFIX + getName(), e); Thread.currentThread().interrupt(); return new Status(IStatus.ERROR, Activator.PLUGIN_ID, FAILED_TO_SLEEP_PREFIX + getName()); } } } while (!isComplete); return Status.OK_STATUS; } } }; thread.setSystem(true); thread.schedule(); } }