diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
index f3c49bebbc6..5ede7bda0ca 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java
@@ -8,6 +8,7 @@
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
+ * Uwe Stieber (Wind River) - [209193] RSE new connection wizard shows empty categories if typing something into the filter
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@@ -181,7 +182,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
*
* @return The list of system types the page is restricted to or null
.
*/
- protected IRSESystemType[] getRestrictToSystemTypes() {
+ public IRSESystemType[] getRestrictToSystemTypes() {
return restrictedSystemTypes;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java
index a671dd2935e..bde48fdbe76 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java
@@ -7,16 +7,91 @@
*
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
+ * Uwe Stieber (Wind River) - [209193] RSE new connection wizard shows empty categories if typing something into the filter
*******************************************************************************/
package org.eclipse.rse.ui.wizards.registries;
+import java.util.Arrays;
+
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.ui.RSESystemTypeAdapter;
+import org.eclipse.rse.ui.wizards.newconnection.RSENewConnectionWizardSelectionPage;
+import org.eclipse.rse.ui.wizards.newconnection.RSENewConnectionWizardSelectionTreeElement;
import org.eclipse.ui.dialogs.PatternFilter;
/**
* Standard RSE wizard selection tree pattern filter.
*/
public class RSEWizardSelectionTreePatternFilter extends PatternFilter {
+ private final WizardPage parentPage;
+
+ /**
+ * Constructor.
+ * Creates a new pattern filter instance which is not associated
+ * with a parent wizard page.
+ */
+ public RSEWizardSelectionTreePatternFilter() {
+ this(null);
+ }
+
+ /**
+ * Constructor.
+ * Creates a new pattern filter instance with the passed in
+ * wizard page associated as parent.
+ *
+ * @param page The parent wizard page or null
.
+ */
+ public RSEWizardSelectionTreePatternFilter(WizardPage page) {
+ parentPage = page;
+ }
+
+ /**
+ * Returns the associated parent wizard parent.
+ *
+ * @return The parent wizard page or null
if none.
+ */
+ protected WizardPage getParentWizardPage() {
+ return parentPage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.PatternFilter#isElementVisible(org.eclipse.jface.viewers.Viewer, java.lang.Object)
+ */
+ public boolean isElementVisible(Viewer viewer, Object element) {
+ // If the element is a new connection wizard selection tree element,
+ // we have to check if the associated system type is enabled and/or
+ // if the system type itself may filter it out from the visible elements.
+ if (element instanceof RSENewConnectionWizardSelectionTreeElement) {
+ // A system type must be associated with such tree element, otherwise it is filtered out
+ IRSESystemType systemType = ((RSENewConnectionWizardSelectionTreeElement)element).getSystemType();
+ if (systemType == null) return false;
+
+ // if the page is restricted to a set of system types, check on them first
+ WizardPage wizardPage = getParentWizardPage();
+ if (wizardPage instanceof RSENewConnectionWizardSelectionPage) {
+ IRSESystemType[] restricted = ((RSENewConnectionWizardSelectionPage)wizardPage).getRestrictToSystemTypes();
+ if (restricted != null && restricted.length > 0) {
+ if (!Arrays.asList(restricted).contains(systemType)) return false;
+ }
+ }
+
+ // First, adapt the system type to a viewer filter and pass on the select request
+ // to the viewer filter adapter if available
+ ViewerFilter filter = (ViewerFilter)(systemType.getAdapter(ViewerFilter.class));
+ // We don't know what the parent of the passed in element is.
+ // So, we can pass on only null here.
+ if (filter != null && !filter.select(viewer, null, element)) return false;
+
+ // Second, double check if the system type passed the viewer filter but is disabled.
+ RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
+ if (adapter != null && !adapter.isEnabled(systemType)) return false;
+ }
+
+ return super.isElementVisible(viewer, element);
+ }
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.PatternFilter#isElementSelectable(java.lang.Object)