use of org.jboss.tools.openshift.internal.ui.wizard.project.NewProjectWizard 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