use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project linuxtools by eclipse.
the class OpenInHierarchyViewCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// retrieve the selected image
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final IDockerConnection2 currentConnection = (IDockerConnection2) CommandUtils.getCurrentConnection(activePart);
// run a job to retrieve the image hierarchy
final RetrieveImageHierarchyJob retrieveImageHierarchyJob = new RetrieveImageHierarchyJob(currentConnection, CommandUtils.getSelectedElement(activePart));
retrieveImageHierarchyJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
// input
if (retrieveImageHierarchyJob.getImageHierarchy() == null) {
Activator.logWarningMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.imageHierarchyView.failure.missingHierarchy"));
}
Display.getDefault().asyncExec(() -> {
try {
final DockerImageHierarchyView dockerImageHierarchyView = (DockerImageHierarchyView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImageHierarchyView.VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE);
dockerImageHierarchyView.setConnection((IDockerConnection) currentConnection);
dockerImageHierarchyView.show(retrieveImageHierarchyJob.getImageHierarchy());
} catch (PartInitException e) {
Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.imageHierarchyView.failure"), e);
}
});
}
});
retrieveImageHierarchyJob.schedule();
//
return null;
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project knime-core by knime.
the class InstallMissingNodesJob method startInstallJob.
private void startInstallJob(final Set<IInstallableUnit> featuresToInstall) {
final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(provUI);
loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
loadJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
if (PlatformUI.isWorkbenchRunning() && event.getResult().isOK()) {
Display.getDefault().asyncExec(() -> {
if (Display.getDefault().isDisposed()) {
NodeLogger.getLogger("Display disposed, aborting install action");
// fixes AP-8376, AP-8380, AP-7184
return;
}
provUI.getPolicy().setRepositoriesVisible(false);
provUI.openInstallWizard(featuresToInstall, new InstallOperation(provUI.getSession(), featuresToInstall), loadJob);
provUI.getPolicy().setRepositoriesVisible(true);
});
}
}
});
loadJob.setUser(true);
loadJob.schedule();
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project bndtools by bndtools.
the class IndexerWizardPage method updateInputs.
private void updateInputs() {
if (updateInputFilesJob != null) {
updateInputFilesJob.cancel();
}
inputPaths = Collections.emptyList();
setPageComplete(false);
vwrInputs.setInput(inputPaths);
lblInputCount.setText(String.format("%d resources found", inputPaths.size()));
lblInputCount.getParent().layout(new Control[] { lblInputCount });
final String resourcePattern = this.resourcePattern;
final Display display = getShell().getDisplay();
if (baseDir == null)
return;
updateInputFilesJob = new SearchFilesJob(baseDir, resourcePattern);
updateInputFilesJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
final IStatus status = updateInputFilesJob.getSearchResult();
display.syncExec(new Runnable() {
@Override
public void run() {
inputPaths = updateInputFilesJob.getPaths();
if (inputPaths == null)
inputPaths = Collections.emptyList();
if (status.isOK())
vwrInputs.setInput(updateInputFilesJob.getPaths());
else
// The error/warning status is displayed in the table instead of the path list
vwrInputs.setInput(Collections.singleton(status));
lblInputCount.setText(String.format("%d resources found", inputPaths.size()));
lblInputCount.getParent().layout(new Control[] { lblInputCount });
validate();
}
});
}
});
updateInputFilesJob.setSystem(true);
updateInputFilesJob.schedule(500);
vwrInputs.setInput(Collections.singleton(new Status(IStatus.INFO, Plugin.PLUGIN_ID, 0, Messages.IndexerWizardPage_checking, null)));
lblInputCount.setText("...");
lblInputCount.getParent().layout(new Control[] { lblInputCount });
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project yamcs-studio by yamcs.
the class PreloadingRepositoryHandler method doExecuteAndLoad.
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);
}
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project translationstudio8 by heartsome.
the class PreloadingRepositoryHandler method doExecuteAndLoad.
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);
}
}
Aggregations