1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

[181394][contributed] Fix incorrect elements shown below filters by fixing getAbsoluteName() of filter and pool references to include context

This commit is contained in:
Martin Oberhuber 2007-04-06 12:56:24 +00:00
parent eedb7b4c9c
commit f3435b0150
2 changed files with 33 additions and 13 deletions

View file

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

View file

@ -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);
}
/**
* <i>Overridden from parent.</i><br>
* 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)}.
* <p>
@ -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);