mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-03 05:33:33 +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:
parent
99b254c72b
commit
4a3477984f
4 changed files with 82 additions and 85 deletions
|
@ -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) &&
|
|
||||||
!(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;
|
|
||||||
}
|
}
|
||||||
/* */
|
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;
|
return enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
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) &&
|
}
|
||||||
!(selectedObject instanceof ISystemFilterPoolReference))
|
ISystemFilterPool pool = null;
|
||||||
enable = false;
|
if (selectedObject instanceof ISystemFilterPool){
|
||||||
// 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;
|
pool = (ISystemFilterPool) selectedObject;
|
||||||
else
|
}
|
||||||
|
else if (selectedObject instanceof ISystemFilterPoolReference) {
|
||||||
pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool();
|
pool = ((ISystemFilterPoolReference) selectedObject).getReferencedFilterPool();
|
||||||
currMgr = pool.getSystemFilterPoolManager();
|
}
|
||||||
if (prevMgr == null)
|
if (pool != null) {
|
||||||
prevMgr = currMgr;
|
String ownerName = pool.getOwningParentName();
|
||||||
else
|
ISystemFilterPoolManager manager = pool.getSystemFilterPoolManager();
|
||||||
enable = (prevMgr == currMgr);
|
managers.add(manager);
|
||||||
if (enable)
|
// enable if the number of managers is one and the owner name is null (i.e. the pool does not belong to a connection)
|
||||||
prevMgr = currMgr;
|
enable = (managers.size() == 1) && (ownerName == null);
|
||||||
|
} else {
|
||||||
|
enable = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* */
|
|
||||||
return enable;
|
return enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
}
|
||||||
//dialog.setRootToPreselect(initialElementSelection);
|
} else {
|
||||||
|
SystemSimpleContentElement[] children = input.getChildren();
|
||||||
|
if (children.length > 0) {
|
||||||
|
initialElementSelection = children[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return initialElementSelection;
|
return initialElementSelection;
|
||||||
|
|
|
@ -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,22 +603,23 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue