1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

[cleanup] format

This commit is contained in:
David Dykstal 2006-09-19 20:52:21 +00:00
parent caba3b3826
commit 53d4619a2e

View file

@ -15,6 +15,7 @@
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.filters; package org.eclipse.rse.filters;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -38,7 +39,6 @@ import org.eclipse.rse.internal.filters.SystemFilter;
import org.eclipse.rse.internal.filters.SystemFilterPoolReference; import org.eclipse.rse.internal.filters.SystemFilterPoolReference;
import org.eclipse.rse.internal.references.SystemPersistableReferenceManager; import org.eclipse.rse.internal.references.SystemPersistableReferenceManager;
/** /**
* This class manages a persistable list of objects each of which reference * This class manages a persistable list of objects each of which reference
* a filter pool. This class builds on the parent class SystemPersistableReferenceManager, * a filter pool. This class builds on the parent class SystemPersistableReferenceManager,
@ -48,8 +48,7 @@ import org.eclipse.rse.internal.references.SystemPersistableReferenceManager;
/** /**
* @lastgen class SystemFilterPoolReferenceManagerImpl extends SystemPersistableReferenceManagerImpl implements SystemFilterPoolReferenceManager, SystemPersistableReferenceManager {} * @lastgen class SystemFilterPoolReferenceManagerImpl extends SystemPersistableReferenceManagerImpl implements SystemFilterPoolReferenceManager, SystemPersistableReferenceManager {}
*/ */
public class SystemFilterPoolReferenceManager extends SystemPersistableReferenceManager implements ISystemFilterPoolReferenceManager public class SystemFilterPoolReferenceManager extends SystemPersistableReferenceManager implements ISystemFilterPoolReferenceManager {
{
//private SystemFilterPoolManager[] poolMgrs = null; //private SystemFilterPoolManager[] poolMgrs = null;
private ISystemFilterPoolManagerProvider poolMgrProvider = null; private ISystemFilterPoolManagerProvider poolMgrProvider = null;
private ISystemFilterPoolManager defaultPoolMgr = null; private ISystemFilterPoolManager defaultPoolMgr = null;
@ -68,10 +67,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/** /**
* Default constructor. Typically called by MOF factory methods. * Default constructor. Typically called by MOF factory methods.
*/ */
public SystemFilterPoolReferenceManager() public SystemFilterPoolReferenceManager() {
{
super(); super();
} }
/** /**
* Create a SystemFilterPoolReferenceManager instance. * Create a SystemFilterPoolReferenceManager instance.
* @param caller Objects which instantiate this class should implement the * @param caller Objects which instantiate this class should implement the
@ -95,26 +94,15 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param namingPolicy The names to use for file and folders when persisting to disk. Pass * @param namingPolicy The names to use for file and folders when persisting to disk. Pass
* null to just use the defaults, or if using SAVE_POLICY_NONE. * null to just use the defaults, or if using SAVE_POLICY_NONE.
*/ */
public static ISystemFilterPoolReferenceManager createSystemFilterPoolReferenceManager( public static ISystemFilterPoolReferenceManager createSystemFilterPoolReferenceManager(ISystemFilterPoolReferenceManagerProvider caller,
ISystemFilterPoolReferenceManagerProvider caller, ISystemFilterPoolManagerProvider relatedPoolManagerProvider, IFolder mgrFolder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
ISystemFilterPoolManagerProvider relatedPoolManagerProvider,
IFolder mgrFolder,
String name,
int savePolicy,
IRSEFilterNamingPolicy namingPolicy)
{
SystemFilterPoolReferenceManager mgr = null; SystemFilterPoolReferenceManager mgr = null;
if (mgrFolder != null) if (mgrFolder != null) SystemResourceHelpers.getResourceHelpers().ensureFolderExists(mgrFolder);
SystemResourceHelpers.getResourceHelpers().ensureFolderExists(mgrFolder); if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
if (namingPolicy == null) try {
namingPolicy = SystemFilterNamingPolicy.getNamingPolicy(); if (savePolicy != ISystemFilterSavePolicies.SAVE_POLICY_NONE) mgr = (SystemFilterPoolReferenceManager) restore(caller, mgrFolder, name, namingPolicy);
try } catch (Exception exc) // real error trying to restore, versus simply not found.
{
if (savePolicy != ISystemFilterSavePolicies.SAVE_POLICY_NONE)
mgr = (SystemFilterPoolReferenceManager)restore(caller, mgrFolder, name, namingPolicy);
}
catch (Exception exc) // real error trying to restore, versus simply not found.
{ {
// todo: something. Log the exception somewhere? // todo: something. Log the exception somewhere?
} }
@ -122,8 +110,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
{ {
mgr = createManager(); mgr = createManager();
} }
if (mgr != null) if (mgr != null) {
{
mgr.initialize(caller, mgrFolder, name, savePolicy, namingPolicy, relatedPoolManagerProvider); mgr.initialize(caller, mgrFolder, name, savePolicy, namingPolicy, relatedPoolManagerProvider);
} }
@ -134,27 +121,18 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Private helper method. * Private helper method.
* Uses MOF to create an instance of this class. * Uses MOF to create an instance of this class.
*/ */
protected static SystemFilterPoolReferenceManager createManager() protected static SystemFilterPoolReferenceManager createManager() {
{
ISystemFilterPoolReferenceManager mgr = new SystemFilterPoolReferenceManager(); ISystemFilterPoolReferenceManager mgr = new SystemFilterPoolReferenceManager();
// FIXME SystemFilterImpl.initMOF().createSystemFilterPoolReferenceManager(); // FIXME SystemFilterImpl.initMOF().createSystemFilterPoolReferenceManager();
return (SystemFilterPoolReferenceManager) mgr; return (SystemFilterPoolReferenceManager) mgr;
} }
/* /*
* Private helper method to initialize state * Private helper method to initialize state
*/ */
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, IFolder folder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy,
IFolder folder, ISystemFilterPoolManagerProvider relatedPoolManagerProvider) {
String name, if (!initialized) initialize(caller, folder, name, savePolicy, namingPolicy); // core data
int savePolicy,
IRSEFilterNamingPolicy namingPolicy,
ISystemFilterPoolManagerProvider relatedPoolManagerProvider)
{
if (!initialized)
initialize(caller, folder, name, savePolicy, namingPolicy); // core data
//setSystemFilterPoolManagers(relatedPoolManagers); //setSystemFilterPoolManagers(relatedPoolManagers);
setSystemFilterPoolManagerProvider(relatedPoolManagerProvider); setSystemFilterPoolManagerProvider(relatedPoolManagerProvider);
} }
@ -163,12 +141,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Private helper method to do core initialization. * Private helper method to do core initialization.
* Might be called from either the static factory method or the static restore method. * Might be called from either the static factory method or the static restore method.
*/ */
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, IFolder folder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
IFolder folder,
String name,
int savePolicy,
IRSEFilterNamingPolicy namingPolicy)
{
this.mgrFolder = folder; this.mgrFolder = folder;
setProvider(caller); setProvider(caller);
setName(name); setName(name);
@ -177,8 +150,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
initialized = true; initialized = true;
} }
private void invalidateFilterPoolReferencesCache() private void invalidateFilterPoolReferencesCache() {
{
fpRefsArray = null; fpRefsArray = null;
invalidateCache(); invalidateCache();
} }
@ -191,19 +163,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* typically manages multiple pool managers and we manage references * typically manages multiple pool managers and we manage references
* across those. * across those.
*/ */
public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider poolMgrProvider) public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider poolMgrProvider) {
{
this.poolMgrProvider = poolMgrProvider; this.poolMgrProvider = poolMgrProvider;
} }
/** /**
* Get the associated master pool manager provider. Note the provider * Get the associated master pool manager provider. Note the provider
* typically manages multiple pool managers and we manage references * typically manages multiple pool managers and we manage references
* across those. * across those.
*/ */
public ISystemFilterPoolManagerProvider getSystemFilterPoolManagerProvider() public ISystemFilterPoolManagerProvider getSystemFilterPoolManagerProvider() {
{
return poolMgrProvider; return poolMgrProvider;
} }
/* /*
* Set the managers of the master list of filter pools, from which * Set the managers of the master list of filter pools, from which
* objects in this list reference. * objects in this list reference.
@ -217,40 +189,34 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Get the managers of the master list of filter pools, from which * Get the managers of the master list of filter pools, from which
* objects in this list reference. * objects in this list reference.
*/ */
public ISystemFilterPoolManager[] getSystemFilterPoolManagers() public ISystemFilterPoolManager[] getSystemFilterPoolManagers() {
{
//return poolMgrs; //return poolMgrs;
return poolMgrProvider.getSystemFilterPoolManagers(); return poolMgrProvider.getSystemFilterPoolManagers();
} }
/** /**
* Get the managers of the master list of filter pools, from which * Get the managers of the master list of filter pools, from which
* objects in this list reference, but which are not in the list of * objects in this list reference, but which are not in the list of
* managers our pool manager supplier gives us. That is, these are * managers our pool manager supplier gives us. That is, these are
* references to filter pools outside the expected list. * references to filter pools outside the expected list.
*/ */
public ISystemFilterPoolManager[] getAdditionalSystemFilterPoolManagers() public ISystemFilterPoolManager[] getAdditionalSystemFilterPoolManagers() {
{
ISystemFilterPoolManager[] poolMgrs = getSystemFilterPoolManagers(); ISystemFilterPoolManager[] poolMgrs = getSystemFilterPoolManagers();
Vector v = new Vector(); Vector v = new Vector();
ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences();
for (int idx=0; idx<fpRefs.length; idx++) for (int idx = 0; idx < fpRefs.length; idx++) {
{
ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool(); ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool();
if (pool != null) if (pool != null) {
{
ISystemFilterPoolManager mgr = pool.getSystemFilterPoolManager(); ISystemFilterPoolManager mgr = pool.getSystemFilterPoolManager();
if (!managerExists(poolMgrs, mgr) && if (!managerExists(poolMgrs, mgr) && !v.contains(mgr)) {
!v.contains(mgr))
{
System.out.println("Found unmatched manager: " + mgr.getName()); System.out.println("Found unmatched manager: " + mgr.getName());
v.addElement(mgr); v.addElement(mgr);
} }
} }
} }
ISystemFilterPoolManager[] additionalMgrs = null; ISystemFilterPoolManager[] additionalMgrs = null;
if (v.size() > 0) if (v.size() > 0) {
{
additionalMgrs = new ISystemFilterPoolManager[v.size()]; additionalMgrs = new ISystemFilterPoolManager[v.size()];
for (int idx = 0; idx < v.size(); idx++) for (int idx = 0; idx < v.size(); idx++)
additionalMgrs[idx] = (ISystemFilterPoolManager) v.elementAt(idx); additionalMgrs[idx] = (ISystemFilterPoolManager) v.elementAt(idx);
@ -258,30 +224,26 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return additionalMgrs; return additionalMgrs;
} }
private boolean managerExists(ISystemFilterPoolManager[] mgrs, ISystemFilterPoolManager mgr) private boolean managerExists(ISystemFilterPoolManager[] mgrs, ISystemFilterPoolManager mgr) {
{
boolean match = false; boolean match = false;
for (int idx = 0; !match && (idx < mgrs.length); idx++) for (int idx = 0; !match && (idx < mgrs.length); idx++)
if (mgr == mgrs[idx]) if (mgr == mgrs[idx]) match = true;
match = true;
return match; return match;
} }
/** /**
* Set the default manager of the master list of filter pools, from which * Set the default manager of the master list of filter pools, from which
* objects in this list reference. * objects in this list reference.
*/ */
public void setDefaultSystemFilterPoolManager(ISystemFilterPoolManager mgr) public void setDefaultSystemFilterPoolManager(ISystemFilterPoolManager mgr) {
{
defaultPoolMgr = mgr; defaultPoolMgr = mgr;
} }
/** /**
* Get the default manager of the master list of filter pools, from which * Get the default manager of the master list of filter pools, from which
* objects in this list reference. * objects in this list reference.
*/ */
public ISystemFilterPoolManager getDefaultSystemFilterPoolManager() public ISystemFilterPoolManager getDefaultSystemFilterPoolManager() {
{
return defaultPoolMgr; return defaultPoolMgr;
} }
@ -289,32 +251,31 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Get the object which instantiated this instance of the filter pool reference manager. * Get the object which instantiated this instance of the filter pool reference manager.
* This is also available from any filter reference framework object. * This is also available from any filter reference framework object.
*/ */
public ISystemFilterPoolReferenceManagerProvider getProvider() public ISystemFilterPoolReferenceManagerProvider getProvider() {
{
return caller; return caller;
} }
/** /**
* Set the object which instantiated this instance of the filter pool reference manager. * Set the object which instantiated this instance of the filter pool reference manager.
* This makes it available to retrieve from any filter reference framework object, * This makes it available to retrieve from any filter reference framework object,
* via the ubiquitous getProvider interface method. * via the ubiquitous getProvider interface method.
*/ */
public void setProvider(ISystemFilterPoolReferenceManagerProvider caller) public void setProvider(ISystemFilterPoolReferenceManagerProvider caller) {
{
this.caller = caller; this.caller = caller;
} }
/** /**
* Turn off callbacks to the provider until turned on again. * Turn off callbacks to the provider until turned on again.
*/ */
public void setProviderEventNotification(boolean fireEvents) public void setProviderEventNotification(boolean fireEvents) {
{
this.fireEvents = fireEvents; this.fireEvents = fireEvents;
} }
/** /**
* Set the naming policy used when saving data to disk. * Set the naming policy used when saving data to disk.
* @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy * @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy
*/ */
public void setNamingPolicy(IRSEFilterNamingPolicy namingPolicy) public void setNamingPolicy(IRSEFilterNamingPolicy namingPolicy) {
{
this.namingPolicy = namingPolicy; this.namingPolicy = namingPolicy;
} }
@ -322,24 +283,21 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Get the naming policy currently used when saving data to disk. * Get the naming policy currently used when saving data to disk.
* @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy * @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy
*/ */
public IRSEFilterNamingPolicy getNamingPolicy() public IRSEFilterNamingPolicy getNamingPolicy() {
{
return namingPolicy; return namingPolicy;
} }
/** /**
* This is to set transient data that is subsequently queryable. * This is to set transient data that is subsequently queryable.
*/ */
public void setSystemFilterPoolReferenceManagerData(Object data) public void setSystemFilterPoolReferenceManagerData(Object data) {
{
this.mgrData = data; this.mgrData = data;
} }
/** /**
* Return transient data set via setFilterPoolData. * Return transient data set via setFilterPoolData.
*/ */
public Object getSystemFilterPoolReferenceManagerData() public Object getSystemFilterPoolReferenceManagerData() {
{
return mgrData; return mgrData;
} }
@ -348,24 +306,20 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* in order to potentially rename the disk file for a save * in order to potentially rename the disk file for a save
* policy of SAVE_POLICY_ONE_FILE_PER_MANAGER. * policy of SAVE_POLICY_ONE_FILE_PER_MANAGER.
*/ */
public void setName(String name) public void setName(String name) {
{
/* /*
* DWD Setting a name should schedule a save. Is this the same as a rename? * DWD Setting a name should schedule a save. Is this the same as a rename?
*/ */
// String oldName = getName(); // String oldName = getName();
if (savePolicy == ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER) if (savePolicy == ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER) {
{
IFile file = getResourceHelpers().getFile(getFolder(), getSaveFileName()); IFile file = getResourceHelpers().getFile(getFolder(), getSaveFileName());
super.setName(name); super.setName(name);
String newFileName = getSaveFileName(); String newFileName = getSaveFileName();
try { try {
getResourceHelpers().renameFile(file, newFileName); getResourceHelpers().renameFile(file, newFileName);
} catch (Exception exc) } catch (Exception exc) {
{
} }
} } else
else
super.setName(name); super.setName(name);
} }
@ -376,29 +330,25 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Ask each referenced pool for its name, and update it. * Ask each referenced pool for its name, and update it.
* Called after the name of the pool or its manager changes. * Called after the name of the pool or its manager changes.
*/ */
public void regenerateReferencedSystemFilterPoolNames() public void regenerateReferencedSystemFilterPoolNames() {
{
ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences();
for (int idx=0; idx<fpRefs.length; idx++) for (int idx = 0; idx < fpRefs.length; idx++) {
{
ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool(); ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool();
if (pool != null) if (pool != null) fpRefs[idx].resetReferencedFilterPoolName(pool.getReferenceName());
fpRefs[idx].resetReferencedFilterPoolName(pool.getReferenceName());
} }
invalidateFilterPoolReferencesCache(); // just in case! invalidateFilterPoolReferencesCache(); // just in case!
quietSave(); quietSave();
} }
/** /**
* Return array of SystemFilterPoolReference objects. * Return array of SystemFilterPoolReference objects.
* Result will never be null, although it may be an array of length zero. * Result will never be null, although it may be an array of length zero.
*/ */
public ISystemFilterPoolReference[] getSystemFilterPoolReferences() public ISystemFilterPoolReference[] getSystemFilterPoolReferences() {
{
IRSEBasePersistableReferencingObject[] refObjs = super.getReferencingObjects(); IRSEBasePersistableReferencingObject[] refObjs = super.getReferencingObjects();
if (refObjs.length == 0) if (refObjs.length == 0)
return emptyFilterPoolRefArray; return emptyFilterPoolRefArray;
else if ((fpRefsArray == null) || (fpRefsArray.length!=refObjs.length)) else if ((fpRefsArray == null) || (fpRefsArray.length != refObjs.length)) {
{
fpRefsArray = new ISystemFilterPoolReference[refObjs.length]; fpRefsArray = new ISystemFilterPoolReference[refObjs.length];
for (int idx = 0; idx < fpRefsArray.length; idx++) for (int idx = 0; idx < fpRefsArray.length; idx++)
fpRefsArray[idx] = (ISystemFilterPoolReference) refObjs[idx]; fpRefsArray[idx] = (ISystemFilterPoolReference) refObjs[idx];
@ -412,14 +362,11 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param array of filter pool reference objects to set the list to. * @param array of filter pool reference objects to set the list to.
* @param deReference true to first de-reference all objects in the existing list. * @param deReference true to first de-reference all objects in the existing list.
*/ */
public void setSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolReferences, public void setSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolReferences, boolean deReference) {
boolean deReference)
{
super.setReferencingObjects(filterPoolReferences, deReference); super.setReferencingObjects(filterPoolReferences, deReference);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesReset();
caller.filterEventFilterPoolReferencesReset();
quietSave(); quietSave();
} }
@ -449,8 +396,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Add a filter pool referencing object to the list. * Add a filter pool referencing object to the list.
* @return the new count of referencing objects * @return the new count of referencing objects
*/ */
public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) {
{
int count = addReferencingObject(filterPoolReference); int count = addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in the addReferencingObject method filterPoolReference.setParentReferenceManager(this); // DWD - should be done in the addReferencingObject method
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
@ -461,24 +407,21 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/** /**
* Reset the filter pool a reference points to. Called on a move-filter-pool operation * Reset the filter pool a reference points to. Called on a move-filter-pool operation
*/ */
public void resetSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, ISystemFilterPool newPool) public void resetSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, ISystemFilterPool newPool) {
{
filterPoolReference.removeReference(); filterPoolReference.removeReference();
filterPoolReference.setReferencedObject(newPool); filterPoolReference.setReferencedObject(newPool);
if (fireEvents && (caller != null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceReset(filterPoolReference);
caller.filterEventFilterPoolReferenceReset(filterPoolReference);
quietSave(); quietSave();
// don't think we need to invalidate the cache // don't think we need to invalidate the cache
} }
/** /**
* Remove a filter pool referencing object from the list. * Remove a filter pool referencing object from the list.
* @param filterPool Reference the reference to remove * @param filterPool Reference the reference to remove
* @param deReference true if we want to dereference the referenced object (call removeReference on it) * @param deReference true if we want to dereference the referenced object (call removeReference on it)
* @return the new count of referencing objects * @return the new count of referencing objects
*/ */
public int removeSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, public int removeSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, boolean deReference) {
boolean deReference)
{
int count = 0; int count = 0;
if (!deReference) if (!deReference)
count = super.removeReferencingObject(filterPoolReference); count = super.removeReferencingObject(filterPoolReference);
@ -487,24 +430,22 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
filterPoolReference.setParentReferenceManager(null); // DWD should be done in remove filterPoolReference.setParentReferenceManager(null); // DWD should be done in remove
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
quietSave(); quietSave();
return count; return count;
} }
/** /**
* Return count of referenced filter pools * Return count of referenced filter pools
*/ */
public int getSystemFilterPoolReferenceCount() public int getSystemFilterPoolReferenceCount() {
{
return super.getReferencingObjectCount(); return super.getReferencingObjectCount();
} }
/** /**
* Return the zero-based position of a SystemFilterPoolReference object within this list * Return the zero-based position of a SystemFilterPoolReference object within this list
*/ */
public int getSystemFilterPoolReferencePosition(ISystemFilterPoolReference filterPoolRef) public int getSystemFilterPoolReferencePosition(ISystemFilterPoolReference filterPoolRef) {
{
return super.getReferencingObjectPosition(filterPoolRef); return super.getReferencingObjectPosition(filterPoolRef);
} }
@ -512,21 +453,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Move a given filter pool reference to a given zero-based location * Move a given filter pool reference to a given zero-based location
* Calls back to inform provider of the event * Calls back to inform provider of the event
*/ */
public void moveSystemFilterPoolReference(ISystemFilterPoolReference filterPoolRef, int pos) public void moveSystemFilterPoolReference(ISystemFilterPoolReference filterPoolRef, int pos) {
{
int oldPos = super.getReferencingObjectPosition(filterPoolRef); int oldPos = super.getReferencingObjectPosition(filterPoolRef);
super.moveReferencingObjectPosition(pos, filterPoolRef); super.moveReferencingObjectPosition(pos, filterPoolRef);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (!noSave) if (!noSave) quietSave();
quietSave(); if (fireEvents && (caller != null) && !noEvents) {
if (fireEvents && (caller != null) && !noEvents)
{
ISystemFilterPoolReference[] refs = new ISystemFilterPoolReference[1]; ISystemFilterPoolReference[] refs = new ISystemFilterPoolReference[1];
refs[0] = filterPoolRef; refs[0] = filterPoolRef;
caller.filterEventFilterPoolReferencesRePositioned(refs, pos - oldPos); caller.filterEventFilterPoolReferencesRePositioned(refs, pos - oldPos);
} }
} }
/** /**
* Move existing filter pool references a given number of positions. * Move existing filter pool references a given number of positions.
* If the delta is negative, they are all moved up by the given amount. If * If the delta is negative, they are all moved up by the given amount. If
@ -536,8 +475,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param filterPoolRefs Array of SystemFilterPoolReferences to move. * @param filterPoolRefs Array of SystemFilterPoolReferences to move.
* @param newPosition new zero-based position for the filter pool references. * @param newPosition new zero-based position for the filter pool references.
*/ */
public void moveSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolRefs, int delta) public void moveSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolRefs, int delta) {
{
int[] oldPositions = new int[filterPoolRefs.length]; int[] oldPositions = new int[filterPoolRefs.length];
noEvents = noSave = true; noEvents = noSave = true;
for (int idx = 0; idx < filterPoolRefs.length; idx++) for (int idx = 0; idx < filterPoolRefs.length; idx++)
@ -551,11 +489,9 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
noEvents = noSave = false; noEvents = noSave = false;
quietSave(); quietSave();
if (fireEvents && (caller!=null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesRePositioned(filterPoolRefs, delta);
caller.filterEventFilterPoolReferencesRePositioned(filterPoolRefs, delta);
} }
// ---------------------------------------------- // ----------------------------------------------
// Methods that work on FilterPool master objects // Methods that work on FilterPool master objects
// ---------------------------------------------- // ----------------------------------------------
@ -563,8 +499,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Return array of filter pools currently referenced by this manager * Return array of filter pools currently referenced by this manager
* Result will never be null, although it may be an array of length zero. * Result will never be null, although it may be an array of length zero.
*/ */
public ISystemFilterPool[] getReferencedSystemFilterPools() public ISystemFilterPool[] getReferencedSystemFilterPools() {
{
ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences();
ISystemFilterPool[] pools = new ISystemFilterPool[refs.length]; ISystemFilterPool[] pools = new ISystemFilterPool[refs.length];
for (int idx = 0; idx < pools.length; idx++) for (int idx = 0; idx < pools.length; idx++)
@ -575,8 +510,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/** /**
* Return true if the given filter pool has a referencing object in this list. * Return true if the given filter pool has a referencing object in this list.
*/ */
public boolean isSystemFilterPoolReferenced(ISystemFilterPool filterPool) public boolean isSystemFilterPoolReferenced(ISystemFilterPool filterPool) {
{
return super.isReferenced(filterPool); return super.isReferenced(filterPool);
} }
@ -584,8 +518,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Given a filter pool, locate the referencing object for it and return it. * Given a filter pool, locate the referencing object for it and return it.
* @return the referencing object if found, else null * @return the referencing object if found, else null
*/ */
public ISystemFilterPoolReference getReferenceToSystemFilterPool(ISystemFilterPool filterPool) public ISystemFilterPoolReference getReferenceToSystemFilterPool(ISystemFilterPool filterPool) {
{
return (ISystemFilterPoolReference) super.getReferencedObject(filterPool); return (ISystemFilterPoolReference) super.getReferencedObject(filterPool);
} }
@ -623,66 +556,56 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Also removes that reference from the filterPool itself, and calls back to provider when done. * Also removes that reference from the filterPool itself, and calls back to provider when done.
* @return the new count of referencing objects * @return the new count of referencing objects
*/ */
public int removeReferenceToSystemFilterPool(ISystemFilterPool filterPool) public int removeReferenceToSystemFilterPool(ISystemFilterPool filterPool) {
{
ISystemFilterPoolReference filterPoolReference = getReferenceToSystemFilterPool(filterPool); ISystemFilterPoolReference filterPoolReference = getReferenceToSystemFilterPool(filterPool);
int newCount = 0; int newCount = 0;
if (filterPoolReference != null) if (filterPoolReference != null) {
{
filterPoolReference.removeReference(); // getReferencedFilterPool().removeReference(this) filterPoolReference.removeReference(); // getReferencedFilterPool().removeReference(this)
newCount = removeReferencingObject(filterPoolReference); newCount = removeReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in removeReferencingObject filterPoolReference.setParentReferenceManager(null); // DWD should be done in removeReferencingObject
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference); } else
}
else
newCount = getSystemFilterPoolReferenceCount(); newCount = getSystemFilterPoolReferenceCount();
return newCount; return newCount;
} }
/** /**
* A reference filter pool has been renamed. Update our stored name... * A reference filter pool has been renamed. Update our stored name...
* <p> Calls back to inform provider * <p> Calls back to inform provider
*/ */
public void renameReferenceToSystemFilterPool(ISystemFilterPool pool) public void renameReferenceToSystemFilterPool(ISystemFilterPool pool) {
{
ISystemFilterPoolReference poolRef = null; ISystemFilterPoolReference poolRef = null;
IRSEBasePersistableReferencingObject[] refs = getReferencingObjects(); IRSEBasePersistableReferencingObject[] refs = getReferencingObjects();
for (int idx = 0; (poolRef == null) && (idx < refs.length); idx++) for (int idx = 0; (poolRef == null) && (idx < refs.length); idx++)
if (refs[idx].getReferencedObject()==pool) if (refs[idx].getReferencedObject() == pool) poolRef = (ISystemFilterPoolReference) refs[idx];
poolRef = (ISystemFilterPoolReference)refs[idx];
if (poolRef != null) if (poolRef != null) {
{
String oldName = poolRef.getReferencedObjectName(); String oldName = poolRef.getReferencedObjectName();
poolRef.resetReferencedFilterPoolName(pool.getReferenceName()); poolRef.resetReferencedFilterPoolName(pool.getReferenceName());
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceRenamed(poolRef, oldName);
caller.filterEventFilterPoolReferenceRenamed(poolRef,oldName);
} }
} }
/** /**
* In one shot, set the filter pool references to new references to supplied filter pools. * In one shot, set the filter pool references to new references to supplied filter pools.
* @param array of filter pool objects to create references for * @param array of filter pool objects to create references for
* @param deReference true to first de-reference all objects in the existing list. * @param deReference true to first de-reference all objects in the existing list.
*/ */
public void setSystemFilterPoolReferences(ISystemFilterPool[] filterPools, public void setSystemFilterPoolReferences(ISystemFilterPool[] filterPools, boolean deReference) {
boolean deReference)
{
if (deReference) if (deReference)
super.removeAndDeReferenceAllReferencingObjects(); super.removeAndDeReferenceAllReferencingObjects();
else else
removeAllReferencingObjects(); removeAllReferencingObjects();
// add current // add current
if (filterPools != null) if (filterPools != null) {
{ for (int idx = 0; idx < filterPools.length; idx++) {
for (int idx=0; idx<filterPools.length; idx++)
{
//addReferenceToSystemFilterPool(filterPools[idx]); //addReferenceToSystemFilterPool(filterPools[idx]);
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]); ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]);
addReferencingObject(filterPoolReference); addReferencingObject(filterPoolReference);
@ -691,10 +614,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null)) if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesReset();
caller.filterEventFilterPoolReferencesReset();
} }
} }
// ------------------------- // -------------------------
// SPECIAL CASE METHODS // SPECIAL CASE METHODS
// ------------------------- // -------------------------
@ -703,8 +626,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* is added to a pool, and the GUI is not showing pools but rather all filters * is added to a pool, and the GUI is not showing pools but rather all filters
* in all pool references. * in all pool references.
*/ */
public ISystemFilterReference getSystemFilterReference(ISubSystem subSystem, ISystemFilter filter) public ISystemFilterReference getSystemFilterReference(ISubSystem subSystem, ISystemFilter filter) {
{
// step 1: find the reference to the filter pool that contains this filter // step 1: find the reference to the filter pool that contains this filter
ISystemFilterPool pool = filter.getParentFilterPool(); ISystemFilterPool pool = filter.getParentFilterPool();
ISystemFilterPoolReference poolRef = getReferenceToSystemFilterPool(pool); ISystemFilterPoolReference poolRef = getReferenceToSystemFilterPool(pool);
@ -714,16 +636,15 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
else else
return null; return null;
} }
/** /**
* Concatenate all filter references from all filter pools we reference, into one * Concatenate all filter references from all filter pools we reference, into one
* big list. * big list.
*/ */
public ISystemFilterReference[] getSystemFilterReferences(ISubSystem subSystem) public ISystemFilterReference[] getSystemFilterReferences(ISubSystem subSystem) {
{
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
Vector v = new Vector(); Vector v = new Vector();
for (int idx=0; idx<poolRefs.length; idx++) for (int idx = 0; idx < poolRefs.length; idx++) {
{
ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(subSystem); ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(subSystem);
for (int jdx = 0; jdx < filterRefs.length; jdx++) for (int jdx = 0; jdx < filterRefs.length; jdx++)
v.addElement(filterRefs[jdx]); v.addElement(filterRefs[jdx]);
@ -739,16 +660,13 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* when you think of all filter references from all filter pool references as * when you think of all filter references from all filter pool references as
* being concatenated * being concatenated
*/ */
public int getSystemFilterReferencePosition(ISystemFilterReference filterRef) public int getSystemFilterReferencePosition(ISystemFilterReference filterRef) {
{
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
int match = -1; int match = -1;
int totalCount = 0; int totalCount = 0;
for (int idx=0; (match==-1) && (idx<poolRefs.length); idx++) for (int idx = 0; (match == -1) && (idx < poolRefs.length); idx++) {
{
ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(filterRef.getSubSystem()); ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(filterRef.getSubSystem());
for (int jdx=0; (match==-1) && (jdx<filterRefs.length); jdx++) for (int jdx = 0; (match == -1) && (jdx < filterRefs.length); jdx++) {
{
if (filterRefs[jdx] == filterRef) if (filterRefs[jdx] == filterRef)
match = totalCount; match = totalCount;
else else
@ -757,21 +675,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
} }
return match; return match;
} }
/** /**
* Given a filter, return its position within this reference manager * Given a filter, return its position within this reference manager
* when you think of all filter references from all filter pool references as * when you think of all filter references from all filter pool references as
* being concatenated * being concatenated
*/ */
public int getSystemFilterReferencePosition(ISubSystem subSystem, ISystemFilter filter) public int getSystemFilterReferencePosition(ISubSystem subSystem, ISystemFilter filter) {
{
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
int match = -1; int match = -1;
int totalCount = 0; int totalCount = 0;
for (int idx=0; (match==-1) && (idx<poolRefs.length); idx++) for (int idx = 0; (match == -1) && (idx < poolRefs.length); idx++) {
{
ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(subSystem); ISystemFilterReference[] filterRefs = poolRefs[idx].getSystemFilterReferences(subSystem);
for (int jdx=0; (match==-1) && (jdx<filterRefs.length); jdx++) for (int jdx = 0; (match == -1) && (jdx < filterRefs.length); jdx++) {
{
if (filterRefs[jdx].getReferencedFilter() == filter) if (filterRefs[jdx].getReferencedFilter() == filter)
match = totalCount; match = totalCount;
else else
@ -784,23 +700,20 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
// ----------------------- // -----------------------
// SAVE/RESTORE METHODS... // SAVE/RESTORE METHODS...
// ----------------------- // -----------------------
private void quietSave() private void quietSave() {
{ try {
try { save(); } save();
catch (Exception exc) } catch (Exception exc) {
{
} }
} }
/** /**
* Save all the filter pools to disk. * Save all the filter pools to disk.
* Only called if the save policy is not none. * Only called if the save policy is not none.
*/ */
public void save() public void save() throws Exception {
throws Exception
{
//System.out.println("Saving filter pool " + this.getName() + "?"); // DWD - debugging //System.out.println("Saving filter pool " + this.getName() + "?"); // DWD - debugging
switch(savePolicy) switch (savePolicy) {
{
// ONE FILE PER FILTER POOL REFERENCE MANAGER // ONE FILE PER FILTER POOL REFERENCE MANAGER
case ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER: case ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER:
saveToOneFile(); saveToOneFile();
@ -811,9 +724,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/** /**
* Save this reference manager to disk. * Save this reference manager to disk.
*/ */
protected boolean saveToOneFile() protected boolean saveToOneFile() throws Exception {
throws Exception
{
/* FIXME /* FIXME
String saveFileName = getSaveFilePathAndName(); String saveFileName = getSaveFilePathAndName();
File saveFile = new File(saveFileName); File saveFile = new File(saveFileName);
@ -850,7 +761,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return true; return true;
} }
/** /**
* Restore the filter pools from disk. * Restore the filter pools from disk.
* After restoration, you must call resolveReferencesAfterRestore! * After restoration, you must call resolveReferencesAfterRestore!
@ -861,16 +771,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @return the restored manager, or null if it does not exist. If anything else went * @return the restored manager, or null if it does not exist. If anything else went
* wrong, an exception is thrown. * wrong, an exception is thrown.
*/ */
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) throws Exception {
IFolder mgrFolder, String name, if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
IRSEFilterNamingPolicy namingPolicy)
throws Exception
{
if (namingPolicy == null)
namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
ISystemFilterPoolReferenceManager mgr = restoreFromOneFile(mgrFolder, name, namingPolicy); ISystemFilterPoolReferenceManager mgr = restoreFromOneFile(mgrFolder, name, namingPolicy);
if (mgr != null) if (mgr != null) {
{
((SystemFilterPoolReferenceManager) mgr).initialize(caller, mgrFolder, name, ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER, namingPolicy); // core data ((SystemFilterPoolReferenceManager) mgr).initialize(caller, mgrFolder, name, ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER, namingPolicy); // core data
} }
return mgr; return mgr;
@ -879,9 +783,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/** /**
* Restore the filter pools from disk, assuming default for prefix of name. * Restore the filter pools from disk, assuming default for prefix of name.
*/ */
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name) public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name) throws Exception {
throws Exception
{
return restore(caller, mgrFolder, name, null); return restore(caller, mgrFolder, name, null);
} }
@ -891,9 +793,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param name The name of the manager, from which the file name is derived. * @param name The name of the manager, from which the file name is derived.
* @param namingPolicy Naming prefix information for persisted data file names. * @param namingPolicy Naming prefix information for persisted data file names.
*/ */
protected static ISystemFilterPoolReferenceManager restoreFromOneFile(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) protected static ISystemFilterPoolReferenceManager restoreFromOneFile(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) throws Exception {
throws Exception
{
ISystemFilterPoolReferenceManager mgr = null; ISystemFilterPoolReferenceManager mgr = null;
/* FIXME /* FIXME
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
@ -934,9 +834,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return mgr; return mgr;
} }
/** /**
* After restoring this from disk, there is only the referenced object name, * After restoring this from disk, there is only the referenced object name,
* not the referenced object pointer, for each referencing object. * not the referenced object pointer, for each referencing object.
@ -953,46 +850,35 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @return A Vector of SystemFilterPoolReferences that were not successfully resolved, or null if all * @return A Vector of SystemFilterPoolReferences that were not successfully resolved, or null if all
* were resolved. * were resolved.
*/ */
public Vector resolveReferencesAfterRestore(ISystemFilterPoolManagerProvider relatedPoolMgrProvider, public Vector resolveReferencesAfterRestore(ISystemFilterPoolManagerProvider relatedPoolMgrProvider, ISystemFilterPoolReferenceManagerProvider provider) {
ISystemFilterPoolReferenceManagerProvider provider)
{
setSystemFilterPoolManagerProvider(relatedPoolMgrProvider); // sets poolMgrs = relatedManagers setSystemFilterPoolManagerProvider(relatedPoolMgrProvider); // sets poolMgrs = relatedManagers
setProvider(provider); setProvider(provider);
ISystemFilterPoolManager[] relatedManagers = getSystemFilterPoolManagers(); ISystemFilterPoolManager[] relatedManagers = getSystemFilterPoolManagers();
if (relatedManagers != null) if (relatedManagers != null) {
{
Vector badRefs = new Vector(); Vector badRefs = new Vector();
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
if (poolRefs != null) if (poolRefs != null) {
{ for (int idx = 0; idx < poolRefs.length; idx++) {
for (int idx=0; idx<poolRefs.length; idx++)
{
String poolName = poolRefs[idx].getReferencedFilterPoolName(); String poolName = poolRefs[idx].getReferencedFilterPoolName();
String mgrName = poolRefs[idx].getReferencedFilterPoolManagerName(); String mgrName = poolRefs[idx].getReferencedFilterPoolManagerName();
ISystemFilterPool refdPool = getFilterPool(relatedManagers, mgrName, poolName); ISystemFilterPool refdPool = getFilterPool(relatedManagers, mgrName, poolName);
if ((refdPool == null) && (getFilterPoolManager(relatedManagers, mgrName) == null)) if ((refdPool == null) && (getFilterPoolManager(relatedManagers, mgrName) == null)) {
{
//System.out.println("...looking for broken reference for "+mgrName+"."+poolName); //System.out.println("...looking for broken reference for "+mgrName+"."+poolName);
refdPool = relatedPoolMgrProvider.getSystemFilterPoolForBrokenReference(this, mgrName, poolName); refdPool = relatedPoolMgrProvider.getSystemFilterPoolForBrokenReference(this, mgrName, poolName);
} }
if (refdPool != null) if (refdPool != null) {
{
poolRefs[idx].setReferenceToFilterPool(refdPool); // calls refdPool.addReference(poolRef) poolRefs[idx].setReferenceToFilterPool(refdPool); // calls refdPool.addReference(poolRef)
} } else {
else
{
badRefs.addElement(poolRefs[idx]); badRefs.addElement(poolRefs[idx]);
} }
} }
if (badRefs.size() == 0) if (badRefs.size() == 0)
return null; return null;
else else {
{ for (int idx = 0; idx < badRefs.size(); idx++) {
for (int idx=0; idx<badRefs.size(); idx++)
{
ISystemFilterPoolReference badRef = (ISystemFilterPoolReference) badRefs.elementAt(idx); ISystemFilterPoolReference badRef = (ISystemFilterPoolReference) badRefs.elementAt(idx);
//badRef.setReferenceBroken(true); //badRef.setReferenceBroken(true);
super.removeReferencingObject(badRef); super.removeReferencingObject(badRef);
@ -1016,25 +902,22 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param poolReferenceName The name of the filter pool as stored on disk. It may be qualified somehow * @param poolReferenceName The name of the filter pool as stored on disk. It may be qualified somehow
* to incorporate the manager name too. * to incorporate the manager name too.
*/ */
public static ISystemFilterPool getFilterPool(ISystemFilterPoolManager[] mgrs, String mgrName, String poolName) public static ISystemFilterPool getFilterPool(ISystemFilterPoolManager[] mgrs, String mgrName, String poolName) {
{
ISystemFilterPoolManager mgr = getFilterPoolManager(mgrs, mgrName); ISystemFilterPoolManager mgr = getFilterPoolManager(mgrs, mgrName);
if (mgr == null) if (mgr == null) return null;
return null;
return mgr.getSystemFilterPool(poolName); return mgr.getSystemFilterPool(poolName);
} }
/** /**
* Utility method to scan across all filter pool managers for a match on a give name. * Utility method to scan across all filter pool managers for a match on a give name.
* <p> * <p>
* @param mgrs The list of filter pool managers to scan for the given name * @param mgrs The list of filter pool managers to scan for the given name
* @param mgrName The name of the manager to restrict the search to * @param mgrName The name of the manager to restrict the search to
*/ */
public static ISystemFilterPoolManager getFilterPoolManager(ISystemFilterPoolManager[] mgrs, String mgrName) public static ISystemFilterPoolManager getFilterPoolManager(ISystemFilterPoolManager[] mgrs, String mgrName) {
{
ISystemFilterPoolManager mgr = null; ISystemFilterPoolManager mgr = null;
for (int idx = 0; (mgr == null) && (idx < mgrs.length); idx++) for (int idx = 0; (mgr == null) && (idx < mgrs.length); idx++)
if (mgrs[idx].getName().equals(mgrName)) if (mgrs[idx].getName().equals(mgrName)) mgr = mgrs[idx];
mgr = mgrs[idx];
return mgr; return mgr;
} }
@ -1042,87 +925,72 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
// HELPER METHODS... // HELPER METHODS...
// ------------------ // ------------------
/** /**
* If saving all info in one file, this returns the fully qualified name of that file, * If saving all info in one file, this returns the fully qualified name of that file,
* given the unadorned manager name and the prefix (if any) to adorn with. * given the unadorned manager name and the prefix (if any) to adorn with.
*/ */
protected static String getSaveFilePathAndName(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) protected static String getSaveFilePathAndName(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) {
{ return SystemFilter.addPathTerminator(getFolderPath(mgrFolder)) + getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(name));
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder))
+ getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(name));
} }
/** /**
* Derive and return the unqualified file name used to store this to disk. * Derive and return the unqualified file name used to store this to disk.
* It is unqualified. * It is unqualified.
*/ */
protected static String getSaveFileName(String fileNameNoSuffix) protected static String getSaveFileName(String fileNameNoSuffix) {
{
return fileNameNoSuffix + ISystemFilterConstants.SAVEFILE_SUFFIX; return fileNameNoSuffix + ISystemFilterConstants.SAVEFILE_SUFFIX;
} }
/** /**
* non-static version. * non-static version.
*/ */
protected String getSaveFilePathAndName() protected String getSaveFilePathAndName() {
{ return SystemFilter.addPathTerminator(getFolderPath(mgrFolder)) + getSaveFileName();
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder))
+ getSaveFileName();
}
/**
* non-static version.
*/
protected String getSaveFileName()
{
return getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(getName()));
} }
/**
* non-static version.
*/
protected String getSaveFileName() {
return getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(getName()));
}
/** /**
* Return the folder that this manager is contained in. * Return the folder that this manager is contained in.
*/ */
public IFolder getFolder() public IFolder getFolder() {
{
return mgrFolder; return mgrFolder;
} }
/** /**
* Reset the folder that this manager is contained in. * Reset the folder that this manager is contained in.
*/ */
public void resetManagerFolder(IFolder newFolder) public void resetManagerFolder(IFolder newFolder) {
{
mgrFolder = newFolder; mgrFolder = newFolder;
} }
/** /**
* Return the path of the folder * Return the path of the folder
*/ */
public String getFolderPath() public String getFolderPath() {
{
return getResourceHelpers().getFolderPath(mgrFolder); return getResourceHelpers().getFolderPath(mgrFolder);
} }
/** /**
* Return the path of the given folder * Return the path of the given folder
*/ */
public static String getFolderPath(IFolder folder) public static String getFolderPath(IFolder folder) {
{
return SystemResourceHelpers.getResourceHelpers().getFolderPath(folder); return SystemResourceHelpers.getResourceHelpers().getFolderPath(folder);
} }
/* /*
* To reduce typing... * To reduce typing...
*/ */
private SystemResourceHelpers getResourceHelpers() private SystemResourceHelpers getResourceHelpers() {
{
return SystemResourceHelpers.getResourceHelpers(); return SystemResourceHelpers.getResourceHelpers();
} }
public String toString() {
public String toString()
{
return getName(); return getName();
} }