From 22ab47928b54a2d589e628ec4a58ab31718f268d Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 11 Jul 2008 16:09:05 +0000 Subject: [PATCH] [238158] Can create duplicate filters --- .../ui/actions/SystemNewFileFilterAction.java | 51 +++++++++++++++++++ .../SystemNewFileFilterFromFolderAction.java | 15 ++++-- .../view/SubSystemConfigurationAdapter.java | 20 +++++++- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterAction.java index 074b4f6a0ad..81d96205307 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterAction.java @@ -12,13 +12,25 @@ * * Contributors: * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods + * David McKnight (IBM) - [238158] Can create duplicate filters ********************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; +import java.util.Iterator; + +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.rse.core.filters.ISystemFilterPool; +import org.eclipse.rse.core.filters.ISystemFilterPoolManager; +import org.eclipse.rse.core.filters.ISystemFilterPoolWrapperInformation; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.SubSystem; +import org.eclipse.rse.core.subsystems.SubSystemConfiguration; import org.eclipse.rse.files.ui.widgets.SystemFileFilterStringEditPane; import org.eclipse.rse.internal.subsystems.files.core.SystemFileResources; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration; +import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile; import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.filters.actions.SystemNewFilterAction; @@ -35,6 +47,7 @@ public class SystemNewFileFilterAction extends SystemNewFilterAction { //private RemoteFileSubSystemConfiguration inputSubsystemConfiguration; + private SubSystem _selectedSubSystem; /** * Constructor @@ -79,4 +92,42 @@ public class SystemNewFileFilterAction wizard.setPage1Description(SystemFileResources.RESID_NEWFILEFILTER_PAGE1_DESCRIPTION); wizard.setFilterStringEditPane(new SystemFileFilterStringEditPane(wizard.getShell())); } + + public void run() + { + if (_selectedSubSystem != null){ + setAllowFilterPoolSelection(_selectedSubSystem.getFilterPoolReferenceManager().getReferencedSystemFilterPools()); + } + else { + // disallow filter pool select (because this is from a filter pool) + setAllowFilterPoolSelection((ISystemFilterPool[])null); + setAllowFilterPoolSelection((ISystemFilterPoolWrapperInformation)null); + + callbackConfigurator = null; + callbackConfiguratorCalled = false; + } + super.run(); + } + + /** + * Called when the selection changes in the systems view. This determines + * the input object for the command and whether to enable or disable + * the action. + * + * @param selection the current seleciton + * @return whether to enable or disable the action + */ + public boolean updateSelection(IStructuredSelection selection) + { + _selectedSubSystem = null; + Iterator e = selection.iterator(); + Object selected = e.next(); + + if (selected != null && selected instanceof SubSystem) + { + _selectedSubSystem = (SubSystem) selected; + } + + return super.updateSelection(selection); + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterFromFolderAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterFromFolderAction.java index 025fed214f9..b4e3a184357 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterFromFolderAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemNewFileFilterFromFolderAction.java @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David McKnight (IBM) - [238158] Can create duplicate filters *******************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; @@ -21,7 +21,9 @@ import java.util.Iterator; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.rse.core.filters.ISystemFilterPool; +import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider; +import org.eclipse.rse.core.subsystems.SubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile; @@ -53,9 +55,14 @@ public class SystemNewFileFilterFromFolderAction extends SystemNewFileFilterActi public void run() { IRemoteFileSubSystem fileSubsystem = _selected.getParentRemoteFileSubSystem(); - //ISubSystemConfiguration config = fileSubsystem.getSubSystemConfiguration(); - ISystemFilterPool filterPool = fileSubsystem.getFilterPoolReferenceManager().getDefaultSystemFilterPoolManager().getFirstDefaultSystemFilterPool(); - setParentFilterPool(filterPool); + + ISystemFilterPool defaultFilterPool = ((SubSystem)fileSubsystem).getConnectionPrivateFilterPool(true); + if (defaultFilterPool == null){ + ISystemFilterPoolManager mgr = fileSubsystem.getFilterPoolReferenceManager().getDefaultSystemFilterPoolManager(); + defaultFilterPool = mgr.getFirstDefaultSystemFilterPool(); + } + + setParentFilterPool(defaultFilterPool); setAllowFilterPoolSelection(fileSubsystem.getFilterPoolReferenceManager().getReferencedSystemFilterPools()); super.run(); } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java index f200331642f..4df0f80d4f7 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java @@ -20,6 +20,7 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types * David Dykstal (IBM) - [168976][api] move ISystemNewConnectionWizardPage from core to UI + * David McKnight (IBM) - [238158] Can create duplicate filters ********************************************************************************/ package org.eclipse.rse.ui.view; @@ -433,7 +434,12 @@ public class SubSystemConfigurationAdapter implements ISubSystemConfigurationAda // if not showing filter pools, we have to add a "new filter" action here... if (!showFilterPools) { - IAction[] newFilterActions = getNewFilterPoolFilterActions(menu, selection, shell, menuGroup, config, null); + ISystemFilterPool defaultPool = null; + if (selectedSubSystem != null){ + defaultPool = ((SubSystem)selectedSubSystem).getConnectionPrivateFilterPool(true); + } + + IAction[] newFilterActions = getNewFilterPoolFilterActions(menu, selection, shell, menuGroup, config, defaultPool); if ((newFilterActions != null) && (newFilterActions.length > 0)) { // pre-scan for legacy @@ -585,8 +591,18 @@ public class SubSystemConfigurationAdapter implements ISubSystemConfigurationAda ISystemProfile activeProfile = selectedSubSystem.getHost().getSystemProfile(); for (int idx = 0; idx < activeProfiles.length; idx++) { - ISystemFilterPool defaultPool = getDefaultSystemFilterPool(config, activeProfiles[idx]); + //ISystemFilterPool defaultPool = getDefaultSystemFilterPool(config, activeProfiles[idx]); + // bug 238158 - now the default pool will be the connection private one + ISystemFilterPool defaultPool = null; + if (selectedSubSystem != null){ + defaultPool = ((SubSystem)selectedSubSystem).getConnectionPrivateFilterPool(true); + } + else { + defaultPool = getDefaultSystemFilterPool(config, activeProfiles[idx]); + } + + if (defaultPool != null) { poolWrapperInfo.addWrapper(activeProfiles[idx].getName(), defaultPool, (activeProfiles[idx] == activeProfile)); // display name, pool to wrap, whether to preselect