use of org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob in project jbosstools-openshift by jbosstools.
the class RefreshResourceHandler method createRefreshJob.
private Job createRefreshJob(IOpenshiftUIElement<?, ?> element) {
return new AbstractDelegatingMonitorJob(LOADING_OPEN_SHIFT_INFORMATIONS) {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
monitor.beginTask(LOADING_OPEN_SHIFT_INFORMATIONS, IProgressMonitor.UNKNOWN);
element.refresh();
} catch (OpenShiftException e) {
OpenShiftCommonUIActivator.getDefault().getLogger().logError(FAILED_TO_REFRESH_ELEMENT, e);
return new Status(Status.ERROR, OpenShiftCommonUIActivator.PLUGIN_ID, FAILED_TO_REFRESH_ELEMENT, e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
}
use of org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method loadBuildConfigs.
private void loadBuildConfigs(final IBuildConfigPageModel model) {
try {
AbstractDelegatingMonitorJob job = new AbstractDelegatingMonitorJob("Loading build configs...") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
model.loadBuildConfigs();
return Status.OK_STATUS;
}
};
WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer());
} catch (InvocationTargetException | InterruptedException e) {
// intentionnally swallowed
}
}
use of org.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob 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(new Runnable() {
@Override
public void run() {
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.jboss.tools.openshift.internal.common.core.job.AbstractDelegatingMonitorJob in project jbosstools-openshift by jbosstools.
the class AbstractProjectPage method getLoadResourcesJobBuilder.
/**
* Create and configure the list of jobs that need to be performed during
* resource loading. The base behavior is to load the projects and force project
* creation if no project exists.
*
* @param closeAfter
* return parameter if wizard needs to be closed (may be updated)
* @param closeOnCancel
* true if the wizard need to be closed
* @return the job builder
*/
protected JobChainBuilder getLoadResourcesJobBuilder(final boolean[] closeAfter, final boolean closeOnCancel) {
JobChainBuilder builder = new JobChainBuilder(new AbstractDelegatingMonitorJob("Loading projects...") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
model.loadResources();
} catch (OpenShiftException e) {
closeAfter[0] = closeOnCancel;
String problem = e.getStatus() == null ? e.getMessage() : e.getStatus().getMessage();
return OpenShiftUIActivator.statusFactory().errorStatus(problem, e);
}
return Status.OK_STATUS;
}
});
builder.runWhenSuccessfullyDone(new UIJob("Verifying required project...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!model.hasProjects()) {
List<IProject> projects = new ObservableTreeItem2ModelConverter().convert(model.getProjectItems());
Connection connection = model.getConnection();
NewProjectWizard newProjectWizard = new NewProjectWizard(connection, projects);
if (Dialog.CANCEL == WizardUtils.openWizardDialog(newProjectWizard, getShell())) {
closeAfter[0] = closeOnCancel;
return Status.CANCEL_STATUS;
} else {
model.loadResources();
model.setProject(newProjectWizard.getProject());
}
}
return Status.OK_STATUS;
}
});
return builder;
}
Aggregations