Search in sources :

Example 1 with LoadingStub

use of org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerContentProvider method getConnectionChildren.

protected Object[] getConnectionChildren(IConnectionWrapper connection) {
    switch(connection.getState()) {
        case LOADED:
            removeStub(connection);
            Object[] result = connection.getResources().toArray();
            if (result == null || result.length == 0) {
                result = new Object[] { new NewProjectLinkNode((Connection) connection.getWrapped()) };
            }
            return result;
        case LOAD_STOPPED:
            LoadingStub stub = removeStub(connection);
            if (stub != null) {
                return stub.getChildren();
            }
        default:
            connection.load(e -> handleLoadingException(connection, e));
            return new Object[] { makeStub(connection) };
    }
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub)

Example 2 with LoadingStub

use of org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerContentProvider method handleLoadingException.

private void handleLoadingException(Object parentElement, Throwable e) {
    LoadingStub stub = makeStub(parentElement);
    stub.add(e);
    asyncExec(() -> refreshViewer(parentElement));
}
Also used : LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub)

Example 3 with LoadingStub

use of org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerContentProvider method getProjectChildren.

protected Object[] getProjectChildren(IProjectWrapper project) {
    switch(project.getState()) {
        case LOADED:
            removeStub(project);
            Collection<IResourceWrapper<?, ?>> services = project.getResourcesOfKind(ResourceKind.SERVICE);
            Collection<IReplicationControllerWrapper> dcs = project.getResourcesOfType(IReplicationControllerWrapper.class);
            services.addAll(dcs);
            Collection<IResourceWrapper<?, ?>> pods = project.getResourcesOfKind(ResourceKind.POD).stream().filter(wrapper -> ResourceUtils.isRuntimePod((IPod) wrapper.getWrapped()) && !((IPod) wrapper.getWrapped()).isAnnotatedWith(OpenShiftAPIAnnotations.DEPLOYMENT_NAME)).collect(Collectors.toList());
            services.addAll(pods);
            return services.toArray();
        case LOAD_STOPPED:
            LoadingStub stub = removeStub(project);
            if (stub != null) {
                return stub.getChildren();
            }
        default:
            project.load(e -> {
                handleLoadingException(project, e);
            });
            return new Object[] { makeStub(project) };
    }
}
Also used : IReplicationControllerWrapper(org.jboss.tools.openshift.internal.ui.models.IReplicationControllerWrapper) Arrays(java.util.Arrays) ResourceUtils(org.jboss.tools.openshift.internal.core.util.ResourceUtils) HashMap(java.util.HashMap) IConnectionWrapper(org.jboss.tools.openshift.internal.ui.models.IConnectionWrapper) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) ArrayList(java.util.ArrayList) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IPod(com.openshift.restclient.model.IPod) Map(java.util.Map) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ConnectionsRegistry(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry) Viewer(org.eclipse.jface.viewers.Viewer) ResourceKind(com.openshift.restclient.ResourceKind) Collection(java.util.Collection) IBuild(com.openshift.restclient.model.IBuild) OpenshiftUIModel(org.jboss.tools.openshift.internal.ui.models.OpenshiftUIModel) IReplicationControllerWrapper(org.jboss.tools.openshift.internal.ui.models.IReplicationControllerWrapper) Collectors(java.util.stream.Collectors) LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub) IResourceContainer(org.jboss.tools.openshift.internal.ui.models.IResourceContainer) IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) Connection(org.jboss.tools.openshift.core.connection.Connection) List(java.util.List) OpenShiftAPIAnnotations(org.jboss.tools.openshift.core.OpenShiftAPIAnnotations) IRoute(com.openshift.restclient.model.route.IRoute) BaseExplorerContentProvider(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider) IProjectWrapper(org.jboss.tools.openshift.internal.ui.models.IProjectWrapper) ConnectionsRegistrySingleton(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistrySingleton) IElementListener(org.jboss.tools.openshift.internal.ui.models.IElementListener) IOpenshiftUIElement(org.jboss.tools.openshift.internal.ui.models.IOpenshiftUIElement) Control(org.eclipse.swt.widgets.Control) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub) IPod(com.openshift.restclient.model.IPod)

Example 4 with LoadingStub

use of org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerContentProvider method makeStub.

private LoadingStub makeStub(Object parentElement) {
    synchronized (stubs) {
        LoadingStub stub = stubs.get(parentElement);
        if (stub == null) {
            stub = new LoadingStub();
            stubs.put(parentElement, stub);
        }
        return stub;
    }
}
Also used : LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub)

Aggregations

LoadingStub (org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub)4 Connection (org.jboss.tools.openshift.core.connection.Connection)2 ResourceKind (com.openshift.restclient.ResourceKind)1 IBuild (com.openshift.restclient.model.IBuild)1 IPod (com.openshift.restclient.model.IPod)1 IRoute (com.openshift.restclient.model.route.IRoute)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 Control (org.eclipse.swt.widgets.Control)1 ConnectionsRegistry (org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry)1 ConnectionsRegistrySingleton (org.jboss.tools.openshift.common.core.connection.ConnectionsRegistrySingleton)1 OpenShiftAPIAnnotations (org.jboss.tools.openshift.core.OpenShiftAPIAnnotations)1