use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement 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" };
}
}
use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.StorageElement 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