1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +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:
* 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
* <p>
* @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;
}

View file

@ -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
* <p>
* @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;
}

View file

@ -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;

View file

@ -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)
{