use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeElement in project jbosstools-openshift by jbosstools.
the class CreateComponentHandler 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);
DevfileRegistryComponentTypeElement componentType = null;
if (project == null) {
application = UIUtils.getFirstElement(selection, ApplicationElement.class);
if (application == null) {
componentType = UIUtils.getFirstElement(selection, DevfileRegistryComponentTypeElement.class);
if (componentType == null) {
DevfileRegistryComponentTypeStarterElement starter = UIUtils.getFirstElement(selection, DevfileRegistryComponentTypeStarterElement.class);
if (starter == null) {
// $NON-NLS-1$
return OpenShiftUIActivator.statusFactory().cancelStatus("No project or application selected");
} else {
componentType = starter.getParent();
}
}
} else {
project = application.getParent();
}
}
final Shell parent = HandlerUtil.getActiveShell(event);
try {
openDialog(componentType, application, project, parent);
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
Aggregations