Search in sources :

Example 6 with Odo

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

the class DescribeHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    ComponentElement component = UIUtils.getFirstElement(selection, ComponentElement.class);
    ServiceElement service = null;
    ApplicationElement application = null;
    if (component == null) {
        service = UIUtils.getFirstElement(selection, ServiceElement.class);
        if (service == null) {
            application = UIUtils.getFirstElement(selection, ApplicationElement.class);
            if (application == null) {
                return OpenShiftUIActivator.statusFactory().cancelStatus(// $NON-NLS-1$
                "No application, component or service selected");
            }
        }
    }
    try {
        Odo odo = component != null ? component.getRoot().getOdo() : service != null ? service.getRoot().getOdo() : application.getRoot().getOdo();
        final ServiceElement fService = service;
        final ApplicationElement fApplication = application;
        executeInJob("Describe", monitor -> execute(odo, component, fService, fApplication));
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : ApplicationElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement) ISelection(org.eclipse.jface.viewers.ISelection) Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException) ComponentElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement) ServiceElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement)

Example 7 with Odo

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

the class LinkComponentHandler 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<Component> targetComponents = odo.getComponents(projectName, applicationName).stream().filter(comp -> !comp.getName().equals(component.getWrapped().getName())).collect(Collectors.toList());
        if (targetComponents.isEmpty()) {
            MessageDialog.openError(shell, "Link component", "No component available to link to.");
        } else {
            final LinkModel<Component> model = new LinkModel<>(odo, projectName, applicationName, component.getWrapped().getName(), targetComponents);
            final IWizard linkComponentWizard = new LinkComponentWizard(model);
            if (WizardUtils.openWizardDialog(linkComponentWizard, shell) == Window.OK) {
                executeInJob("Link component", monitor -> execute(shell, model, component));
            }
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : Component(org.jboss.tools.openshift.core.odo.Component) Shell(org.eclipse.swt.widgets.Shell) LinkComponentWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkComponentWizard) IWizard(org.eclipse.jface.wizard.IWizard) Status(org.eclipse.core.runtime.Status) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) Odo(org.jboss.tools.openshift.core.odo.Odo) Collectors(java.util.stream.Collectors) List(java.util.List) Window(org.eclipse.jface.window.Window) WizardUtils(org.jboss.tools.common.ui.WizardUtils) LinkModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkModel) ComponentElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement) LabelNotification(org.jboss.tools.common.ui.notification.LabelNotification) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) OpenShiftUIActivator(org.jboss.tools.openshift.internal.ui.OpenShiftUIActivator) LinkComponentWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkComponentWizard) IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException) Component(org.jboss.tools.openshift.core.odo.Component) LinkModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkModel)

Example 8 with Odo

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

the class DebugHandler method execute.

@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
    try {
        Odo odo = component.getRoot().getOdo();
        String project = component.getParent().getParent().getWrapped();
        String application = component.getParent().getWrapped().getName();
        ComponentInfo info = odo.getComponentInfo(project, application, component.getWrapped().getName(), component.getWrapped().getPath(), component.getWrapped().getInfo().getComponentKind());
        RemoteStackDebugger remoteDebugger = RemoteStackProviderRegistry.getInstance().findBytype(info.getComponentTypeName(), info.getComponentTypeVersion());
        if (remoteDebugger != null) {
            DebugInfo debugInfo = odo.debugInfo(project, application, component.getWrapped().getPath(), component.getWrapped().getName());
            int port = debugInfo.getStatus() == DebugStatus.RUNNING ? debugInfo.getLocalPort() : allocateLocalPort();
            if (debugInfo.getStatus() != DebugStatus.RUNNING) {
                executeInJob("Debug", monitor -> startDebug(odo, project, application, component, port));
            }
            executeInJob("Attach debugger", monitor -> createAndLaunchConfig(odo, project, application, component.getWrapped(), info, port, remoteDebugger, monitor, shell));
        } else {
            MessageDialog.openError(shell, "Debug", "Debugging is not supported for this type of component");
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : RemoteStackDebugger(org.jboss.tools.openshift.core.stack.RemoteStackDebugger) Odo(org.jboss.tools.openshift.core.odo.Odo) ComponentInfo(org.jboss.tools.openshift.core.odo.ComponentInfo) IOException(java.io.IOException) DebugInfo(org.jboss.tools.openshift.core.odo.DebugInfo)

Example 9 with Odo

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

the class CreateStorageHandler 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 CreateStorageModel model = new CreateStorageModel(odo, projectName, applicationName, component.getWrapped().getName(), Storage.getSizes());
        final IWizard createStorageWizard = new CreateStorageWizard(model);
        if (WizardUtils.openWizardDialog(createStorageWizard, shell) == Window.OK) {
            executeInJob("Create storage", monitor -> execute(model, component));
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : CreateStorageWizard(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateStorageWizard) CreateStorageModel(org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.CreateStorageModel) IWizard(org.eclipse.jface.wizard.IWizard) Odo(org.jboss.tools.openshift.core.odo.Odo) IOException(java.io.IOException)

Example 10 with Odo

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

the class DeleteHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    AbstractOpenshiftUIElement<?, ?, ?> element = UIUtils.getFirstElement(selection, AbstractOpenshiftUIElement.class);
    if (element == null) {
        return OpenShiftUIActivator.statusFactory().cancelStatus(// $NON-NLS-1$
        "No element selected");
    }
    try {
        String label = getLabel(element);
        if (MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), String.join(" ", "Delete", label), String.join(" ", "Are you sure to delete", label, "?"))) {
            Odo odo = ((ApplicationExplorerUIModel) element.getRoot()).getOdo();
            executeInJob("Delete", monitor -> execute(odo, element));
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) ISelection(org.eclipse.jface.viewers.ISelection) 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