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

[170932][api][refactor] revamp persistence manager interface

This commit is contained in:
David Dykstal 2007-04-19 06:04:49 +00:00
parent d6c7ba4fad
commit 5be124e200
48 changed files with 896 additions and 1082 deletions

View file

@ -274,17 +274,6 @@ public class SystemResourceManager implements SystemResourceConstants
} }
*/ */
// -----------------------------------
// 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 * Get profiles folder for a given profile name
*/ */
@ -293,9 +282,6 @@ public class SystemResourceManager implements SystemResourceConstants
return getResourceHelpers().getOrCreateFolder(getRemoteSystemsProject(),profileName); return getResourceHelpers().getOrCreateFolder(getRemoteSystemsProject(),profileName);
} }
/* /*
* -------------------------------------------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------------------------------------------
* USER ACTIONS SUBTREE FOLDER METHODS... * USER ACTIONS SUBTREE FOLDER METHODS...

View file

@ -338,5 +338,4 @@ public interface ISystemFilterPool extends IRSEPersistableReferencedObject, ISys
*/ */
void setNonRenamable(boolean value); void setNonRenamable(boolean value);
public ISystemFilterPool createSystemFilterPool(String name, boolean allowNestedFilters, boolean isDeletable, boolean tryToRestore);
} }

View file

@ -201,11 +201,10 @@ public interface ISystemFilterPoolReferenceManager extends IRSEBasePersistableRe
* Given a filter pool name, create a referencing object and add it to the list. * Given a filter pool name, create a referencing object and add it to the list.
* This creates an unresolved reference to that filter pool. It will be resolved on first use. * This creates an unresolved reference to that filter pool. It will be resolved on first use.
* <p> Calls back to inform provider * <p> 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. * @param filterPoolName the name of the filter pool being referenced.
* @return new filter pool reference * @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. * Given a filter pool, locate the referencing object for it and remove it from the list.

View file

@ -18,6 +18,7 @@ package org.eclipse.rse.core.filters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -25,15 +26,11 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile; 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.model.RSEPersistableObject;
import org.eclipse.rse.core.references.IRSEBaseReferencingObject; import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
import org.eclipse.rse.internal.core.filters.ISystemFilterConstants; 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.logging.Logger;
import org.eclipse.rse.persistence.IRSEPersistenceManager;
//
//
/** /**
* A filter pool manager manages filter pools. * A filter pool manager manages filter pools.
@ -190,10 +187,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
*/ */
protected boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT; protected boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT;
/** protected List pools = null;
* @generated This field/method will be replaced during code generation.
*/
protected java.util.List pools = null;
/** /**
* Constructor * Constructor
@ -224,7 +218,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* individual filter pool level. * individual filter pool level.
* @param savePolicy The save policy for the filter pools and filters. One of the * @param savePolicy The save policy for the filter pools and filters. One of the
* following constants from the * following constants from the
* {@link org.eclipse.rse.internal.core.filters.ISystemFilterConstants SystemFilterConstants} interface: * {@link ISystemFilterConstants} interface:
* <ul> * <ul>
* <li>SAVE_POLICY_NONE - no files, all save/restore handled elsewhere * <li>SAVE_POLICY_NONE - no files, all save/restore handled elsewhere
* <li>SAVE_POLICY_ONE_FILE_PER_MANAGER - one file: mgrName.xmi * <li>SAVE_POLICY_ONE_FILE_PER_MANAGER - one file: mgrName.xmi
@ -238,26 +232,8 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public static ISystemFilterPoolManager createSystemFilterPoolManager(ISystemProfile profile, Logger logger, public static ISystemFilterPoolManager createSystemFilterPoolManager(ISystemProfile profile, Logger logger,
ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters, ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters,
int savePolicy, IRSEFilterNamingPolicy namingPolicy) { int savePolicy, IRSEFilterNamingPolicy namingPolicy) {
SystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile);
SystemFilterPoolManager mgr = null; mgr.initialize(logger, caller, name, allowNestedFilters);
if (namingPolicy == null) namingPolicy = SystemFilterNamingPolicy.getNamingPolicy();
try {
mgr = (SystemFilterPoolManager) RSECorePlugin.getThePersistenceManager().restoreFilterPoolManager(profile, logger, caller, name);
/*
if (savePolicy != SystemFilterConstants.SAVE_POLICY_NONE)
mgr = (SystemFilterPoolManagerImpl)restore(;
*/
} catch (Exception exc) // real error trying to restore, versus simply not found.
{
// todo: something. Log the exception somewhere?
}
if (mgr == null) // not found or some serious error.
{
mgr = createManager(profile);
}
if (mgr != null) {
mgr.initialize(logger, caller, name, allowNestedFilters);
}
return mgr; return mgr;
} }
@ -276,30 +252,29 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Private helper method to initialize state * Private helper method to initialize state
*/ */
public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters) { public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name, boolean allowNestedFilters) {
if (!initialized) initialize(logger, caller, name); // core data if (!initialized) {
initialize(logger, caller, name); // core data
{
java.util.List pools = getPools();
ISystemFilterPool pool = null;
Vector poolNames = getSystemFilterPoolNamesVector();
for (int idx = 0; idx < poolNames.size(); idx++) {
String poolName = (String) poolNames.elementAt(idx);
pool = RSECorePlugin.getThePersistenceManager().restoreFilterPool(poolName);
pool.setSystemFilterPoolManager(this);
pools.add(pool);
/** FIXME test
if (pool.specialCaseNoDataRestored)
{
pool.setDeletable(true); // what else to do?
//pool.setSupportsNestedFilters(allowNestedFilters); will be cascaded down anyway
}
*/
}
} }
setSupportsNestedFilters(allowNestedFilters); // cascade it down setSupportsNestedFilters(allowNestedFilters); // cascade it down
invalidatePoolCache(); invalidatePoolCache();
// List pools = getPools();
// ISystemFilterPool pool = null;
// Vector poolNames = getSystemFilterPoolNamesVector();
// for (int idx = 0; idx < poolNames.size(); idx++) {
// String poolName = (String) poolNames.elementAt(idx);
//// pool = RSECorePlugin.getThePersistenceManager().restoreFilterPool(poolName);
// pool = null; // that's what the above returned
// pool.setSystemFilterPoolManager(this);
// pools.add(pool);
//
// /** FIXME test
// if (pool.specialCaseNoDataRestored)
// {
// pool.setDeletable(true); // what else to do?
// //pool.setSupportsNestedFilters(allowNestedFilters); will be cascaded down anyway
// }
// */
// }
} }
/* /*
@ -309,7 +284,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name) { public void initialize(Logger logger, ISystemFilterPoolManagerProvider caller, String name) {
this.logger = logger; this.logger = logger;
setProvider(caller); setProvider(caller);
setNameGen(name); setName(name);
setFilterPoolManager(); // cascade it down setFilterPoolManager(); // cascade it down
initialized = true; initialized = true;
} }
@ -331,14 +306,11 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/** /**
* Set the name of this manager. * Set the name of this manager.
* Intercepted so the file get be renamed for SAVE_POLICY_ONE_FILE_PER_MANAGER.
*/ */
public void setName(String name) { public void setName(String newName) {
String oldName = getName(); if ((name == null && newName != null) || !name.equals(newName)) {
if (oldName != null) { this.name = newName;
if (!oldName.equals(name)) { setDirty(true);
this.name = name;
}
} }
} }
@ -473,7 +445,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
public ISystemFilterPool[] getSystemFilterPools() { public ISystemFilterPool[] getSystemFilterPools() {
//System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null)); //System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null));
if ((poolArray == null) || (getPools().size() != poolArray.length)) { if ((poolArray == null) || (getPools().size() != poolArray.length)) {
java.util.List pools = getPools(); List pools = getPools();
poolArray = new ISystemFilterPool[pools.size()]; poolArray = new ISystemFilterPool[pools.size()];
Iterator i = pools.iterator(); Iterator i = pools.iterator();
int idx = 0; int idx = 0;
@ -499,7 +471,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Get list of filter pool names currently existing. * Get list of filter pool names currently existing.
*/ */
public Vector getSystemFilterPoolNamesVector() { public Vector getSystemFilterPoolNamesVector() {
java.util.List pools = getPools(); List pools = getPools();
if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated? if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated?
{ {
poolNames = new Vector(); poolNames = new Vector();
@ -540,30 +512,20 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Calls back to inform provider of this event * Calls back to inform provider of this event
*/ */
public ISystemFilterPool createSystemFilterPool(String poolName, boolean isDeletable) throws Exception { public ISystemFilterPool createSystemFilterPool(String poolName, boolean isDeletable) throws Exception {
// always trim the pool name, MOF does not handle trailing or preceding spaces
poolName = poolName.trim();
if (getSystemFilterPool(poolName) != null) return null;
ISystemFilterPool pool = null; ISystemFilterPool pool = null;
poolName = poolName.trim();
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); if (getSystemFilterPool(poolName) == null) {
ISystemFilterPool filterPool = registry.getSystemFilterPool(); pool = new SystemFilterPool(poolName, supportsNestedFilters(), isDeletable);
pool = filterPool.createSystemFilterPool(poolName, supportsNestedFilters(), isDeletable, ISystemFilterConstants.TRY_TO_RESTORE_NO);
if (pool != null) {
pool.setSystemFilterPoolManager(this); pool.setSystemFilterPoolManager(this);
pool.setStringsCaseSensitive(areStringsCaseSensitive()); pool.setStringsCaseSensitive(areStringsCaseSensitive());
if (isSetSupportsDuplicateFilterStrings()) pool.setSupportsDuplicateFilterStrings(supportsDuplicateFilterStrings()); pool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings() && supportsDuplicateFilterStrings());
// add to model List pools = getPools();
java.util.List pools = getPools();
pools.add(pool); pools.add(pool);
//System.out.println("Inside createSFPool for mgr "+getName()+". Pool "+name+" added");
invalidatePoolCache(); invalidatePoolCache();
// save to disk...
commit(pool); commit(pool);
// if caller provider, callback to inform them of this event if ((caller != null) && !suspendCallbacks) {
if ((caller != null) && !suspendCallbacks) caller.filterEventFilterPoolCreated(pool); caller.filterEventFilterPoolCreated(pool);
}
} }
return pool; return pool;
} }
@ -601,8 +563,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
// DWD removing a pool should mark its parent profile as dirty and cause a save to be "scheduled" // DWD removing a pool should mark its parent profile as dirty and cause a save to be "scheduled"
// remove from model // remove from model
java.util.List pools = getPools(); List pools = getPools();
pools.remove(pool); pools.remove(pool);
invalidatePoolCache();
/* FIXME /* FIXME
// now in EMF, the pools are "owned" by the Resource, and only referenced by this pool manager, // now in EMF, the pools are "owned" by the Resource, and only referenced by this pool manager,
@ -1530,7 +1493,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/* FIXME /* FIXME
String fileName = getRootSaveFileName(namingPolicy, name); String fileName = getRootSaveFileName(namingPolicy, name);
java.util.List ext = getMOFHelpers(logger).restore(mgrFolder,fileName); List ext = getMOFHelpers(logger).restore(mgrFolder,fileName);
SystemFilterPoolManager mgr = null; SystemFilterPoolManager mgr = null;
@ -1652,25 +1615,13 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
/** /**
* @generated This field/method will be replaced during code generation * @generated This field/method will be replaced during code generation
*/ */
public java.util.List getPools() { public List getPools() {
if (pools == null) { if (pools == null) {
pools = new ArrayList(); pools = new ArrayList();
//FIXME new EObjectResolvingeList(SystemFilterPool.class, this, FiltersPackage.SYSTEM_FILTER_POOL_MANAGER__POOLS);
} }
return pools; return pools;
} }
/**
* @generated This field/method will be replaced during code generation.
*/
public void setNameGen(String newName) {
String oldName = name;
if (oldName != newName) {
name = newName;
setDirty(true);
}
}
/** /**
* @generated This field/method will be replaced during code generation. * @generated This field/method will be replaced during code generation.
*/ */
@ -1727,8 +1678,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Uses the save policy specified in this manager's factory method. * Uses the save policy specified in this manager's factory method.
*/ */
public boolean commit() { public boolean commit() {
IRSEPersistenceManager mgr = RSECorePlugin.getThePersistenceManager(); ISystemProfile profile = getSystemProfile();
return mgr.commit(this); boolean result = profile.commit();
return result;
} }
/** /**
@ -1741,12 +1693,11 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
} }
public IRSEPersistableContainer getPersistableParent() { public IRSEPersistableContainer getPersistableParent() {
return _profile; return null;
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
IRSEPersistableContainer[] result = getSystemFilterPools(); return new IRSEPersistableContainer[0];
return result;
} }
} }

View file

@ -21,6 +21,9 @@
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
@ -511,7 +514,11 @@ public class Host extends RSEModelObject implements IHost {
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
IConnectorService[] result = getConnectorServices(); List children = new ArrayList(10);
children.addAll(Arrays.asList(getPropertySets()));
children.addAll(Arrays.asList(getConnectorServices()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result; return result;
} }

View file

@ -154,4 +154,11 @@ public interface IPropertySet {
*/ */
public boolean removeProperty(String key); public boolean removeProperty(String key);
/**
* Sets the container of this property set. Used to notify the
* container of a change in a property.
* @param container
*/
public void setContainer(IPropertySetContainer container);
} }

View file

@ -50,21 +50,6 @@ public interface IRSEPersistableContainer {
*/ */
public void setWasRestored(boolean flag); 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 * An object is dirty if a change has been made to it that requires
* it to be persisted. * it to be persisted.
@ -106,8 +91,7 @@ public interface IRSEPersistableContainer {
* Sets the tainted attribute for this object. This should set to * Sets the tainted attribute for this object. This should set to
* true only by child objects when they have been marked dirty or tainted. * 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 * Setting this to true will cause all parent objects in the containment
* hierarchy to be marked tainted. Setting this to false will cause all * hierarchy to be marked tainted.
* children to be marked as not tainted.
* It should be set to false only by a persistence manager when the * It should be set to false only by a persistence manager when the
* object has been committed. * object has been committed.
* @param flag the tainted state of the object. * @param flag the tainted state of the object.

View file

@ -16,6 +16,7 @@
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
import java.util.List;
import java.util.Vector; import java.util.Vector;
/** /**
@ -44,10 +45,16 @@ public interface ISystemProfileManager {
public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive); 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(); public ISystemProfile[] getSystemProfiles();
/**
* @return the number of profiles known to this manager.
*/
public int getSize();
/** /**
* @return an array of all existing profile names. * @return an array of all existing profile names.
*/ */
@ -129,7 +136,9 @@ public interface ISystemProfileManager {
* @return The list of profiles known to this manager. This list is generated * @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. * 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. // * Reusable method to return a name validator for renaming a profile.

View file

@ -22,7 +22,6 @@ import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.rse.core.IRSESystemType; 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.filters.ISystemFilterStartHere;
import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
@ -44,8 +43,6 @@ public interface ISystemRegistry extends ISchedulingRule {
public ISystemFilterStartHere getSystemFilterStartHere(); public ISystemFilterStartHere getSystemFilterStartHere();
public ISystemFilterPool getSystemFilterPool();
// ---------------------------------- // ----------------------------------
// UI METHODS... // UI METHODS...
// ---------------------------------- // ----------------------------------

View file

@ -17,10 +17,9 @@
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
/** import java.util.Observable;
*
*/ public class Property extends Observable implements IProperty {
public class Property implements IProperty {
private String _name; private String _name;
private String _label; private String _label;
@ -35,6 +34,7 @@ public class Property implements IProperty {
_value = property.getValue(); _value = property.getValue();
_type = property.getType(); _type = property.getType();
_isEnabled = property.isEnabled(); _isEnabled = property.isEnabled();
touch();
} }
public Property(String name, String value, IPropertyType type, boolean isEnabled) { public Property(String name, String value, IPropertyType type, boolean isEnabled) {
@ -42,6 +42,7 @@ public class Property implements IProperty {
_value = value; _value = value;
_type = type; _type = type;
_isEnabled = isEnabled; _isEnabled = isEnabled;
touch();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -55,7 +56,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setLabel(java.lang.String) * @see org.eclipse.rse.core.model.IProperty#setLabel(java.lang.String)
*/ */
public void setLabel(String label) { public void setLabel(String label) {
_label = label; if (!stringsAreEqual(_label, label)) {
_label = label;
touch();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -72,7 +76,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setValue(java.lang.String) * @see org.eclipse.rse.core.model.IProperty#setValue(java.lang.String)
*/ */
public void setValue(String value) { public void setValue(String value) {
_value = value; if (!stringsAreEqual(_value, value)) {
_value = value;
touch();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -86,7 +93,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setType(org.eclipse.rse.core.model.IPropertyType) * @see org.eclipse.rse.core.model.IProperty#setType(org.eclipse.rse.core.model.IPropertyType)
*/ */
public void setType(IPropertyType type) { public void setType(IPropertyType type) {
_type = type; if (_type != type) {
_type = type;
touch();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -100,7 +110,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setEnabled(boolean) * @see org.eclipse.rse.core.model.IProperty#setEnabled(boolean)
*/ */
public void setEnabled(boolean flag) { public void setEnabled(boolean flag) {
_isEnabled = flag; if (_isEnabled != flag) {
_isEnabled = flag;
touch();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -114,7 +127,10 @@ public class Property implements IProperty {
* @see org.eclipse.rse.core.model.IProperty#setReadOnly(boolean) * @see org.eclipse.rse.core.model.IProperty#setReadOnly(boolean)
*/ */
public void setReadOnly(boolean flag) { public void setReadOnly(boolean flag) {
_isReadOnly = flag; if (_isReadOnly != flag) {
_isReadOnly = flag;
touch();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -124,4 +140,15 @@ public class Property implements IProperty {
return _isReadOnly; return _isReadOnly;
} }
private boolean stringsAreEqual(String s1, String s2) {
if (s1 == s2) return true;
if (s1 == null) return false;
return s1.equals(s2);
}
private void touch() {
setChanged();
notifyObservers();
}
} }

View file

@ -19,6 +19,8 @@ package org.eclipse.rse.core.model;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.Set; import java.util.Set;
/** /**
@ -27,9 +29,10 @@ import java.util.Set;
* Not thread-safe since the underlying {@link java.util.HashMap} is * Not thread-safe since the underlying {@link java.util.HashMap} is
* not thread-safe. * not thread-safe.
*/ */
public class PropertySet implements IPropertySet { public class PropertySet extends RSEPersistableObject implements IPropertySet, Observer {
private String _name; private String _name;
private Map _properties; private Map _properties;
private IPropertySetContainer _container = null;
protected static IPropertyType _defaultType = PropertyType.getStringPropertyType(); protected static IPropertyType _defaultType = PropertyType.getStringPropertyType();
@ -47,6 +50,7 @@ public class PropertySet implements IPropertySet {
IProperty property = propertySet.getProperty(key); IProperty property = propertySet.getProperty(key);
addProperty(key, new Property(property)); addProperty(key, new Property(property));
} }
setDirty(true);
} }
/** /**
@ -56,6 +60,7 @@ public class PropertySet implements IPropertySet {
public PropertySet(String name) { public PropertySet(String name) {
_name = name; _name = name;
_properties = new HashMap(); _properties = new HashMap();
setDirty(true);
} }
public String getName() { public String getName() {
@ -68,16 +73,17 @@ public class PropertySet implements IPropertySet {
public void setDescription(String description) { public void setDescription(String description) {
addProperty(DESCRIPTION_KEY, description); addProperty(DESCRIPTION_KEY, description);
setDirty(true);
} }
public String[] getPropertyKeys() { public String[] getPropertyKeys() {
Set set = _properties.keySet(); Set set = _properties.keySet();
return (String[]) set.toArray(new String[set.size()]); return (String[]) set.toArray(new String[set.size()]);
} }
public void setName(String name) { public void setName(String name) {
_name = name; _name = name;
setDirty(true);
} }
public void setProperties(Map map) { public void setProperties(Map map) {
@ -85,7 +91,11 @@ public class PropertySet implements IPropertySet {
for (Iterator z = map.keySet().iterator(); z.hasNext();) { for (Iterator z = map.keySet().iterator(); z.hasNext();) {
String key = (String) z.next(); String key = (String) z.next();
Object value = map.get(key); Object value = map.get(key);
_properties.put(key, value); if (value instanceof IProperty) {
addProperty(key, (IProperty)value);
} else if (value instanceof String) {
addProperty(key, (String)value);
}
} }
} }
@ -100,6 +110,7 @@ public class PropertySet implements IPropertySet {
*/ */
public IProperty addProperty(String key, IProperty property) { public IProperty addProperty(String key, IProperty property) {
_properties.put(key, property); _properties.put(key, property);
setDirty(true);
return property; return property;
} }
@ -109,10 +120,10 @@ public class PropertySet implements IPropertySet {
//FIXME should throw a NumberFormatException or similar, //FIXME should throw a NumberFormatException or similar,
//if the value does not fit the type of the existing property. //if the value does not fit the type of the existing property.
property.setValue(value); property.setValue(value);
return property;
} else { } else {
return addProperty(key, value, _defaultType); property = addProperty(key, value, _defaultType);
} }
return property;
} }
public IProperty addProperty(String key, String value, IPropertyType type) { public IProperty addProperty(String key, String value, IPropertyType type) {
@ -121,7 +132,10 @@ public class PropertySet implements IPropertySet {
} }
public boolean removeProperty(String key) { public boolean removeProperty(String key) {
return _properties.remove(key) != null; Object value = _properties.remove(key);
if (value == null) return false;
setDirty(true);
return true;
} }
public IProperty getProperty(String key) { public IProperty getProperty(String key) {
@ -144,4 +158,27 @@ public class PropertySet implements IPropertySet {
return null; return null;
} }
public boolean commit() {
return getPersistableParent().commit();
}
public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0];
}
public IRSEPersistableContainer getPersistableParent() {
IRSEPersistableContainer result = null;
if (_container instanceof IRSEPersistableContainer) {
result = (IRSEPersistableContainer) _container;
}
return result;
}
public void setContainer(IPropertySetContainer container) {
_container = container;
}
public void update(Observable o, Object arg) {
setDirty(true);
}
} }

View file

@ -44,6 +44,7 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen
public IPropertySet createPropertySet(String name, String description) { public IPropertySet createPropertySet(String name, String description) {
IPropertySet newSet = new PropertySet(name); IPropertySet newSet = new PropertySet(name);
newSet.setContainer(this);
newSet.addProperty(IPropertySet.DESCRIPTION_KEY, description); newSet.addProperty(IPropertySet.DESCRIPTION_KEY, description);
_propertySets.put(name, newSet); _propertySets.put(name, newSet);
return newSet; return newSet;
@ -51,11 +52,13 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen
public IPropertySet createPropertySet(String name) { public IPropertySet createPropertySet(String name) {
IPropertySet newSet = new PropertySet(name); IPropertySet newSet = new PropertySet(name);
newSet.setContainer(this);
_propertySets.put(name, newSet); _propertySets.put(name, newSet);
return newSet; return newSet;
} }
public boolean addPropertySet(IPropertySet set) { public boolean addPropertySet(IPropertySet set) {
set.setContainer(this);
_propertySets.put(set.getName(), set); _propertySets.put(set.getName(), set);
return true; return true;
} }

View file

@ -30,21 +30,4 @@ public abstract class RSEModelObject extends PropertySetContainer implements IRS
return RSEModelResources.RESID_MODELOBJECTS_MODELOBJECT_DESCRIPTION; return RSEModelResources.RESID_MODELOBJECTS_MODELOBJECT_DESCRIPTION;
} }
/**
* Does a null-aware string comparison. Two strings that are
* <code>null</code> will compare equal. Otherwise the result is
* the same as s1.equals(s2), if s1 is not null.
* @param s1 The first string to compare
* @param s2 the second string
* @return true if the strings are equal or both null.
*/
protected boolean compareStrings(String s1, String s2) {
boolean result = false;
if (s1 == null) {
result = (s2 == null);
} else {
result = s1.equals(s2);
}
return result;
}
} }

View file

@ -74,10 +74,8 @@ public abstract class RSEModelOperation {
* Ends a transaction. Schedules all changed profiles for save. * Ends a transaction. Schedules all changed profiles for save.
*/ */
private static void endTransaction() { private static void endTransaction() {
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISystemProfileManager profileManager = registry.getSystemProfileManager();
IRSEPersistenceManager persistenceManager = RSECorePlugin.getDefault().getPersistenceManager(); IRSEPersistenceManager persistenceManager = RSECorePlugin.getDefault().getPersistenceManager();
persistenceManager.commit(profileManager); persistenceManager.commitProfiles();
} }
/** /**

View file

@ -1,11 +1,11 @@
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
public abstract class RSEPersistableObject implements IRSEPersistableContainer { public abstract class RSEPersistableObject implements IRSEPersistableContainer {
private boolean _isDirty = false; private boolean _isDirty = false;
private boolean _wasRestored = false; private boolean _wasRestored = false;
private boolean _isTainted = false; private boolean _isTainted = false;
private boolean _restoring = false;
public RSEPersistableObject() { public RSEPersistableObject() {
super(); super();
@ -16,21 +16,8 @@ public abstract class RSEPersistableObject implements IRSEPersistableContainer {
} }
public final void setDirty(boolean flag) { public final void setDirty(boolean flag) {
if (!_restoring) { _isDirty = flag;
_isDirty = flag; setTainted(flag);
if (flag) {
setTainted(true);
}
}
}
public final void beginRestore() {
_restoring = true;
}
public final void endRestore() {
_restoring = false;
setWasRestored(true);
} }
public final boolean wasRestored() { public final boolean wasRestored() {
@ -46,21 +33,28 @@ public abstract class RSEPersistableObject implements IRSEPersistableContainer {
} }
public final void setTainted(boolean flag) { public final void setTainted(boolean flag) {
if (!_restoring) { boolean taintParent = flag && !_isTainted;
_isTainted = flag; _isTainted = flag;
if (_isTainted) { if (taintParent) {
IRSEPersistableContainer parent = getPersistableParent(); IRSEPersistableContainer parent = getPersistableParent();
if (parent != null) { if (parent != null) {
parent.setTainted(true); parent.setTainted(true);
}
} else {
IRSEPersistableContainer[] children = getPersistableChildren();
for (int i = 0; i < children.length; i++) {
IRSEPersistableContainer child = children[i];
child.setTainted(false);
}
} }
} }
} }
/**
* Does a null-aware string comparison. Two strings that are
* <code>null</code> will compare equal. Otherwise the result is
* the same as s1.equals(s2), if s1 is not null.
* @param s1 The first string to compare
* @param s2 the second string
* @return true if the strings are equal or both null.
*/
protected boolean compareStrings(String s1, String s2) {
if (s1 == s2) return true;
if (s1 == null) return false;
return s1.equals(s2);
}
} }

View file

@ -18,11 +18,11 @@
package org.eclipse.rse.core.subsystems; package org.eclipse.rse.core.subsystems;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor; 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.IHost;
import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
@ -253,8 +253,12 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
List children = new ArrayList(20); List children = new ArrayList(20);
children.add(getRemoteServerLauncherProperties()); IServerLauncherProperties launcherProperties = getRemoteServerLauncherProperties();
if (launcherProperties != null) {
children.add(getRemoteServerLauncherProperties());
}
children.addAll(_registeredSubSystems); children.addAll(_registeredSubSystems);
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()]; IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result); children.toArray(result);
return result; return result;

View file

@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEPersistableObject;
public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService
{ {
@ -752,6 +751,9 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false; return false;
} }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#isTainted()
*/
public boolean isTainted() { public boolean isTainted() {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)
@ -761,6 +763,9 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false; return false;
} }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#setTainted(boolean)
*/
public void setTainted(boolean flag) { public void setTainted(boolean flag) {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)
@ -769,26 +774,16 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
} }
} }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableParent()
*/
public IRSEPersistableContainer getPersistableParent() { public IRSEPersistableContainer getPersistableParent() {
return getHost(); return getHost();
} }
public void beginRestore() { /* (non-Javadoc)
IConnectorService conServ = getRealConnectorService(); * @see org.eclipse.rse.core.model.IRSEPersistableContainer#getPersistableChildren()
if (conServ != null) */
{
conServ.beginRestore();
}
}
public void endRestore() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.endRestore();
}
}
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)

View file

@ -17,6 +17,7 @@
package org.eclipse.rse.internal.core.filters; package org.eclipse.rse.internal.core.filters;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
@ -1384,6 +1385,7 @@ public class SystemFilter extends SystemReferencedObject implements ISystemFilte
if (filterStringVector != null) { if (filterStringVector != null) {
children.addAll(filterStringVector); children.addAll(filterStringVector);
} }
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()]; IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result); children.toArray(result);
return result; return result;

View file

@ -17,7 +17,9 @@
package org.eclipse.rse.internal.core.filters; package org.eclipse.rse.internal.core.filters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
@ -256,102 +258,21 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
* @generated This field/method will be replaced during code generation. * @generated This field/method will be replaced during code generation.
*/ */
protected java.util.List filters = null; protected java.util.List filters = null;
private static SystemFilterPool _instance;
/** /**
* Default constructor * Default constructor
*/ */
protected SystemFilterPool() public SystemFilterPool(String poolName, boolean allowNestedFilters, boolean isDeletable)
{ {
super(); super();
helpers = new SystemFilterContainerCommonMethods(); helpers = new SystemFilterContainerCommonMethods();
} setRelease(RSECorePlugin.CURRENT_RELEASE);
if (!initialized) {
public static SystemFilterPool getDefault() initialize(poolName, savePolicy, namingPolicy);
{
if (_instance == null)
{
_instance = new SystemFilterPool();
} }
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.
* <p>
* 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 setDeletable(isDeletable); // mof attribute
//System.out.println("In initialize() for filter pool " + getName() + ". isDeletable= " + isDeletable);
setSupportsNestedFilters(allowNestedFilters); // cascades to each filter setSupportsNestedFilters(allowNestedFilters); // cascades to each filter
} }
/* /*
* Private helper method to core initialization, from either createXXX or restore. * Private helper method to core initialization, from either createXXX or restore.
@ -1321,17 +1242,25 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public boolean commit() public boolean commit()
{ {
ISystemProfile profile = getSystemFilterPoolManager().getSystemProfile(); return getPersistableParent().commit();
boolean result = profile.commit();
return result;
} }
public IRSEPersistableContainer getPersistableParent() { public IRSEPersistableContainer getPersistableParent() {
return mgr; ISystemProfile profile = null;
ISystemFilterPoolManager filterPoolManager = getSystemFilterPoolManager();
if (filterPoolManager != null) {
profile = filterPoolManager.getSystemProfile();
}
return profile;
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
return getSystemFilters(); List children = new ArrayList(10);
children.addAll(Arrays.asList(getSystemFilters()));
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
} }
} }

View file

@ -16,9 +16,6 @@
package org.eclipse.rse.internal.core.filters; 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.IAdaptable;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
@ -35,6 +32,7 @@ import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.references.SystemPersistableReferencingObject; import org.eclipse.rse.internal.references.SystemPersistableReferencingObject;
/** /**
@ -66,13 +64,10 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
/** /**
* Constructs a new filter pool reference. This is an unresolved reference. * 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. * @param filterPoolName the name of the filter pool.
*/ */
public SystemFilterPoolReference(ISystemFilterPoolManager filterPoolManager, String filterPoolName) { public SystemFilterPoolReference(String filterPoolName) {
this(); this();
this.filterPoolManager = filterPoolManager;
setReferencedObjectName(filterPoolName); setReferencedObjectName(filterPoolName);
} }
@ -105,28 +100,48 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolName() * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolName()
*/ */
public String getReferencedFilterPoolName() { public String getReferencedFilterPoolName() {
String savedName = super.getReferencedObjectName(); /*
String poolName = null; * A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName.
int idx = savedName.indexOf(DELIMITER); * or in the unqualified form of filterPoolName which references a locally defined filter pool.
if (idx >= 0) * ___ is the delimiter. Absence of the delimiter indicates an unqualified name.
poolName = savedName.substring(idx + DELIMITER_LENGTH); * The filter pool manager name is the same as its owning profile.
else */
poolName = savedName; String savedName = getReferencedObjectName();
return poolName; String[] parts = savedName.split(DELIMITER, 2);
String result = parts[0];
if (parts.length == 2) {
result = parts[1];
}
return result;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolManagerName() * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getReferencedFilterPoolManagerName()
*/ */
public String getReferencedFilterPoolManagerName() { public String getReferencedFilterPoolManagerName() {
String savedName = super.getReferencedObjectName(); /*
String mgrName = null; * A filter pool reference stores the name of the filter pool it references in the form managerName___filterPoolName.
int idx = savedName.indexOf(DELIMITER); * or in the unqualified form of filterPoolName which references a locally defined filter pool.
if (idx >= 0) * ___ is the delimiter. Absence of the delimiter indicates an unqualified name.
mgrName = savedName.substring(0, idx); * The filter pool manager name is the same as its owning profile.
else */
mgrName = savedName; String result = null;
return mgrName; 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) /* (non-Javadoc)
@ -150,28 +165,20 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
ISystemFilterPool filterPool = (ISystemFilterPool) getReferencedObject(); ISystemFilterPool filterPool = (ISystemFilterPool) getReferencedObject();
if (filterPool == null) { if (filterPool == null) {
String filterPoolName = getReferencedFilterPoolName(); 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); 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; return filterPool;
} }
@ -234,7 +241,7 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
* @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getFullName() * @see org.eclipse.rse.core.filters.ISystemFilterPoolReference#getFullName()
*/ */
public String getFullName() { public String getFullName() {
return super.getReferencedObjectName(); return getReferencedObjectName();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -16,6 +16,8 @@
package org.eclipse.rse.internal.core.filters; package org.eclipse.rse.internal.core.filters;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -384,9 +386,10 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* Create a filter pool reference. This creates an unresolved raw reference that * Create a filter pool reference. This creates an unresolved raw reference that
* must be added to the managed lists by the caller. * must be added to the managed lists by the caller.
* That will be attempted to be resolved on first use. * 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) { private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolManager, filterPoolName); ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
return filterPoolReference; return filterPoolReference;
} }
@ -503,10 +506,16 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/ */
public ISystemFilterPool[] getReferencedSystemFilterPools() { public ISystemFilterPool[] getReferencedSystemFilterPools() {
ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences(); ISystemFilterPoolReference[] refs = getSystemFilterPoolReferences();
ISystemFilterPool[] pools = new ISystemFilterPool[refs.length]; List pools = new ArrayList(refs.length);
for (int idx = 0; idx < pools.length; idx++) for (int idx = 0; idx < refs.length; idx++) {
pools[idx] = refs[idx].getReferencedFilterPool(); ISystemFilterPool pool = refs[idx].getReferencedFilterPool();
return pools; if (pool != null) {
pools.add(pool);
}
}
ISystemFilterPool[] result = new ISystemFilterPool[pools.size()];
pools.toArray(result);
return result;
} }
/** /**
@ -542,8 +551,8 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.filters.ISystemFilterPoolReferenceManager#addReferenceToSystemFilterPool(org.eclipse.rse.filters.ISystemFilterPoolManager, java.lang.String) * @see org.eclipse.rse.filters.ISystemFilterPoolReferenceManager#addReferenceToSystemFilterPool(org.eclipse.rse.filters.ISystemFilterPoolManager, java.lang.String)
*/ */
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPoolManager filterPoolManager, String filterPoolName) { public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolManager, filterPoolName); ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName);
addReferencingObject(filterPoolReference); addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();

View file

@ -18,7 +18,6 @@ package org.eclipse.rse.internal.core.filters;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform; 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.ISystemFilter;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider; import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;

View file

@ -14,11 +14,15 @@
* David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - 142806: refactoring persistence framework
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.model; package org.eclipse.rse.internal.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform; 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.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
@ -28,9 +32,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.core.model.RSEModelResources;
import org.eclipse.rse.persistence.IRSEPersistenceProvider; import org.eclipse.rse.persistence.IRSEPersistenceProvider;
import org.eclipse.rse.ui.RSEUIPlugin;
/** /**
* A profile contains hosts and filter pools. It is the unit of save/restore for RSE model * A profile contains hosts and filter pools. It is the unit of save/restore for RSE model
@ -39,9 +41,9 @@ import org.eclipse.rse.ui.RSEUIPlugin;
public class SystemProfile extends RSEModelObject implements ISystemProfile, IAdaptable public class SystemProfile extends RSEModelObject implements ISystemProfile, IAdaptable
{ {
private ISystemProfileManager mgr; private ISystemProfileManager mgr = null;
private IRSEPersistenceProvider provider; private IRSEPersistenceProvider provider = null;
private boolean active; private boolean isActive = true;
private String name = null; private String name = null;
private boolean defaultPrivate = false; private boolean defaultPrivate = false;
@ -53,6 +55,11 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
super(); 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 * Set the in-memory pointer back to the parent system profile manager
*/ */
@ -75,7 +82,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/ */
public IHost createHost(String systemType, String connectionName, String hostName, String description) throws Exception public IHost createHost(String systemType, String connectionName, String hostName, String description) throws Exception
{ {
return RSEUIPlugin.getTheSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description); return RSECorePlugin.getDefault().getSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description);
} }
/** /**
@ -83,7 +90,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/ */
public IHost[] getHosts() public IHost[] getHosts()
{ {
return RSEUIPlugin.getTheSystemRegistry().getHostsByProfile(this); return RSECorePlugin.getDefault().getSystemRegistry().getHostsByProfile(this);
} }
/** /**
@ -91,7 +98,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/ */
public ISystemFilterPool[] getFilterPools() public ISystemFilterPool[] getFilterPools()
{ {
ISubSystemConfiguration[] ssFactories = RSEUIPlugin.getTheSystemRegistry().getSubSystemConfigurations(); ISubSystemConfiguration[] ssFactories = RSECorePlugin.getDefault().getSystemRegistry().getSubSystemConfigurations();
Vector poolsVector = new Vector(); Vector poolsVector = new Vector();
for (int idx = 0; idx < ssFactories.length; idx++) for (int idx = 0; idx < ssFactories.length; idx++)
{ {
@ -121,14 +128,15 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
*/ */
public boolean isActive() public boolean isActive()
{ {
return active; return isActive;
} }
/** /**
* Reset whether this profile is currently active. * Reset whether this profile is currently active.
*/ */
public void setActive(boolean active) public void setActive(boolean active)
{ {
this.active = active; this.isActive = active;
setDirty(true);
} }
/** /**
@ -175,6 +183,7 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
public void setName(String newName) public void setName(String newName)
{ {
name = newName; name = newName;
setDirty(true);
} }
/** /**
@ -193,11 +202,12 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
public void setDefaultPrivate(boolean newDefaultPrivate) public void setDefaultPrivate(boolean newDefaultPrivate)
{ {
defaultPrivate = newDefaultPrivate; defaultPrivate = newDefaultPrivate;
setDirty(true);
} }
public boolean commit() public boolean commit()
{ {
return RSEUIPlugin.getThePersistenceManager().commit(this); return RSECorePlugin.getThePersistenceManager().commitProfile(this);
} }
/** /**
@ -209,11 +219,12 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
ISystemFilterPool[] pools = getFilterPools(); List children = new ArrayList(10);
IHost[] hosts = getHosts(); children.addAll(Arrays.asList(getFilterPools()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[pools.length + hosts.length]; children.addAll(Arrays.asList(getHosts()));
System.arraycopy(pools, 0, result, 0, pools.length); children.addAll(Arrays.asList(getPropertySets()));
System.arraycopy(hosts, 0, result, pools.length, hosts.length); IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result; return result;
} }
@ -224,10 +235,11 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return provider; return provider;
} }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfile#setPersistenceProvider(org.eclipse.rse.persistence.IRSEPersistenceProvider)
*/
public void setPersistenceProvider(IRSEPersistenceProvider provider) { public void setPersistenceProvider(IRSEPersistenceProvider provider) {
this.provider = provider; this.provider = provider;
} }
} }

View file

@ -15,49 +15,48 @@
* - moved SystemPreferencesManager to a new plugin * - moved SystemPreferencesManager to a new plugin
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.model; package org.eclipse.rse.internal.core.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.model.SystemStartHere; import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.persistence.IRSEPersistenceProvider;
import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorProfileName;
/** /**
* A class that manages a list of SystemProfile objects. * A class that manages a list of SystemProfile objects.
* This should be used as a singleton. * This should be used as a singleton.
*/ */
public class SystemProfileManager implements ISystemProfileManager { public class SystemProfileManager implements ISystemProfileManager {
private List _profiles = null;
private String[] profileNames = null; private List _profiles = new ArrayList(10);
private Vector profileNamesVector = null; // private String[] profileNames = null;
private static ISystemProfileManager singleton = null; // private Vector profileNamesVector = null;
private static final String PROFILE_FILE_NAME = "profile"; //$NON-NLS-1$ private static SystemProfileManager singleton = null;
private boolean restoring = false;
/** /**
* Ordinarily there should be only one instance of a SystemProfileManager * Ordinarily there should be only one instance of a SystemProfileManager
* created on the system, so the static method {@link #getSystemProfileManager()} is * created on the system, so the static method {@link #getDefault()} is
* preferred to using this. * preferred to using this.
*/ */
private SystemProfileManager() { private SystemProfileManager() {
super();
} }
/** /**
* @return (and create if necessary) the singleton instance of this class. * @return (and create if necessary) the singleton instance of this class.
*/ */
public static ISystemProfileManager getSystemProfileManager() { public static SystemProfileManager getDefault() {
if (singleton == null) { if (singleton == null) {
singleton = new SystemProfileManager(); singleton = new SystemProfileManager();
RSEUIPlugin.getThePersistenceManager().restore(singleton); // restores all of RSE RSECorePlugin.getThePersistenceManager().restoreProfiles();
} }
return singleton; return singleton;
} }
@ -81,18 +80,16 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see ISystemProfileManager#createSystemProfile(String, boolean) * @see ISystemProfileManager#createSystemProfile(String, boolean)
*/ */
public ISystemProfile createSystemProfile(String name, boolean makeActive) { public ISystemProfile createSystemProfile(String name, boolean makeActive) {
// FIXME - used to use MOF
ISystemProfile existingProfile = getSystemProfile(name); ISystemProfile existingProfile = getSystemProfile(name);
if (existingProfile != null) { if (existingProfile != null) {
deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile deleteSystemProfile(existingProfile, false); // replace the existing one with a new profile
} }
ISystemProfile newProfile = internalCreateSystemProfile(name);
ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name);
if (makeActive) { if (makeActive) {
RSEPreferencesManager.addActiveProfile(name); RSEPreferencesManager.addActiveProfile(name);
((SystemProfile) newProfile).setActive(makeActive); ((SystemProfile) newProfile).setActive(makeActive);
} }
RSEUIPlugin.getThePersistenceManager().commit(this); newProfile.commit();
return newProfile; return newProfile;
} }
@ -107,124 +104,58 @@ public class SystemProfileManager implements ISystemProfileManager {
((SystemProfile) profile).setActive(makeActive); ((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) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles() * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/ */
public ISystemProfile[] getSystemProfiles() { public ISystemProfile[] getSystemProfiles() {
List profiles = getProfiles(); return getSystemProfiles(!restoring);
// 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) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames() * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames()
*/ */
public String[] getSystemProfileNames() { public String[] getSystemProfileNames() {
if (profileNames == null) { ISystemProfile[] profiles = getSystemProfiles();
ISystemProfile[] profiles = getSystemProfiles(); String[] profileNames = new String[profiles.length];
profileNames = new String[profiles.length]; for (int i = 0; i < profiles.length; i++) {
for (int idx = 0; idx < profiles.length; idx++) ISystemProfile profile = profiles[i];
profileNames[idx] = profiles[idx].getName(); profileNames[i] = profile.getName();
} }
return profileNames; 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) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector() * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector()
*/ */
public Vector getSystemProfileNamesVector() { public Vector getSystemProfileNamesVector() {
if (profileNamesVector == null) { List names = Arrays.asList(getSystemProfileNames());
ISystemProfile[] profiles = getSystemProfiles(); Vector result = new Vector(names.size());
profileNamesVector = new Vector(profiles.length); result.addAll(names);
for (int idx = 0; idx < profiles.length; idx++) return result;
profileNamesVector.addElement(profiles[idx].getName()); // if (profileNamesVector == null) {
} // ISystemProfile[] profiles = getSystemProfiles();
return profileNamesVector; // profileNamesVector = new Vector(profiles.length);
} // for (int idx = 0; idx < profiles.length; idx++)
// profileNamesVector.addElement(profiles[idx].getName());
/** // }
* Something changed so invalide cache of profiles so it will be regenerated // return profileNamesVector;
*/
protected void invalidateCache() {
//DY profiles = null;
profileNames = null;
profileNamesVector = null;
} }
// /**
// * Something changed so invalide cache of profiles so it will be regenerated
// */
// protected void invalidateCache() {
// profileNames = null;
// profileNamesVector = null;
// }
//
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String) * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
*/ */
@ -245,7 +176,7 @@ public class SystemProfileManager implements ISystemProfileManager {
String oldName = profile.getName(); String oldName = profile.getName();
profile.setName(newName); profile.setName(newName);
if (isActive) RSEPreferencesManager.renameActiveProfile(oldName, newName); if (isActive) RSEPreferencesManager.renameActiveProfile(oldName, newName);
invalidateCache(); // invalidateCache();
// FIXME RSEUIPlugin.getThePersistenceManager().save(this); // FIXME RSEUIPlugin.getThePersistenceManager().save(this);
} }
@ -255,7 +186,7 @@ public class SystemProfileManager implements ISystemProfileManager {
public void deleteSystemProfile(ISystemProfile profile, boolean persist) { public void deleteSystemProfile(ISystemProfile profile, boolean persist) {
String oldName = profile.getName(); String oldName = profile.getName();
boolean isActive = isSystemProfileActive(oldName); boolean isActive = isSystemProfileActive(oldName);
getProfiles().remove(profile); _profiles.remove(profile);
/* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager, /* 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. * 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. * No longer needed since EMF is not in use.
@ -264,9 +195,10 @@ public class SystemProfileManager implements ISystemProfileManager {
* res.getContents().remove(profile); * res.getContents().remove(profile);
*/ */
if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName); if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName);
invalidateCache(); // invalidateCache();
if (persist) { if (persist) {
RSEUIPlugin.getThePersistenceManager().deleteProfile(oldName); IRSEPersistenceProvider provider = profile.getPersistenceProvider();
RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
} }
} }
@ -430,100 +362,115 @@ public class SystemProfileManager implements ISystemProfileManager {
return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName()); 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. * Instantiate a user profile given its name.
* @param userProfileName the name of the profile to find or create * @param userProfileName the name of the profile to find or create
* @return the profile that was found or created. * @return the profile that was found or created.
*/ */
protected ISystemProfile getOrCreateSystemProfile(String userProfileName) { private ISystemProfile getOrCreateSystemProfile(String userProfileName) {
ISystemProfile userProfile = getSystemProfile(userProfileName); ISystemProfile userProfile = getSystemProfile(userProfileName);
if (userProfile == null) { if (userProfile == null) {
userProfile = internalCreateSystemProfileAndFolder(userProfileName); userProfile = internalCreateSystemProfile(userProfileName);
} }
return userProfile; 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;
}
} }

View file

@ -16,7 +16,9 @@
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.core.subsystems; package org.eclipse.rse.internal.core.subsystems;
import org.eclipse.rse.core.RSECorePlugin; import java.util.Arrays;
import java.util.List;
import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
@ -59,7 +61,10 @@ public abstract class ServerLauncher extends RSEModelObject implements IServerLa
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0]; List children = Arrays.asList(getPropertySets());
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;
} }
/** /**

View file

@ -16,11 +16,13 @@
package org.eclipse.rse.internal.persistence; package org.eclipse.rse.internal.persistence;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IExtensionRegistry;
@ -29,19 +31,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.jobs.Job; 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.IRSEPreferenceNames;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.model.IRSEPersistableContainer;
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.ISystemProfile; 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.ISystemRegistry;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter; import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter;
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter; import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
import org.eclipse.rse.logging.Logger; import org.eclipse.rse.logging.Logger;
@ -58,129 +54,117 @@ import org.eclipse.rse.persistence.dom.RSEDOM;
public class RSEPersistenceManager implements IRSEPersistenceManager { public class RSEPersistenceManager implements IRSEPersistenceManager {
private static final int STATE_NONE = 0; private static final int STATE_NONE = 0;
private static final int STATE_IMPORTING = 1; private static final int STATE_LOADING = 1;
private static final int STATE_EXPORTING = 2; private static final int STATE_SAVING = 2;
private static IProject remoteSystemsProject = null; private static IProject remoteSystemsProject = null;
public static final String RESOURCE_PROJECT_NAME = "RemoteSystemsConnections"; //$NON-NLS-1$
/** /**
* Get the default remote systems project. * 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() { public static IProject getRemoteSystemsProject() {
if (remoteSystemsProject == null) if (remoteSystemsProject == null)
{ {
remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(); remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject();
} }
return remoteSystemsProject; return remoteSystemsProject;
} }
private Map loadedProviders = new HashMap(10);
private Map knownProviders = new HashMap(10);
private int _currentState = STATE_NONE; private int _currentState = STATE_NONE;
private RSEDOMExporter _exporter; private RSEDOMExporter _exporter;
private RSEDOMImporter _importer; private RSEDOMImporter _importer;
public RSEPersistenceManager(ISystemRegistry registry) { public RSEPersistenceManager(ISystemRegistry registry) {
// _registry = registry;
_exporter = RSEDOMExporter.getInstance(); _exporter = RSEDOMExporter.getInstance();
_exporter.setSystemRegistry(registry);
_importer = RSEDOMImporter.getInstance(); _importer = RSEDOMImporter.getInstance();
_importer.setSystemRegistry(registry); _importer.setSystemRegistry(registry);
getProviderExtensions();
} }
public boolean commit(ISystemFilterPoolManager filterPoolManager) { public boolean isExporting() {
if (filterPoolManager.isDirty()) { return _currentState == STATE_SAVING;
commit(filterPoolManager.getSystemProfile());
filterPoolManager.setDirty(false);
}
return false;
} }
public boolean commit(ISystemHostPool connectionPool) { public boolean isImporting() {
if (connectionPool.isDirty()) { return _currentState == STATE_LOADING;
commit(connectionPool.getSystemProfile()); }
connectionPool.setDirty(false);
} public void registerPersistenceProvider(String id, IRSEPersistenceProvider provider) {
/* knownProviders.put(id, provider);
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
} }
/** /**
* Attempt to save single profile to disk. * Attempt to save single profile to disk.
*/ */
public boolean commit(ISystemProfile profile) { public boolean commitProfile(ISystemProfile profile) {
boolean result = false;
if (profile != null) { if (profile != null) {
return save(profile, false); result = save(profile, true);
} }
return false; return result;
} }
/** public boolean commitProfiles() {
* Save all profiles to disk boolean ok = true;
*/ ISystemProfile[] profiles = RSECorePlugin.getDefault().getSystemRegistry().getAllSystemProfiles();
public boolean commit(ISystemProfileManager profileManager) { for (int idx = 0; idx < profiles.length && ok; idx++) {
ISystemProfile[] profiles = profileManager.getSystemProfiles();
for (int idx = 0; idx < profiles.length; idx++) {
try { try {
commit(profiles[idx]); ok = commitProfile(profiles[idx]);
} catch (Exception exc) { } catch (Exception exc) {
Logger logger = RSECorePlugin.getDefault().getLogger(); Logger logger = RSECorePlugin.getDefault().getLogger();
String profileName = profiles[idx].getName(); String profileName = profiles[idx].getName();
String message = "Error saving profile " + profileName; //$NON-NLS-1$ String message = "Error saving profile " + profileName; //$NON-NLS-1$
logger.logError(message, exc); logger.logError(message, exc);
return false; ok = false;
} }
} }
return ok;
}
return true; /* (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) /* (non-Javadoc)
* @see org.eclipse.rse.persistence.IRSEPersistenceManager#deleteProfile(java.lang.String) * @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) { Job job = new Job(Messages.RSEPersistenceManager_DeleteProfileJobName) {
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
IRSEPersistenceProvider provider = getRSEPersistenceProvider(); IRSEPersistenceProvider p = persistenceProvider != null ? persistenceProvider : getDefaultPersistenceProvider();
IStatus result = provider.deleteProfile(profileName, monitor); IStatus result = p.deleteProfile(profileName, monitor);
return result; return result;
} }
}; };
job.schedule(); job.schedule();
} }
private RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) { /* (non-Javadoc)
RSEDOM dom = _exporter.createRSEDOM(profile, force); * @see org.eclipse.rse.persistence.IRSEPersistenceManager#restoreProfiles()
return dom; */
public ISystemProfile[] restoreProfiles() {
List profiles = loadProfiles();
ISystemProfile[] result = new ISystemProfile[profiles.size()];
profiles.toArray(result);
return result;
} }
/** public ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName) {
* Retrieves the default persistence provider for this workbench configuration. ISystemProfile result = load(provider, profileName);
* Several persistence providers may be registered, but the default one is used for all return result;
* profiles that do not have one explicitly specified.
* This persistence provider's identifier is specified in the org.eclipse.rse.core/defaultPersistenceProvider
* preference and can be specified a product's plugin_customization.ini file.
* @see IRSEPreferenceNames
* @return the default IRSEPersistenceProvider for this installation.
*/
public IRSEPersistenceProvider getRSEPersistenceProvider() {
Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
String providerName = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
IRSEPersistenceProvider provider = getRSEPersistenceProvider(providerName);
return provider;
} }
/** /**
@ -189,216 +173,163 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
* @param id The id of the persistence provider, as denoted by the id attribute on its declaration. * @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. * @return an IRSEPersistenceProvider which may be null if this id is not found.
*/ */
public IRSEPersistenceProvider getRSEPersistenceProvider(String id) { public IRSEPersistenceProvider getPersistenceProvider(String id) {
Logger logger = RSECorePlugin.getDefault().getLogger(); IRSEPersistenceProvider provider = null;
IRSEPersistenceProvider provider = (IRSEPersistenceProvider) loadedProviders.get(id); Object providerCandidate = knownProviders.get(id);
if (provider == null) { if (providerCandidate instanceof IConfigurationElement) {
IExtensionRegistry registry = Platform.getExtensionRegistry(); IConfigurationElement element = (IConfigurationElement) providerCandidate;
IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$ try {
for (int j = 0; j < providerCandidates.length; j++) { provider = (IRSEPersistenceProvider) element.createExecutableExtension("class"); //$NON-NLS-1$
IConfigurationElement providerCandidate = providerCandidates[j]; } catch (CoreException e) {
if (providerCandidate.getName().equals("persistenceProvider")) { //$NON-NLS-1$ Logger logger = RSECorePlugin.getDefault().getLogger();
String candidateId = providerCandidate.getAttribute("id"); //$NON-NLS-1$ logger.logError("Exception loading persistence provider", e); //$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$
}
} else {
logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$
}
} }
if (provider == null) { if (provider != null) {
logger.logError("Persistence provider not found.", null); //$NON-NLS-1$ knownProviders.put(id, provider);
} }
loadedProviders.put(id, provider); // even if provider is null } else if (providerCandidate instanceof IRSEPersistenceProvider) {
provider = (IRSEPersistenceProvider) providerCandidate;
} }
return provider; return provider;
} }
private RSEDOM importRSEDOM(String domName) { /* (non-Javadoc)
RSEDOM dom = null; * @see org.eclipse.rse.persistence.IRSEPersistenceManager#getPersistenceProviderIds()
IRSEPersistenceProvider provider = getRSEPersistenceProvider(); */
if (provider != null) { public String[] getPersistenceProviderIds() {
dom = provider.loadRSEDOM(domName, null); Set ids = knownProviders.keySet();
} else { String[] result = new String[ids.size()];
Logger logger = RSECorePlugin.getDefault().getLogger(); ids.toArray(result);
logger.logError("Persistence provider is not available.", null); //$NON-NLS-1$ return result;
}
return dom;
}
public synchronized boolean isExporting() {
return _currentState == STATE_EXPORTING;
}
public synchronized boolean isImporting() {
return _currentState == STATE_IMPORTING;
} }
/** /**
* Loads and restores RSE artifacts from the last session * Retrieves the default persistence provider for this workbench configuration.
* @param profileManager * Several persistence providers may be registered, but the default one is used for all
* @return true if the profiles are loaded * profiles that do not have one explicitly specified.
* 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.
*/ */
private boolean load(ISystemProfileManager profileManager) { private IRSEPersistenceProvider getDefaultPersistenceProvider() {
boolean successful = true; Preferences preferences = RSECorePlugin.getDefault().getPluginPreferences();
synchronized(this) { String providerId = preferences.getString(IRSEPreferenceNames.DEFAULT_PERSISTENCE_PROVIDER);
if (isExporting() || isImporting()) { IRSEPersistenceProvider provider = getPersistenceProvider(providerId);
successful = false; return provider;
} else { }
setState(STATE_IMPORTING);
} /**
} * Loads the map of known providers from the extensions made by all the plugins.
if(successful) { * This is done once at initialization of the manager. As these ids are resolved to
try { * their providers as needed, the configuration elements are replaced in the map
IProject project = getRemoteSystemsProject(); * by the persistence providers they reference.
if (!project.isSynchronized(IResource.DEPTH_ONE)) project.refreshLocal(IResource.DEPTH_ONE, null); */
IRSEPersistenceProvider persistenceProvider = getRSEPersistenceProvider(); private void getProviderExtensions() {
String[] profileNames = persistenceProvider.getSavedProfileNames(); Logger logger = RSECorePlugin.getDefault().getLogger();
for (int i = 0; i < profileNames.length; i++) { IExtensionRegistry registry = Platform.getExtensionRegistry();
String profileName = profileNames[i]; IConfigurationElement[] providerCandidates = registry.getConfigurationElementsFor("org.eclipse.rse.core", "persistenceProviders"); //$NON-NLS-1$ //$NON-NLS-2$
RSEDOM dom = importRSEDOM(profileName); for (int j = 0; j < providerCandidates.length; j++) {
if (dom != null) { IConfigurationElement configurationElement = providerCandidates[j];
ISystemProfile restoredProfile = _importer.restoreProfile(profileManager, dom); if (configurationElement.getName().equals("persistenceProvider")) { //$NON-NLS-1$
if (restoredProfile == null) { String candidateId = configurationElement.getAttribute("id"); //$NON-NLS-1$
successful = false; if (candidateId != null) {
} knownProviders.put(candidateId, configurationElement);
} else { } else {
successful = false; logger.logError("Missing id attribute in persistenceProvider element", null); //$NON-NLS-1$
}
} }
} catch (Exception e) { } else {
e.printStackTrace(); logger.logError("Invalid element in persistenceProviders extension point", null); //$NON-NLS-1$
successful = false;
} finally {
setState(STATE_NONE);
} }
} }
return successful;
} }
public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider) { private List loadProfiles() {
loadedProviders.put(id, provider); 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 profiles;
} }
public boolean restore(ISystemFilterPool filterPool) { private List loadProfiles(IRSEPersistenceProvider persistenceProvider) {
//System.out.println("restore filterpool"); List profiles = new ArrayList(10);
// DWD function Is this method really needed? String[] profileNames = persistenceProvider.getSavedProfileNames();
return false; for (int i = 0; i < profileNames.length; i++) {
} String profileName = profileNames[i];
ISystemProfile profile = load(persistenceProvider, profileName);
public boolean restore(ISystemHostPool connectionPool) { profiles.add(profile);
return false; }
} return profiles;
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 * Loads a profile of the given name using the given persistence provider. If the provider cannot
* "restore" for historcal reasons. * find a profile with that name, return null.
* @param profile the profile that will own this ISystemFilterPoolManager. There is one of these per profile. * @param provider the persistence provider that understands the name and can produce a profile.
* @param logger the logging object for logging errors. Each ISystemFilterPoolManager has one of these. * @param profileName the name of the profile to produce
* @param caller The creator/owner of this ISystemFilterPoolManager, this ends up being a SubSystemConfiguration. * @return the profile or null
* @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) { private synchronized ISystemProfile load(IRSEPersistenceProvider provider, String profileName) {
SystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile); ISystemProfile profile = null;
mgr.initialize(logger, caller, name); // core data if (_currentState == STATE_NONE) {
mgr.setWasRestored(false); // managers are not "restored from disk" since they are not persistent of themselves _currentState = STATE_LOADING;
return mgr; RSEDOM dom = provider.loadRSEDOM(profileName, null);
if (dom != null) {
SystemProfileManager.getDefault().setRestoring(true);
profile = _importer.restoreProfile(dom);
profile.setPersistenceProvider(provider);
cleanTree(profile);
SystemProfileManager.getDefault().setRestoring(false);
}
_currentState = STATE_NONE;
}
return profile;
} }
/** /**
* Restore a connection of a given name from disk... * Writes a profile to a DOM and schedules writing of that DOM to 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.
* May, in fact, update an existing DOM instead of creating a new one. * May, in fact, update an existing DOM instead of creating a new one.
* If in the process of importing, skip writing. * If in the process of importing, skip writing.
* @return true if the profile is written to a DOM * @return true if the profile is written to a DOM
*/ */
private boolean save(ISystemProfile profile, boolean force) { private synchronized boolean save(ISystemProfile profile, boolean force) {
boolean result = false; if (_currentState == STATE_NONE) {
boolean acquiredLock = false; _currentState = STATE_SAVING;
synchronized(this) { IRSEPersistenceProvider provider = profile.getPersistenceProvider();
if (!isImporting()) { if (provider == null) {
setState(STATE_EXPORTING); provider = getDefaultPersistenceProvider();
acquiredLock = true; profile.setPersistenceProvider(provider);
} }
} RSEDOM dom = _exporter.createRSEDOM(profile, force);
if (acquiredLock) { cleanTree(profile);
try { if (dom.needsSave()) {
RSEDOM dom = exportRSEDOM(profile, true); // DWD should do merge, but does not handle deletes properly yet Job job = dom.getSaveJob();
result = true; if (job == null) {
if (dom.needsSave()) { job = new SaveRSEDOMJob(dom, getDefaultPersistenceProvider());
Job job = dom.getSaveJob(); dom.setSaveJob(job);
if (job == null) {
job = new SaveRSEDOMJob(dom, getRSEPersistenceProvider());
dom.setSaveJob(job);
}
job.schedule(3000); // three second delay
} }
} finally { job.schedule(3000); // three second delay
setState(STATE_NONE);
} }
_currentState = STATE_NONE;
} }
return result; return true;
} }
private synchronized void setState(int state) { private void cleanTree(IRSEPersistableContainer node) {
_currentState = state; 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);
}
} }
} }

View file

@ -31,7 +31,6 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType; import org.eclipse.rse.core.model.IPropertyType;
import org.eclipse.rse.core.model.IRSEModelObject; import org.eclipse.rse.core.model.IRSEModelObject;
import org.eclipse.rse.core.model.ISystemProfile; 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.IConnectorService;
import org.eclipse.rse.core.subsystems.IDelegatingConnectorService; import org.eclipse.rse.core.subsystems.IDelegatingConnectorService;
import org.eclipse.rse.core.subsystems.IServerLauncherProperties; import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
@ -41,11 +40,10 @@ import org.eclipse.rse.persistence.dom.RSEDOM;
import org.eclipse.rse.persistence.dom.RSEDOMNode; import org.eclipse.rse.persistence.dom.RSEDOMNode;
public class RSEDOMExporter implements IRSEDOMExporter { public class RSEDOMExporter implements IRSEDOMExporter {
private static RSEDOMExporter _instance = new RSEDOMExporter(); private static RSEDOMExporter _instance = new RSEDOMExporter();
private Map _domMap; private Map _domMap;
// private ISystemRegistry _registry;
/** /**
* Constructor to create a new DOM exporter. * Constructor to create a new DOM exporter.
*/ */
@ -53,10 +51,6 @@ public class RSEDOMExporter implements IRSEDOMExporter {
_domMap = new HashMap(); _domMap = new HashMap();
} }
public void setSystemRegistry(ISystemRegistry registry) {
// _registry = registry;
}
/** /**
* @return the singleton instance of this exporter * @return the singleton instance of this exporter
*/ */
@ -401,13 +395,13 @@ public class RSEDOMExporter implements IRSEDOMExporter {
*/ */
public RSEDOMNode createNode(RSEDOMNode parent, ISystemFilterPoolReference filterPoolReference, boolean clean) { public RSEDOMNode createNode(RSEDOMNode parent, ISystemFilterPoolReference filterPoolReference, boolean clean) {
RSEDOMNode node = findOrCreateNode(parent, IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE, filterPoolReference, 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()) { if (clean || node.isDirty()) {
ISystemFilterPool filterPool = filterPoolReference.getReferencedFilterPool(); ISystemFilterPool filterPool = filterPoolReference.getReferencedFilterPool();
String refId = (filterPool != null) ? filterPool.getId() : "unknown"; //$NON-NLS-1$ String refId = (filterPool != null) ? filterPool.getId() : "unknown"; //$NON-NLS-1$
node.addAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID, refId); node.addAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID, refId);
} }
createPropertySetNodes(node, filterPoolReference, clean); createPropertySetNodes(node, filterPoolReference, clean);
node.setDirty(false); node.setDirty(false);
return node; return node;
@ -430,8 +424,7 @@ public class RSEDOMExporter implements IRSEDOMExporter {
node.setDirty(true); node.setDirty(true);
} }
} }
boolean newNode = (node == null); if (node == null) {
if (newNode) {
node = new RSEDOMNode(parent, type, name); node = new RSEDOMNode(parent, type, name);
} }
return node; return node;

View file

@ -30,7 +30,6 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertyType; import org.eclipse.rse.core.model.IPropertyType;
import org.eclipse.rse.core.model.IRSEModelObject; import org.eclipse.rse.core.model.IRSEModelObject;
import org.eclipse.rse.core.model.ISystemProfile; 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.ISystemRegistry;
import org.eclipse.rse.core.model.PropertyType; import org.eclipse.rse.core.model.PropertyType;
import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.IConnectorService;
@ -40,13 +39,14 @@ import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.SubSystemFilterNamingPolicy; 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.IRSEDOMConstants;
import org.eclipse.rse.persistence.dom.RSEDOM; import org.eclipse.rse.persistence.dom.RSEDOM;
import org.eclipse.rse.persistence.dom.RSEDOMNode; import org.eclipse.rse.persistence.dom.RSEDOMNode;
import org.eclipse.rse.persistence.dom.RSEDOMNodeAttribute; import org.eclipse.rse.persistence.dom.RSEDOMNodeAttribute;
public class RSEDOMImporter implements IRSEDOMImporter { public class RSEDOMImporter {
private static RSEDOMImporter _instance = new RSEDOMImporter(); private static RSEDOMImporter _instance = new RSEDOMImporter();
private ISystemRegistry _registry; private ISystemRegistry _registry;
@ -63,20 +63,17 @@ public class RSEDOMImporter implements IRSEDOMImporter {
/** /**
* Restores the profile represented by dom * Restores the profile represented by dom
* @param profileManager
* @param dom * @param dom
* @return the restored profile * @return the restored profile
*/ */
public ISystemProfile restoreProfile(ISystemProfileManager profileManager, RSEDOM dom) { public ISystemProfile restoreProfile(RSEDOM dom) {
// create the profile
String profileName = dom.getName(); String profileName = dom.getName();
boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue()); boolean defaultPrivate = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_DEFAULT_PRIVATE).getValue());
boolean isActive = getBooleanValue(dom.getAttribute(IRSEDOMConstants.ATTRIBUTE_IS_ACTIVE).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) { if (profile != null) {
profile.setDefaultPrivate(defaultPrivate); profile.setDefaultPrivate(defaultPrivate);
profileManager.makeSystemProfileActive(profile, isActive); SystemProfileManager.getDefault().addSystemProfile(profile);
// restore the children for the profile // restore the children for the profile
RSEDOMNode[] children = dom.getChildren(); RSEDOMNode[] children = dom.getChildren();
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
@ -130,7 +127,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
restorePropertySet(host, child); restorePropertySet(host, child);
} }
} }
return host; return host;
} }
@ -194,7 +190,7 @@ public class RSEDOMImporter implements IRSEDOMImporter {
} }
public IServerLauncherProperties restoreServerLauncher(IConnectorService service, RSEDOMNode serverLauncherNode, IServerLauncherProperties sl) { 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); RSEDOMNode[] psChildren = serverLauncherNode.getChildren(IRSEDOMConstants.TYPE_PROPERTY_SET);
for (int p = 0; p < psChildren.length; p++) { for (int p = 0; p < psChildren.length; p++) {
RSEDOMNode psChild = psChildren[p]; RSEDOMNode psChild = psChildren[p];
@ -243,7 +239,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
subSystem.setSubSystemConfiguration(factory); subSystem.setSubSystemConfiguration(factory);
subSystem.setName(factory.getName()); subSystem.setName(factory.getName());
subSystem.setConfigurationId(factory.getId()); subSystem.setConfigurationId(factory.getId());
subSystem.setWasRestored(true);
if (factory.supportsFilters()) { if (factory.supportsFilters()) {
ISystemFilterStartHere startHere = _registry.getSystemFilterStartHere(); ISystemFilterStartHere startHere = _registry.getSystemFilterStartHere();
@ -267,6 +262,7 @@ public class RSEDOMImporter implements IRSEDOMImporter {
restorePropertySet(subSystem, psChild); restorePropertySet(subSystem, psChild);
} }
} }
subSystem.wasRestored();
return subSystem; return subSystem;
} }
@ -304,10 +300,6 @@ public class RSEDOMImporter implements IRSEDOMImporter {
// create the filter // create the filter
ISystemFilter filter = filterPool.createSystemFilter(name, filterStrings); ISystemFilter filter = filterPool.createSystemFilter(name, filterStrings);
filter.setWasRestored(true);
// set filter attributes
filter.setSupportsNestedFilters(supportsNestedFilters); filter.setSupportsNestedFilters(supportsNestedFilters);
filter.setRelativeOrder(relativeOrder); filter.setRelativeOrder(relativeOrder);
filter.setDefault(isDefault); filter.setDefault(isDefault);
@ -361,26 +353,21 @@ public class RSEDOMImporter implements IRSEDOMImporter {
filterPool = mgr.getSystemFilterPool(name); filterPool = mgr.getSystemFilterPool(name);
} }
if (filterPool == null) { if (filterPool == null) {
filterPool = _registry.getSystemFilterPool().createSystemFilterPool(name, supportsNestedFilters, isDeletable, ISystemFilterConstants.TRY_TO_RESTORE_NO); filterPool = mgr.createSystemFilterPool(name, isDeletable);
// filterPool = new SystemFilterPool(name, supportsNestedFilters, isDeletable);
if (filterPool != null) { // filterPool.setSystemFilterPoolManager(mgr);
filterPool.setSystemFilterPoolManager(mgr); // mgr.getPools().add(filterPool);
// 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.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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -407,26 +394,15 @@ public class RSEDOMImporter implements IRSEDOMImporter {
*/ */
public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) { public ISystemFilterPoolReference restoreFilterPoolReference(ISubSystem subsystem, RSEDOMNode node) {
ISystemFilterPoolReference filterPoolReference = null; ISystemFilterPoolReference filterPoolReference = null;
String subsystemName = node.getAttribute(IRSEDOMConstants.ATTRIBUTE_REF_ID).getValue();
String filterPoolName = node.getName(); String filterPoolName = node.getName();
ISubSystemConfiguration configuration = getSubSystemConfiguration(subsystemName); String[] part = filterPoolName.split("___", 2); //$NON-NLS-1$
if (configuration != null) { 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(); // DWD are there cases where this may be null? ISystemProfile profile = subsystem.getSystemProfile();
ISystemFilterPoolManager filterPoolManager = configuration.getFilterPoolManager(profile); String profileName = profile.getName();
ISystemFilterPool filterPool = filterPoolManager.getSystemFilterPool(filterPoolName); filterPoolName = profileName + "___" + filterPoolName; //$NON-NLS-1$
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);
}
} }
ISystemFilterPoolReferenceManager referenceManager = subsystem.getFilterPoolReferenceManager();
filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPoolName);
return filterPoolReference; return filterPoolReference;
} }

View file

@ -16,84 +16,89 @@
package org.eclipse.rse.persistence; 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.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.logging.Logger;
public interface IRSEPersistenceManager { public interface IRSEPersistenceManager {
public boolean commit(ISystemFilterPoolManager filterPoolManager);
/** /**
* Save all connections in the connection pool * Save a particular profile. If the profile has an existing persistence provider
* @param connectionPool * 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 * @return true if successful
*/ */
public boolean commit(ISystemHostPool connectionPool); public boolean commitProfile(ISystemProfile profile);
/** /**
* Save this profile * Save all profiles.
* @param profile
* @return true if successful * @return true if successful
*/ */
public boolean commit(ISystemProfile profile); public boolean commitProfiles();
/** /**
* Save all profiles * Restore all profiles
* @param profileManager * @return an array of restored profiles.
* @return true if successful
*/ */
public boolean commit(ISystemProfileManager profileManager); 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 ISystemProfile restoreProfile(IRSEPersistenceProvider provider, String profileName);
/** /**
* Delete the persistent form of a profile. * 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 * @param profileName The name of the profile to delete
*/ */
public void deleteProfile(String profileName); public void deleteProfile(IRSEPersistenceProvider persistenceProvider, String profileName);
public boolean isExporting(); /**
* Migrates a profile to a new persistence provider. It will delete the persistent form known to its previous
public boolean isImporting(); * 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. * Register the persistence provider to be used when saving and restoring RSE doms.
* The provider is registered under the provided id. * 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 id the provider id.
* @param provider the provider. * @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 * @return an array of persistence provider ids known to this workbench. These may have been
* @param filterPool * provided by extension point or by registering them using
* @return true if sucessful * {@link #registerPersistenceProvider(String, IRSEPersistenceProvider)}
*/ */
public boolean restore(ISystemFilterPool filterPool); public String[] getPersistenceProviderIds();
/** /**
* Restore all connections in the connection pool * Retrieves the persistence provider named by a particular id. It can return null if there
* @param connectionPool * is no provider known by that id. This may have the effect of activating the plugin that
* @return true if successful * 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 * @return true if this instance of the persistence manager is currently exporting a profile.
* @param profileManager
* @return true if successful
*/ */
public boolean restore(ISystemProfileManager profileManager); public boolean isExporting();
/** /**
* Restore the filter pool * @return true if this instance of the persistence manager is currently importing a profile.
* @param name
* @return the filter pool if successful
*/ */
public ISystemFilterPool restoreFilterPool(String name); public boolean isImporting();
public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name);
} }

View file

@ -21,10 +21,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RSEDOMNode implements Serializable { 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; // This should be updated if there is a schema change.
*/
private static final long serialVersionUID = 1L;
protected String _type; protected String _type;
protected String _name; protected String _name;
protected RSEDOMNode _parent; protected RSEDOMNode _parent;
@ -220,4 +218,12 @@ public class RSEDOMNode implements Serializable {
this.restoring = restoring; this.restoring = restoring;
} }
public void setName(String name) {
_name = name;
}
public void setType(String type) {
_type = type;
}
} }

View file

@ -17,13 +17,12 @@
package org.eclipse.rse.internal.ui; package org.eclipse.rse.internal.ui;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.model.SystemProfileManager;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.messages.ISystemMessageLine; import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator; import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorFactory;
import org.eclipse.rse.ui.validators.ValidatorProfileName; import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -79,10 +78,7 @@ public class SystemProfileForm
this.showVerbiage = showVerbiage; this.showVerbiage = showVerbiage;
callerInstanceOfWizardPage = (caller instanceof WizardPage); callerInstanceOfWizardPage = (caller instanceof WizardPage);
callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog); callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
nameValidator = ValidatorFactory.getProfileNameValidator(profile.getName());
// 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(profile);
} }
/** /**

View file

@ -18,7 +18,7 @@ package org.eclipse.rse.internal.ui.actions;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; 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.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction; import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -38,7 +38,7 @@ public class SystemProfileNameSelectAction extends SystemBaseAction
{ {
super(profile.getName(),parent); super(profile.getName(),parent);
this.profile = profile; this.profile = profile;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager mgr = SystemProfileManager.getDefault();
setChecked(mgr.isSystemProfileActive(profile.getName())); setChecked(mgr.isSystemProfileActive(profile.getName()));
setSelectionSensitive(false); setSelectionSensitive(false);

View file

@ -18,7 +18,6 @@ package org.eclipse.rse.internal.ui.dialogs;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; 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.internal.ui.SystemResources;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -27,6 +26,7 @@ import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement; import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
import org.eclipse.rse.ui.messages.ISystemMessageLine; import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.validators.ISystemValidator; import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorFactory;
import org.eclipse.rse.ui.validators.ValidatorProfileName; import org.eclipse.rse.ui.validators.ValidatorProfileName;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -71,10 +71,7 @@ public class SystemCopyProfileDialog extends SystemPromptDialog
{ {
setInputObject(profile); setInputObject(profile);
} }
nameValidator = ValidatorFactory.getProfileNameValidator((String)null);
// 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);
//pack(); //pack();
setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); //$NON-NLS-1$ setHelp(RSEUIPlugin.HELPPREFIX+"drnp0000"); //$NON-NLS-1$
} }

View file

@ -531,7 +531,7 @@ public class SystemViewConnectionAdapter
IHost conn = (IHost)propertySourceInput; IHost conn = (IHost)propertySourceInput;
if (name.equals(ISystemPropertyConstants.P_SYSTEMTYPE)) if (name.equals(ISystemPropertyConstants.P_SYSTEMTYPE))
return conn.getSystemType().getName(); return conn.getSystemType().getLabel();
else if (name.equals(ISystemPropertyConstants.P_HOSTNAME)) else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
return conn.getHostName(); return conn.getHostName();
else if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID)) else if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))

View file

@ -25,6 +25,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.SystemAdapterHelpers; import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager; 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.ISystemFilterPoolReference;
import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider; import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
@ -89,7 +90,7 @@ public class SystemViewFilterPoolReferenceAdapter
menu.add(menuGroup, action); 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) if (actions != null)
{ {
//menu.addSeparator(); //menu.addSeparator();
@ -112,35 +113,35 @@ public class SystemViewFilterPoolReferenceAdapter
*/ */
public ISubSystem getSubSystem(Object element) 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. * Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired * @param element The element for which an image is desired
*/ */
public ImageDescriptor getImageDescriptor(Object element) public ImageDescriptor getImageDescriptor(Object element) {
{ ImageDescriptor poolImage = null;
ImageDescriptor poolImage = null; ISystemFilterPool pool = getFilterPool(element);
ISystemFilterPool pool = getFilterPool(element); if (pool != null) {
if (pool.getProvider() != null) ISystemFilterPoolManagerProvider provider = pool.getProvider();
{ if (provider != null) {
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)pool.getProvider().getAdapter(ISubSystemConfigurationAdapter.class); ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) provider.getAdapter(ISubSystemConfigurationAdapter.class);
poolImage = adapter.getSystemFilterPoolImage(pool); poolImage = adapter.getSystemFilterPoolImage(pool);
} }
if (poolImage == null) }
poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID); if (poolImage == null) {
return poolImage; poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
} }
return poolImage;
private ISystemFilterPoolReference getFilterPoolReference(Object element)
{
return (ISystemFilterPoolReference)element; // get referenced object
} }
private ISystemFilterPool getFilterPool(Object element) 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 @@ public class SystemViewFilterPoolReferenceAdapter
* @return the label for this filter pool reference. * @return the label for this filter pool reference.
*/ */
public String getText(Object element) { 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); ISystemFilterPool pool = getFilterPool(element);
if (pool != null) { if (pool != null) {
result = pool.getName(); result = pool.getName();
// the following looks like it was copied from the host adapter and not really needed here.
// boolean qualifyNames = RSEUIPlugin.getTheSystemRegistry().getQualifiedHostNames();
// if (qualifyNames) {
// String prefix = SubSystemHelpers.getParentSystemProfile(pool).getName();
// result = prefix + "." + result;
// }
} }
return result; return result;
} }
@ -178,13 +174,14 @@ public class SystemViewFilterPoolReferenceAdapter
public String getAbsoluteName(Object element) 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 //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(); ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider();
ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem); ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem);
String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$ String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$
return parentAbsoluteName + "." + //$NON-NLS-1$ String referenceName = filterPoolRef.getName();
filterPoolRef.getReferencedFilterPool().getSystemFilterPoolManager().getName() + "." + //$NON-NLS-1$ String managerName = filterPoolRef.getReferencedFilterPoolManagerName();
filterPoolRef.getName(); String absoluteName = parentAbsoluteName + "." + managerName + "." + referenceName; //$NON-NLS-1$ //$NON-NLS-2$
return absoluteName;
} }
/** /**
@ -202,7 +199,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/ */
public Object getParent(Object element) public Object getParent(Object element)
{ {
ISystemFilterPoolReference fpr = getFilterPoolReference(element); ISystemFilterPoolReference fpr = (ISystemFilterPoolReference)element;
return SubSystemHelpers.getParentSubSystem(fpr); return SubSystemHelpers.getParentSubSystem(fpr);
} }
@ -212,7 +209,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/ */
public Object[] getChildren(IProgressMonitor monitor, IAdaptable element) public Object[] getChildren(IProgressMonitor monitor, IAdaptable element)
{ {
ISystemFilterPoolReference fpRef = getFilterPoolReference(element); ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
ISubSystem ss = getSubSystem(element); ISubSystem ss = getSubSystem(element);
return fpRef.getSystemFilterReferences(ss); return fpRef.getSystemFilterReferences(ss);
} }
@ -222,7 +219,7 @@ public class SystemViewFilterPoolReferenceAdapter
*/ */
public boolean hasChildren(IAdaptable element) { public boolean hasChildren(IAdaptable element) {
int count = 0; int count = 0;
ISystemFilterPoolReference fpRef = getFilterPoolReference(element); ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
if (fpRef != null) { if (fpRef != null) {
ISystemFilterPool filterPool = fpRef.getReferencedFilterPool(); ISystemFilterPool filterPool = fpRef.getReferencedFilterPool();
if (filterPool != null) { if (filterPool != null) {

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; 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.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
@ -61,7 +61,7 @@ public class SystemTeamViewActiveProfileAction extends SystemBaseAction
ISystemProfile profile = (ISystemProfile)getFirstSelection(); ISystemProfile profile = (ISystemProfile)getFirstSelection();
if (profile == null) if (profile == null)
return false; return false;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager mgr = SystemProfileManager.getDefault();
// todo... we need to have two actions, one to make active, and one to make inactive. // todo... we need to have two actions, one to make active, and one to make inactive.
while (profile != null) while (profile != null)
{ {

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; 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.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
@ -60,7 +60,7 @@ public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
if (!(currsel instanceof ISystemProfile)) if (!(currsel instanceof ISystemProfile))
return false; return false;
ISystemProfile profile = (ISystemProfile)currsel; ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allActive = true; boolean allActive = true;
while (profile != null) while (profile != null)
{ {

View file

@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; 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.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
@ -60,7 +60,7 @@ public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
if (!(currsel instanceof ISystemProfile)) if (!(currsel instanceof ISystemProfile))
return false; return false;
ISystemProfile profile = (ISystemProfile)currsel; ISystemProfile profile = (ISystemProfile)currsel;
ISystemProfileManager mgr = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager mgr = SystemProfileManager.getDefault();
boolean allInActive = true; boolean allInActive = true;
while (profile != null) while (profile != null)
{ {

View file

@ -16,11 +16,13 @@
package org.eclipse.rse.internal.ui.view.team; package org.eclipse.rse.internal.ui.view.team;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
@ -371,7 +373,9 @@ public class SystemTeamViewProfileAdapter
*/ */
public ISystemValidator getNameValidator(Object element) public ISystemValidator getNameValidator(Object element)
{ {
return new ValidatorProfileName(RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfileNamesVector()); Vector names = RSECorePlugin.getDefault().getSystemRegistry().getSystemProfileManager().getSystemProfileNamesVector();
ISystemValidator validator = new ValidatorProfileName(names);
return validator;
} }
/** /**
* Parent override. * Parent override.

View file

@ -44,9 +44,9 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; 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.SubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxyComparator; 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.RSESystemTypeAdapterFactory;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemDynamicPopupMenuExtensionManager; import org.eclipse.rse.internal.ui.actions.SystemDynamicPopupMenuExtensionManager;
@ -114,7 +114,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
if (systemType != null) { if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class)); RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class));
if (adapter != null && adapter.isEnabled(systemType)) { if (adapter != null && adapter.isEnabled(systemType)) {
ISystemProfileManager profileManager = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager profileManager = SystemProfileManager.getDefault();
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile(); ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
String userName = System.getProperty("user.name"); //$NON-NLS-1$ String userName = System.getProperty("user.name"); //$NON-NLS-1$
registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName); registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName);
@ -761,7 +761,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
*/ */
public static ISystemProfileManager getTheSystemProfileManager() public static ISystemProfileManager getTheSystemProfileManager()
{ {
return SystemProfileManager.getSystemProfileManager(); return SystemProfileManager.getDefault();
} }
/** /**

View file

@ -23,7 +23,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; 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.internal.ui.SystemResources;
import org.eclipse.rse.model.SystemRegistry; import org.eclipse.rse.model.SystemRegistry;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
@ -87,7 +87,7 @@ public abstract class SystemBaseCopyAction extends SystemBaseDialogAction
: RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MOVE_ID)), : RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_MOVE_ID)),
parent); parent);
this.mode = mode; this.mode = mode;
mgr = SystemProfileManager.getSystemProfileManager(); mgr = SystemProfileManager.getDefault();
sr = RSEUIPlugin.getTheSystemRegistry(); sr = RSEUIPlugin.getTheSystemRegistry();
allowOnMultipleSelection(true); allowOnMultipleSelection(true);
setProcessAllSelections(true); setProcessAllSelections(true);

View file

@ -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;
}
}

View file

@ -124,21 +124,14 @@ public class ValidatorUniqueString
/** /**
* Reset the existing names list. * Reset the existing names list.
*/ */
public void setExistingNamesList(Vector existingList) public void setExistingNamesList(Vector newList)
{ {
if (existingList == null) if (newList == null)
this.existingList = null; existingList = null;
else else
{ {
String newList[] = new String[existingList.size()]; existingList = new String[newList.size()];
for (int idx=0; idx<existingList.size(); idx++) newList.toArray(existingList);
{
if (!caseSensitive)
newList[idx] = existingList.elementAt(idx).toString().toLowerCase();
else
newList[idx] = existingList.elementAt(idx).toString();
}
init(newList, true); // don't redo the toLowerCase calls
} }
} }
/** /**

View file

@ -34,6 +34,7 @@ import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.internal.core.model.RSEModelResources; import org.eclipse.rse.internal.core.model.RSEModelResources;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.ui.RSESystemTypeAdapter; import org.eclipse.rse.ui.RSESystemTypeAdapter;
@ -102,7 +103,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
*/ */
public ISystemProfile getSystemProfile() public ISystemProfile getSystemProfile()
{ {
return SystemProfileManager.getSystemProfileManager().getSystemProfile(getName()); return SystemProfileManager.getDefault().getSystemProfile(getName());
} }
/** /**
@ -408,7 +409,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
conn.deletingHost(); // let connection do any necessary cleanup conn.deletingHost(); // let connection do any necessary cleanup
getHostList().remove(conn); getHostList().remove(conn);
setDirty(true); setDirty(true);
RSECorePlugin.getThePersistenceManager().commit(conn.getSystemProfile()); conn.getSystemProfile().commit();
} }
/** /**
@ -648,7 +649,9 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
*/ */
public boolean commit() public boolean commit()
{ {
return RSECorePlugin.getThePersistenceManager().commit(this); ISystemProfile profile = getSystemProfile();
boolean result = profile.commit();
return result;
} }
/** /**

View file

@ -35,11 +35,9 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.IRSEUserIdConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemAdapterHelpers; import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.filters.ISystemFilter; 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.ISystemFilterPoolReferenceManager;
import org.eclipse.rse.core.filters.ISystemFilterReference; import org.eclipse.rse.core.filters.ISystemFilterReference;
import org.eclipse.rse.core.filters.ISystemFilterStartHere; import org.eclipse.rse.core.filters.ISystemFilterStartHere;
@ -66,14 +64,13 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; 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.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.model.SystemHostPool; import org.eclipse.rse.internal.model.SystemHostPool;
import org.eclipse.rse.internal.model.SystemModelChangeEvent; import org.eclipse.rse.internal.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.model.SystemModelChangeEventManager; import org.eclipse.rse.internal.model.SystemModelChangeEventManager;
import org.eclipse.rse.internal.model.SystemPostableEventNotifier; import org.eclipse.rse.internal.model.SystemPostableEventNotifier;
import org.eclipse.rse.internal.model.SystemPreferenceChangeManager; 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.SystemRemoteChangeEventManager;
import org.eclipse.rse.internal.model.SystemResourceChangeManager; import org.eclipse.rse.internal.model.SystemResourceChangeManager;
import org.eclipse.rse.internal.model.SystemScratchpad; import org.eclipse.rse.internal.model.SystemScratchpad;
@ -764,7 +761,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/ */
public ISystemProfileManager getSystemProfileManager() public ISystemProfileManager getSystemProfileManager()
{ {
return SystemProfileManager.getSystemProfileManager(); return SystemProfileManager.getDefault();
} }
/** /**
@ -795,12 +792,14 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
{ {
return getSystemProfileManager().getSystemProfileNames(); return getSystemProfileManager().getSystemProfileNames();
} }
/** /**
* Return all defined profile names as a vector * Return all defined profile names as a vector
*/ */
public Vector getAllSystemProfileNamesVector() public Vector getAllSystemProfileNamesVector()
{ {
return getSystemProfileManager().getSystemProfileNamesVector(); Vector v = getSystemProfileManager().getSystemProfileNamesVector();
return v;
} }
/** /**
@ -2842,8 +2841,6 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/ */
public void disconnectAllSubSystems(IHost conn) public void disconnectAllSubSystems(IHost conn)
{ {
// FIXME - save profile
save();
ISubSystem[] subsystems = getSubSystemsLazily(conn); ISubSystem[] subsystems = getSubSystemsLazily(conn);
if (subsystems == null) if (subsystems == null)
@ -3346,8 +3343,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/ */
public boolean save() public boolean save()
{ {
ISystemProfileManager profileManager = getSystemProfileManager(); return RSEUIPlugin.getThePersistenceManager().commitProfiles();
return RSEUIPlugin.getThePersistenceManager().commit(profileManager);
} }
/** /**
@ -3356,7 +3352,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
*/ */
public boolean saveHostPool(ISystemHostPool pool) public boolean saveHostPool(ISystemHostPool pool)
{ {
return RSEUIPlugin.getThePersistenceManager().commit(pool); return pool.commit();
} }
/** /**
@ -3414,9 +3410,4 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
return SystemFilterStartHere.getDefault(); return SystemFilterStartHere.getDefault();
} }
public ISystemFilterPool getSystemFilterPool()
{
return SystemFilterPool.getDefault();
}
}//SystemRegistryImpl }//SystemRegistryImpl

View file

@ -21,7 +21,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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; import org.eclipse.rse.ui.RSEUIPlugin;
@ -161,7 +161,7 @@ public class SystemStartHere
*/ */
public static ISystemProfileManager getSystemProfileManager() public static ISystemProfileManager getSystemProfileManager()
{ {
return SystemProfileManager.getSystemProfileManager(); return SystemProfileManager.getDefault();
} }
/** /**

View file

@ -20,6 +20,9 @@
package org.eclipse.rse.core.subsystems; package org.eclipse.rse.core.subsystems;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -3249,8 +3252,14 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
} }
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
List children = new ArrayList(10);
ISystemFilterPoolReferenceManager manager = getSystemFilterPoolReferenceManager(); ISystemFilterPoolReferenceManager manager = getSystemFilterPoolReferenceManager();
IRSEPersistableContainer[] result = manager.getReferencedSystemFilterPools(); if (manager != null) {
children.addAll(Arrays.asList(manager.getSystemFilterPoolReferences()));
}
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result; return result;
} }

View file

@ -55,7 +55,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.references.IRSEBaseReferencingObject; import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
import org.eclipse.rse.internal.core.filters.SystemFilterPoolWrapperInformation; import org.eclipse.rse.internal.core.filters.SystemFilterPoolWrapperInformation;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere; import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.model.SystemProfileManager; import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemPropertyResources; import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter; import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter;
@ -773,7 +773,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
*/ */
public ISystemProfile getSystemProfile(String name) public ISystemProfile getSystemProfile(String name)
{ {
return SystemProfileManager.getSystemProfileManager().getSystemProfile(name); return SystemProfileManager.getDefault().getSystemProfile(name);
} }
/** /**
@ -1001,8 +1001,8 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
} }
if ((subsystems == null) || (subsystems.length != getSubSystemList().size())) if ((subsystems == null) || (subsystems.length != getSubSystemList().size()))
{ {
java.util.List alist = null; List alist = null;
if (SystemProfileManager.getSystemProfileManager().getSystemProfileNamesVector().size() > 0) // 42913 if (SystemProfileManager.getDefault().getSize() > 0) // 42913
alist = getSubSystemList(); alist = getSubSystemList();
if (alist == null) if (alist == null)
return new ISubSystem[0]; return new ISubSystem[0];
@ -1803,12 +1803,9 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
*/ */
protected boolean isUserPrivateProfile(ISystemFilterPoolManager mgr) protected boolean isUserPrivateProfile(ISystemFilterPoolManager mgr)
{ {
//System.out.println("mgr name = " + mgr.getName()); ISystemProfile profile = mgr.getSystemProfile();
//String name = mgr.getName(); boolean result = profile.isDefaultPrivate() || mgr.getName().equalsIgnoreCase("private"); //$NON-NLS-1$
//return name.equalsIgnoreCase("private"); return result;
ISystemProfile profile = getSystemProfile(mgr);
//System.out.println("Testing for user private profile for mgr " + mgr.getName() + ": " + profile.isDefaultPrivate());;
return profile.isDefaultPrivate() || mgr.getName().equalsIgnoreCase("private"); //$NON-NLS-1$
} }
/** /**
@ -2538,7 +2535,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
public ISubSystem[] testForActiveReferences(ISystemProfile profile) public ISubSystem[] testForActiveReferences(ISystemProfile profile)
{ {
Vector v = new Vector(); Vector v = new Vector();
ISystemProfileManager profileMgr = SystemProfileManager.getSystemProfileManager(); ISystemProfileManager profileMgr = SystemProfileManager.getDefault();
ISystemFilterPoolManager sfpm = getFilterPoolManager(profile); ISystemFilterPoolManager sfpm = getFilterPoolManager(profile);
String profileName = profile.getName(); String profileName = profile.getName();
if (sfpm != null) if (sfpm != null)
@ -3022,7 +3019,6 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
if (filterPoolManagerList == null) if (filterPoolManagerList == null)
{ {
filterPoolManagerList = new ArrayList(); filterPoolManagerList = new ArrayList();
//FIXMEnew EObjectContainmenteList(SystemFilterPoolManager.class, this, SubsystemsPackage.SUB_SYSTEM_FACTORY__FILTER_POOL_MANAGER_LIST);
} }
return filterPoolManagerList; return filterPoolManagerList;
} }
@ -3080,6 +3076,12 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
{ {
} }
public void beginRestore() {
}
public void endRestore() {
}
/** /**
* Subsystem configurations are not persisted. * Subsystem configurations are not persisted.
* @return null * @return null
@ -3088,12 +3090,6 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
return null; return null;
} }
public void beginRestore() {
}
public void endRestore() {
}
public IRSEPersistableContainer[] getPersistableChildren() { public IRSEPersistableContainer[] getPersistableChildren() {
return new IRSEPersistableContainer[0]; return new IRSEPersistableContainer[0];
} }