### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.core Index: src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReferenceManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReferenceManager.java,v retrieving revision 1.2 diff -u -r1.2 SystemFilterPoolReferenceManager.java --- src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReferenceManager.java 12 Apr 2007 20:25:59 -0000 1.2 +++ src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReferenceManager.java 14 Apr 2007 17:38:26 -0000 @@ -16,6 +16,8 @@ package org.eclipse.rse.internal.core.filters; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import org.eclipse.core.resources.IFile; @@ -384,9 +386,10 @@ * Create a filter pool reference. This creates an unresolved raw reference that * must be added to the managed lists by the caller. * That will be attempted to be resolved on first use. + * @param filterPoolName the fully qualified filter pool name */ - private ISystemFilterPoolReference createSystemFilterPoolReference(ISystemFilterPoolManager filterPoolManager, String filterPoolName) { - ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolManager, filterPoolName); + private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) { + ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName); invalidateFilterPoolReferencesCache(); return filterPoolReference; } @@ -503,10 +506,16 @@ */ public ISystemFilterPool[] getReferencedSystemFilterPools() { ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences(); - ISystemFilterPool[] pools = new ISystemFilterPool[refs.length]; - for (int idx = 0; idx < pools.length; idx++) - pools[idx] = refs[idx].getReferencedFilterPool(); - return pools; + List pools = new ArrayList(refs.length); + for (int idx = 0; idx < refs.length; idx++) { + ISystemFilterPool pool = refs[idx].getReferencedFilterPool(); + if (pool != null) { + pools.add(pool); + } + } + ISystemFilterPool[] result = new ISystemFilterPool[pools.size()]; + pools.toArray(result); + return result; } /** @@ -542,8 +551,8 @@ /* (non-Javadoc) * @see org.eclipse.rse.filters.ISystemFilterPoolReferenceManager#addReferenceToSystemFilterPool(org.eclipse.rse.filters.ISystemFilterPoolManager, java.lang.String) */ - public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName) { - ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolManager, filterPoolName); + public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) { + ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName); addReferencingObject(filterPoolReference); filterPoolReference.setParentReferenceManager(this); invalidateFilterPoolReferencesCache(); Index: src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReference.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReference.java,v retrieving revision 1.2 diff -u -r1.2 SystemFilterPoolReference.java --- src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReference.java 4 Apr 2007 02:27:55 -0000 1.2 +++ src/org/eclipse/rse/internal/core/filters/SystemFilterPoolReference.java 14 Apr 2007 17:38:25 -0000 @@ -16,9 +16,6 @@ package org.eclipse.rse.internal.core.filters; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.rse.core.RSECorePlugin; @@ -35,6 +32,7 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.references.SystemPersistableReferencingObject; /** @@ -66,13 +64,10 @@ /** * Constructs a new filter pool reference. This is an unresolved reference. - * It is resolved on first use by using the supplied filterPoolManager. - * @param filterPoolManager the manager used to resolve the reference. * @param filterPoolName the name of the filter pool. */ - public SystemFilterPoolReference(ISystemFilterPoolManager filterPoolManager, String filterPoolName) { + public SystemFilterPoolReference(String filterPoolName) { this(); - this.filterPoolManager = filterPoolManager; setReferencedObjectName(filterPoolName); } @@ -105,28 +100,48 @@ * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolName() */ public String getReferencedFilterPoolName() { - String savedName = super.getReferencedObjectName(); - String poolName = null; - int idx = savedName.indexOf(DELIMITER); - if (idx >= 0) - poolName = savedName.substring(idx + DELIMITER_LENGTH); - else - poolName = savedName; - return poolName; + /* + * A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName. + * or in the unqualified form of filterPoolName which references a locally defined filter pool. + * ___ is the delimiter. Absence of the delimiter indicates an unqualified name. + * The filter pool manager name is the same as its owning profile. + */ + String savedName = getReferencedObjectName(); + String[] parts = savedName.split(DELIMITER, 2); + String result = parts[0]; + if (parts.length == 2) { + result = parts[1]; + } + return result; } /* (non-Javadoc) * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolManagerName() */ public String getReferencedFilterPoolManagerName() { - String savedName = super.getReferencedObjectName(); - String mgrName = null; - int idx = savedName.indexOf(DELIMITER); - if (idx >= 0) - mgrName = savedName.substring(0, idx); - else - mgrName = savedName; - return mgrName; + /* + * A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName. + * or in the unqualified form of filterPoolName which references a locally defined filter pool. + * ___ is the delimiter. Absence of the delimiter indicates an unqualified name. + * The filter pool manager name is the same as its owning profile. + */ + String result = null; + String savedName = getReferencedObjectName(); + String[] parts = savedName.split(DELIMITER, 2); + if (parts.length == 2) { + result = parts[0]; + } else { + ISystemFilterPoolReferenceManagerProvider provider = getProvider(); + if (provider instanceof ISubSystem) { + ISubSystem subsystem = (ISubSystem) provider; + ISystemProfile profile = subsystem.getSystemProfile(); + result = profile.getName(); + } + } + if (result == null) { + RSECorePlugin.getDefault().getLogger().logWarning("Unexpected condition: filter pool manager name not found.", null); //$NON-NLS-1$ + } + return result; } /* (non-Javadoc) @@ -150,28 +165,20 @@ ISystemFilterPool filterPool = (ISystemFilterPool) getReferencedObject(); if (filterPool == null) { String filterPoolName = getReferencedFilterPoolName(); + String profileName = getReferencedFilterPoolManagerName(); + ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); + ISystemProfile profile = registry.getSystemProfile(profileName); + ISubSystem subsystem = (ISubSystem) getProvider(); + ISubSystemConfiguration config = subsystem.getSubSystemConfiguration(); + filterPoolManager = config.getFilterPoolManager(profile); filterPool = filterPoolManager.getSystemFilterPool(filterPoolName); - if (filterPool == null) { - Pattern p = Pattern.compile("(^.*):"); //$NON-NLS-1$ - Matcher m = p.matcher(filterPoolName); - if (m.find()) { - String profileName = m.group(1); - ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); - ISystemProfile profile = registry.getSystemProfile(profileName); - if (profile != null) { - ISystemFilterPool[] pools = profile.getFilterPools(); - for (int i = 0; i < pools.length && filterPool == null; i++) { - ISystemFilterPool pool = pools[i]; - if (filterPoolName.equals(pool.getName())) filterPool = pool; - } - } - } - } - if (filterPool != null) { - setReferenceToFilterPool(filterPool); - } } - setReferenceBroken(filterPool == null); + if (filterPool != null) { + setReferenceToFilterPool(filterPool); + setReferenceBroken(false); + } else { + setReferenceBroken(true); + } return filterPool; } @@ -234,7 +241,7 @@ * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getFullName() */ public String getFullName() { - return super.getReferencedObjectName(); + return getReferencedObjectName(); } /* (non-Javadoc) Index: src/org/eclipse/rse/internal/core/filters/SystemFilterPool.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/filters/SystemFilterPool.java,v retrieving revision 1.6 diff -u -r1.6 SystemFilterPool.java --- src/org/eclipse/rse/internal/core/filters/SystemFilterPool.java 12 Apr 2007 20:25:59 -0000 1.6 +++ src/org/eclipse/rse/internal/core/filters/SystemFilterPool.java 14 Apr 2007 17:38:25 -0000 @@ -256,103 +256,22 @@ * @generated This field/method will be replaced during code generation. */ protected java.util.List filters = null; - private static SystemFilterPool _instance; -/** + + /** * Default constructor */ - protected SystemFilterPool() + public SystemFilterPool(String poolName, boolean allowNestedFilters, boolean isDeletable) { super(); helpers = new SystemFilterContainerCommonMethods(); - } - - public static SystemFilterPool getDefault() - { - if (_instance == null) - { - _instance = new SystemFilterPool(); + setRelease(RSECorePlugin.CURRENT_RELEASE); + if (!initialized) { + initialize(poolName, savePolicy, namingPolicy); } - return _instance; - } - - /** - * Static factory method for creating a new filter pool. Will - * first try to restore it, and if that fails will create a new instance and - * return it. - *
- * Use this method only if you are not using a SystemFilterPoolManager, else - * use the createSystemFilterPool method in that class. - * - * This folder will be created if it does not already exist. - * @param name the name of the filter pool. Typically this is also the name - * of the given folder, but this is not required. For the save policy of one file - * per pool, the name of the file is derived from this. - * @param allowNestedFilters true if filters inside this filter pool are - * to allow nested filters. - * @param isDeletable true if this filter pool is allowed to be deleted by users. - * @param tryToRestore true to attempt a restore first, false if a pure create operation. - */ - public ISystemFilterPool createSystemFilterPool( - String name, - boolean allowNestedFilters, - boolean isDeletable, - boolean tryToRestore) - { - - - SystemFilterPool pool = null; - if (tryToRestore) - { - try - { - pool = (SystemFilterPool)RSECorePlugin.getThePersistenceManager().restoreFilterPool(name); - } - catch (Exception exc) // real error trying to restore, versus simply not found. - { - // todo: something? Log the exception somewhere? - } - } - if (pool == null) // not found or some serious error. - { - pool = createPool(); - } - if (pool != null) - { - pool.initialize(name, allowNestedFilters, isDeletable); - } - return pool; - } - - // temporary! - //public boolean isSharable() {return isSharable; } - //public void setIsSharable(boolean is) { isSharable = is; } - - /* - * Private helper method. - * Uses MOF to create an instance of this class. - */ - protected static SystemFilterPool createPool() - { - ISystemFilterPool pool = new SystemFilterPool(); - // FIXME SystemFilterImpl.initMOF().createSystemFilterPool(); - pool.setRelease(RSECorePlugin.CURRENT_RELEASE); - return (SystemFilterPool)pool; - } - - /* - * Private helper method to initialize attributes - */ - protected void initialize(String name, - boolean allowNestedFilters, - boolean isDeletable) - { - if (!initialized) - initialize(name, savePolicy, namingPolicy); setDeletable(isDeletable); // mof attribute - //System.out.println("In initialize() for filter pool " + getName() + ". isDeletable= " + isDeletable); setSupportsNestedFilters(allowNestedFilters); // cascades to each filter - } - + } + /* * Private helper method to core initialization, from either createXXX or restore. */ Index: src/org/eclipse/rse/internal/core/filters/SystemFilterString.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/filters/SystemFilterString.java,v retrieving revision 1.4 diff -u -r1.4 SystemFilterString.java --- src/org/eclipse/rse/internal/core/filters/SystemFilterString.java 12 Apr 2007 20:25:59 -0000 1.4 +++ src/org/eclipse/rse/internal/core/filters/SystemFilterString.java 14 Apr 2007 17:38:28 -0000 @@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider; Index: src/org/eclipse/rse/core/model/RSEPersistableObject.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/RSEPersistableObject.java,v retrieving revision 1.1 diff -u -r1.1 RSEPersistableObject.java --- src/org/eclipse/rse/core/model/RSEPersistableObject.java 4 Apr 2007 02:27:54 -0000 1.1 +++ src/org/eclipse/rse/core/model/RSEPersistableObject.java 14 Apr 2007 17:38:22 -0000 @@ -1,11 +1,11 @@ package org.eclipse.rse.core.model; + public abstract class RSEPersistableObject implements IRSEPersistableContainer { private boolean _isDirty = false; private boolean _wasRestored = false; private boolean _isTainted = false; - private boolean _restoring = false; public RSEPersistableObject() { super(); @@ -16,21 +16,8 @@ } public final void setDirty(boolean flag) { - if (!_restoring) { - _isDirty = flag; - if (flag) { - setTainted(true); - } - } - } - - public final void beginRestore() { - _restoring = true; - } - - public final void endRestore() { - _restoring = false; - setWasRestored(true); + _isDirty = flag; + setTainted(flag); } public final boolean wasRestored() { @@ -46,19 +33,12 @@ } public final void setTainted(boolean flag) { - if (!_restoring) { - _isTainted = flag; - if (_isTainted) { - IRSEPersistableContainer parent = getPersistableParent(); - if (parent != null) { - parent.setTainted(true); - } - } else { - IRSEPersistableContainer[] children = getPersistableChildren(); - for (int i = 0; i < children.length; i++) { - IRSEPersistableContainer child = children[i]; - child.setTainted(false); - } + boolean taintParent = flag && !_isTainted; + _isTainted = flag; + if (taintParent) { + IRSEPersistableContainer parent = getPersistableParent(); + if (parent != null) { + parent.setTainted(true); } } } Index: src/org/eclipse/rse/core/model/ISystemRegistry.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java,v retrieving revision 1.11 diff -u -r1.11 ISystemRegistry.java --- src/org/eclipse/rse/core/model/ISystemRegistry.java 27 Mar 2007 18:42:44 -0000 1.11 +++ src/org/eclipse/rse/core/model/ISystemRegistry.java 14 Apr 2007 17:38:22 -0000 @@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterStartHere; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.ISubSystem; @@ -44,8 +43,6 @@ public ISystemFilterStartHere getSystemFilterStartHere(); - public ISystemFilterPool getSystemFilterPool(); - // ---------------------------------- // UI METHODS... // ---------------------------------- Index: src/org/eclipse/rse/core/model/ISystemProfileManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemProfileManager.java,v retrieving revision 1.5 diff -u -r1.5 ISystemProfileManager.java --- src/org/eclipse/rse/core/model/ISystemProfileManager.java 2 Mar 2007 18:54:02 -0000 1.5 +++ src/org/eclipse/rse/core/model/ISystemProfileManager.java 14 Apr 2007 17:38:21 -0000 @@ -16,6 +16,7 @@ package org.eclipse.rse.core.model; +import java.util.List; import java.util.Vector; /** @@ -44,11 +45,17 @@ public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive); /** - * @return an array of all existing profiles. + * @return an array of all existing profiles. This is guaranteed to contain the + * default private profile. */ public ISystemProfile[] getSystemProfiles(); /** + * @return the number of profiles known to this manager. + */ + public int getSize(); + + /** * @return an array of all existing profile names. */ public String[] getSystemProfileNames(); @@ -129,7 +136,9 @@ * @return The list of profiles known to this manager. This list is generated * at the point of this call and may thus be manipulated by the caller. */ - java.util.List getProfiles(); + public List getProfiles(); + + public void addSystemProfile(ISystemProfile profile); // /** // * Reusable method to return a name validator for renaming a profile. Index: src/org/eclipse/rse/core/model/RSEModelOperation.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/RSEModelOperation.java,v retrieving revision 1.2 diff -u -r1.2 RSEModelOperation.java --- src/org/eclipse/rse/core/model/RSEModelOperation.java 3 Jan 2007 16:44:01 -0000 1.2 +++ src/org/eclipse/rse/core/model/RSEModelOperation.java 14 Apr 2007 17:38:22 -0000 @@ -74,10 +74,8 @@ * Ends a transaction. Schedules all changed profiles for save. */ private static void endTransaction() { - ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); - ISystemProfileManager profileManager = registry.getSystemProfileManager(); IRSEPersistenceManager persistenceManager = RSECorePlugin.getDefault().getPersistenceManager(); - persistenceManager.commit(profileManager); + persistenceManager.commitProfiles(); } /** Index: src/org/eclipse/rse/core/model/IRSEPersistableContainer.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IRSEPersistableContainer.java,v retrieving revision 1.2 diff -u -r1.2 IRSEPersistableContainer.java --- src/org/eclipse/rse/core/model/IRSEPersistableContainer.java 4 Apr 2007 02:27:54 -0000 1.2 +++ src/org/eclipse/rse/core/model/IRSEPersistableContainer.java 14 Apr 2007 17:38:21 -0000 @@ -49,22 +49,7 @@ * @param flag true if the object was restored. */ public void setWasRestored(boolean flag); - - /** - * Notifies the object that it is being restored. Typically this will - * suppress any marking of the object as dirty and related objects as - * tainted while the restore is taking place. Should be used only by - * persistence providers. - */ - public void beginRestore(); - - /** - * Notifies the object that it is has been restored. This will - * enable the object to be marked as dirty if subsequent changes - * are made to it. Should be used only by persistence providers. - */ - public void endRestore(); - + /** * An object is dirty if a change has been made to it that requires * it to be persisted. @@ -106,8 +91,7 @@ * Sets the tainted attribute for this object. This should set to * true only by child objects when they have been marked dirty or tainted. * Setting this to true will cause all parent objects in the containment - * hierarchy to be marked tainted. Setting this to false will cause all - * children to be marked as not tainted. + * hierarchy to be marked tainted. * It should be set to false only by a persistence manager when the * object has been committed. * @param flag the tainted state of the object. Index: src/org/eclipse/rse/core/filters/SystemFilterPoolManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/filters/SystemFilterPoolManager.java,v retrieving revision 1.6 diff -u -r1.6 SystemFilterPoolManager.java --- src/org/eclipse/rse/core/filters/SystemFilterPoolManager.java 12 Apr 2007 20:25:59 -0000 1.6 +++ src/org/eclipse/rse/core/filters/SystemFilterPoolManager.java 14 Apr 2007 17:38:21 -0000 @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Vector; import org.eclipse.core.resources.IFile; @@ -25,15 +26,11 @@ import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.RSEPersistableObject; import org.eclipse.rse.core.references.IRSEBaseReferencingObject; import org.eclipse.rse.internal.core.filters.ISystemFilterConstants; +import org.eclipse.rse.internal.core.filters.SystemFilterPool; import org.eclipse.rse.logging.Logger; -import org.eclipse.rse.persistence.IRSEPersistenceManager; - -// -// /** * A filter pool manager manages filter pools. @@ -190,10 +187,7 @@ */ protected boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT; - /** - * @generated This field/method will be replaced during code generation. - */ - protected java.util.List pools = null; + protected List pools = null; /** * Constructor @@ -224,7 +218,7 @@ * individual filter pool level. * @param savePolicy The save policy for the filter pools and filters. One of the * following constants from the - * {@link org.eclipse.rse.internal.core.filters.ISystemFilterConstants SystemFilterConstants} interface: + * {@link ISystemFilterConstants} interface: *
Calls back to inform provider - * @param filterPoolManager the manager that can be used to resolve the reference. * @param filterPoolName the name of the filter pool being referenced. * @return new filter pool reference */ - public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName); + public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName); /** * Given a filter pool, locate the referencing object for it and remove it from the list. Index: src/org/eclipse/rse/persistence/dom/RSEDOMNode.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/dom/RSEDOMNode.java,v retrieving revision 1.2 diff -u -r1.2 RSEDOMNode.java --- src/org/eclipse/rse/persistence/dom/RSEDOMNode.java 3 Apr 2007 00:05:07 -0000 1.2 +++ src/org/eclipse/rse/persistence/dom/RSEDOMNode.java 14 Apr 2007 17:38:29 -0000 @@ -21,10 +21,8 @@ import java.util.List; public class RSEDOMNode implements Serializable { - /* - * Recommended for serializable objects. This should be updated if there is a schema change. - */ - private static final long serialVersionUID = 1L; + + private static final long serialVersionUID = 1L; // This should be updated if there is a schema change. protected String _type; protected String _name; protected RSEDOMNode _parent; @@ -219,5 +217,13 @@ public void setRestoring(boolean restoring) { this.restoring = restoring; } + + public void setName(String name) { + _name = name; + } + + public void setType(String type) { + _type = type; + } } \ No newline at end of file Index: src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java,v retrieving revision 1.3 diff -u -r1.3 RSEDOMExporter.java --- src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java 5 Apr 2007 19:28:07 -0000 1.3 +++ src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java 14 Apr 2007 17:38:29 -0000 @@ -31,7 +31,6 @@ import org.eclipse.rse.core.model.IPropertyType; import org.eclipse.rse.core.model.IRSEModelObject; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.IDelegatingConnectorService; import org.eclipse.rse.core.subsystems.IServerLauncherProperties; @@ -41,11 +40,10 @@ import org.eclipse.rse.persistence.dom.RSEDOMNode; public class RSEDOMExporter implements IRSEDOMExporter { + private static RSEDOMExporter _instance = new RSEDOMExporter(); private Map _domMap; - // private ISystemRegistry _registry; - /** * Constructor to create a new DOM exporter. */ @@ -53,10 +51,6 @@ _domMap = new HashMap(); } - public void setSystemRegistry(ISystemRegistry registry) { - // _registry = registry; - } - /** * @return the singleton instance of this exporter */ @@ -401,13 +395,13 @@ */ public RSEDOMNode createNode(RSEDOMNode parent, ISystemFilterPoolReference filterPoolReference, boolean clean) { RSEDOMNode node = findOrCreateNode(parent, IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE, filterPoolReference, clean); - + String name = filterPoolReference.getFullName(); + node.setName(name); // filter pool references must write out the fully qualified name of their referenced filter pool if (clean || node.isDirty()) { ISystemFilterPool filterPool = filterPoolReference.getReferencedFilterPool(); String refId = (filterPool != null) ? filterPool.getId() : "unknown"; //$NON-NLS-1$ node.addAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID, refId); } - createPropertySetNodes(node, filterPoolReference, clean); node.setDirty(false); return node; @@ -430,8 +424,7 @@ node.setDirty(true); } } - boolean newNode = (node == null); - if (newNode) { + if (node == null) { node = new RSEDOMNode(parent, type, name); } return node; Index: src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java,v retrieving revision 1.3 diff -u -r1.3 RSEDOMImporter.java --- src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java 12 Apr 2007 20:25:59 -0000 1.3 +++ src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java 14 Apr 2007 17:38:29 -0000 @@ -30,7 +30,6 @@ import org.eclipse.rse.core.model.IPropertyType; import org.eclipse.rse.core.model.IRSEModelObject; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.PropertyType; import org.eclipse.rse.core.subsystems.IConnectorService; @@ -40,13 +39,14 @@ import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.SubSystemFilterNamingPolicy; -import org.eclipse.rse.internal.core.filters.ISystemFilterConstants; +import org.eclipse.rse.internal.core.model.SystemProfile; +import org.eclipse.rse.internal.core.model.SystemProfileManager; import org.eclipse.rse.persistence.dom.IRSEDOMConstants; import org.eclipse.rse.persistence.dom.RSEDOM; import org.eclipse.rse.persistence.dom.RSEDOMNode; import org.eclipse.rse.persistence.dom.RSEDOMNodeAttribute; -public class RSEDOMImporter implements IRSEDOMImporter { +public class RSEDOMImporter { private static RSEDOMImporter _instance = new RSEDOMImporter(); private ISystemRegistry _registry; @@ -63,20 +63,17 @@ /** * Restores the profile represented by dom - * @param profileManager * @param dom * @return the restored profile */ - public ISystemProfile restoreProfile(ISystemProfileManager profileManager, RSEDOM dom) { - // create the profile + public ISystemProfile restoreProfile(RSEDOM dom) { String profileName = dom.getName(); boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue()); boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).getValue()); - ISystemProfile profile = profileManager.createSystemProfile(profileName, isActive); - + ISystemProfile profile = new SystemProfile(profileName, isActive); if (profile != null) { profile.setDefaultPrivate(defaultPrivate); - profileManager.makeSystemProfileActive(profile, isActive); + SystemProfileManager.getDefault().addSystemProfile(profile); // restore the children for the profile RSEDOMNode[] children = dom.getChildren(); for (int i = 0; i < children.length; i++) { @@ -130,7 +127,6 @@ restorePropertySet(host, child); } } - return host; } @@ -194,7 +190,7 @@ } public IServerLauncherProperties restoreServerLauncher(IConnectorService service, RSEDOMNode serverLauncherNode, IServerLauncherProperties sl) { - // restore all property sets + // restore all property sets RSEDOMNode[] psChildren = serverLauncherNode.getChildren(IRSEDOMConstants.TYPE_PROPERTY_SET); for (int p = 0; p < psChildren.length; p++) { RSEDOMNode psChild = psChildren[p]; @@ -232,7 +228,7 @@ subSystem = existingSubSystems[0]; } } - + if (subSystem == null) { // subSystem = factory.createSubSystemInternal(host); ISubSystem[] createdSystems = _registry.createSubSystems(host, new ISubSystemConfiguration[]{factory}); @@ -243,7 +239,6 @@ subSystem.setSubSystemConfiguration(factory); subSystem.setName(factory.getName()); subSystem.setConfigurationId(factory.getId()); - subSystem.setWasRestored(true); if (factory.supportsFilters()) { ISystemFilterStartHere startHere = _registry.getSystemFilterStartHere(); @@ -267,6 +262,7 @@ restorePropertySet(subSystem, psChild); } } + subSystem.wasRestored(); return subSystem; } @@ -304,10 +300,6 @@ // create the filter ISystemFilter filter = filterPool.createSystemFilter(name, filterStrings); - - filter.setWasRestored(true); - - // set filter attributes filter.setSupportsNestedFilters(supportsNestedFilters); filter.setRelativeOrder(relativeOrder); filter.setDefault(isDefault); @@ -361,26 +353,21 @@ filterPool = mgr.getSystemFilterPool(name); } if (filterPool == null) { - filterPool = _registry.getSystemFilterPool().createSystemFilterPool(name, supportsNestedFilters, isDeletable, ISystemFilterConstants.TRY_TO_RESTORE_NO); - - if (filterPool != null) { - filterPool.setSystemFilterPoolManager(mgr); - // add to model - mgr.getPools().add(filterPool); - } - } - if (filterPool != null) { - filterPool.setType(type); - filterPool.setDefault(isDefault); - filterPool.setSupportsNestedFilters(supportsNestedFilters); - filterPool.setStringsCaseSensitive(isSetStringsCaseSensitive); - filterPool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings); - filterPool.setRelease(release); - filterPool.setSingleFilterStringOnly(isSetSingleFilterStringOnly); - filterPool.setOwningParentName(owningParentName); - filterPool.setNonRenamable(isNonRenamable); - filterPool.setWasRestored(true); + filterPool = mgr.createSystemFilterPool(name, isDeletable); +// filterPool = new SystemFilterPool(name, supportsNestedFilters, isDeletable); +// filterPool.setSystemFilterPoolManager(mgr); +// mgr.getPools().add(filterPool); } + filterPool.setType(type); + filterPool.setDefault(isDefault); + filterPool.setSupportsNestedFilters(supportsNestedFilters); + filterPool.setStringsCaseSensitive(isSetStringsCaseSensitive); + filterPool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings); + filterPool.setRelease(release); + filterPool.setSingleFilterStringOnly(isSetSingleFilterStringOnly); + filterPool.setOwningParentName(owningParentName); + filterPool.setNonRenamable(isNonRenamable); +// filterPool.wasRestored(); } } catch (Exception e) { e.printStackTrace(); @@ -407,26 +394,15 @@ */ public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) { ISystemFilterPoolReference filterPoolReference = null; - String subsystemName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID).getValue(); String filterPoolName = node.getName(); - ISubSystemConfiguration configuration = getSubSystemConfiguration(subsystemName); - if (configuration != null) { - ISystemProfile profile = subsystem.getSystemProfile(); // DWD are there cases where this may be null? - ISystemFilterPoolManager filterPoolManager = configuration.getFilterPoolManager(profile); - ISystemFilterPool filterPool = filterPoolManager.getSystemFilterPool(filterPoolName); - ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager(); - /* - * DWD filterpool can be null when restoring since there can be forward references. - * A profile may be being restored that has references to a filter pool in a profile that doesn't yet exist. - * Need to create an "unresolved" reference instead of a null object and then patch them up on first access. - */ - // create reference to the filterpool - if (filterPool != null) { - filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPool); - } else { - filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolManager, filterPoolName); - } + String[] part = filterPoolName.split("___", 2); //$NON-NLS-1$ + if (part.length == 1) { // name is unqualified and refers to a filter pool in the current profile, ensure it is qualified + ISystemProfile profile = subsystem.getSystemProfile(); + String profileName = profile.getName(); + filterPoolName = profileName + "___" + filterPoolName; //$NON-NLS-1$ } + ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager(); + filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolName); return filterPoolReference; } Index: src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java,v retrieving revision 1.3 diff -u -r1.3 RSEPersistenceManager.java --- src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java 5 Apr 2007 02:03:34 -0000 1.3 +++ src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java 14 Apr 2007 17:38:28 -0000 @@ -16,11 +16,13 @@ package org.eclipse.rse.internal.persistence; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; @@ -29,19 +31,13 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.rse.core.IRSEPreferenceNames; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemResourceManager; -import org.eclipse.rse.core.filters.ISystemFilterPool; -import org.eclipse.rse.core.filters.ISystemFilterPoolManager; -import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider; -import org.eclipse.rse.core.filters.SystemFilterPoolManager; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemHostPool; +import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.internal.core.model.SystemProfileManager; import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter; import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter; import org.eclipse.rse.logging.Logger; @@ -58,347 +54,283 @@ public class RSEPersistenceManager implements IRSEPersistenceManager { private static final int STATE_NONE = 0; - private static final int STATE_IMPORTING = 1; - private static final int STATE_EXPORTING = 2; + private static final int STATE_LOADING = 1; + private static final int STATE_SAVING = 2; private static IProject remoteSystemsProject = null; - public static final String RESOURCE_PROJECT_NAME = "RemoteSystemsConnections"; //$NON-NLS-1$ + /** * Get the default remote systems project. - * @return IProject handle of the project. Use exists() to test existence. + * @return IProject handle of the project. */ public static IProject getRemoteSystemsProject() { if (remoteSystemsProject == null) { remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(); } - return remoteSystemsProject; } - private Map loadedProviders = new HashMap(10); + private Map knownProviders = new HashMap(10); private int _currentState = STATE_NONE; private RSEDOMExporter _exporter; - private RSEDOMImporter _importer; public RSEPersistenceManager(ISystemRegistry registry) { - // _registry = registry; _exporter = RSEDOMExporter.getInstance(); - _exporter.setSystemRegistry(registry); _importer = RSEDOMImporter.getInstance(); _importer.setSystemRegistry(registry); + getProviderExtensions(); } - public boolean commit(ISystemFilterPoolManager filterPoolManager) { - if (filterPoolManager.isDirty()) { - commit(filterPoolManager.getSystemProfile()); - filterPoolManager.setDirty(false); - } - return false; - } - - public boolean commit(ISystemHostPool connectionPool) { - if (connectionPool.isDirty()) { - commit(connectionPool.getSystemProfile()); - connectionPool.setDirty(false); - } - /* - Host[] connections = connectionPool.getHosts(); - for (int idx = 0; idx < connections.length; idx++) - { - if (!saveHost(connectionPool, connections[idx])) - { - return false; - } - } - return true; - */ - return false; // all persistence should be at profile level + public boolean isExporting() { + return _currentState == STATE_SAVING; + } + + public boolean isImporting() { + return _currentState == STATE_LOADING; + } + + public void registerPersistenceProvider(String id, IRSEPersistenceProvider provider) { + knownProviders.put(id, provider); } /** * Attempt to save single profile to disk. */ - public boolean commit(ISystemProfile profile) { + public boolean commitProfile(ISystemProfile profile) { + boolean result = false; if (profile != null) { - return save(profile, false); + result = save(profile, false); } - return false; + return result; } - /** - * Save all profiles to disk - */ - public boolean commit(ISystemProfileManager profileManager) { - - ISystemProfile[] profiles = profileManager.getSystemProfiles(); - for (int idx = 0; idx < profiles.length; idx++) { + public boolean commitProfiles() { + boolean ok = true; + ISystemProfile[] profiles = RSECorePlugin.getDefault().getSystemRegistry().getAllSystemProfiles(); + for (int idx = 0; idx < profiles.length && ok; idx++) { try { - commit(profiles[idx]); + ok = commitProfile(profiles[idx]); } catch (Exception exc) { Logger logger = RSECorePlugin.getDefault().getLogger(); String profileName = profiles[idx].getName(); String message = "Error saving profile " + profileName; //$NON-NLS-1$ logger.logError(message, exc); - return false; + ok = false; } } - - return true; + return ok; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.persistence.IRSEPersistenceManager#migrateProfile(org.eclipse.rse.core.model.ISystemProfile, org.eclipse.rse.persistence.IRSEPersistenceProvider) + */ + public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider) { + IRSEPersistenceProvider oldProvider = profile.getPersistenceProvider(); + oldProvider = (oldProvider == null) ? getDefaultPersistenceProvider() : oldProvider; + IRSEPersistenceProvider newProvider = persistenceProvider; + newProvider = (newProvider == null) ? getDefaultPersistenceProvider() : newProvider; + if (oldProvider != newProvider) { + profile.setPersistenceProvider(newProvider); + profile.commit(); + deleteProfile(oldProvider, profile.getName()); + } } /* (non-Javadoc) * @see org.eclipse.rse.persistence.IRSEPersistenceManager#deleteProfile(java.lang.String) */ - public void deleteProfile(final String profileName) { + public void deleteProfile(final IRSEPersistenceProvider persistenceProvider, final String profileName) { Job job = new Job(Messages.RSEPersistenceManager_DeleteProfileJobName) { protected IStatus run(IProgressMonitor monitor) { - IRSEPersistenceProvider provider = getRSEPersistenceProvider(); - IStatus result = provider.deleteProfile(profileName, monitor); + IRSEPersistenceProvider p = persistenceProvider != null ? persistenceProvider : getDefaultPersistenceProvider(); + IStatus result = p.deleteProfile(profileName, monitor); return result; } }; job.schedule(); } - private RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) { - RSEDOM dom = _exporter.createRSEDOM(profile, force); - return dom; + /* (non-Javadoc) + * @see org.eclipse.rse.persistence.IRSEPersistenceManager#restoreProfiles() + */ + public ISystemProfile[] restoreProfiles() { + List profiles = loadProfiles(); + ISystemProfile[] result = new ISystemProfile[profiles.size()]; + profiles.toArray(result); + return result; + } + + public ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName) { + ISystemProfile result = load(provider, profileName); + return result; } /** + * Returns the persistence provider denoted by the id. Only one instance of this + * persistence provider is created. + * @param id The id of the persistence provider, as denoted by the id attribute on its declaration. + * @return an IRSEPersistenceProvider which may be null if this id is not found. + */ + public IRSEPersistenceProvider getPersistenceProvider(String id) { + IRSEPersistenceProvider provider = null; + Object providerCandidate = knownProviders.get(id); + if (providerCandidate instanceof IConfigurationElement) { + IConfigurationElement element = (IConfigurationElement) providerCandidate; + try { + provider = (IRSEPersistenceProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + Logger logger = RSECorePlugin.getDefault().getLogger(); + logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$ + } + if (provider != null) { + knownProviders.put(id, provider); + } + } else if (providerCandidate instanceof IRSEPersistenceProvider) { + provider = (IRSEPersistenceProvider) providerCandidate; + } + return provider; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.persistence.IRSEPersistenceManager#getPersistenceProviderIds() + */ + public String[] getPersistenceProviderIds() { + Set ids = knownProviders.keySet(); + String[] result = new String[ids.size()]; + ids.toArray(result); + return result; + } + + /** * Retrieves the default persistence provider for this workbench configuration. * Several persistence providers may be registered, but the default one is used for all * profiles that do not have one explicitly specified. - * This persistence provider's identifier is specified in the org.eclipse.rse.core/defaultPersistenceProvider + * This persistence provider's identifier is specified in the org.eclipse.rse.core/DEFAULT_PERSISTENCE_PROVIDER * preference and can be specified a product's plugin_customization.ini file. * @see IRSEPreferenceNames * @return the default IRSEPersistenceProvider for this installation. */ - public IRSEPersistenceProvider getRSEPersistenceProvider() { + private IRSEPersistenceProvider getDefaultPersistenceProvider() { Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences(); - String providerName = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER); - IRSEPersistenceProvider provider = getRSEPersistenceProvider(providerName); + String providerId = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER); + IRSEPersistenceProvider provider = getPersistenceProvider(providerId); return provider; } /** - * Returns the persistence provider denoted by the id. Only one instance of this - * persistence provider is created. - * @param id The id of the persistence provider, as denoted by the id attribute on its declaration. - * @return an IRSEPersistenceProvider which may be null if this id is not found. + * Loads the map of known providers from the extensions made by all the plugins. + * This is done once at initialization of the manager. As these ids are resolved to + * their providers as needed, the configuration elements are replaced in the map + * by the persistence providers they reference. */ - public IRSEPersistenceProvider getRSEPersistenceProvider(String id) { + private void getProviderExtensions() { Logger logger = RSECorePlugin.getDefault().getLogger(); - IRSEPersistenceProvider provider = (IRSEPersistenceProvider) loadedProviders.get(id); - if (provider == null) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$ - for (int j = 0; j < providerCandidates.length; j++) { - IConfigurationElement providerCandidate = providerCandidates[j]; - if (providerCandidate.getName().equals("persistenceProvider")) { //$NON-NLS-1$ - String candidateId = providerCandidate.getAttribute("id"); //$NON-NLS-1$ - if (candidateId != null) { - if (candidateId.equals(id)) { - try { - provider = (IRSEPersistenceProvider) providerCandidate.createExecutableExtension("class"); //$NON-NLS-1$ - } catch (CoreException e) { - logger.logError("Exception loading persistence provider", e); //$NON-NLS-1$ - } - } - } else { - logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$ - } + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$ + for (int j = 0; j < providerCandidates.length; j++) { + IConfigurationElement configurationElement = providerCandidates[j]; + if (configurationElement.getName().equals("persistenceProvider")) { //$NON-NLS-1$ + String candidateId = configurationElement.getAttribute("id"); //$NON-NLS-1$ + if (candidateId != null) { + knownProviders.put(candidateId, configurationElement); } else { - logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$ + logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$ } + } else { + logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$ } - if (provider == null) { - logger.logError("Persistence provider not found.", null); //$NON-NLS-1$ - } - loadedProviders.put(id, provider); // even if provider is null } - return provider; } - private RSEDOM importRSEDOM(String domName) { - RSEDOM dom = null; - IRSEPersistenceProvider provider = getRSEPersistenceProvider(); - if (provider != null) { - dom = provider.loadRSEDOM(domName, null); - } else { - Logger logger = RSECorePlugin.getDefault().getLogger(); - logger.logError("Persistence provider is not available.", null); //$NON-NLS-1$ + private List loadProfiles() { + List profiles = new ArrayList(10); + String[] ids = getPersistenceProviderIds(); + for (int i = 0; i < ids.length; i++) { + String id = ids[i]; + IRSEPersistenceProvider provider = getPersistenceProvider(id); + if (provider != null) { + profiles.addAll(loadProfiles(provider)); + } } - return dom; + return profiles; } - public synchronized boolean isExporting() { - return _currentState == STATE_EXPORTING; - } - - public synchronized boolean isImporting() { - return _currentState == STATE_IMPORTING; + private List loadProfiles(IRSEPersistenceProvider persistenceProvider) { + List profiles = new ArrayList(10); + String[] profileNames = persistenceProvider.getSavedProfileNames(); + for (int i = 0; i < profileNames.length; i++) { + String profileName = profileNames[i]; + ISystemProfile profile = load(persistenceProvider, profileName); + profiles.add(profile); + } + return profiles; } /** - * Loads and restores RSE artifacts from the last session - * @param profileManager - * @return true if the profiles are loaded - */ - private boolean load(ISystemProfileManager profileManager) { - boolean successful = true; - synchronized(this) { - if (isExporting() || isImporting()) { - successful = false; - } else { - setState(STATE_IMPORTING); - } - } - if(successful) { - try { - IProject project = getRemoteSystemsProject(); - if (!project.isSynchronized(IResource.DEPTH_ONE)) project.refreshLocal(IResource.DEPTH_ONE, null); - IRSEPersistenceProvider persistenceProvider = getRSEPersistenceProvider(); - String[] profileNames = persistenceProvider.getSavedProfileNames(); - for (int i = 0; i < profileNames.length; i++) { - String profileName = profileNames[i]; - RSEDOM dom = importRSEDOM(profileName); - if (dom != null) { - ISystemProfile restoredProfile = _importer.restoreProfile(profileManager, dom); - if (restoredProfile == null) { - successful = false; - } - } else { - successful = false; - } - } - } catch (Exception e) { - e.printStackTrace(); - successful = false; - } finally { - setState(STATE_NONE); + * Loads a profile of the given name using the given persistence provider. If the provider cannot + * find a profile with that name, return null. + * @param provider the persistence provider that understands the name and can produce a profile. + * @param profileName the name of the profile to produce + * @return the profile or null + */ + private synchronized ISystemProfile load(IRSEPersistenceProvider provider, String profileName) { + ISystemProfile profile = null; + if (_currentState == STATE_NONE) { + _currentState = STATE_LOADING; + RSEDOM dom = provider.loadRSEDOM(profileName, null); + if (dom != null) { + SystemProfileManager.getDefault().setRestoring(true); + profile = _importer.restoreProfile(dom); + SystemProfileManager.getDefault().setRestoring(false); + profile.setPersistenceProvider(provider); + cleanTree(profile); } + _currentState = STATE_NONE; } - return successful; - } - - public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider) { - loadedProviders.put(id, provider); - } - - public boolean restore(ISystemFilterPool filterPool) { - //System.out.println("restore filterpool"); - // DWD function Is this method really needed? - return false; + return profile; } - - public boolean restore(ISystemHostPool connectionPool) { - return false; - } - - public boolean restore(ISystemProfileManager profileManager) { - return load(profileManager); - } - - public ISystemFilterPool restoreFilterPool(String name) { - //System.out.println("restore filter pool "+name); - // DWD function is this method really needed? - return null; - } - - /** - * Creates a filter pool manager for a particular SubSystemConfiguration and SystemProfile. Called - * "restore" for historcal reasons. - * @param profile the profile that will own this ISystemFilterPoolManager. There is one of these per profile. - * @param logger the logging object for logging errors. Each ISystemFilterPoolManager has one of these. - * @param caller The creator/owner of this ISystemFilterPoolManager, this ends up being a SubSystemConfiguration. - * @param name the name of the manager to restore. File name is derived from it when saving to one file. - * @return the "restored" manager. - */ - public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name) { - SystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile); - mgr.initialize(logger, caller, name); // core data - mgr.setWasRestored(false); // managers are not "restored from disk" since they are not persistent of themselves - return mgr; - } - + /** - * Restore a connection of a given name from disk... - */ - protected IHost restoreHost(ISystemHostPool hostPool, String connectionName) throws Exception { - /* - * FIXME //System.out.println("in SystemConnectionPoolImpl#restore for - * connection " + connectionName); String fileName = - * getRootSaveFileName(connectionName); - * //System.out.println(".......fileName = " + fileName); - * //System.out.println(".......folderName = " + - * getConnectionFolder(connectionName).getName()); java.util.List ext = - * getMOFHelpers().restore(getConnectionFolder(connectionName),fileName); - * // should be exactly one profile... Iterator iList = ext.iterator(); - * SystemConnection connection = (SystemConnection)iList.next(); if - * (connection != null) { if - * (!connection.getAliasName().equalsIgnoreCase(connectionName)) { - * RSEUIPlugin.logDebugMessage(this.getClass().getName(),"Incorrect - * alias name found in connections.xmi file for " + connectionName+". - * Name was reset"); connection.setAliasName(connectionName); // just in - * case! } internalAddConnection(connection); } return connection; - */ - return null; - } - - /** - * Restore a profile of a given name from disk... - */ - protected ISystemProfile restoreProfile(ISystemProfileManager mgr, String name) throws Exception { - /* - * FIXME String fileName = mgr.getRootSaveFileName(name); java.util.List - * ext = null;//FIXME - * getMOFHelpers().restore(SystemResourceManager.getProfileFolder(name),fileName); - * // should be exactly one profile... Iterator iList = ext.iterator(); - * SystemProfile profile = (SystemProfile)iList.next(); - * mgr.initialize(profile, name); return profile; - */ - return null; - } - - /** - * Writes the RSE model to a DOM and schedules writing of that DOM to disk. + * Writes a profile to a DOM and schedules writing of that DOM to disk. * May, in fact, update an existing DOM instead of creating a new one. * If in the process of importing, skip writing. * @return true if the profile is written to a DOM */ - private boolean save(ISystemProfile profile, boolean force) { - boolean result = false; - boolean acquiredLock = false; - synchronized(this) { - if (!isImporting()) { - setState(STATE_EXPORTING); - acquiredLock = true; + private synchronized boolean save(ISystemProfile profile, boolean force) { + if (_currentState == STATE_NONE) { + _currentState = STATE_SAVING; + IRSEPersistenceProvider provider = profile.getPersistenceProvider(); + if (provider == null) { + provider = getDefaultPersistenceProvider(); + profile.setPersistenceProvider(provider); } - } - if (acquiredLock) { - try { - RSEDOM dom = exportRSEDOM(profile, true); // DWD should do merge, but does not handle deletes properly yet - result = true; - if (dom.needsSave()) { - Job job = dom.getSaveJob(); - if (job == null) { - job = new SaveRSEDOMJob(dom, getRSEPersistenceProvider()); - dom.setSaveJob(job); - } - job.schedule(3000); // three second delay + RSEDOM dom = null; // DWD should do merge, but does not handle deletes properly yet + dom = _exporter.createRSEDOM(profile, force); + cleanTree(profile); + if (dom.needsSave()) { + Job job = dom.getSaveJob(); + if (job == null) { + job = new SaveRSEDOMJob(dom, getDefaultPersistenceProvider()); + dom.setSaveJob(job); } - } finally { - setState(STATE_NONE); + job.schedule(3000); // three second delay } + _currentState = STATE_NONE; } - return result; + return true; } - - private synchronized void setState(int state) { - _currentState = state; + + private void cleanTree(IRSEPersistableContainer node) { + node.setWasRestored(true); + node.setTainted(false); + node.setDirty(false); + IRSEPersistableContainer[] children = node.getPersistableChildren(); + for (int i = 0; i < children.length; i++) { + IRSEPersistableContainer child = children[i]; + cleanTree(child); + } } } \ No newline at end of file Index: src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java,v retrieving revision 1.6 diff -u -r1.6 AbstractConnectorService.java --- src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java 4 Apr 2007 02:27:54 -0000 1.6 +++ src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java 14 Apr 2007 17:38:23 -0000 @@ -22,7 +22,6 @@ import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.RSEModelObject; @@ -253,7 +252,10 @@ public IRSEPersistableContainer[] getPersistableChildren() { List children = new ArrayList(20); - children.add(getRemoteServerLauncherProperties()); + IServerLauncherProperties launcherProperties = getRemoteServerLauncherProperties(); + if (launcherProperties != null) { + children.add(getRemoteServerLauncherProperties()); + } children.addAll(_registeredSubSystems); IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()]; children.toArray(result); Index: src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java,v retrieving revision 1.4 diff -u -r1.4 AbstractDelegatingConnectorService.java --- src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java 4 Apr 2007 02:27:54 -0000 1.4 +++ src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java 14 Apr 2007 17:38:23 -0000 @@ -18,7 +18,6 @@ import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IRSEPersistableContainer; -import org.eclipse.rse.core.model.RSEPersistableObject; public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService { @@ -752,6 +751,9 @@ return false; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IRSEPersistableContainer#isTainted() + */ public boolean isTainted() { IConnectorService conServ = getRealConnectorService(); if (conServ != null) @@ -761,6 +763,9 @@ return false; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IRSEPersistableContainer#setTainted(boolean) + */ public void setTainted(boolean flag) { IConnectorService conServ = getRealConnectorService(); if (conServ != null) @@ -769,26 +774,16 @@ } } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent() + */ public IRSEPersistableContainer getPersistableParent() { return getHost(); } - public void beginRestore() { - IConnectorService conServ = getRealConnectorService(); - if (conServ != null) - { - conServ.beginRestore(); - } - } - - public void endRestore() { - IConnectorService conServ = getRealConnectorService(); - if (conServ != null) - { - conServ.endRestore(); - } - } - + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableChildren() + */ public IRSEPersistableContainer[] getPersistableChildren() { IConnectorService conServ = getRealConnectorService(); if (conServ != null) Index: src/org/eclipse/rse/core/SystemResourceManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemResourceManager.java,v retrieving revision 1.4 diff -u -r1.4 SystemResourceManager.java --- src/org/eclipse/rse/core/SystemResourceManager.java 22 Mar 2007 12:42:54 -0000 1.4 +++ src/org/eclipse/rse/core/SystemResourceManager.java 14 Apr 2007 17:38:17 -0000 @@ -274,17 +274,6 @@ } */ - // ----------------------------------- - // GET A SPECIFIC PROFILE FOLDER... - // ----------------------------------- - /** - * Get profiles folder for a given profile - */ - public static IFolder getProfileFolder(ISystemProfile profile) - { - return getProfileFolder(profile.getName()); - } - /** * Get profiles folder for a given profile name */ @@ -293,9 +282,6 @@ return getResourceHelpers().getOrCreateFolder(getRemoteSystemsProject(),profileName); } - - - /* * -------------------------------------------------------------------------------------------------------------------------------- * USER ACTIONS SUBTREE FOLDER METHODS... Index: src/org/eclipse/rse/persistence/IRSEPersistenceManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/persistence/IRSEPersistenceManager.java,v retrieving revision 1.2 diff -u -r1.2 IRSEPersistenceManager.java --- src/org/eclipse/rse/persistence/IRSEPersistenceManager.java 4 Apr 2007 02:27:54 -0000 1.2 +++ src/org/eclipse/rse/persistence/IRSEPersistenceManager.java 14 Apr 2007 17:38:29 -0000 @@ -16,84 +16,89 @@ package org.eclipse.rse.persistence; -import org.eclipse.rse.core.filters.ISystemFilterPool; -import org.eclipse.rse.core.filters.ISystemFilterPoolManager; -import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider; -import org.eclipse.rse.core.model.ISystemHostPool; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemProfileManager; -import org.eclipse.rse.logging.Logger; public interface IRSEPersistenceManager { - public boolean commit(ISystemFilterPoolManager filterPoolManager); - /** - * Save all connections in the connection pool - * @param connectionPool + * Save a particular profile. If the profile has an existing persistence provider + * it is saved by that persistence provider. If the profile has no persistence provider + * then the default persistence provider is used. + * @param profile the profile to save * @return true if successful */ - public boolean commit(ISystemHostPool connectionPool); + public boolean commitProfile(ISystemProfile profile); /** - * Save this profile - * @param profile + * Save all profiles. * @return true if successful */ - public boolean commit(ISystemProfile profile); + public boolean commitProfiles(); /** - * Save all profiles - * @param profileManager - * @return true if successful + * Restore all profiles + * @return an array of restored profiles. + */ + public ISystemProfile[] restoreProfiles(); + + /** + * Restore a profiles particular provider by name. + * @param provider a persistence provider + * @param profileName the name of the profile to restore + * @return the restored profile or null if no profile of that name is known to this provider. */ - public boolean commit(ISystemProfileManager profileManager); + public ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName); /** * Delete the persistent form of a profile. + * @param persistenceProvider the persistence provider to use to delete the profile. + * If this is null the default persistence provider is used. * @param profileName The name of the profile to delete */ - public void deleteProfile(String profileName); - - public boolean isExporting(); - - public boolean isImporting(); + public void deleteProfile(IRSEPersistenceProvider persistenceProvider, String profileName); + + /** + * Migrates a profile to a new persistence provider. It will delete the persistent form known to its previous + * persistence provider. If the new provider and the previous provider are the same this does nothing. + * @param profile the system profile to be migrated + * @param persistenceProvider the persistence provider to which this profile will be migrated. + */ + public void migrateProfile(ISystemProfile profile, IRSEPersistenceProvider persistenceProvider); /** * Register the persistence provider to be used when saving and restoring RSE doms. * The provider is registered under the provided id. + * If the id has already been registered, this provider replaces the previous provider + * with that id. * @param id the provider id. * @param provider the provider. */ - public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider); - + public void registerPersistenceProvider(String id, IRSEPersistenceProvider provider); + /** - * Restore all the filters for the filter pool - * @param filterPool - * @return true if sucessful + * @return an array of persistence provider ids known to this workbench. These may have been + * provided by extension point or by registering them using + * {@link #registerPersistenceProvider(String, IRSEPersistenceProvider)} */ - public boolean restore(ISystemFilterPool filterPool); - + public String[] getPersistenceProviderIds(); + /** - * Restore all connections in the connection pool - * @param connectionPool - * @return true if successful + * Retrieves the persistence provider named by a particular id. It can return null if there + * is no provider known by that id. This may have the effect of activating the plugin that + * contains this provider. + * @param id the id of the persistence provider to locate + * @return the persistence provider or null */ - public boolean restore(ISystemHostPool connectionPool); + public IRSEPersistenceProvider getPersistenceProvider(String id); /** - * Restore all profiles - * @param profileManager - * @return true if successful + * @return true if this instance of the persistence manager is currently exporting a profile. */ - public boolean restore(ISystemProfileManager profileManager); + public boolean isExporting(); /** - * Restore the filter pool - * @param name - * @return the filter pool if successful + * @return true if this instance of the persistence manager is currently importing a profile. */ - public ISystemFilterPool restoreFilterPool(String name); + public boolean isImporting(); - public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name); } \ No newline at end of file Index: src/org/eclipse/rse/internal/core/model/SystemProfileManager.java =================================================================== RCS file: src/org/eclipse/rse/internal/core/model/SystemProfileManager.java diff -N src/org/eclipse/rse/internal/core/model/SystemProfileManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rse/internal/core/model/SystemProfileManager.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,476 @@ +/******************************************************************************** + * Copyright (c) 2006, 2007 IBM Corporation. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * David Dykstal (IBM) - created and used RSEPreferencesManager + * - moved SystemPreferencesManager to a new plugin + ********************************************************************************/ + +package org.eclipse.rse.internal.core.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.RSEPreferencesManager; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.model.ISystemProfileManager; +import org.eclipse.rse.logging.Logger; +import org.eclipse.rse.persistence.IRSEPersistenceProvider; + +/** + * A class that manages a list of SystemProfile objects. + * This should be used as a singleton. + */ +public class SystemProfileManager implements ISystemProfileManager { + + private List _profiles = new ArrayList(10); +// private String[] profileNames = null; +// private Vector profileNamesVector = null; + private static SystemProfileManager singleton = null; + private boolean restoring = false; + + /** + * Ordinarily there should be only one instance of a SystemProfileManager + * created on the system, so the static method {@link #getDefault()} is + * preferred to using this. + */ + private SystemProfileManager() { + } + + /** + * @return (and create if necessary) the singleton instance of this class. + */ + public static SystemProfileManager getDefault() { + if (singleton == null) { + singleton = new SystemProfileManager(); + RSECorePlugin.getThePersistenceManager().restoreProfiles(); + } + return singleton; + } + + /** + * Clear the default after a team sychronization say + */ + public static void clearDefault() { + singleton = null; + } + + /** + * Create a new profile with the given name, and add to the list. + * The name must be unique within the existing list. + *
+ * The underlying folder is created in the file system. + *
+ * @param name What to name this profile
+ * @param makeActive true if this profile is to be added to the active profile list.
+ * @return new profile, or null if name not unique.
+ * @see ISystemProfileManager#createSystemProfile(String, boolean)
+ */
+ public ISystemProfile createSystemProfile(String name, boolean makeActive) {
+ ISystemProfile existingProfile = getSystemProfile(name);
+ if (existingProfile != null) {
+ deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile
+ }
+ ISystemProfile newProfile = internalCreateSystemProfile(name);
+ if (makeActive) {
+ RSEPreferencesManager.addActiveProfile(name);
+ ((SystemProfile) newProfile).setActive(makeActive);
+ }
+ newProfile.commit();
+ return newProfile;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#makeSystemProfileActive(org.eclipse.rse.core.model.ISystemProfile, boolean)
+ */
+ public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) {
+ boolean wasActive = isSystemProfileActive(profile.getName());
+ if (wasActive && !makeActive)
+ RSEPreferencesManager.deleteActiveProfile(profile.getName());
+ else if (makeActive && !wasActive) RSEPreferencesManager.addActiveProfile(profile.getName());
+ ((SystemProfile) profile).setActive(makeActive);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
+ */
+ public ISystemProfile[] getSystemProfiles() {
+ return getSystemProfiles(!restoring);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames()
+ */
+ public String[] getSystemProfileNames() {
+ ISystemProfile[] profiles = getSystemProfiles();
+ String[] profileNames = new String[profiles.length];
+ for (int i = 0; i < profiles.length; i++) {
+ ISystemProfile profile = profiles[i];
+ profileNames[i] = profile.getName();
+ }
+ return profileNames;
+// if (profileNames == null) {
+// ISystemProfile[] profiles = getSystemProfiles();
+// profileNames = new String[profiles.length];
+// for (int idx = 0; idx < profiles.length; idx++)
+// profileNames[idx] = profiles[idx].getName();
+// }
+// return profileNames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector()
+ */
+ public Vector getSystemProfileNamesVector() {
+ List names = Arrays.asList(getSystemProfileNames());
+ Vector result = new Vector(names.size());
+ result.addAll(names);
+ return result;
+// if (profileNamesVector == null) {
+// ISystemProfile[] profiles = getSystemProfiles();
+// profileNamesVector = new Vector(profiles.length);
+// for (int idx = 0; idx < profiles.length; idx++)
+// profileNamesVector.addElement(profiles[idx].getName());
+// }
+// return profileNamesVector;
+ }
+
+// /**
+// * Something changed so invalide cache of profiles so it will be regenerated
+// */
+// protected void invalidateCache() {
+// profileNames = null;
+// profileNamesVector = null;
+// }
+//
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
+ */
+ public ISystemProfile getSystemProfile(String name) {
+ ISystemProfile[] profiles = getSystemProfiles();
+ if ((profiles == null) || (profiles.length == 0)) return null;
+ ISystemProfile match = null;
+ for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
+ if (profiles[idx].getName().equals(name)) match = profiles[idx];
+ return match;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
+ */
+ public void renameSystemProfile(ISystemProfile profile, String newName) {
+ boolean isActive = isSystemProfileActive(profile.getName());
+ String oldName = profile.getName();
+ profile.setName(newName);
+ if (isActive) RSEPreferencesManager.renameActiveProfile(oldName, newName);
+// invalidateCache();
+ // FIXME RSEUIPlugin.getThePersistenceManager().save(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#deleteSystemProfile(org.eclipse.rse.core.model.ISystemProfile, boolean)
+ */
+ public void deleteSystemProfile(ISystemProfile profile, boolean persist) {
+ String oldName = profile.getName();
+ boolean isActive = isSystemProfileActive(oldName);
+ _profiles.remove(profile);
+ /* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager,
+ * so just removing it from the manager is not enough, it must also be removed from its resource.
+ * No longer needed since EMF is not in use.
+ * Resource res = profile.eResource();
+ * if (res != null)
+ * res.getContents().remove(profile);
+ */
+ if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName);
+// invalidateCache();
+ if (persist) {
+ IRSEPersistenceProvider provider = profile.getPersistenceProvider();
+ RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#cloneSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
+ */
+ public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName) {
+ ISystemProfile newProfile = createSystemProfile(newName, false);
+ return newProfile;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String)
+ */
+ public boolean isSystemProfileActive(String profileName) {
+ String[] activeProfiles = getActiveSystemProfileNames();
+ boolean match = false;
+ for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
+ if (activeProfiles[idx].equals(profileName)) match = true;
+ }
+ return match;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles()
+ */
+ public ISystemProfile[] getActiveSystemProfiles() {
+ String[] profileNames = getActiveSystemProfileNames();
+ ISystemProfile[] profiles = new ISystemProfile[profileNames.length];
+ for (int idx = 0; idx < profileNames.length; idx++) {
+ profiles[idx] = getOrCreateSystemProfile(profileNames[idx]);
+ ((SystemProfile) profiles[idx]).setActive(true);
+ }
+ return profiles;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames()
+ */
+ public String[] getActiveSystemProfileNames() {
+ String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles();
+ // dy: defect 48355, need to sync this with the actual profile list. If the user
+ // imports old preference settings or does a team sync and a profile is deleted then
+ // it is possible an active profile no longer exists.
+ // String[] systemProfileNames = getSystemProfileNames();
+ ISystemProfile[] systemProfiles = getSystemProfiles();
+ boolean found;
+ boolean found_team = false;
+ boolean found_private = false;
+ boolean changed = false;
+ String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
+
+ for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
+ // skip Team and Private profiles
+ String activeProfileName = activeProfileNames[activeIdx];
+ if (activeProfileName.equals(defaultProfileName)) {
+ found_private = true;
+ } else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) {
+ found_team = true;
+ } else {
+ found = false;
+ for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
+ if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ // The active profile no longer exists so remove it from the active list
+ RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]);
+ changed = true;
+ }
+ }
+ }
+
+ for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
+ boolean matchesBoth = false;
+ String name = systemProfiles[systemIdx].getName();
+
+ for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
+ String aname = activeProfileNames[activeIdx];
+ if (name.equals(aname)) {
+ matchesBoth = true;
+ }
+
+ }
+ if (!matchesBoth && found_private) {
+ if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
+ RSEPreferencesManager.addActiveProfile(name);
+ RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName());
+ activeProfileNames = RSEPreferencesManager.getActiveProfiles();
+ }
+ }
+ }
+
+ // the active profiles list needed to be changed because of an external update, also
+ // check if Default profile needs to be added back to the list
+ if (changed || !found_team || !found_private) {
+ if (systemProfiles.length == 0) {
+ // First time user, make sure default is in the active list, the only time it wouldn't
+ // be is if the pref_store.ini was modified (because the user imported old preferences)
+ if (!found_team) {
+ RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName());
+ changed = true;
+ }
+
+ if (!found_private) {
+ RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName());
+ changed = true;
+ }
+ } else {
+ ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
+ if (defaultProfile != null && !found_private) {
+ RSEPreferencesManager.addActiveProfile(defaultProfile.getName());
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ activeProfileNames = RSEPreferencesManager.getActiveProfiles();
+ }
+ }
+
+ return activeProfileNames;
+ }
+
+ /**
+ * @return the profile names currently selected by the user as "active" profiles
+ */
+ public Vector getActiveSystemProfileNamesVector() {
+ String[] profileNames = RSEPreferencesManager.getActiveProfiles();
+ Vector v = new Vector(profileNames.length);
+ for (int idx = 0; idx < profileNames.length; idx++)
+ v.addElement(profileNames[idx]);
+ return v;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfilePosition(java.lang.String)
+ */
+ public int getActiveSystemProfilePosition(String profileName) {
+ String[] profiles = getActiveSystemProfileNames();
+ int pos = -1;
+ for (int idx = 0; (pos < 0) && (idx < profiles.length); idx++) {
+ if (profiles[idx].equals(profileName)) pos = idx;
+ }
+ return pos;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
+ */
+ public ISystemProfile getDefaultPrivateSystemProfile() {
+ return getSystemProfile(RSEPreferencesManager.getDefaultPrivateSystemProfileName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
+ */
+ public ISystemProfile getDefaultTeamSystemProfile() {
+ return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getProfiles()
+ */
+ public List getProfiles() {
+ List result = new ArrayList(_profiles.size());
+ result.addAll(_profiles);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSize()
+ */
+ public int getSize() {
+ return _profiles.size();
+ }
+
+ /**
+ * Adds a newly restored profile to this manager
+ * @param profile the profile to add
+ */
+ public void addSystemProfile(ISystemProfile profile) {
+ _profiles.add(profile);
+ String name = profile.getName();
+ if (profile.isActive()) {
+ RSEPreferencesManager.addActiveProfile(name);
+ }
+ profile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
+ }
+
+ private ISystemProfile[] getSystemProfiles(boolean ensureDefaultPrivateProfileExists) {
+ if (ensureDefaultPrivateProfileExists) {
+ ensureDefaultPrivateProfile();
+ }
+ ISystemProfile[] result = new ISystemProfile[_profiles.size()];
+ _profiles.toArray(result);
+ return result;
+ }
+
+ public void setRestoring(boolean flag) {
+ restoring = flag;
+ }
+
+ private ISystemProfile internalCreateSystemProfile(String name) {
+ ISystemProfile newProfile = new SystemProfile();
+ newProfile.setName(name);
+ newProfile.setProfileManager(this);
+ _profiles.add(newProfile);
+ // invalidateCache();
+ newProfile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
+ return newProfile;
+ }
+
+ private void ensureDefaultPrivateProfile() {
+ // Ensure that one Profile is the default Profile - defect 48995 NH
+ boolean defaultProfileExists = false;
+ for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
+ ISystemProfile profile = (ISystemProfile) z.next();
+ defaultProfileExists = profile.isDefaultPrivate();
+ }
+ if (!defaultProfileExists) {
+ // find one with the right name
+ String defaultPrivateProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
+ for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
+ ISystemProfile profile = (ISystemProfile) z.next();
+ if (profile.getName().equals(defaultPrivateProfileName)) {
+ profile.setDefaultPrivate(true);
+ defaultProfileExists = true;
+ }
+ }
+ }
+ if (!defaultProfileExists) {
+ // Find the first profile that is not the Team profile and make it the default private profile
+ String defaultTeamProfileName = RSEPreferencesManager.getDefaultTeamProfileName();
+ for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
+ ISystemProfile profile = (ISystemProfile) z.next();
+ if (!profile.getName().equals(defaultTeamProfileName)) {
+ profile.setDefaultPrivate(true);
+ defaultProfileExists = true;
+ }
+ }
+ }
+ if (!defaultProfileExists) {
+ // If Team is the only profile - then put a message in the log and create the default private profile
+ Logger logger = RSECorePlugin.getDefault().getLogger();
+ logger.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
+ createDefaultPrivateProfile();
+ }
+ }
+
+ private void createDefaultPrivateProfile() {
+ ISystemProfile profile = new SystemProfile();
+ String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
+ profile.setName(initProfileName);
+ profile.setDefaultPrivate(true);
+ _profiles = new ArrayList();
+ _profiles.add(profile);
+ }
+
+ /**
+ * Instantiate a user profile given its name.
+ * @param userProfileName the name of the profile to find or create
+ * @return the profile that was found or created.
+ */
+ private ISystemProfile getOrCreateSystemProfile(String userProfileName) {
+ ISystemProfile userProfile = getSystemProfile(userProfileName);
+ if (userProfile == null) {
+ userProfile = internalCreateSystemProfile(userProfileName);
+ }
+ return userProfile;
+ }
+
+}
Index: src/org/eclipse/rse/internal/core/model/SystemProfile.java
===================================================================
RCS file: src/org/eclipse/rse/internal/core/model/SystemProfile.java
diff -N src/org/eclipse/rse/internal/core/model/SystemProfile.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/rse/internal/core/model/SystemProfile.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,240 @@
+/********************************************************************************
+ * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * David Dykstal (IBM) - 142806: refactoring persistence framework
+ ********************************************************************************/
+
+package org.eclipse.rse.internal.core.model;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.filters.ISystemFilterPool;
+import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.IRSEPersistableContainer;
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.core.model.ISystemProfileManager;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.model.RSEModelObject;
+import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
+import org.eclipse.rse.persistence.IRSEPersistenceProvider;
+
+/**
+ * A profile contains hosts and filter pools. It is the unit of save/restore for RSE model
+ * objects. All model objects are contained within a profile.
+ */
+public class SystemProfile extends RSEModelObject implements ISystemProfile, IAdaptable
+{
+
+ private ISystemProfileManager mgr = null;
+ private IRSEPersistenceProvider provider = null;
+ private boolean isActive = true;
+ private String name = null;
+ private boolean defaultPrivate = false;
+
+ /**
+ * Default constructor
+ */
+ protected SystemProfile()
+ {
+ super();
+ }
+
+ public SystemProfile(String name, boolean isActive) {
+ this.name = name;
+ this.isActive = isActive;
+ }
+
+ /**
+ * Set the in-memory pointer back to the parent system profile manager
+ */
+ public void setProfileManager(ISystemProfileManager mgr)
+ {
+ this.mgr = mgr;
+ }
+
+ /**
+ * Get the in-memory pointer back to the parent system profile manager
+ */
+ public ISystemProfileManager getProfileManager()
+ {
+ return mgr;
+ }
+
+ /**
+ * Convenience method for create a new connection within this profile.
+ * Shortcut for {@link ISystemRegistry#createHost(String,String,String,String)}
+ */
+ public IHost createHost(String systemType, String connectionName, String hostName, String description) throws Exception
+ {
+ return RSECorePlugin.getDefault().getSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description);
+ }
+
+ /**
+ * Return all connections for this profile
+ */
+ public IHost[] getHosts()
+ {
+ return RSECorePlugin.getDefault().getSystemRegistry().getHostsByProfile(this);
+ }
+
+ /**
+ * Return all filter pools for this profile
+ */
+ public ISystemFilterPool[] getFilterPools()
+ {
+ ISubSystemConfiguration[] ssFactories = RSECorePlugin.getDefault().getSystemRegistry().getSubSystemConfigurations();
+ Vector poolsVector = new Vector();
+ for (int idx = 0; idx < ssFactories.length; idx++)
+ {
+ ISystemFilterPoolManager poolMgr = ssFactories[idx].getFilterPoolManager(this);
+ ISystemFilterPool[] pools = poolMgr.getSystemFilterPools();
+ for (int ydx=0; ydx
- * @param name What to name this profile
- * @param makeActive true if this profile is to be added to the active profile list.
- * @return new profile, or null if name not unique.
- * @see ISystemProfileManager#createSystemProfile(String, boolean)
- */
- public ISystemProfile createSystemProfile(String name, boolean makeActive) {
- // FIXME - used to use MOF
- ISystemProfile existingProfile = getSystemProfile(name);
- if (existingProfile != null) {
- deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile
- }
-
- ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name);
- if (makeActive) {
- RSEPreferencesManager.addActiveProfile(name);
- ((SystemProfile) newProfile).setActive(makeActive);
- }
- RSEUIPlugin.getThePersistenceManager().commit(this);
- return newProfile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#makeSystemProfileActive(org.eclipse.rse.core.model.ISystemProfile, boolean)
- */
- public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) {
- boolean wasActive = isSystemProfileActive(profile.getName());
- if (wasActive && !makeActive)
- RSEPreferencesManager.deleteActiveProfile(profile.getName());
- else if (makeActive && !wasActive) RSEPreferencesManager.addActiveProfile(profile.getName());
- ((SystemProfile) profile).setActive(makeActive);
- }
-
- /*
- * private version that avoids name collision check
- */
- private ISystemProfile internalCreateSystemProfile(String name) {
- ISystemProfile profile = new SystemProfile();
- initialize(profile, name);
- profile.setDefaultPrivate(name.equalsIgnoreCase(RSEPreferencesManager.getDefaultPrivateSystemProfileName()));
- return profile;
- }
-
- /*
- * private version that avoids name collision check
- */
- private ISystemProfile internalCreateSystemProfileAndFolder(String name) {
- ISystemProfile profile = internalCreateSystemProfile(name);
- // FIXME This is where the old style folders get created for profiles.
- // This is no longer needed but
- // SystemResourceManager.getProfileFolder(profile); // creates proj/profileName folder
- return profile;
- }
-
- /*
- * private method to initialize state for new profile
- */
- private void initialize(ISystemProfile profile, String name) {
- profile.setName(name);
- profile.setProfileManager(this);
- getProfiles().add(profile);
- invalidateCache();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
- */
- public ISystemProfile[] getSystemProfiles() {
- List profiles = getProfiles();
-
- // Ensure that one Profile is the default Profile - defect 48995 NH
- boolean defaultProfileExist = false;
- for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
- ISystemProfile profile = (ISystemProfile) profiles.get(idx);
- if (profile.isDefaultPrivate()) {
- defaultProfileExist = true;
- }
- }
- if (!defaultProfileExist) {
- // Check if the Profile exists with name same as the LocalMachine Name - this is the default we give
- // when creating connections.
- for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
- ISystemProfile profile = (ISystemProfile) profiles.get(idx);
- String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
- if (profile.getName().equalsIgnoreCase(initProfileName)) {
- profile.setDefaultPrivate(true);
- defaultProfileExist = true;
- }
- }
-
- // If did not find such a profile then the first profile found besides Team is set to be the default profile
- if (!defaultProfileExist) {
- for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
- ISystemProfile profile = (ISystemProfile) profiles.get(idx);
- if (!profile.getName().equalsIgnoreCase(RSEPreferencesManager.getDefaultTeamProfileName())) {
- profile.setDefaultPrivate(true);
-
- RSEUIPlugin.getThePersistenceManager().commit(SystemStartHere.getSystemProfileManager());
- defaultProfileExist = true;
- }
- }
- }
- if (!defaultProfileExist) {
- // If Team is the only profile - then put a message in the log - do not make Team to be default
- if (profiles.size() == 1 && ((ISystemProfile) profiles.get(0)).getName().equalsIgnoreCase("Team")) //$NON-NLS-1$
- {
- SystemBasePlugin.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
- } else {
- // sonething must have gone wrong - it should not come here
- SystemBasePlugin.logWarning("Something went wrong and the default profile is not set"); //$NON-NLS-1$
- }
- }
- }
- return (ISystemProfile[]) profiles.toArray(new ISystemProfile[profiles.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames()
- */
- public String[] getSystemProfileNames() {
- if (profileNames == null) {
- ISystemProfile[] profiles = getSystemProfiles();
- profileNames = new String[profiles.length];
- for (int idx = 0; idx < profiles.length; idx++)
- profileNames[idx] = profiles[idx].getName();
- }
- return profileNames;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector()
- */
- public Vector getSystemProfileNamesVector() {
- if (profileNamesVector == null) {
- ISystemProfile[] profiles = getSystemProfiles();
- profileNamesVector = new Vector(profiles.length);
- for (int idx = 0; idx < profiles.length; idx++)
- profileNamesVector.addElement(profiles[idx].getName());
- }
- return profileNamesVector;
- }
-
- /**
- * Something changed so invalide cache of profiles so it will be regenerated
- */
- protected void invalidateCache() {
- //DY profiles = null;
- profileNames = null;
- profileNamesVector = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
- */
- public ISystemProfile getSystemProfile(String name) {
- ISystemProfile[] profiles = getSystemProfiles();
- if ((profiles == null) || (profiles.length == 0)) return null;
- ISystemProfile match = null;
- for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
- if (profiles[idx].getName().equals(name)) match = profiles[idx];
- return match;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
- */
- public void renameSystemProfile(ISystemProfile profile, String newName) {
- boolean isActive = isSystemProfileActive(profile.getName());
- String oldName = profile.getName();
- profile.setName(newName);
- if (isActive) RSEPreferencesManager.renameActiveProfile(oldName, newName);
- invalidateCache();
- // FIXME RSEUIPlugin.getThePersistenceManager().save(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#deleteSystemProfile(org.eclipse.rse.core.model.ISystemProfile, boolean)
- */
- public void deleteSystemProfile(ISystemProfile profile, boolean persist) {
- String oldName = profile.getName();
- boolean isActive = isSystemProfileActive(oldName);
- getProfiles().remove(profile);
- /* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager,
- * so just removing it from the manager is not enough, it must also be removed from its resource.
- * No longer needed since EMF is not in use.
- * Resource res = profile.eResource();
- * if (res != null)
- * res.getContents().remove(profile);
- */
- if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName);
- invalidateCache();
- if (persist) {
- RSEUIPlugin.getThePersistenceManager().deleteProfile(oldName);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#cloneSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
- */
- public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName) {
- ISystemProfile newProfile = createSystemProfile(newName, false);
- return newProfile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String)
- */
- public boolean isSystemProfileActive(String profileName) {
- String[] activeProfiles = getActiveSystemProfileNames();
- boolean match = false;
- for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
- if (activeProfiles[idx].equals(profileName)) match = true;
- }
- return match;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles()
- */
- public ISystemProfile[] getActiveSystemProfiles() {
- String[] profileNames = getActiveSystemProfileNames();
- ISystemProfile[] profiles = new ISystemProfile[profileNames.length];
- for (int idx = 0; idx < profileNames.length; idx++) {
- profiles[idx] = getOrCreateSystemProfile(profileNames[idx]);
- ((SystemProfile) profiles[idx]).setActive(true);
- }
- return profiles;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames()
- */
- public String[] getActiveSystemProfileNames() {
- String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles();
- // dy: defect 48355, need to sync this with the actual profile list. If the user
- // imports old preference settings or does a team sync and a profile is deleted then
- // it is possible an active profile no longer exists.
- // String[] systemProfileNames = getSystemProfileNames();
- ISystemProfile[] systemProfiles = getSystemProfiles();
- boolean found;
- boolean found_team = false;
- boolean found_private = false;
- boolean changed = false;
- String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
-
- for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
- // skip Team and Private profiles
- String activeProfileName = activeProfileNames[activeIdx];
- if (activeProfileName.equals(defaultProfileName)) {
- found_private = true;
- } else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) {
- found_team = true;
- } else {
- found = false;
- for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
- if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
- found = true;
- }
- }
-
- if (!found) {
- // The active profile no longer exists so remove it from the active list
- RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]);
- changed = true;
- }
- }
- }
-
- for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
- boolean matchesBoth = false;
- String name = systemProfiles[systemIdx].getName();
-
- for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
- String aname = activeProfileNames[activeIdx];
- if (name.equals(aname)) {
- matchesBoth = true;
- }
-
- }
- if (!matchesBoth && found_private) {
- if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
- RSEPreferencesManager.addActiveProfile(name);
- RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName());
- activeProfileNames = RSEPreferencesManager.getActiveProfiles();
- }
- }
- }
-
- // the active profiles list needed to be changed because of an external update, also
- // check if Default profile needs to be added back to the list
- if (changed || !found_team || !found_private) {
- if (systemProfiles.length == 0) {
- // First time user, make sure default is in the active list, the only time it wouldn't
- // be is if the pref_store.ini was modified (because the user imported old preferences)
- if (!found_team) {
- RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName());
- changed = true;
- }
-
- if (!found_private) {
- RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName());
- changed = true;
- }
- } else {
- ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
- if (defaultProfile != null && !found_private) {
- RSEPreferencesManager.addActiveProfile(defaultProfile.getName());
- changed = true;
- }
- }
-
- if (changed) {
- activeProfileNames = RSEPreferencesManager.getActiveProfiles();
- }
- }
-
- return activeProfileNames;
- }
-
- /**
- * @return the profile names currently selected by the user as "active" profiles
- */
- public Vector getActiveSystemProfileNamesVector() {
- String[] profileNames = RSEPreferencesManager.getActiveProfiles();
- Vector v = new Vector(profileNames.length);
- for (int idx = 0; idx < profileNames.length; idx++)
- v.addElement(profileNames[idx]);
- return v;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfilePosition(java.lang.String)
- */
- public int getActiveSystemProfilePosition(String profileName) {
- String[] profiles = getActiveSystemProfileNames();
- int pos = -1;
- for (int idx = 0; (pos < 0) && (idx < profiles.length); idx++) {
- if (profiles[idx].equals(profileName)) pos = idx;
- }
- return pos;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
- */
- public ISystemProfile getDefaultPrivateSystemProfile() {
- return getSystemProfile(RSEPreferencesManager.getDefaultPrivateSystemProfileName());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
- */
- public ISystemProfile getDefaultTeamSystemProfile() {
- return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
- }
-
- /**
- * Instantiate a user profile given its name.
- * @param userProfileName the name of the profile to find or create
- * @return the profile that was found or created.
- */
- protected ISystemProfile getOrCreateSystemProfile(String userProfileName) {
- ISystemProfile userProfile = getSystemProfile(userProfileName);
- if (userProfile == null) {
- userProfile = internalCreateSystemProfileAndFolder(userProfileName);
- }
- return userProfile;
- }
-
- /**
- * No longer used.
- * @param profileName the name of the profile from which to construct the name
- * @return the unqualified save file name with the extension .xmi
- */
- public static String getSaveFileName(String profileName) {
- return null;
- //FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profileName)); no longer needed.
- }
-
- /**
- * No longer used.
- * @param profile the profile from which to construct the name
- * @return the unqualified save file name with the extension .xmi
- */
- public static String getSaveFileName(ISystemProfile profile) {
- return null;
- //FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profile)); no longer needed.
- }
-
- /**
- * No longer used.
- * @param profile the profile from which to retrieve the root.
- * @return the root save file name without the extension .xmi
- */
- protected static String getRootSaveFileName(ISystemProfile profile) {
- return getRootSaveFileName(profile.getName());
- }
-
- /**
- * No longer used.
- * @param profileName the name of the profile
- * @return the root save file name without the extension .xmi
- */
- protected static String getRootSaveFileName(String profileName) {
- //String fileName = profileName; // may be a bad idea to include manager name in it!
- String fileName = PROFILE_FILE_NAME;
- return fileName;
- }
-
- /**
- * Reusable method to return a name validator for renaming a profile.
- * @param profileName the current profile name on updates. Can be null for new profiles. Used
- * to remove from the existing name list the current connection.
- * @return the validator
- */
- public ISystemValidator getProfileNameValidator(String profileName) {
- //Vector v = getActiveSystemProfileNamesVector();
- Vector v = getSystemProfileNamesVector();
- if (profileName != null) v.removeElement(profileName);
- ISystemValidator nameValidator = new ValidatorProfileName(v);
- return nameValidator;
- }
-
- /**
- * Reusable method to return a name validator for renaming a profile.
- * @param profile the current profile object on updates. Can be null for new profiles. Used
- * to remove from the existing name list the current connection.
- * @return the validator
- */
- public ISystemValidator getProfileNameValidator(ISystemProfile profile) {
- if (profile != null)
- return getProfileNameValidator(profile.getName());
- else
- return getProfileNameValidator((String) null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemProfileManager#getProfiles()
- */
- public List getProfiles() {
- if (_profiles == null) {
- ISystemProfile profile = new SystemProfile();
- String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
- profile.setName(initProfileName);
- profile.setDefaultPrivate(true);
- _profiles = new ArrayList();
- _profiles.add(profile);
- //profiles = null;//FIXME new EObjectResolvingeList(SystemProfile.class, this, ModelPackage.SYSTEM_PROFILE_MANAGER__PROFILES);
- }
- return _profiles;
- }
-
-}
\ No newline at end of file
Index: UI/org/eclipse/rse/ui/actions/SystemBaseCopyAction.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemBaseCopyAction.java,v
retrieving revision 1.9
diff -u -r1.9 SystemBaseCopyAction.java
--- UI/org/eclipse/rse/ui/actions/SystemBaseCopyAction.java 29 Mar 2007 18:55:31 -0000 1.9
+++ UI/org/eclipse/rse/ui/actions/SystemBaseCopyAction.java 14 Apr 2007 17:38:35 -0000
@@ -23,7 +23,7 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.model.SystemProfileManager;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.model.SystemRegistry;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
@@ -87,7 +87,7 @@
: RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MOVE_ID)),
parent);
this.mode = mode;
- mgr = SystemProfileManager.getSystemProfileManager();
+ mgr = SystemProfileManager.getDefault();
sr = RSEUIPlugin.getTheSystemRegistry();
allowOnMultipleSelection(true);
setProcessAllSelections(true);
Index: UI/org/eclipse/rse/internal/ui/actions/SystemProfileNameSelectAction.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemProfileNameSelectAction.java,v
retrieving revision 1.1
diff -u -r1.1 SystemProfileNameSelectAction.java
--- UI/org/eclipse/rse/internal/ui/actions/SystemProfileNameSelectAction.java 28 Mar 2007 19:49:54 -0000 1.1
+++ UI/org/eclipse/rse/internal/ui/actions/SystemProfileNameSelectAction.java 14 Apr 2007 17:38:31 -0000
@@ -18,7 +18,7 @@
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.model.SystemProfileManager;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
@@ -38,7 +38,7 @@
{
super(profile.getName(),parent);
this.profile = profile;
- ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager();
+ ISystemProfileManager mgr = SystemProfileManager.getDefault();
setChecked(mgr.isSystemProfileActive(profile.getName()));
setSelectionSensitive(false);
Index: UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyProfileDialog.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyProfileDialog.java,v
retrieving revision 1.2
diff -u -r1.2 SystemCopyProfileDialog.java
--- UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyProfileDialog.java 3 Apr 2007 14:41:58 -0000 1.2
+++ UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyProfileDialog.java 14 Apr 2007 17:38:31 -0000
@@ -18,7 +18,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin;
@@ -27,6 +26,7 @@
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator;
+import org.eclipse.rse.ui.validators.ValidatorFactory;
import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -71,10 +71,7 @@
{
setInputObject(profile);
}
-
- // FIXME cast to SystemProfileManager is temporary to get at api - need to use an adapter for getting validators
- SystemProfileManager mgr = (SystemProfileManager)RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager();
- nameValidator = mgr.getProfileNameValidator((String)null);
+ nameValidator = ValidatorFactory.getProfileNameValidator((String)null);
//pack();
setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); //$NON-NLS-1$
}
Index: model/org/eclipse/rse/model/SystemRegistry.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemRegistry.java,v
retrieving revision 1.37
diff -u -r1.37 SystemRegistry.java
--- model/org/eclipse/rse/model/SystemRegistry.java 4 Apr 2007 15:23:16 -0000 1.37
+++ model/org/eclipse/rse/model/SystemRegistry.java 14 Apr 2007 17:38:40 -0000
@@ -35,11 +35,9 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants;
-import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
import org.eclipse.rse.core.filters.ISystemFilterReference;
import org.eclipse.rse.core.filters.ISystemFilterStartHere;
@@ -66,14 +64,13 @@
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.internal.core.filters.SystemFilterPool;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.model.SystemHostPool;
import org.eclipse.rse.internal.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.model.SystemModelChangeEventManager;
import org.eclipse.rse.internal.model.SystemPostableEventNotifier;
import org.eclipse.rse.internal.model.SystemPreferenceChangeManager;
-import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.model.SystemRemoteChangeEventManager;
import org.eclipse.rse.internal.model.SystemResourceChangeManager;
import org.eclipse.rse.internal.model.SystemScratchpad;
@@ -764,7 +761,7 @@
*/
public ISystemProfileManager getSystemProfileManager()
{
- return SystemProfileManager.getSystemProfileManager();
+ return SystemProfileManager.getDefault();
}
/**
@@ -795,12 +792,14 @@
{
return getSystemProfileManager().getSystemProfileNames();
}
+
/**
* Return all defined profile names as a vector
*/
public Vector getAllSystemProfileNamesVector()
{
- return getSystemProfileManager().getSystemProfileNamesVector();
+ Vector v = getSystemProfileManager().getSystemProfileNamesVector();
+ return v;
}
/**
@@ -2843,7 +2842,7 @@
public void disconnectAllSubSystems(IHost conn)
{
// FIXME - save profile
- save();
+// save();
ISubSystem[] subsystems = getSubSystemsLazily(conn);
if (subsystems == null)
@@ -3346,8 +3345,7 @@
*/
public boolean save()
{
- ISystemProfileManager profileManager = getSystemProfileManager();
- return RSEUIPlugin.getThePersistenceManager().commit(profileManager);
+ return RSEUIPlugin.getThePersistenceManager().commitProfiles();
}
/**
@@ -3356,7 +3354,7 @@
*/
public boolean saveHostPool(ISystemHostPool pool)
{
- return RSEUIPlugin.getThePersistenceManager().commit(pool);
+ return pool.commit();
}
/**
@@ -3414,9 +3412,4 @@
return SystemFilterStartHere.getDefault();
}
- public ISystemFilterPool getSystemFilterPool()
- {
- return SystemFilterPool.getDefault();
- }
-
}//SystemRegistryImpl
\ No newline at end of file
Index: model/org/eclipse/rse/model/SystemStartHere.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemStartHere.java,v
retrieving revision 1.6
diff -u -r1.6 SystemStartHere.java
--- model/org/eclipse/rse/model/SystemStartHere.java 31 Aug 2006 17:37:28 -0000 1.6
+++ model/org/eclipse/rse/model/SystemStartHere.java 14 Apr 2007 17:38:41 -0000
@@ -21,7 +21,7 @@
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.internal.model.SystemProfileManager;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSEUIPlugin;
@@ -161,7 +161,7 @@
*/
public static ISystemProfileManager getSystemProfileManager()
{
- return SystemProfileManager.getSystemProfileManager();
+ return SystemProfileManager.getDefault();
}
/**
Index: UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java,v
retrieving revision 1.9
diff -u -r1.9 SystemViewFilterPoolReferenceAdapter.java
--- UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java 12 Apr 2007 20:26:13 -0000 1.9
+++ UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java 14 Apr 2007 17:38:32 -0000
@@ -25,6 +25,7 @@
import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
+import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;
import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
import org.eclipse.rse.core.subsystems.ISubSystem;
@@ -89,7 +90,7 @@
menu.add(menuGroup, action);
}
}
- actions = adapter.getFilterPoolReferenceActions(menu, selection, shell, menuGroup, ssFactory, getFilterPoolReference(element));
+ actions = adapter.getFilterPoolReferenceActions(menu, selection, shell, menuGroup, ssFactory, (ISystemFilterPoolReference)element);
if (actions != null)
{
//menu.addSeparator();
@@ -112,35 +113,35 @@
*/
public ISubSystem getSubSystem(Object element)
{
- return ((ISubSystem)getFilterPoolReference(element).getProvider());
+ ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
+ return (ISubSystem)ref.getProvider();
}
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired
*/
- public ImageDescriptor getImageDescriptor(Object element)
- {
- ImageDescriptor poolImage = null;
- ISystemFilterPool pool = getFilterPool(element);
- if (pool.getProvider() != null)
- {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)pool.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
- poolImage = adapter.getSystemFilterPoolImage(pool);
- }
- if (poolImage == null)
- poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
- return poolImage;
- }
-
- private ISystemFilterPoolReference getFilterPoolReference(Object element)
- {
- return (ISystemFilterPoolReference)element; // get referenced object
+ public ImageDescriptor getImageDescriptor(Object element) {
+ ImageDescriptor poolImage = null;
+ ISystemFilterPool pool = getFilterPool(element);
+ if (pool != null) {
+ ISystemFilterPoolManagerProvider provider = pool.getProvider();
+ if (provider != null) {
+ ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) provider.getAdapter(ISubSystemConfigurationAdapter.class);
+ poolImage = adapter.getSystemFilterPoolImage(pool);
+ }
+ }
+ if (poolImage == null) {
+ poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
+ }
+ return poolImage;
}
private ISystemFilterPool getFilterPool(Object element)
{
- return getFilterPoolReference(element).getReferencedFilterPool(); // get master object
+ ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
+ ISystemFilterPool pool = ref.getReferencedFilterPool();
+ return pool; // get master object
}
/**
@@ -148,16 +149,11 @@
* @return the label for this filter pool reference.
*/
public String getText(Object element) {
- String result = "unknown"; // $NON-NLS-1$ //$NON-NLS-1$
+ ISystemFilterPoolReference reference = (ISystemFilterPoolReference) element;
+ String result = reference.getName();
ISystemFilterPool pool = getFilterPool(element);
if (pool != null) {
result = pool.getName();
-// the following looks like it was copied from the host adapter and not really needed here.
-// boolean qualifyNames = RSEUIPlugin.getTheSystemRegistry().getQualifiedHostNames();
-// if (qualifyNames) {
-// String prefix = SubSystemHelpers.getParentSystemProfile(pool).getName();
-// result = prefix + "." + result;
-// }
}
return result;
}
@@ -178,13 +174,14 @@
public String getAbsoluteName(Object element)
{
//TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change
- ISystemFilterPoolReference filterPoolRef = getFilterPoolReference(element);
+ ISystemFilterPoolReference filterPoolRef = (ISystemFilterPoolReference)element;
ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider();
ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem);
String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$
- return parentAbsoluteName + "." + //$NON-NLS-1$
- filterPoolRef.getReferencedFilterPool().getSystemFilterPoolManager().getName() + "." + //$NON-NLS-1$
- filterPoolRef.getName();
+ String referenceName = filterPoolRef.getName();
+ String managerName = filterPoolRef.getReferencedFilterPoolManagerName();
+ String absoluteName = parentAbsoluteName + "." + managerName + "." + referenceName; //$NON-NLS-1$ //$NON-NLS-2$
+ return absoluteName;
}
/**
@@ -202,7 +199,7 @@
*/
public Object getParent(Object element)
{
- ISystemFilterPoolReference fpr = getFilterPoolReference(element);
+ ISystemFilterPoolReference fpr = (ISystemFilterPoolReference)element;
return SubSystemHelpers.getParentSubSystem(fpr);
}
@@ -212,7 +209,7 @@
*/
public Object[] getChildren(IProgressMonitor monitor, IAdaptable element)
{
- ISystemFilterPoolReference fpRef = getFilterPoolReference(element);
+ ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
ISubSystem ss = getSubSystem(element);
return fpRef.getSystemFilterReferences(ss);
}
@@ -222,7 +219,7 @@
*/
public boolean hasChildren(IAdaptable element) {
int count = 0;
- ISystemFilterPoolReference fpRef = getFilterPoolReference(element);
+ ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
if (fpRef != null) {
ISystemFilterPool filterPool = fpRef.getReferencedFilterPool();
if (filterPool != null) {
Index: UI/org/eclipse/rse/ui/RSEUIPlugin.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java,v
retrieving revision 1.43
diff -u -r1.43 RSEUIPlugin.java
--- UI/org/eclipse/rse/ui/RSEUIPlugin.java 3 Apr 2007 01:22:09 -0000 1.43
+++ UI/org/eclipse/rse/ui/RSEUIPlugin.java 14 Apr 2007 17:38:34 -0000
@@ -44,9 +44,9 @@
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxyComparator;
-import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemDynamicPopupMenuExtensionManager;
@@ -114,7 +114,7 @@
if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
if (adapter != null && adapter.isEnabled(systemType)) {
- ISystemProfileManager profileManager = SystemProfileManager.getSystemProfileManager();
+ ISystemProfileManager profileManager = SystemProfileManager.getDefault();
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
String userName = System.getProperty("user.name"); //$NON-NLS-1$
registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName);
@@ -761,7 +761,7 @@
*/
public static ISystemProfileManager getTheSystemProfileManager()
{
- return SystemProfileManager.getSystemProfileManager();
+ return SystemProfileManager.getDefault();
}
/**
Index: UI/org/eclipse/rse/ui/validators/ValidatorFactory.java
===================================================================
RCS file: UI/org/eclipse/rse/ui/validators/ValidatorFactory.java
diff -N UI/org/eclipse/rse/ui/validators/ValidatorFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ UI/org/eclipse/rse/ui/validators/ValidatorFactory.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,27 @@
+package org.eclipse.rse.ui.validators;
+
+import java.util.Vector;
+
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.ISystemProfileManager;
+
+/**
+ * This class constructs validators for various bits of the user interface.
+ */
+public class ValidatorFactory {
+
+ /**
+ * Reusable method to return a name validator for renaming a profile.
+ * @param profileName the current profile name on updates. Can be null for new profiles. Used
+ * to remove from the existing name list the current connection.
+ * @return the validator
+ */
+ public static ISystemValidator getProfileNameValidator(String profileName) {
+ ISystemProfileManager manager = RSECorePlugin.getDefault().getSystemRegistry().getSystemProfileManager();
+ Vector profileNames = manager.getSystemProfileNamesVector();
+ if (profileName != null) profileNames.remove(profileName);
+ ISystemValidator nameValidator = new ValidatorProfileName(profileNames);
+ return nameValidator;
+ }
+
+}