Java Code Examples for org.eclipse.core.runtime.jobs.Job#setSystem()
The following examples show how to use
org.eclipse.core.runtime.jobs.Job#setSystem() .
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: Activator.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private void visit(IJavaElementDelta delta) { switch (delta.getElement().getElementType()) { case IJavaElement.JAVA_PROJECT: if ((delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) { final IJavaProject javaProject = (IJavaProject) delta.getElement(); Job updateContainerStateJob = new WorkspaceJob("Updating Google Cloud libraries") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) { BuildPath.checkLibraryList(javaProject, null); return Status.OK_STATUS; } }; IWorkspace workspace = javaProject.getProject().getWorkspace(); ISchedulingRule buildRule = workspace.getRuleFactory().buildRule(); updateContainerStateJob.setRule(buildRule); updateContainerStateJob.setSystem(true); updateContainerStateJob.schedule(); } break; case IJavaElement.JAVA_MODEL: visitChildren(delta); break; default: break; } }
Example 2
Source File: CorePlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void start(BundleContext context) throws Exception { this.context = context; super.start(context); plugin = this; Job job = new Job("Enable debugging and flush log cache") //$NON-NLS-1$ { @Override protected IStatus run(IProgressMonitor monitor) { // Perhaps don't enable this if platform is already in -debug mode? // // Place after context & plugin assignments, as this relies on both existing already enableDebugging(); IdeLog.flushCache(); return Status.OK_STATUS; } }; // DO NOT CALL EclipseUtil.setSystemForJob!!! It breaks startup by causing plugin loading issues in // resources.core plugin job.setSystem(true); job.schedule(); }
Example 3
Source File: AddSvnAndRefreshStartUp.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override public void earlyStartup() { Job job = new WorkspaceJob("refresh svn view") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { monitor.beginTask("refresh", 4); initData(); monitor.worked(1); saveFeatureInfo(ip, userName, cookie); monitor.worked(1); addSvnToView(ip, userName, cookie); monitor.worked(1); monitor.done(); return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); job.setSystem(true); job.schedule(200L); }
Example 4
Source File: SyncSVNPathActionDelegate.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override public void run(IAction action) { Job job = new WorkspaceJob("refresh svn view") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { monitor.beginTask("refresh", 2); initData(); monitor.worked(1); addSvnToView(); monitor.worked(2); monitor.done(); return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); job.setSystem(true); job.schedule(200L); }
Example 5
Source File: SCTPerspectiveManager.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void schedulePerspectiveSwitchJob(final String perspectiveID) { Job switchJob = new UIJob(DebugUIPlugin.getStandardDisplay(), "Perspective Switch Job") { //$NON-NLS-1$ public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow(); if (window != null && !(isCurrentPerspective(window, perspectiveID))) { switchToPerspective(window, perspectiveID); } // Force the debug view to open if (window != null) { try { window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SIMULATION_VIEW_ID); } catch (PartInitException e) { e.printStackTrace(); } } return Status.OK_STATUS; } }; switchJob.setSystem(true); switchJob.setPriority(Job.INTERACTIVE); switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this)); switchJob.schedule(); }
Example 6
Source File: GdbEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void selectFrame(final GdbTrace gdbTrace, final long frameNumber) { Job b = new Job("GDB Trace select frame") { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { // This sends commands to GDB and can potentially wait on the UI // thread (gdb traces console buffer full) so it needs to be // exectued on a non-UI thread gdbTrace.selectFrame(frameNumber); fSelectedTrace = gdbTrace; fSelectedFrame = frameNumber; return Status.OK_STATUS; } }; b.setSystem(true); b.schedule(); }
Example 7
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 8
Source File: ADBService.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void syncLog() throws ADBException { if (!logListenning) { ScriptingConsole.getInstance().clear(); ScriptLogger.logError("开启日志监听..."); logListenning = true; Job startADBJob = new Job("Start ADB log") { protected IStatus run(IProgressMonitor monitor) { if (isStarted) { try { ADBCmdProcessor.callProcess(new ADBCommand( ADBCommand.CMD_TYPE_LOGCAT)); logListenning = true; } catch (ADBException e) { e.printStackTrace(); logListenning = false; //throw adbEx; } } return Status.OK_STATUS; } }; startADBJob.setSystem(true); startADBJob.schedule(500L); startADBJob.addJobChangeListener(new JobChangeAdapter() { public void done(IJobChangeEvent event) { if (event.getResult().isOK()) { ScriptLogger.logError("\u65AD\u5F00\u8FDE\u63A5..."); logListenning = false; } } }); } }
Example 9
Source File: PyEditNotifier.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Helper function to run the notifications of the editor in a job. * * @param runnable the runnable to be run. */ private void runIt(final INotifierRunnable runnable) { Job job = new Job("PyEditNotifier") { @Override protected IStatus run(IProgressMonitor monitor) { runnable.run(monitor); return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); job.setSystem(true); job.schedule(); }
Example 10
Source File: FixedHighlightingReconciler.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Refreshes the highlighting. */ @Override public void refresh() { if (oldCalculator != null || newCalculator != null) { IDocument document = editor != null ? editor.getDocument() : sourceViewer.getDocument(); if (document instanceof IXtextDocument) { Job job = new Job("Calculating highlighting") { //$NON-NLS-1$ @Override protected IStatus run(final IProgressMonitor monitor) { ((XtextDocument) document).readOnly(new CancelableUnitOfWork<Void, XtextResource>() { @Override public java.lang.Void exec(final XtextResource state, final CancelIndicator cancelIndicator) throws Exception { beforeRefresh(state, cancelIndicator); modelChanged(state, cancelIndicator); return null; } }); return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); } } else { Display display = getDisplay(); display.asyncExec(presenter.createSimpleUpdateRunnable()); } }
Example 11
Source File: EclipseUtil.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static void setSystemForJob(Job job) { try { job.setSystem(!showSystemJobs()); } catch (Exception e) { // ignore } }
Example 12
Source File: ServletClasspathProvider.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** Request that a project's Server Runtime classpath container be updated. */ @VisibleForTesting protected void requestClasspathContainerUpdate( IProject project, IRuntime runtime, IClasspathEntry[] entries) { /* * The deceptively-named {@code requestClasspathContainerUpdate()} on our superclass * does not actually request an update of our Server Runtime classpath container. * * A JDT classpath container can be updated either by explicitly requesting an update from its * initializer ({@code ClasspathContainerInitializer#requestClasspathContainerUpdate()}), or * by calling {@code JavaCore.setClasspathContainer()}. Both approaches require specifying the * container path (the container ID, so to speak), and the Server Runtime classpath container's * path is considered internal to WTP. * * But our superclass' {@code resolveClasspathContainerImpl()} implementation does call * {@code JavaCore.setClasspathContainer()} to update the container if the * classpath entries returned from our {@code resolveClasspathContainer()} change. * https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/3055#issuecomment-390242592 */ // Perform update request in a separate job to ensure it's run without holding any additional // locks or rules. Job requestUpdateJob = new Job("Update server runtime classpath container") { //$NON-NLS-1$ @Override public IStatus run(IProgressMonitor monitor) { requestClasspathContainerUpdate(runtime, entries); // triggers update of this classpath container resolveClasspathContainerImpl(project, runtime); return Status.OK_STATUS; } @Override public boolean belongsTo(Object family) { return family == ServletClasspathProvider.this || super.belongsTo(family); } }; requestUpdateJob.setSystem(true); requestUpdateJob.schedule(); }
Example 13
Source File: SVNTeamProviderType.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Create and schedule an auto-add job */ private static synchronized void createAutoAddJob(IProject project) { Job j = new AutoAddJob(project); j.setSystem(true); j.setPriority(Job.SHORT); j.setRule(ResourcesPlugin.getWorkspace().getRoot()); j.schedule(); }
Example 14
Source File: ClassFileEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void installSemanticHighlighting() { super.installSemanticHighlighting(); Job job= new Job(JavaEditorMessages.OverrideIndicatorManager_intallJob) { /* * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) * @since 3.0 */ @Override protected IStatus run(IProgressMonitor monitor) { CompilationUnit ast= SharedASTProvider.getAST(getInputJavaElement(), SharedASTProvider.WAIT_YES, null); if (fOverrideIndicatorManager != null) fOverrideIndicatorManager.reconciled(ast, true, monitor); if (fSemanticManager != null) { SemanticHighlightingReconciler reconciler= fSemanticManager.getReconciler(); if (reconciler != null) reconciler.reconciled(ast, false, monitor); } if (isMarkingOccurrences()) installOccurrencesFinder(false); return Status.OK_STATUS; } }; job.setPriority(Job.DECORATE); job.setSystem(true); job.schedule(); }
Example 15
Source File: StaticHTMLPrviewPlugin.java From birt with Eclipse Public License 1.0 | 5 votes |
private void deleteTempFile( ) { Job deleteJob = new Job( "Delete temporary files" ) { //$NON-NLS-1$ protected IStatus run( IProgressMonitor monitor ) { deleteFile( new File( getTempFolder( ) ) ); return Status.OK_STATUS; } }; deleteJob.setSystem( true ); deleteJob.schedule( ); }
Example 16
Source File: StaticHTMLViewer.java From birt with Eclipse Public License 1.0 | 5 votes |
private void getParamValuesJob( RenderJobRule jobRule ) { Job getParameterJob = new AbstractUIJob( "Collecting parameters", //$NON-NLS-1$ this.reportDesignFile ) { public void work( IProgressMonitor monitor ) { monitor.subTask( "Collecting parameters" ); //$NON-NLS-1$ getParameterValues( inputParameters ); } }; getParameterJob.setSystem( true ); RenderJobRunner.runRenderJob( getParameterJob, jobRule ); }
Example 17
Source File: AbstractSelectTreeViewer2.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(); } }
Example 18
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(); } }
Example 19
Source File: DefaultAnalyticsEventHandler.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void sendEvent(final AnalyticsEvent event) { Job job = new Job("Sending Analytics Ping ...") //$NON-NLS-1$ { @Override protected IStatus run(IProgressMonitor monitor) { IAnalyticsUserManager userManager = AnalyticsEvent.getUserManager(); if (userManager == null) { // send as anonymous user if (!isValidResponse(responseCode = sendPing(event, null))) { // log the event to the database AnalyticsLogger.getInstance().logEvent(event); } return Status.OK_STATUS; } IAnalyticsUser user = userManager.getUser(); // Only send ping if user is logged in. Otherwise, we log it to the database if (user == null || !user.isOnline() || !isValidResponse(responseCode = sendPing(event, user))) { // log the event to the database AnalyticsLogger.getInstance().logEvent(event); } else { // Send out all previous events from the db synchronized (lock) { List<AnalyticsEvent> events = AnalyticsLogger.getInstance().getEvents(); // Sort the events. We want all project.create events to be first, and all project.delete events // to be last Collections.sort(events, new AnalyticsEventComparator()); for (AnalyticsEvent aEvent : events) { if (!isValidResponse(responseCode = sendPing(aEvent, user))) { return Status.OK_STATUS; } // Remove the event after it has been sent AnalyticsLogger.getInstance().clearEvent(aEvent); } } } return Status.OK_STATUS; } }; job.setSystem(true); job.setPriority(Job.BUILD); job.schedule(); // Make this a blocking job for unit tests if (EclipseUtil.isTesting()) { try { job.join(); } catch (InterruptedException e) { } } }
Example 20
Source File: StaticHTMLViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
private void showReportOutputJob( RenderJobRule jobRule ) { Job showJob = new AbstractUIJob( "Showing report", //$NON-NLS-1$ this.reportDesignFile ) { public void work( IProgressMonitor monitor ) { monitor.subTask( "Show report in Browser" ); //$NON-NLS-1$ if ( !form.isDisposed( ) ) { // browser.setUrl( outputLocation // + ( currentBookmark == null ? "" // : ( "#" + currentBookmark ) ) ); browser.setUrl( outputLocation ); // if special the anchor, SWT browser will not refresh // browser.refresh( ); if ( currentPageNum < totalPageNum ) { navNextAction.setEnabled( true ); navLastAction.setEnabled( true ); } else { navNextAction.setEnabled( false ); navLastAction.setEnabled( false ); } if ( currentPageNum > 1 ) { navPreAction.setEnabled( true ); navFirstAction.setEnabled( true ); } else { navPreAction.setEnabled( false ); navFirstAction.setEnabled( false ); } goPageInput.setText( currentPageNum + "" ); //$NON-NLS-1$ refreshTOC( ); } } }; showJob.setSystem( true ); RenderJobRunner.runRenderJob( showJob, jobRule ); }