Search in sources :

Example 1 with IOpenshiftUIElement

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

IPod (com.openshift.restclient.model.IPod)1 IService (com.openshift.restclient.model.IService)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 ISelection (org.eclipse.jface.viewers.ISelection)1 SWT (org.eclipse.swt.SWT)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 ISelectionService (org.eclipse.ui.ISelectionService)1 PlatformUI (org.eclipse.ui.PlatformUI)1 CompoundContributionItem (org.eclipse.ui.actions.CompoundContributionItem)1 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)1 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)1 IWorkbenchContribution (org.eclipse.ui.menus.IWorkbenchContribution)1 IServiceLocator (org.eclipse.ui.services.IServiceLocator)1 UIUtils (org.jboss.tools.openshift.internal.common.ui.utils.UIUtils)1 ResourceUtils (org.jboss.tools.openshift.internal.core.util.ResourceUtils)1 OpenShiftImages (org.jboss.tools.openshift.internal.ui.OpenShiftImages)1 IOpenshiftUIElement (org.jboss.tools.openshift.internal.ui.models.IOpenshiftUIElement)1