From f3435b0150c3492b589d6e6cda05491ee17f9bbf Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Fri, 6 Apr 2007 12:56:24 +0000 Subject: [PATCH] [181394][contributed] Fix incorrect elements shown below filters by fixing getAbsoluteName() of filter and pool references to include context --- .../SystemViewFilterPoolReferenceAdapter.java | 26 +++++++++++++------ .../SystemViewFilterReferenceAdapter.java | 20 ++++++++++---- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java index 1d21732d8d8..4c6122c93fd 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -22,9 +22,11 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.rse.core.SystemAdapterHelpers; import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolReference; +import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.SubSystemHelpers; @@ -37,6 +39,7 @@ import org.eclipse.rse.ui.validators.ValidatorFilterPoolName; import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; import org.eclipse.rse.ui.view.ISystemMementoConstants; import org.eclipse.rse.ui.view.ISystemPropertyConstants; +import org.eclipse.rse.ui.view.ISystemViewElementAdapter; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.ui.views.properties.PropertyDescriptor; @@ -112,7 +115,6 @@ public class SystemViewFilterPoolReferenceAdapter { return ((ISubSystem)getFilterPoolReference(element).getProvider()); } - /** * Returns an image descriptor for the image. More efficient than getting the image. @@ -142,7 +144,6 @@ public class SystemViewFilterPoolReferenceAdapter return getFilterPoolReference(element).getReferencedFilterPool(); // get master object } - /** * @param element the filter pool reference masquerading as an object * @return the label for this filter pool reference. @@ -161,6 +162,7 @@ public class SystemViewFilterPoolReferenceAdapter } return result; } + /** * Return the name of this object, which may be different than the display text ({#link #getText(Object)}. *
@@ -170,14 +172,22 @@ public class SystemViewFilterPoolReferenceAdapter
{
return getFilterPool(element).getName();
}
+
/**
* Return the absolute name, versus just display name, of this object
*/
public String getAbsoluteName(Object element)
{
- ISystemFilterPoolReference filterPoolRef = (ISystemFilterPoolReference)element;
- return filterPoolRef.getReferencedFilterPool().getSystemFilterPoolManager().getName() + "." + filterPoolRef.getName(); //$NON-NLS-1$
- }
+ //TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change
+ ISystemFilterPoolReference filterPoolRef = getFilterPoolReference(element);
+ ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider();
+ ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem);
+ String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$
+ return parentAbsoluteName + "." + //$NON-NLS-1$
+ filterPoolRef.getReferencedFilterPool().getSystemFilterPoolManager().getName() + "." + //$NON-NLS-1$
+ filterPoolRef.getName();
+ }
+
/**
* Return the type label for this object
*/
@@ -367,7 +377,7 @@ public class SystemViewFilterPoolReferenceAdapter
public String getInputMementoHandle(Object element)
{
Object parent = getParent(element);
- return getSystemViewElementAdapter(parent).getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);
+ return SystemAdapterHelpers.getViewAdapter(parent, getViewer()).getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);
}
/**
* Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
index 19f172c6d07..734c345e42f 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved.
+ * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -12,6 +12,7 @@
*
* Contributors:
* David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
+ * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@@ -27,6 +28,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.filters.ISystemFilter;
import org.eclipse.rse.core.filters.ISystemFilterContainerReference;
@@ -126,6 +128,7 @@ public class SystemViewFilterReferenceAdapter
{
return SubSystemHelpers.getParentSubSystemConfiguration(filter);
}
+
/**
* Overridden from parent.
* Returns the subsystem that contains this object.
@@ -137,6 +140,7 @@ public class SystemViewFilterReferenceAdapter
else
return null;
}
+
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired
@@ -161,6 +165,7 @@ public class SystemViewFilterReferenceAdapter
{
return (ISystemFilterReference) element; // get referenced object
}
+
private ISystemFilter getFilter(Object element)
{
return getFilterReference(element).getReferencedFilter(); // get master object
@@ -173,6 +178,7 @@ public class SystemViewFilterReferenceAdapter
{
return getFilter(element).getName();
}
+
/**
* Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
*
@@ -182,13 +188,17 @@ public class SystemViewFilterReferenceAdapter { return getFilter(element).getName(); } + /** * Return the absolute name, versus just display name, of this object */ public String getAbsoluteName(Object element) { - ISystemFilter filter = getFilter(element); - return filter.getSystemFilterPoolManager().getName() + "." + filter.getParentFilterPool().getName() + "." + filter.getName(); //$NON-NLS-1$ //$NON-NLS-2$ + //TODO consider caching the absolute name in the FilterReference to avoid unnecessary String operations - the name won't ever change + ISystemFilterPoolReference filterPoolReference = getFilterReference(element).getParentSystemFilterReferencePool(); + ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(filterPoolReference); + String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(filterPoolReference) : ""; //$NON-NLS-1$ + return parentAbsoluteName + "." + getName(element); //$NON-NLS-1$ } /** @@ -757,14 +767,14 @@ public class SystemViewFilterReferenceAdapter public String getInputMementoHandle(Object element) { Object parent = ((ISystemFilterReference) element).getParent(); //getParent(element); // will be filter (nested) or filter pool - ISystemViewElementAdapter parentAdapter = getSystemViewElementAdapter(parent); + ISystemViewElementAdapter parentAdapter = SystemAdapterHelpers.getViewAdapter(parent, getViewer()); boolean showFPs = SystemPreferencesManager.getShowFilterPools(); if (parent instanceof ISystemFilterPoolReference) // not a nested filter { if (!showFPs) // not showing the real parent in GUI? { parent = parentAdapter.getParent(parent); // get the subsystem parent of the filter pool reference - parentAdapter = getSystemViewElementAdapter(parent); // get the adapter for the subsystem parent + parentAdapter = SystemAdapterHelpers.getViewAdapter(parent, getViewer()); // get the adapter for the subsystem parent } } return parentAdapter.getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);