Java Code Examples for org.eclipse.core.runtime.jobs.Job#addJobChangeListener()

The following examples show how to use org.eclipse.core.runtime.jobs.Job#addJobChangeListener() . 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: DeployDiagramHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: FactoryEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 3
Source File: ADBService.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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 4
Source File: BackgroundUpdaterTaskListener.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
/**
 * schedule a meta file reader job to check if there are updates
 */
private void executeUpdateJob() {
	Job readMetaFileJob = new UpdateMetaFileReaderJob(updateManager);
	readMetaFileJob.schedule();
	readMetaFileJob.addJobChangeListener(
			new UpdateMetaFileReaderJobListener(updateManager, ActiveTab.UPDATE_FEATURES, true));
}
 
Example 5
Source File: UpdateFeaturesCommandHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
	Job updateJob = new UpdateCheckerJob(updateManager);
	updateJob.schedule();
	updateJob.addJobChangeListener(new UpdateCheckerJobListener(
			updateManager, ActiveTab.UPDATE_FEATURES, false));
	try {
		PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getActivePage().showView(IProgressConstants.PROGRESS_VIEW_ID);
	} catch (PartInitException e) {
		log.error(e);
	}
	return null;
}
 
Example 6
Source File: InstallFeaturesCommandHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
	Job updateJob = new UpdateCheckerJob(updateManager);
	updateJob.schedule();
	updateJob.addJobChangeListener(new UpdateCheckerJobListener(
			updateManager, ActiveTab.ALL_FEATURES, false));
	try {
		PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getActivePage().showView(IProgressConstants.PROGRESS_VIEW_ID);
	} catch (PartInitException e) {
		log.error(e);
	}
	return null;
}
 
Example 7
Source File: WidgetModel.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
	if (!isDirty) {
		synchronized (this) {
			final HybridProject project = getProject();

			final IDOMModel domModel = (IDOMModel) model;

			Job updatePlugins = new Job(
					"Synchronize project " + project.getProject().getName() + " with config.xml") {

				@Override
				protected IStatus run(IProgressMonitor monitor) {
					if (project.getProject().exists()) {
						reloadEditableWidget();
						Widget newWidget = load(domModel.getDocument());
						syncEngines(project, newWidget, monitor);
						syncPlugins(project, newWidget, monitor);
					}
					return Status.OK_STATUS;
				}
			};

			updatePlugins.addJobChangeListener(new JobChangeAdapter() {

				@Override
				public void done(IJobChangeEvent event) {
					lastWidget.reload(domModel.getDocument().getDocumentElement());
					reloadEditableWidget();
					readonlyWidget = null;
					readonlyTimestamp = -1;
				}
			});
			ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project.getProject());
			updatePlugins.setRule(rule);
			updatePlugins.schedule();
		}
	}
}
 
Example 8
Source File: CheckUpateManager.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void checkIDEUpdate() {
	if (isFinished) {
		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				MessageDialog.openInformation(null,
						Messages.TIPINFORMATION, Messages.UPDATEINFO);
			}
		});
		return;
	}
	if (!isUpdate) {
		isUpdate = true;
		Job job = new WorkspaceJob("check out") {
			@Override
			public IStatus runInWorkspace(IProgressMonitor monitor)
					throws CoreException {
				IDEUpdateModel model = null;

				try {
					model = getIDEUpdate();
				} catch (JSONException e) {
					return Status.CANCEL_STATUS;
				}

				if (model == null || oUpdateUrl == null
						&& iUpdateUrl == null && aUpdateUrl == null
						&& bUpdateUrl == null) {
					if (!isAuto) {
						Display.getDefault().syncExec(new Runnable() {
							public void run() {
								MessageDialog.openInformation(null,
										Messages.TIPINFORMATION,
										Messages.LATESTVERSION);
							}
						});
					}
					return Status.OK_STATUS;
				}
				if (dialog == null) {
					dialog = new IDEUpdateDialog(null, model,
							CheckUpateManager.this);
				}
				dialog.setModel(model);
				
				if ("1".equals(basic_updateType)||"1".equals(third_updateType)) {
					IDEUpdate();
				} else {

					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							dialog.open();
						}
					});

				}
				return Status.OK_STATUS;
			}

		};
		job.schedule(100L);
		job.addJobChangeListener(new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				isUpdate = false;
			}
		});
	}
}
 
Example 9
Source File: UpdaterRootJob.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
private void runUpdateMetaFileReaderJob() {
	Job readMetaFileJob = new UpdateMetaFileReaderJob(updateManager);
	readMetaFileJob.schedule();
	readMetaFileJob.addJobChangeListener(
			new UpdateMetaFileReaderJobListener(updateManager, ActiveTab.UPDATE_FEATURES, true));
}