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

[197036] - filter pools are now created only for the subsystem configurations used during connection creation

ASSIGNED - bug 197036: All Filter Pools created on Clean Workspace
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197036
This commit is contained in:
David Dykstal 2008-02-05 18:33:54 +00:00
parent 3f705b5db7
commit 1464adb94f
26 changed files with 1008 additions and 953 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others.
* Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,7 +12,8 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David Dykstal (IBM) - [197036] All filter pools created on clean workspace
* cleaned javadoc for renameSystemFilterPool
*******************************************************************************/
package org.eclipse.rse.core.filters;
@ -237,19 +238,13 @@ public interface ISystemFilterPoolManager extends IRSEPersistableContainer {
public boolean preTestRenameFilterPool(ISystemFilterPool pool) throws Exception;
/**
* Rename a given filter pool. Dependending on the save policy, the
* appropriate file or folder on disk will also be renamed.
* <p>
* Does the following:
* Rename a filter pool.
* <ul>
* <li>Renames referencing objects
* <li>Renames pool object in the in-memory model
* <li>Renames folder on disk for policies of one folder per pool
* <li>Renames file on disk for policy of one file per pool
* <li>Saves model to disk for policy of one file per manager
* <li>Invalidates in-memory caches
* <li>Renames pool object
* <li>Informs any filter pool references to this pool
* <li>Schedules a save of the pool object
* </ul>
* @param pool The filter pool object to physically rename
* @param pool The filter pool object to rename
* @param newName The new name to give the pool
*/
public void renameSystemFilterPool(ISystemFilterPool pool, String newName) throws Exception;

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe
* David Dykstal (IBM) - [197036] cleaned javddoc for getConnectorServices()
********************************************************************************/
package org.eclipse.rse.core.model;
@ -261,8 +262,7 @@ public interface IHost extends IAdaptable, IRSEModelObject {
void setOffline(boolean value);
/**
* Returns all the connector services provided
* for this host
* Returns all the connector services currently configured for this host
* @return the connector services
*/
IConnectorService[] getConnectorServices();

View file

@ -13,11 +13,12 @@
* Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* David Dykstal (IBM) - [197036] removed createHost() shortcut (should use ISystemRegistry),
* cleaned javadoc for getFilterPools()
********************************************************************************/
package org.eclipse.rse.core.model;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -46,12 +47,6 @@ public interface ISystemProfile extends IRSEModelObject {
*/
public ISystemProfileManager getProfileManager();
/**
* Convenience method for create a new connection within this profile.
* Shortcut for {@link ISystemRegistry#createHost(IRSESystemType,String,String,String)}
*/
public IHost createHost(IRSESystemType systemType, String connectionName, String hostName, String description) throws Exception;
/**
* @return The value of the Name attribute
*/
@ -81,7 +76,7 @@ public interface ISystemProfile extends IRSEModelObject {
public IHost[] getHosts();
/**
* Return all filter pools for this profile
* @return all existing filter pools for this profile.
*/
public ISystemFilterPool[] getFilterPools();

View file

@ -11,11 +11,13 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David Dykstal (IBM) - [197036] added commitSystemProfile operation to interface
********************************************************************************/
package org.eclipse.rse.core.model;
import org.eclipse.core.runtime.IStatus;
/**
* Manages a list of SystemProfile objects. System profiles
* should be created, deleted, restored, activated, and deactivated though
@ -108,6 +110,13 @@ public interface ISystemProfileManager {
* @return the new profile
*/
public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName);
/**
* Commit a system profile
* @param profile the profile to commit
* @return a status object indicating the result of the commit
*/
public IStatus commitSystemProfile(ISystemProfile profile);
/**
* Get an indication of whether a profile is active or not.

View file

@ -20,6 +20,8 @@
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
* David McKnight (IBM) - [207100] adding ISystemRegistry.isRegisteredSystemRemoteChangeListener
* David Dykstal (IBM) - [197036] adding new createHost and getSubSystemConfigurationsBySYstemType which
* are able to delay the creation of subsystems.
********************************************************************************/
package org.eclipse.rse.core.model;
@ -99,11 +101,26 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
/**
* Return all subsystem configurations which support the given system type.
* If the type is null, returns all.
* If the type is null, returns all subsystem confgurations.
* Fully equivalent to getSubSystemConfigurationsBySystemType(systemType, filterDuplicates, <code>true</code>)
* which is preferred since we do not want to load subsystem configurations unless necessary.
* @param systemType system type to filter
* @param filterDuplicateServiceSubSystemConfigurations set false by default
* @param filterDuplicates if true and the subsystem configuration uses services then return only one
* subsystem configuration that supports this service. Which configuration is returned is undefined.
* @return an array of subsystem configurations meeting the criteria
*/
public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemConfigurations);
public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicates);
/**
* Return all subsystem configurations which support the given system type.
* If the type is null, returns all subsystem confgurations.
* @param systemType system type to filter
* @param filterDuplicates if true and the subsystem configuration uses services then return only one
* subsystem configuration that supports this service. Which configuration is returned is undefined.
* @param activate if true activate the respective configurations if not already active, if false return only those that are already active.
* @return an array of subsystem configurations meeting the criteria
*/
public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicates, boolean activate);
// ----------------------------------
// SYSTEMVIEWINPUTPROVIDER METHODS...
@ -211,59 +228,52 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
public void setSystemProfileActive(ISystemProfile profile, boolean makeActive);
/**
* Return the list of connector services provided for the given host
* @param conn the host
* Return the list of connector services currently configured for the given host
* @param host the host
* @return the list of connector services
*/
public IConnectorService[] getConnectorServices(IHost conn);
public IConnectorService[] getConnectorServices(IHost host);
// ----------------------------
// SUBSYSTEM METHODS...
// ----------------------------
/**
* Return list of subsystem objects for a given connection. If the subsystems have
* not all been read into memory, this loads them up
* Return list of subsystem objects for a given host.
* @param host the host for which to return the subsystems that are currently known.
* @return an array of subsystem objects known to this host.
*/
public ISubSystem[] getSubSystems(IHost conn);
public ISubSystem[] getSubSystems(IHost host);
/**
* Return list of subsystem objects for a given connection. Use the force
* flag to indicate whether or not to restore from disk
* Return list of subsystem objects for a given connection.
* @param host the host for which to return the subsystems that are known.
* @param force if true, force the creation of subsystems for which the system type of this host is configured.
* Use this parameter with care since it can cause extensive initialization.
* @return the list of subsystems known to this host, possibly after the creation of subsystems.
* @deprecated Use {@link #getSubSystems(IHost)} instead, the "force" parameter is now ignored.
*/
public ISubSystem[] getSubSystems(IHost conn, boolean force);
public ISubSystem[] getSubSystems(IHost host, boolean force);
/**
* Get those subsystems that are registered against a given connection,
* which are an instance of the given interface class.
* <p>
* This method activates all subsystem configurations of the given
* host in order to support checking against the given interface.
* If lazy loading is desired, use {@link #getSubSystems(IHost, boolean)}
* with a boolean parameter <code>false</code> instead, and check against
* the class instance in client code.
* </p>
* @param connection the connection to check
* @param host the connection to check
* @param subsystemInterface the interface class to filter against
* @return list of matching subsystems
*/
public ISubSystem[] getSubsystems(IHost connection, Class subsystemInterface);
public ISubSystem[] getSubsystems(IHost host, Class subsystemInterface);
/**
* Get those subsystems that are registered against a given connection,
* which are an instance of ServiceSubSystem for the given serviceType.
* <p>
* This method activates all subsystem configurations of the given
* host in order to support checking against the given interface.
* If lazy loading is desired, use {@link #getSubSystems(IHost, boolean)}
* with a boolean parameter <code>false</code> instead, and check against
* the class instance in client code.
* </p>
* @param connection the connection to check
* @param host the host to check
* @param serviceType the class of service to ask for
* @return list of matching subsystems
*/
public ISubSystem[] getServiceSubSystems(IHost connection, Class serviceType);
public ISubSystem[] getServiceSubSystems(IHost host, Class serviceType);
/**
* Resolve a subsystem from it's absolute name
@ -283,10 +293,10 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
/**
* Return the absolute name for the specified host (connection)
* @param connection the host (aka connection) object to query
* @param host the host (aka connection) object to query
* @return the absolute name of the host
*/
public String getAbsoluteNameForConnection(IHost connection);
public String getAbsoluteNameForConnection(IHost host);
/**
* Get a list of subsystem objects for given connection, owned by a subsystem factory
@ -301,7 +311,7 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
* that are really needed. Then, use {@link ISubSystemConfiguration#getSubSystems(boolean)}
* with a parameter true.
*/
public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost connection);
public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost host);
/**
* Delete a subsystem object. This code finds the factory that owns it and
@ -507,6 +517,26 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
public IHost createHost(IRSESystemType systemType, String connectionName, String hostAddress, String description) throws Exception;
/**
* Create a host object. The resulting host object is added to the list of existing host objects
* in the specified profile.
* <ul>
* <li>creates and saves a new host within the given profile
* <li>optionally creates subsystem instances
* <li>fires an ISystemResourceChangeEvent event of type EVENT_ADD to all registered listeners
* </ul>
* <p>
* @param profileName Name of the system profile to which the host is to be added.
* @param systemType system type of the new host.
* @param hostName unique host name within the profile.
* @param hostAddress ip name of host.
* @param description optional description of the connection. May be null.
* @param createSubSystems <code>true</code> to create subsystems for the host, <code>false</code> otherwise.
* @return IHost object, or null if it failed to create. This is typically because the hostName is not unique. Call getLastException() if necessary.
* @since 3.0
*/
public IHost createHost(String profileName, IRSESystemType systemType, String hostName, String hostAddress, String description, boolean createSubSystems) throws Exception;
/**
* Update an existing host given the new information.
* This method:
* <ul>

View file

@ -12,13 +12,44 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David Dykstal (IBM) - [197036] added javadoc and canSwitchTo method.
*******************************************************************************/
package org.eclipse.rse.core.subsystems;
/**
* A service subsystem provides a common subsystem implementation defined on a
* service interface. The service itself may have various
* implementations determined by a subsystem configuration. A service subsystem
* may be asked to switch its subsystem configuration in order to switch the
* underlying service implementation.
*/
public interface IServiceSubSystem extends ISubSystem {
/**
* Returns the interface type (i.e. a Class object that is an Interface) of a service subsystem.
* @return the service interface on which this service subsystem is implemented. If this
* subsystem is not a service subsystem it must return null.
*/
public Class getServiceType();
public void switchServiceFactory(IServiceSubSystemConfiguration factory);
/**
* Requests a service subsystem to switch to a new configuration. If the configuration
* is compatible with this subsystem then it must disconnect, possibly reset its
* filter pool references, and request new services and parameters from its new configuration.
* It must also answer true to {@link #canSwitchTo(IServiceSubSystemConfiguration)}.
* If the configuration is not compatible with this subsystem then this must do nothing and must answer
* false to {@link #canSwitchTo(IServiceSubSystemConfiguration)}.
* @param configuration the configuration to which to switch.
*/
public void switchServiceFactory(IServiceSubSystemConfiguration configuration);
/**
* Determine is this subsystem is compatible with this specified configuration.
* @param configuration the configuration which may be switched to
* @return true if the subsystem can switch to this configuration, false otherwise.
* Subsystems which are not service subsystems must return false.
*/
public boolean canSwitchTo(IServiceSubSystemConfiguration configuration);
}

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core
* David Dykstal (IBM) - [197036] change signature of getFilterPoolManager method to be able to control the creation of filter pools
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -34,7 +35,7 @@ import org.eclipse.rse.core.model.ISystemProfile;
*
* <p>
* This interface is not intended to be implemented by clients. Subsystem
* configuration implementations must subclass {@link SubSystemConfiguration}
* configuration implementations must subclass SubSystemConfiguration
* rather than implementing this interface directly.
* </p>
*/
@ -351,11 +352,13 @@ public interface ISubSystemConfiguration extends ISystemFilterPoolManagerProvide
/**
* Called by SystemRegistry's renameSystemProfile method to ensure we update our
* subsystem names within each subsystem.
* <p>
* This is called AFTER changing the profile's name!!
* subsystem names within each subsystem.
* This should be invoked after changing the profile's name.
* @param subsystem the subsystem to be updated
* @param oldProfileName the old profile name
* @param newProfileName the new profile name
*/
public void renameSubSystemProfile(ISubSystem ss, String oldProfileName, String newProfileName);
public void renameSubSystemProfile(ISubSystem subsystem, String oldProfileName, String newProfileName);
/**
* Called by SystemRegistry's renameSystemProfile method to pre-test if we are going to run into errors on a
@ -488,7 +491,22 @@ public interface ISubSystemConfiguration extends ISystemFilterPoolManagerProvide
// FILTER POOL METHODS...
// ---------------------------------
/**
* Get the filter pool manager for the given profile
* A subsystem configuration has a filter pool manager for each profile.
* Get the filter pool manager for the given profile.
* @param profile The system profile for which to get the manager.
* @param force if true then create the default filters for this subsystem configuration in this profile. This should only be
* done during initial subsystem creation, not during subsystem restore.
* @return a filter pool manager
*/
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile, boolean force);
/**
* A subsystem configuration has a filter pool manager for each profile.
* Get the filter pool manager for the given profile.
* Do not force the creation of default filter pools.
* Fully equivalent to getFilterPoolManager(profile, false).
* @param profile The system profile for which to get the manager.
* @return a filter pool manager
*/
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile);

View file

@ -12,6 +12,7 @@
*
* Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework
* David Dykstal (IBM) - [197036] removed caching mechanism to clean up logic
********************************************************************************/
package org.eclipse.rse.internal.core.filters;
@ -57,10 +58,10 @@ import org.eclipse.rse.logging.Logger;
* This class is not intended to be subclassed by clients.
*/
public class SystemFilterPoolManager extends RSEPersistableObject implements ISystemFilterPoolManager {
private ISystemFilterPool[] poolArray = null; // cache for performance
// private ISystemFilterPool[] poolArray = null; // cache for performance
private ISystemFilterPoolManagerProvider caller = null;
private Object poolMgrData;
private Vector poolNames;
// private Vector poolNames;
private boolean initialized = false;
private boolean suspendCallbacks = false;
@ -152,7 +153,8 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
*/
protected boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT;
protected List pools = null;
protected List pools = new ArrayList(3);
// protected List pools = null;
/**
* Constructor
@ -210,7 +212,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
initialize(logger, caller, name); // core data
}
setSupportsNestedFilters(allowNestedFilters); // cascade it down
invalidatePoolCache();
// invalidatePoolCache();
// List pools = getPools();
// ISystemFilterPool pool = null;
// Vector poolNames = getSystemFilterPoolNamesVector();
@ -397,17 +399,20 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Return array of SystemFilterPools managed by this manager.
*/
public ISystemFilterPool[] getSystemFilterPools() {
//System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null));
if ((poolArray == null) || (getPools().size() != poolArray.length)) {
List pools = getPools();
poolArray = new ISystemFilterPool[pools.size()];
Iterator i = pools.iterator();
int idx = 0;
while (i.hasNext())
poolArray[idx++] = (ISystemFilterPool) i.next();
//System.out.println("Pool array created. length = "+poolArray.length);
}
return poolArray;
ISystemFilterPool[] result = new ISystemFilterPool[pools.size()];
pools.toArray(result);
return result;
// //System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null));
// if ((poolArray == null) || (getPools().size() != poolArray.length)) {
// List pools = getPools();
// poolArray = new ISystemFilterPool[pools.size()];
// Iterator i = pools.iterator();
// int idx = 0;
// while (i.hasNext())
// poolArray[idx++] = (ISystemFilterPool) i.next();
// //System.out.println("Pool array created. length = "+poolArray.length);
// }
// return poolArray;
}
/**
@ -425,24 +430,31 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Get list of filter pool names currently existing.
*/
public Vector getSystemFilterPoolNamesVector() {
List pools = getPools();
if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated?
{
poolNames = new Vector();
Iterator i = pools.iterator();
while (i.hasNext())
poolNames.addElement(((ISystemFilterPool) i.next()).getName());
Vector result = new Vector(pools.size());
for (Iterator z = pools.iterator(); z.hasNext();) {
ISystemFilterPool pool = (ISystemFilterPool) z.next();
String poolName = pool.getName();
result.add(poolName);
}
return poolNames;
return result;
// List pools = getPools();
// if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated?
// {
// poolNames = new Vector();
// Iterator i = pools.iterator();
// while (i.hasNext())
// poolNames.addElement(((ISystemFilterPool) i.next()).getName());
// }
// return poolNames;
}
/*
* Call this to invalidate array cache after any activity
*/
private void invalidatePoolCache() {
poolArray = null;
poolNames = null;
}
// private void invalidatePoolCache() {
// poolArray = null;
// poolNames = null;
// }
/**
* Create a new filter pool.
@ -473,9 +485,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
pool.setSystemFilterPoolManager(this);
pool.setStringsCaseSensitive(areStringsCaseSensitive());
pool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings() && supportsDuplicateFilterStrings());
List pools = getPools();
// List pools = getPools();
pools.add(pool);
invalidatePoolCache();
// invalidatePoolCache();
commit(pool);
if ((caller != null) && !suspendCallbacks) {
caller.filterEventFilterPoolCreated(pool);
@ -501,63 +513,22 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* @param pool The filter pool object to physically delete
*/
public void deleteSystemFilterPool(ISystemFilterPool pool) throws Exception {
// remove all references
IRSEBaseReferencingObject[] refs = pool.getReferencingObjects();
//boolean needsSave = false;
if (refs != null) {
for (int idx = 0; idx < refs.length; idx++) {
if (refs[idx] instanceof ISystemFilterPoolReference) {
ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference) refs[idx];
ISystemFilterPoolReferenceManager fprMgr = fpRef.getFilterPoolReferenceManager();
if (fprMgr != null) fprMgr.removeSystemFilterPoolReference(fpRef, false);// false means don't dereference
if (fprMgr != null) {
fprMgr.removeSystemFilterPoolReference(fpRef, false); // false means don't dereference DWD why?
}
}
}
}
// DWD removing a pool should mark its parent profile as dirty and cause a save to be "scheduled"
// remove from model
List pools = getPools();
pools.remove(pool);
invalidatePoolCache();
/* FIXME
// now in EMF, the pools are "owned" by the Resource, and only referenced by this pool manager,
// so I don't think just removing it from the manager is enough... it must also be removed from its
// resource. Phil.
Resource res = pool.eResource();
if (res != null)
res.getContents().remove(pool);
// remove from disk
if ( (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILEANDFOLDER_PER_POOL) ||
(savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_FILTER) )
{
String expectedFolderName = derivePoolFolderName(poolName);
if (expectedFolderName.equals(poolFolder.getName()))
{
// folder name equals what we would have named it if left to us.
// assumption is this folder only exists to hold this pool!
if (poolFolder.exists())
getResourceHelpers().deleteResource(poolFolder);
}
}
else if (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_POOL_SAME_FOLDER)
{
String poolFileName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool);
IFile poolFile = SystemResourceHelpers.getResourceHelpers().getFile(poolFolder,poolFileName);
if (poolFile.exists())
getResourceHelpers().deleteResource(poolFile);
}
else // all pools in one file per manager. Just save it
{
commit();
}
invalidatePoolCache();
// if caller provider, callback to inform them of this event
if ((caller != null) && !suspendCallbacks)
caller.filterEventFilterPoolDeleted(pool);
*/
_profile.setDirty(true);
_profile.commit();
getProvider().filterEventFilterPoolDeleted(pool);
}
/**
@ -576,174 +547,25 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
}
/**
* Pre-test if we are going to run into any trouble renaming any of the files or folders
* used to persist a filter pool.
* @return true if everything seems ok, false if a file/folder is in use.
* Pre-test if we are going to run into any trouble renaming a filter pool.
* @return true if the pool can be renamed.
*/
public boolean preTestRenameFilterPool(ISystemFilterPool pool) throws Exception {
boolean ok = true;
/*
* DWD this looks like it needs to be modified so that it queries the persistence
* manager to see if the pool can be renamed. The provider is in charge of determining
* pool names in the persistent form. The Manager will have to construct a DOM
* object for this pool and query the appropriate provider.
*/
/* FIXME
if ( (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILEANDFOLDER_PER_POOL) ||
(savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_FILTER) )
{
String expectedFolderName = derivePoolFolderName(pool.getName());
boolean ourFolderName = expectedFolderName.equals(pool.getFolder().getName());
// we must rename the old file...
String poolFileName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool);
IFile poolFile = getResourceHelpers().getFile(pool.getFolder(),poolFileName);
IFolder poolFolder = pool.getFolder();
// first, pre-test for file-in-use error:
boolean inUse = poolFile.exists() && SystemResourceHelpers.testIfResourceInUse(poolFile);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FILE_INUSE);
msg.makeSubstitution(poolFile.getFullPath());
throw new SystemMessageException(msg);
}
// next, pre-test for folder-in-use error:
if (ourFolderName)
{
inUse = poolFolder.exists() && SystemResourceHelpers.testIfResourceInUse(poolFolder);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_INUSE);
msg.makeSubstitution(poolFolder.getFullPath());
throw new SystemMessageException(msg);
}
}
}
else if (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_POOL_SAME_FOLDER)
{
String poolFileName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool);
IFile poolFile = getResourceHelpers().getFile(pool.getFolder(),poolFileName);
// first, pre-test for file-in-use error:
boolean inUse = poolFile.exists() && SystemResourceHelpers.testIfResourceInUse(poolFile);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FILE_INUSE);
msg.makeSubstitution(poolFile.getFullPath());
throw new SystemMessageException(msg);
}
}
* The default implementation returns true. Persistence providers should be able to handle this
* circumstance regardless. If a pool can be renamed internally, it should be able to be
* renamed in its persistent form.
*/
boolean ok = true;
return ok;
}
/**
* Rename a given filter pool. Dependending on the save policy, the
* appropriate file or folder on disk will also be renamed.
* <p>
* Does the following:
* <ul>
* <li>Updates all referencing objects
* <li>Renames pool object in the in-memory model
* <li>Renames folder on disk for policies of one folder per pool
* <li>Renames file on disk for policy of one file per pool
* <li>Saves model to disk for policy of one file per manager
* <li>Invalidates in-memory caches
* <li>Calls back to provider to inform of this event.
* </ul>
* @param pool The filter pool object to physically rename
* @param newName The new name to give the pool
/* (non-Javadoc)
* @see org.eclipse.rse.core.filters.ISystemFilterPoolManager#renameSystemFilterPool(org.eclipse.rse.core.filters.ISystemFilterPool, java.lang.String)
*/
public void renameSystemFilterPool(ISystemFilterPool pool, String newName) throws Exception {
/*
* DWD Renaming a filter pool should mark its parent profile as dirty and
* the pool itself as dirty. A rewrite of the profile should be scheduled.
*/
String oldName = pool.getName();
// rename on disk
/* FIXME
int oldLen = oldName.length();
int newLen = newName.length();
if ( (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILEANDFOLDER_PER_POOL) ||
(savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_FILTER) )
{
String expectedFolderName = derivePoolFolderName(pool.getName());
boolean ourFolderName = expectedFolderName.equals(pool.getFolder().getName());
// we must rename the old file...
String poolFileName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool);
String poolFileNewName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool,newName);
IFile poolFile = getResourceHelpers().getFile(pool.getFolder(),poolFileName);
IFolder poolFolder = pool.getFolder();
// first, pre-test for file-in-use error:
boolean inUse = poolFile.exists() && SystemResourceHelpers.testIfResourceInUse(poolFile);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FILE_INUSE);
msg.makeSubstitution(poolFile.getFullPath());
throw new SystemMessageException(msg);
}
// next, pre-test for folder-in-use error:
if (ourFolderName)
{
inUse = poolFolder.exists() && SystemResourceHelpers.testIfResourceInUse(poolFolder);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_INUSE);
msg.makeSubstitution(poolFolder.getFullPath());
throw new SystemMessageException(msg);
}
}
if (poolFile.exists())
{
// pre-test if the new name will be too long for MOF (256)
if (nameLenDiff > 0)
{
if (ourFolderName)
nameLenDiff *= 2; // new name affects folder and file
int newNameLen = poolFile.getLocation().toOSString().length() + nameLenDiff;
if (newNameLen > 256)
throw new Exception("Fully qualified filter pool name too long for "+newName+". Exceeds 256 characters");
}
getResourceHelpers().renameResource(poolFile, poolFileNewName);
}
if (ourFolderName)
{
// folder name equals what we would have named it if left to us.
// assumption is this folder only exists to hold this pool!
if (poolFolder.exists())
{
String newFolderName = derivePoolFolderName(newName);
getResourceHelpers().renameResource(poolFolder, newFolderName);
// as we now know, the original IFolder still points to the old name!
poolFolder = getResourceHelpers().getRenamedFolder(poolFolder, newFolderName);
pool.setFolder(poolFolder);
}
}
}
else if (savePolicy == SystemFilterConstants.SAVE_POLICY_ONE_FILE_PER_POOL_SAME_FOLDER)
{
String poolFileName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool);
IFile poolFile = getResourceHelpers().getFile(pool.getFolder(),poolFileName);
// first, pre-test for file-in-use error:
boolean inUse = poolFile.exists() && SystemResourceHelpers.testIfResourceInUse(poolFile);
if (inUse)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FILE_INUSE);
msg.makeSubstitution(poolFile.getFullPath());
throw new SystemMessageException(msg);
}
if (poolFile.exists())
{
String poolFileNewName = SystemFilterPoolImpl.getSaveFileName(getMOFHelpers(),pool,newName);
getResourceHelpers().renameResource(poolFile, poolFileNewName);
}
}
*/
pool.setName(newName);
invalidatePoolCache();
// inform all referencees
IRSEBaseReferencingObject[] refs = pool.getReferencingObjects();
if (refs != null) {
@ -756,9 +578,10 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
}
}
}
// if caller provider, callback to inform them of this event
if ((caller != null) && !suspendCallbacks) caller.filterEventFilterPoolRenamed(pool, oldName);
if ((caller != null) && !suspendCallbacks) {
caller.filterEventFilterPoolRenamed(pool, oldName);
}
}
/**
@ -1148,24 +971,23 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* @param delta the amount by which to move the filters (filterEventFiltersRePositioned)
*/
public void moveSystemFilters(ISystemFilter filters[], int delta) throws Exception {
/*
* DWD revisit this. Make sure that the pool is scheduled to be saved.
*/
// ISystemFilterContainer container = filters[0].getParentFilterContainer();
int[] oldPositions = new int[filters.length];
for (int idx = 0; idx < filters.length; idx++)
for (int idx = 0; idx < filters.length; idx++) {
oldPositions[idx] = getSystemFilterPosition(filters[idx]);
if (delta > 0) // moving down, process backwards
for (int idx = filters.length - 1; idx >= 0; idx--)
}
if (delta > 0) { // moving down, process backwards
for (int idx = filters.length - 1; idx >= 0; idx--) {
moveFilter(filters[idx], oldPositions[idx] + delta);
else
for (int idx = 0; idx < filters.length; idx++)
}
} else {
for (int idx = 0; idx < filters.length; idx++) {
moveFilter(filters[idx], oldPositions[idx] + delta);
}
}
commit(filters[0].getParentFilterPool());
// if caller provider, callback to inform them of this event
if ((caller != null) && !suspendCallbacks) caller.filterEventFiltersRePositioned(filters, delta);
if ((caller != null) && !suspendCallbacks) {
caller.filterEventFiltersRePositioned(filters, delta);
}
}
/**
@ -1331,21 +1153,13 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Copy a system filter string to a filter in this or another filter pool manager.
*/
public ISystemFilterString copySystemFilterString(ISystemFilter targetFilter, ISystemFilterString oldFilterString) throws Exception {
/*
* DWD revisit this. make sure that pool is persisted.
*/
ISystemFilterPool targetPool = targetFilter.getParentFilterPool();
ISystemFilterPoolManager targetMgr = targetPool.getSystemFilterPoolManager();
ISystemFilter oldFilter = oldFilterString.getParentSystemFilter();
// ISystemFilterPool oldPool = oldFilter.getParentFilterPool();
targetMgr.suspendCallbacks(true);
ISystemFilterString newFilterString = oldFilter.copySystemFilterString(targetFilter, oldFilterString); // creates it in memory
commit(targetPool); // save updated pool to disk
targetMgr.suspendCallbacks(false);
targetMgr.getProvider().filterEventFilterStringCreated(newFilterString);
return newFilterString;
}
@ -1570,10 +1384,12 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* @generated This field/method will be replaced during code generation
*/
public List getPools() {
if (pools == null) {
pools = new ArrayList();
}
return pools;
// if (pools == null) {
// pools = new ArrayList();
// }
List result = new ArrayList(pools.size());
result.addAll(pools);
return result;
}
/**
@ -1638,10 +1454,10 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
}
/**
* Save all the filter pools to disk.
* Uses the save policy specified in this manager's factory method.
* Save a specific filter pool.
*/
public boolean commit(ISystemFilterPool pool) {
pool.setDirty(true);
boolean result = pool.commit();
return result;
}

View file

@ -12,7 +12,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David Dykstal (IBM) - [197036] fixed parent references and names so that delete references would function correctly
*******************************************************************************/
package org.eclipse.rse.internal.core.filters;
@ -185,7 +185,11 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* objects in this list reference.
*/
public ISystemFilterPoolManager[] getSystemFilterPoolManagers() {
return poolMgrProvider.getSystemFilterPoolManagers();
ISystemFilterPoolManager[] result = new ISystemFilterPoolManager[0];
if (poolMgrProvider != null) {
result = poolMgrProvider.getSystemFilterPoolManagers();
}
return result;
}
/**
@ -379,6 +383,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/
private ISystemFilterPoolReference createSystemFilterPoolReference(ISystemFilterPool filterPool) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPool);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache();
return filterPoolReference;
}
@ -391,6 +396,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/
private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache();
return filterPoolReference;
}
@ -402,7 +408,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/
public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) {
int count = addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in the addReferencingObject method?
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache();
quietSave();
return count;
@ -432,7 +438,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
count = super.removeReferencingObject(filterPoolReference);
else
count = super.removeAndDeReferenceReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in remove?
invalidateFilterPoolReferencesCache();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
quietSave();
@ -541,8 +546,8 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPool filterPool) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPool);
addReferencingObject(filterPoolReference); // DWD - should be done in addReferencingObject?
filterPoolReference.setParentReferenceManager(this);
addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache();
quietSave();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference);
@ -555,7 +560,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName);
addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache();
quietSave();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference);
@ -574,11 +579,12 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
if (filterPoolReference != null) {
filterPoolReference.removeReference();
newCount = removeReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in removeReferencingObject?
invalidateFilterPoolReferencesCache();
quietSave();
// callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
if (fireEvents && (caller != null)) {
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
}
} else
newCount = getSystemFilterPoolReferenceCount();
return newCount;
@ -621,7 +627,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
//addReferenceToSystemFilterPool(filterPools[idx]);
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]);
addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD should be done in addReferencingObject?
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
}
invalidateFilterPoolReferencesCache();
quietSave();

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Dykstal (IBM) - [197036] new interface
*******************************************************************************/
package org.eclipse.rse.internal.core.model;
import org.eclipse.core.runtime.IStatus;
/**
* A profile operation can be executed by the SystemProfileManager. This allows for multiple changes
* to model objects to be committed all at once when the last level of nesting is completed.
*/
public interface ISystemProfileOperation {
/**
* Run this operation. Should not be invoked directly.
* See {@link SystemProfileManager#run(ISystemProfileOperation)
* @return The IStatus of the operation
*/
public IStatus run();
}

View file

@ -14,17 +14,18 @@
* David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* David Dykstal (IBM) - [197036] changed getFilterPools to not force the loading of subsystem configurations
* removed createHost, migrated commit logic to SystemProfileManager
********************************************************************************/
package org.eclipse.rse.internal.core.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
@ -35,6 +36,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -80,15 +82,6 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return mgr;
}
/**
* Convenience method for create a new connection within this profile.
* Shortcut for {@link ISystemRegistry#createHost(String,String,String,String)}
*/
public IHost createHost(IRSESystemType systemType, String connectionName, String hostName, String description) throws Exception
{
return RSECorePlugin.getTheSystemRegistry().createHost(getName(), systemType, connectionName, hostName, description);
}
/**
* Return all connections for this profile
*/
@ -97,25 +90,26 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return RSECorePlugin.getTheSystemRegistry().getHostsByProfile(this);
}
/**
* Return all filter pools for this profile
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfile#getFilterPools()
*/
public ISystemFilterPool[] getFilterPools()
{
ISubSystemConfiguration[] ssFactories = RSECorePlugin.getTheSystemRegistry().getSubSystemConfigurations();
Vector poolsVector = new Vector();
for (int idx = 0; idx < ssFactories.length; idx++)
{
ISystemFilterPoolManager poolMgr = ssFactories[idx].getFilterPoolManager(this);
ISystemFilterPool[] pools = poolMgr.getSystemFilterPools();
for (int ydx=0; ydx<pools.length; ydx++)
{
poolsVector.add(pools[ydx]);
List filterPools = new ArrayList(10); // 10 is arbitrary but reasonable
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
ISubSystemConfigurationProxy proxies[] = registry.getSubSystemConfigurationProxies();
for (int i = 0; i < proxies.length; i++) {
ISubSystemConfigurationProxy proxy = proxies[i];
if (proxy.isSubSystemConfigurationActive()) {
ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
ISystemFilterPoolManager fpm = config.getFilterPoolManager(this);
ISystemFilterPool[] poolArray = fpm.getSystemFilterPools();
filterPools.addAll(Arrays.asList(poolArray));
}
}
ISystemFilterPool[] allPools = new ISystemFilterPool[poolsVector.size()];
poolsVector.toArray(allPools);
return allPools;
ISystemFilterPool[] result = new ISystemFilterPool[filterPools.size()];
filterPools.toArray(result);
return result;
}
/**
@ -209,13 +203,13 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
setDirty(true);
}
public boolean commit()
{
boolean result = false;
if (!RSECorePlugin.getThePersistenceManager().isBusy()) {
result = RSECorePlugin.getThePersistenceManager().commitProfile(this, 5000);
}
return result;
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit()
*/
public boolean commit() {
IStatus status = SystemProfileManager.getDefault().commitSystemProfile(this);
boolean scheduled = status.isOK();
return scheduled;
}
/**

View file

@ -16,6 +16,7 @@
* Kevin Doyle (IBM) - [197199] Renaming a Profile doesn't cause a save
* Yu-Fen Kuo (MontaVista) - [189271] [team] New Profile's are always active
* - [189219] [team] Inactive Profiles become active after workbench restart
* David Dykstal (IBM) - [197036] added implementation of run() for commit transaction support
********************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -24,6 +25,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.model.ISystemProfile;
@ -39,7 +42,8 @@ public class SystemProfileManager implements ISystemProfileManager {
private List _profiles = new ArrayList(10);
private static SystemProfileManager singleton = null;
private boolean restoring = false;
private boolean restoring = false;
private boolean active = true;
/**
* Ordinarily there should be only one instance of a SystemProfileManager
@ -68,11 +72,65 @@ public class SystemProfileManager implements ISystemProfileManager {
public static void clearDefault() {
singleton = null;
}
public void setRestoring(boolean flag) {
restoring = flag;
}
/**
* Run an operation that make make changes to the persistent model in such a way that
* results are scheduled to be persisted at the end of the operation.
* @param operation an ISystemProfileOperation to be performed.
* @return an IStatus indicating the status of the operation. Changes to
* profiles are committed in any case.
*/
public static IStatus run(ISystemProfileOperation operation) {
IStatus result = null;
SystemProfileManager instance = getDefault();
result = instance.runOperation(operation);
return result;
}
private IStatus runOperation(ISystemProfileOperation operation) {
IStatus status = Status.OK_STATUS;
boolean wasActive = active;
active = false;
try {
status = operation.run();
} finally {
if (wasActive) {
active = true;
commitProfiles();
}
}
return status;
}
private void commitProfiles() {
for (Iterator z = _profiles.iterator(); z.hasNext();) {
ISystemProfile profile = (ISystemProfile) z.next();
profile.commit();
}
}
public IStatus commitSystemProfile(ISystemProfile profile) {
IStatus status = Status.OK_STATUS;
boolean scheduled = false;
if (active) {
if (!RSECorePlugin.getThePersistenceManager().isBusy()) {
scheduled = RSECorePlugin.getThePersistenceManager().commitProfile(profile, 5000);
}
} else {
scheduled = true;
}
if (!scheduled) {
String pluginId = RSECorePlugin.getDefault().getBundle().getSymbolicName();
int code = 1; // TODO DWD make this a constant
status = new Status(IStatus.INFO, pluginId, code, "", null); //$NON-NLS-1$
}
return status;
}
/**
* Create a new profile with the given name, and add to the list.
* The name must be unique within the existing list.
@ -115,7 +173,7 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/
public ISystemProfile[] getSystemProfiles() {
return getSystemProfiles(!restoring);
return getSystemProfiles(restoring);
}
/* (non-Javadoc)
@ -162,14 +220,14 @@ public class SystemProfileManager implements ISystemProfileManager {
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
*/
private ISystemProfile getSystemProfileOld(String name) {
ISystemProfile[] profiles = getSystemProfiles();
if ((profiles == null) || (profiles.length == 0)) return null;
ISystemProfile match = null;
for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
if (profiles[idx].getName().equals(name)) match = profiles[idx];
return match;
}
// private ISystemProfile getSystemProfileOld(String name) {
// ISystemProfile[] profiles = getSystemProfiles();
// if ((profiles == null) || (profiles.length == 0)) return null;
// ISystemProfile match = null;
// for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
// if (profiles[idx].getName().equals(name)) match = profiles[idx];
// return match;
// }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
@ -225,14 +283,14 @@ public class SystemProfileManager implements ISystemProfileManager {
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String)
*/
private boolean isSystemProfileActiveOld(String profileName) {
String[] activeProfiles = getActiveSystemProfileNames();
boolean match = false;
for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
if (activeProfiles[idx].equals(profileName)) match = true;
}
return match;
}
// private boolean isSystemProfileActiveOld(String profileName) {
// String[] activeProfiles = getActiveSystemProfileNames();
// boolean match = false;
// for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
// if (activeProfiles[idx].equals(profileName)) match = true;
// }
// return match;
// }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles()
@ -270,92 +328,92 @@ public class SystemProfileManager implements ISystemProfileManager {
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames()
*/
private String[] getActiveSystemProfileNamesOld() {
String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles();
// dy: defect 48355, need to sync this with the actual profile list. If the user
// imports old preference settings or does a team sync and a profile is deleted then
// it is possible an active profile no longer exists.
// String[] systemProfileNames = getSystemProfileNames();
ISystemProfile[] systemProfiles = getSystemProfiles();
boolean found;
boolean found_team = false;
boolean found_private = false;
boolean changed = false;
String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
// skip Team and Private profiles
String activeProfileName = activeProfileNames[activeIdx];
if (activeProfileName.equals(defaultProfileName)) {
found_private = true;
} else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) {
found_team = true;
} else {
found = false;
for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
found = true;
}
}
if (!found) {
// The active profile no longer exists so remove it from the active list
RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]);
changed = true;
}
}
}
for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
boolean matchesBoth = false;
String name = systemProfiles[systemIdx].getName();
for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
String aname = activeProfileNames[activeIdx];
if (name.equals(aname)) {
matchesBoth = true;
}
}
if (!matchesBoth && found_private) {
if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
RSEPreferencesManager.addActiveProfile(name);
RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName());
activeProfileNames = RSEPreferencesManager.getActiveProfiles();
}
}
}
// the active profiles list needed to be changed because of an external update, also
// check if Default profile needs to be added back to the list
if (changed || !found_team || !found_private) {
if (systemProfiles.length == 0) {
// First time user, make sure default is in the active list, the only time it wouldn't
// be is if the pref_store.ini was modified (because the user imported old preferences)
if (!found_team) {
RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName());
changed = true;
}
if (!found_private) {
RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName());
changed = true;
}
} else {
ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
if (defaultProfile != null && !found_private) {
RSEPreferencesManager.addActiveProfile(defaultProfile.getName());
changed = true;
}
}
if (changed) {
activeProfileNames = RSEPreferencesManager.getActiveProfiles();
}
}
return activeProfileNames;
}
// private String[] getActiveSystemProfileNamesOld() {
// String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles();
// // dy: defect 48355, need to sync this with the actual profile list. If the user
// // imports old preference settings or does a team sync and a profile is deleted then
// // it is possible an active profile no longer exists.
// // String[] systemProfileNames = getSystemProfileNames();
// ISystemProfile[] systemProfiles = getSystemProfiles();
// boolean found;
// boolean found_team = false;
// boolean found_private = false;
// boolean changed = false;
// String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
//
// for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
// // skip Team and Private profiles
// String activeProfileName = activeProfileNames[activeIdx];
// if (activeProfileName.equals(defaultProfileName)) {
// found_private = true;
// } else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) {
// found_team = true;
// } else {
// found = false;
// for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
// if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
// found = true;
// }
// }
//
// if (!found) {
// // The active profile no longer exists so remove it from the active list
// RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]);
// changed = true;
// }
// }
// }
//
// for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
// boolean matchesBoth = false;
// String name = systemProfiles[systemIdx].getName();
//
// for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
// String aname = activeProfileNames[activeIdx];
// if (name.equals(aname)) {
// matchesBoth = true;
// }
//
// }
// if (!matchesBoth && found_private) {
// if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
// RSEPreferencesManager.addActiveProfile(name);
// RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName());
// activeProfileNames = RSEPreferencesManager.getActiveProfiles();
// }
// }
// }
//
// // the active profiles list needed to be changed because of an external update, also
// // check if Default profile needs to be added back to the list
// if (changed || !found_team || !found_private) {
// if (systemProfiles.length == 0) {
// // First time user, make sure default is in the active list, the only time it wouldn't
// // be is if the pref_store.ini was modified (because the user imported old preferences)
// if (!found_team) {
// RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName());
// changed = true;
// }
//
// if (!found_private) {
// RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName());
// changed = true;
// }
// } else {
// ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
// if (defaultProfile != null && !found_private) {
// RSEPreferencesManager.addActiveProfile(defaultProfile.getName());
// changed = true;
// }
// }
//
// if (changed) {
// activeProfileNames = RSEPreferencesManager.getActiveProfiles();
// }
// }
//
// return activeProfileNames;
// }
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
@ -449,8 +507,8 @@ public class SystemProfileManager implements ISystemProfileManager {
}
}
private ISystemProfile[] getSystemProfiles(boolean ensureDefaultPrivateProfileExists) {
if (ensureDefaultPrivateProfileExists) {
private ISystemProfile[] getSystemProfiles(boolean restoring) {
if (!restoring) {
ensureDefaultPrivateProfile();
}
ISystemProfile[] result = new ISystemProfile[_profiles.size()];

View file

@ -16,6 +16,7 @@
* David Dykstal (IBM) - 168870: move core function from UI to core
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* David Dykstal (IBM) - [197036] delay the creation of filterPoolManagers when restoring
********************************************************************************/
package org.eclipse.rse.internal.core.subsystems;
@ -264,11 +265,12 @@ public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy
* After a reset, restore from disk
*/
public void restore() {
try {
configuration.getAllSystemFilterPoolManagers();
} catch (Exception exc) {
RSECorePlugin.getDefault().getLogger().logError("Error restoring subsystem for configuration " + getName(), exc); //$NON-NLS-1$
}
// Filter pool managers do not need to be created until they are needed.
// try {
// configuration.getAllSystemFilterPoolManagers();
// } catch (Exception exc) {
// RSECorePlugin.getDefault().getLogger().logError("Error restoring subsystem for configuration " + getName(), exc); //$NON-NLS-1$
// }
}
/* (non-Javadoc)

View file

@ -17,6 +17,7 @@
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
* David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets
* David Dykstal (IBM) - [197036] respond to removal of SystemProfile.createHost()
********************************************************************************/
package org.eclipse.rse.internal.persistence.dom;
@ -117,11 +118,11 @@ public class RSEDOMImporter {
IHost host = null;
// get host node attributes
String connectionName = hostNode.getName();
String hostName = hostNode.getName();
// we changed from storing names to storing IDs, so these may be null
String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
String systemTypeId = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_TYPE);
String hostName = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
String hostAddress = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_HOSTNAME);
String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE);
boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
@ -130,16 +131,18 @@ public class RSEDOMImporter {
try {
// NOTE create host effectively recreates the subsystems
// so instead of creating subsystems on restore, we should be updating their properties
IRSECoreRegistry registry = RSECorePlugin.getTheCoreRegistry();
IRSECoreRegistry coreRegistry = RSECorePlugin.getTheCoreRegistry();
IRSESystemType systemType = null;
if (systemTypeId != null) {
systemType = registry.getSystemTypeById(systemTypeId);
systemType = coreRegistry.getSystemTypeById(systemTypeId);
} else if (systemTypeName != null) {
systemType = registry.getSystemType(systemTypeName);
systemType = coreRegistry.getSystemType(systemTypeName);
}
//cannot create a host from a profile if we do not know the systemType
if (systemType != null) {
host = profile.createHost(systemType, connectionName, hostName, description);
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
String profileName = profile.getName();
host = registry.createHost(profileName, systemType, hostName, hostAddress, description, false);
host.setOffline(isOffline);
host.setPromptable(isPromptable);
} else {
@ -151,7 +154,7 @@ public class RSEDOMImporter {
msg.append(") in "); //$NON-NLS-1$
msg.append(profile.getName());
msg.append(':');
msg.append(connectionName);
msg.append(hostName);
logWarning(msg.toString());
}
} catch (Exception e) {
@ -292,7 +295,7 @@ public class RSEDOMImporter {
fprMgr.setDefaultSystemFilterPoolManager(defaultFilterPoolManager);
}
// restore filer pool references
// restore filter pool references
RSEDOMNode[] filterPoolReferenceChildren = subSystemNode.getChildren(IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE);
for (int i = 0; i < filterPoolReferenceChildren.length; i++) {
RSEDOMNode fprChild = filterPoolReferenceChildren[i];
@ -506,7 +509,7 @@ public class RSEDOMImporter {
}
// properties are now stored as children, get those next
RSEDOMNode[] children = propertySetNode.getChildren();
for (int i = 0; i < children.length; i++) {
for (int i = 0; i < children.length; i++) {
RSEDOMNode child = children[i];
// is this a property set or a property?
@ -515,14 +518,14 @@ public class RSEDOMImporter {
restorePropertySet((IRSEModelObject)set, child);
}
else {
String propertyName = child.getName();
String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
set.setDescription(propertyValue);
} else {
set.addProperty(propertyName, propertyValue, propertyType);
String propertyName = child.getName();
String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
set.setDescription(propertyValue);
} else {
set.addProperty(propertyName, propertyValue, propertyType);
}
}
}

View file

@ -27,6 +27,7 @@
* David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated
* Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
* David McKnight (IBM) - [209704] added supportsEncodingConversion()
* David Dykstal (IBM) - [197036] pulling up subsystem switch logic
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -77,10 +78,6 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
protected ISearchService _hostSearchService;
protected IHostFileToRemoteFileAdapter _hostFileToRemoteFileAdapter;
protected IRemoteFile _userHome;
public FileServiceSubSystem(IHost host, IConnectorService connectorService, IFileService hostFileService, IHostFileToRemoteFileAdapter fileAdapter, ISearchService searchService)
{
super(host, connectorService);
@ -919,43 +916,28 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
return null;
}
/**
* Switch to use another protocol
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#canSwitchTo(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
* Overriding the super implementation to return true for any configuration that implements IFileServiceSubSystemConfiguration
*/
public void switchServiceFactory(IServiceSubSystemConfiguration fact)
{
if (fact != getSubSystemConfiguration() && fact instanceof IFileServiceSubSystemConfiguration)
{
IFileServiceSubSystemConfiguration factory = (IFileServiceSubSystemConfiguration)fact;
try
{
_cachedRemoteFiles.clear();
disconnect();
}
catch (Exception e)
{
}
_languageUtilityFactory = null;
IHost host = getHost();
setSubSystemConfiguration(factory);
public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
return (configuration instanceof IFileServiceSubSystemConfiguration);
}
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = factory.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
setName(factory.getName());
setFileService(factory.getFileService(host));
setHostFileToRemoteFileAdapter(factory.getHostFileAdapter());
setSearchService(factory.getSearchService(host));
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#internalSwitchServiceSubSystemConfiguration(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
* Overriding the super implementation to do switch the file subsystem bits that need to be copied or initialized in a switch
*/
protected void internalSwitchServiceSubSystemConfiguration(IServiceSubSystemConfiguration newConfig) {
if (newConfig instanceof IFileServiceSubSystemConfiguration) {
IHost host = getHost();
IFileServiceSubSystemConfiguration config = (IFileServiceSubSystemConfiguration) newConfig;
// file subsystem specific bits
_cachedRemoteFiles.clear();
_languageUtilityFactory = null;
setFileService(config.getFileService(host));
setHostFileToRemoteFileAdapter(config.getHostFileAdapter());
setSearchService(config.getSearchService(host));
}
}

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
* Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core
* Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core
* David Dykstal (IBM) - [197036] fixed NPE found during testing
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.subsystems;
@ -330,13 +331,14 @@ public abstract class RemoteFileSubSystemConfiguration extends SubSystemConfigur
try {
// -----------------------------------------------------
// create a pool named filters
// -----------------------------------------------------
pool = mgr.createSystemFilterPool(getDefaultFilterPoolName(mgr.getName(), getId()), true); // true=>is deletable by user
// -----------------------------------------------------
String poolName = getDefaultFilterPoolName(mgr.getName(), getId());
pool = mgr.createSystemFilterPool(poolName, true); // true => is deletable by user
//System.out.println("Pool created");
// ---------------------------------------------------------------------------------------------
// create default filters in that pool iff this is the user's private profile we are creating...
// ---------------------------------------------------------------------------------------------
if (isUserPrivateProfile(mgr))
if (pool != null && isUserPrivateProfile(mgr))
{
Vector filterStrings = new Vector();

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* David Dykstal (IBM) - [197036] refactored switch configuration
********************************************************************************/
package org.eclipse.rse.subsystems.processes.servicesubsystem;
@ -145,37 +146,21 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.servicesubsystem.IServiceSubSystem#switchServiceFactory(org.eclipse.rse.core.servicesubsystem.IServiceSubSystemConfiguration)
* @see org.eclipse.rse.core.subsystems.SubSystem#internalSwitchServiceSubSystemConfiguration(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
*/
public void switchServiceFactory(IServiceSubSystemConfiguration fact)
protected void internalSwitchServiceSubSystemConfiguration(IServiceSubSystemConfiguration configuration)
{
if (fact != getSubSystemConfiguration() && fact instanceof IProcessServiceSubSystemConfiguration)
{
IProcessServiceSubSystemConfiguration factory = (IProcessServiceSubSystemConfiguration)fact;
try
{
disconnect();
}
catch (Exception e)
{
}
IProcessServiceSubSystemConfiguration config = (IProcessServiceSubSystemConfiguration) configuration;
IHost host = getHost();
setSubSystemConfiguration(factory);
setName(factory.getName());
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = factory.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
setProcessService(factory.getProcessService(host));
setHostProcessToRemoteProcessAdapter(factory.getHostProcessAdapter());
}
setProcessService(config.getProcessService(host));
setHostProcessToRemoteProcessAdapter(config.getHostProcessAdapter());
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#canSwitchTo(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
*/
public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
return configuration instanceof IProcessServiceSubSystemConfiguration;
}
/* (non-Javadoc)
@ -186,7 +171,6 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen
return IProcessService.class;
}
/* (non-Javadoc)
* @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor)
*/

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* David McKnight (IBM) - [191599] Need to pass in shell encoding
* David Dykstal (IBM) - [197036] refactored switch configuration
********************************************************************************/
package org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem;
@ -33,6 +34,7 @@ import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IShellService;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystemConfiguration;
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell;
import org.eclipse.rse.subsystems.shells.core.subsystems.RemoteCmdSubSystem;
@ -204,38 +206,25 @@ public final class ShellServiceSubSystem extends RemoteCmdSubSystem implements I
return l;
}
/**
* swtich from one protocol to another
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#canSwitchTo(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
*/
public void switchServiceFactory(IServiceSubSystemConfiguration fact)
{
if (fact != getSubSystemConfiguration() && fact instanceof IShellServiceSubSystemConfiguration)
{
IShellServiceSubSystemConfiguration factory = (IShellServiceSubSystemConfiguration)fact;
try
{
disconnect();
}
catch (Exception e)
{
}
IHost host = getHost();
setSubSystemConfiguration(factory);
setName(factory.getName());
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = factory.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
setShellService(factory.getShellService(host));
}
public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
return configuration instanceof IShellServiceSubSystemConfiguration;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#internalSwitchServiceSubSystemConfiguration(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
*/
protected void internalSwitchServiceSubSystemConfiguration(IServiceSubSystemConfiguration newConfiguration) {
IShellServiceSubSystemConfiguration configuration = (IShellServiceSubSystemConfiguration) newConfiguration;
IHost host = getHost();
setShellService(configuration.getShellService(host));
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#getServiceType()
*/
public Class getServiceType()
{
return IShellService.class;

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Kevin Doyle (IBM) - [175277] Cannot disconnect multiple connections at once with multiselect
* David Dykstal (IBM) - [197036] minor refactoring
********************************************************************************/
package org.eclipse.rse.internal.ui.actions;
@ -59,7 +60,7 @@ public class SystemDisconnectAllSubSystemsAction extends SystemBaseAction
if (element instanceof IHost) {
IHost host = (IHost)element;
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] ss = sr.getSubSystems(host, false);
ISubSystem[] ss = sr.getSubSystems(host);
List l = new ArrayList();
for (int i=0; i<ss.length; i++) {
if (ss[i].isConnected() && ss[i].getSubSystemConfiguration().supportsSubSystemConnect()) {

View file

@ -12,6 +12,8 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [197036] fixed delete filter pool bug found during testing of this bug
* see also bug 194260 regarding deleting filter pools
********************************************************************************/
package org.eclipse.rse.internal.ui.filters.dialogs;
@ -20,6 +22,7 @@ import java.util.Vector;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.ISelection;
@ -77,6 +80,15 @@ public class SystemFilterWorkWithFilterPoolsDialog
SystemFilterPoolDialogInterface
//,ISystemResourceChangeListener
{
class DeleteFilterPoolAction extends SystemCommonDeleteAction {
public DeleteFilterPoolAction(Shell parent, ISystemDeleteTarget deleteTarget) {
super(parent, deleteTarget);
}
protected Object getDialogValue(Dialog dlg) {
doDelete(null);
return null;
}
}
private String promptString;
//private Label prompt;
@ -93,8 +105,8 @@ public class SystemFilterWorkWithFilterPoolsDialog
//private ActionContributionItem newActionItem, deleteActionItem, renameActionItem;
private SystemFilterWorkWithFilterPoolsRefreshAllAction refreshAction = null;
private SystemFilterNewFilterPoolAction newAction = null;
//private SystemSimpleDeleteAction dltAction = null;
private SystemCommonDeleteAction dltAction = null;
private DeleteFilterPoolAction dltAction = null;
//private SystemCommonDeleteAction dltAction = null;
//private SystemSimpleRenameAction rnmAction = null;
private SystemCommonRenameAction rnmAction = null;
private SystemFilterCopyFilterPoolAction cpyAction = null;
@ -251,7 +263,7 @@ public class SystemFilterWorkWithFilterPoolsDialog
{
newAction = new SystemFilterNewFilterPoolAction(shell,this);
//dltAction = new SystemSimpleDeleteAction(shell,this);
dltAction = new SystemCommonDeleteAction(shell,this);
dltAction = new DeleteFilterPoolAction(shell,this);
rnmAction = new SystemCommonRenameAction(shell,this);
// undo typical settings...
rnmAction.allowOnMultipleSelection(false);

View file

@ -30,6 +30,7 @@
* Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false)
* David Dykstal (IBM) - [197036] minor refactoring caused by SystemRegistry fix for this bug
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -599,7 +600,7 @@ public class SystemViewConnectionAdapter
//specifically, this allows deletion of "Local" which is always connected (but does not support disconnect)
//need to get subsystems from registry instead of host in order to be lazy:
//subsystems which are not yet instantiated do not need to be considered.
ISubSystem[] ss = sr.getSubSystems(host, false);
ISubSystem[] ss = sr.getSubSystems(host);
for (int i=0; i<ss.length; i++) {
if (ss[i].isConnected() && ss[i].getSubSystemConfiguration().supportsSubSystemConnect())
return false;

View file

@ -15,10 +15,18 @@
* Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [197036] rewrote getSubSystemConfigurationNodes to get filter pools
* in a way that delays the loading of subsystem configurations
********************************************************************************/
package org.eclipse.rse.internal.ui.view.team;
import java.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@ -28,6 +36,8 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.view.SystemViewResources;
import org.eclipse.rse.ui.SystemMenuManager;
@ -156,48 +166,55 @@ public class SystemTeamViewCategoryAdapter
/**
* Create subsystem factory child nodes for expanded category node
* Create subsystem configuration child nodes for expanded category node.
*/
private SystemTeamViewSubSystemConfigurationNode[] createSubSystemConfigurationNodes(ISystemProfile profile, SystemTeamViewCategoryNode category)
{
SystemTeamViewSubSystemConfigurationNode[] nodes = null;
private SystemTeamViewSubSystemConfigurationNode[] createSubSystemConfigurationNodes(ISystemProfile profile, SystemTeamViewCategoryNode category) {
// create a sorted set to hold the subsystem configurations based on the proxy ordering
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystemConfiguration[] factories = sr.getSubSystemConfigurations();
if (factories != null)
{
Vector v = new Vector();
String categoryType = category.getMementoHandle();
for (int idx=0; idx<factories.length; idx++)
{
boolean createNode = false;
ISubSystemConfiguration ssf = factories[idx];
if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS))
{
createNode = ssf.supportsFilters() && (profile.getFilterPools(ssf).length > 0);
}
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS))
{
createNode = ssf.supportsUserDefinedActions(); // && profile.getUserActions(ssf).length > 0;
}
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS))
{
createNode = ssf.supportsCompileActions(); // && profile.getCompileCommandTypes(ssf).length > 0;
}
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_TARGETS))
{
createNode = ssf.supportsTargets(); // && profile.getTargets(ssf).length > 0;
}
if (createNode)
v.addElement(new SystemTeamViewSubSystemConfigurationNode(profile, category, factories[idx]));
final List proxies = Arrays.asList(sr.getSubSystemConfigurationProxies());
Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
ISubSystemConfiguration c1 = (SubSystemConfiguration) o1;
ISubSystemConfiguration c2 = (SubSystemConfiguration) o2;
ISubSystemConfigurationProxy proxy1 = c1.getSubSystemConfigurationProxy();
ISubSystemConfigurationProxy proxy2 = c2.getSubSystemConfigurationProxy();
Integer p1 = new Integer(proxies.indexOf(proxy1));
Integer p2 = new Integer(proxies.indexOf(proxy2));
int result = p1.compareTo(p2);
return result;
}
nodes = new SystemTeamViewSubSystemConfigurationNode[v.size()];
for (int idx=0; idx<nodes.length; idx++)
{
nodes[idx] = (SystemTeamViewSubSystemConfigurationNode)v.elementAt(idx);
};
SortedSet activeSubsystemConfigurations = new TreeSet(comparator);
// find the active subsystem configurations
for (Iterator z = proxies.iterator(); z.hasNext();) {
ISubSystemConfigurationProxy proxy = (ISubSystemConfigurationProxy) z.next();
if (proxy.isSubSystemConfigurationActive()) {
ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
activeSubsystemConfigurations.add(config);
}
}
return nodes;
}
// construct the nodes for the view based on these configurations
List nodes = new ArrayList();
String categoryType = category.getMementoHandle();
for (Iterator z = activeSubsystemConfigurations.iterator(); z.hasNext();) {
ISubSystemConfiguration ssf = (ISubSystemConfiguration) z.next();
boolean createNode = false;
if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS)) {
createNode = ssf.supportsFilters() && (profile.getFilterPools(ssf).length > 0);
} else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS)) {
createNode = ssf.supportsUserDefinedActions(); // && profile.getUserActions(ssf).length > 0;
} else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS)) {
createNode = ssf.supportsCompileActions(); // && profile.getCompileCommandTypes(ssf).length > 0;
} else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_TARGETS)) {
createNode = ssf.supportsTargets(); // && profile.getTargets(ssf).length > 0;
}
if (createNode) {
nodes.add(new SystemTeamViewSubSystemConfigurationNode(profile, category, ssf));
}
}
SystemTeamViewSubSystemConfigurationNode[] result = new SystemTeamViewSubSystemConfigurationNode[nodes.size()];
nodes.toArray(result);
return result;
}
/**

View file

@ -27,7 +27,8 @@
* David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
* API to the user actions plugin
* David Dykstal (IBM) - [191038] initialize SystemRegistryUI without a log file, it was not used
* David McKnight (IBM) - [196838] Don't recreate local after it has been deleted
* David McKnight (IBM) - [196838] Don't recreate local after it has been deleted
* David Dykstal (IBM) - [197036] formatted the initialize job to be able to read it
********************************************************************************/
package org.eclipse.rse.ui;
@ -79,45 +80,26 @@ import org.osgi.framework.BundleContext;
*/
public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvider
{
public class InitRSEJob extends Job
{
public InitRSEJob()
{
//IMPORTANT: The name of this job must not ever be changed. It is par of API,
//because clients can use it to find the InitRSEJob by name, such that they can join it.
public class InitRSEJob extends Job {
public InitRSEJob() {
// IMPORTANT: The name of this job must not ever be changed. It is part of the API,
// because clients can use it to find the InitRSEJob by name, such that they can join it.
super("Initialize RSE"); //$NON-NLS-1$
}
public IStatus run(IProgressMonitor monitor)
{
public IStatus run(IProgressMonitor monitor) {
//System.err.println("InitRSEJob started"); //$NON-NLS-1$
ISystemRegistry registry = getSystemRegistryInternal();
// SystemResourceManager.getRemoteSystemsProject(); // create core folder tree
try
{
SystemStartHere.getSystemProfileManager(); // create folders per profile
}
catch (Exception e)
{
e.printStackTrace();
}
SystemStartHere.getSystemProfileManager(); // create folders per profile
// add workspace listener for our project
IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false);
SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject);
SystemResourceManager.startResourceEventListening(listener);
// determining whether to create an initial local connection
IPath statePath = RSECorePlugin.getDefault().getStateLocation();
IPath markPath = statePath.append("localHostCreated.mark"); //$NON-NLS-1$
File markFile = new File(markPath.toOSString());
if (!markFile.exists() && SystemPreferencesManager.getShowLocalConnection())
{
if (!markFile.exists() && SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
if (systemType != null) {
@ -134,7 +116,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
}
}
}
//System.err.println("InitRSEJob done"); //$NON-NLS-1$
return Status.OK_STATUS;
}

View file

@ -39,18 +39,25 @@
* Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe
* David Dykstal (IBM) - [210537] removed exception handling for SystemHostPool, no longer needed
* Martin Oberhuber (Wind River) - [216266] improved non-forced getSubSystems() code, removed getSubSystemsLazily()
* David Dykstal (IBM) - [197036] wrapped createHost to commit changes only once
* rewrote createHost to better pick default subsystem configurations to activate
* rewrote getSubSystemConfigurationsBySystemType to be able to delay the creation (and loading) of subsystem configurations
********************************************************************************/
package org.eclipse.rse.ui.internal.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants;
@ -90,6 +97,7 @@ import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.core.model.ISystemProfileOperation;
import org.eclipse.rse.internal.core.model.SystemHostPool;
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.core.model.SystemModelChangeEventManager;
@ -108,6 +116,8 @@ import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.swt.widgets.Display;
import com.ibm.icu.text.MessageFormat;
/**
* Registry for all connections.
*/
@ -206,7 +216,9 @@ public class SystemRegistry implements ISystemRegistry
*/
public Object[] getConnectionChildren(IHost selectedConnection)
{
return getSubSystems(selectedConnection);
// DWD shouldn't this be "getHostChildren"? Its part of the ISystemViewInputProvider interface.
Object[] result = getSubSystems(selectedConnection);
return result;
}
/**
* This method is called by the connection adapter when deciding to show a plus-sign
@ -321,64 +333,45 @@ public class SystemRegistry implements ISystemRegistry
* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemConfigurationsBySystemType(org.eclipse.rse.core.IRSESystemType, boolean)
*/
/**
* @deprecated Use {@link #getSubSystemConfigurationsBySystemType(IRSESystemType,boolean,boolean)} instead
*/
public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemFactories)
{
List serviceTypesAdded = new ArrayList();
List serviceImplsAdded = new ArrayList();
Vector v = new Vector();
if (subsystemConfigurationProxies != null)
{
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
{
ISubSystemConfigurationProxy ssfProxy = subsystemConfigurationProxies[idx];
if (ssfProxy.appliesToSystemType(systemType))
{
ISubSystemConfiguration ssFactory = ssfProxy.getSubSystemConfiguration();
if (ssFactory != null)
{
if (ssFactory instanceof IServiceSubSystemConfiguration && filterDuplicateServiceSubSystemFactories)
{
IServiceSubSystemConfiguration serviceFactory = (IServiceSubSystemConfiguration)ssFactory;
Class serviceType = serviceFactory.getServiceType();
Class serviceImplType = serviceFactory.getServiceImplType();
boolean containsThisServiceType = serviceTypesAdded.contains(serviceType);
boolean containsThisServiceImplType = serviceImplsAdded.contains(serviceImplType);
if (!containsThisServiceType)
{
serviceTypesAdded.add(serviceType);
serviceImplsAdded.add(serviceImplType);
v.addElement(ssFactory);
}
else if (containsThisServiceImplType)
{
// remove the other one
for (int i = 0; i < v.size(); i++)
{
if (v.get(i) instanceof IServiceSubSystemConfiguration)
{
IServiceSubSystemConfiguration addedConfig = (IServiceSubSystemConfiguration)v.get(i);
if (addedConfig.getServiceType() == serviceType)
{
v.remove(addedConfig);
}
}
return getSubSystemConfigurationsBySystemType(systemType, filterDuplicateServiceSubSystemFactories, true);
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemConfigurationsBySystemType(org.eclipse.rse.core.IRSESystemType, boolean)
*/
public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, final boolean filterDuplicates, boolean activate) {
List configurations = new ArrayList();
if (subsystemConfigurationProxies != null) {
Set serviceTypes = new HashSet();
// Set serviceImplsAdded = new HashSet();
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) {
ISubSystemConfigurationProxy subsystemConfigurationProxy = subsystemConfigurationProxies[idx];
if (subsystemConfigurationProxy.appliesToSystemType(systemType)) {
if (activate || subsystemConfigurationProxy.isSubSystemConfigurationActive()) {
ISubSystemConfiguration configuration = subsystemConfigurationProxy.getSubSystemConfiguration();
if (configuration != null) { // could happen if activate fails
if (filterDuplicates && configuration instanceof IServiceSubSystemConfiguration) {
IServiceSubSystemConfiguration service = (IServiceSubSystemConfiguration) configuration;
Class serviceType = service.getServiceType();
if (!serviceTypes.contains(serviceType)) {
serviceTypes.add(serviceType);
configurations.add(configuration);
}
v.addElement(ssFactory);
} else {
configurations.add(configuration);
}
}
else
{
v.addElement(ssFactory);
}
}
}
}
}
ISubSystemConfiguration[] factories = (ISubSystemConfiguration[])v.toArray(new ISubSystemConfiguration[v.size()]);
return factories;
ISubSystemConfiguration[] result = (ISubSystemConfiguration[]) configurations.toArray(new ISubSystemConfiguration[configurations.size()]);
return result;
}
@ -875,70 +868,53 @@ public class SystemRegistry implements ISystemRegistry
return pool.getSystemProfile();
}
public IConnectorService[] getConnectorServices(IHost conn)
{
List csList = new ArrayList();
// DKM for now, I'll just use the subsystems to get at the systems
// but later with new model, we should be getting these directly
ISubSystem[] sses = getSubSystems(conn);
for (int i = 0; i < sses.length; i++)
{
ISubSystem ss = sses[i];
IConnectorService service = ss.getConnectorService();
if (!csList.contains(service))
{
csList.add(service);
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getConnectorServices(org.eclipse.rse.core.model.IHost)
*/
public IConnectorService[] getConnectorServices(IHost host) {
List services = new ArrayList();
ISubSystem[] subsystems = getSubSystems(host);
for (int i = 0; i < subsystems.length; i++) {
ISubSystem subsystem = subsystems[i];
IConnectorService service = subsystem.getConnectorService();
if (!services.contains(service)) {
services.add(service);
}
}
return (IConnectorService[])csList.toArray(new IConnectorService[csList.size()]);
return (IConnectorService[]) services.toArray(new IConnectorService[services.size()]);
}
/**
* Return list of subsystem objects for a given connection.
* Demand pages the subsystem factories into memory if they aren't already.
* <p>
* To protect against crashes, if there are no subsystems, an array of length zero is returned.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost, boolean)
*/
public ISubSystem[] getSubSystems(IHost conn)
{
return getSubSystems(conn, ISubSystemConfiguration.FORCE_INTO_MEMORY);
public ISubSystem[] getSubSystems(IHost host, boolean force) {
return getSubSystems(host);
}
/**
* Return list of subsystem objects for a given connection.
* Demand pages the subsystem factories into memory if they aren't already.
* <p>
* To protect against crashes, if there are no subsystems, an array of length zero is returned.
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost)
*/
public ISubSystem[] getSubSystems(IHost conn, boolean force)
{
ISubSystem[] subsystems = null;
if (subsystemConfigurationProxies != null)
{
List v = new ArrayList();
for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
{
if (!force && !subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) {
//avoid instantiation if not forced.
continue;
}
if (subsystemConfigurationProxies[idx].appliesToSystemType(conn.getSystemType()))
{
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
if (factory != null)
{
ISubSystem[] sss = factory.getSubSystems(conn, force);
if (sss != null)
for (int jdx = 0; jdx < sss.length; jdx++)
v.add(sss[jdx]);
public ISubSystem[] getSubSystems(IHost host) {
IRSESystemType systemType = host.getSystemType();
List subsystems = new ArrayList();
if (subsystemConfigurationProxies != null) {
for (int i = 0; i < subsystemConfigurationProxies.length; i++) {
ISubSystemConfigurationProxy proxy = subsystemConfigurationProxies[i];
if (proxy.appliesToSystemType(systemType)) {
if (proxy.isSubSystemConfigurationActive()) {
ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
ISubSystem[] ssArray = config.getSubSystems(host, false);
if (ssArray == null) { // create a subsystem for this connection and config
ssArray = this.createSubSystems(host, new ISubSystemConfiguration[] {config});
}
subsystems.addAll(Arrays.asList(ssArray));
}
}
}
subsystems = (ISubSystem[])v.toArray(new ISubSystem[v.size()]);
}
return subsystems;
ISubSystem[] result = new ISubSystem[subsystems.size()];
subsystems.toArray(result);
return result;
}
/**
@ -1147,12 +1123,15 @@ public class SystemRegistry implements ISystemRegistry
dataStream.append("."); //$NON-NLS-1$
dataStream.append(connectionName);
return dataStream.toString();
}
public ISubSystem[] getSubsystems(IHost connection, Class subsystemInterface)
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubsystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
*/
public ISubSystem[] getSubsystems(IHost host, Class subsystemInterface)
{
List matches = new ArrayList();
ISubSystem[] allSS = connection.getSubSystems();
ISubSystem[] allSS = getSubSystems(host);
for (int i = 0; i < allSS.length; i++)
{
ISubSystem ss = allSS[i];
@ -1164,10 +1143,13 @@ public class SystemRegistry implements ISystemRegistry
return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]);
}
public ISubSystem[] getServiceSubSystems(IHost connection, Class serviceType)
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getServiceSubSystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
*/
public ISubSystem[] getServiceSubSystems(IHost host, Class serviceType)
{
List matches = new ArrayList();
ISubSystem[] allSS = connection.getSubSystems();
ISubSystem[] allSS = getSubSystems(host);
for (int i = 0; i < allSS.length; i++)
{
ISubSystem ss = allSS[i];
@ -1187,9 +1169,9 @@ public class SystemRegistry implements ISystemRegistry
* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemsBySubSystemConfigurationCategory(java.lang.String, org.eclipse.rse.core.model.IHost)
*/
public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost connection)
public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost host)
{
ISubSystem[] subsystems = getSubSystems(connection);
ISubSystem[] subsystems = getSubSystems(host);
if ((subsystems != null) && (subsystems.length > 0))
{
Vector v = new Vector();
@ -1658,82 +1640,116 @@ public class SystemRegistry implements ISystemRegistry
}
/**
* Create a connection object, given the connection pool and given all the possible attributes.
* <p>
* THE RESULTING CONNECTION OBJECT IS ADDED TO THE LIST OF EXISTING CONNECTIONS FOR YOU, IN
* THE PROFILE YOU SPECIFY. THE PROFILE IS ALSO SAVED TO DISK.
* Create a host object, given its host pool and its attributes.
* <p>
* This method:
* <ul>
* <li>creates and saves a new connection within the given profile
* <li>calls all subsystem factories to give them a chance to create a subsystem instance
* <li>fires an ISystemResourceChangeEvent event of type EVENT_ADD to all registered listeners
* <li>creates and saves a new connection within the given profile
* <li>calls all subsystem factories to give them a chance to create a subsystem instance
* <li>fires an ISystemResourceChangeEvent event of type EVENT_ADD to all registered listeners
* </ul>
* <p>
* @param profileName Name of the system profile the connection is to be added to.
* @param systemType system type matching one of the system types
* defined via the systemTypes extension point.
* @param connectionName unique connection name.
* @param hostName ip name of host.
* @param systemType system type matching one of the system types defined via the systemTypes extension point.
* @param hostName unique connection name.
* @param hostAddress IP name of host.
* @param description optional description of the connection. Can be null.
* @param defaultUserId userId to use as the default for the subsystems.
* @param defaultUserIdLocation one of the constants in {@link org.eclipse.rse.core.IRSEUserIdConstants}
* that tells us where to set the user Id
* that tells us where to set the user Id
* @param createSubSystems <code>true</code> to create subsystems for the host, <code>false</code> otherwise.
* @param newConnectionWizardPages when called from the New Connection wizard this is union of the list of additional
* wizard pages supplied by the subsystem factories that pertain to the specified system type. Else null.
* wizard pages supplied by the subsystem factories that pertain to the specified system type. Else null.
* @return SystemConnection object, or null if it failed to create. This is typically
* because the connectionName is not unique. Call getLastException() if necessary.
* because the connectionName is not unique. Call getLastException() if necessary.
*/
public IHost createHost(
String profileName,
IRSESystemType systemType,
String connectionName,
String hostName,
String description,
String defaultUserId,
int defaultUserIdLocation,
boolean createSubSystems,
ISystemNewConnectionWizardPage[] newConnectionWizardPages)
throws Exception {
lastException = null;
ISystemHostPool pool = getHostPool(profileName);
IHost conn = null;
boolean promptable = false; // systemType.equals(IRSESystemType.SYSTEMTYPE_PROMPT);
try
{
// create, register and save new connection...
if ((defaultUserId != null) && (defaultUserId.length() == 0))
defaultUserId = null;
conn = pool.createHost(systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation);
if (conn == null) // conn already exists
{
conn = pool.getHost(connectionName);
// FIXME need to remove ISystemNewConnectionWizardPage[] from this and replace with IAdaptable[]
public IHost createHost(final String profileName, final IRSESystemType systemType, final String hostName,
final String hostAddress, final String description, final String defaultUserId,
final int defaultUserIdLocation, final boolean createSubSystems,
final ISystemNewConnectionWizardPage[] newConnectionWizardPages) throws Exception {
final ISystemRegistry sr = this;
class CreateHostOperation implements ISystemProfileOperation {
private IHost host = null;
private ISubSystem[] subsystems = new ISubSystem[0];
IHost getHost() {
return host;
}
if (promptable)
conn.setPromptable(true);
}
catch (Exception exc)
{
lastException = exc;
SystemBasePlugin.logError("Exception in createConnection for " + connectionName, exc); //$NON-NLS-1$
throw exc;
}
if ((lastException == null) && !promptable && createSubSystems) {
// only 1 factory used per service type
ISubSystemConfiguration[] factories = getSubSystemConfigurationsBySystemType(systemType, true);
ISubSystem subSystems[] = new ISubSystem[factories.length];
for (int idx = 0; idx < factories.length; idx++) {
ISubSystemConfiguration factory = factories[idx];
ISystemNewConnectionWizardPage[] interestingPages = getApplicableWizardPages(factory, newConnectionWizardPages);
subSystems[idx] = factory.createSubSystem(conn, true, interestingPages); // give it the opportunity to create a subsystem
public ISubSystem[] getSubSystems() {
return subsystems;
}
public IStatus run() {
IStatus status = Status.OK_STATUS;
ISystemHostPool pool = getHostPool(profileName);
try {
// create, register and save new connection...
String uid = defaultUserId;
if ((uid != null) && (uid.length() == 0)) {
uid = null;
}
host = pool.createHost(systemType, hostName, hostAddress, description, uid, defaultUserIdLocation);
if (host == null) { // did not create since host already exists
host = pool.getHost(hostName);
}
} catch (Exception e) {
String pluginId = RSEUIPlugin.getDefault().getSymbolicName();
String message = MessageFormat.format("Exception in createHost for {0}", new Object[] {hostName});
status = new Status(IStatus.ERROR, pluginId, message, e);
}
if (status.isOK()) {
if (createSubSystems) {
// determine the list of configs to use to create subsystems from
List configs = new ArrayList(10); // arbitrary but reasonable
if (newConnectionWizardPages != null) {
// if there are wizard pages need to at least use those
for (int i = 0; i < newConnectionWizardPages.length; i++) {
configs.add(newConnectionWizardPages[i].getSubSystemConfiguration());
}
// add any non-service subsystem configs that aren't already there that apply to this systemtype
ISubSystemConfiguration[] configsArray = getSubSystemConfigurationsBySystemType(systemType, false);
for (int i = 0; i < configsArray.length; i++) {
ISubSystemConfiguration config = configsArray[i];
boolean isStrange = !(config instanceof IServiceSubSystemConfiguration);
boolean isAbsent = !configs.contains(config);
if (isStrange && isAbsent) {
configs.add(config);
}
}
} else {
// just get the defaults with the service subsystems filtered
ISubSystemConfiguration[] configsArray = getSubSystemConfigurationsBySystemType(systemType, true);
configs = Arrays.asList(configsArray);
}
// only subsystem configuration is used per service type
subsystems = new ISubSystem[configs.size()];
ISystemProfile profile = host.getSystemProfile();
int i = 0;
for (Iterator z = configs.iterator(); z.hasNext();) {
ISubSystemConfiguration config = (ISubSystemConfiguration) z.next();
config.getFilterPoolManager(profile, true); // create the filter pool
ISystemNewConnectionWizardPage[] interestingPages = getApplicableWizardPages(config, newConnectionWizardPages);
subsystems[i] = config.createSubSystem(host, true, interestingPages); // give it the opportunity to create a subsystem
i++;
}
}
host.commit();
}
return status;
}
FireNewHostEvents fire = new FireNewHostEvents(conn, subSystems, this);
Display.getDefault().asyncExec(fire);
}
conn.commit();
CreateHostOperation op = new CreateHostOperation();
IStatus status = SystemProfileManager.run(op);
lastException = (Exception) status.getException();
if (lastException != null) {
SystemBasePlugin.logError(status.getMessage(), lastException);
throw lastException;
}
IHost host = op.getHost();
ISubSystem[] subsystems = op.getSubSystems();
FireNewHostEvents fire = new FireNewHostEvents(host, subsystems, sr);
Display.getDefault().asyncExec(fire);
SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
return conn;
return host;
}
/*
@ -1949,33 +1965,12 @@ public class SystemRegistry implements ISystemRegistry
return createHost(profileName, systemType, connectionName, hostName, description, true);
}
/**
* Create a connection object. This is a simplified version
* <p>
* THE RESULTING CONNECTION OBJECT IS ADDED TO THE LIST OF EXISTING CONNECTIONS FOR YOU, IN
* THE PROFILE YOU SPECIFY. THE PROFILE IS ALSO SAVED TO DISK.
* <p>
* This method:
* <ul>
* <li>creates and saves a new connection within the given profile
* <li>optionally calls all subsystem factories to give them a chance to create subsystem instances
* <li>fires an ISystemResourceChangeEvent event of type EVENT_ADD to all registered listeners
* </ul>
* <p>
* @param profileName Name of the system profile the connection is to be added to.
* @param systemType system type matching one of the system types
* defined via the systemTypes extension point.
* @param connectionName unique connection name.
* @param hostName ip name of host.
* @param description optional description of the connection. Can be null.
* @param createSubSystems <code>true</code> to create subsystems for the host, <code>false</code> otherwise.
* @return SystemConnection object, or null if it failed to create. This is typically
* because the connectionName is not unique. Call getLastException() if necessary.
* @since 2.0
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, boolean)
*/
public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description, boolean createSubSystems) throws Exception
{
return createHost(profileName, systemType, connectionName, hostName, description, null, IRSEUserIdConstants.USERID_LOCATION_HOST, null);
return createHost(profileName, systemType, connectionName, hostName, description, null, IRSEUserIdConstants.USERID_LOCATION_HOST, createSubSystems, null);
}
/*
@ -2318,7 +2313,7 @@ public class SystemRegistry implements ISystemRegistry
public boolean isAnySubSystemConnected(IHost conn)
{
boolean any = false;
ISubSystem[] subsystems = getSubSystems(conn, false);
ISubSystem[] subsystems = getSubSystems(conn);
if (subsystems == null)
return false;
for (int idx = 0; !any && (idx < subsystems.length); idx++)
@ -2352,7 +2347,7 @@ public class SystemRegistry implements ISystemRegistry
return false;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#areAllSubSystemsConnected(org.eclipse.rse.core.model.IHost)
@ -2394,7 +2389,7 @@ public class SystemRegistry implements ISystemRegistry
public void disconnectAllSubSystems(IHost conn)
{
// get subsystems lazily, because not instantiated ones cannot be disconnected anyways.
ISubSystem[] subsystems = getSubSystems(conn, false);
ISubSystem[] subsystems = getSubSystems(conn);
if (subsystems == null)
return;

View file

@ -28,13 +28,19 @@
* David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect()
* David McKnight (IBM) - [211472] [api][breaking] IRemoteObjectResolver.getObjectWithAbsoluteName() needs a progress monitor
* David McKnight (IBM) - [212403] [apidoc][breaking] Fixing docs of SubSystem#getConnectorService() and making internalConnect() private
* David Dykstal (IBM) - [197036] pulled up subsystem configuration switching logic from the service subsystem layer
* implemented IServiceSubSystem here so that subsystem configuration switching can be
* made common among all service subsystems.
********************************************************************************/
package org.eclipse.rse.core.subsystems;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.core.resources.IResource;
@ -51,6 +57,7 @@ import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
@ -69,6 +76,9 @@ import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.internal.core.model.ISystemProfileOperation;
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.GenericMessages;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
@ -122,7 +132,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
*/
public abstract class SubSystem extends RSEModelObject
implements IAdaptable, ISubSystem,
implements IAdaptable, ISubSystem, IServiceSubSystem,
ISystemFilterPoolReferenceManagerProvider
{
@ -175,6 +185,8 @@ public abstract class SubSystem extends RSEModelObject
*/
protected ISystemFilterPoolReferenceManager filterPoolReferenceManager = null;
private Map poolReferencesMap = new HashMap();
private class NullRunnableContext implements IRunnableContext {
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
IProgressMonitor monitor = new NullProgressMonitor();
@ -2958,7 +2970,7 @@ public abstract class SubSystem extends RSEModelObject
{
ISubSystem firstSS = null;
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] sses = registry.getSubSystems(getHost(), false);
ISubSystem[] sses = registry.getSubSystems(getHost());
for (int i = 0; i < sses.length; i++)
{
ISubSystem ss = sses[i];
@ -3049,4 +3061,131 @@ public abstract class SubSystem extends RSEModelObject
return result;
}
/* Service Subsystem support */
/**
* Perform the subsystem specific processing required to complete a subsystem configuration switch for a
* service subsystem. The subsystem will typically query this configuration for interesting properties or
* policies. It should also reset any state to a fresh start.
* This supplied implementation does nothing. Subclasses may override if they implement a service subsystem.
* @param newConfiguration the configuration this subsystem should use from this point.
*/
protected void internalSwitchServiceSubSystemConfiguration(IServiceSubSystemConfiguration newConfiguration) {
}
/**
* Determine if a service subsystem is capable of switching to this new configuration.
* This is usually a test of this configuration's type against the type expected by this subsystem.
* This supplied implementation returns false. Subclasses should override if they implement a service subsystem.
* @param configuration the configuration to which this subsystem may switch
* @return true if this subsystem is capable of switching to this configuration, false otherwise. This implementation
* returns false.
* @see IServiceSubSystem#canSwitchTo(IServiceSubSystemConfiguration)
*/
public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
return false;
}
/**
* Switch to use another subsystem configuration. This default implementation will test if the subsystem is a
* service subsystem and if the subsystem is compatible with the suggested configuration. If it is the switch will
* be performed and internalSwitchSubSystemConfiguration will be called.
* @see IServiceSubSystem#switchServiceFactory(IServiceSubSystemConfiguration)
* @see #internalSwitchServiceSubSystemConfiguration(IServiceSubSystemConfiguration)
*/
public void switchServiceFactory(final IServiceSubSystemConfiguration config) {
if (config != getSubSystemConfiguration() && canSwitchTo(config)) {
// define the operation to be executed
ISystemProfileOperation op = new ISystemProfileOperation() {
public IStatus run() {
doSwitchServiceConfiguration(config);
return Status.OK_STATUS;
}
};
// execute the operation in a commit guard
SystemProfileManager.run(op);
}
}
/**
* Return the service type for this subsystem.
* @return the default implementation returns null. Subclasses that implement service subsystems
* should return a type as specified in the interface.
* @see org.eclipse.rse.core.subsystems.IServiceSubSystem#getServiceType()
*/
public Class getServiceType() {
return null;
}
/**
* Actually perform the switch inside the commit guard
* @param newConfig
*/
private void doSwitchServiceConfiguration(IServiceSubSystemConfiguration newConfig) {
try {
disconnect();
} catch (Exception e) {
}
IHost host = getHost();
// remove the old references and store them for later use
ISubSystemConfiguration oldConfig = getSubSystemConfiguration();
if (oldConfig.supportsFilters()) {
ISystemFilterPoolReferenceManager fprm = getSystemFilterPoolReferenceManager();
List poolReferences = Arrays.asList(fprm.getSystemFilterPoolReferences());
poolReferencesMap.put(oldConfig, poolReferences);
for (Iterator z = poolReferences.iterator(); z.hasNext();) {
ISystemFilterPoolReference poolReference = (ISystemFilterPoolReference) z.next();
fprm.removeSystemFilterPoolReference(poolReference, true);
}
fprm.setSystemFilterPoolManagerProvider(null);
}
setSubSystemConfiguration(newConfig);
setConfigurationId(newConfig.getId());
setName(newConfig.getName());
// add the new pools to the manager
if (newConfig.supportsFilters()) {
ISystemFilterPoolReferenceManager fprm = getSystemFilterPoolReferenceManager();
fprm.setSystemFilterPoolManagerProvider(newConfig);
List poolReferences = (List) poolReferencesMap.get(newConfig);
if (poolReferences == null) {
// create default pools
ISystemProfile profile = host.getSystemProfile();
ISystemFilterPoolManager poolManager = newConfig.getFilterPoolManager(profile, true); // get and initialize the new filter pool manager
int eventType = ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED;
int resourceType = ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION;
ISystemModelChangeEvent event = new SystemModelChangeEvent(eventType, resourceType, host);
RSECorePlugin.getTheSystemRegistry().fireEvent(event); // signal a model change event as well
// create references to those pools
fprm.setDefaultSystemFilterPoolManager(poolManager);
ISystemFilterPool[] pools = poolManager.getSystemFilterPools();
for (int i = 0; i < pools.length; i++) {
ISystemFilterPool pool = pools[i];
fprm.addReferenceToSystemFilterPool(pool);
}
} else { // use the found pools
for (Iterator z = poolReferences.iterator(); z.hasNext();) {
ISystemFilterPoolReference poolReference = (ISystemFilterPoolReference) z.next();
fprm.addSystemFilterPoolReference(poolReference);
}
fprm.resolveReferencesAfterRestore();
}
filterEventFilterPoolReferencesReset(); // signal a resource change event
}
// switch the connector service
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = newConfig.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
// call the subsystem specfic switching support
internalSwitchServiceSubSystemConfiguration(newConfig);
// commit the subsystem
setDirty(true);
commit();
}
}

View file

@ -25,6 +25,8 @@
* Rupen Mardirossian (IBM) - [189434] Move Up/Down on Filters Error
* Kevin Doyle (IBM) - [190445] Set Position of cloned event in cloneEvent()
* Martin Oberhuber (Wind River) - [195392] Avoid setting port 0 in initializeSubSystem()
* David Dykstal (IBM) - [197036] rewrote getFilterPoolManager to delay the creation of default filter pools until the corresponding
* a subsystem configuration is actually used for a host.
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -67,6 +69,7 @@ import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
@ -632,31 +635,20 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
// SUBSYSTEM METHODS...
// ---------------------------------
/**
* Called by SystemRegistry's renameSystemProfile method to ensure we update our
* subsystem names within each subsystem.
* <p>
* This is called AFTER changing the profile's name!!
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#renameSubSystemProfile(org.eclipse.rse.core.subsystems.ISubSystem, java.lang.String, java.lang.String)
*/
public void renameSubSystemProfile(ISubSystem ss, String oldProfileName, String newProfileName)
{
//RSEUIPlugin.logDebugMessage(this.getClass().getName(), "Inside renameSubSystemProfile. newProfileName = "+newProfileName+", old ssName = "+ss.getName());
//renameFilterPoolManager(getSystemProfile(newProfileName)); // update filter pool manager name
ss.renamingProfile(oldProfileName, newProfileName);
ISystemFilterPoolReferenceManager sfprm = ss.getSystemFilterPoolReferenceManager();
if (sfprm != null)
{
sfprm.regenerateReferencedSystemFilterPoolNames(); // ask it to re-ask each pool for its reference name
public void renameSubSystemProfile(ISubSystem subsystem, String oldProfileName, String newProfileName) {
subsystem.renamingProfile(oldProfileName, newProfileName);
ISystemFilterPoolReferenceManager sfprm = subsystem.getSystemFilterPoolReferenceManager();
if (sfprm != null) {
sfprm.regenerateReferencedSystemFilterPoolNames(); // ask it to re-ask each pool for its reference name
}
try
{
saveSubSystem(ss);
try {
saveSubSystem(subsystem);
} catch (Exception exc) {
RSECorePlugin.getDefault().getLogger().logError("Unexpected error saving subsystem.", exc); //$NON-NLS-1$
}
catch (Exception exc)
{
// already dealt with in save?
}
}
/**
@ -1015,9 +1007,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
try
{
saveSubSystem(subsys);
//DKM - save this event til all the processing is done!
// fire model change event in case any BP code is listening...
//RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsys, null);
RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsys, null);
}
catch (Exception exc)
{
@ -1597,79 +1587,55 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
}
return activeManagers;
}
/**
* Get the filter pool manager for the given profile
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#getFilterPoolManager(org.eclipse.rse.core.model.ISystemProfile)
*/
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile)
{
// it is important to key by profile object not profile name, since that
// name can change but the object never should for any one session.
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile) {
return getFilterPoolManager(profile, false);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#getFilterPoolManager(org.eclipse.rse.core.model.ISystemProfile, boolean)
*/
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile, boolean force) {
// it is important to key by profile object not profile name, since that name can change but the object never should for any one session.
ISystemFilterPoolManager mgr = (ISystemFilterPoolManager) filterPoolManagersPerProfile.get(profile);
//System.out.println("in getFilterPoolManager for ssfactory "+getId()+" for profile " + profile.getName() + ", mgr found? " + (mgr!=null));
if (mgr == null)
{
try
{
mgr = SystemFilterPoolManager.createSystemFilterPoolManager(profile, RSECorePlugin.getDefault().getLogger(), this, // the caller
getFilterPoolManagerName(profile), // the filter pool manager name
supportsNestedFilters(), // whether or not nested filters are allowed
ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_FILTER, filterNamingPolicy);
mgr.setSingleFilterStringOnly(!supportsMultipleFilterStrings()); // DWD was restored flag?
}
catch (Exception exc)
{
if (mgr == null) {
try {
Logger logger = RSECorePlugin.getDefault().getLogger();
String managerName = getFilterPoolManagerName(profile);
boolean supportsNested = supportsNestedFilters();
int savePolicy = ISystemFilterSavePolicies.SAVE_POLICY_ONE_FILE_PER_FILTER;
mgr = SystemFilterPoolManager.createSystemFilterPoolManager(profile, logger, this, managerName, supportsNested, savePolicy, filterNamingPolicy);// the filter pool manager name
mgr.setSingleFilterStringOnly(!supportsMultipleFilterStrings());
mgr.setWasRestored(false); // not yet initialized
} catch (Exception exc) {
SystemBasePlugin.logError("Restore/Creation of SystemFilterPoolManager " + getFilterPoolManagerName(profile) + " failed!", exc); //$NON-NLS-1$ //$NON-NLS-2$
SystemMessageDialog.displayExceptionMessage(null, exc);
return null; // something very bad happend!
return null; // something very bad happened!
}
addFilterPoolManager(profile, mgr);
boolean restored = mgr.wasRestored();
//System.out.println("...after createSystemFilterPoolManager for " + mgr.getName() + ", restored = " + restored);
// allow subclasses to create default filter pool...
if (!restored)
{
ISystemFilterPool defaultPool = createDefaultFilterPool(mgr);
if (defaultPool != null)
{
defaultPool.setDefault(true);
try
{
defaultPool.commit();
}
catch (Exception exc)
{
}
}
}
boolean initialized = mgr.wasRestored();
if (force && !initialized) {
String defaultPoolName = getDefaultFilterPoolName(profile.getName(), getId());
ISystemFilterPool defaultPool = mgr.getSystemFilterPool(defaultPoolName);
if (defaultPool == null) {
// allow subclasses to create default filter pool...
defaultPool = createDefaultFilterPool(mgr); // createDefaultFilterPool(mgr) is typically overridden by subclasses
}
// else filter pools restored for this profile. Allow subclasses chance to do post-processing,
// such as any migration needed
else
{
if (doPostRestoreProcessing(mgr))
{
try
{
mgr.commit();
}
catch (Exception exc)
{
}
}
if (defaultPool != null) {
defaultPool.setDefault(true);
defaultPool.commit();
}
// these should be inside the above logic but we need them outside for now because they were
// added late and there are existing filter pool managers that need this to be set for.
// In a future release we should move them inside the if (!restored) logic. Phil.
if (supportsDuplicateFilterStrings())
mgr.setSupportsDuplicateFilterStrings(true);
if (isCaseSensitive())
mgr.setStringsCaseSensitive(isCaseSensitive());
if (supportsDuplicateFilterStrings()) mgr.setSupportsDuplicateFilterStrings(true);
if (isCaseSensitive()) mgr.setStringsCaseSensitive(true);
mgr.setWasRestored(true);
}
return mgr;
}
/**
* Do post-restore-processing of an existing filter pool manager.
* This is where child classes do any required migration work. By default, we do nothing.