Search in sources :

Example 1 with Odo

use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.

the class CreateComponentHandler method openDialog.

private static void openDialog(DevfileRegistryComponentTypeElement componentType, ApplicationElement application, ProjectElement project, final Shell parent) throws IOException {
    Odo odo = project != null ? project.getParent().getOdo() : componentType.getRoot().getOdo();
    String projectName = project != null ? project.getWrapped() : odo.getNamespace();
    IProject eclipseProject = getOpenedProject();
    final CreateComponentModel model = new CreateComponentModel(odo, odo.getComponentTypes(), projectName, application == null ? null : application.getWrapped().getName(), eclipseProject);
    if (componentType != null) {
        model.setSelectedComponentType(componentType.getWrapped());
    }
    final IWizard createComponentWizard = new CreateComponentWizard(model);
    if (WizardUtils.openWizardDialog(createComponentWizard, parent) == Window.OK) {
        AbstractOpenshiftUIElement<?, ?, ApplicationExplorerUIModel> element = componentType != null ? componentType.getRoot() : application == null ? project : application;
        executeInJob("Creating component", monitor -> execute(parent, model, element));
    }
}
Also used : CreateComponentWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateComponentWizard) ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) CreateComponentModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateComponentModel) IProject(org.eclipse.core.resources.IProject)

Example 2 with Odo

use of org.jboss.tools.openshift.core.odo.Odo 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);
    }
}
Also used : ApplicationElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement) ProjectElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement) ServiceTemplate(org.jboss.tools.openshift.core.odo.ServiceTemplate) ISelection(org.eclipse.jface.viewers.ISelection) IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException) CreateServiceWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateServiceWizard)

Example 3 with Odo

use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.

the class CreateURLHandler method execute.

@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
    try {
        Odo odo = component.getRoot().getOdo();
        String projectName = component.getParent().getParent().getWrapped();
        String applicationName = component.getParent().getWrapped().getName();
        final CreateURLModel model = new CreateURLModel(odo, projectName, applicationName, component.getWrapped().getName());
        final IWizard createURLWizard = new CreateURLWizard(model);
        if (WizardUtils.openWizardDialog(createURLWizard, shell) == Window.OK) {
            executeInJob("Create url", monitor -> execute(model, component));
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) CreateURLModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateURLModel) CreateURLWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateURLWizard) IOException(java.io.IOException)

Example 4 with Odo

use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.

the class LinkServiceHandler method execute.

@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
    try {
        Odo odo = component.getRoot().getOdo();
        String projectName = component.getParent().getParent().getWrapped();
        String applicationName = component.getParent().getWrapped().getName();
        List<Service> serviceNames = odo.getServices(projectName, applicationName);
        final LinkModel<Service> model = new LinkModel<>(odo, projectName, applicationName, component.getWrapped().getName(), serviceNames);
        final IWizard linkServiceWizard = new LinkServiceWizard(model);
        if (WizardUtils.openWizardDialog(linkServiceWizard, shell) == Window.OK) {
            executeInJob("Link service", monitor -> execute(shell, model, component));
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : LinkServiceWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkServiceWizard) Service(org.jboss.tools.openshift.core.odo.Service) IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException) LinkModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkModel)

Example 5 with Odo

use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.

the class UndeployHandler method execute.

@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
    try {
        Odo odo = component.getRoot().getOdo();
        executeInJob("Undeploy", monitor -> execute(odo, component));
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException)

Aggregations

Odo (org.jboss.tools.openshift.core.odo.Odo)11 IOException (java.io.IOException)9 IWizard (org.eclipse.jface.wizard.IWizard)6 ISelection (org.eclipse.jface.viewers.ISelection)3 ApplicationExplorerUIModel (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel)3 ApplicationElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement)2 ComponentElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement)2 LinkModel (org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkModel)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IProject (org.eclipse.core.resources.IProject)1 Status (org.eclipse.core.runtime.Status)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 Window (org.eclipse.jface.window.Window)1 Shell (org.eclipse.swt.widgets.Shell)1 WizardUtils (org.jboss.tools.common.ui.WizardUtils)1 LabelNotification (org.jboss.tools.common.ui.notification.LabelNotification)1 Component (org.jboss.tools.openshift.core.odo.Component)1 ComponentInfo (org.jboss.tools.openshift.core.odo.ComponentInfo)1