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