use of org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateServiceWizard in project jbosstools-openshift by jbosstools.
the class CreateServiceHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
ApplicationElement application = null;
ProjectElement project = UIUtils.getFirstElement(selection, ProjectElement.class);
if (project == null) {
application = UIUtils.getFirstElement(selection, ApplicationElement.class);
if (application == null) {
// $NON-NLS-1$
return OpenShiftUIActivator.statusFactory().cancelStatus("No project or application selected");
}
project = application.getParent();
}
try {
Odo odo = project.getParent().getOdo();
List<ServiceTemplate> templates = odo.getServiceTemplates();
if (!templates.isEmpty()) {
final IWizard createServiceWizard = new CreateServiceWizard(templates, project.getWrapped(), application == null ? "" : application.getWrapped().getName(), odo);
if (WizardUtils.openWizardDialog(createServiceWizard, HandlerUtil.getActiveShell(event)) == Window.OK) {
if (application == null) {
project.refresh();
} else {
application.refresh();
}
}
} else {
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "Create service", "No operators installed on your cluster, can't create services");
}
return Status.OK_STATUS;
} catch (IOException e) {
String title = "Unable to create service";
String message = e.getMessage();
MessageDialog.open(MessageDialog.ERROR, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message, SWT.NONE);
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
Aggregations