diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterCopyFilterPoolAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterCopyFilterPoolAction.java index 5a039d1d7cf..5fd758e4957 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterCopyFilterPoolAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterCopyFilterPoolAction.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * David Dykstal (IBM) - [194268] fixed updateSelection to disable when selection is empty ********************************************************************************/ package org.eclipse.rse.internal.ui.actions; @@ -83,27 +84,26 @@ public class SystemFilterCopyFilterPoolAction extends SystemBaseCopyAction *

* @see SystemBaseAction#updateSelection(IStructuredSelection) */ - public boolean updateSelection(IStructuredSelection selection) - { - boolean enable = true; - /* */ - Iterator e= selection.iterator(); - while (enable && e.hasNext()) - { - Object selectedObject = e.next(); - if (selectedObject instanceof SystemSimpleContentElement) - selectedObject = ((SystemSimpleContentElement)selectedObject).getData(); - if (!(selectedObject instanceof ISystemFilterPool) && - !(selectedObject instanceof ISystemFilterPoolReference)) - enable = false; - // disable if this is a connection-unique filter pool - else if (selectedObject instanceof ISystemFilterPool) - enable = ((ISystemFilterPool)selectedObject).getOwningParentName() == null; - // disable if this is a connection-unique filter pool - else if (selectedObject instanceof ISystemFilterPoolReference) - enable = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool().getOwningParentName() == null; + public boolean updateSelection(IStructuredSelection selection) { + boolean enable = false; + if (!selection.isEmpty()) { + enable = true; + Iterator e = selection.iterator(); + while (enable && e.hasNext()) { + Object selectedObject = e.next(); + if (selectedObject instanceof SystemSimpleContentElement) { + selectedObject = ((SystemSimpleContentElement) selectedObject).getData(); + } + ISystemFilterPool pool = null; + if (selectedObject instanceof ISystemFilterPool) { + pool = (ISystemFilterPool) selectedObject; + } else if (selectedObject instanceof ISystemFilterPoolReference) { + pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool(); + } + // enable if this is not a connection specific filter pool + enable = (pool != null) && (pool.getOwningParentName() == null); + } } - /* */ return enable; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterMoveFilterPoolAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterMoveFilterPoolAction.java index 85adeb443ee..1f303ce5b97 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterMoveFilterPoolAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterMoveFilterPoolAction.java @@ -13,10 +13,13 @@ * Contributors: * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * David Dykstal (IBM) - [194268] fixed updateSelection() to disable when selection is empty ********************************************************************************/ package org.eclipse.rse.internal.ui.actions; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; @@ -86,45 +89,35 @@ public class SystemFilterMoveFilterPoolAction extends SystemBaseCopyAction *

* @see SystemBaseAction#updateSelection(IStructuredSelection) */ - public boolean updateSelection(IStructuredSelection selection) - { - boolean enable = true; - /* */ - Iterator e = selection.iterator(); - ISystemFilterPoolManager prevMgr = null; - ISystemFilterPoolManager currMgr = null; - ISystemFilterPool pool; - while (enable && e.hasNext()) - { - Object selectedObject = e.next(); - if (selectedObject instanceof SystemSimpleContentElement) - selectedObject = ((SystemSimpleContentElement)selectedObject).getData(); - if (!(selectedObject instanceof ISystemFilterPool) && - !(selectedObject instanceof ISystemFilterPoolReference)) - enable = false; - // disable if this is a connection-unique filter pool - else if (selectedObject instanceof ISystemFilterPool) - enable = ((ISystemFilterPool)selectedObject).getOwningParentName() == null; - // disable if this is a connection-unique filter pool - else if (selectedObject instanceof ISystemFilterPoolReference) - enable = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool().getOwningParentName() == null; - - if (enable) - { - if (selectedObject instanceof ISystemFilterPool) - pool = (ISystemFilterPool)selectedObject; - else - pool = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool(); - currMgr = pool.getSystemFilterPoolManager(); - if (prevMgr == null) - prevMgr = currMgr; - else - enable = (prevMgr == currMgr); - if (enable) - prevMgr = currMgr; + public boolean updateSelection(IStructuredSelection selection) { + boolean enable = false; + if (!selection.isEmpty()) { + enable = true; + Iterator e = selection.iterator(); + Set managers = new HashSet(); + while (enable && e.hasNext()) { + Object selectedObject = e.next(); + if (selectedObject instanceof SystemSimpleContentElement) { + selectedObject = ((SystemSimpleContentElement) selectedObject).getData(); + } + ISystemFilterPool pool = null; + if (selectedObject instanceof ISystemFilterPool){ + pool = (ISystemFilterPool) selectedObject; + } + else if (selectedObject instanceof ISystemFilterPoolReference) { + pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool(); + } + if (pool != null) { + String ownerName = pool.getOwningParentName(); + ISystemFilterPoolManager manager = pool.getSystemFilterPoolManager(); + managers.add(manager); + // enable if the number of managers is one and the owner name is null (i.e. the pool does not belong to a connection) + enable = (managers.size() == 1) && (ownerName == null); + } else { + enable = false; + } } } - /* */ return enable; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterWorkWithFilterPoolsAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterWorkWithFilterPoolsAction.java index 5d6ddd40a1a..88f338b5a9c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterWorkWithFilterPoolsAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemFilterWorkWithFilterPoolsAction.java @@ -12,7 +12,8 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David Dykstal (IBM) - [194268] action now assumes the first filter pool manager is selected if there was no selection + * provided by the caller. *******************************************************************************/ package org.eclipse.rse.internal.ui.actions; @@ -161,21 +162,22 @@ public class SystemFilterWorkWithFilterPoolsAction SystemFilterUIHelpers.getFilterPoolModel(getFilterPoolManagerProvider(), mgrs); return input; } + /** * Callback for dialog to refresh its contents */ - public SystemSimpleContentElement getTreeModelPreSelection(SystemSimpleContentElement input) - { - ISystemFilterPoolReferenceManagerProvider sprmp = getReferenceManagerProviderSelection(); + public SystemSimpleContentElement getTreeModelPreSelection(SystemSimpleContentElement input) { SystemSimpleContentElement initialElementSelection = null; - if (sprmp != null) - { + ISystemFilterPoolReferenceManagerProvider sprmp = getReferenceManagerProviderSelection(); + if (sprmp != null) { ISystemFilterPoolManager initialSelection = sprmp.getSystemFilterPoolReferenceManager().getDefaultSystemFilterPoolManager(); - if (initialSelection != null) - { - initialElementSelection = SystemFilterUIHelpers.getDataElement(input, initialSelection); - //if (initialElementSelection != null) - //dialog.setRootToPreselect(initialElementSelection); + if (initialSelection != null) { + initialElementSelection = SystemFilterUIHelpers.getDataElement(input, initialSelection); + } + } else { + SystemSimpleContentElement[] children = input.getChildren(); + if (children.length > 0) { + initialElementSelection = children[0]; } } return initialElementSelection; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/filters/dialogs/SystemFilterWorkWithFilterPoolsDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/filters/dialogs/SystemFilterWorkWithFilterPoolsDialog.java index bd105c7570a..28feef62df7 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/filters/dialogs/SystemFilterWorkWithFilterPoolsDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/filters/dialogs/SystemFilterWorkWithFilterPoolsDialog.java @@ -14,6 +14,7 @@ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * David Dykstal (IBM) - [197036] fixed delete filter pool bug found during testing of this bug * see also bug 194260 regarding deleting filter pools + * David Dykstal (IBM) - [194268] fixed initial selection and new action selection ********************************************************************************/ package org.eclipse.rse.internal.ui.filters.dialogs; @@ -602,24 +603,25 @@ public class SystemFilterWorkWithFilterPoolsDialog ISystemFilterPoolManager[] mgrs = filterPoolManagers; return mgrs; } + /** - * Callback from new action to get index of initial manager to select - */ - public int getFilterPoolManagerSelection() - { - int selection = 0; - SystemSimpleContentElement element = getSelectedElement(); - Object elementData = element.getData(); - if (elementData != null) - { - if (elementData instanceof ISystemFilterPoolManager) - selection = getManagerIndex((ISystemFilterPoolManager)elementData); - else if (elementData instanceof ISystemFilterPool) - selection = getManagerIndex(((ISystemFilterPool)elementData).getSystemFilterPoolManager()); - } - //System.out.println("In getFilterPoolManagerSelection(). Returning "+selection); - return selection; - } + * Callback from new action to get index of initial manager to select + */ + public int getFilterPoolManagerSelection() { + int selection = 0; + SystemSimpleContentElement element = getSelectedElement(); + if (element != null) { + Object elementData = element.getData(); + if (elementData != null) { + if (elementData instanceof ISystemFilterPoolManager) { + selection = getManagerIndex((ISystemFilterPoolManager) elementData); + } else if (elementData instanceof ISystemFilterPool) { + selection = getManagerIndex(((ISystemFilterPool) elementData).getSystemFilterPoolManager()); + } + } + } + return selection; + } private int getManagerIndex(ISystemFilterPoolManager mgr) {