1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,7 +12,8 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * 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; package org.eclipse.rse.core.filters;
@ -237,19 +238,13 @@ public interface ISystemFilterPoolManager extends IRSEPersistableContainer {
public boolean preTestRenameFilterPool(ISystemFilterPool pool) throws Exception; public boolean preTestRenameFilterPool(ISystemFilterPool pool) throws Exception;
/** /**
* Rename a given filter pool. Dependending on the save policy, the * Rename a filter pool.
* appropriate file or folder on disk will also be renamed.
* <p>
* Does the following:
* <ul> * <ul>
* <li>Renames referencing objects * <li>Renames pool object
* <li>Renames pool object in the in-memory model * <li>Informs any filter pool references to this pool
* <li>Renames folder on disk for policies of one folder per pool * <li>Schedules a save of the pool object
* <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
* </ul> * </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 * @param newName The new name to give the pool
*/ */
public void renameSystemFilterPool(ISystemFilterPool pool, String newName) throws Exception; public void renameSystemFilterPool(ISystemFilterPool pool, String newName) throws Exception;

View file

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

View file

@ -13,11 +13,12 @@
* Contributors: * Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * 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; package org.eclipse.rse.core.model;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.persistence.IRSEPersistenceProvider; import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -46,12 +47,6 @@ public interface ISystemProfile extends IRSEModelObject {
*/ */
public ISystemProfileManager getProfileManager(); 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 * @return The value of the Name attribute
*/ */
@ -81,7 +76,7 @@ public interface ISystemProfile extends IRSEModelObject {
public IHost[] getHosts(); public IHost[] getHosts();
/** /**
* Return all filter pools for this profile * @return all existing filter pools for this profile.
*/ */
public ISystemFilterPool[] getFilterPools(); public ISystemFilterPool[] getFilterPools();

View file

@ -11,11 +11,13 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * David Dykstal (IBM) - [197036] added commitSystemProfile operation to interface
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
import org.eclipse.core.runtime.IStatus;
/** /**
* Manages a list of SystemProfile objects. System profiles * Manages a list of SystemProfile objects. System profiles
* should be created, deleted, restored, activated, and deactivated though * should be created, deleted, restored, activated, and deactivated though
@ -109,6 +111,13 @@ public interface ISystemProfileManager {
*/ */
public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName); 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. * Get an indication of whether a profile is active or not.
* @param profileName the name of the profile to test * @param profileName the name of the profile to test

View file

@ -20,6 +20,8 @@
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
* Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
* David McKnight (IBM) - [207100] adding ISystemRegistry.isRegisteredSystemRemoteChangeListener * 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; 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. * 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 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... // SYSTEMVIEWINPUTPROVIDER METHODS...
@ -211,59 +228,52 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
public void setSystemProfileActive(ISystemProfile profile, boolean makeActive); public void setSystemProfileActive(ISystemProfile profile, boolean makeActive);
/** /**
* Return the list of connector services provided for the given host * Return the list of connector services currently configured for the given host
* @param conn the host * @param host the host
* @return the list of connector services * @return the list of connector services
*/ */
public IConnectorService[] getConnectorServices(IHost conn); public IConnectorService[] getConnectorServices(IHost host);
// ---------------------------- // ----------------------------
// SUBSYSTEM METHODS... // SUBSYSTEM METHODS...
// ---------------------------- // ----------------------------
/** /**
* Return list of subsystem objects for a given connection. If the subsystems have * Return list of subsystem objects for a given host.
* not all been read into memory, this loads them up * @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 * Return list of subsystem objects for a given connection.
* flag to indicate whether or not to restore from disk * @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, * Get those subsystems that are registered against a given connection,
* which are an instance of the given interface class. * 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> * </p>
* @param connection the connection to check * @param host the connection to check
* @param subsystemInterface the interface class to filter against * @param subsystemInterface the interface class to filter against
* @return list of matching subsystems * @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, * Get those subsystems that are registered against a given connection,
* which are an instance of ServiceSubSystem for the given serviceType. * 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> * </p>
* @param connection the connection to check * @param host the host to check
* @param serviceType the class of service to ask for * @param serviceType the class of service to ask for
* @return list of matching subsystems * @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 * 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) * 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 * @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 * 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)} * that are really needed. Then, use {@link ISubSystemConfiguration#getSubSystems(boolean)}
* with a parameter true. * 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 * Delete a subsystem object. This code finds the factory that owns it and
@ -506,6 +516,26 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
*/ */
public IHost createHost(IRSESystemType systemType, String connectionName, String hostAddress, String description) throws Exception; 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. * Update an existing host given the new information.
* This method: * This method:

View file

@ -12,13 +12,44 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * David Dykstal (IBM) - [197036] added javadoc and canSwitchTo method.
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.core.subsystems; 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 { 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 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) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core * 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; package org.eclipse.rse.core.subsystems;
@ -34,7 +35,7 @@ import org.eclipse.rse.core.model.ISystemProfile;
* *
* <p> * <p>
* This interface is not intended to be implemented by clients. Subsystem * 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. * rather than implementing this interface directly.
* </p> * </p>
*/ */
@ -352,10 +353,12 @@ public interface ISubSystemConfiguration extends ISystemFilterPoolManagerProvide
/** /**
* Called by SystemRegistry's renameSystemProfile method to ensure we update our * Called by SystemRegistry's renameSystemProfile method to ensure we update our
* subsystem names within each subsystem. * subsystem names within each subsystem.
* <p> * This should be invoked after changing the profile's name.
* This is called 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 * 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... // 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); public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile);

View file

@ -12,6 +12,7 @@
* *
* Contributors: * Contributors:
* David Dykstal (IBM) - 142806: refactoring persistence framework * 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; 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. * This class is not intended to be subclassed by clients.
*/ */
public class SystemFilterPoolManager extends RSEPersistableObject implements ISystemFilterPoolManager { 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 ISystemFilterPoolManagerProvider caller = null;
private Object poolMgrData; private Object poolMgrData;
private Vector poolNames; // private Vector poolNames;
private boolean initialized = false; private boolean initialized = false;
private boolean suspendCallbacks = 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 boolean singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT;
protected List pools = null; protected List pools = new ArrayList(3);
// protected List pools = null;
/** /**
* Constructor * Constructor
@ -210,7 +212,7 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
initialize(logger, caller, name); // core data initialize(logger, caller, name); // core data
} }
setSupportsNestedFilters(allowNestedFilters); // cascade it down setSupportsNestedFilters(allowNestedFilters); // cascade it down
invalidatePoolCache(); // invalidatePoolCache();
// List pools = getPools(); // List pools = getPools();
// ISystemFilterPool pool = null; // ISystemFilterPool pool = null;
// Vector poolNames = getSystemFilterPoolNamesVector(); // Vector poolNames = getSystemFilterPoolNamesVector();
@ -397,17 +399,20 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* Return array of SystemFilterPools managed by this manager. * Return array of SystemFilterPools managed by this manager.
*/ */
public ISystemFilterPool[] getSystemFilterPools() { public ISystemFilterPool[] getSystemFilterPools() {
//System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null)); ISystemFilterPool[] result = new ISystemFilterPool[pools.size()];
if ((poolArray == null) || (getPools().size() != poolArray.length)) { pools.toArray(result);
List pools = getPools(); return result;
poolArray = new ISystemFilterPool[pools.size()]; // //System.out.println("Inside getSFPools for mgr "+getName()+". poolArray null? "+(poolArray==null));
Iterator i = pools.iterator(); // if ((poolArray == null) || (getPools().size() != poolArray.length)) {
int idx = 0; // List pools = getPools();
while (i.hasNext()) // poolArray = new ISystemFilterPool[pools.size()];
poolArray[idx++] = (ISystemFilterPool) i.next(); // Iterator i = pools.iterator();
//System.out.println("Pool array created. length = "+poolArray.length); // int idx = 0;
} // while (i.hasNext())
return poolArray; // 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. * Get list of filter pool names currently existing.
*/ */
public Vector getSystemFilterPoolNamesVector() { public Vector getSystemFilterPoolNamesVector() {
List pools = getPools(); Vector result = new Vector(pools.size());
if ((poolNames == null) || (poolNames.size() != pools.size())) // been invalidated? for (Iterator z = pools.iterator(); z.hasNext();) {
{ ISystemFilterPool pool = (ISystemFilterPool) z.next();
poolNames = new Vector(); String poolName = pool.getName();
Iterator i = pools.iterator(); result.add(poolName);
while (i.hasNext())
poolNames.addElement(((ISystemFilterPool) i.next()).getName());
} }
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 * Call this to invalidate array cache after any activity
*/ */
private void invalidatePoolCache() { // private void invalidatePoolCache() {
poolArray = null; // poolArray = null;
poolNames = null; // poolNames = null;
} // }
/** /**
* Create a new filter pool. * Create a new filter pool.
@ -473,9 +485,9 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
pool.setSystemFilterPoolManager(this); pool.setSystemFilterPoolManager(this);
pool.setStringsCaseSensitive(areStringsCaseSensitive()); pool.setStringsCaseSensitive(areStringsCaseSensitive());
pool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings() && supportsDuplicateFilterStrings()); pool.setSupportsDuplicateFilterStrings(isSetSupportsDuplicateFilterStrings() && supportsDuplicateFilterStrings());
List pools = getPools(); // List pools = getPools();
pools.add(pool); pools.add(pool);
invalidatePoolCache(); // invalidatePoolCache();
commit(pool); commit(pool);
if ((caller != null) && !suspendCallbacks) { if ((caller != null) && !suspendCallbacks) {
caller.filterEventFilterPoolCreated(pool); caller.filterEventFilterPoolCreated(pool);
@ -501,63 +513,22 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* @param pool The filter pool object to physically delete * @param pool The filter pool object to physically delete
*/ */
public void deleteSystemFilterPool(ISystemFilterPool pool) throws Exception { public void deleteSystemFilterPool(ISystemFilterPool pool) throws Exception {
// remove all references
IRSEBaseReferencingObject[] refs = pool.getReferencingObjects(); IRSEBaseReferencingObject[] refs = pool.getReferencingObjects();
//boolean needsSave = false;
if (refs != null) { if (refs != null) {
for (int idx = 0; idx < refs.length; idx++) { for (int idx = 0; idx < refs.length; idx++) {
if (refs[idx] instanceof ISystemFilterPoolReference) { if (refs[idx] instanceof ISystemFilterPoolReference) {
ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference) refs[idx]; ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference) refs[idx];
ISystemFilterPoolReferenceManager fprMgr = fpRef.getFilterPoolReferenceManager(); 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); pools.remove(pool);
invalidatePoolCache(); _profile.setDirty(true);
_profile.commit();
/* FIXME getProvider().filterEventFilterPoolDeleted(pool);
// 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);
*/
} }
/** /**
@ -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 * Pre-test if we are going to run into any trouble renaming a filter pool.
* used to persist a filter pool. * @return true if the pool can be renamed.
* @return true if everything seems ok, false if a file/folder is in use.
*/ */
public boolean preTestRenameFilterPool(ISystemFilterPool pool) throws Exception { 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 * The default implementation returns true. Persistence providers should be able to handle this
* manager to see if the pool can be renamed. The provider is in charge of determining * circumstance regardless. If a pool can be renamed internally, it should be able to be
* pool names in the persistent form. The Manager will have to construct a DOM * renamed in its persistent form.
* 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);
}
}
*/ */
boolean ok = true;
return ok; return ok;
} }
/** /* (non-Javadoc)
* Rename a given filter pool. Dependending on the save policy, the * @see org.eclipse.rse.core.filters.ISystemFilterPoolManager#renameSystemFilterPool(org.eclipse.rse.core.filters.ISystemFilterPool, java.lang.String)
* 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
*/ */
public void renameSystemFilterPool(ISystemFilterPool pool, String newName) throws Exception { 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(); 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); pool.setName(newName);
invalidatePoolCache();
// inform all referencees // inform all referencees
IRSEBaseReferencingObject[] refs = pool.getReferencingObjects(); IRSEBaseReferencingObject[] refs = pool.getReferencingObjects();
if (refs != null) { 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 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) * @param delta the amount by which to move the filters (filterEventFiltersRePositioned)
*/ */
public void moveSystemFilters(ISystemFilter filters[], int delta) throws Exception { 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]; 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]); 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); 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); moveFilter(filters[idx], oldPositions[idx] + delta);
}
}
commit(filters[0].getParentFilterPool()); commit(filters[0].getParentFilterPool());
if ((caller != null) && !suspendCallbacks) {
// if caller provider, callback to inform them of this event 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. * Copy a system filter string to a filter in this or another filter pool manager.
*/ */
public ISystemFilterString copySystemFilterString(ISystemFilter targetFilter, ISystemFilterString oldFilterString) throws Exception { public ISystemFilterString copySystemFilterString(ISystemFilter targetFilter, ISystemFilterString oldFilterString) throws Exception {
/*
* DWD revisit this. make sure that pool is persisted.
*/
ISystemFilterPool targetPool = targetFilter.getParentFilterPool(); ISystemFilterPool targetPool = targetFilter.getParentFilterPool();
ISystemFilterPoolManager targetMgr = targetPool.getSystemFilterPoolManager(); ISystemFilterPoolManager targetMgr = targetPool.getSystemFilterPoolManager();
ISystemFilter oldFilter = oldFilterString.getParentSystemFilter(); ISystemFilter oldFilter = oldFilterString.getParentSystemFilter();
// ISystemFilterPool oldPool = oldFilter.getParentFilterPool();
targetMgr.suspendCallbacks(true); targetMgr.suspendCallbacks(true);
ISystemFilterString newFilterString = oldFilter.copySystemFilterString(targetFilter, oldFilterString); // creates it in memory ISystemFilterString newFilterString = oldFilter.copySystemFilterString(targetFilter, oldFilterString); // creates it in memory
commit(targetPool); // save updated pool to disk commit(targetPool); // save updated pool to disk
targetMgr.suspendCallbacks(false); targetMgr.suspendCallbacks(false);
targetMgr.getProvider().filterEventFilterStringCreated(newFilterString); targetMgr.getProvider().filterEventFilterStringCreated(newFilterString);
return newFilterString; return newFilterString;
} }
@ -1570,10 +1384,12 @@ public class SystemFilterPoolManager extends RSEPersistableObject implements ISy
* @generated This field/method will be replaced during code generation * @generated This field/method will be replaced during code generation
*/ */
public List getPools() { public List getPools() {
if (pools == null) { // if (pools == null) {
pools = new ArrayList(); // pools = new ArrayList();
} // }
return pools; 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. * Save a specific filter pool.
* Uses the save policy specified in this manager's factory method.
*/ */
public boolean commit(ISystemFilterPool pool) { public boolean commit(ISystemFilterPool pool) {
pool.setDirty(true);
boolean result = pool.commit(); boolean result = pool.commit();
return result; return result;
} }

View file

@ -12,7 +12,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * 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; package org.eclipse.rse.internal.core.filters;
@ -185,7 +185,11 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
* objects in this list reference. * objects in this list reference.
*/ */
public ISystemFilterPoolManager[] getSystemFilterPoolManagers() { 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) { private ISystemFilterPoolReference createSystemFilterPoolReference(ISystemFilterPool filterPool) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPool); ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPool);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
return filterPoolReference; return filterPoolReference;
} }
@ -391,6 +396,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/ */
private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) { private ISystemFilterPoolReference createSystemFilterPoolReference(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName); ISystemFilterPoolReference filterPoolReference = new SystemFilterPoolReference(filterPoolName);
filterPoolReference.setParentReferenceManager(this);
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
return filterPoolReference; return filterPoolReference;
} }
@ -402,7 +408,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/ */
public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) { public int addSystemFilterPoolReference(ISystemFilterPoolReference filterPoolReference) {
int count = addReferencingObject(filterPoolReference); int count = addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD - should be done in the addReferencingObject method? filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
return count; return count;
@ -432,7 +438,6 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
count = super.removeReferencingObject(filterPoolReference); count = super.removeReferencingObject(filterPoolReference);
else else
count = super.removeAndDeReferenceReferencingObject(filterPoolReference); count = super.removeAndDeReferenceReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in remove?
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference); if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
quietSave(); quietSave();
@ -541,8 +546,8 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
*/ */
public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPool filterPool) { public ISystemFilterPoolReference addReferenceToSystemFilterPool(ISystemFilterPool filterPool) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPool); ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPool);
addReferencingObject(filterPoolReference); // DWD - should be done in addReferencingObject? addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference); if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference);
@ -555,7 +560,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) { public ISystemFilterPoolReference addReferenceToSystemFilterPool(String filterPoolName) {
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName); ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPoolName);
addReferencingObject(filterPoolReference); addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference); if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceCreated(filterPoolReference);
@ -574,11 +579,12 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
if (filterPoolReference != null) { if (filterPoolReference != null) {
filterPoolReference.removeReference(); filterPoolReference.removeReference();
newCount = removeReferencingObject(filterPoolReference); newCount = removeReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(null); // DWD should be done in removeReferencingObject?
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); quietSave();
// callback to provider so they can fire events in their GUI // callback to provider so they can fire events in their GUI
if (fireEvents && (caller != null)) caller.filterEventFilterPoolReferenceDeleted(filterPoolReference); if (fireEvents && (caller != null)) {
caller.filterEventFilterPoolReferenceDeleted(filterPoolReference);
}
} else } else
newCount = getSystemFilterPoolReferenceCount(); newCount = getSystemFilterPoolReferenceCount();
return newCount; return newCount;
@ -621,7 +627,7 @@ public class SystemFilterPoolReferenceManager extends SystemPersistableReference
//addReferenceToSystemFilterPool(filterPools[idx]); //addReferenceToSystemFilterPool(filterPools[idx]);
ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]); ISystemFilterPoolReference filterPoolReference = createSystemFilterPoolReference(filterPools[idx]);
addReferencingObject(filterPoolReference); addReferencingObject(filterPoolReference);
filterPoolReference.setParentReferenceManager(this); // DWD should be done in addReferencingObject? filterPoolReference.setParentReferenceManager(this); // DWD - should be done in addReferencingObject?
} }
invalidateFilterPoolReferencesCache(); invalidateFilterPoolReferencesCache();
quietSave(); 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 * David Dykstal (IBM) - 142806: refactoring persistence framework
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * 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; package org.eclipse.rse.internal.core.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager; import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
@ -35,6 +36,7 @@ import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.RSECoreMessages; import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.persistence.IRSEPersistenceProvider; import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -80,15 +82,6 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return mgr; 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 * Return all connections for this profile
*/ */
@ -97,25 +90,26 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
return RSECorePlugin.getTheSystemRegistry().getHostsByProfile(this); return RSECorePlugin.getTheSystemRegistry().getHostsByProfile(this);
} }
/** /* (non-Javadoc)
* Return all filter pools for this profile * @see org.eclipse.rse.core.model.ISystemProfile#getFilterPools()
*/ */
public ISystemFilterPool[] getFilterPools() public ISystemFilterPool[] getFilterPools()
{ {
ISubSystemConfiguration[] ssFactories = RSECorePlugin.getTheSystemRegistry().getSubSystemConfigurations(); List filterPools = new ArrayList(10); // 10 is arbitrary but reasonable
Vector poolsVector = new Vector(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
for (int idx = 0; idx < ssFactories.length; idx++) ISubSystemConfigurationProxy proxies[] = registry.getSubSystemConfigurationProxies();
{ for (int i = 0; i < proxies.length; i++) {
ISystemFilterPoolManager poolMgr = ssFactories[idx].getFilterPoolManager(this); ISubSystemConfigurationProxy proxy = proxies[i];
ISystemFilterPool[] pools = poolMgr.getSystemFilterPools(); if (proxy.isSubSystemConfigurationActive()) {
for (int ydx=0; ydx<pools.length; ydx++) ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
{ ISystemFilterPoolManager fpm = config.getFilterPoolManager(this);
poolsVector.add(pools[ydx]); ISystemFilterPool[] poolArray = fpm.getSystemFilterPools();
filterPools.addAll(Arrays.asList(poolArray));
} }
} }
ISystemFilterPool[] allPools = new ISystemFilterPool[poolsVector.size()]; ISystemFilterPool[] result = new ISystemFilterPool[filterPools.size()];
poolsVector.toArray(allPools); filterPools.toArray(result);
return allPools; return result;
} }
/** /**
@ -209,13 +203,13 @@ public class SystemProfile extends RSEModelObject implements ISystemProfile, IAd
setDirty(true); setDirty(true);
} }
public boolean commit() /* (non-Javadoc)
{ * @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit()
boolean result = false; */
if (!RSECorePlugin.getThePersistenceManager().isBusy()) { public boolean commit() {
result = RSECorePlugin.getThePersistenceManager().commitProfile(this, 5000); IStatus status = SystemProfileManager.getDefault().commitSystemProfile(this);
} boolean scheduled = status.isOK();
return result; return scheduled;
} }
/** /**

View file

@ -16,6 +16,7 @@
* Kevin Doyle (IBM) - [197199] Renaming a Profile doesn't cause a save * Kevin Doyle (IBM) - [197199] Renaming a Profile doesn't cause a save
* Yu-Fen Kuo (MontaVista) - [189271] [team] New Profile's are always active * Yu-Fen Kuo (MontaVista) - [189271] [team] New Profile's are always active
* - [189219] [team] Inactive Profiles become active after workbench restart * - [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; package org.eclipse.rse.internal.core.model;
@ -24,6 +25,8 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
@ -40,6 +43,7 @@ public class SystemProfileManager implements ISystemProfileManager {
private List _profiles = new ArrayList(10); private List _profiles = new ArrayList(10);
private static SystemProfileManager singleton = null; 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 * Ordinarily there should be only one instance of a SystemProfileManager
@ -73,6 +77,60 @@ public class SystemProfileManager implements ISystemProfileManager {
restoring = 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. * Create a new profile with the given name, and add to the list.
* The name must be unique within the existing 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() * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/ */
public ISystemProfile[] getSystemProfiles() { public ISystemProfile[] getSystemProfiles() {
return getSystemProfiles(!restoring); return getSystemProfiles(restoring);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -162,14 +220,14 @@ public class SystemProfileManager implements ISystemProfileManager {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String) * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
*/ */
private ISystemProfile getSystemProfileOld(String name) { // private ISystemProfile getSystemProfileOld(String name) {
ISystemProfile[] profiles = getSystemProfiles(); // ISystemProfile[] profiles = getSystemProfiles();
if ((profiles == null) || (profiles.length == 0)) return null; // if ((profiles == null) || (profiles.length == 0)) return null;
ISystemProfile match = null; // ISystemProfile match = null;
for (int idx = 0; (match == null) && (idx < profiles.length); idx++) // for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
if (profiles[idx].getName().equals(name)) match = profiles[idx]; // if (profiles[idx].getName().equals(name)) match = profiles[idx];
return match; // return match;
} // }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String) * @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) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String) * @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String)
*/ */
private boolean isSystemProfileActiveOld(String profileName) { // private boolean isSystemProfileActiveOld(String profileName) {
String[] activeProfiles = getActiveSystemProfileNames(); // String[] activeProfiles = getActiveSystemProfileNames();
boolean match = false; // boolean match = false;
for (int idx = 0; !match && (idx < activeProfiles.length); idx++) { // for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
if (activeProfiles[idx].equals(profileName)) match = true; // if (activeProfiles[idx].equals(profileName)) match = true;
} // }
return match; // return match;
} // }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles() * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles()
@ -270,92 +328,92 @@ public class SystemProfileManager implements ISystemProfileManager {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames() * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames()
*/ */
private String[] getActiveSystemProfileNamesOld() { // private String[] getActiveSystemProfileNamesOld() {
String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles(); // String[] activeProfileNames = RSEPreferencesManager.getActiveProfiles();
// dy: defect 48355, need to sync this with the actual profile list. If the user // // 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 // // imports old preference settings or does a team sync and a profile is deleted then
// it is possible an active profile no longer exists. // // it is possible an active profile no longer exists.
// String[] systemProfileNames = getSystemProfileNames(); // // String[] systemProfileNames = getSystemProfileNames();
ISystemProfile[] systemProfiles = getSystemProfiles(); // ISystemProfile[] systemProfiles = getSystemProfiles();
boolean found; // boolean found;
boolean found_team = false; // boolean found_team = false;
boolean found_private = false; // boolean found_private = false;
boolean changed = false; // boolean changed = false;
String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName(); // String defaultProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
//
for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) { // for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
// skip Team and Private profiles // // skip Team and Private profiles
String activeProfileName = activeProfileNames[activeIdx]; // String activeProfileName = activeProfileNames[activeIdx];
if (activeProfileName.equals(defaultProfileName)) { // if (activeProfileName.equals(defaultProfileName)) {
found_private = true; // found_private = true;
} else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) { // } else if (activeProfileName.equals(RSEPreferencesManager.getDefaultTeamProfileName())) {
found_team = true; // found_team = true;
} else { // } else {
found = false; // found = false;
for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) { // for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) { // if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
found = true; // found = true;
} // }
} // }
//
if (!found) { // if (!found) {
// The active profile no longer exists so remove it from the active list // // The active profile no longer exists so remove it from the active list
RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]); // RSEPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]);
changed = true; // changed = true;
} // }
} // }
} // }
//
for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) { // for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
boolean matchesBoth = false; // boolean matchesBoth = false;
String name = systemProfiles[systemIdx].getName(); // String name = systemProfiles[systemIdx].getName();
//
for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) { // for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
String aname = activeProfileNames[activeIdx]; // String aname = activeProfileNames[activeIdx];
if (name.equals(aname)) { // if (name.equals(aname)) {
matchesBoth = true; // matchesBoth = true;
} // }
//
} // }
if (!matchesBoth && found_private) { // if (!matchesBoth && found_private) {
if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) { // if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
RSEPreferencesManager.addActiveProfile(name); // RSEPreferencesManager.addActiveProfile(name);
RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName()); // RSEPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName());
activeProfileNames = RSEPreferencesManager.getActiveProfiles(); // activeProfileNames = RSEPreferencesManager.getActiveProfiles();
} // }
} // }
} // }
//
// the active profiles list needed to be changed because of an external update, also // // 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 // // check if Default profile needs to be added back to the list
if (changed || !found_team || !found_private) { // if (changed || !found_team || !found_private) {
if (systemProfiles.length == 0) { // if (systemProfiles.length == 0) {
// First time user, make sure default is in the active list, the only time it wouldn't // // 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) // // be is if the pref_store.ini was modified (because the user imported old preferences)
if (!found_team) { // if (!found_team) {
RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName()); // RSEPreferencesManager.addActiveProfile(RSEPreferencesManager.getDefaultTeamProfileName());
changed = true; // changed = true;
} // }
//
if (!found_private) { // if (!found_private) {
RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName()); // RSEPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName());
changed = true; // changed = true;
} // }
} else { // } else {
ISystemProfile defaultProfile = getDefaultPrivateSystemProfile(); // ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
if (defaultProfile != null && !found_private) { // if (defaultProfile != null && !found_private) {
RSEPreferencesManager.addActiveProfile(defaultProfile.getName()); // RSEPreferencesManager.addActiveProfile(defaultProfile.getName());
changed = true; // changed = true;
} // }
} // }
//
if (changed) { // if (changed) {
activeProfileNames = RSEPreferencesManager.getActiveProfiles(); // activeProfileNames = RSEPreferencesManager.getActiveProfiles();
} // }
} // }
//
return activeProfileNames; // return activeProfileNames;
} // }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile() * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
@ -449,8 +507,8 @@ public class SystemProfileManager implements ISystemProfileManager {
} }
} }
private ISystemProfile[] getSystemProfiles(boolean ensureDefaultPrivateProfileExists) { private ISystemProfile[] getSystemProfiles(boolean restoring) {
if (ensureDefaultPrivateProfileExists) { if (!restoring) {
ensureDefaultPrivateProfile(); ensureDefaultPrivateProfile();
} }
ISystemProfile[] result = new ISystemProfile[_profiles.size()]; ISystemProfile[] result = new ISystemProfile[_profiles.size()];

View file

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

View file

@ -17,6 +17,7 @@
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM * 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 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; package org.eclipse.rse.internal.persistence.dom;
@ -117,11 +118,11 @@ public class RSEDOMImporter {
IHost host = null; IHost host = null;
// get host node attributes // 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 // we changed from storing names to storing IDs, so these may be null
String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE); String systemTypeName = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_TYPE);
String systemTypeId = getAttributeValueMaybeNull(hostNode, IRSEDOMConstants.ATTRIBUTE_SYSTEM_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); String description = getAttributeValue(hostNode, IRSEDOMConstants.ATTRIBUTE_DESCRIPTION);
boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE); boolean isOffline = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_OFFLINE);
boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE); boolean isPromptable = getBooleanValue(hostNode, IRSEDOMConstants.ATTRIBUTE_PROMPTABLE);
@ -130,16 +131,18 @@ public class RSEDOMImporter {
try { try {
// NOTE create host effectively recreates the subsystems // NOTE create host effectively recreates the subsystems
// so instead of creating subsystems on restore, we should be updating their properties // so instead of creating subsystems on restore, we should be updating their properties
IRSECoreRegistry registry = RSECorePlugin.getTheCoreRegistry(); IRSECoreRegistry coreRegistry = RSECorePlugin.getTheCoreRegistry();
IRSESystemType systemType = null; IRSESystemType systemType = null;
if (systemTypeId != null) { if (systemTypeId != null) {
systemType = registry.getSystemTypeById(systemTypeId); systemType = coreRegistry.getSystemTypeById(systemTypeId);
} else if (systemTypeName != null) { } 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 //cannot create a host from a profile if we do not know the systemType
if (systemType != null) { 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.setOffline(isOffline);
host.setPromptable(isPromptable); host.setPromptable(isPromptable);
} else { } else {
@ -151,7 +154,7 @@ public class RSEDOMImporter {
msg.append(") in "); //$NON-NLS-1$ msg.append(") in "); //$NON-NLS-1$
msg.append(profile.getName()); msg.append(profile.getName());
msg.append(':'); msg.append(':');
msg.append(connectionName); msg.append(hostName);
logWarning(msg.toString()); logWarning(msg.toString());
} }
} catch (Exception e) { } catch (Exception e) {
@ -292,7 +295,7 @@ public class RSEDOMImporter {
fprMgr.setDefaultSystemFilterPoolManager(defaultFilterPoolManager); fprMgr.setDefaultSystemFilterPoolManager(defaultFilterPoolManager);
} }
// restore filer pool references // restore filter pool references
RSEDOMNode[] filterPoolReferenceChildren = subSystemNode.getChildren(IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE); RSEDOMNode[] filterPoolReferenceChildren = subSystemNode.getChildren(IRSEDOMConstants.TYPE_FILTER_POOL_REFERENCE);
for (int i = 0; i < filterPoolReferenceChildren.length; i++) { for (int i = 0; i < filterPoolReferenceChildren.length; i++) {
RSEDOMNode fprChild = filterPoolReferenceChildren[i]; RSEDOMNode fprChild = filterPoolReferenceChildren[i];

View file

@ -27,6 +27,7 @@
* David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated * 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 * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
* David McKnight (IBM) - [209704] added supportsEncodingConversion() * David McKnight (IBM) - [209704] added supportsEncodingConversion()
* David Dykstal (IBM) - [197036] pulling up subsystem switch logic
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.subsystems.files.core.servicesubsystem; package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -77,10 +78,6 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
protected ISearchService _hostSearchService; protected ISearchService _hostSearchService;
protected IHostFileToRemoteFileAdapter _hostFileToRemoteFileAdapter; protected IHostFileToRemoteFileAdapter _hostFileToRemoteFileAdapter;
protected IRemoteFile _userHome; protected IRemoteFile _userHome;
public FileServiceSubSystem(IHost host, IConnectorService connectorService, IFileService hostFileService, IHostFileToRemoteFileAdapter fileAdapter, ISearchService searchService) public FileServiceSubSystem(IHost host, IConnectorService connectorService, IFileService hostFileService, IHostFileToRemoteFileAdapter fileAdapter, ISearchService searchService)
{ {
super(host, connectorService); super(host, connectorService);
@ -919,43 +916,28 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
return null; return null;
} }
/* (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
* Switch to use another protocol
*/ */
public void switchServiceFactory(IServiceSubSystemConfiguration fact) public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
{ return (configuration instanceof IFileServiceSubSystemConfiguration);
if (fact != getSubSystemConfiguration() && fact instanceof IFileServiceSubSystemConfiguration)
{
IFileServiceSubSystemConfiguration factory = (IFileServiceSubSystemConfiguration)fact;
try
{
_cachedRemoteFiles.clear();
disconnect();
}
catch (Exception e)
{
} }
_languageUtilityFactory = null; /* (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(); IHost host = getHost();
setSubSystemConfiguration(factory); IFileServiceSubSystemConfiguration config = (IFileServiceSubSystemConfiguration) newConfig;
// file subsystem specific bits
IConnectorService oldConnectorService = getConnectorService(); _cachedRemoteFiles.clear();
oldConnectorService.deregisterSubSystem(this); _languageUtilityFactory = null;
setFileService(config.getFileService(host));
IConnectorService newConnectorService = factory.getConnectorService(host); setHostFileToRemoteFileAdapter(config.getHostFileAdapter());
setConnectorService(newConnectorService); setSearchService(config.getSearchService(host));
oldConnectorService.commit();
newConnectorService.commit();
setName(factory.getName());
setFileService(factory.getFileService(host));
setHostFileToRemoteFileAdapter(factory.getHostFileAdapter());
setSearchService(factory.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) - [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) - [189130] Move SystemIFileProperties from UI to Core
* Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() 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; package org.eclipse.rse.subsystems.files.core.subsystems;
@ -331,12 +332,13 @@ public abstract class RemoteFileSubSystemConfiguration extends SubSystemConfigur
// ----------------------------------------------------- // -----------------------------------------------------
// create a pool named filters // 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"); //System.out.println("Pool created");
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
// create default filters in that pool iff this is the user's private profile we are creating... // 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(); Vector filterStrings = new Vector();

View file

@ -13,6 +13,7 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * 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; package org.eclipse.rse.subsystems.processes.servicesubsystem;
@ -145,37 +146,21 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen
} }
/* (non-Javadoc) /* (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 config = (IProcessServiceSubSystemConfiguration) configuration;
{
IProcessServiceSubSystemConfiguration factory = (IProcessServiceSubSystemConfiguration)fact;
try
{
disconnect();
}
catch (Exception e)
{
}
IHost host = getHost(); IHost host = getHost();
setSubSystemConfiguration(factory); setProcessService(config.getProcessService(host));
setName(factory.getName()); setHostProcessToRemoteProcessAdapter(config.getHostProcessAdapter());
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = factory.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
setProcessService(factory.getProcessService(host));
setHostProcessToRemoteProcessAdapter(factory.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) /* (non-Javadoc)
@ -186,7 +171,6 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen
return IProcessService.class; return IProcessService.class;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) * @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) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* David McKnight (IBM) - [191599] Need to pass in shell encoding * 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; 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.services.shells.IShellService;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; 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.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.IRemoteCommandShell;
import org.eclipse.rse.subsystems.shells.core.subsystems.RemoteCmdSubSystem; import org.eclipse.rse.subsystems.shells.core.subsystems.RemoteCmdSubSystem;
@ -204,38 +206,25 @@ public final class ShellServiceSubSystem extends RemoteCmdSubSystem implements I
return l; return l;
} }
/** /* (non-Javadoc)
* swtich from one protocol to another * @see org.eclipse.rse.core.subsystems.SubSystem#canSwitchTo(org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration)
*/ */
public void switchServiceFactory(IServiceSubSystemConfiguration fact) public boolean canSwitchTo(IServiceSubSystemConfiguration configuration) {
{ return configuration instanceof IShellServiceSubSystemConfiguration;
if (fact != getSubSystemConfiguration() && fact instanceof IShellServiceSubSystemConfiguration)
{
IShellServiceSubSystemConfiguration factory = (IShellServiceSubSystemConfiguration)fact;
try
{
disconnect();
}
catch (Exception e)
{
} }
/* (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(); IHost host = getHost();
setSubSystemConfiguration(factory); setShellService(configuration.getShellService(host));
setName(factory.getName());
IConnectorService oldConnectorService = getConnectorService();
oldConnectorService.deregisterSubSystem(this);
IConnectorService newConnectorService = factory.getConnectorService(host);
setConnectorService(newConnectorService);
oldConnectorService.commit();
newConnectorService.commit();
setShellService(factory.getShellService(host));
}
} }
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#getServiceType()
*/
public Class getServiceType() public Class getServiceType()
{ {
return IShellService.class; return IShellService.class;

View file

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

View file

@ -12,6 +12,8 @@
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * 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; 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.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
@ -77,6 +80,15 @@ public class SystemFilterWorkWithFilterPoolsDialog
SystemFilterPoolDialogInterface SystemFilterPoolDialogInterface
//,ISystemResourceChangeListener //,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 String promptString;
//private Label prompt; //private Label prompt;
@ -93,8 +105,8 @@ public class SystemFilterWorkWithFilterPoolsDialog
//private ActionContributionItem newActionItem, deleteActionItem, renameActionItem; //private ActionContributionItem newActionItem, deleteActionItem, renameActionItem;
private SystemFilterWorkWithFilterPoolsRefreshAllAction refreshAction = null; private SystemFilterWorkWithFilterPoolsRefreshAllAction refreshAction = null;
private SystemFilterNewFilterPoolAction newAction = null; private SystemFilterNewFilterPoolAction newAction = null;
//private SystemSimpleDeleteAction dltAction = null; private DeleteFilterPoolAction dltAction = null;
private SystemCommonDeleteAction dltAction = null; //private SystemCommonDeleteAction dltAction = null;
//private SystemSimpleRenameAction rnmAction = null; //private SystemSimpleRenameAction rnmAction = null;
private SystemCommonRenameAction rnmAction = null; private SystemCommonRenameAction rnmAction = null;
private SystemFilterCopyFilterPoolAction cpyAction = null; private SystemFilterCopyFilterPoolAction cpyAction = null;
@ -251,7 +263,7 @@ public class SystemFilterWorkWithFilterPoolsDialog
{ {
newAction = new SystemFilterNewFilterPoolAction(shell,this); newAction = new SystemFilterNewFilterPoolAction(shell,this);
//dltAction = new SystemSimpleDeleteAction(shell,this); //dltAction = new SystemSimpleDeleteAction(shell,this);
dltAction = new SystemCommonDeleteAction(shell,this); dltAction = new DeleteFilterPoolAction(shell,this);
rnmAction = new SystemCommonRenameAction(shell,this); rnmAction = new SystemCommonRenameAction(shell,this);
// undo typical settings... // undo typical settings...
rnmAction.allowOnMultipleSelection(false); rnmAction.allowOnMultipleSelection(false);

View file

@ -30,6 +30,7 @@
* Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter * 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 * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false) * 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; 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) //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: //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. //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++) { for (int i=0; i<ss.length; i++) {
if (ss[i].isConnected() && ss[i].getSubSystemConfiguration().supportsSubSystemConnect()) if (ss[i].isConnected() && ss[i].getSubSystemConfiguration().supportsSubSystemConnect())
return false; return false;

View file

@ -15,10 +15,18 @@
* Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * 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; 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.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor; 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.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.view.SystemViewResources; import org.eclipse.rse.internal.ui.view.SystemViewResources;
import org.eclipse.rse.ui.SystemMenuManager; 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) private SystemTeamViewSubSystemConfigurationNode[] createSubSystemConfigurationNodes(ISystemProfile profile, SystemTeamViewCategoryNode category) {
{ // create a sorted set to hold the subsystem configurations based on the proxy ordering
SystemTeamViewSubSystemConfigurationNode[] nodes = null;
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystemConfiguration[] factories = sr.getSubSystemConfigurations(); final List proxies = Arrays.asList(sr.getSubSystemConfigurationProxies());
if (factories != null) Comparator comparator = new Comparator() {
{ public int compare(Object o1, Object o2) {
Vector v = new Vector(); 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;
}
};
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);
}
}
// construct the nodes for the view based on these configurations
List nodes = new ArrayList();
String categoryType = category.getMementoHandle(); String categoryType = category.getMementoHandle();
for (int idx=0; idx<factories.length; idx++) for (Iterator z = activeSubsystemConfigurations.iterator(); z.hasNext();) {
{ ISubSystemConfiguration ssf = (ISubSystemConfiguration) z.next();
boolean createNode = false; boolean createNode = false;
ISubSystemConfiguration ssf = factories[idx]; if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS)) {
if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS))
{
createNode = ssf.supportsFilters() && (profile.getFilterPools(ssf).length > 0); createNode = ssf.supportsFilters() && (profile.getFilterPools(ssf).length > 0);
} } else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS)) {
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS))
{
createNode = ssf.supportsUserDefinedActions(); // && profile.getUserActions(ssf).length > 0; createNode = ssf.supportsUserDefinedActions(); // && profile.getUserActions(ssf).length > 0;
} } else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS)) {
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS))
{
createNode = ssf.supportsCompileActions(); // && profile.getCompileCommandTypes(ssf).length > 0; createNode = ssf.supportsCompileActions(); // && profile.getCompileCommandTypes(ssf).length > 0;
} } else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_TARGETS)) {
else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_TARGETS))
{
createNode = ssf.supportsTargets(); // && profile.getTargets(ssf).length > 0; createNode = ssf.supportsTargets(); // && profile.getTargets(ssf).length > 0;
} }
if (createNode) if (createNode) {
v.addElement(new SystemTeamViewSubSystemConfigurationNode(profile, category, factories[idx])); nodes.add(new SystemTeamViewSubSystemConfigurationNode(profile, category, ssf));
}
nodes = new SystemTeamViewSubSystemConfigurationNode[v.size()];
for (int idx=0; idx<nodes.length; idx++)
{
nodes[idx] = (SystemTeamViewSubSystemConfigurationNode)v.elementAt(idx);
} }
} }
return nodes; SystemTeamViewSubSystemConfigurationNode[] result = new SystemTeamViewSubSystemConfigurationNode[nodes.size()];
nodes.toArray(result);
return result;
} }
/** /**

View file

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

View file

@ -39,18 +39,25 @@
* Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe * Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe
* David Dykstal (IBM) - [210537] removed exception handling for SystemHostPool, no longer needed * David Dykstal (IBM) - [210537] removed exception handling for SystemHostPool, no longer needed
* Martin Oberhuber (Wind River) - [216266] improved non-forced getSubSystems() code, removed getSubSystemsLazily() * 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; package org.eclipse.rse.ui.internal.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants; 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.ISubSystemConfigurationProxy;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter; import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere; 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.SystemHostPool;
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent; import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.core.model.SystemModelChangeEventManager; 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.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import com.ibm.icu.text.MessageFormat;
/** /**
* Registry for all connections. * Registry for all connections.
*/ */
@ -206,7 +216,9 @@ public class SystemRegistry implements ISystemRegistry
*/ */
public Object[] getConnectionChildren(IHost selectedConnection) 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 * 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) * (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemConfigurationsBySystemType(org.eclipse.rse.core.IRSESystemType, boolean) * @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) public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemFactories)
{ {
List serviceTypesAdded = new ArrayList(); return getSubSystemConfigurationsBySystemType(systemType, filterDuplicateServiceSubSystemFactories, true);
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) /*
{ * (non-Javadoc)
// remove the other one * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemConfigurationsBySystemType(org.eclipse.rse.core.IRSESystemType, boolean)
for (int i = 0; i < v.size(); i++) */
{ public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, final boolean filterDuplicates, boolean activate) {
if (v.get(i) instanceof IServiceSubSystemConfiguration) List configurations = new ArrayList();
{ if (subsystemConfigurationProxies != null) {
IServiceSubSystemConfiguration addedConfig = (IServiceSubSystemConfiguration)v.get(i); Set serviceTypes = new HashSet();
if (addedConfig.getServiceType() == serviceType) // Set serviceImplsAdded = new HashSet();
{ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) {
v.remove(addedConfig); 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);
} }
} } else {
configurations.add(configuration);
}
v.addElement(ssFactory);
}
}
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(); return pool.getSystemProfile();
} }
public IConnectorService[] getConnectorServices(IHost conn) /* (non-Javadoc)
{ * @see org.eclipse.rse.core.model.ISystemRegistry#getConnectorServices(org.eclipse.rse.core.model.IHost)
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);
}
}
return (IConnectorService[])csList.toArray(new IConnectorService[csList.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.
*/ */
public ISubSystem[] getSubSystems(IHost conn) public IConnectorService[] getConnectorServices(IHost host) {
{ List services = new ArrayList();
return getSubSystems(conn, ISubSystemConfiguration.FORCE_INTO_MEMORY); 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[]) services.toArray(new IConnectorService[services.size()]);
} }
/** /* (non-Javadoc)
* Return list of subsystem objects for a given connection. * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost, boolean)
* 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.
*/ */
public ISubSystem[] getSubSystems(IHost conn, boolean force) public ISubSystem[] getSubSystems(IHost host, boolean force) {
{ return getSubSystems(host);
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())) /* (non-Javadoc)
{ * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost)
ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration(); */
if (factory != null) public ISubSystem[] getSubSystems(IHost host) {
{ IRSESystemType systemType = host.getSystemType();
ISubSystem[] sss = factory.getSubSystems(conn, force); List subsystems = new ArrayList();
if (sss != null) if (subsystemConfigurationProxies != null) {
for (int jdx = 0; jdx < sss.length; jdx++) for (int i = 0; i < subsystemConfigurationProxies.length; i++) {
v.add(sss[jdx]); 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;
} }
/** /**
@ -1149,10 +1125,13 @@ public class SystemRegistry implements ISystemRegistry
return dataStream.toString(); 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(); List matches = new ArrayList();
ISubSystem[] allSS = connection.getSubSystems(); ISubSystem[] allSS = getSubSystems(host);
for (int i = 0; i < allSS.length; i++) for (int i = 0; i < allSS.length; i++)
{ {
ISubSystem ss = allSS[i]; ISubSystem ss = allSS[i];
@ -1164,10 +1143,13 @@ public class SystemRegistry implements ISystemRegistry
return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]); 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(); List matches = new ArrayList();
ISubSystem[] allSS = connection.getSubSystems(); ISubSystem[] allSS = getSubSystems(host);
for (int i = 0; i < allSS.length; i++) for (int i = 0; i < allSS.length; i++)
{ {
ISubSystem ss = allSS[i]; ISubSystem ss = allSS[i];
@ -1187,9 +1169,9 @@ public class SystemRegistry implements ISystemRegistry
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemsBySubSystemConfigurationCategory(java.lang.String, org.eclipse.rse.core.model.IHost) * @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)) if ((subsystems != null) && (subsystems.length > 0))
{ {
Vector v = new Vector(); Vector v = new Vector();
@ -1658,10 +1640,7 @@ public class SystemRegistry implements ISystemRegistry
} }
/** /**
* Create a connection object, given the connection pool and given all the possible attributes. * Create a host object, given its host pool and its 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.
* <p> * <p>
* This method: * This method:
* <ul> * <ul>
@ -1671,10 +1650,9 @@ public class SystemRegistry implements ISystemRegistry
* </ul> * </ul>
* <p> * <p>
* @param profileName Name of the system profile the connection is to be added to. * @param profileName Name of the system profile the connection is to be added to.
* @param systemType system type matching one of the system types * @param systemType system type matching one of the system types defined via the systemTypes extension point.
* defined via the systemTypes extension point. * @param hostName unique connection name.
* @param connectionName unique connection name. * @param hostAddress IP name of host.
* @param hostName ip name of host.
* @param description optional description of the connection. Can be null. * @param description optional description of the connection. Can be null.
* @param defaultUserId userId to use as the default for the subsystems. * @param defaultUserId userId to use as the default for the subsystems.
* @param defaultUserIdLocation one of the constants in {@link org.eclipse.rse.core.IRSEUserIdConstants} * @param defaultUserIdLocation one of the constants in {@link org.eclipse.rse.core.IRSEUserIdConstants}
@ -1685,55 +1663,93 @@ public class SystemRegistry implements ISystemRegistry
* @return SystemConnection object, or null if it failed to create. This is typically * @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( // FIXME need to remove ISystemNewConnectionWizardPage[] from this and replace with IAdaptable[]
String profileName, public IHost createHost(final String profileName, final IRSESystemType systemType, final String hostName,
IRSESystemType systemType, final String hostAddress, final String description, final String defaultUserId,
String connectionName, final int defaultUserIdLocation, final boolean createSubSystems,
String hostName, final ISystemNewConnectionWizardPage[] newConnectionWizardPages) throws Exception {
String description, final ISystemRegistry sr = this;
String defaultUserId, class CreateHostOperation implements ISystemProfileOperation {
int defaultUserIdLocation, private IHost host = null;
boolean createSubSystems, private ISubSystem[] subsystems = new ISubSystem[0];
ISystemNewConnectionWizardPage[] newConnectionWizardPages) IHost getHost() {
throws Exception { return host;
lastException = null; }
public ISubSystem[] getSubSystems() {
return subsystems;
}
public IStatus run() {
IStatus status = Status.OK_STATUS;
ISystemHostPool pool = getHostPool(profileName); ISystemHostPool pool = getHostPool(profileName);
IHost conn = null; try {
boolean promptable = false; // systemType.equals(IRSESystemType.SYSTEMTYPE_PROMPT);
try
{
// create, register and save new connection... // create, register and save new connection...
if ((defaultUserId != null) && (defaultUserId.length() == 0)) String uid = defaultUserId;
defaultUserId = null; if ((uid != null) && (uid.length() == 0)) {
conn = pool.createHost(systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation); uid = null;
if (conn == null) // conn already exists
{
conn = pool.getHost(connectionName);
} }
if (promptable) host = pool.createHost(systemType, hostName, hostAddress, description, uid, defaultUserIdLocation);
conn.setPromptable(true); if (host == null) { // did not create since host already exists
host = pool.getHost(hostName);
} }
catch (Exception exc) } catch (Exception e) {
{ String pluginId = RSEUIPlugin.getDefault().getSymbolicName();
lastException = exc; String message = MessageFormat.format("Exception in createHost for {0}", new Object[] {hostName});
SystemBasePlugin.logError("Exception in createConnection for " + connectionName, exc); //$NON-NLS-1$ status = new Status(IStatus.ERROR, pluginId, message, e);
throw exc;
} }
if ((lastException == null) && !promptable && createSubSystems) { if (status.isOK()) {
// only 1 factory used per service type if (createSubSystems) {
ISubSystemConfiguration[] factories = getSubSystemConfigurationsBySystemType(systemType, true); // determine the list of configs to use to create subsystems from
ISubSystem subSystems[] = new ISubSystem[factories.length]; List configs = new ArrayList(10); // arbitrary but reasonable
for (int idx = 0; idx < factories.length; idx++) { if (newConnectionWizardPages != null) {
ISubSystemConfiguration factory = factories[idx]; // if there are wizard pages need to at least use those
ISystemNewConnectionWizardPage[] interestingPages = getApplicableWizardPages(factory, newConnectionWizardPages); for (int i = 0; i < newConnectionWizardPages.length; i++) {
subSystems[idx] = factory.createSubSystem(conn, true, interestingPages); // give it the opportunity to create a subsystem configs.add(newConnectionWizardPages[i].getSubSystemConfiguration());
} }
FireNewHostEvents fire = new FireNewHostEvents(conn, subSystems, this); // 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;
}
}
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); Display.getDefault().asyncExec(fire);
}
conn.commit();
SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list 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); return createHost(profileName, systemType, connectionName, hostName, description, true);
} }
/** /* (non-Javadoc)
* Create a connection object. This is a simplified version * @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)
* <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
*/ */
public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description, boolean createSubSystems) throws Exception 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) public boolean isAnySubSystemConnected(IHost conn)
{ {
boolean any = false; boolean any = false;
ISubSystem[] subsystems = getSubSystems(conn, false); ISubSystem[] subsystems = getSubSystems(conn);
if (subsystems == null) if (subsystems == null)
return false; return false;
for (int idx = 0; !any && (idx < subsystems.length); idx++) for (int idx = 0; !any && (idx < subsystems.length); idx++)
@ -2394,7 +2389,7 @@ public class SystemRegistry implements ISystemRegistry
public void disconnectAllSubSystems(IHost conn) public void disconnectAllSubSystems(IHost conn)
{ {
// get subsystems lazily, because not instantiated ones cannot be disconnected anyways. // get subsystems lazily, because not instantiated ones cannot be disconnected anyways.
ISubSystem[] subsystems = getSubSystems(conn, false); ISubSystem[] subsystems = getSubSystems(conn);
if (subsystems == null) if (subsystems == null)
return; return;

View file

@ -28,13 +28,19 @@
* David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect() * 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) - [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 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; package org.eclipse.rse.core.subsystems;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IResource; 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.jface.operation.IRunnableWithProgress;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
import org.eclipse.rse.core.events.ISystemModelChangeEvents; import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.core.events.ISystemResourceChangeEvents; import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
import org.eclipse.rse.core.events.SystemResourceChangeEvent; 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.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.RSEModelObject; import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.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.internal.ui.GenericMessages;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
@ -122,7 +132,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
*/ */
public abstract class SubSystem extends RSEModelObject public abstract class SubSystem extends RSEModelObject
implements IAdaptable, ISubSystem, implements IAdaptable, ISubSystem, IServiceSubSystem,
ISystemFilterPoolReferenceManagerProvider ISystemFilterPoolReferenceManagerProvider
{ {
@ -175,6 +185,8 @@ public abstract class SubSystem extends RSEModelObject
*/ */
protected ISystemFilterPoolReferenceManager filterPoolReferenceManager = null; protected ISystemFilterPoolReferenceManager filterPoolReferenceManager = null;
private Map poolReferencesMap = new HashMap();
private class NullRunnableContext implements IRunnableContext { private class NullRunnableContext implements IRunnableContext {
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
IProgressMonitor monitor = new NullProgressMonitor(); IProgressMonitor monitor = new NullProgressMonitor();
@ -2958,7 +2970,7 @@ public abstract class SubSystem extends RSEModelObject
{ {
ISubSystem firstSS = null; ISubSystem firstSS = null;
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] sses = registry.getSubSystems(getHost(), false); ISubSystem[] sses = registry.getSubSystems(getHost());
for (int i = 0; i < sses.length; i++) for (int i = 0; i < sses.length; i++)
{ {
ISubSystem ss = sses[i]; ISubSystem ss = sses[i];
@ -3049,4 +3061,131 @@ public abstract class SubSystem extends RSEModelObject
return result; 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 * Rupen Mardirossian (IBM) - [189434] Move Up/Down on Filters Error
* Kevin Doyle (IBM) - [190445] Set Position of cloned event in cloneEvent() * Kevin Doyle (IBM) - [190445] Set Position of cloned event in cloneEvent()
* Martin Oberhuber (Wind River) - [195392] Avoid setting port 0 in initializeSubSystem() * 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; 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.core.model.SystemProfileManager;
import org.eclipse.rse.internal.ui.SystemPropertyResources; import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -632,31 +635,20 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
// SUBSYSTEM METHODS... // SUBSYSTEM METHODS...
// --------------------------------- // ---------------------------------
/** /* (non-Javadoc)
* Called by SystemRegistry's renameSystemProfile method to ensure we update our * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#renameSubSystemProfile(org.eclipse.rse.core.subsystems.ISubSystem, java.lang.String, java.lang.String)
* subsystem names within each subsystem.
* <p>
* This is called AFTER changing the profile's name!!
*/ */
public void renameSubSystemProfile(ISubSystem ss, String oldProfileName, String newProfileName) public void renameSubSystemProfile(ISubSystem subsystem, String oldProfileName, String newProfileName) {
{ subsystem.renamingProfile(oldProfileName, newProfileName);
//RSEUIPlugin.logDebugMessage(this.getClass().getName(), "Inside renameSubSystemProfile. newProfileName = "+newProfileName+", old ssName = "+ss.getName()); ISystemFilterPoolReferenceManager sfprm = subsystem.getSystemFilterPoolReferenceManager();
//renameFilterPoolManager(getSystemProfile(newProfileName)); // update filter pool manager name if (sfprm != null) {
ss.renamingProfile(oldProfileName, newProfileName);
ISystemFilterPoolReferenceManager sfprm = ss.getSystemFilterPoolReferenceManager();
if (sfprm != null)
{
sfprm.regenerateReferencedSystemFilterPoolNames(); // ask it to re-ask each pool for its reference name sfprm.regenerateReferencedSystemFilterPoolNames(); // ask it to re-ask each pool for its reference name
} }
try try {
{ saveSubSystem(subsystem);
saveSubSystem(ss); } 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 try
{ {
saveSubSystem(subsys); saveSubSystem(subsys);
//DKM - save this event til all the processing is done! RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsys, null);
// fire model change event in case any BP code is listening...
//RSECorePlugin.getTheSystemRegistry().fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsys, null);
} }
catch (Exception exc) catch (Exception exc)
{ {
@ -1598,78 +1588,54 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
return activeManagers; return activeManagers;
} }
/** /* (non-Javadoc)
* Get the filter pool manager for the given profile * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#getFilterPoolManager(org.eclipse.rse.core.model.ISystemProfile)
*/ */
public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile) public ISystemFilterPoolManager getFilterPoolManager(ISystemProfile profile) {
{ return getFilterPoolManager(profile, false);
// 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)
{ /* (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);
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$ SystemBasePlugin.logError("Restore/Creation of SystemFilterPoolManager " + getFilterPoolManagerName(profile) + " failed!", exc); //$NON-NLS-1$ //$NON-NLS-2$
SystemMessageDialog.displayExceptionMessage(null, exc); SystemMessageDialog.displayExceptionMessage(null, exc);
return null; // something very bad happend! return null; // something very bad happened!
} }
addFilterPoolManager(profile, mgr); addFilterPoolManager(profile, mgr);
}
boolean restored = mgr.wasRestored(); boolean initialized = mgr.wasRestored();
//System.out.println("...after createSystemFilterPoolManager for " + mgr.getName() + ", restored = " + restored); if (force && !initialized) {
String defaultPoolName = getDefaultFilterPoolName(profile.getName(), getId());
ISystemFilterPool defaultPool = mgr.getSystemFilterPool(defaultPoolName);
if (defaultPool == null) {
// allow subclasses to create default filter pool... // allow subclasses to create default filter pool...
if (!restored) defaultPool = createDefaultFilterPool(mgr); // createDefaultFilterPool(mgr) is typically overridden by subclasses
{ }
ISystemFilterPool defaultPool = createDefaultFilterPool(mgr); if (defaultPool != null) {
if (defaultPool != null)
{
defaultPool.setDefault(true); defaultPool.setDefault(true);
try
{
defaultPool.commit(); defaultPool.commit();
} }
catch (Exception exc) if (supportsDuplicateFilterStrings()) mgr.setSupportsDuplicateFilterStrings(true);
{ if (isCaseSensitive()) mgr.setStringsCaseSensitive(true);
} mgr.setWasRestored(true);
}
}
// 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)
{
}
}
}
// 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());
} }
return mgr; return mgr;
} }
/** /**
* Do post-restore-processing of an existing filter pool manager. * 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. * This is where child classes do any required migration work. By default, we do nothing.