use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.
the class DeployImageWizard method performFinish.
@Override
public boolean performFinish() {
// checks if we need to push the image, first
final Job job = getJobChain(getModel());
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
final IStatus status = event.getResult();
UsageStats.getInstance().newV3Application(getModel().getConnection().getHost(), isFailed(status));
super.done(event);
}
});
job.schedule();
return true;
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.
the class ImportApplicationWizard method createImportJob.
private void createImportJob(boolean reuseGitRepository) {
if (reuseGitRepository) {
this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath(), model.isCheckoutBranchReusedRepo());
} else {
this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath());
}
String gitContextDir = model.getGitContextDir();
if (StringUtils.isNotEmpty(gitContextDir)) {
importJob.setFilters(Collections.singleton(gitContextDir));
}
importJob.setUser(true);
importJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
boolean success = JobUtils.isOk(importJob.getResult());
if (success) {
saveRepoPath();
}
UsageStats.getInstance().importV3Application(model.getConnection().getHost(), success);
}
});
for (IJobChangeListener importJobChangeListener : importJobChangeListenersList) {
importJob.addJobChangeListener(importJobChangeListener);
}
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.
the class NewResourceWizard method performFinish.
@Override
public boolean performFinish() {
boolean success = false;
try (InputStream is = (OpenshiftUIConstants.URL_VALIDATOR.isValid(model.getSource())) ? new URL(model.getSource()).openStream() : new FileInputStream(VariablesHelper.replaceVariables(model.getSource()))) {
final CreateResourceJob createJob = new CreateResourceJob(model.getProject(), is);
createJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
IStatus status = event.getResult();
if (JobUtils.isOk(status) || JobUtils.isWarning(status)) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
new ResourceSummaryDialog(getShell(), createJob.getResource(), "Create Resource Summary", "Results of creating the resource(s)").open();
}
});
OpenShiftUIUtils.showOpenShiftExplorer();
}
}
});
IStatus status = runInWizard(createJob, createJob.getDelegatingProgressMonitor(), getContainer());
success = isSuccess(status);
} catch (InvocationTargetException | InterruptedException | IOException e) {
page.setErrorMessage(e.getClass().getName() + ": " + e.getLocalizedMessage());
success = false;
}
return success;
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project jbosstools-openshift by jbosstools.
the class DeployImageHandler method runWizard.
public void runWizard(final Shell shell, final IDockerConnection dockerConnection, final IDockerImage image, final IProject project, final Connection connection) {
if (connection != null) {
final boolean[] authorized = new boolean[1];
Job job = new AbstractDelegatingMonitorJob("Checking connection...") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
authorized[0] = connection.isAuthorized(new NullProgressMonitor());
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(Status.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Unable to load the OpenShift projects for the selected connection.", e);
}
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
shell.getDisplay().asyncExec(() -> {
DeployImageWizard wizard = new DeployImageWizard(dockerConnection, image, connection, project, authorized[0]);
WizardUtils.openWizardDialog(500, 500, wizard, shell);
});
}
});
job.schedule();
} else {
DeployImageWizard wizard = new DeployImageWizard(dockerConnection, image, connection, project, false);
WizardUtils.openWizardDialog(600, 1500, wizard, shell);
}
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent 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