use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement 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);
}
}
use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement in project jbosstools-openshift by jbosstools.
the class OpenShiftApplicationExplorerContentProvider method getChildren.
private Object[] getChildren(ApplicationElement parentElement) {
List<Object> childs = new ArrayList<>();
try {
ProjectElement project = parentElement.getParent();
ApplicationExplorerUIModel cluster = project.getParent();
cluster.getOdo().getComponents(project.getWrapped(), parentElement.getWrapped().getName()).forEach(comp -> childs.add(new ComponentElement(comp, parentElement)));
cluster.getOdo().getServices(project.getWrapped(), parentElement.getWrapped().getName()).forEach(service -> childs.add(new ServiceElement(service, parentElement)));
} catch (IOException | KubernetesClientException e) {
if (childs.isEmpty()) {
return new Object[] { "Can't list components" };
}
}
if (childs.isEmpty()) {
childs.add(new CreateComponentMessageElement<ApplicationElement>(parentElement));
}
return childs.toArray();
}
use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ServiceElement 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()));
}
}
Aggregations