1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

Bug 158180 - Forward reference logic fixed in SystemFilterPoolReference. Since there may actually be valid broken references cases were added to handle those as well.

This commit is contained in:
David Dykstal 2006-09-21 17:26:40 +00:00
parent 4af17ed91b
commit 7e0a48a36e
5 changed files with 61 additions and 48 deletions

View file

@ -481,20 +481,13 @@ public class RSEDOMImporter implements IRSEDOMImporter
/*
* DWD filterpool can be null when restoring since there can be forward references.
* A profile may be being restored that has references to a filter pool in a profile that doesn't yet exist.
* Need to create an "unresolved" reference instead of a null object and then patch them up
* at the end.
* Need to create an "unresolved" reference instead of a null object and then patch them up on first access.
*/
// create reference to the filterpool
if (filterPool != null) {
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPool);
} else {
try {
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolManager, filterPoolName);
} catch(NullPointerException e) {
//TODO Workaround for bug 153253 -- should be fixed properly
System.err.println("TODO: Fix bug 153253 - NPE reading connection-private filter pools");
e.printStackTrace();
}
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolManager, filterPoolName);
}
}
return filterPoolReference;

View file

@ -140,15 +140,22 @@ public class SystemViewFilterPoolReferenceAdapter
/**
* Return the label for this object. Uses getName() on the filter pool object.
* @param element the filter pool reference masquerading as an object
* @return the label for this filter pool reference.
*/
public String getText(Object element)
{
boolean qualifyNames = RSEUIPlugin.getTheSystemRegistry().getQualifiedHostNames();
if (!qualifyNames)
return getFilterPool(element).getName();
else
return SubSystemHelpers.getParentSystemProfile(getFilterPool(element))+"." + getFilterPool(element).getName();
public String getText(Object element) {
String result = "unknown"; // $NON-NLS-1$
ISystemFilterPool pool = getFilterPool(element);
if (pool != null) {
result = pool.getName();
// the following looks like it was copied from the host adapter and not really needed here.
// boolean qualifyNames = RSEUIPlugin.getTheSystemRegistry().getQualifiedHostNames();
// if (qualifyNames) {
// String prefix = SubSystemHelpers.getParentSystemProfile(pool).getName();
// result = prefix + "." + result;
// }
}
return result;
}
/**
* Return the name of this object, which may be different than the display text ({#link #getText(Object)}.

View file

@ -542,13 +542,12 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return filterPoolReference;
}
// DWD Working - the method above and this one can be combined?
/* (non-Javadoc)
* @see org.eclipse.rse.filters.ISystemFilterPoolReferenceManager#addReferenceToSystemFilterPool(org.eclipse.rse.filters.ISystemFilterPoolManager, java.lang.String)
*/
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolManager, filterPoolName);
addReferencingObject(filterPoolReference); // DWD - should be done in addReferencingObject?
addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache();
quietSave();

View file

@ -16,6 +16,9 @@
package org.eclipse.rse.internal.filters;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.filters.ISystemFilter;
@ -27,8 +30,10 @@ import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
import org.eclipse.rse.core.filters.ISystemFilterReference;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.references.SystemPersistableReferencingObject;
import org.eclipse.rse.model.SystemRegistry;
/**
* A reference to a filter pool. A reference may be "resolved" or "unresolved".
@ -144,12 +149,26 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
if (filterPool == null) {
String filterPoolName = getReferencedFilterPoolName();
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
if (filterPool == null) {
Pattern p = Pattern.compile("(^.*):");
Matcher m = p.matcher(filterPoolName);
if (m.find()) {
String profileName = m.group(1);
ISystemProfile profile = SystemRegistry.getSystemRegistry().getSystemProfile(profileName);
if (profile != null) {
ISystemFilterPool[] pools = profile.getFilterPools();
for (int i = 0; i < pools.length && filterPool == null; i++) {
ISystemFilterPool pool = pools[i];
if (filterPoolName.equals(pool.getName())) filterPool = pool;
}
}
}
}
if (filterPool != null) {
setReferenceToFilterPool(filterPool);
} else {
this.setReferenceBroken(true);
}
}
setReferenceBroken(filterPool == null);
return filterPool;
}

View file

@ -1072,35 +1072,30 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
// -------------------------------
// FILTER POOL REFERENCE EVENTS...
// -------------------------------
/**
* A new filter pool reference has been created
*/
public void filterEventFilterPoolReferenceCreated(ISystemFilterPoolReference newPoolRef)
{
if (getSubSystemConfiguration().showFilterPools())
{
fireEvent(newPoolRef, EVENT_ADD, this);
fireEvent(newPoolRef, EVENT_REVEAL_AND_SELECT, this);
}
else if (newPoolRef.getReferencedFilterPool().getSystemFilterCount()>0)
{
ISystemFilterReference[] filterRefs = newPoolRef.getSystemFilterReferences(this);
fireEvent(filterRefs, EVENT_ADD_MANY, this, -1); // -1 means append to end
}
try {
//System.out.println(" calling saveSubSystem(this)...");
getSubSystemConfiguration().saveSubSystem(this);
//System.out.println(" Back and done!");
// fire model change event in case any BP code is listening...
RSEUIPlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_FILTERPOOLREF, newPoolRef, null);
}
catch (Exception exc)
{
SystemBasePlugin.logError("Error saving subsystem "+getName(),exc);
}
}
/**
* A new filter pool reference has been created. Fire the appropriate events for this.
*/
public void filterEventFilterPoolReferenceCreated(ISystemFilterPoolReference newPoolRef) {
if (getSubSystemConfiguration().showFilterPools()) {
fireEvent(newPoolRef, EVENT_ADD, this);
fireEvent(newPoolRef, EVENT_REVEAL_AND_SELECT, this);
} else {
ISystemFilterPool pool = newPoolRef.getReferencedFilterPool();
if (pool != null && pool.getSystemFilterCount() > 0) {
ISystemFilterReference[] filterRefs = newPoolRef.getSystemFilterReferences(this);
fireEvent(filterRefs, EVENT_ADD_MANY, this, -1); // -1 means append to end
}
}
try {
getSubSystemConfiguration().saveSubSystem(this);
RSEUIPlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_FILTERPOOLREF, newPoolRef, null);
} catch (Exception exc) {
SystemBasePlugin.logError("Error saving subsystem " + getName(), exc);
}
}
/**
* A filter pool reference has been deleted
*/
public void filterEventFilterPoolReferenceDeleted(ISystemFilterPoolReference filterPoolRef)