Search in sources :

Example 1 with Component

use of org.jboss.tools.openshift.core.odo.Component 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)

Aggregations

IOException (java.io.IOException)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 Status (org.eclipse.core.runtime.Status)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 Window (org.eclipse.jface.window.Window)1 IWizard (org.eclipse.jface.wizard.IWizard)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 Odo (org.jboss.tools.openshift.core.odo.Odo)1 OpenShiftUIActivator (org.jboss.tools.openshift.internal.ui.OpenShiftUIActivator)1 ComponentElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement)1 LinkComponentWizard (org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkComponentWizard)1 LinkModel (org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkModel)1