job.schedule();
}
}
protected Job getJob() {
Job job = new Job(getJobName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
try {
ICloudFoundryOperation operation = getOperation(monitor);
if (operation == null) {
return CloudFoundryPlugin.getStatus(Messages.CloudFoundryEditorAction_TEXT_NO_OP_EXECUTE, IStatus.WARNING);
}
operation.run(monitor);
}
catch (CoreException e) {
CloudFoundryException cfe = e.getCause() instanceof CloudFoundryException ? (CloudFoundryException) e
.getCause() : null;
if (cfe instanceof NotFinishedStagingException) {
status = new Status(IStatus.WARNING, CloudFoundryServerUiPlugin.PLUGIN_ID,
Messages.CloudFoundryEditorAction_WARNING_RESTART_APP);
}
else if (shouldLogException(e)) {
status = new Status(Status.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID, e.getMessage(), e);
}
else {
status = new Status(Status.CANCEL, CloudFoundryServerUiPlugin.PLUGIN_ID, e.getMessage(), e);
}
}
return status;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {