use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel 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.ApplicationExplorerUIModel 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.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.
the class DeleteHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
AbstractOpenshiftUIElement<?, ?, ?> element = UIUtils.getFirstElement(selection, AbstractOpenshiftUIElement.class);
if (element == null) {
return OpenShiftUIActivator.statusFactory().cancelStatus(// $NON-NLS-1$
"No element selected");
}
try {
String label = getLabel(element);
if (MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), String.join(" ", "Delete", label), String.join(" ", "Are you sure to delete", label, "?"))) {
Odo odo = ((ApplicationExplorerUIModel) element.getRoot()).getOdo();
executeInJob("Delete", monitor -> execute(odo, element));
}
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.
the class LoginHandler 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 {
openDialog(HandlerUtil.getActiveShell(event), cluster);
return Status.OK_STATUS;
} catch (IOException e) {
throw new ExecutionException(e.getLocalizedMessage(), e);
}
}
use of org.jboss.tools.openshift.internal.ui.models.applicationexplorer.ApplicationExplorerUIModel in project jbosstools-openshift by jbosstools.
the class OpenShiftApplicationExplorerContentProviderTest method setup.
@Before
public void setup() throws Exception {
odo = mock(Odo.class);
ClusterClient info = mock(ClusterClient.class);
doReturn(odo).when(info).getOdo();
OdoCliFactory factory = mock(OdoCliFactory.class);
doReturn(CompletableFuture.completedFuture(odo)).when(factory).getOdo();
this.model = new ApplicationExplorerUIModel(info) {
@Override
protected OdoCliFactory getFactory() {
return factory;
}
};
this.provider = new OpenShiftApplicationExplorerContentProvider(model) {
};
}
Aggregations