1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46: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;
import java.util.Vector;
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.references.SystemPersistableReferenceManager;
/**
* This class manages a persistable list of objects each of which reference
* 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 {}
*/
public class SystemFilterPoolReferenceManager extends SystemPersistableReferenceManager implements ISystemFilterPoolReferenceManager
{
public class SystemFilterPoolReferenceManager extends SystemPersistableReferenceManager implements ISystemFilterPoolReferenceManager {
//private SystemFilterPoolManager[] poolMgrs = null;
private ISystemFilterPoolManagerProvider poolMgrProvider = null;
private ISystemFilterPoolManager defaultPoolMgr = null;
@ -68,10 +67,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/**
* Default constructor. Typically called by MOF factory methods.
*/
public SystemFilterPoolReferenceManager()
{
public SystemFilterPoolReferenceManager() {
super();
}
/**
* Create a SystemFilterPoolReferenceManager instance.
* @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
* null to just use the defaults, or if using SAVE_POLICY_NONE.
*/
public static ISystemFilterPoolReferenceManager createSystemFilterPoolReferenceManager(
ISystemFilterPoolReferenceManagerProvider caller,
ISystemFilterPoolManagerProvider relatedPoolManagerProvider,
IFolder mgrFolder,
String name,
int savePolicy,
IRSEFilterNamingPolicy namingPolicy)
{
public static ISystemFilterPoolReferenceManager createSystemFilterPoolReferenceManager(ISystemFilterPoolReferenceManagerProvider caller,
ISystemFilterPoolManagerProvider relatedPoolManagerProvider, IFolder mgrFolder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
SystemFilterPoolReferenceManager mgr = null;
if (mgrFolder != null)
SystemResourceHelpers.getResourceHelpers().ensureFolderExists(mgrFolder);
if (namingPolicy == null)
namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
try
{
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.
if (mgrFolder != null) SystemResourceHelpers.getResourceHelpers().ensureFolderExists(mgrFolder);
if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
try {
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?
}
@ -122,8 +110,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
{
mgr = createManager();
}
if (mgr != null)
{
if (mgr != null) {
mgr.initialize(caller, mgrFolder, name, savePolicy, namingPolicy, relatedPoolManagerProvider);
}
@ -134,27 +121,18 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Private helper method.
* Uses MOF to create an instance of this class.
*/
protected static SystemFilterPoolReferenceManager createManager()
{
protected static SystemFilterPoolReferenceManager createManager() {
ISystemFilterPoolReferenceManager mgr = new SystemFilterPoolReferenceManager();
// FIXME SystemFilterImpl.initMOF().createSystemFilterPoolReferenceManager();
return (SystemFilterPoolReferenceManager) mgr;
}
/*
* Private helper method to initialize state
*/
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller,
IFolder folder,
String name,
int savePolicy,
IRSEFilterNamingPolicy namingPolicy,
ISystemFilterPoolManagerProvider relatedPoolManagerProvider)
{
if (!initialized)
initialize(caller, folder, name, savePolicy, namingPolicy); // core data
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, IFolder folder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy,
ISystemFilterPoolManagerProvider relatedPoolManagerProvider) {
if (!initialized) initialize(caller, folder, name, savePolicy, namingPolicy); // core data
//setSystemFilterPoolManagers(relatedPoolManagers);
setSystemFilterPoolManagerProvider(relatedPoolManagerProvider);
}
@ -163,12 +141,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Private helper method to do core initialization.
* Might be called from either the static factory method or the static restore method.
*/
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller,
IFolder folder,
String name,
int savePolicy,
IRSEFilterNamingPolicy namingPolicy)
{
protected void initialize(ISystemFilterPoolReferenceManagerProvider caller, IFolder folder, String name, int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
this.mgrFolder = folder;
setProvider(caller);
setName(name);
@ -177,8 +150,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
initialized = true;
}
private void invalidateFilterPoolReferencesCache()
{
private void invalidateFilterPoolReferencesCache() {
fpRefsArray = null;
invalidateCache();
}
@ -191,19 +163,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* typically manages multiple pool managers and we manage references
* across those.
*/
public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider poolMgrProvider)
{
public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider poolMgrProvider) {
this.poolMgrProvider = poolMgrProvider;
}
/**
* Get the associated master pool manager provider. Note the provider
* typically manages multiple pool managers and we manage references
* across those.
*/
public ISystemFilterPoolManagerProvider getSystemFilterPoolManagerProvider()
{
public ISystemFilterPoolManagerProvider getSystemFilterPoolManagerProvider() {
return poolMgrProvider;
}
/*
* Set the managers of the master list of filter pools, from which
* 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
* objects in this list reference.
*/
public ISystemFilterPoolManager[] getSystemFilterPoolManagers()
{
public ISystemFilterPoolManager[] getSystemFilterPoolManagers() {
//return poolMgrs;
return poolMgrProvider.getSystemFilterPoolManagers();
}
/**
* 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
* managers our pool manager supplier gives us. That is, these are
* references to filter pools outside the expected list.
*/
public ISystemFilterPoolManager[] getAdditionalSystemFilterPoolManagers()
{
public ISystemFilterPoolManager[] getAdditionalSystemFilterPoolManagers() {
ISystemFilterPoolManager[] poolMgrs = getSystemFilterPoolManagers();
Vector v = new Vector();
ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences();
for (int idx=0; idx<fpRefs.length; idx++)
{
for (int idx = 0; idx < fpRefs.length; idx++) {
ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool();
if (pool != null)
{
if (pool != null) {
ISystemFilterPoolManager mgr = pool.getSystemFilterPoolManager();
if (!managerExists(poolMgrs, mgr) &&
!v.contains(mgr))
{
if (!managerExists(poolMgrs, mgr) && !v.contains(mgr)) {
System.out.println("Found unmatched manager: " + mgr.getName());
v.addElement(mgr);
}
}
}
ISystemFilterPoolManager[] additionalMgrs = null;
if (v.size() > 0)
{
if (v.size() > 0) {
additionalMgrs = new ISystemFilterPoolManager[v.size()];
for (int idx = 0; idx < v.size(); idx++)
additionalMgrs[idx] = (ISystemFilterPoolManager) v.elementAt(idx);
@ -258,30 +224,26 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return additionalMgrs;
}
private boolean managerExists(ISystemFilterPoolManager[] mgrs, ISystemFilterPoolManager mgr)
{
private boolean managerExists(ISystemFilterPoolManager[] mgrs, ISystemFilterPoolManager mgr) {
boolean match = false;
for (int idx = 0; !match && (idx < mgrs.length); idx++)
if (mgr == mgrs[idx])
match = true;
if (mgr == mgrs[idx]) match = true;
return match;
}
/**
* Set the default manager of the master list of filter pools, from which
* objects in this list reference.
*/
public void setDefaultSystemFilterPoolManager(ISystemFilterPoolManager mgr)
{
public void setDefaultSystemFilterPoolManager(ISystemFilterPoolManager mgr) {
defaultPoolMgr = mgr;
}
/**
* Get the default manager of the master list of filter pools, from which
* objects in this list reference.
*/
public ISystemFilterPoolManager getDefaultSystemFilterPoolManager()
{
public ISystemFilterPoolManager getDefaultSystemFilterPoolManager() {
return defaultPoolMgr;
}
@ -289,32 +251,31 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Get the object which instantiated this instance of the filter pool reference manager.
* This is also available from any filter reference framework object.
*/
public ISystemFilterPoolReferenceManagerProvider getProvider()
{
public ISystemFilterPoolReferenceManagerProvider getProvider() {
return caller;
}
/**
* 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,
* via the ubiquitous getProvider interface method.
*/
public void setProvider(ISystemFilterPoolReferenceManagerProvider caller)
{
public void setProvider(ISystemFilterPoolReferenceManagerProvider caller) {
this.caller = caller;
}
/**
* Turn off callbacks to the provider until turned on again.
*/
public void setProviderEventNotification(boolean fireEvents)
{
public void setProviderEventNotification(boolean fireEvents) {
this.fireEvents = fireEvents;
}
/**
* Set the naming policy used when saving data to disk.
* @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy
*/
public void setNamingPolicy(IRSEFilterNamingPolicy namingPolicy)
{
public void setNamingPolicy(IRSEFilterNamingPolicy namingPolicy) {
this.namingPolicy = namingPolicy;
}
@ -322,24 +283,21 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Get the naming policy currently used when saving data to disk.
* @see org.eclipse.rse.core.filters.IRSEFilterNamingPolicy
*/
public IRSEFilterNamingPolicy getNamingPolicy()
{
public IRSEFilterNamingPolicy getNamingPolicy() {
return namingPolicy;
}
/**
* This is to set transient data that is subsequently queryable.
*/
public void setSystemFilterPoolReferenceManagerData(Object data)
{
public void setSystemFilterPoolReferenceManagerData(Object data) {
this.mgrData = data;
}
/**
* Return transient data set via setFilterPoolData.
*/
public Object getSystemFilterPoolReferenceManagerData()
{
public Object getSystemFilterPoolReferenceManagerData() {
return mgrData;
}
@ -348,24 +306,20 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* in order to potentially rename the disk file for a save
* 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?
*/
// 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());
super.setName(name);
String newFileName = getSaveFileName();
try {
getResourceHelpers().renameFile(file, newFileName);
} catch (Exception exc)
{
} catch (Exception exc) {
}
}
else
} else
super.setName(name);
}
@ -376,29 +330,25 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Ask each referenced pool for its name, and update it.
* Called after the name of the pool or its manager changes.
*/
public void regenerateReferencedSystemFilterPoolNames()
{
public void regenerateReferencedSystemFilterPoolNames() {
ISystemFilterPoolReference[] fpRefs = getSystemFilterPoolReferences();
for (int idx=0; idx<fpRefs.length; idx++)
{
for (int idx = 0; idx < fpRefs.length; idx++) {
ISystemFilterPool pool = fpRefs[idx].getReferencedFilterPool();
if (pool != null)
fpRefs[idx].resetReferencedFilterPoolName(pool.getReferenceName());
if (pool != null) fpRefs[idx].resetReferencedFilterPoolName(pool.getReferenceName());
}
invalidateFilterPoolReferencesCache(); // just in case!
quietSave();
}
/**
* Return array of SystemFilterPoolReference objects.
* Result will never be null, although it may be an array of length zero.
*/
public ISystemFilterPoolReference[] getSystemFilterPoolReferences()
{
public ISystemFilterPoolReference[] getSystemFilterPoolReferences() {
IRSEBasePersistableReferencingObject[] refObjs = super.getReferencingObjects();
if (refObjs.length == 0)
return emptyFilterPoolRefArray;
else if ((fpRefsArray == null) || (fpRefsArray.length!=refObjs.length))
{
else if ((fpRefsArray == null) || (fpRefsArray.length != refObjs.length)) {
fpRefsArray = new ISystemFilterPoolReference[refObjs.length];
for (int idx = 0; idx < fpRefsArray.length; 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 deReference true to first de-reference all objects in the existing list.
*/
public void setSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolReferences,
boolean deReference)
{
public void setSystemFilterPoolReferences(ISystemFilterPoolReference[] filterPoolReferences, boolean deReference) {
super.setReferencingObjects(filterPoolReferences, deReference);
invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null))
caller.filterEventFilterPoolReferencesReset();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesReset();
quietSave();
}
@ -449,8 +396,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Add a filter pool referencing object to the list.
* @return the new count of referencing objects
*/
public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference)
{
public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) {
int count = addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in the addReferencingObject method
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
*/
public void resetSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, ISystemFilterPool newPool)
{
public void resetSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, ISystemFilterPool newPool) {
filterPoolReference.removeReference();
filterPoolReference.setReferencedObject(newPool);
if (fireEvents && (caller != null))
caller.filterEventFilterPoolReferenceReset(filterPoolReference);
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceReset(filterPoolReference);
quietSave();
// don't think we need to invalidate the cache
}
/**
* Remove a filter pool referencing object from the list.
* @param filterPool Reference the reference to remove
* @param deReference true if we want to dereference the referenced object (call removeReference on it)
* @return the new count of referencing objects
*/
public int removeSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference,
boolean deReference)
{
public int removeSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference, boolean deReference) {
int count = 0;
if (!deReference)
count = super.removeReferencingObject(filterPoolReference);
@ -487,24 +430,22 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
filterPoolReference.setParentReferenceManager(null); // DWD should be done in remove
invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null))
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
quietSave();
return count;
}
/**
* Return count of referenced filter pools
*/
public int getSystemFilterPoolReferenceCount()
{
public int getSystemFilterPoolReferenceCount() {
return super.getReferencingObjectCount();
}
/**
* 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);
}
@ -512,21 +453,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Move a given filter pool reference to a given zero-based location
* 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);
super.moveReferencingObjectPosition(pos, filterPoolRef);
invalidateFilterPoolReferencesCache();
// callback to provider so they can fire events in their GUI
if (!noSave)
quietSave();
if (fireEvents && (caller != null) && !noEvents)
{
if (!noSave) quietSave();
if (fireEvents && (caller != null) && !noEvents) {
ISystemFilterPoolReference[] refs = new ISystemFilterPoolReference[1];
refs[0] = filterPoolRef;
caller.filterEventFilterPoolReferencesRePositioned(refs, pos - oldPos);
}
}
/**
* 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
@ -536,8 +475,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* @param filterPoolRefs Array of SystemFilterPoolReferences to move.
* @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];
noEvents = noSave = true;
for (int idx = 0; idx < filterPoolRefs.length; idx++)
@ -551,11 +489,9 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
invalidateFilterPoolReferencesCache();
noEvents = noSave = false;
quietSave();
if (fireEvents && (caller!=null))
caller.filterEventFilterPoolReferencesRePositioned(filterPoolRefs, delta);
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesRePositioned(filterPoolRefs, delta);
}
// ----------------------------------------------
// 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
* Result will never be null, although it may be an array of length zero.
*/
public ISystemFilterPool[] getReferencedSystemFilterPools()
{
public ISystemFilterPool[] getReferencedSystemFilterPools() {
ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences();
ISystemFilterPool[] pools = new ISystemFilterPool[refs.length];
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.
*/
public boolean isSystemFilterPoolReferenced(ISystemFilterPool filterPool)
{
public boolean isSystemFilterPoolReferenced(ISystemFilterPool 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.
* @return the referencing object if found, else null
*/
public ISystemFilterPoolReference getReferenceToSystemFilterPool(ISystemFilterPool filterPool)
{
public ISystemFilterPoolReference getReferenceToSystemFilterPool(ISystemFilterPool 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.
* @return the new count of referencing objects
*/
public int removeReferenceToSystemFilterPool(ISystemFilterPool filterPool)
{
public int removeReferenceToSystemFilterPool(ISystemFilterPool filterPool) {
ISystemFilterPoolReference filterPoolReference = getReferenceToSystemFilterPool(filterPool);
int newCount = 0;
if (filterPoolReference != null)
{
if (filterPoolReference != null) {
filterPoolReference.removeReference(); // getReferencedFilterPool().removeReference(this)
newCount = removeReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in removeReferencingObject
invalidateFilterPoolReferencesCache();
quietSave();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null))
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
}
else
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
} else
newCount = getSystemFilterPoolReferenceCount();
return newCount;
}
/**
* A reference filter pool has been renamed. Update our stored name...
* <p> Calls back to inform provider
*/
public void renameReferenceToSystemFilterPool(ISystemFilterPool pool)
{
public void renameReferenceToSystemFilterPool(ISystemFilterPool pool) {
ISystemFilterPoolReference poolRef = null;
IRSEBasePersistableReferencingObject[] refs = getReferencingObjects();
for (int idx = 0; (poolRef == null) && (idx < refs.length); idx++)
if (refs[idx].getReferencedObject()==pool)
poolRef = (ISystemFilterPoolReference)refs[idx];
if (refs[idx].getReferencedObject() == pool) poolRef = (ISystemFilterPoolReference) refs[idx];
if (poolRef != null)
{
if (poolRef != null) {
String oldName = poolRef.getReferencedObjectName();
poolRef.resetReferencedFilterPoolName(pool.getReferenceName());
invalidateFilterPoolReferencesCache();
quietSave();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null))
caller.filterEventFilterPoolReferenceRenamed(poolRef,oldName);
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceRenamed(poolRef, oldName);
}
}
/**
* 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 deReference true to first de-reference all objects in the existing list.
*/
public void setSystemFilterPoolReferences(ISystemFilterPool[] filterPools,
boolean deReference)
{
public void setSystemFilterPoolReferences(ISystemFilterPool[] filterPools, boolean deReference) {
if (deReference)
super.removeAndDeReferenceAllReferencingObjects();
else
removeAllReferencingObjects();
// add current
if (filterPools != null)
{
for (int idx=0; idx<filterPools.length; idx++)
{
if (filterPools != null) {
for (int idx = 0; idx < filterPools.length; idx++) {
//addReferenceToSystemFilterPool(filterPools[idx]);
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]);
addReferencingObject(filterPoolReference);
@ -691,10 +614,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
invalidateFilterPoolReferencesCache();
quietSave();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller!=null))
caller.filterEventFilterPoolReferencesReset();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferencesReset();
}
}
// -------------------------
// 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
* 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
ISystemFilterPool pool = filter.getParentFilterPool();
ISystemFilterPoolReference poolRef = getReferenceToSystemFilterPool(pool);
@ -714,16 +636,15 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
else
return null;
}
/**
* Concatenate all filter references from all filter pools we reference, into one
* big list.
*/
public ISystemFilterReference[] getSystemFilterReferences(ISubSystem subSystem)
{
public ISystemFilterReference[] getSystemFilterReferences(ISubSystem subSystem) {
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
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);
for (int jdx = 0; jdx < filterRefs.length; 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
* being concatenated
*/
public int getSystemFilterReferencePosition(ISystemFilterReference filterRef)
{
public int getSystemFilterReferencePosition(ISystemFilterReference filterRef) {
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
int match = -1;
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());
for (int jdx=0; (match==-1) && (jdx<filterRefs.length); jdx++)
{
for (int jdx = 0; (match == -1) && (jdx < filterRefs.length); jdx++) {
if (filterRefs[jdx] == filterRef)
match = totalCount;
else
@ -757,21 +675,19 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
}
return match;
}
/**
* Given a filter, return its position within this reference manager
* when you think of all filter references from all filter pool references as
* being concatenated
*/
public int getSystemFilterReferencePosition(ISubSystem subSystem, ISystemFilter filter)
{
public int getSystemFilterReferencePosition(ISubSystem subSystem, ISystemFilter filter) {
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
int match = -1;
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);
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)
match = totalCount;
else
@ -784,23 +700,20 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
// -----------------------
// SAVE/RESTORE METHODS...
// -----------------------
private void quietSave()
{
try { save(); }
catch (Exception exc)
{
private void quietSave() {
try {
save();
} catch (Exception exc) {
}
}
/**
* Save all the filter pools to disk.
* Only called if the save policy is not none.
*/
public void save()
throws Exception
{
public void save() throws Exception {
//System.out.println("Saving filter pool " + this.getName() + "?"); // DWD - debugging
switch(savePolicy)
{
switch (savePolicy) {
// ONE FILE PER FILTER POOL REFERENCE MANAGER
case ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_MANAGER:
saveToOneFile();
@ -811,9 +724,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/**
* Save this reference manager to disk.
*/
protected boolean saveToOneFile()
throws Exception
{
protected boolean saveToOneFile() throws Exception {
/* FIXME
String saveFileName = getSaveFilePathAndName();
File saveFile = new File(saveFileName);
@ -850,7 +761,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return true;
}
/**
* Restore the filter pools from disk.
* 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
* wrong, an exception is thrown.
*/
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller,
IFolder mgrFolder, String name,
IRSEFilterNamingPolicy namingPolicy)
throws Exception
{
if (namingPolicy == null)
namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) throws Exception {
if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
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
}
return mgr;
@ -879,9 +783,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/**
* Restore the filter pools from disk, assuming default for prefix of name.
*/
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name)
throws Exception
{
public static ISystemFilterPoolReferenceManager restore(ISystemFilterPoolReferenceManagerProvider caller, IFolder mgrFolder, String name) throws Exception {
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 namingPolicy Naming prefix information for persisted data file names.
*/
protected static ISystemFilterPoolReferenceManager restoreFromOneFile(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy)
throws Exception
{
protected static ISystemFilterPoolReferenceManager restoreFromOneFile(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) throws Exception {
ISystemFilterPoolReferenceManager mgr = null;
/* FIXME
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
@ -934,9 +834,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
return mgr;
}
/**
* After restoring this from disk, there is only the referenced object name,
* 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
* were resolved.
*/
public Vector resolveReferencesAfterRestore(ISystemFilterPoolManagerProvider relatedPoolMgrProvider,
ISystemFilterPoolReferenceManagerProvider provider)
{
public Vector resolveReferencesAfterRestore(ISystemFilterPoolManagerProvider relatedPoolMgrProvider, ISystemFilterPoolReferenceManagerProvider provider) {
setSystemFilterPoolManagerProvider(relatedPoolMgrProvider); // sets poolMgrs = relatedManagers
setProvider(provider);
ISystemFilterPoolManager[] relatedManagers = getSystemFilterPoolManagers();
if (relatedManagers != null)
{
if (relatedManagers != null) {
Vector badRefs = new Vector();
ISystemFilterPoolReference[] poolRefs = getSystemFilterPoolReferences();
if (poolRefs != null)
{
for (int idx=0; idx<poolRefs.length; idx++)
{
if (poolRefs != null) {
for (int idx = 0; idx < poolRefs.length; idx++) {
String poolName = poolRefs[idx].getReferencedFilterPoolName();
String mgrName = poolRefs[idx].getReferencedFilterPoolManagerName();
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);
refdPool = relatedPoolMgrProvider.getSystemFilterPoolForBrokenReference(this, mgrName, poolName);
}
if (refdPool != null)
{
if (refdPool != null) {
poolRefs[idx].setReferenceToFilterPool(refdPool); // calls refdPool.addReference(poolRef)
}
else
{
} else {
badRefs.addElement(poolRefs[idx]);
}
}
if (badRefs.size() == 0)
return null;
else
{
for (int idx=0; idx<badRefs.size(); idx++)
{
else {
for (int idx = 0; idx < badRefs.size(); idx++) {
ISystemFilterPoolReference badRef = (ISystemFilterPoolReference) badRefs.elementAt(idx);
//badRef.setReferenceBroken(true);
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
* 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);
if (mgr == null)
return null;
if (mgr == null) return null;
return mgr.getSystemFilterPool(poolName);
}
/**
* Utility method to scan across all filter pool managers for a match on a give name.
* <p>
* @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
*/
public static ISystemFilterPoolManager getFilterPoolManager(ISystemFilterPoolManager[] mgrs, String mgrName)
{
public static ISystemFilterPoolManager getFilterPoolManager(ISystemFilterPoolManager[] mgrs, String mgrName) {
ISystemFilterPoolManager mgr = null;
for (int idx = 0; (mgr == null) && (idx < mgrs.length); idx++)
if (mgrs[idx].getName().equals(mgrName))
mgr = mgrs[idx];
if (mgrs[idx].getName().equals(mgrName)) mgr = mgrs[idx];
return mgr;
}
@ -1042,87 +925,72 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
// HELPER METHODS...
// ------------------
/**
* 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.
*/
protected static String getSaveFilePathAndName(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy)
{
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder))
+ getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(name));
protected static String getSaveFilePathAndName(IFolder mgrFolder, String name, IRSEFilterNamingPolicy namingPolicy) {
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder)) + getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(name));
}
/**
* Derive and return the unqualified file name used to store this to disk.
* It is unqualified.
*/
protected static String getSaveFileName(String fileNameNoSuffix)
{
protected static String getSaveFileName(String fileNameNoSuffix) {
return fileNameNoSuffix + ISystemFilterConstants.SAVEFILE_SUFFIX;
}
/**
* non-static version.
*/
protected String getSaveFilePathAndName()
{
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder))
+ getSaveFileName();
}
/**
* non-static version.
*/
protected String getSaveFileName()
{
return getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(getName()));
protected String getSaveFilePathAndName() {
return SystemFilter.addPathTerminator(getFolderPath(mgrFolder)) + getSaveFileName();
}
/**
* non-static version.
*/
protected String getSaveFileName() {
return getSaveFileName(namingPolicy.getReferenceManagerSaveFileName(getName()));
}
/**
* Return the folder that this manager is contained in.
*/
public IFolder getFolder()
{
public IFolder getFolder() {
return mgrFolder;
}
/**
* Reset the folder that this manager is contained in.
*/
public void resetManagerFolder(IFolder newFolder)
{
public void resetManagerFolder(IFolder newFolder) {
mgrFolder = newFolder;
}
/**
* Return the path of the folder
*/
public String getFolderPath()
{
public String getFolderPath() {
return getResourceHelpers().getFolderPath(mgrFolder);
}
/**
* Return the path of the given folder
*/
public static String getFolderPath(IFolder folder)
{
public static String getFolderPath(IFolder folder) {
return SystemResourceHelpers.getResourceHelpers().getFolderPath(folder);
}
/*
* To reduce typing...
*/
private SystemResourceHelpers getResourceHelpers()
{
private SystemResourceHelpers getResourceHelpers() {
return SystemResourceHelpers.getResourceHelpers();
}
public String toString()
{
public String toString() {
return getName();
}