Java Code Examples for org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob#setSystem()

The following examples show how to use org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob#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: PreloadingRepositoryHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
void doExecuteAndLoad(){
	if (preloadRepositories()) {
		// cancel any load that is already running
		Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
		final LoadMetadataRepositoryJob loadJob =
			new LoadMetadataRepositoryJob(getProvisioningUI());
		setLoadJobProperties(loadJob);
		if (waitForPreload()) {
			loadJob.addJobChangeListener(new JobChangeAdapter() {
				public void done(IJobChangeEvent event){
					if (PlatformUI.isWorkbenchRunning())
						if (event.getResult().isOK()) {
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
								public void run(){
									doExecute(loadJob);
								}
							});
						}
				}
			});
			loadJob.setUser(true);
			loadJob.schedule();
			
		} else {
			loadJob.setSystem(true);
			loadJob.setUser(false);
			loadJob.schedule();
			doExecute(null);
		}
	} else {
		doExecute(null);
	}
}
 
Example 2
Source File: PreloadingRepositoryHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
void doExecuteAndLoad() {
	if (preloadRepositories()) {
		// cancel any load that is already running
		final IStatus[] checkStatus = new IStatus[1];
		Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
		final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()) {
			public IStatus runModal(IProgressMonitor monitor) {
				SubMonitor sub = SubMonitor.convert(monitor, getProgressTaskName(), 1000);
				IStatus status = super.runModal(sub.newChild(500));
				if (status.getSeverity() == IStatus.CANCEL)
					return status;
				if (status.getSeverity() != IStatus.OK) {
					// 记录检查错误
					checkStatus[0] = status;
					return Status.OK_STATUS;
				}
				try {
					doPostLoadBackgroundWork(sub.newChild(500));
				} catch (OperationCanceledException e) {
					return Status.CANCEL_STATUS;
				}
				return status;
			}
		};
		setLoadJobProperties(loadJob);
		loadJob.setName(P2UpdateUtil.CHECK_UPDATE_JOB_NAME);
		if (waitForPreload()) {
			loadJob.addJobChangeListener(new JobChangeAdapter() {
				public void done(IJobChangeEvent event) {
					if (PlatformUI.isWorkbenchRunning())
						if (event.getResult().isOK()) {
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
								public void run() {
									if (checkStatus[0] != null) {
										// 提示连接异常
										P2UpdateUtil.openConnectErrorInfoDialog(getShell(),
												P2UpdateUtil.INFO_TYPE_CHECK);
										return;
									}
									doExecute(loadJob);
								}
							});
						}
				}
			});
			loadJob.setUser(true);
			loadJob.schedule();

		} else {
			loadJob.setSystem(true);
			loadJob.setUser(false);
			loadJob.schedule();
			doExecute(null);
		}
	} else {
		doExecute(null);
	}
}
 
Example 3
Source File: PreloadingRepositoryHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
void doExecuteAndLoad() {
	if (preloadRepositories()) {
		// cancel any load that is already running
		final IStatus[] checkStatus = new IStatus[1];
		Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
		final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()) {
			public IStatus runModal(IProgressMonitor monitor) {
				SubMonitor sub = SubMonitor.convert(monitor, getProgressTaskName(), 1000);
				IStatus status = super.runModal(sub.newChild(500));
				if (status.getSeverity() == IStatus.CANCEL)
					return status;
				if (status.getSeverity() != IStatus.OK) {
					// 记录检查错误
					checkStatus[0] = status;
					return Status.OK_STATUS;
				}
				try {
					doPostLoadBackgroundWork(sub.newChild(500));
				} catch (OperationCanceledException e) {
					return Status.CANCEL_STATUS;
				}
				return status;
			}
		};
		setLoadJobProperties(loadJob);
		loadJob.setName(P2UpdateUtil.CHECK_UPDATE_JOB_NAME);
		if (waitForPreload()) {
			loadJob.addJobChangeListener(new JobChangeAdapter() {
				public void done(IJobChangeEvent event) {
					if (PlatformUI.isWorkbenchRunning())
						if (event.getResult().isOK()) {
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
								public void run() {
									if (checkStatus[0] != null) {
										// 提示连接异常
										P2UpdateUtil.openConnectErrorInfoDialog(getShell(),
												P2UpdateUtil.INFO_TYPE_CHECK);
										return;
									}
									doExecute(loadJob);
								}
							});
						}
				}
			});
			loadJob.setUser(true);
			loadJob.schedule();

		} else {
			loadJob.setSystem(true);
			loadJob.setUser(false);
			loadJob.schedule();
			doExecute(null);
		}
	} else {
		doExecute(null);
	}
}