1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-03 13:43:31 +02:00

[194268] fixed enablement issues in Work With Filter Pool dialog

RESOLVED - bug 194268: [Team] Work With Filter Pools Dialog Issue's
https://bugs.eclipse.org/bugs/show_bug.cgi?id=194268
This commit is contained in:
David Dykstal 2008-02-06 20:49:32 +00:00
parent 99b254c72b
commit 4a3477984f
4 changed files with 82 additions and 85 deletions

View file

@ -13,6 +13,7 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * 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 * 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; package org.eclipse.rse.internal.ui.actions;
@ -83,27 +84,26 @@ public class SystemFilterCopyFilterPoolAction extends SystemBaseCopyAction
* <p> * <p>
* @see SystemBaseAction#updateSelection(IStructuredSelection) * @see SystemBaseAction#updateSelection(IStructuredSelection)
*/ */
public boolean updateSelection(IStructuredSelection selection) public boolean updateSelection(IStructuredSelection selection) {
{ boolean enable = false;
boolean enable = true; if (!selection.isEmpty()) {
/* */ enable = true;
Iterator e= selection.iterator(); Iterator e = selection.iterator();
while (enable && e.hasNext()) while (enable && e.hasNext()) {
{ Object selectedObject = e.next();
Object selectedObject = e.next(); if (selectedObject instanceof SystemSimpleContentElement) {
if (selectedObject instanceof SystemSimpleContentElement) selectedObject = ((SystemSimpleContentElement) selectedObject).getData();
selectedObject = ((SystemSimpleContentElement)selectedObject).getData(); }
if (!(selectedObject instanceof ISystemFilterPool) && ISystemFilterPool pool = null;
!(selectedObject instanceof ISystemFilterPoolReference)) if (selectedObject instanceof ISystemFilterPool) {
enable = false; pool = (ISystemFilterPool) selectedObject;
// disable if this is a connection-unique filter pool } else if (selectedObject instanceof ISystemFilterPoolReference) {
else if (selectedObject instanceof ISystemFilterPool) pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool();
enable = ((ISystemFilterPool)selectedObject).getOwningParentName() == null; }
// disable if this is a connection-unique filter pool // enable if this is not a connection specific filter pool
else if (selectedObject instanceof ISystemFilterPoolReference) enable = (pool != null) && (pool.getOwningParentName() == null);
enable = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool().getOwningParentName() == null; }
} }
/* */
return enable; return enable;
} }

View file

@ -13,10 +13,13 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * 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 * 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; package org.eclipse.rse.internal.ui.actions;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -86,45 +89,35 @@ public class SystemFilterMoveFilterPoolAction extends SystemBaseCopyAction
* <p> * <p>
* @see SystemBaseAction#updateSelection(IStructuredSelection) * @see SystemBaseAction#updateSelection(IStructuredSelection)
*/ */
public boolean updateSelection(IStructuredSelection selection) public boolean updateSelection(IStructuredSelection selection) {
{ boolean enable = false;
boolean enable = true; if (!selection.isEmpty()) {
/* */ enable = true;
Iterator e = selection.iterator(); Iterator e = selection.iterator();
ISystemFilterPoolManager prevMgr = null; Set managers = new HashSet();
ISystemFilterPoolManager currMgr = null; while (enable && e.hasNext()) {
ISystemFilterPool pool; Object selectedObject = e.next();
while (enable && e.hasNext()) if (selectedObject instanceof SystemSimpleContentElement) {
{ selectedObject = ((SystemSimpleContentElement) selectedObject).getData();
Object selectedObject = e.next(); }
if (selectedObject instanceof SystemSimpleContentElement) ISystemFilterPool pool = null;
selectedObject = ((SystemSimpleContentElement)selectedObject).getData(); if (selectedObject instanceof ISystemFilterPool){
if (!(selectedObject instanceof ISystemFilterPool) && pool = (ISystemFilterPool) selectedObject;
!(selectedObject instanceof ISystemFilterPoolReference)) }
enable = false; else if (selectedObject instanceof ISystemFilterPoolReference) {
// disable if this is a connection-unique filter pool pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool();
else if (selectedObject instanceof ISystemFilterPool) }
enable = ((ISystemFilterPool)selectedObject).getOwningParentName() == null; if (pool != null) {
// disable if this is a connection-unique filter pool String ownerName = pool.getOwningParentName();
else if (selectedObject instanceof ISystemFilterPoolReference) ISystemFilterPoolManager manager = pool.getSystemFilterPoolManager();
enable = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool().getOwningParentName() == null; 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)
if (enable) enable = (managers.size() == 1) && (ownerName == null);
{ } else {
if (selectedObject instanceof ISystemFilterPool) enable = false;
pool = (ISystemFilterPool)selectedObject; }
else
pool = ((ISystemFilterPoolReference)selectedObject).getReferencedFilterPool();
currMgr = pool.getSystemFilterPoolManager();
if (prevMgr == null)
prevMgr = currMgr;
else
enable = (prevMgr == currMgr);
if (enable)
prevMgr = currMgr;
} }
} }
/* */
return enable; return enable;
} }

View file

@ -12,7 +12,8 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * 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; package org.eclipse.rse.internal.ui.actions;
@ -161,21 +162,22 @@ public class SystemFilterWorkWithFilterPoolsAction
SystemFilterUIHelpers.getFilterPoolModel(getFilterPoolManagerProvider(), mgrs); SystemFilterUIHelpers.getFilterPoolModel(getFilterPoolManagerProvider(), mgrs);
return input; return input;
} }
/** /**
* Callback for dialog to refresh its contents * Callback for dialog to refresh its contents
*/ */
public SystemSimpleContentElement getTreeModelPreSelection(SystemSimpleContentElement input) public SystemSimpleContentElement getTreeModelPreSelection(SystemSimpleContentElement input) {
{
ISystemFilterPoolReferenceManagerProvider sprmp = getReferenceManagerProviderSelection();
SystemSimpleContentElement initialElementSelection = null; SystemSimpleContentElement initialElementSelection = null;
if (sprmp != null) ISystemFilterPoolReferenceManagerProvider sprmp = getReferenceManagerProviderSelection();
{ if (sprmp != null) {
ISystemFilterPoolManager initialSelection = sprmp.getSystemFilterPoolReferenceManager().getDefaultSystemFilterPoolManager(); ISystemFilterPoolManager initialSelection = sprmp.getSystemFilterPoolReferenceManager().getDefaultSystemFilterPoolManager();
if (initialSelection != null) if (initialSelection != null) {
{ initialElementSelection = SystemFilterUIHelpers.getDataElement(input, initialSelection);
initialElementSelection = SystemFilterUIHelpers.getDataElement(input, initialSelection); }
//if (initialElementSelection != null) } else {
//dialog.setRootToPreselect(initialElementSelection); SystemSimpleContentElement[] children = input.getChildren();
if (children.length > 0) {
initialElementSelection = children[0];
} }
} }
return initialElementSelection; return initialElementSelection;

View file

@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [197036] fixed delete filter pool bug found during testing of this bug * David Dykstal (IBM) - [197036] fixed delete filter pool bug found during testing of this bug
* see also bug 194260 regarding deleting filter pools * 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; package org.eclipse.rse.internal.ui.filters.dialogs;
@ -602,24 +603,25 @@ public class SystemFilterWorkWithFilterPoolsDialog
ISystemFilterPoolManager[] mgrs = filterPoolManagers; ISystemFilterPoolManager[] mgrs = filterPoolManagers;
return mgrs; return mgrs;
} }
/** /**
* Callback from new action to get index of initial manager to select * Callback from new action to get index of initial manager to select
*/ */
public int getFilterPoolManagerSelection() public int getFilterPoolManagerSelection() {
{ int selection = 0;
int selection = 0; SystemSimpleContentElement element = getSelectedElement();
SystemSimpleContentElement element = getSelectedElement(); if (element != null) {
Object elementData = element.getData(); Object elementData = element.getData();
if (elementData != null) if (elementData != null) {
{ if (elementData instanceof ISystemFilterPoolManager) {
if (elementData instanceof ISystemFilterPoolManager) selection = getManagerIndex((ISystemFilterPoolManager) elementData);
selection = getManagerIndex((ISystemFilterPoolManager)elementData); } else if (elementData instanceof ISystemFilterPool) {
else if (elementData instanceof ISystemFilterPool) selection = getManagerIndex(((ISystemFilterPool) elementData).getSystemFilterPoolManager());
selection = getManagerIndex(((ISystemFilterPool)elementData).getSystemFilterPoolManager()); }
} }
//System.out.println("In getFilterPoolManagerSelection(). Returning "+selection); }
return selection; return selection;
} }
private int getManagerIndex(ISystemFilterPoolManager mgr) private int getManagerIndex(ISystemFilterPoolManager mgr)
{ {