Search in sources :

Example 1 with DevfileRegistryComponentTypeStarterElement

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeStarterElement 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);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ApplicationElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement) ProjectElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement) DevfileRegistryComponentTypeElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeElement) DevfileRegistryComponentTypeStarterElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeStarterElement) ISelection(org.eclipse.jface.viewers.ISelection) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ISelection (org.eclipse.jface.viewers.ISelection)1 Shell (org.eclipse.swt.widgets.Shell)1 ApplicationElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement)1 DevfileRegistryComponentTypeElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeElement)1 DevfileRegistryComponentTypeStarterElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryComponentTypeStarterElement)1 ProjectElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement)1