org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob Java Examples

The following examples show how to use org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob. 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: UpdateHandler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
protected void doExecute(LoadMetadataRepositoryJob job){
	if (hasNoRepos) {
		return;
	}
	UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
	// check for updates
	operation.resolveModal(null);
	if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
		if (UpdateSingleIUWizard.validFor(operation)) {
			// Special case for only updating a single root
			UpdateSingleIUWizard wizard =
				new UpdateSingleIUWizard(getProvisioningUI(), operation);
			WizardDialog dialog = new WizardDialog(getShell(), wizard);
			dialog.create();
			dialog.open();
		} else {
			// Open the normal version of the update wizard
			getProvisioningUI().openUpdateWizard(false, operation, job);
		}
	}
}
 
Example #2
Source File: CheckUpdateHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
	// TODO Auto-generated method stub		
	if (hasNoRepos) {
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_CHECK);
		return;
	}
	
	if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
		UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), operation, operation.getSelectedUpdates());
		TSWizardDialog dialog = new TSWizardDialog(getShell(), wizard);
		dialog.create();
		dialog.open();
	}
}
 
Example #3
Source File: UpdateDetailsPresenter.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
  try {
    // Save the global settings that we will modify
    saveSettings();

    // Modify those settings
    prepareWizardSettings();

    // Boilerplate for opening the wizard
    InstallWizard wizard = new InstallWizard(getProvisioningUI(), null,
        null, job);
    WizardDialog dialog = new ProvisioningWizardDialog(getShell(), wizard);
    dialog.create();
    PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
        IProvHelpContextIds.INSTALL_WIZARD);

    prepareWizard(wizard);

    // Open it
    dialog.open();

  } catch (Exception e) {
    throw new RuntimeException(e);

  } finally {
    // Restore the settings which we touched
    restoreSettings();
  }
}
 
Example #4
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 #5
Source File: InstallNewSoftwareHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
protected void setLoadJobProperties(Job loadJob){
	super.setLoadJobProperties(loadJob);
	// If we are doing a background load, we do not wish to authenticate, as the
	// user is unaware that loading was needed
	if (!waitForPreload()) {
		loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER,
			Boolean.toString(true));
		loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS,
			Boolean.toString(true));
	}
}
 
Example #6
Source File: CheckUpdateHandler.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
	// TODO Auto-generated method stub		
	if (hasNoRepos) {
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_CHECK);
		return;
	}
	
	if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
		UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), operation, operation.getSelectedUpdates());
		TSWizardDialog dialog = new TSWizardDialog(getShell(), wizard);
		dialog.create();
		dialog.open();
	}
}
 
Example #7
Source File: PreloadingRepositoryHandler.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
protected void setLoadJobProperties(Job loadJob){
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS,
		Boolean.toString(true));
}
 
Example #8
Source File: InstallNewSoftwareHandler.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
protected void doExecute(LoadMetadataRepositoryJob job){
	getProvisioningUI().openInstallWizard(null, null, job);
}
 
Example #9
Source File: AutomaticUpdate.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void checkForUpdates() throws OperationCanceledException {
	// 检查 propfile
	String profileId = getProvisioningUI().getProfileId();
	IProvisioningAgent agent = getProvisioningUI().getSession().getProvisioningAgent();
	IProfile profile = null;
	if (agent != null) {
		IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
		if (registry != null) {
			profile = registry.getProfile(profileId);
		}
	}
	if (profile == null) {
		// Inform the user nicely
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	// 开始检查前先确定是否有repository
	RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
	if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	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, P2UpdateUtil.CHECK_UPDATE_TASK_NAME, 1000);
			// load repository
			IStatus status = super.runModal(sub.newChild(500));
			if (status.getSeverity() == IStatus.CANCEL) {
				return status;
			}
			if (status.getSeverity() != Status.OK) {
				// load repository error
				checkStatus[0] = status;
			}
			operation = getProvisioningUI().getUpdateOperation(null, null);
			// check for updates
			IStatus resolveStatus = operation.resolveModal(sub.newChild(500));
			if (resolveStatus.getSeverity() == IStatus.CANCEL) {
				return Status.CANCEL_STATUS;
			}
			return Status.OK_STATUS;
		}
	};
	loadJob.setName(P2UpdateUtil.ATUO_CHECK_UPDATE_JOB_NAME);
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
	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_AUTO_CHECK);
								return;
							}
							doUpdate();
						}
					});
				}
		}
	});
	loadJob.setUser(true);
	loadJob.schedule();
}
 
Example #10
Source File: PreloadingRepositoryHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected void setLoadJobProperties(Job loadJob) {
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
}
 
Example #11
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);
	}
}
 
Example #12
Source File: AutomaticUpdate.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void checkForUpdates() throws OperationCanceledException {
	// 检查 propfile
	String profileId = getProvisioningUI().getProfileId();
	IProvisioningAgent agent = getProvisioningUI().getSession().getProvisioningAgent();
	IProfile profile = null;
	if (agent != null) {
		IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
		if (registry != null) {
			profile = registry.getProfile(profileId);
		}
	}
	if (profile == null) {
		// Inform the user nicely
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	// 开始检查前先确定是否有repository
	RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
	if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	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, P2UpdateUtil.CHECK_UPDATE_TASK_NAME, 1000);
			// load repository
			IStatus status = super.runModal(sub.newChild(500));
			if (status.getSeverity() == IStatus.CANCEL) {
				return status;
			}
			if (status.getSeverity() != Status.OK) {
				// load repository error
				checkStatus[0] = status;
			}
			operation = getProvisioningUI().getUpdateOperation(null, null);
			// check for updates
			IStatus resolveStatus = operation.resolveModal(sub.newChild(500));
			if (resolveStatus.getSeverity() == IStatus.CANCEL) {
				return Status.CANCEL_STATUS;
			}
			return Status.OK_STATUS;
		}
	};
	loadJob.setName(P2UpdateUtil.ATUO_CHECK_UPDATE_JOB_NAME);
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
	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_AUTO_CHECK);
								return;
							}
							doUpdate();
						}
					});
				}
		}
	});
	loadJob.setUser(true);
	loadJob.schedule();
}
 
Example #13
Source File: PreloadingRepositoryHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected void setLoadJobProperties(Job loadJob) {
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
}
 
Example #14
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 #15
Source File: PreloadingRepositoryHandler.java    From tmxeditor8 with GNU General Public License v2.0 votes vote down vote up
protected abstract void doExecute(LoadMetadataRepositoryJob job); 
Example #16
Source File: PreloadingRepositoryHandler.java    From translationstudio8 with GNU General Public License v2.0 votes vote down vote up
protected abstract void doExecute(LoadMetadataRepositoryJob job); 
Example #17
Source File: PreloadingRepositoryHandler.java    From elexis-3-core with Eclipse Public License 1.0 votes vote down vote up
protected abstract void doExecute(LoadMetadataRepositoryJob job);