Search in sources :

Example 1 with ApplicationExplorerUIModel

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel 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 ApplicationExplorerUIModel

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.

the class ListComponentsHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    ApplicationExplorerUIModel cluster = UIUtils.getFirstElement(selection, ApplicationExplorerUIModel.class);
    if (cluster == null) {
        // $NON-NLS-1$
        return OpenShiftUIActivator.statusFactory().cancelStatus("No cluster selected");
    }
    try {
        cluster.getOdo().listComponents();
    } catch (IOException e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
    return null;
}
Also used : ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) ISelection(org.eclipse.jface.viewers.ISelection) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 3 with ApplicationExplorerUIModel

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.

the class OpenConsoleHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    ApplicationExplorerUIModel cluster = UIUtils.getFirstElement(selection, ApplicationExplorerUIModel.class);
    if (cluster == null) {
        // $NON-NLS-1$
        return OpenShiftUIActivator.statusFactory().cancelStatus("No cluster selected");
    }
    try {
        String url = cluster.getOdo().consoleURL();
        new BrowserUtility().checkedCreateInternalBrowser(url, url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
    } catch (IOException e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
    return null;
}
Also used : ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) ISelection(org.eclipse.jface.viewers.ISelection) BrowserUtility(org.jboss.tools.foundation.ui.util.BrowserUtility) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 4 with ApplicationExplorerUIModel

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.

the class ListServicesHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    ApplicationExplorerUIModel cluster = UIUtils.getFirstElement(selection, ApplicationExplorerUIModel.class);
    if (cluster == null) {
        // $NON-NLS-1$
        return OpenShiftUIActivator.statusFactory().cancelStatus("No cluster selected");
    }
    try {
        cluster.getOdo().listServices();
    } catch (IOException e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
    return null;
}
Also used : ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) ISelection(org.eclipse.jface.viewers.ISelection) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 5 with ApplicationExplorerUIModel

use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.

the class AboutHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    ApplicationExplorerUIModel cluster = UIUtils.getFirstElement(selection, ApplicationExplorerUIModel.class);
    if (cluster == null) {
        // $NON-NLS-1$
        return OpenShiftUIActivator.statusFactory().cancelStatus("No cluster selected");
    }
    try {
        cluster.getOdo().about();
    } catch (IOException e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
    return null;
}
Also used : ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) ISelection(org.eclipse.jface.viewers.ISelection) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

ApplicationExplorerUIModel (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel)12 IOException (java.io.IOException)8 ISelection (org.eclipse.jface.viewers.ISelection)8 ExecutionException (org.eclipse.core.commands.ExecutionException)5 Odo (org.jboss.tools.openshift.core.odo.Odo)3 ArrayList (java.util.ArrayList)2 Shell (org.eclipse.swt.widgets.Shell)2 ApplicationElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement)2 ProjectElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 IProject (org.eclipse.core.resources.IProject)1 IWizard (org.eclipse.jface.wizard.IWizard)1 BrowserUtility (org.jboss.tools.foundation.ui.util.BrowserUtility)1 OpenShiftApplicationExplorerContentProvider (org.jboss.tools.openshift.internal.ui.applicationexplorer.OpenShiftApplicationExplorerContentProvider)1 ClusterClient (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel.ClusterClient)1 ComponentElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement)1 ServiceElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement)1 StorageElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement)1 URLElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.URLElement)1 OdoCliFactory (org.jboss.tools.openshift.internal.ui.odo.OdoCliFactory)1