Search in sources :

Example 1 with URLElement

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

the class OpenShiftApplicationExplorerContentProvider method getChildren.

private Object[] getChildren(ComponentElement parentElement) {
    try {
        List<Object> childs = new ArrayList<>();
        ApplicationElement application = parentElement.getParent();
        ProjectElement project = application.getParent();
        ApplicationExplorerUIModel cluster = project.getParent();
        cluster.getOdo().getStorages(project.getWrapped(), application.getWrapped().getName(), parentElement.getWrapped().getPath(), parentElement.getWrapped().getName()).forEach(storage -> childs.add(new StorageElement(storage, parentElement)));
        cluster.getOdo().listURLs(project.getWrapped(), application.getWrapped().getName(), parentElement.getWrapped().getPath(), parentElement.getWrapped().getName()).forEach(url -> childs.add(new URLElement(url, parentElement)));
        return childs.toArray();
    } catch (IOException e) {
        return new Object[] { "Can't list storages or urls" };
    }
}
Also used : ApplicationElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement) ApplicationExplorerUIModel(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel) StorageElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement) ProjectElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URLElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.URLElement)

Example 2 with URLElement

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

the class DeleteHandler method execute.

private void execute(Odo odo, AbstractOpenshiftUIElement<?, ?, ?> element) {
    try {
        if (element instanceof ProjectElement) {
            odo.deleteProject(((ProjectElement) element).getWrapped());
        } else if (element instanceof ApplicationElement) {
            odo.deleteApplication(((ApplicationElement) element).getParent().getWrapped(), ((ApplicationElement) element).getWrapped().getName());
        } else if (element instanceof ComponentElement) {
            ComponentElement component = (ComponentElement) element;
            odo.deleteComponent(component.getParent().getParent().getWrapped(), component.getParent().getWrapped().getName(), component.getWrapped().getPath(), component.getWrapped().getName(), component.getWrapped().getInfo().getComponentKind());
            if (component.getWrapped().hasContext()) {
                component.getRoot().removeContext(component.getWrapped().getPath());
            }
        } else if (element instanceof ServiceElement) {
            odo.deleteService(((ServiceElement) element).getParent().getParent().getWrapped(), ((ServiceElement) element).getParent().getWrapped().getName(), ((ServiceElement) element).getWrapped());
        } else if (element instanceof URLElement) {
            odo.deleteURL(((URLElement) element).getParent().getParent().getParent().getWrapped(), ((URLElement) element).getParent().getParent().getWrapped().getName(), ((URLElement) element).getParent().getWrapped().getPath(), ((URLElement) element).getParent().getWrapped().getName(), ((URLElement) element).getWrapped().getName());
        } else if (element instanceof StorageElement) {
            odo.deleteStorage(((StorageElement) element).getParent().getParent().getParent().getWrapped(), ((StorageElement) element).getParent().getParent().getWrapped().getName(), ((StorageElement) element).getParent().getWrapped().getPath(), ((StorageElement) element).getParent().getWrapped().getName(), ((StorageElement) element).getWrapped().getName());
        } else if (element instanceof DevfileRegistryElement) {
            odo.deleteDevfileRegistry(((DevfileRegistryElement) element).getWrapped().getName());
        }
        element.getParent().refresh();
    } catch (IOException e) {
        Display.getDefault().asyncExec(() -> MessageDialog.openError(Display.getDefault().getActiveShell(), "Delete", "Delete error:" + e.getLocalizedMessage()));
    }
}
Also used : DevfileRegistryElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryElement) ApplicationElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement) StorageElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement) ProjectElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement) IOException(java.io.IOException) ComponentElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement) URLElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.URLElement) ServiceElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement)

Example 3 with URLElement

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

the class OpenInBrowserHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    URLElement urlElement = UIUtils.getFirstElement(selection, URLElement.class);
    if (urlElement == null) {
        // $NON-NLS-1$
        return OpenShiftUIActivator.statusFactory().cancelStatus("No url selected");
    }
    String url = urlElement.getWrapped().getProtocol() + "://" + urlElement.getWrapped().getHost();
    new BrowserUtility().checkedCreateInternalBrowser(url, url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
    return null;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) BrowserUtility(org.jboss.tools.foundation.ui.util.BrowserUtility) URLElement(org.jboss.tools.openshift.internal.ui.models.applicationexplorer.URLElement)

Aggregations

URLElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.URLElement)3 IOException (java.io.IOException)2 ApplicationElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationElement)2 ProjectElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ProjectElement)2 StorageElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement)2 ArrayList (java.util.ArrayList)1 ISelection (org.eclipse.jface.viewers.ISelection)1 BrowserUtility (org.jboss.tools.foundation.ui.util.BrowserUtility)1 ApplicationExplorerUIModel (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel)1 ComponentElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ComponentElement)1 DevfileRegistryElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.DevfileRegistryElement)1 ServiceElement (org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement)1