Search in sources :

Example 11 with IResourceWrapper

use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.

the class ScaleDeploymentContributionItem method isRelevant.

private boolean isRelevant() {
    ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
    ISelection selection = service != null ? service.getSelection() : null;
    if (selection == null || selection.isEmpty()) {
        return false;
    }
    IRunningPodHolder podHolder = UIUtils.getFirstElement(selection, IRunningPodHolder.class);
    if (podHolder == null) {
        return false;
    }
    IOpenshiftUIElement<?, IOpenshiftUIElement<?, ?>> podUIElement = podHolder.getPodUIElement();
    if (!(podUIElement instanceof IResourceWrapper)) {
        return false;
    }
    IResourceWrapper<?, ?> podWrapper = (IResourceWrapper<?, ?>) podUIElement;
    if (ResourceWrapperUtils.getServiceWrapperFor(podWrapper, serviceWrapper -> ResourceUtils.areRelated((IPod) podWrapper.getWrapped(), (IService) serviceWrapper.getWrapped())) == null) {
        return false;
    }
    return true;
}
Also used : IOpenshiftUIElement(org.jboss.tools.openshift.internal.ui.models.IOpenshiftUIElement) ISelectionService(org.eclipse.ui.ISelectionService) OpenShiftImages(org.jboss.tools.openshift.internal.ui.OpenShiftImages) CompoundContributionItem(org.eclipse.ui.actions.CompoundContributionItem) PlatformUI(org.eclipse.ui.PlatformUI) ResourceWrapperUtils(org.jboss.tools.openshift.internal.ui.utils.ResourceWrapperUtils) ResourceUtils(org.jboss.tools.openshift.internal.core.util.ResourceUtils) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) HashMap(java.util.HashMap) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IPod(com.openshift.restclient.model.IPod) UIUtils(org.jboss.tools.openshift.internal.common.ui.utils.UIUtils) MenuItem(org.eclipse.swt.widgets.MenuItem) IWorkbenchContribution(org.eclipse.ui.menus.IWorkbenchContribution) IRunningPodHolder(org.jboss.tools.openshift.internal.ui.models.IRunningPodHolder) Map(java.util.Map) SWT(org.eclipse.swt.SWT) IContributionItem(org.eclipse.jface.action.IContributionItem) ISelection(org.eclipse.jface.viewers.ISelection) IServiceLocator(org.eclipse.ui.services.IServiceLocator) Menu(org.eclipse.swt.widgets.Menu) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) IOpenshiftUIElement(org.jboss.tools.openshift.internal.ui.models.IOpenshiftUIElement) IService(com.openshift.restclient.model.IService) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IRunningPodHolder(org.jboss.tools.openshift.internal.ui.models.IRunningPodHolder) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService)

Aggregations

IResourceWrapper (org.jboss.tools.openshift.internal.ui.models.IResourceWrapper)11 IResource (com.openshift.restclient.model.IResource)4 ResourceKind (com.openshift.restclient.ResourceKind)3 ISelection (org.eclipse.jface.viewers.ISelection)3 Viewer (org.eclipse.jface.viewers.Viewer)3 IPod (com.openshift.restclient.model.IPod)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 JobGroup (org.eclipse.core.runtime.jobs.JobGroup)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 SWT (org.eclipse.swt.SWT)2 ConnectionsRegistry (org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry)2 Connection (org.jboss.tools.openshift.core.connection.Connection)2 DeleteResourceJob (org.jboss.tools.openshift.internal.core.job.DeleteResourceJob)2 ResourceUtils (org.jboss.tools.openshift.internal.core.util.ResourceUtils)2 IConnectionWrapper (org.jboss.tools.openshift.internal.ui.models.IConnectionWrapper)2 IElementListener (org.jboss.tools.openshift.internal.ui.models.IElementListener)2