### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.ui Index: model/org/eclipse/rse/ui/internal/model/SystemPostableEventNotifier.java =================================================================== RCS file: model/org/eclipse/rse/ui/internal/model/SystemPostableEventNotifier.java diff -N model/org/eclipse/rse/ui/internal/model/SystemPostableEventNotifier.java --- model/org/eclipse/rse/ui/internal/model/SystemPostableEventNotifier.java 23 Apr 2007 13:42:09 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2007 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core - ********************************************************************************/ - -package org.eclipse.rse.ui.internal.model; -import org.eclipse.rse.core.events.ISystemResourceChangeEvent; -import org.eclipse.rse.core.events.ISystemResourceChangeListener; -import org.eclipse.swt.widgets.Display; - - -/** - * To support posted events versus synchronous events, this class encapsulates - * the code to execute via the run() method. - *
- * The post behaviour is accomplished by calling the asyncExec method in the swt - * widget Display class. The Display object comes from calling getDisplay() on - * the shell which we get by calling getShell on the given listener. - *
- * By having a separate class we can support multiple simultaneous post event
- * requests by instantiating this class for each request.
- */
-public class SystemPostableEventNotifier implements Runnable
-{
- private ISystemResourceChangeEvent event = null;
- private ISystemResourceChangeListener listener = null;
-
- /**
- * Constructor when the request is to post one event to one listener
- */
- public SystemPostableEventNotifier(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event)
- {
- this.event = event;
- this.listener = listener;
- // fix for 150919
- Display d = Display.getDefault();
- //Display d = listener.getShell().getDisplay();
- //d.asyncExec(this);
- d.syncExec(this);
- }
-
- // -----------------------------
- // java.lang.Runnable methods...
- // -----------------------------
- public void run()
- {
- if (listener != null)
- listener.systemResourceChanged(event);
- }
-
-}
\ No newline at end of file
Index: model/org/eclipse/rse/ui/internal/model/SystemResourceChangeManager.java
===================================================================
RCS file: model/org/eclipse/rse/ui/internal/model/SystemResourceChangeManager.java
diff -N model/org/eclipse/rse/ui/internal/model/SystemResourceChangeManager.java
--- model/org/eclipse/rse/ui/internal/model/SystemResourceChangeManager.java 12 Feb 2008 17:53:03 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,116 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [218659] Make *EventManager, *ChangeManager thread-safe
- ********************************************************************************/
-
-package org.eclipse.rse.ui.internal.model;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-
-
-/**
- * Manages the list of registered resource change listeners.
- */
-public class SystemResourceChangeManager
-{
- private List listeners = new ArrayList();
- private Object lockObject = new Object();
-
- /**
- * Constructor
- */
- public SystemResourceChangeManager()
- {
- }
-
- /**
- * Query if the given listener is already listening for SystemResourceChange events.
- * @param l the listener to check
- * @return
- * As well, all the filter pools for this profile are deleted, and subsequently any
- * cross references from subsystems in connections in other profiles are removed.
- *
- * A delete event is fired for every connection deleted.
- */
- public void deleteSystemProfile(ISystemProfile profile) throws Exception
- {
- // step 0: load the world!
- loadAll(); // force the world into memory!
-
- // step 1: delete subsystems and connections
- IHost[] connections = getHostsByProfile(profile);
- //SystemConnectionPool pool = getConnectionPool(profile);
- for (int idx = 0; idx < connections.length; idx++)
- {
- deleteHost(connections[idx]);
- }
- // step 2: bring to life every factory and ask it to delete all filter pools for this profile
- if (subsystemConfigurationProxies != null)
- {
- for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
- {
- ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
- if (factory != null)
- factory.deletingSystemProfile(profile);
- }
- }
- // last step... physically blow away the profile...
- getSystemProfileManager().deleteSystemProfile(profile, true);
- SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
- if (connections.length > 0) // defect 42112
- fireEvent(new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this));
-
- fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
- profile, null);
- }
-
- /**
- * Make or unmake the given profile active.
- * If switching to inactive, we force a disconnect for all subsystems of all connections in this profile.
- */
- public void setSystemProfileActive(ISystemProfile profile, boolean makeActive)
- {
- // Test if there are any filter pools in this profile that are referenced by another active profile...
- Vector activeReferenceVector = new Vector();
- if (!makeActive && (subsystemConfigurationProxies != null))
- {
- for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
- {
- //if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
- {
- ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
- if (factory != null)
- {
- ISubSystem[] activeReferences = factory.testForActiveReferences(profile);
- if (activeReferences != null)
- for (int jdx = 0; jdx < activeReferences.length; jdx++)
- activeReferenceVector.addElement(activeReferences[jdx]);
- }
- }
- }
- }
- if (activeReferenceVector.size() > 0)
- {
- SystemBasePlugin.logWarning(
- ISystemMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED
- + ": De-Activativing profile " //$NON-NLS-1$
- + profile.getName()
- + " for which there are subsystems containing references to filter pools:"); //$NON-NLS-1$
- for (int idx = 0; idx < activeReferenceVector.size(); idx++)
- {
- ISubSystem activeReference = (ISubSystem) activeReferenceVector.elementAt(idx);
- SystemBasePlugin.logWarning(
- " " + activeReference.getName() + " in connection " + activeReference.getHost().getAliasName() + " in profile " + activeReference.getSystemProfileName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- ISubSystem firstSubSystem = (ISubSystem) activeReferenceVector.elementAt(0);
- String connectionName = firstSubSystem.getHost().getSystemProfileName() + "." + firstSubSystem.getHost().getAliasName(); //$NON-NLS-1$
- //Warning. Profile '%1' should be active. Active connection '%2' contains a reference to it.
- //FIXME I think it should be sufficient to log this as warning rather than open a dialog
- SystemMessage sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED);
- sysMsg.makeSubstitution(profile.getName(), connectionName);
- SystemBasePlugin.logWarning(sysMsg.getFullMessageID() + ": " + sysMsg.getLevelOneText()); //$NON-NLS-1$
- SystemMessageDialog msgDlg = new SystemMessageDialog(null, sysMsg);
- msgDlg.open();
- }
-
- getSystemProfileManager().makeSystemProfileActive(profile, makeActive);
-
- // To be safe, we tell each subsystem factory about the change in status.
- // At a minimum, each factory may have to load the subsystems for connections that
- // are suddenly active.
- if (subsystemConfigurationProxies != null)
- {
- for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
- {
- if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
- {
- ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
- if (factory != null)
- factory.changingSystemProfileActiveStatus(profile, makeActive);
- }
- }
- }
-
- IHost[] affectedConnections = getHostsByProfile(profile);
- //System.out.println("Affected Connection Count: " + affectedConnections.length);
-
- // delete...
- if (!makeActive) // better disconnect all connections before we lose sight of them
- {
- if ((affectedConnections != null) && (affectedConnections.length > 0))
- {
- for (int idx = 0; idx < affectedConnections.length; idx++)
- {
- disconnectAllSubSystems(affectedConnections[idx]);
- }
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this);
- fireEvent(event);
- }
- }
- // add...
- else if ((affectedConnections != null) && (affectedConnections.length > 0))
- {
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_ADD_MANY, this);
- fireEvent(event);
- }
- SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
-
- fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
- profile, null);
- }
-
- // private profile methods...
-
- /**
- * Get a SystemProfile given a connection pool
- */
- private ISystemProfile getSystemProfile(ISystemHostPool pool)
- {
- return pool.getSystemProfile();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getConnectorServices(org.eclipse.rse.core.model.IHost)
- */
- public IConnectorService[] getConnectorServices(IHost host) {
- List services = new ArrayList();
- ISubSystem[] subsystems = getSubSystems(host);
- for (int i = 0; i < subsystems.length; i++) {
- ISubSystem subsystem = subsystems[i];
- IConnectorService service = subsystem.getConnectorService();
- if (!services.contains(service)) {
- services.add(service);
- }
- }
- return (IConnectorService[]) services.toArray(new IConnectorService[services.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost, boolean)
- */
- public ISubSystem[] getSubSystems(IHost host, boolean force) {
- return getSubSystems(host);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost)
- */
- public ISubSystem[] getSubSystems(IHost host) {
- IRSESystemType systemType = host.getSystemType();
- List subsystems = new ArrayList();
- if (subsystemConfigurationProxies != null) {
- for (int i = 0; i < subsystemConfigurationProxies.length; i++) {
- ISubSystemConfigurationProxy proxy = subsystemConfigurationProxies[i];
- if (proxy.appliesToSystemType(systemType)) {
- if (proxy.isSubSystemConfigurationActive()) {
- ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
- ISubSystem[] ssArray = config.getSubSystems(host, false);
- if (ssArray == null) { // create a subsystem for this connection and config
- ssArray = this.createSubSystems(host, new ISubSystemConfiguration[] {config});
- }
- subsystems.addAll(Arrays.asList(ssArray));
- }
- }
- }
- }
- ISubSystem[] result = new ISubSystem[subsystems.size()];
- subsystems.toArray(result);
- return result;
- }
-
- /**
- * Resolve a subsystem from it's absolute name. The absolute name of a subsystem
- * is denoted by profileName.connectionName:subsystemConfigurationId
- *
- * @param absoluteSubSystemName the name of the subsystem
- *
- * @return the subsystem
- */
- public ISubSystem getSubSystem(String absoluteSubSystemName)
- {
- // first extract subsystem id
- int profileDelim = absoluteSubSystemName.indexOf("."); //$NON-NLS-1$
- int connectionDelim = absoluteSubSystemName.indexOf(":", profileDelim + 1); //$NON-NLS-1$
-
- if (profileDelim > 0 && connectionDelim > profileDelim)
- {
- String srcProfileName = absoluteSubSystemName.substring(0, profileDelim);
- String srcConnectionName = absoluteSubSystemName.substring(profileDelim + 1, connectionDelim);
- String srcSubSystemConfigurationId = absoluteSubSystemName.substring(connectionDelim + 1, absoluteSubSystemName.length());
-
- ISystemProfile profile = getSystemProfile(srcProfileName);
- return getSubSystem(profile, srcConnectionName, srcSubSystemConfigurationId);
- }
-
- return null;
- }
-
- /**
- * Resolve a subsystem from it's profile, connection and subsystem name.
- *
- * @param profile the profile to search
- * @param srcConnectionName the name of the connection
- * @param subsystemConfigurationId the factory Id of the subsystem
- *
- * @return the subsystem
- */
- public ISubSystem getSubSystem(ISystemProfile profile, String srcConnectionName, String subsystemConfigurationId)
- {
- // find the src connection
- IHost[] connections = getHostsByProfile(profile);
- if (connections == null)
- {
- // if the profile can't be found, get all connections
- connections = getHosts();
- }
-
- for (int i = 0; i < connections.length; i++)
- {
- IHost connection = connections[i];
- String connectionName = connection.getAliasName();
-
- if (connectionName.equals(srcConnectionName))
- {
- ISubSystem[] subsystems = getSubSystems(connection);
- for (int s = 0; s < subsystems.length; s++)
- {
- ISubSystem subsystem = subsystems[s];
- String compareId = subsystem.getConfigurationId();
- if (compareId.equals(subsystemConfigurationId))
- {
- return subsystem;
- }
- else
- {
- // for migration purposes, test the against the name
- // we used to use the subsystem name instead of the factory Id
- if (subsystem.getName().equals(subsystemConfigurationId))
- {
- return subsystem;
- }
- }
- }
- }
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getAbsoluteNameForSubSystem(org.eclipse.rse.core.subsystems.ISubSystem)
- */
- public String getAbsoluteNameForSubSystem(ISubSystem subSystem)
- {
- StringBuffer dataStream = new StringBuffer();
-
- String profileName = subSystem.getSystemProfileName();
- String connectionName = subSystem.getHostAliasName();
- String factoryId = subSystem.getConfigurationId();
-
- dataStream.append(profileName);
- dataStream.append("."); //$NON-NLS-1$
- dataStream.append(connectionName);
- dataStream.append(":"); //$NON-NLS-1$
- dataStream.append(factoryId);
- return dataStream.toString();
- }
-
- /**
- * Check if two objects refers to the same system object by comparing it absoluteName with its subsystem id.
- *
- * @param firstObject the first object to compare
- * @param firstObjectFullName the full name of the firstObject. If null, get the full name from the firstObject
- * @param secondObject the second object to compare
- * @param secondObjectFullName the full name of the secondObject. If null, get the full name from the secondObject
- */
- public boolean isSameObjectByAbsoluteName(Object firstObject, String firstObjectFullName, Object secondObject, String secondObjectFullName)
- {
- if (firstObject == secondObject)
- {
- return true;
- }
- String firstObjectAbsoluteNameWithSubSystemId = null;
-
- //Simply doing comparason of if two object is equal is not enough
- //If two different objects, but if their absoluate path (with subsystem id)
- //are the same, they refer to the same remote object.
-
- if(firstObject instanceof IAdaptable)
- {
- ISystemDragDropAdapter adapter = null;
-
- adapter = (ISystemDragDropAdapter)((IAdaptable)firstObject).getAdapter(ISystemDragDropAdapter.class);
- String subSystemId = null;
-
- if (adapter != null ) {
- // first need to check subsystems
- ISubSystem subSystem = adapter.getSubSystem(firstObject);
- if (null != subSystem)
- {
- subSystemId = getAbsoluteNameForSubSystem(subSystem);
- }
- else
- {
- subSystemId = ""; //$NON-NLS-1$
- }
-
- if (firstObjectFullName != null)
- {
- firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + firstObjectFullName; //$NON-NLS-1$
- }
- else
- {
- String absolutePath = adapter.getAbsoluteName(firstObject);
- firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$
- }
-
- }
- }
-
-
- String secondObjectAbsoluteNameWithSubSystemId = null;
- if(secondObject instanceof IAdaptable)
- {
- ISystemDragDropAdapter adapter = null;
-
- adapter = (ISystemDragDropAdapter)((IAdaptable)secondObject).getAdapter(ISystemDragDropAdapter.class);
- String subSystemId = null;
-
- if (adapter != null ) {
- // first need to check subsystems
- ISubSystem subSystem = adapter.getSubSystem(secondObject);
- if (null != subSystem)
- {
- subSystemId = getAbsoluteNameForSubSystem(subSystem);
- }
- else
- {
- subSystemId = ""; //$NON-NLS-1$
- }
- if (secondObjectFullName != null)
- {
- secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + secondObjectFullName; //$NON-NLS-1$
- }
- else
- {
- String absolutePath = adapter.getAbsoluteName(secondObject);
- secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$
- }
-
- }
- }
-
- if (firstObjectAbsoluteNameWithSubSystemId != null && firstObjectAbsoluteNameWithSubSystemId.equals(secondObjectAbsoluteNameWithSubSystemId))
- {
- return true;
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getAbsoluteNameForConnection(org.eclipse.rse.core.model.IHost)
- */
- public String getAbsoluteNameForConnection(IHost connection)
- {
- StringBuffer dataStream = new StringBuffer();
-
- String profileName = connection.getSystemProfileName();
- String connectionName = connection.getAliasName();
-
- dataStream.append(profileName);
- dataStream.append("."); //$NON-NLS-1$
- dataStream.append(connectionName);
- return dataStream.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getSubsystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
- */
- public ISubSystem[] getSubsystems(IHost host, Class subsystemInterface)
- {
- List matches = new ArrayList();
- ISubSystem[] allSS = getSubSystems(host);
- for (int i = 0; i < allSS.length; i++)
- {
- ISubSystem ss = allSS[i];
- if (subsystemInterface.isInstance(subsystemInterface))
- {
- matches.add(ss);
- }
- }
- return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getServiceSubSystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
- */
- public ISubSystem[] getServiceSubSystems(IHost host, Class serviceType)
- {
- List matches = new ArrayList();
- ISubSystem[] allSS = getSubSystems(host);
- for (int i = 0; i < allSS.length; i++)
- {
- ISubSystem ss = allSS[i];
- Class thisServiceType = ss.getServiceType();
- if (thisServiceType == serviceType)
- {
- matches.add(ss);
- }
- }
- return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemsBySubSystemConfigurationCategory(java.lang.String, org.eclipse.rse.core.model.IHost)
- */
- public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost host)
- {
- ISubSystem[] subsystems = getSubSystems(host);
- if ((subsystems != null) && (subsystems.length > 0))
- {
- Vector v = new Vector();
- for (int idx = 0; idx < subsystems.length; idx++)
- if (subsystems[idx].getSubSystemConfiguration().getCategory().equals(factoryCategory))
- v.addElement(subsystems[idx]);
- ISubSystem[] sss = new ISubSystem[v.size()];
- for (int idx = 0; idx < sss.length; idx++)
- sss[idx] = (ISubSystem) v.elementAt(idx);
- return sss;
- }
- else
- return (new ISubSystem[0]);
- }
-
- public ISubSystemConfiguration[] getSubSystemConfigurations() {
- // fixed Bugzilla Bug 160115 - added non-null guard for config
- Vector v = new Vector();
- ISubSystemConfigurationProxy[] proxies = getSubSystemConfigurationProxies();
- if (proxies != null) {
- for (int idx = 0; idx < proxies.length; idx++) {
- ISubSystemConfigurationProxy proxy = proxies[idx];
- ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
- if (config != null) {
- v.add(proxies[idx].getSubSystemConfiguration());
- }
- }
- }
- ISubSystemConfiguration[] result = new ISubSystemConfiguration[v.size()];
- v.toArray(result);
- return result;
- }
-
- /**
- * Return Vector of subsystem factories that apply to a given system connection
- */
- protected Vector getSubSystemFactories(IHost conn)
- {
- Vector factories = new Vector();
- errorLoadingFactory = false;
- return getSubSystemFactories(conn, factories);
- }
-
- /**
- * Return Vector of subsystem factories that apply to a given system connection, updating given vector
- */
- protected Vector getSubSystemFactories(IHost conn, Vector factories)
- {
- ISubSystem[] subsystems = getSubSystems(conn);
- if (subsystems != null)
- for (int idx = 0; idx < subsystems.length; idx++)
- {
- ISubSystemConfiguration ssFactory = subsystems[idx].getSubSystemConfiguration();
- if (ssFactory == null)
- errorLoadingFactory = true;
- if ((ssFactory != null) && !factories.contains(ssFactory))
- factories.add(ssFactory);
- }
- return factories;
- }
-
- /**
- * Return Vector of subsystem factories that apply to a given system connection array
- */
- protected Vector getSubSystemFactories(IHost[] conns)
- {
- Vector factories = new Vector();
- errorLoadingFactory = false;
- if (conns != null)
- for (int idx = 0; idx < conns.length; idx++)
- {
- getSubSystemFactories(conns[idx], factories);
- }
- return factories;
- }
-
- /**
- * Delete a subsystem object. This code finds the factory that owns it and
- * delegates the request to that factory.
- */
- public boolean deleteSubSystem(ISubSystem subsystem)
- {
- ISubSystemConfiguration ssFactory = subsystem.getSubSystemConfiguration();
- if (ssFactory == null)
- return false;
- boolean ok = ssFactory.deleteSubSystem(subsystem);
- return ok;
- }
-
- // ----------------------------
- // PRIVATE CONNECTION METHODS...
- // ----------------------------
- /**
- * Return a connection pool given a profile name
- */
- private ISystemHostPool getHostPool(String profileName)
- {
- ISystemProfile profile = getSystemProfileManager().getSystemProfile(profileName);
- if (profile == null)
- {
- return null;
- }
- return getHostPool(profile);
- }
- /**
- * Return a connection pool given a profile
- */
- private ISystemHostPool getHostPool(ISystemProfile profile) {
- ISystemHostPool result = SystemHostPool.getSystemHostPool(profile);
- return result;
- }
-
- /**
- * Return connection pools for active profiles. One per.
- */
- private ISystemHostPool[] getHostPools()
- {
- ISystemProfile[] profiles = getSystemProfileManager().getActiveSystemProfiles();
- ISystemHostPool[] pools = new ISystemHostPool[profiles.length];
- for (int idx = 0; idx < pools.length; idx++)
- {
- try
- {
- pools[idx] = SystemHostPool.getSystemHostPool(profiles[idx]);
- }
- catch (Exception exc)
- {
- }
- }
- return pools;
- }
-
- // ----------------------------
- // PUBLIC CONNECTION METHODS...
- // ----------------------------
-
- /**
- * Return the first connection to localhost we can find. While we always create a default one in
- * the user's profile, it is possible that this profile is not active or the connection was deleted.
- * However, since any connection to localHost will usually do, we just search all active profiles
- * until we find one, and return it.
- * This method:
- *
- * @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 hostName unique connection name.
- * @param hostAddress IP name of host.
- * @param description optional description of the connection. Can be null.
- * @param defaultUserId userId to use as the default for the subsystems.
- * @param defaultUserIdLocation one of the constants in {@link org.eclipse.rse.core.IRSEUserIdConstants}
- * that tells us where to set the user Id
- * @param createSubSystems
+ * As well, all the filter pools for this profile are deleted, and subsequently any
+ * cross references from subsystems in connections in other profiles are removed.
+ *
+ * A delete event is fired for every connection deleted.
+ */
+ public void deleteSystemProfile(ISystemProfile profile) throws Exception
+ {
+ // step 0: load the world!
+ loadAll(); // force the world into memory!
+
+ // step 1: delete subsystems and connections
+ IHost[] connections = getHostsByProfile(profile);
+ //SystemConnectionPool pool = getConnectionPool(profile);
+ for (int idx = 0; idx < connections.length; idx++)
+ {
+ deleteHost(connections[idx]);
+ }
+ // step 2: bring to life every factory and ask it to delete all filter pools for this profile
+ if (subsystemConfigurationProxies != null)
+ {
+ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
+ {
+ ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
+ if (factory != null)
+ factory.deletingSystemProfile(profile);
+ }
+ }
+ // last step... physically blow away the profile...
+ getSystemProfileManager().deleteSystemProfile(profile, true);
+ ////Listening to Events now
+ //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
+ if (connections.length > 0) // defect 42112
+ fireEvent(new SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this));
+
+ fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
+ profile, null);
+ }
+
+ /**
+ * Make or unmake the given profile active.
+ * If switching to inactive, we force a disconnect for all subsystems of all connections in this profile.
+ */
+ public void setSystemProfileActive(ISystemProfile profile, boolean makeActive)
+ {
+ // Test if there are any filter pools in this profile that are referenced by another active profile...
+ Vector activeReferenceVector = new Vector();
+ if (!makeActive && (subsystemConfigurationProxies != null))
+ {
+ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
+ {
+ //if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
+ {
+ ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
+ if (factory != null)
+ {
+ ISubSystem[] activeReferences = factory.testForActiveReferences(profile);
+ if (activeReferences != null)
+ for (int jdx = 0; jdx < activeReferences.length; jdx++)
+ activeReferenceVector.addElement(activeReferences[jdx]);
+ }
+ }
+ }
+ }
+ if (activeReferenceVector.size() > 0)
+ {
+ //RSEG1069: De-Activativing profile {0} for which there are subsystems containing references to filter pools:
+ String msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS, profile.getName());
+ RSECorePlugin.getDefault().getLogger().logWarning(msg);
+ for (int idx = 0; idx < activeReferenceVector.size(); idx++)
+ {
+ //\ \ {refname} in connection {1} in profile {2}
+ ISubSystem activeReference = (ISubSystem) activeReferenceVector.elementAt(idx);
+ msg = " " + activeReference.getName(); //$NON-NLS-1$
+ msg += NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF,
+ activeReference.getHost().getAliasName(),
+ activeReference.getSystemProfileName());
+ RSECorePlugin.getDefault().getLogger().logWarning(msg);
+ }
+ ISubSystem firstSubSystem = (ISubSystem) activeReferenceVector.elementAt(0);
+ String connectionName = firstSubSystem.getHost().getSystemProfileName() + "." + firstSubSystem.getHost().getAliasName(); //$NON-NLS-1$
+ //RSEG1069: Warning. Profile '%1' should be active. Active connection '%2' contains a reference to it.
+ msg = NLS.bind(RSECoreMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED, profile.getName(), connectionName);
+ RSECorePlugin.getDefault().getLogger().logWarning(msg);
+ //// I think it should be sufficient to log this as warning rather than open a dialog
+ //SystemMessage sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED);
+ //sysMsg.makeSubstitution(profile.getName(), connectionName);
+ //SystemMessageDialog msgDlg = new SystemMessageDialog(null, sysMsg);
+ //msgDlg.open();
+ }
+
+ getSystemProfileManager().makeSystemProfileActive(profile, makeActive);
+
+ // To be safe, we tell each subsystem factory about the change in status.
+ // At a minimum, each factory may have to load the subsystems for connections that
+ // are suddenly active.
+ if (subsystemConfigurationProxies != null)
+ {
+ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
+ {
+ if (subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) // don't bother if not yet alive
+ {
+ ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
+ if (factory != null)
+ factory.changingSystemProfileActiveStatus(profile, makeActive);
+ }
+ }
+ }
+
+ IHost[] affectedConnections = getHostsByProfile(profile);
+ //System.out.println("Affected Connection Count: " + affectedConnections.length);
+
+ // delete...
+ if (!makeActive) // better disconnect all connections before we lose sight of them
+ {
+ if ((affectedConnections != null) && (affectedConnections.length > 0))
+ {
+ for (int idx = 0; idx < affectedConnections.length; idx++)
+ {
+ disconnectAllSubSystems(affectedConnections[idx]);
+ }
+ SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this);
+ fireEvent(event);
+ }
+ }
+ // add...
+ else if ((affectedConnections != null) && (affectedConnections.length > 0))
+ {
+ SystemResourceChangeEvent event = new SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_ADD_MANY, this);
+ fireEvent(event);
+ }
+ ////Listening to Events now
+ //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
+
+ fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE,
+ profile, null);
+ }
+
+ // private profile methods...
+
+ /**
+ * Get a SystemProfile given a connection pool
+ */
+ private ISystemProfile getSystemProfile(ISystemHostPool pool)
+ {
+ return pool.getSystemProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getConnectorServices(org.eclipse.rse.core.model.IHost)
+ */
+ public IConnectorService[] getConnectorServices(IHost host) {
+ List services = new ArrayList();
+ ISubSystem[] subsystems = getSubSystems(host);
+ for (int i = 0; i < subsystems.length; i++) {
+ ISubSystem subsystem = subsystems[i];
+ IConnectorService service = subsystem.getConnectorService();
+ if (!services.contains(service)) {
+ services.add(service);
+ }
+ }
+ return (IConnectorService[]) services.toArray(new IConnectorService[services.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost, boolean)
+ */
+ public ISubSystem[] getSubSystems(IHost host, boolean force) {
+ return getSubSystems(host);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(org.eclipse.rse.core.model.IHost)
+ */
+ public ISubSystem[] getSubSystems(IHost host) {
+ IRSESystemType systemType = host.getSystemType();
+ List subsystems = new ArrayList();
+ if (subsystemConfigurationProxies != null) {
+ for (int i = 0; i < subsystemConfigurationProxies.length; i++) {
+ ISubSystemConfigurationProxy proxy = subsystemConfigurationProxies[i];
+ if (proxy.appliesToSystemType(systemType)) {
+ if (proxy.isSubSystemConfigurationActive()) {
+ ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
+ ISubSystem[] ssArray = config.getSubSystems(host, false);
+ if (ssArray == null) { // create a subsystem for this connection and config
+ ssArray = this.createSubSystems(host, new ISubSystemConfiguration[] {config});
+ }
+ subsystems.addAll(Arrays.asList(ssArray));
+ }
+ }
+ }
+ }
+ ISubSystem[] result = new ISubSystem[subsystems.size()];
+ subsystems.toArray(result);
+ return result;
+ }
+
+ /**
+ * Resolve a subsystem from it's absolute name. The absolute name of a subsystem
+ * is denoted by profileName.connectionName:subsystemConfigurationId
+ *
+ * @param absoluteSubSystemName the name of the subsystem
+ *
+ * @return the subsystem
+ */
+ public ISubSystem getSubSystem(String absoluteSubSystemName)
+ {
+ // first extract subsystem id
+ int profileDelim = absoluteSubSystemName.indexOf("."); //$NON-NLS-1$
+ int connectionDelim = absoluteSubSystemName.indexOf(":", profileDelim + 1); //$NON-NLS-1$
+
+ if (profileDelim > 0 && connectionDelim > profileDelim)
+ {
+ String srcProfileName = absoluteSubSystemName.substring(0, profileDelim);
+ String srcConnectionName = absoluteSubSystemName.substring(profileDelim + 1, connectionDelim);
+ String srcSubSystemConfigurationId = absoluteSubSystemName.substring(connectionDelim + 1, absoluteSubSystemName.length());
+
+ ISystemProfile profile = getSystemProfile(srcProfileName);
+ return getSubSystem(profile, srcConnectionName, srcSubSystemConfigurationId);
+ }
+
+ return null;
+ }
+
+ /**
+ * Resolve a subsystem from it's profile, connection and subsystem name.
+ *
+ * @param profile the profile to search
+ * @param srcConnectionName the name of the connection
+ * @param subsystemConfigurationId the factory Id of the subsystem
+ *
+ * @return the subsystem
+ */
+ public ISubSystem getSubSystem(ISystemProfile profile, String srcConnectionName, String subsystemConfigurationId)
+ {
+ // find the src connection
+ IHost[] connections = getHostsByProfile(profile);
+ if (connections == null)
+ {
+ // if the profile can't be found, get all connections
+ connections = getHosts();
+ }
+
+ for (int i = 0; i < connections.length; i++)
+ {
+ IHost connection = connections[i];
+ String connectionName = connection.getAliasName();
+
+ if (connectionName.equals(srcConnectionName))
+ {
+ ISubSystem[] subsystems = getSubSystems(connection);
+ for (int s = 0; s < subsystems.length; s++)
+ {
+ ISubSystem subsystem = subsystems[s];
+ String compareId = subsystem.getConfigurationId();
+ if (compareId.equals(subsystemConfigurationId))
+ {
+ return subsystem;
+ }
+ else
+ {
+ // for migration purposes, test the against the name
+ // we used to use the subsystem name instead of the factory Id
+ if (subsystem.getName().equals(subsystemConfigurationId))
+ {
+ return subsystem;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getAbsoluteNameForSubSystem(org.eclipse.rse.core.subsystems.ISubSystem)
+ */
+ public String getAbsoluteNameForSubSystem(ISubSystem subSystem)
+ {
+ StringBuffer dataStream = new StringBuffer();
+
+ String profileName = subSystem.getSystemProfileName();
+ String connectionName = subSystem.getHostAliasName();
+ String factoryId = subSystem.getConfigurationId();
+
+ dataStream.append(profileName);
+ dataStream.append("."); //$NON-NLS-1$
+ dataStream.append(connectionName);
+ dataStream.append(":"); //$NON-NLS-1$
+ dataStream.append(factoryId);
+ return dataStream.toString();
+ }
+
+ /**
+ * Check if two objects refers to the same system object by comparing it absoluteName with its subsystem id.
+ *
+ * @param firstObject the first object to compare
+ * @param firstObjectFullName the full name of the firstObject. If null, get the full name from the firstObject
+ * @param secondObject the second object to compare
+ * @param secondObjectFullName the full name of the secondObject. If null, get the full name from the secondObject
+ */
+ public boolean isSameObjectByAbsoluteName(Object firstObject, String firstObjectFullName, Object secondObject, String secondObjectFullName)
+ {
+ if (firstObject == secondObject)
+ {
+ return true;
+ }
+ String firstObjectAbsoluteNameWithSubSystemId = null;
+
+ //Simply doing comparason of if two object is equal is not enough
+ //If two different objects, but if their absoluate path (with subsystem id)
+ //are the same, they refer to the same remote object.
+
+ if(firstObject instanceof IAdaptable)
+ {
+ ISystemDragDropAdapter adapter = null;
+
+ adapter = (ISystemDragDropAdapter)((IAdaptable)firstObject).getAdapter(ISystemDragDropAdapter.class);
+ String subSystemId = null;
+
+ if (adapter != null ) {
+ // first need to check subsystems
+ ISubSystem subSystem = adapter.getSubSystem(firstObject);
+ if (null != subSystem)
+ {
+ subSystemId = getAbsoluteNameForSubSystem(subSystem);
+ }
+ else
+ {
+ subSystemId = ""; //$NON-NLS-1$
+ }
+
+ if (firstObjectFullName != null)
+ {
+ firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + firstObjectFullName; //$NON-NLS-1$
+ }
+ else
+ {
+ String absolutePath = adapter.getAbsoluteName(firstObject);
+ firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$
+ }
+
+ }
+ }
+
+
+ String secondObjectAbsoluteNameWithSubSystemId = null;
+ if(secondObject instanceof IAdaptable)
+ {
+ ISystemDragDropAdapter adapter = null;
+
+ adapter = (ISystemDragDropAdapter)((IAdaptable)secondObject).getAdapter(ISystemDragDropAdapter.class);
+ String subSystemId = null;
+
+ if (adapter != null ) {
+ // first need to check subsystems
+ ISubSystem subSystem = adapter.getSubSystem(secondObject);
+ if (null != subSystem)
+ {
+ subSystemId = getAbsoluteNameForSubSystem(subSystem);
+ }
+ else
+ {
+ subSystemId = ""; //$NON-NLS-1$
+ }
+ if (secondObjectFullName != null)
+ {
+ secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + secondObjectFullName; //$NON-NLS-1$
+ }
+ else
+ {
+ String absolutePath = adapter.getAbsoluteName(secondObject);
+ secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$
+ }
+
+ }
+ }
+
+ if (firstObjectAbsoluteNameWithSubSystemId != null && firstObjectAbsoluteNameWithSubSystemId.equals(secondObjectAbsoluteNameWithSubSystemId))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getAbsoluteNameForConnection(org.eclipse.rse.core.model.IHost)
+ */
+ public String getAbsoluteNameForConnection(IHost connection)
+ {
+ StringBuffer dataStream = new StringBuffer();
+
+ String profileName = connection.getSystemProfileName();
+ String connectionName = connection.getAliasName();
+
+ dataStream.append(profileName);
+ dataStream.append("."); //$NON-NLS-1$
+ dataStream.append(connectionName);
+ return dataStream.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getSubsystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
+ */
+ public ISubSystem[] getSubsystems(IHost host, Class subsystemInterface)
+ {
+ List matches = new ArrayList();
+ ISubSystem[] allSS = getSubSystems(host);
+ for (int i = 0; i < allSS.length; i++)
+ {
+ ISubSystem ss = allSS[i];
+ if (subsystemInterface.isInstance(subsystemInterface))
+ {
+ matches.add(ss);
+ }
+ }
+ return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getServiceSubSystems(org.eclipse.rse.core.model.IHost, java.lang.Class)
+ */
+ public ISubSystem[] getServiceSubSystems(IHost host, Class serviceType)
+ {
+ List matches = new ArrayList();
+ ISubSystem[] allSS = getSubSystems(host);
+ for (int i = 0; i < allSS.length; i++)
+ {
+ ISubSystem ss = allSS[i];
+ Class thisServiceType = ss.getServiceType();
+ if (thisServiceType == serviceType)
+ {
+ matches.add(ss);
+ }
+ }
+ return (ISubSystem[])matches.toArray(new ISubSystem[matches.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemsBySubSystemConfigurationCategory(java.lang.String, org.eclipse.rse.core.model.IHost)
+ */
+ public ISubSystem[] getSubSystemsBySubSystemConfigurationCategory(String factoryCategory, IHost host)
+ {
+ ISubSystem[] subsystems = getSubSystems(host);
+ if ((subsystems != null) && (subsystems.length > 0))
+ {
+ Vector v = new Vector();
+ for (int idx = 0; idx < subsystems.length; idx++)
+ if (subsystems[idx].getSubSystemConfiguration().getCategory().equals(factoryCategory))
+ v.addElement(subsystems[idx]);
+ ISubSystem[] sss = new ISubSystem[v.size()];
+ for (int idx = 0; idx < sss.length; idx++)
+ sss[idx] = (ISubSystem) v.elementAt(idx);
+ return sss;
+ }
+ else
+ return (new ISubSystem[0]);
+ }
+
+ public ISubSystemConfiguration[] getSubSystemConfigurations() {
+ // fixed Bugzilla Bug 160115 - added non-null guard for config
+ Vector v = new Vector();
+ ISubSystemConfigurationProxy[] proxies = getSubSystemConfigurationProxies();
+ if (proxies != null) {
+ for (int idx = 0; idx < proxies.length; idx++) {
+ ISubSystemConfigurationProxy proxy = proxies[idx];
+ ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
+ if (config != null) {
+ v.add(proxies[idx].getSubSystemConfiguration());
+ }
+ }
+ }
+ ISubSystemConfiguration[] result = new ISubSystemConfiguration[v.size()];
+ v.toArray(result);
+ return result;
+ }
+
+ /**
+ * Return Vector of subsystem factories that apply to a given system connection
+ */
+ protected Vector getSubSystemFactories(IHost conn)
+ {
+ Vector factories = new Vector();
+ errorLoadingFactory = false;
+ return getSubSystemFactories(conn, factories);
+ }
+
+ /**
+ * Return Vector of subsystem factories that apply to a given system connection, updating given vector
+ */
+ protected Vector getSubSystemFactories(IHost conn, Vector factories)
+ {
+ ISubSystem[] subsystems = getSubSystems(conn);
+ if (subsystems != null)
+ for (int idx = 0; idx < subsystems.length; idx++)
+ {
+ ISubSystemConfiguration ssFactory = subsystems[idx].getSubSystemConfiguration();
+ if (ssFactory == null)
+ errorLoadingFactory = true;
+ if ((ssFactory != null) && !factories.contains(ssFactory))
+ factories.add(ssFactory);
+ }
+ return factories;
+ }
+
+ /**
+ * Return Vector of subsystem factories that apply to a given system connection array
+ */
+ protected Vector getSubSystemFactories(IHost[] conns)
+ {
+ Vector factories = new Vector();
+ errorLoadingFactory = false;
+ if (conns != null)
+ for (int idx = 0; idx < conns.length; idx++)
+ {
+ getSubSystemFactories(conns[idx], factories);
+ }
+ return factories;
+ }
+
+ /**
+ * Delete a subsystem object. This code finds the factory that owns it and
+ * delegates the request to that factory.
+ */
+ public boolean deleteSubSystem(ISubSystem subsystem)
+ {
+ ISubSystemConfiguration ssFactory = subsystem.getSubSystemConfiguration();
+ if (ssFactory == null)
+ return false;
+ boolean ok = ssFactory.deleteSubSystem(subsystem);
+ return ok;
+ }
+
+ // ----------------------------
+ // PRIVATE CONNECTION METHODS...
+ // ----------------------------
+ /**
+ * Return a connection pool given a profile name
+ */
+ private ISystemHostPool getHostPool(String profileName)
+ {
+ ISystemProfile profile = getSystemProfileManager().getSystemProfile(profileName);
+ if (profile == null)
+ {
+ return null;
+ }
+ return getHostPool(profile);
+ }
+ /**
+ * Return a connection pool given a profile
+ */
+ private ISystemHostPool getHostPool(ISystemProfile profile) {
+ ISystemHostPool result = SystemHostPool.getSystemHostPool(profile);
+ return result;
+ }
+
+ /**
+ * Return connection pools for active profiles. One per.
+ */
+ private ISystemHostPool[] getHostPools()
+ {
+ ISystemProfile[] profiles = getSystemProfileManager().getActiveSystemProfiles();
+ ISystemHostPool[] pools = new ISystemHostPool[profiles.length];
+ for (int idx = 0; idx < pools.length; idx++)
+ {
+ try
+ {
+ pools[idx] = SystemHostPool.getSystemHostPool(profiles[idx]);
+ }
+ catch (Exception exc)
+ {
+ }
+ }
+ return pools;
+ }
+
+ // ----------------------------
+ // PUBLIC CONNECTION METHODS...
+ // ----------------------------
+
+ /**
+ * Return the first connection to localhost we can find. While we always create a default one in
+ * the user's profile, it is possible that this profile is not active or the connection was deleted.
+ * However, since any connection to localHost will usually do, we just search all active profiles
+ * until we find one, and return it.
+ * This method:
+ *
+ * @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 hostName unique connection name.
+ * @param hostAddress IP name of host.
+ * @param description optional description of the connection. Can be null.
+ * @param defaultUserId userId to use as the default for the subsystems.
+ * @param defaultUserIdLocation one of the constants in {@link org.eclipse.rse.core.IRSEUserIdConstants}
+ * that tells us where to set the user Id
+ * @param createSubSystems
+ * The post behavior is accomplished by calling the asyncExec method in the SWT
+ * widget Display class. The Display object comes from calling getDisplay() on
+ * the shell which we get by calling getShell on the given listener.
+ *
+ * By having a separate class we can support multiple simultaneous post event
+ * requests by instantiating this class for each request.
+ */
+public class SystemPostableEventNotifier implements Runnable
+{
+ private ISystemResourceChangeEvent event = null;
+ private ISystemResourceChangeListener listener = null;
+
+ /**
+ * Constructor when the request is to post one event to one listener
+ */
+ public SystemPostableEventNotifier(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event)
+ {
+ this.event = event;
+ this.listener = listener;
+ // fix for 150919
+ Display d = Display.getDefault();
+ //Display d = listener.getShell().getDisplay();
+ //d.asyncExec(this);
+ d.syncExec(this);
+ }
+
+ // -----------------------------
+ // java.lang.Runnable methods...
+ // -----------------------------
+ public void run()
+ {
+ if (listener != null)
+ listener.systemResourceChanged(event);
+ }
+
+}
Index: src/org/eclipse/rse/internal/core/model/SystemResourceChangeManager.java
===================================================================
RCS file: src/org/eclipse/rse/internal/core/model/SystemResourceChangeManager.java
diff -N src/org/eclipse/rse/internal/core/model/SystemResourceChangeManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/rse/internal/core/model/SystemResourceChangeManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+/********************************************************************************
+ * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
+ * Martin Oberhuber (Wind River) - [218659] Make *EventManager, *ChangeManager thread-safe
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
+ ********************************************************************************/
+
+package org.eclipse.rse.internal.core.model;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
+import org.eclipse.rse.core.events.ISystemResourceChangeListener;
+
+
+/**
+ * Manages the list of registered resource change listeners.
+ */
+public class SystemResourceChangeManager
+{
+ private List listeners = new ArrayList();
+ private Object lockObject = new Object();
+
+ /**
+ * Constructor
+ */
+ public SystemResourceChangeManager()
+ {
+ }
+
+ /**
+ * Query if the given listener is already listening for SystemResourceChange events.
+ * @param l the listener to check
+ * @return true
if the listener is already registered
- */
- public boolean isRegisteredSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- synchronized(lockObject) {
- return listeners.contains(l);
- }
- }
-
- /**
- * Add a listener to list of listeners.
- * If this object is already in the list, this does nothing.
- * @param l the listener to add
- */
- public void addSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- synchronized(lockObject) {
- if (!listeners.contains(l))
- listeners.add(l);
- }
- }
-
- /**
- * Remove a listener from the list of listeners.
- * If this object is not in the list, this does nothing.
- * @param l the listener to remove
- */
- public void removeSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- synchronized(lockObject) {
- //Thread-safety: create a new List when removing, to avoid problems in notify()
- listeners = new ArrayList(listeners);
- listeners.remove(l);
- }
- }
-
- /**
- * Notify all registered listeners of the given event.
- * @param event the event to send
- */
- public void notify(ISystemResourceChangeEvent event)
- {
- //Thread-safe event firing: fire events on a current snapshot of the list.
- //If not done that way, and a thread removes a listener while event firing
- //is in progress, an ArrayIndexOutOfBoundException might occur.
- List currentListeners;
- synchronized(lockObject) {
- currentListeners = listeners;
- }
- for (int idx=0; idx
- * If no localhost connection is found, this will return null. If one is needed, it can be created
- * easily by calling {@link #createLocalHost(ISystemProfile, String, String)}.
- */
- public IHost getLocalHost()
- {
- IHost localConn = null;
- IRSESystemType localType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
- IHost[] conns = getHostsBySystemType(localType);
- if (conns != null && conns.length > 0) return conns[0];
- else return localConn;
- }
-
- /**
- * Return all connections in all active profiles.
- * Never returns null, but may return a zero-length array.
- * All array elements are valid hosts (never returns null elements).
- */
- public IHost[] getHosts()
- {
- ISystemHostPool[] pools = getHostPools();
- List hosts = new ArrayList();
- for (int idx = 0; idx < pools.length; idx++) {
- IHost[] conns = pools[idx].getHosts();
- if (conns != null) {
- for (int jdx = 0; jdx < conns.length; jdx++) {
- //ISystemHostPool ensures that we never have "null" hosts.
- assert conns[jdx]!=null : "Null host in pool "+pools[idx].getName()+" at "+jdx; //$NON-NLS-1$ //$NON-NLS-2$
- hosts.add(conns[jdx]);
- }
- }
- }
- IHost[] allConns = (IHost[])hosts.toArray(new IHost[hosts.size()]);
- return allConns;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsByProfile(org.eclipse.rse.core.model.ISystemProfile)
- */
- public IHost[] getHostsByProfile(ISystemProfile profile)
- {
- ISystemHostPool pool = getHostPool(profile);
- return pool.getHosts();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySubSystemConfiguration(org.eclipse.rse.core.subsystems.ISubSystemConfiguration)
- */
- public IHost[] getHostsBySubSystemConfiguration(ISubSystemConfiguration factory)
- {
- /* The following algorithm failed because factory.getSubSystems() only returns
- * subsystems that have been restored, which are only those that have been
- * expanded.
- */
- ISubSystem[] subsystems = factory.getSubSystems(true); // true ==> force full restore
- Vector v = new Vector();
- for (int idx = 0; idx < subsystems.length; idx++)
- {
- IHost conn = subsystems[idx].getHost();
- if (!v.contains(conn))
- v.addElement(conn);
- }
- IHost[] conns = new IHost[v.size()];
- for (int idx = 0; idx < v.size(); idx++)
- {
- conns[idx] = (IHost) v.elementAt(idx);
- }
- return conns;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySubSystemConfigurationCategory(java.lang.String)
- */
- public IHost[] getHostsBySubSystemConfigurationCategory(String factoryCategory)
- {
- Vector v = new Vector();
- if (subsystemConfigurationProxies != null)
- {
- for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
- {
- if (subsystemConfigurationProxies[idx].getCategory().equals(factoryCategory))
- {
- ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
- if (factory != null)
- {
- ISubSystem[] subsystems = factory.getSubSystems(true); // true ==> force full restore
- if (subsystems != null)
- for (int jdx = 0; jdx < subsystems.length; jdx++)
- {
- IHost conn = subsystems[jdx].getHost();
- if (!v.contains(conn))
- v.addElement(conn);
- }
- }
- }
- }
- }
- IHost[] conns = new IHost[v.size()];
- for (int idx = 0; idx < v.size(); idx++)
- {
- conns[idx] = (IHost) v.elementAt(idx);
- }
- return conns;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySystemType(org.eclipse.rse.core.IRSESystemType)
- */
- public IHost[] getHostsBySystemType(IRSESystemType systemType) {
- List connections = new ArrayList();
-
- if (systemType != null) {
- IHost[] candidates = getHosts();
- for (int i = 0; i < candidates.length; i++) {
- IHost candidate = candidates[i];
- IRSESystemType candidateType = candidate.getSystemType();
- if (systemType.equals(candidateType)) {
- connections.add(candidate);
- }
- }
- }
-
- return (IHost[])connections.toArray(new IHost[connections.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySystemTypes(org.eclipse.rse.core.IRSESystemType[])
- */
- public IHost[] getHostsBySystemTypes(IRSESystemType[] systemTypes)
- {
- List systemTypesList = Arrays.asList(systemTypes);
- IHost[] connections = getHosts();
- Vector v = new Vector();
- for (int idx = 0; idx < connections.length; idx++)
- {
- IRSESystemType systemType = connections[idx].getSystemType();
- if (systemTypesList.contains(systemType)) {
- v.addElement(connections[idx]);
- }
- }
- return (IHost[])v.toArray(new IHost[v.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHost(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
- */
- public IHost getHost(ISystemProfile profile, String connectionName)
- {
- return getHostPool(profile).getHost(connectionName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostPosition(org.eclipse.rse.core.model.IHost)
- */
- public int getHostPosition(IHost conn)
- {
- ISystemHostPool pool = conn.getHostPool();
- return pool.getHostPosition(conn);
- }
-
- /**
- * Return the zero-based position of a SystemConnection object within all active profiles.
- */
- public int getHostPositionInView(IHost conn)
- {
- IHost[] conns = getHosts();
- int pos = -1;
- for (int idx = 0;(pos == -1) && (idx < conns.length); idx++)
- {
- if (conns[idx] == conn)
- pos = idx;
- }
- return pos;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCount(org.eclipse.rse.core.model.ISystemProfile)
- */
- public int getHostCount(ISystemProfile profile)
- {
- return getHostPool(profile).getHostCount();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCountWithinProfile(org.eclipse.rse.core.model.IHost)
- */
- public int getHostCountWithinProfile(IHost conn)
- {
- return conn.getHostPool().getHostCount();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCount()
- */
- public int getHostCount()
- {
- ISystemHostPool[] pools = getHostPools();
- int total = 0;
- for (int idx = 0; idx < pools.length; idx++)
- {
- total += pools[idx].getHostCount();
- }
- return total;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostAliasNames(org.eclipse.rse.core.model.ISystemProfile)
- */
- public Vector getHostAliasNames(ISystemProfile profile)
- {
- ISystemHostPool pool = getHostPool(profile);
- Vector names = new Vector();
- IHost[] conns = pool.getHosts();
- for (int idx = 0; idx < conns.length; idx++)
- {
- names.addElement(conns[idx].getAliasName());
- }
- return names;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostAliasNamesForAllActiveProfiles()
- */
- public Vector getHostAliasNamesForAllActiveProfiles()
- {
- ISystemHostPool[] allPools = getHostPools();
- Vector allNames = new Vector();
- for (int idx = 0; idx < allPools.length; idx++)
- {
- Vector v = getHostAliasNames(getSystemProfile(allPools[idx]));
- for (int jdx = 0; jdx < v.size(); jdx++)
- allNames.addElement(v.elementAt(jdx));
- }
- return allNames;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#getHostNames(org.eclipse.rse.core.IRSESystemType)
- */
- public String[] getHostNames(IRSESystemType systemType)
- {
- Vector v = new Vector();
-
- if (systemType != null)
- {
- IHost[] conns = getHosts();
- for (int idx = 0; idx < conns.length; idx++)
- {
- // Note: IHost.getHostName() can return null if the connection is using
- // any non-IP based connectivity (serial line, JTAG, ...). Adding
- // null unchecked to the result list will trigger InvalidArgumentExceptions
- // in SystemConnectionForm.
- if (conns[idx].getHostName() != null && !v.contains(conns[idx].getHostName()))
- {
- if (conns[idx].getSystemType().equals(systemType))
- v.addElement(conns[idx].getHostName());
- }
- }
- }
- if ((systemType != null) && (systemType.isLocal() && (v.size() == 0)))
- v.addElement("localhost"); //$NON-NLS-1$
- return (String[])v.toArray(new String[v.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createLocalHost(org.eclipse.rse.core.model.ISystemProfile, java.lang.String, java.lang.String)
- */
- public IHost createLocalHost(ISystemProfile profile, String name, String userId)
- {
- IHost localConn = null;
- if (profile == null)
- profile = getSystemProfileManager().getDefaultPrivateSystemProfile();
- if (profile == null)
- profile = getSystemProfileManager().getActiveSystemProfiles()[0];
-
- try
- {
- IRSESystemType localType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
- localConn = createHost(
- profile.getName(), localType,
- name, // connection name
- "localhost", // hostname //$NON-NLS-1$
- "", // description //$NON-NLS-1$
- // DY: defect 42101, description cannot be null
- // null, // description
- userId, // default user Id
- IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE, null);
-
- }
- catch (Exception exc)
- {
- SystemBasePlugin.logError("Error creating local connection", exc); //$NON-NLS-1$
- }
- return localConn;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, org.eclipse.rse.core.model.ISystemNewConnectionWizardPage[])
- */
- public IHost createHost(
- String profileName,
- IRSESystemType systemType,
- String connectionName,
- String hostName,
- String description,
- String defaultUserId,
- int defaultUserIdLocation,
- ISystemNewConnectionWizardPage[] newConnectionWizardPages)
- throws Exception
- {
- return createHost(profileName, systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation, true, newConnectionWizardPages);
- }
-
- /**
- * Create a host object, given its host pool and its attributes.
- *
- *
- * true
to create subsystems for the host, false
otherwise.
- * @param newConnectionWizardPages when called from the New Connection wizard this is union of the list of additional
- * wizard pages supplied by the subsystem factories that pertain to the specified system type. Else null.
- * @return SystemConnection object, or null if it failed to create. This is typically
- * because the connectionName is not unique. Call getLastException() if necessary.
- */
- // FIXME need to remove ISystemNewConnectionWizardPage[] from this and replace with IAdaptable[]
- public IHost createHost(final String profileName, final IRSESystemType systemType, final String hostName,
- final String hostAddress, final String description, final String defaultUserId,
- final int defaultUserIdLocation, final boolean createSubSystems,
- final ISystemNewConnectionWizardPage[] newConnectionWizardPages) throws Exception {
- final ISystemRegistry sr = this;
- class CreateHostOperation implements ISystemProfileOperation {
- private IHost host = null;
- private ISubSystem[] subsystems = new ISubSystem[0];
- IHost getHost() {
- return host;
- }
- public ISubSystem[] getSubSystems() {
- return subsystems;
- }
- public IStatus run() {
- IStatus status = Status.OK_STATUS;
- ISystemHostPool pool = getHostPool(profileName);
- try {
- // create, register and save new connection...
- String uid = defaultUserId;
- if ((uid != null) && (uid.length() == 0)) {
- uid = null;
- }
- host = pool.createHost(systemType, hostName, hostAddress, description, uid, defaultUserIdLocation);
- if (host == null) { // did not create since host already exists
- host = pool.getHost(hostName);
- }
- } catch (Exception e) {
- String pluginId = RSEUIPlugin.getDefault().getSymbolicName();
- String message = MessageFormat.format("Exception in createHost for {0}", new Object[] {hostName});
- status = new Status(IStatus.ERROR, pluginId, message, e);
- }
- if (status.isOK()) {
- if (createSubSystems) {
- // determine the list of configs to use to create subsystems from
- List configs = new ArrayList(10); // arbitrary but reasonable
- if (newConnectionWizardPages != null) {
- // if there are wizard pages need to at least use those
- for (int i = 0; i < newConnectionWizardPages.length; i++) {
- configs.add(newConnectionWizardPages[i].getSubSystemConfiguration());
- }
- // add any non-service subsystem configs that aren't already there that apply to this systemtype
- ISubSystemConfiguration[] configsArray = getSubSystemConfigurationsBySystemType(systemType, false);
- for (int i = 0; i < configsArray.length; i++) {
- ISubSystemConfiguration config = configsArray[i];
- boolean isStrange = (config.getServiceType() == null);
- 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);
- SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
- return host;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createSubSystems(org.eclipse.rse.core.model.IHost, org.eclipse.rse.core.subsystems.ISubSystemConfiguration[])
- */
- public ISubSystem[] createSubSystems(IHost host, ISubSystemConfiguration[] configurations) {
-
- ISubSystem[] subsystems = new ISubSystem[configurations.length];
-
- for (int i = 0; i < configurations.length; i++) {
- subsystems[i] = configurations[i].createSubSystem(host, true, null);
- }
-
- for (int j = 0; j < subsystems.length; j++) {
- fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsystems[j], null);
- }
-
- host.commit();
- return subsystems;
- }
-
- class NotifyModelChangedRunnable implements Runnable
- {
- private ISystemModelChangeEvent _event;
- public NotifyModelChangedRunnable(ISystemModelChangeEvent event)
- {
- _event = event;
- }
-
- public void run()
- {
- modelListenerManager.notify(_event);
- }
- }
-
- class NotifyResourceChangedRunnable implements Runnable
- {
- private ISystemResourceChangeEvent _event;
- public NotifyResourceChangedRunnable(ISystemResourceChangeEvent event)
- {
- _event = event;
- }
-
- public void run()
- {
- listenerManager.notify(_event);
- }
- }
-
- class NotifyPreferenceChangedRunnable implements Runnable
- {
- private ISystemPreferenceChangeEvent _event;
- public NotifyPreferenceChangedRunnable(ISystemPreferenceChangeEvent event)
- {
- _event = event;
- }
-
- public void run()
- {
- preferenceListManager.notify(_event);
- }
- }
-
- class PreferenceChangedRunnable implements Runnable
- {
- private ISystemPreferenceChangeEvent _event;
- private ISystemPreferenceChangeListener _listener;
-
- public PreferenceChangedRunnable(ISystemPreferenceChangeEvent event, ISystemPreferenceChangeListener listener)
- {
- _event = event;
- _listener = listener;
- }
-
- public void run()
- {
- _listener.systemPreferenceChanged(_event);
- }
- }
-
- class ModelResourceChangedRunnable implements Runnable
- {
- private ISystemModelChangeListener _listener;
- private ISystemModelChangeEvent _event;
- public ModelResourceChangedRunnable(ISystemModelChangeEvent event, ISystemModelChangeListener listener)
- {
- _event = event;
- _listener = listener;
- }
-
- public void run()
- {
- _listener.systemModelResourceChanged(_event);
- }
- }
-
- class ResourceChangedRunnable implements Runnable
- {
- private ISystemResourceChangeListener _listener;
- private ISystemResourceChangeEvent _event;
- public ResourceChangedRunnable(ISystemResourceChangeEvent event, ISystemResourceChangeListener listener)
- {
- _event = event;
- _listener = listener;
- }
-
- public void run()
- {
- _listener.systemResourceChanged(_event);
- }
- }
-
- class RemoteResourceChangedRunnable implements Runnable
- {
- private ISystemRemoteChangeListener _listener;
- private ISystemRemoteChangeEvent _event;
- public RemoteResourceChangedRunnable(ISystemRemoteChangeEvent event, ISystemRemoteChangeListener listener)
- {
- _event = event;
- _listener = listener;
- }
-
- public void run()
- {
- _listener.systemRemoteResourceChanged(_event);
- }
- }
-
- class RemoteChangedRunnable implements Runnable
- {
- private ISystemRemoteChangeEvent _event;
- public RemoteChangedRunnable(ISystemRemoteChangeEvent event)
- {
- _event = event;
- }
-
- public void run()
- {
- remoteListManager.notify(_event);
- }
- }
-
-
- class FireNewHostEvents implements Runnable
- {
- private ISubSystem[] subSystems;
- private IHost conn;
- private ISystemRegistry reg;
-
-
- public FireNewHostEvents(IHost host, ISubSystem[] subSystems, ISystemRegistry registry)
- {
- this.subSystems= subSystems;
- this.conn = host;
- this.reg = registry;
- }
-
- public void run()
- {
- int eventType = ISystemResourceChangeEvents.EVENT_ADD_RELATIVE;
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(conn, eventType, reg);
- //event.setPosition(pool.getConnectionPosition(conn));
- //event.setPosition(getConnectionPositionInView(conn));
- IHost previous = getPreviousHost(conn);
- if (previous != null)
- {
- event.setRelativePrevious(previous);
- }
- else
- {
- event.setType(ISystemResourceChangeEvents.EVENT_ADD);
- }
- fireEvent(event);
- fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
- conn, null);
-
- for (int s = 0; s < subSystems.length; s++)
- {
- ISubSystem ss = subSystems[s];
- fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, ss, null);
- }
- }
- }
-
- private ISystemNewConnectionWizardPage[] getApplicableWizardPages(ISubSystemConfiguration ssf, ISystemNewConnectionWizardPage[] allPages)
- {
- if ((allPages == null) || (allPages.length == 0))
- return null;
- int count = 0;
- for (int idx = 0; idx < allPages.length; idx++)
- if (allPages[idx].getSubSystemConfiguration() == ssf)
- ++count;
- if (count == 0)
- return null;
- ISystemNewConnectionWizardPage[] subPages = new ISystemNewConnectionWizardPage[count];
- count = 0;
- for (int idx = 0; idx < allPages.length; idx++)
- if (allPages[idx].getSubSystemConfiguration() == ssf)
- subPages[count++] = allPages[idx];
- return subPages;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String)
- */
- public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description)
- throws Exception
- {
- return createHost(profileName, systemType, connectionName, hostName, description, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, boolean)
- */
- public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description, boolean createSubSystems) throws Exception
- {
- return createHost(profileName, systemType, connectionName, hostName, description, null, IRSEUserIdConstants.USERID_LOCATION_HOST, createSubSystems, null);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String)
- */
- public IHost createHost(IRSESystemType systemType, String connectionName, String hostName, String description)
- throws Exception
- {
- ISystemProfile profile = getSystemProfileManager().getDefaultPrivateSystemProfile();
- if (profile == null)
- profile = getSystemProfileManager().getActiveSystemProfiles()[0];
- return createHost(profile.getName(), systemType, connectionName, hostName, description);
- }
-
- /**
- * Return the previous connection as would be shown in the view
- */
- protected IHost getPreviousHost(IHost conn)
- {
- IHost prevConn = null;
- ISystemHostPool pool = conn.getHostPool();
- int pos = pool.getHostPosition(conn);
- if (pos > 0)
- prevConn = pool.getHost(pos - 1);
- else
- {
- IHost allConns[] = getHosts();
- if (allConns != null)
- {
- pos = getHostPositionInView(conn);
- if (pos > 0)
- prevConn = allConns[pos - 1];
- }
- }
- return prevConn;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#updateHost(org.eclipse.rse.core.model.IHost, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)
- */
- public void updateHost(IHost conn, IRSESystemType systemType, String connectionName, String hostName, String description, String defaultUserId, int defaultUserIdLocation)
- {
- lastException = null;
- boolean connectionNameChanged = !connectionName.equalsIgnoreCase(conn.getAliasName());
- boolean hostNameChanged = !hostName.equalsIgnoreCase(conn.getHostName());
- String orgDefaultUserId = conn.getDefaultUserId();
- boolean defaultUserIdChanged = false;
- if ((defaultUserId == null) || (orgDefaultUserId == null))
- {
- if (orgDefaultUserId != defaultUserId)
- defaultUserIdChanged = true;
- }
- else
- defaultUserIdChanged = !conn.compareUserIds(defaultUserId, orgDefaultUserId); // d43219
- //!defaultUserId.equalsIgnoreCase(orgDefaultUserId);
-
- try
- {
- if (connectionNameChanged)
- renameHost(conn, connectionName);
- conn.getHostPool().updateHost(conn, systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation);
- }
- catch (SystemMessageException exc)
- {
- SystemBasePlugin.logError("Exception in updateConnection for " + connectionName, exc); //$NON-NLS-1$
- lastException = exc;
- return;
- }
- catch (Exception exc)
- {
- SystemBasePlugin.logError("Exception in updateConnection for " + connectionName, exc); //$NON-NLS-1$
- lastException = exc;
- return;
- }
- boolean skipUpdate = (defaultUserIdChanged && !hostNameChanged && !connectionNameChanged);
- if (!skipUpdate) fireEvent(new SystemResourceChangeEvent(
- //conn,ISystemResourceChangeEvent.EVENT_CHANGE,this));
- conn, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, this)); // only update simple property sheet values here
- if (!skipUpdate) fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
- conn, null);
-
- if (hostNameChanged || defaultUserIdChanged)
- {
- ISubSystem[] subsystems = getSubSystems(conn); // get list of related subsystems
- for (int idx = 0; idx < subsystems.length; idx++)
- {
- if (hostNameChanged || (subsystems[idx].getLocalUserId() == null))
- {
- try
- {
- if (subsystems[idx].isConnected()) subsystems[idx].disconnect(); // MJB: added conditional for defect 45754
- if (defaultUserIdChanged)
- {
- subsystems[idx].getConnectorService().clearCredentials();
- }
- subsystems[idx].getConnectorService().clearPassword(false, true);
- }
- catch (Exception exc)
- {
- } // msg already shown
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#setHostOffline(org.eclipse.rse.core.model.IHost, boolean)
- */
- public void setHostOffline(IHost conn, boolean offline)
- {
- if (conn.isOffline() != offline)
- {
- conn.setOffline(offline);
- saveHost(conn);
- fireEvent(new SystemResourceChangeEvent(conn, ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE, null));
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#deleteHost(org.eclipse.rse.core.model.IHost)
- */
- public void deleteHost(IHost conn)
- {
- Vector affectedSubSystemFactories = getSubSystemFactories(conn);
- for (int idx = 0; idx < affectedSubSystemFactories.size(); idx++)
- {
- ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).deleteSubSystemsByConnection(conn);
- }
- conn.getHostPool().deleteHost(conn); // delete from memory and from disk.
- SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
- fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
- conn, null);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#renameHost(org.eclipse.rse.core.model.IHost, java.lang.String)
- */
- public void renameHost(IHost conn, String newName) throws Exception
- {
- // first, pre-test for folder-in-use error:
-
- // it looks good, so proceed...
- String oldName = conn.getAliasName();
-
-
- // DKM - changing how this is done since there are services with different configurations now
- ISubSystem[] subsystems = conn.getSubSystems();
- for (int i = 0; i < subsystems.length; i++)
- {
- ISubSystem ss = subsystems[i];
- ss.getSubSystemConfiguration().renameSubSystemsByConnection(conn, newName);
- }
-
- /*
- Vector affectedSubSystemFactories = getSubSystemFactories(conn);
- for (int idx = 0; idx < affectedSubSystemFactories.size(); idx++)
- ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).renameSubSystemsByConnection(conn, newName);
- */
- conn.getHostPool().renameHost(conn, newName); // rename in memory and disk
- SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
- fireModelChangeEvent(
- ISystemModelChangeEvents.SYSTEM_RESOURCE_RENAMED,
- ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
- conn, oldName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#moveHosts(java.lang.String, org.eclipse.rse.core.model.IHost[], int)
- * FIXME PROBLEM: CAN'T RE-ORDER FOLDERS SO CAN WE SUPPORT THIS ACTION?
- */
- public void moveHosts(String profileName, IHost conns[], int delta)
- {
- ISystemHostPool pool = getHostPool(profileName);
- pool.moveHosts(conns, delta);
- SystemPreferencesManager.setConnectionNamesOrder();
- //fireEvent(new SystemResourceChangeEvent(pool.getSystemConnections(),ISystemResourceChangeEvent.EVENT_MOVE_MANY,this));
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(conns, ISystemResourceChangeEvents.EVENT_MOVE_MANY, this);
- event.setPosition(delta);
- fireEvent(event);
- // fire new model change event, which BPs might listen for...
- for (int idx=0; idxtrue
if there are any matching subsystem configurations not yet instantiated.
- */
- public boolean hasInactiveSubsystemConfigurations(IRSESystemType systemType)
- {
- if (subsystemConfigurationProxies != null)
- {
- for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
- {
- if (!subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()
- && subsystemConfigurationProxies[idx].appliesToSystemType(systemType))
- {
- return true;
- }
- }
- }
- return false;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#areAllSubSystemsConnected(org.eclipse.rse.core.model.IHost)
- */
- public boolean areAllSubSystemsConnected(IHost conn)
- {
- boolean all = true;
- if (hasInactiveSubsystemConfigurations(conn.getSystemType())) {
- //any uninitialized subsystem configuration that applies to the system type can not be connected.
- //TODO this may change in the future: We might want to have markup in the plugin.xml
- //to check whether a subsystem configuration is actually connectable or not
- return false;
- }
-
- //May force load subsystem configurations here because there are no inactive ones for our system type.
- //Do we need to force load actual subsystems too, just to check if they are connected?
- ISubSystem[] subsystems = getSubSystems(conn);
- if (subsystems == null) {
- //If there are no subsystems, they are all connected.
- return true;
- }
-
- for (int idx = 0; all && (idx < subsystems.length); idx++)
- {
- ISubSystem ss = subsystems[idx];
- if (!ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect())
- {
- //we ignore unconnected subsystems that can not be connected anyways.
- return false;
- }
- }
- return all;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#disconnectAllSubSystems(org.eclipse.rse.core.model.IHost)
- */
- public void disconnectAllSubSystems(IHost conn)
- {
- // get subsystems lazily, because not instantiated ones cannot be disconnected anyways.
- ISubSystem[] subsystems = getSubSystems(conn);
- if (subsystems == null)
- return;
-
- // dy: defect 47281, user repeatedly prompted to disconnect if there is an open file
- // and they keep hitting cancel.
- boolean cancelled = false;
- for (int idx = 0; idx < subsystems.length && !cancelled; idx++)
- {
- ISubSystem ss = subsystems[idx];
- if (ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect())
- {
- try
- {
- //ss.getConnectorService().disconnect(); defect 40675
- ss.disconnect();
- }
- catch (InterruptedException exc)
- {
- System.out.println("Cancelled"); //$NON-NLS-1$
- cancelled = true;
- }
- catch (Exception exc)
- {
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#connectedStatusChange(org.eclipse.rse.core.subsystems.ISubSystem, boolean, boolean)
- */
- public void connectedStatusChange(ISubSystem subsystem, boolean connected, boolean wasConnected)
- {
- connectedStatusChange(subsystem, connected, wasConnected, true);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.model.ISystemRegistry#connectedStatusChange(org.eclipse.rse.core.subsystems.ISubSystem, boolean, boolean, boolean)
- */
- public void connectedStatusChange(ISubSystem subsystem, boolean connected, boolean wasConnected, boolean collapseTree)
- {
- //System.out.println("INSIDE CONNECTEDSTATUSCHANGE: "+connected+" vs "+wasConnected);
- IHost conn = subsystem.getHost();
- //int eventId = ISystemResourceChangeEvent.EVENT_CHANGE;
- //int eventId = ISystemResourceChangeEvent.EVENT_PROPERTY_CHANGE;
- if (connected != wasConnected)
- {
- int eventId = ISystemResourceChangeEvents.EVENT_ICON_CHANGE;
- fireEvent(new SystemResourceChangeEvent(conn, eventId, this));
-
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(subsystem, eventId, conn);
- fireEvent(event);
-
- // DKM
- // fire for each subsystem
- ISubSystem[] sses = getSubSystems(conn);
- for (int i = 0; i < sses.length; i++)
- {
- ISubSystem ss = sses[i];
- if (ss != subsystem)
- {
- SystemResourceChangeEvent sevent = new SystemResourceChangeEvent(ss, eventId, conn);
- fireEvent(sevent);
-
- sevent.setType(ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE); // update vrm
- fireEvent(sevent);
- }
- }
-
-
- // DY: Conditioning of property change event type has been removed so
- // that the connected property is updated on a disconnect.
- //if (connected)
- event.setType(ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE); // update vrm
-
- fireEvent(event);
- }
- if (!connected && wasConnected && collapseTree)
- {
- invalidateFiltersFor(subsystem);
- fireEvent(new SystemResourceChangeEvent(subsystem, ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE, this));
-
- ISubSystem[] sses = getSubSystems(conn);
- for (int i = 0; i < sses.length; i++)
- {
- ISubSystem ss = sses[i];
- if (ss != subsystem && !ss.isConnected())
- {
- invalidateFiltersFor(ss);
- SystemResourceChangeEvent sevent = new SystemResourceChangeEvent(ss, ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE, conn);
- fireEvent(sevent);
- }
- }
- }
- }
-
- // ----------------------------
- // RESOURCE EVENT METHODS...
- // ----------------------------
-
- /**
- * Register your interest in being told when a system resource such as a connection is changed.
- */
- public void addSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- listenerManager.addSystemResourceChangeListener(l);
- listenerCount++;
- }
- /**
- * De-Register your interest in being told when a system resource such as a connection is changed.
- */
- public void removeSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- listenerManager.removeSystemResourceChangeListener(l);
- listenerCount--;
- }
- /**
- * Query if the ISystemResourceChangeListener is already listening for SystemResourceChange events
- */
- public boolean isRegisteredSystemResourceChangeListener(ISystemResourceChangeListener l)
- {
- return listenerManager.isRegisteredSystemResourceChangeListener(l);
- }
- /**
- * Notify all listeners of a change to a system resource such as a connection.
- * You would not normally call this as the methods in this class call it when appropriate.
- */
- public void fireEvent(ISystemResourceChangeEvent event)
- {
- Object src = event.getSource();
- if (src instanceof ISystemFilter)
- {
- IRSEBaseReferencingObject[] references = ((ISystemFilter)src).getReferencingObjects();
- for (int i = 0; i < references.length; i++)
- {
- IRSEBaseReferencingObject ref = references[i];
- if (ref instanceof ISystemContainer)
- {
- ((ISystemContainer)ref).markStale(true);
- }
- }
- }
-
- if (onMainThread()) {
- listenerManager.notify(event);
- }
- else {
- runOnMainThread(new NotifyResourceChangedRunnable(event));
- }
-
- }
- /**
- * Notify a specific listener of a change to a system resource such as a connection.
- */
- public void fireEvent(ISystemResourceChangeListener l, ISystemResourceChangeEvent event)
- {
- if (onMainThread()) {
- l.systemResourceChanged(event);
- }
- else {
- runOnMainThread(new ResourceChangedRunnable(event, l));
- }
- }
-
- /**
- * Return the listener manager such that the SystemRegistryUI
- * can re-use it for posting events that can only be posted
- * in UI.
- * @return the System resource change listener manager
- * used by the registry.
- */
- public SystemResourceChangeManager getResourceChangeManager() {
- return listenerManager;
- }
-
- // ----------------------------
- // MODEL RESOURCE EVENT METHODS...
- // ----------------------------
-
- /**
- * Register your interest in being told when an RSE model resource is changed.
- * These are model events, not GUI-optimized events.
- */
- public void addSystemModelChangeListener(ISystemModelChangeListener l)
- {
- modelListenerManager.addSystemModelChangeListener(l);
- modelListenerCount++;
- }
- /**
- * De-Register your interest in being told when an RSE model resource is changed.
- */
- public void removeSystemModelChangeListener(ISystemModelChangeListener l)
- {
- modelListenerManager.removeSystemModelChangeListener(l);
- modelListenerCount--;
- }
-
- private boolean onMainThread()
- {
- return Display.getCurrent() != null;
- }
-
- private void runOnMainThread(Runnable runnable)
- {
- Display.getDefault().asyncExec(runnable);
- }
-
- /**
- * Notify all listeners of a change to a system model resource such as a connection.
- * You would not normally call this as the methods in this class call it when appropriate.
- */
- public void fireEvent(ISystemModelChangeEvent event)
- {
- if (onMainThread()) {
- modelListenerManager.notify(event);
- }
- else {
- // fire this on the main thread
- runOnMainThread(new NotifyModelChangedRunnable(event));
- }
- }
- /**
- * Notify all listeners of a change to a system model resource such as a connection.
- * This one takes the information needed and creates the event for you.
- */
- public void fireModelChangeEvent(int eventType, int resourceType, Object resource, String oldName)
- {
- if (modelEvent == null)
- modelEvent = new SystemModelChangeEvent();
- modelEvent.setEventType(eventType);
- modelEvent.setResourceType(resourceType);
- modelEvent.setResource(resource);
- modelEvent.setOldName(oldName);
-
- if (onMainThread()) {
- modelListenerManager.notify(modelEvent);
- }
- else {
- // fire this one the main thread
- runOnMainThread(new NotifyModelChangedRunnable(modelEvent));
- }
- }
-
-
-
- /**
- * Notify a specific listener of a change to a system model resource such as a connection.
- */
- public void fireEvent(ISystemModelChangeListener l, ISystemModelChangeEvent event)
- {
- if (onMainThread()) {
- l.systemModelResourceChanged(event);
- }
- else {
- runOnMainThread(new ModelResourceChangedRunnable(event, l));
- }
- }
-
- // --------------------------------
- // REMOTE RESOURCE EVENT METHODS...
- // --------------------------------
-
- /**
- * Register your interest in being told when a remote resource is changed.
- * These are model events, not GUI-optimized events.
- */
- public void addSystemRemoteChangeListener(ISystemRemoteChangeListener l)
- {
- remoteListManager.addSystemRemoteChangeListener(l);
- remoteListCount++;
- }
- /**
- * De-Register your interest in being told when a remote resource is changed.
- */
- public void removeSystemRemoteChangeListener(ISystemRemoteChangeListener l)
- {
- remoteListManager.removeSystemRemoteChangeListener(l);
- remoteListCount--;
- }
-
- /**
- * Query if the ISystemRemoteChangeListener is already listening for SystemRemoteChange events
- */
- public boolean isRegisteredSystemRemoteChangeListener(ISystemRemoteChangeListener l)
- {
- return remoteListManager.isRegisteredSystemRemoteChangeListener(l);
- }
-
- /**
- * Notify all listeners of a change to a remote resource such as a file.
- * You would not normally call this as the methods in this class call it when appropriate.
- */
- public void fireEvent(ISystemRemoteChangeEvent event)
- {
- if (onMainThread()) {
- remoteListManager.notify(event);
- }
- else {
- runOnMainThread(new RemoteChangedRunnable(event));
- }
- }
-
- /**
- * Notify all listeners of a change to a remote resource such as a file.
- * This one takes the information needed and creates the event for you.
- * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents}
- * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter
- * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent.
- * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be
- * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection.
- * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename
- */
- public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName)
- {
- if (resourceParent instanceof ISystemContainer)
- {
- ((ISystemContainer)resourceParent).markStale(true);
- }
- // mark stale any filters that reference this object
- invalidateFiltersFor(resourceParent, subsystem);
-
- if (remoteEvent == null)
- remoteEvent = new SystemRemoteChangeEvent();
- remoteEvent.setEventType(eventType);
- remoteEvent.setResource(resource);
- remoteEvent.setResourceParent(resourceParent);
- remoteEvent.setOldName(oldName);
- remoteEvent.setSubSystem(subsystem);
-
- if (onMainThread())
- {
- remoteListManager.notify(remoteEvent);
- }
- else
- {
- runOnMainThread(new RemoteChangedRunnable(remoteEvent));
- }
- }
-
- /**
- * Notify all listeners of a change to a remote resource such as a file.
- * This one takes the information needed and creates the event for you.
- * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents}
- * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter
- * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent.
- * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be
- * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection.
- * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename
- * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent.
- * This saves sending a separate event to reveal and select the new created resource on a create event, for example.
- */
- public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName, Object originatingViewer)
- {
- if (resourceParent instanceof ISystemContainer)
- {
- ((ISystemContainer)resourceParent).markStale(true);
- }
- // mark stale any filters that reference this object
- invalidateFiltersFor(resourceParent, subsystem);
-
- //if (remoteEvent == null)
- remoteEvent = new SystemRemoteChangeEvent();
- remoteEvent.setEventType(eventType);
- remoteEvent.setResource(resource);
- remoteEvent.setResourceParent(resourceParent);
- remoteEvent.setOldName(oldName);
- remoteEvent.setSubSystem(subsystem);
- remoteEvent.setOriginatingViewer(originatingViewer);
-
- if (onMainThread())
- {
- remoteListManager.notify(remoteEvent);
- }
- else
- {
- runOnMainThread(new RemoteChangedRunnable(remoteEvent));
- }
- }
-
- /**
- * Returns the implementation of ISystemRemoteElement for the given
- * object. Returns null if this object does not adaptable to this.
- */
- protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
- {
- return SystemAdapterHelpers.getRemoteAdapter(o);
- }
-
- private String getRemoteResourceAbsoluteName(Object remoteResource)
- {
- if (remoteResource == null)
- return null;
- String remoteResourceName = null;
- if (remoteResource instanceof String)
- remoteResourceName = (String)remoteResource;
- else if (remoteResource instanceof SystemFilterReference)
- {
- ISystemFilterReference ref = (ISystemFilterReference)remoteResource;
- ISubSystem ss = ref.getSubSystem();
- remoteResource = ss.getTargetForFilter(ref);
- ISystemRemoteElementAdapter ra = getRemoteAdapter(remoteResource);
- if (ra == null)
- return null;
- remoteResourceName = ra.getAbsoluteName(remoteResource);
- }
- else
- {
- ISystemRemoteElementAdapter ra = getRemoteAdapter(remoteResource);
- if (ra == null)
- return null;
- remoteResourceName = ra.getAbsoluteName(remoteResource);
- }
- return remoteResourceName;
- }
-
- private List findFilterReferencesFor(ISubSystem subsystem)
- {
- List results = new ArrayList();
- if (subsystem != null)
- {
- ISystemFilterPoolReferenceManager refmgr = subsystem.getFilterPoolReferenceManager();
- if (refmgr != null)
- {
- ISystemFilterReference[] refs = refmgr.getSystemFilterReferences(subsystem);
- for (int i = 0; i < refs.length; i++)
- {
- ISystemFilterReference filterRef = refs[i];
-
- if (!filterRef.isStale() && filterRef.hasContents(SystemChildrenContentsType.getInstance()))
- {
- results.add(filterRef);
- }
- }
-
- }
- }
- return results;
-
- }
-
- public List findFilterReferencesFor(Object resource, ISubSystem subsystem)
- {
- return findFilterReferencesFor(resource, subsystem, true);
- }
-
- public List findFilterReferencesFor(Object resource, ISubSystem subsystem, boolean onlyCached)
- {
- String elementName = getRemoteResourceAbsoluteName(resource);
- List results = new ArrayList();
- if (subsystem != null && elementName != null && subsystem.getSubSystemConfiguration().supportsFilters())
- {
- ISystemFilterReference[] refs = subsystem.getFilterPoolReferenceManager().getSystemFilterReferences(subsystem);
- for (int i = 0; i < refs.length; i++)
- {
- ISystemFilterReference filterRef = refs[i];
-
- if (!onlyCached || (!filterRef.isStale() && filterRef.hasContents(SystemChildrenContentsType.getInstance())))
-
- {
- // #1
- if (subsystem.doesFilterMatch(filterRef.getReferencedFilter(), elementName))
- {
- results.add(filterRef); // found a match!
-
- }
- // #2
- else if (subsystem.doesFilterListContentsOf(filterRef.getReferencedFilter(),elementName))
- {
- results.add(filterRef); // found a match!
- }
- }
- }
-
-
- }
- return results;
-
- }
-
- public void invalidateFiltersFor(ISubSystem subsystem)
- {
- if (subsystem != null)
- {
-
- List results = findFilterReferencesFor(subsystem);
- for (int i = 0; i < results.size(); i++)
- {
- ((ISystemFilterReference)results.get(i)).markStale(true);
- }
- }
- }
-
- public void invalidateFiltersFor(Object resourceParent, ISubSystem subsystem)
- {
- if (subsystem != null)
- {
-
- List results = findFilterReferencesFor(resourceParent, subsystem);
- for (int i = 0; i < results.size(); i++)
- {
- ((ISystemFilterReference)results.get(i)).markStale(true);
- }
- }
- }
-
- /**
- * Notify a specific listener of a change to a remote resource such as a file.
- */
- public void fireEvent(ISystemRemoteChangeListener l, ISystemRemoteChangeEvent event)
- {
- if (onMainThread()) {
- l.systemRemoteResourceChanged(event);
- }
- else {
- runOnMainThread(new RemoteResourceChangedRunnable(event, l));
- }
-
- }
-
- // ----------------------------
- // PREFERENCE EVENT METHODS...
- // ----------------------------
-
- /**
- * Register your interest in being told when a system preference changes
- */
- public void addSystemPreferenceChangeListener(ISystemPreferenceChangeListener l)
- {
- preferenceListManager.addSystemPreferenceChangeListener(l);
- }
- /**
- * De-Register your interest in being told when a system preference changes
- */
- public void removeSystemPreferenceChangeListener(ISystemPreferenceChangeListener l)
- {
- preferenceListManager.removeSystemPreferenceChangeListener(l);
- }
- /**
- * Notify all listeners of a change to a system preference
- * You would not normally call this as the methods in this class call it when appropriate.
- */
- public void fireEvent(ISystemPreferenceChangeEvent event)
- {
- if (onMainThread()) {
- preferenceListManager.notify(event);
- }
- else {
- runOnMainThread(new NotifyPreferenceChangedRunnable(event));
- }
- }
- /**
- * Notify a specific listener of a change to a system preference
- */
- public void fireEvent(ISystemPreferenceChangeListener l, ISystemPreferenceChangeEvent event)
- {
- if (onMainThread()) {
- l.systemPreferenceChanged(event);
- }
- else {
- runOnMainThread(new PreferenceChangedRunnable(event, l));
- }
- }
-
- // ----------------------------
- // MISCELLANEOUS METHODS...
- // ----------------------------
-
- /**
- * Load everything into memory. Needed for pervasive operations like rename and copy
- */
- public void loadAll()
- {
- // step 0_a: force every subsystem factory to be active
- ISubSystemConfigurationProxy[] proxies = getSubSystemConfigurationProxies();
- if (proxies != null)
- {
- for (int idx = 0; idx < proxies.length; idx++)
- proxies[idx].getSubSystemConfiguration();
- }
-
- // step 0_b: force every subsystem of every connection to be active!
- IHost[] connections = getHosts();
- for (int idx = 0; idx < connections.length; idx++)
- getSubSystems(connections[idx]);
- }
-
- /**
- * Return last exception object caught in any method, or null if no exception.
- * This has the side effect of clearing the last exception.
- */
- public Exception getLastException()
- {
- Exception last = lastException;
- lastException = null;
- return last;
- }
-
- // ----------------------------
- // SAVE / RESTORE METHODS...
- // ----------------------------
-
- /**
- * Save everything!
- */
- public boolean save()
- {
- ISystemProfile[] notSaved = RSECorePlugin.getThePersistenceManager().commitProfiles(5000);
- return notSaved.length > 0;
- }
-
- /**
- * Save specific connection pool
- * @return true if saved ok, false if error encountered. If false, call getLastException().
- */
- public boolean saveHostPool(ISystemHostPool pool)
- {
- return pool.commit();
- }
-
- /**
- * Save specific connection
- * @return true if saved ok, false if error encountered. If false, call getLastException().
- */
- public boolean saveHost(IHost conn)
- {
- return conn.commit();
- }
-
- /**
- * Restore all connections within active profiles
- * @return true if restored ok, false if error encountered. If false, call getLastException().
- */
- public boolean restore()
- {
- boolean ok = true;
- lastException = null;
- /*
- SystemProfileManager profileManager = SystemStartHere.getSystemProfileManager();
-
- SystemHostPool pool = null;
- SystemPreferencesManager prefmgr = SystemPreferencesManager.getPreferencesManager();
- if (!RSEUIPlugin.getThePersistenceManager().restore(profileManager))
- {
- SystemProfile[] profiles = profileManager.getActiveSystemProfiles();
- for (int idx = 0; idx < profiles.length; idx++)
- {
- try
- {
- pool = SystemHostPoolImpl.getSystemConnectionPool(profiles[idx]);
- Host[] conns = pool.getHosts();
- pool.orderHosts(prefmgr.getConnectionNamesOrder(conns, pool.getName()));
- }
- catch (Exception exc)
- {
- lastException = exc;
- RSEUIPlugin.logError("Exception in restore for connection pool " + profiles[idx].getName(), exc);
- }
- }
- }
- */
- return ok;
- }
- public boolean contains(ISchedulingRule rule)
- {
- return rule == this;
- }
- public boolean isConflicting(ISchedulingRule rule)
- {
- return rule == this;
- }
- public ISystemFilterStartHere getSystemFilterStartHere() {
- return SystemFilterStartHere.getInstance();
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
-
- /**
- * Return the children objects to constitute the root elements in the system view tree.
- * We return all connections for all active profiles.
- */
- public Object[] getSystemViewRoots()
- {
- //DKM - only return enabled connections now
- IHost[] connections = getHosts();
- List result = new ArrayList();
- for (int i = 0; i < connections.length; i++) {
- IHost con = connections[i];
- IRSESystemType sysType = con.getSystemType();
- if (sysType != null) { // sysType can be null if workspace contains a host that is no longer defined by the workbench
- RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(RSESystemTypeAdapter.class));
- // Note: System types without registered subsystems get disabled by the adapter itself!
- // There is no need to re-check this here again.
- if (adapter.isEnabled(sysType)) result.add(con);
- }
- }
- return result.toArray();
- }
-
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true if there are any connections for any active profile.
- */
- public boolean hasSystemViewRoots()
- {
- return (getHostCount() > 0);
- }
-
- /**
- * Return true if we are listing connections or not, so we know whether
- * we are interested in connection-add events
- */
- public boolean showingConnections()
- {
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setShell(java.lang.Object)
- */
- public void setShell(Object shell)
- {
- this.shell = shell;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.ui.model.ISystemShellProvider#getShell()
- */
- public Object getShell()
- {
-// // thread safe shell
-// IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench();
-// if (workbench != null)
-// {
-// // first try to get the active workbench window
-// IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
-// if (ww == null) // no active window so just get the first one
-// ww = workbench.getWorkbenchWindows()[0];
-// if (ww != null)
-// {
-// Shell shell = ww.getShell();
-// if (!shell.isDisposed())
-// {
-// return shell;
-// }
-// }
-// }
-// return null;
- return this.shell;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setViewer(java.lang.Object)
- */
- public void setViewer(Object viewer)
- {
- this.viewer = viewer;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getViewer()
- */
- public Object getViewer()
- {
- return viewer;
- }
-
-
-}//SystemRegistryImpl
\ No newline at end of file
Index: UI/org/eclipse/rse/internal/ui/propertypages/RemoteSystemsPreferencePage.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/propertypages/RemoteSystemsPreferencePage.java,v
retrieving revision 1.7
diff -u -r1.7 RemoteSystemsPreferencePage.java
--- UI/org/eclipse/rse/internal/ui/propertypages/RemoteSystemsPreferencePage.java 14 May 2007 13:04:56 -0000 1.7
+++ UI/org/eclipse/rse/internal/ui/propertypages/RemoteSystemsPreferencePage.java 12 Feb 2008 18:37:20 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [180562] don't implement ISystemPreferencesConstants
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.ui.propertypages;
@@ -195,14 +196,14 @@
{
boolean ok = super.performOk();
SystemPreferencesManager.savePreferences(); // better save to disk, just in case.
- if (!RSEUIPlugin.getDefault().isSystemRegistryActive())
+ if (!RSECorePlugin.isTheSystemRegistryActive())
return ok;
if (showFilterPoolsEditor != null)
{
boolean newValue = showFilterPoolsEditor.getBooleanValue();
if (newValue != lastShowFilterPoolsValue)
{
- RSECorePlugin.getTheSystemRegistry().setShowFilterPools(newValue);
+ RSEUIPlugin.getTheSystemRegistryUI().setShowFilterPools(newValue);
firePreferenceChangeEvent(ISystemPreferenceChangeEvents.EVENT_SHOWFILTERPOOLS,lastShowFilterPoolsValue,newValue);
}
lastShowFilterPoolsValue = newValue;
@@ -212,7 +213,7 @@
boolean newValue = showNewConnectionPromptEditor.getBooleanValue();
if (newValue != lastShowNewConnectionPromptValue)
{
- RSECorePlugin.getTheSystemRegistry().setShowNewHostPrompt(newValue);
+ RSEUIPlugin.getTheSystemRegistryUI().setShowNewHostPrompt(newValue);
}
lastShowNewConnectionPromptValue = newValue;
}
@@ -221,7 +222,7 @@
boolean newValue = qualifyConnectionNamesEditor.getBooleanValue();
if (newValue != lastQualifyConnectionNamesValue)
{
- RSECorePlugin.getTheSystemRegistry().setQualifiedHostNames(newValue);
+ RSEUIPlugin.getTheSystemRegistryUI().setQualifiedHostNames(newValue);
firePreferenceChangeEvent(ISystemPreferenceChangeEvents.EVENT_QUALIFYCONNECTIONNAMES,lastQualifyConnectionNamesValue,newValue);
}
lastQualifyConnectionNamesValue = newValue;
Index: UI/org/eclipse/rse/ui/RSEUIPlugin.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java,v
retrieving revision 1.68
diff -u -r1.68 RSEUIPlugin.java
--- UI/org/eclipse/rse/ui/RSEUIPlugin.java 5 Feb 2008 18:33:40 -0000 1.68
+++ UI/org/eclipse/rse/ui/RSEUIPlugin.java 12 Feb 2008 18:37:21 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -29,6 +29,7 @@
* 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 Dykstal (IBM) - [197036] formatted the initialize job to be able to read it
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.ui;
@@ -53,10 +54,10 @@
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.SystemStartHere;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
+import org.eclipse.rse.internal.core.model.SystemRegistry;
import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory;
import org.eclipse.rse.internal.ui.SystemResourceListener;
import org.eclipse.rse.internal.ui.SystemResources;
@@ -69,7 +70,6 @@
import org.eclipse.rse.services.clientserver.messages.ISystemMessageProvider;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
-import org.eclipse.rse.ui.internal.model.SystemRegistry;
import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
import org.eclipse.rse.ui.model.ISystemRegistryUI;
import org.osgi.framework.BundleContext;
@@ -89,8 +89,8 @@
public IStatus run(IProgressMonitor monitor) {
//System.err.println("InitRSEJob started"); //$NON-NLS-1$
- ISystemRegistry registry = getSystemRegistryInternal();
- SystemStartHere.getSystemProfileManager(); // create folders per profile
+ ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+ RSECorePlugin.getTheSystemProfileManager(); // create folders per profile
// add workspace listener for our project
IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false);
SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject);
@@ -105,7 +105,7 @@
if (systemType != null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
if (adapter != null && adapter.isEnabled(systemType)) {
- ISystemProfileManager profileManager = SystemProfileManager.getDefault();
+ ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager();
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
String userName = System.getProperty("user.name"); //$NON-NLS-1$
registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName);
@@ -130,10 +130,6 @@
private static SystemMessageFile messageFile = null;
private static SystemMessageFile defaultMessageFile = null;
-
-// private SystemType[] allSystemTypes = null;
- private SystemRegistryUI _systemRegistryUI = null;
- private SystemRegistry _systemRegistry = null;
private Vector viewSuppliers = new Vector();
private SystemViewAdapterFactory svaf; // for fastpath access
@@ -439,9 +435,9 @@
messageFile = getMessageFile("systemmessages.xml"); //$NON-NLS-1$
defaultMessageFile = getDefaultMessageFile("systemmessages.xml"); //$NON-NLS-1$
-
- ISystemRegistry registry = getSystemRegistryInternal();
- RSECorePlugin.getDefault().setSystemRegistry(registry);
+
+ //Force load the SystemRegistry - TODO Is this really necessary?
+ RSECorePlugin.getTheSystemRegistry();
IAdapterManager manager = Platform.getAdapterManager();
@@ -461,11 +457,8 @@
svraf = new SystemTeamViewResourceAdapterFactory();
svraf.registerWithManager(manager);
-
InitRSEJob initJob = new InitRSEJob();
initJob.schedule();
-
-
}
/**
@@ -482,39 +475,42 @@
*/
public void restart()
{
- if (_systemRegistry != null)
- {
- // disconnect all active connections
- disconnectAll(false); // don't save ?
- // collapse and flush all nodes in all views
- _systemRegistry.fireEvent(new SystemResourceChangeEvent("dummy", ISystemResourceChangeEvents.EVENT_COLLAPSE_ALL, null)); //$NON-NLS-1$
-
- // allow child classes to override
- closeViews();
-
- // clear in-memory settings for all filter pools and subsystems
- ISubSystemConfigurationProxy[] proxies = getSystemRegistryInternal().getSubSystemConfigurationProxies();
- if (proxies != null)
- for (int idx=0; idx < proxies.length; idx++)
- proxies[idx].reset();
- // clear in-memory settings for all profiles
- SystemProfileManager.clearDefault();
-
- // rebuild profiles
- SystemStartHere.getSystemProfileManager(); // create folders per profile
- // clear in-memory settings for all connections, then restore from disk
- _systemRegistry.reset();
- // restore in-memory settings for all filter pools and subsystems
- if (proxies != null)
- for (int idx=0; idx < proxies.length; idx++)
- proxies[idx].restore();
-
- // refresh GUIs
- _systemRegistry.fireEvent(new SystemResourceChangeEvent(_systemRegistry, ISystemResourceChangeEvents.EVENT_REFRESH, null));
-
- // allow child classes to override
- openViews();
- }
+ if (RSECorePlugin.isTheSystemRegistryActive()) {
+ ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+
+ // disconnect all active connections
+ disconnectAll(false); // don't save ?
+ // collapse and flush all nodes in all views
+ sr.fireEvent(new SystemResourceChangeEvent("dummy", ISystemResourceChangeEvents.EVENT_COLLAPSE_ALL, null)); //$NON-NLS-1$
+
+ // allow child classes to override
+ closeViews();
+
+ // clear in-memory settings for all filter pools and subsystems
+ ISubSystemConfigurationProxy[] proxies = sr.getSubSystemConfigurationProxies();
+ if (proxies != null) {
+ for (int idx=0; idx < proxies.length; idx++)
+ proxies[idx].reset();
+ }
+ // clear in-memory settings for all profiles
+ SystemProfileManager.clearDefault();
+
+ // rebuild profiles
+ RSECorePlugin.getTheSystemProfileManager(); // create folders per profile
+ // clear in-memory settings for all connections, then restore from disk
+ ((SystemRegistry)sr).reset();
+ // restore in-memory settings for all filter pools and subsystems
+ if (proxies != null) {
+ for (int idx=0; idx < proxies.length; idx++)
+ proxies[idx].restore();
+ }
+
+ // refresh GUIs
+ sr.fireEvent(new SystemResourceChangeEvent(sr, ISystemResourceChangeEvents.EVENT_REFRESH, null));
+
+ // allow child classes to override
+ openViews();
+ }
}
/**
@@ -569,9 +565,10 @@
*/
protected void disconnectAll(boolean doSave)
{
- if (isSystemRegistryActive())
+ if (RSECorePlugin.isTheSystemRegistryActive())
{
- ISubSystemConfigurationProxy[] proxies = getSystemRegistryInternal().getSubSystemConfigurationProxies();
+ ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+ ISubSystemConfigurationProxy[] proxies = sr.getSubSystemConfigurationProxies();
if (proxies != null)
{
for (int idx=0; idx < proxies.length; idx++)
@@ -605,86 +602,54 @@
}
/**
- * Returns true if the SystemRegistry has been instantiated already.
+ * Test if the SystemRegistry has been instantiated already.
* Use this when you don't want to start the system registry as a side effect of retrieving it.
+ * @return true
if the System Registry has been instantiated already.
+ * @deprecated use {@link RSECorePlugin#isTheSystemRegistryActive()}
*/
public boolean isSystemRegistryActive()
{
- return (_systemRegistry != null);
+ return RSECorePlugin.isTheSystemRegistryActive();
}
/**
+ * Return the persistence manager used for persisting RSE profiles.
* @return the persistence manager used for persisting RSE profiles
+ * @deprecated use {@link RSECorePlugin#getThePersistenceManager()}
*/
public IRSEPersistenceManager getPersistenceManager()
{
return RSECorePlugin.getThePersistenceManager();
}
-
-
- /**
- * Return the SystemRegistry singleton.
- * Clients should use static @{link getTheSystemRegistry()} instead.
- */
- private SystemRegistry getSystemRegistryInternal()
- {
- if (_systemRegistry == null)
- {
- String logfilePath = getStateLocation().toOSString();
-
- _systemRegistry = SystemRegistry.getInstance(logfilePath);
-
- ISubSystemConfigurationProxy[] proxies = RSECorePlugin.getDefault().getSubSystemConfigurationProxies();
- if (proxies != null)
- {
- _systemRegistry.setSubSystemConfigurationProxies(proxies);
- }
-
- }
- return _systemRegistry;
- }
-
/**
* Return the SystemRegistryUI singleton.
- * Clients should use static @{link getTheSystemRegistry()} instead.
- */
- private SystemRegistryUI getSystemRegistryUIInternal()
- {
- if (_systemRegistryUI == null)
- {
- _systemRegistryUI = SystemRegistryUI.getInstance();
- }
- return _systemRegistryUI;
- }
-
- /**
- * A static version for convenience
- * Returns the master registry singleton.
+ * @return the SystemRegistryUI singleton.
*/
public static ISystemRegistryUI getTheSystemRegistryUI()
{
- return getDefault().getSystemRegistryUIInternal();
+ return SystemRegistryUI.getInstance();
}
/**
- * A static version for convenience
- * Returns the master profile manager singleton.
+ * Return the master profile manager singleton.
+ * @return the RSE Profile Manager Singleton.
+ * @deprecated use {@link RSECorePlugin#getTheSystemProfileManager()}
*/
public static ISystemProfileManager getTheSystemProfileManager()
{
- return SystemProfileManager.getDefault();
+ return RSECorePlugin.getTheSystemProfileManager();
}
/**
- * A static version for convenience
+ * Check if the SystemRegistry has been instantiated already.
+ * Use this when you don't want to start the system registry as a side effect
+ * of retrieving it.
+ * @return true
if the System Registry has been instantiated already.
+ * @deprecated use {@link RSECorePlugin#isTheSystemRegistryActive()}
*/
- public static boolean isTheSystemRegistryActive()
- {
- if (inst == null)
- return false;
- else
- return getDefault().isSystemRegistryActive();
+ public static boolean isTheSystemRegistryActive() {
+ return RSECorePlugin.isTheSystemRegistryActive();
}
/**
Index: UI/org/eclipse/rse/ui/SystemPreferencesManager.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemPreferencesManager.java,v
retrieving revision 1.7
diff -u -r1.7 SystemPreferencesManager.java
--- UI/org/eclipse/rse/ui/SystemPreferencesManager.java 2 Jan 2008 19:28:31 -0000 1.7
+++ UI/org/eclipse/rse/ui/SystemPreferencesManager.java 12 Feb 2008 18:37:21 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation. All rights reserved.
+ * Copyright (c) 2000, 2008 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -14,14 +14,23 @@
* David Dykstal (IBM) - moved SystemPreferencesManager to a this package, was in
* the org.eclipse.rse.core package of the UI plugin.
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.ui;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.rse.core.IRSEPreferenceNames;
import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.events.ISystemModelChangeEvent;
+import org.eclipse.rse.core.events.ISystemModelChangeEvents;
+import org.eclipse.rse.core.events.ISystemModelChangeListener;
+import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
+import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
+import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
+import org.eclipse.rse.core.events.ISystemResourceChangeListener;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
@@ -49,6 +58,22 @@
private static boolean showProfilePage; // This is not a persistent preference
private static boolean showNewConnectionPrompt; // This is not a persistent preference
+ /*
+ * Singleton instance to support listening to model change events
+ */
+ private static SystemPreferencesManager fInstance = new SystemPreferencesManager();
+ private int fModelChangeListeners = 0;
+ private ISystemModelChangeListener fModelChangeListener = null;
+
+ /*
+ * Private Constructor to discourage instance creation other than by ourselves.
+ */
+ private SystemPreferencesManager() {
+ }
+
+ /**
+ * Migrate Preferences from UI Preference Store into Core Preference store
+ */
private static void migrateCorePreferences() {
String[] keys = {
IRSEPreferenceNames.ACTIVEUSERPROFILES,
@@ -80,11 +105,12 @@
migrateCorePreferences();
initDefaultsUI();
savePreferences();
+ fInstance.startModelChangeListening();
}
private static void initDefaultsUI() {
- String showProp = System.getProperty("rse.showNewConnectionPrompt");
+ //String showProp = System.getProperty("rse.showNewConnectionPrompt");
RSEUIPlugin ui = RSEUIPlugin.getDefault();
Preferences store = ui.getPluginPreferences();
showNewConnectionPrompt= getBooleanProperty("rse.showNewConnectionPrompt", ISystemPreferencesConstants.DEFAULT_SHOWNEWCONNECTIONPROMPT); //$NON-NLS-1$
@@ -155,15 +181,13 @@
String[] allConnectionNamesOrder = SystemPreferencesManager.getConnectionNamesOrder();
profileName = profileName + "."; //$NON-NLS-1$
int profileNameLength = profileName.length();
- Vector v = new Vector();
+ List l = new ArrayList();
for (int idx = 0; idx < allConnectionNamesOrder.length; idx++)
if (allConnectionNamesOrder[idx].startsWith(profileName)) {
- v.addElement(allConnectionNamesOrder[idx].substring(profileNameLength));
+ l.add(allConnectionNamesOrder[idx].substring(profileNameLength));
}
- String[] names = new String[v.size()];
- for (int idx = 0; idx < names.length; idx++) {
- names[idx] = (String) v.elementAt(idx);
- }
+ String[] names = new String[l.size()];
+ l.toArray(names);
return names;
}
@@ -191,6 +215,9 @@
/**
* Sets user's preference for the order of the connection names according to the
* list kept in the system registry.
+ * This resets any user-specified ordering of profiles since the SystemRegistry
+ * has no concept of ordered profiles. The hosts inside a profile, though,
+ * will be ordered according to user preference.
*/
public static void setConnectionNamesOrder() {
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
@@ -231,14 +258,14 @@
* a restored ordered list of names.
*/
private static String[] resolveOrderPreferenceVersusReality(String[] reality, String[] ordered) {
- Vector finalList = new Vector();
+ List finalList = new ArrayList();
// step 1: include all names from preferences list which do exist in reality...
for (int idx = 0; idx < ordered.length; idx++) {
- if (SystemPreferencesManager.find(reality, ordered[idx])) finalList.addElement(ordered[idx]);
+ if (SystemPreferencesManager.find(reality, ordered[idx])) finalList.add(ordered[idx]);
}
// step 2: add all names in reality which do not exist in preferences list...
for (int idx = 0; idx < reality.length; idx++) {
- if (!SystemPreferencesManager.find(ordered, reality[idx])) finalList.addElement(reality[idx]);
+ if (!SystemPreferencesManager.find(ordered, reality[idx])) finalList.add(reality[idx]);
}
String[] resolved = new String[finalList.size()];
finalList.toArray(resolved);
@@ -335,7 +362,7 @@
store.setValue(ISystemPreferencesConstants.SHOWFILTERPOOLS, show);
savePreferences();
if (show != prevValue) {
- RSECorePlugin.getTheSystemRegistry().setShowFilterPools(show);
+ RSEUIPlugin.getTheSystemRegistryUI().setShowFilterPools(show);
}
}
@@ -435,10 +462,64 @@
RSEUIPlugin.getDefault().savePluginPreferences();
RSECorePlugin.getDefault().savePluginPreferences();
}
-
+
/*
- * Private to discourage instance creation.
+ * Start listening to SystemRegistry model change events
*/
- private SystemPreferencesManager() {
+ private void startModelChangeListening() {
+ //TODO Register a listener for shutdown, to stop model change listening
+ boolean alreadyListening;
+ synchronized(this) {
+ alreadyListening = (fModelChangeListeners>0);
+ fModelChangeListeners++;
+ }
+ if (!alreadyListening) {
+ fModelChangeListener = new ModelChangeListener();
+ RSECorePlugin.getTheSystemRegistry().addSystemModelChangeListener(fModelChangeListener);
+ }
}
+
+ /*
+ * A listener for SystemRegistry Model Change events
+ */
+ private static class ModelChangeListener implements ISystemModelChangeListener, ISystemResourceChangeListener {
+
+ public void systemModelResourceChanged(ISystemModelChangeEvent event) {
+ int rt = event.getResourceType();
+ if (rt==ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION) {
+ switch(event.getEventType()) {
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_RENAMED:
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED:
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED:
+ //TODO Change order of hosts from affected profile only?
+ SystemPreferencesManager.setConnectionNamesOrder();
+ break;
+ }
+ } else if (rt==ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE) {
+ switch (event.getEventType()) {
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_RENAMED:
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED:
+ case ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED:
+ //TODO Change order of hosts from affected profile only?
+ SystemPreferencesManager.setConnectionNamesOrder();
+ break;
+ }
+ if (event.getEventType()==ISystemModelChangeEvents.SYSTEM_RESOURCE_RENAMED) {
+ boolean namesQualified = SystemPreferencesManager.getQualifyConnectionNames();
+ RSEUIPlugin.getTheSystemRegistryUI().setQualifiedHostNames(namesQualified); // causes refresh events to be fired
+ }
+ }
+ }
+
+ public void systemResourceChanged(ISystemResourceChangeEvent event) {
+ if (event.getType()==ISystemResourceChangeEvents.EVENT_MOVE_MANY
+ && (event.getSource() instanceof IHost[])
+ ) {
+ //TODO Change order of hosts from affected profile only?
+ SystemPreferencesManager.setConnectionNamesOrder();
+ }
+ }
+
+ }
+
}
\ No newline at end of file
Index: UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java,v
retrieving revision 1.24
diff -u -r1.24 SystemTableViewPart.java
--- UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java 26 Nov 2007 20:39:08 -0000 1.24
+++ UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java 12 Feb 2008 18:37:21 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -25,6 +25,7 @@
* Martin Oberhuber (Wind River) - [199585] Fix NPE during testConnectionRemoval unit test
* David McKnight (IBM) - [187543] use view filter to only show containers for set input dialog
* David McKnight (IBM) - [210229] table refresh needs unique table-specific tooltip-text
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@@ -71,6 +72,7 @@
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
+import org.eclipse.rse.internal.core.model.SystemRegistry;
import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
@@ -87,7 +89,6 @@
import org.eclipse.rse.ui.actions.SystemTablePrintAction;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.dialogs.SystemSelectAnythingDialog;
-import org.eclipse.rse.ui.internal.model.SystemRegistry;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.model.ISystemShellProvider;
import org.eclipse.rse.ui.view.IRSEViewPart;
Index: UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java,v
retrieving revision 1.42
diff -u -r1.42 SystemViewConnectionAdapter.java
--- UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java 5 Feb 2008 18:33:40 -0000 1.42
+++ UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java 12 Feb 2008 18:37:21 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -31,6 +31,7 @@
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false)
* David Dykstal (IBM) - [197036] minor refactoring caused by SystemRegistry fix for this bug
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@@ -234,7 +235,7 @@
public String getText(Object element)
{
IHost conn = (IHost)element;
- boolean qualifyNames = RSECorePlugin.getTheSystemRegistry().getQualifiedHostNames();
+ boolean qualifyNames = RSEUIPlugin.getTheSystemRegistryUI().getQualifiedHostNames();
if (!qualifyNames)
return conn.getAliasName();
else
Index: UI/org/eclipse/rse/internal/ui/view/ElementComparer.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ElementComparer.java,v
retrieving revision 1.1
diff -u -r1.1 ElementComparer.java
--- UI/org/eclipse/rse/internal/ui/view/ElementComparer.java 9 Jul 2007 18:16:19 -0000 1.1
+++ UI/org/eclipse/rse/internal/ui/view/ElementComparer.java 12 Feb 2008 18:37:20 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
-* Copyright (c) 2007 IBM Corporation. All rights reserved.
+* Copyright (c) 2007, 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
@@ -12,6 +12,7 @@
*
* Contributors:
* Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@@ -20,7 +21,7 @@
import org.eclipse.jface.viewers.IElementComparer;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.ui.internal.model.SystemRegistry;
+import org.eclipse.rse.internal.core.model.SystemRegistry;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
public class ElementComparer implements IElementComparer
Index: model/org/eclipse/rse/ui/model/ISystemRegistryUI.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/model/ISystemRegistryUI.java,v
retrieving revision 1.7
diff -u -r1.7 ISystemRegistryUI.java
--- model/org/eclipse/rse/ui/model/ISystemRegistryUI.java 5 Jun 2007 20:59:59 -0000 1.7
+++ model/org/eclipse/rse/ui/model/ISystemRegistryUI.java 12 Feb 2008 18:37:21 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [189123] Prepare ISystemRegistry for move into non-UI
* Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.ui.model;
@@ -69,6 +70,34 @@
*/
public List getSystemClipboardObjects(int srcType);
+ // ----------------------------
+ // USER PREFERENCE METHODS...
+ // ----------------------------
+ /**
+ * Are connection names to be qualified by profile name?
+ */
+ public boolean getQualifiedHostNames();
+
+ /**
+ * Set if connection names are to be qualified by profile name
+ */
+ public void setQualifiedHostNames(boolean set);
+
+ /**
+ * Reflect the user changing the preference for showing filter pools.
+ */
+ public void setShowFilterPools(boolean show);
+
+ /*
+ * Reflect the user changing the preference for showing filter strings.
+ *
+ public void setShowFilterStrings(boolean show);
+ */
+ /**
+ * Reflect the user changing the preference for showing new connection prompt
+ */
+ public void setShowNewHostPrompt(boolean show);
+
// ----------------------------------
// ACTIVE PROGRESS MONITOR METHODS...
// ----------------------------------
Index: UI/org/eclipse/rse/internal/ui/actions/SystemPreferenceQualifyConnectionNamesAction.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemPreferenceQualifyConnectionNamesAction.java,v
retrieving revision 1.5
diff -u -r1.5 SystemPreferenceQualifyConnectionNamesAction.java
--- UI/org/eclipse/rse/internal/ui/actions/SystemPreferenceQualifyConnectionNamesAction.java 14 May 2007 13:04:54 -0000 1.5
+++ UI/org/eclipse/rse/internal/ui/actions/SystemPreferenceQualifyConnectionNamesAction.java 12 Feb 2008 18:37:20 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,12 +13,12 @@
* Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.ui.actions;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemPreferenceChangeEvents;
-import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.core.model.SystemPreferenceChangeEvent;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.RSEUIPlugin;
@@ -33,8 +33,6 @@
public class SystemPreferenceQualifyConnectionNamesAction extends SystemBaseAction
{
-
- private ISystemRegistry sr = null;
/**
* Constructor
*/
@@ -44,8 +42,7 @@
parent);
setSelectionSensitive(false);
allowOnMultipleSelection(true);
- sr = RSECorePlugin.getTheSystemRegistry();
- setChecked(sr.getQualifiedHostNames());
+ setChecked(RSEUIPlugin.getTheSystemRegistryUI().getQualifiedHostNames());
setHelp(RSEUIPlugin.HELPPREFIX+"actn0008"); //$NON-NLS-1$
}
@@ -57,7 +54,7 @@
public void run()
{
boolean newState = isChecked();
- sr.setQualifiedHostNames(newState);
+ RSEUIPlugin.getTheSystemRegistryUI().setQualifiedHostNames(newState);
firePreferenceChangeEvent(ISystemPreferenceChangeEvents.EVENT_QUALIFYCONNECTIONNAMES,
!newState,newState); // defect 41794
}
#P org.eclipse.rse.core
Index: src/org/eclipse/rse/internal/core/RSECoreMessages.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/RSECoreMessages.java,v
retrieving revision 1.2
diff -u -r1.2 RSECoreMessages.java
--- src/org/eclipse/rse/internal/core/RSECoreMessages.java 22 May 2007 13:47:38 -0000 1.2
+++ src/org/eclipse/rse/internal/core/RSECoreMessages.java 12 Feb 2008 18:37:26 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -8,6 +8,7 @@
* David Dykstal (IBM) - initial API and implementation
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
* Martin Oberhuber (Wind River) - [184095] combined RSEModelResources and persistence.Messages into this file
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.internal.core;
@@ -51,6 +52,17 @@
// Password Persistence Manager
public static String DefaultSystemType_Label;
+ // SystemRegistry: Loading Profile Warning Messages - See also ISystemMessages
+ public static String MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS;
+ public static String MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF;
+ public static String MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED; //RSEG1069
+ public static String MSG_CREATEHOST_EXCEPTION;
+
+ // SystemRegistry: Progress Reporting - See also ISystemMessages
+ public static String MSG_COPYCONNECTION_PROGRESS; //RSEG1073
+ public static String MSG_COPYFILTERPOOLS_PROGRESS; //RSEG1075
+ public static String MSG_COPYSUBSYSTEMS_PROGRESS; //RSEG1081
+
private RSECoreMessages() {
}
}
Index: src/org/eclipse/rse/internal/core/messages.properties
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/messages.properties,v
retrieving revision 1.2
diff -u -r1.2 messages.properties
--- src/org/eclipse/rse/internal/core/messages.properties 22 May 2007 13:47:38 -0000 1.2
+++ src/org/eclipse/rse/internal/core/messages.properties 12 Feb 2008 18:37:26 -0000
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 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
@@ -9,6 +9,7 @@
# David Dykstal (IBM) - initial API and implementation
# David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
# Martin Oberhuber (Wind River) - [184095] combined RSEModelResources and persistence.Messages into this file
+# Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
###############################################################################
# NLS_MESSAGEFORMAT_VAR
@@ -44,3 +45,14 @@
# Password Persistence Manager
DefaultSystemType_Label=Default
+
+# SystemRegistry: Loading Profile Warning Messages - See also ISystemMessages
+MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS=RSEG1069: De-Activating profile {0} for which there are subsystems containing references to filter pools:
+MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF=\ in connection {1} in profile {2}
+MSG_LOADING_PROFILE_SHOULDNOTBE_DEACTIVATED=RSEG1069: Warning. Profile '{0}' should be active. Active connection '{1}' contains a reference to it.
+MSG_CREATEHOST_EXCEPTION=Exception in createHost for {0}
+
+# SystemRegistry: Progress Reporting - See also ISystemMessages
+MSG_COPYCONNECTION_PROGRESS=Copying connection {0}
+MSG_COPYFILTERPOOLS_PROGRESS=Copying filter pools
+MSG_COPYSUBSYSTEMS_PROGRESS=Copying subsystems
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/META-INF/MANIFEST.MF,v
retrieving revision 1.33
diff -u -r1.33 MANIFEST.MF
--- META-INF/MANIFEST.MF 1 Feb 2008 13:14:11 -0000 1.33
+++ META-INF/MANIFEST.MF 12 Feb 2008 18:37:26 -0000
@@ -7,7 +7,8 @@
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.rse.services;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.rse.services;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.swt
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: org.eclipse.rse.core,
Index: src/org/eclipse/rse/core/RSECorePlugin.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java,v
retrieving revision 1.22
diff -u -r1.22 RSECorePlugin.java
--- src/org/eclipse/rse/core/RSECorePlugin.java 23 Jul 2007 15:51:34 -0000 1.22
+++ src/org/eclipse/rse/core/RSECorePlugin.java 12 Feb 2008 18:37:26 -0000
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -19,6 +19,7 @@
* Martin Oberhuber (Wind River) - [160293] NPE on startup when only Core feature is installed
* Uwe Stieber (Wind River) - [192611] RSE Core plugin may fail to initialize because of cyclic code invocation
* Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by priority then Id
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.core;
@@ -33,9 +34,12 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.rse.core.comm.SystemKeystoreProviderManager;
+import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.RSECoreRegistry;
+import org.eclipse.rse.internal.core.model.SystemProfileManager;
+import org.eclipse.rse.internal.core.model.SystemRegistry;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.subsystems.SubSystemConfigurationProxyComparator;
import org.eclipse.rse.internal.persistence.RSEPersistenceManager;
@@ -64,7 +68,7 @@
private static RSECorePlugin plugin = null; // the singleton instance of this plugin
private Logger logger = null;
- private ISystemRegistry _registry = null;
+ private ISystemRegistry _systemRegistry = null;
private IRSEPersistenceManager _persistenceManager = null;
private ISubSystemConfigurationProxy[] _subsystemConfigurations = null;
@@ -78,6 +82,15 @@
/**
* A static convenience method - fully equivalent to
+ * RSECorePlugin.getDefault().getRegistry()
.
+ * @return the RSE Core Registry.
+ */
+ public static IRSECoreRegistry getTheCoreRegistry() {
+ return getDefault().getCoreRegistry();
+ }
+
+ /**
+ * A static convenience method - fully equivalent to
* RSECorePlugin.getDefault().getPersistenceManager()
.
* @return the persistence manager currently in use for RSE
*/
@@ -86,17 +99,32 @@
}
/**
- * A static convenience method - fully equivalent to
- * RSECorePlugin.getDefault().getRegistry()
.
- * @return the RSE Core Registry.
+ * Return the master profile manager singleton.
+ * @return the RSE Profile Manager Singleton.
*/
- public static IRSECoreRegistry getTheCoreRegistry() {
- return getDefault().getCoreRegistry();
+ public static ISystemProfileManager getTheSystemProfileManager() {
+ return SystemProfileManager.getDefault();
}
-
+
+ /**
+ * Check if the SystemRegistry has been instantiated already.
+ * Use this when you don't want to start the system registry as a
+ * side effect of retrieving it.
+ * @return true
if the System Registry has been instantiated already.
+ */
+ public static boolean isTheSystemRegistryActive()
+ {
+ if (plugin == null) {
+ return false;
+ }
+ return getDefault().isSystemRegistryActive();
+ }
+
/**
* A static convenience method - fully equivalent to
* RSECorePlugin.getDefault().getSystemRegistry()
.
+ * The SystemRegistry is used to gain access to the basic services
+ * and components used in RSE.
* @return the RSE System Registry.
*/
public static ISystemRegistry getTheSystemRegistry() {
@@ -173,7 +201,11 @@
*/
public IRSEPersistenceManager getPersistenceManager() {
if (_persistenceManager == null) {
- _persistenceManager = new RSEPersistenceManager(_registry);
+ synchronized(this) {
+ if (_persistenceManager==null) {
+ _persistenceManager = new RSEPersistenceManager(getSystemRegistry());
+ }
+ }
}
return _persistenceManager;
}
@@ -183,19 +215,43 @@
* that require a user interface. This should be set only by RSE startup components and
* not by any external client.
* @param registry the implementation of ISystemRegistry that the core should remember.
+ * @deprecated Do not use this method.
*/
public void setSystemRegistry(ISystemRegistry registry) {
- _registry = registry;
+ _systemRegistry = registry;
}
+ /**
+ * Test if the SystemRegistry has been instantiated already.
+ * Use this when you don't want to start the system registry as a
+ * side effect of retrieving it.
+ * @return true
if the system registry has been instantiated already.
+ */
+ private boolean isSystemRegistryActive()
+ {
+ return (_systemRegistry != null);
+ }
+
/**
- * Gets the system registry set by {@link #setSystemRegistry(ISystemRegistry)}.
- * This registry is used to gain access to the basic services and components used in
- * the RSE user interface.
+ * Return the SystemRegistry singleton.
+ * Clients should use static @{link getTheSystemRegistry()} instead.
* @return the RSE system registry
*/
public ISystemRegistry getSystemRegistry() {
- return _registry;
+ if (_systemRegistry == null) {
+ synchronized(this) {
+ if (_systemRegistry == null) {
+ String logfilePath = getStateLocation().toOSString();
+ SystemRegistry sr = SystemRegistry.getInstance(logfilePath);
+ ISubSystemConfigurationProxy[] proxies = getSubSystemConfigurationProxies();
+ if (proxies != null) {
+ sr.setSubSystemConfigurationProxies(proxies);
+ }
+ _systemRegistry = sr;
+ }
+ }
+ }
+ return _systemRegistry;
}
/**
Index: src/org/eclipse/rse/core/model/ISystemRegistry.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java,v
retrieving revision 1.32
diff -u -r1.32 ISystemRegistry.java
--- src/org/eclipse/rse/core/model/ISystemRegistry.java 8 Feb 2008 18:48:20 -0000 1.32
+++ src/org/eclipse/rse/core/model/ISystemRegistry.java 12 Feb 2008 18:37:26 -0000
@@ -23,6 +23,7 @@
* David Dykstal (IBM) - [197036] adding new createHost and getSubSystemConfigurationsBySYstemType which
* are able to delay the creation of subsystems.
* David Dykstal (IBM) - [217556] remove service subsystem types
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/
package org.eclipse.rse.core.model;
@@ -145,34 +146,6 @@
public boolean hasConnectionChildren(IHost selectedConnection);
// ----------------------------
- // USER PREFERENCE METHODS...
- // ----------------------------
- /**
- * Are connection names to be qualified by profile name?
- */
- public boolean getQualifiedHostNames();
-
- /**
- * Set if connection names are to be qualified by profile name
- */
- public void setQualifiedHostNames(boolean set);
-
- /**
- * Reflect the user changing the preference for showing filter pools.
- */
- public void setShowFilterPools(boolean show);
-
- /*
- * Reflect the user changing the preference for showing filter strings.
- *
- public void setShowFilterStrings(boolean show);
- */
- /**
- * Reflect the user changing the preference for showing new connection prompt
- */
- public void setShowNewHostPrompt(boolean show);
-
- // ----------------------------
// PROFILE METHODS...
// ----------------------------
/**
@@ -324,12 +297,15 @@
// CONNECTION METHODS...
// ----------------------------
/**
- * Return the first connection to localhost we can find. While we always create a default one in
- * the user's profile, it is possible that this profile is not active or the connection was deleted.
- * However, since any connection to localHost will usually do, we just search all active profiles
- * until we find one, and return it.
- * If no localhost connection is found, this will return null. If one is needed, it can be created
- * easily by calling {@link #createLocalHost(ISystemProfile, String, String)}.
+ * Return the first connection to the local host we can find.
+ *
+ * While we always create a default one in the user's profile, it is possible that
+ * this profile is not active or the connection was deleted. However, since any
+ * connection to the local host will usually do, we just search all active profiles
+ * until we find one, and return it.
+ * If no connection to the local host can be found, this will return null
.
+ * If one is needed, it can be created easily by calling
+ * {@link #createLocalHost(ISystemProfile, String, String)}.
*/
public IHost getLocalHost();
Index: src/org/eclipse/rse/internal/core/model/SystemRegistry.java
===================================================================
RCS file: src/org/eclipse/rse/internal/core/model/SystemRegistry.java
diff -N src/org/eclipse/rse/internal/core/model/SystemRegistry.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/rse/internal/core/model/SystemRegistry.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,3065 @@
+/********************************************************************************
+ * Copyright (c) 2006, 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
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * Michael Scharf (Wind River) - patch for an NPE in getSubSystemConfigurations()
+ * David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
+ * Uwe Stieber (Wind River) - bugfixing
+ * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
+ * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
+ * David Dykstal (IBM) - 142806: refactoring persistence framework
+ * Tobias Schwarz (Wind River) - [183134] getLocalHost() does not return Local
+ * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
+ * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
+ * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
+ * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
+ * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
+ * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
+ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
+ * Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
+ * Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
+ * Martin Oberhuber (Wind River) - [189123] Prepare ISystemRegistry for move into non-UI
+ * Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core
+ * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
+ * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
+ * Xuan Chen (IBM) - [194838] Move the code for comparing two objects by absolute name to a common location
+ * David McKnight (IBM) - [165674] Sort subsystem configurations to be in deterministic order
+ * Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by priority then Id
+ * Martin Oberhuber (Wind River) - [194898] Avoid NPE when doing EVENT_REFRESH_REMOTE on a subsys without filters
+ * David McKnight (IBM) - [207100] adding ISystemRegistry.isRegisteredSystemRemoteChangeListener
+ * Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe
+ * David Dykstal (IBM) - [210537] removed exception handling for SystemHostPool, no longer needed
+ * Martin Oberhuber (Wind River) - [216266] improved non-forced getSubSystems() code, removed getSubSystemsLazily()
+ * David Dykstal (IBM) - [197036] wrapped createHost to commit changes only once
+ * rewrote createHost to better pick default subsystem configurations to activate
+ * rewrote getSubSystemConfigurationsBySystemType to be able to delay the creation (and loading) of subsystem configurations
+ * David Dykstal (IBM) - [217556] remove service subsystem types
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
+ ********************************************************************************/
+
+package org.eclipse.rse.internal.core.model;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.IRSEUserIdConstants;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.events.ISystemModelChangeEvent;
+import org.eclipse.rse.core.events.ISystemModelChangeEvents;
+import org.eclipse.rse.core.events.ISystemModelChangeListener;
+import org.eclipse.rse.core.events.ISystemPreferenceChangeEvent;
+import org.eclipse.rse.core.events.ISystemPreferenceChangeListener;
+import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
+import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
+import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
+import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
+import org.eclipse.rse.core.events.ISystemResourceChangeListener;
+import org.eclipse.rse.core.events.SystemRemoteChangeEvent;
+import org.eclipse.rse.core.events.SystemResourceChangeEvent;
+import org.eclipse.rse.core.filters.ISystemFilter;
+import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
+import org.eclipse.rse.core.filters.ISystemFilterReference;
+import org.eclipse.rse.core.filters.ISystemFilterStartHere;
+import org.eclipse.rse.core.filters.SystemFilterReference;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
+import org.eclipse.rse.core.model.ISystemContainer;
+import org.eclipse.rse.core.model.ISystemHostPool;
+import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage;
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.core.model.ISystemProfileManager;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.model.SystemChildrenContentsType;
+import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
+import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
+import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
+import org.eclipse.rse.internal.core.RSECoreMessages;
+import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Registry for all connections.
+ */
+public class SystemRegistry implements ISystemRegistry
+{
+ private static Exception lastException = null;
+ private static SystemRegistry registry = null;
+ private final SystemResourceChangeManager listenerManager = new SystemResourceChangeManager();
+ private final SystemPreferenceChangeManager preferenceListManager = new SystemPreferenceChangeManager();
+ private final SystemModelChangeEventManager modelListenerManager = new SystemModelChangeEventManager();
+ private final SystemRemoteChangeEventManager remoteListManager = new SystemRemoteChangeEventManager();
+ private SystemModelChangeEvent modelEvent;
+ private SystemRemoteChangeEvent remoteEvent;
+ private int listenerCount = 0;
+ private int modelListenerCount = 0;
+ private int remoteListCount = 0;
+
+ private ISubSystemConfigurationProxy[] subsystemConfigurationProxies = null;
+ private boolean errorLoadingFactory = false;
+
+ //For ISystemViewInputProvider
+ private Object viewer = null;
+
+ /**
+ * Constructor.
+ * This is protected as the singleton instance should be retrieved by
+ * calling getSystemRegistry().
+ * @param logfilePath Root folder. Where to place the log file.
+ */
+ protected SystemRegistry(String logfilePath)
+ {
+ super();
+
+ // get initial shell
+ //FIXME - this can cause problems - don't think we should do this here anyway
+ //getShell(); // will quietly fail in headless mode. Phil
+
+ registry = this;
+ restore();
+ }
+ /**
+ * Reset for a full refresh from disk, such as after a team synch
+ */
+ public void reset()
+ {
+ SystemHostPool.reset();
+ restore();
+ }
+
+ // ----------------------------
+ // PUBLIC STATIC METHODS...
+ // ----------------------------
+
+ /**
+ * Return singleton instance. Must be used on first instantiate.
+ * @param logfilePath Root folder. Where to place the log file.
+ */
+ public static SystemRegistry getInstance(String logfilePath)
+ {
+ if (registry == null)
+ new SystemRegistry(logfilePath);
+ return registry;
+ }
+
+ /**
+ * Return singleton instance assuming it already exists.
+ */
+ public static SystemRegistry getInstance()
+ {
+ return registry;
+ }
+
+// /**
+// * Ensure given path ends with path separator.
+// */
+// public static String addPathTerminator(String path)
+// {
+// if (!path.endsWith(File.separator))
+// {
+// path = path + File.separatorChar;
+// }
+// return path;
+// }
+
+ /**
+ * This method is called by the connection adapter when the user expands
+ * a connection. This method must return the child objects to show for that
+ * connection.
+ */
+ public Object[] getConnectionChildren(IHost 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
+ * or not beside a connection. Return true if this connection has children to be shown.
+ */
+ public boolean hasConnectionChildren(IHost selectedConnection)
+ {
+ return true; // much faster and safer
+ /*
+ boolean hasSubsystems = false;
+ if (subsystemConfigurationProxies != null)
+ {
+ for (int idx = 0; (!hasSubsystems) && (idx < subsystemConfigurationProxies.length); idx++)
+ {
+ if (subsystemConfigurationProxies[idx].appliesToSystemType(selectedConnection.getSystemType().getName()) &&
+ subsystemConfigurationProxies[idx].isSubSystemConfigurationActive())
+ {
+ SubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
+ if (factory != null)
+ {
+ SubSystem[] sss = factory.getSubSystems(selectedConnection, SubSystemConfiguration.LAZILY);
+ if ((sss != null) && (sss.length>0))
+ hasSubsystems = true;
+ }
+ else
+ hasSubsystems = false;
+ }
+ else
+ hasSubsystems = true;
+ }
+ }
+ else
+ hasSubsystems = true;
+ return hasSubsystems;
+ */
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapterType)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapterType);
+ }
+
+ // ----------------------------
+ // SUBSYSTEM FACTORY METHODS...
+ // ----------------------------
+
+ /**
+ * Private method used by RSEUIPlugin to tell registry all registered subsystem
+ * factories. This way, all code can use this registry to access them versus the
+ * RSEUIPlugin.
+ *
+ * Proxies must be set sorted by priority, then ID in order to get deterministic
+ * results for all getSubSystemConfiguration*() queries.
+ */
+ public void setSubSystemConfigurationProxies(ISubSystemConfigurationProxy[] proxies)
+ {
+ subsystemConfigurationProxies = proxies;
+ //for (int idx=0; idx
+ * If no localhost connection is found, this will return null. If one is needed, it can be created
+ * easily by calling {@link #createLocalHost(ISystemProfile, String, String)}.
+ */
+ public IHost getLocalHost()
+ {
+ IHost localConn = null;
+ IRSESystemType localType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
+ IHost[] conns = getHostsBySystemType(localType);
+ if (conns != null && conns.length > 0) return conns[0];
+ else return localConn;
+ }
+
+ /**
+ * Return all connections in all active profiles.
+ * Never returns null, but may return a zero-length array.
+ * All array elements are valid hosts (never returns null elements).
+ */
+ public IHost[] getHosts()
+ {
+ ISystemHostPool[] pools = getHostPools();
+ List hosts = new ArrayList();
+ for (int idx = 0; idx < pools.length; idx++) {
+ IHost[] conns = pools[idx].getHosts();
+ if (conns != null) {
+ for (int jdx = 0; jdx < conns.length; jdx++) {
+ //ISystemHostPool ensures that we never have "null" hosts.
+ assert conns[jdx]!=null : "Null host in pool "+pools[idx].getName()+" at "+jdx; //$NON-NLS-1$ //$NON-NLS-2$
+ hosts.add(conns[jdx]);
+ }
+ }
+ }
+ IHost[] allConns = (IHost[])hosts.toArray(new IHost[hosts.size()]);
+ return allConns;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsByProfile(org.eclipse.rse.core.model.ISystemProfile)
+ */
+ public IHost[] getHostsByProfile(ISystemProfile profile)
+ {
+ ISystemHostPool pool = getHostPool(profile);
+ return pool.getHosts();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySubSystemConfiguration(org.eclipse.rse.core.subsystems.ISubSystemConfiguration)
+ */
+ public IHost[] getHostsBySubSystemConfiguration(ISubSystemConfiguration factory)
+ {
+ /* The following algorithm failed because factory.getSubSystems() only returns
+ * subsystems that have been restored, which are only those that have been
+ * expanded.
+ */
+ ISubSystem[] subsystems = factory.getSubSystems(true); // true ==> force full restore
+ Vector v = new Vector();
+ for (int idx = 0; idx < subsystems.length; idx++)
+ {
+ IHost conn = subsystems[idx].getHost();
+ if (!v.contains(conn))
+ v.addElement(conn);
+ }
+ IHost[] conns = new IHost[v.size()];
+ for (int idx = 0; idx < v.size(); idx++)
+ {
+ conns[idx] = (IHost) v.elementAt(idx);
+ }
+ return conns;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySubSystemConfigurationCategory(java.lang.String)
+ */
+ public IHost[] getHostsBySubSystemConfigurationCategory(String factoryCategory)
+ {
+ Vector v = new Vector();
+ if (subsystemConfigurationProxies != null)
+ {
+ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
+ {
+ if (subsystemConfigurationProxies[idx].getCategory().equals(factoryCategory))
+ {
+ ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration();
+ if (factory != null)
+ {
+ ISubSystem[] subsystems = factory.getSubSystems(true); // true ==> force full restore
+ if (subsystems != null)
+ for (int jdx = 0; jdx < subsystems.length; jdx++)
+ {
+ IHost conn = subsystems[jdx].getHost();
+ if (!v.contains(conn))
+ v.addElement(conn);
+ }
+ }
+ }
+ }
+ }
+ IHost[] conns = new IHost[v.size()];
+ for (int idx = 0; idx < v.size(); idx++)
+ {
+ conns[idx] = (IHost) v.elementAt(idx);
+ }
+ return conns;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySystemType(org.eclipse.rse.core.IRSESystemType)
+ */
+ public IHost[] getHostsBySystemType(IRSESystemType systemType) {
+ List connections = new ArrayList();
+
+ if (systemType != null) {
+ IHost[] candidates = getHosts();
+ for (int i = 0; i < candidates.length; i++) {
+ IHost candidate = candidates[i];
+ IRSESystemType candidateType = candidate.getSystemType();
+ if (systemType.equals(candidateType)) {
+ connections.add(candidate);
+ }
+ }
+ }
+
+ return (IHost[])connections.toArray(new IHost[connections.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostsBySystemTypes(org.eclipse.rse.core.IRSESystemType[])
+ */
+ public IHost[] getHostsBySystemTypes(IRSESystemType[] systemTypes)
+ {
+ List systemTypesList = Arrays.asList(systemTypes);
+ IHost[] connections = getHosts();
+ Vector v = new Vector();
+ for (int idx = 0; idx < connections.length; idx++)
+ {
+ IRSESystemType systemType = connections[idx].getSystemType();
+ if (systemTypesList.contains(systemType)) {
+ v.addElement(connections[idx]);
+ }
+ }
+ return (IHost[])v.toArray(new IHost[v.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHost(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
+ */
+ public IHost getHost(ISystemProfile profile, String connectionName)
+ {
+ return getHostPool(profile).getHost(connectionName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostPosition(org.eclipse.rse.core.model.IHost)
+ */
+ public int getHostPosition(IHost conn)
+ {
+ ISystemHostPool pool = conn.getHostPool();
+ return pool.getHostPosition(conn);
+ }
+
+ /**
+ * Return the zero-based position of a SystemConnection object within all active profiles.
+ */
+ public int getHostPositionInView(IHost conn)
+ {
+ IHost[] conns = getHosts();
+ int pos = -1;
+ for (int idx = 0;(pos == -1) && (idx < conns.length); idx++)
+ {
+ if (conns[idx] == conn)
+ pos = idx;
+ }
+ return pos;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCount(org.eclipse.rse.core.model.ISystemProfile)
+ */
+ public int getHostCount(ISystemProfile profile)
+ {
+ return getHostPool(profile).getHostCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCountWithinProfile(org.eclipse.rse.core.model.IHost)
+ */
+ public int getHostCountWithinProfile(IHost conn)
+ {
+ return conn.getHostPool().getHostCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostCount()
+ */
+ public int getHostCount()
+ {
+ ISystemHostPool[] pools = getHostPools();
+ int total = 0;
+ for (int idx = 0; idx < pools.length; idx++)
+ {
+ total += pools[idx].getHostCount();
+ }
+ return total;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostAliasNames(org.eclipse.rse.core.model.ISystemProfile)
+ */
+ public Vector getHostAliasNames(ISystemProfile profile)
+ {
+ ISystemHostPool pool = getHostPool(profile);
+ Vector names = new Vector();
+ IHost[] conns = pool.getHosts();
+ for (int idx = 0; idx < conns.length; idx++)
+ {
+ names.addElement(conns[idx].getAliasName());
+ }
+ return names;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostAliasNamesForAllActiveProfiles()
+ */
+ public Vector getHostAliasNamesForAllActiveProfiles()
+ {
+ ISystemHostPool[] allPools = getHostPools();
+ Vector allNames = new Vector();
+ for (int idx = 0; idx < allPools.length; idx++)
+ {
+ Vector v = getHostAliasNames(getSystemProfile(allPools[idx]));
+ for (int jdx = 0; jdx < v.size(); jdx++)
+ allNames.addElement(v.elementAt(jdx));
+ }
+ return allNames;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#getHostNames(org.eclipse.rse.core.IRSESystemType)
+ */
+ public String[] getHostNames(IRSESystemType systemType)
+ {
+ Vector v = new Vector();
+
+ if (systemType != null)
+ {
+ IHost[] conns = getHosts();
+ for (int idx = 0; idx < conns.length; idx++)
+ {
+ // Note: IHost.getHostName() can return null if the connection is using
+ // any non-IP based connectivity (serial line, JTAG, ...). Adding
+ // null unchecked to the result list will trigger InvalidArgumentExceptions
+ // in SystemConnectionForm.
+ if (conns[idx].getHostName() != null && !v.contains(conns[idx].getHostName()))
+ {
+ if (conns[idx].getSystemType().equals(systemType))
+ v.addElement(conns[idx].getHostName());
+ }
+ }
+ }
+ if ((systemType != null) && (systemType.isLocal() && (v.size() == 0)))
+ v.addElement("localhost"); //$NON-NLS-1$
+ return (String[])v.toArray(new String[v.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createLocalHost(org.eclipse.rse.core.model.ISystemProfile, java.lang.String, java.lang.String)
+ */
+ public IHost createLocalHost(ISystemProfile profile, String name, String userId)
+ {
+ IHost localConn = null;
+ if (profile == null)
+ profile = getSystemProfileManager().getDefaultPrivateSystemProfile();
+ if (profile == null)
+ profile = getSystemProfileManager().getActiveSystemProfiles()[0];
+
+ try
+ {
+ IRSESystemType localType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
+ localConn = createHost(
+ profile.getName(), localType,
+ name, // connection name
+ "localhost", // hostname //$NON-NLS-1$
+ "", // description //$NON-NLS-1$
+ // DY: defect 42101, description cannot be null
+ // null, // description
+ userId, // default user Id
+ IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE, null);
+
+ }
+ catch (Exception exc)
+ {
+ RSECorePlugin.getDefault().getLogger().logError("Error creating local connection", exc); //$NON-NLS-1$
+ }
+ return localConn;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, org.eclipse.rse.core.model.ISystemNewConnectionWizardPage[])
+ */
+ public IHost createHost(
+ String profileName,
+ IRSESystemType systemType,
+ String connectionName,
+ String hostName,
+ String description,
+ String defaultUserId,
+ int defaultUserIdLocation,
+ ISystemNewConnectionWizardPage[] newConnectionWizardPages)
+ throws Exception
+ {
+ return createHost(profileName, systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation, true, newConnectionWizardPages);
+ }
+
+ /**
+ * Create a host object, given its host pool and its attributes.
+ *
+ *
+ * true
to create subsystems for the host, false
otherwise.
+ * @param newConnectionWizardPages when called from the New Connection wizard this is union of the list of additional
+ * wizard pages supplied by the subsystem factories that pertain to the specified system type. Else null.
+ * @return SystemConnection object, or null if it failed to create. This is typically
+ * because the connectionName is not unique. Call getLastException() if necessary.
+ */
+ // FIXME need to remove ISystemNewConnectionWizardPage[] from this and replace with IAdaptable[]
+ public IHost createHost(final String profileName, final IRSESystemType systemType, final String hostName,
+ final String hostAddress, final String description, final String defaultUserId,
+ final int defaultUserIdLocation, final boolean createSubSystems,
+ final ISystemNewConnectionWizardPage[] newConnectionWizardPages) throws Exception {
+ final ISystemRegistry sr = this;
+ class CreateHostOperation implements ISystemProfileOperation {
+ private IHost host = null;
+ private ISubSystem[] subsystems = new ISubSystem[0];
+ IHost getHost() {
+ return host;
+ }
+ public ISubSystem[] getSubSystems() {
+ return subsystems;
+ }
+ public IStatus run() {
+ IStatus status = Status.OK_STATUS;
+ ISystemHostPool pool = getHostPool(profileName);
+ try {
+ // create, register and save new connection...
+ String uid = defaultUserId;
+ if ((uid != null) && (uid.length() == 0)) {
+ uid = null;
+ }
+ host = pool.createHost(systemType, hostName, hostAddress, description, uid, defaultUserIdLocation);
+ if (host == null) { // did not create since host already exists
+ host = pool.getHost(hostName);
+ }
+ } catch (Exception e) {
+ String pluginId = RSECorePlugin.getDefault().getBundle().getSymbolicName();
+ String message = NLS.bind(RSECoreMessages.MSG_CREATEHOST_EXCEPTION, hostName);
+ status = new Status(IStatus.ERROR, pluginId, message, e);
+ }
+ if (status.isOK()) {
+ if (createSubSystems) {
+ // determine the list of configs to use to create subsystems from
+ List configs = new ArrayList(10); // arbitrary but reasonable
+ if (newConnectionWizardPages != null) {
+ // if there are wizard pages need to at least use those
+ for (int i = 0; i < newConnectionWizardPages.length; i++) {
+ configs.add(newConnectionWizardPages[i].getSubSystemConfiguration());
+ }
+ // add any non-service subsystem configs that aren't already there that apply to this systemtype
+ ISubSystemConfiguration[] configsArray = getSubSystemConfigurationsBySystemType(systemType, false);
+ for (int i = 0; i < configsArray.length; i++) {
+ ISubSystemConfiguration config = configsArray[i];
+ boolean isStrange = (config.getServiceType() == null);
+ 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) {
+ RSECorePlugin.getDefault().getLogger().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);
+ ////Listening to FireNewHostEvents now
+ //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
+ return host;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createSubSystems(org.eclipse.rse.core.model.IHost, org.eclipse.rse.core.subsystems.ISubSystemConfiguration[])
+ */
+ public ISubSystem[] createSubSystems(IHost host, ISubSystemConfiguration[] configurations) {
+
+ ISubSystem[] subsystems = new ISubSystem[configurations.length];
+
+ for (int i = 0; i < configurations.length; i++) {
+ subsystems[i] = configurations[i].createSubSystem(host, true, null);
+ }
+
+ for (int j = 0; j < subsystems.length; j++) {
+ fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, subsystems[j], null);
+ }
+
+ host.commit();
+ return subsystems;
+ }
+
+ class NotifyModelChangedRunnable implements Runnable
+ {
+ private ISystemModelChangeEvent _event;
+ public NotifyModelChangedRunnable(ISystemModelChangeEvent event)
+ {
+ _event = event;
+ }
+
+ public void run()
+ {
+ modelListenerManager.notify(_event);
+ }
+ }
+
+ class NotifyResourceChangedRunnable implements Runnable
+ {
+ private ISystemResourceChangeEvent _event;
+ public NotifyResourceChangedRunnable(ISystemResourceChangeEvent event)
+ {
+ _event = event;
+ }
+
+ public void run()
+ {
+ listenerManager.notify(_event);
+ }
+ }
+
+ class NotifyPreferenceChangedRunnable implements Runnable
+ {
+ private ISystemPreferenceChangeEvent _event;
+ public NotifyPreferenceChangedRunnable(ISystemPreferenceChangeEvent event)
+ {
+ _event = event;
+ }
+
+ public void run()
+ {
+ preferenceListManager.notify(_event);
+ }
+ }
+
+ class PreferenceChangedRunnable implements Runnable
+ {
+ private ISystemPreferenceChangeEvent _event;
+ private ISystemPreferenceChangeListener _listener;
+
+ public PreferenceChangedRunnable(ISystemPreferenceChangeEvent event, ISystemPreferenceChangeListener listener)
+ {
+ _event = event;
+ _listener = listener;
+ }
+
+ public void run()
+ {
+ _listener.systemPreferenceChanged(_event);
+ }
+ }
+
+ class ModelResourceChangedRunnable implements Runnable
+ {
+ private ISystemModelChangeListener _listener;
+ private ISystemModelChangeEvent _event;
+ public ModelResourceChangedRunnable(ISystemModelChangeEvent event, ISystemModelChangeListener listener)
+ {
+ _event = event;
+ _listener = listener;
+ }
+
+ public void run()
+ {
+ _listener.systemModelResourceChanged(_event);
+ }
+ }
+
+ class ResourceChangedRunnable implements Runnable
+ {
+ private ISystemResourceChangeListener _listener;
+ private ISystemResourceChangeEvent _event;
+ public ResourceChangedRunnable(ISystemResourceChangeEvent event, ISystemResourceChangeListener listener)
+ {
+ _event = event;
+ _listener = listener;
+ }
+
+ public void run()
+ {
+ _listener.systemResourceChanged(_event);
+ }
+ }
+
+ class RemoteResourceChangedRunnable implements Runnable
+ {
+ private ISystemRemoteChangeListener _listener;
+ private ISystemRemoteChangeEvent _event;
+ public RemoteResourceChangedRunnable(ISystemRemoteChangeEvent event, ISystemRemoteChangeListener listener)
+ {
+ _event = event;
+ _listener = listener;
+ }
+
+ public void run()
+ {
+ _listener.systemRemoteResourceChanged(_event);
+ }
+ }
+
+ class RemoteChangedRunnable implements Runnable
+ {
+ private ISystemRemoteChangeEvent _event;
+ public RemoteChangedRunnable(ISystemRemoteChangeEvent event)
+ {
+ _event = event;
+ }
+
+ public void run()
+ {
+ remoteListManager.notify(_event);
+ }
+ }
+
+
+ class FireNewHostEvents implements Runnable
+ {
+ private ISubSystem[] subSystems;
+ private IHost conn;
+ private ISystemRegistry reg;
+
+
+ public FireNewHostEvents(IHost host, ISubSystem[] subSystems, ISystemRegistry registry)
+ {
+ this.subSystems= subSystems;
+ this.conn = host;
+ this.reg = registry;
+ }
+
+ public void run()
+ {
+ int eventType = ISystemResourceChangeEvents.EVENT_ADD_RELATIVE;
+ SystemResourceChangeEvent event = new SystemResourceChangeEvent(conn, eventType, reg);
+ //event.setPosition(pool.getConnectionPosition(conn));
+ //event.setPosition(getConnectionPositionInView(conn));
+ IHost previous = getPreviousHost(conn);
+ if (previous != null)
+ {
+ event.setRelativePrevious(previous);
+ }
+ else
+ {
+ event.setType(ISystemResourceChangeEvents.EVENT_ADD);
+ }
+ fireEvent(event);
+ fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
+ conn, null);
+
+ for (int s = 0; s < subSystems.length; s++)
+ {
+ ISubSystem ss = subSystems[s];
+ fireModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ADDED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM, ss, null);
+ }
+ }
+ }
+
+ private ISystemNewConnectionWizardPage[] getApplicableWizardPages(ISubSystemConfiguration ssf, ISystemNewConnectionWizardPage[] allPages)
+ {
+ if ((allPages == null) || (allPages.length == 0))
+ return null;
+ int count = 0;
+ for (int idx = 0; idx < allPages.length; idx++)
+ if (allPages[idx].getSubSystemConfiguration() == ssf)
+ ++count;
+ if (count == 0)
+ return null;
+ ISystemNewConnectionWizardPage[] subPages = new ISystemNewConnectionWizardPage[count];
+ count = 0;
+ for (int idx = 0; idx < allPages.length; idx++)
+ if (allPages[idx].getSubSystemConfiguration() == ssf)
+ subPages[count++] = allPages[idx];
+ return subPages;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description)
+ throws Exception
+ {
+ return createHost(profileName, systemType, connectionName, hostName, description, true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(java.lang.String, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, boolean)
+ */
+ public IHost createHost(String profileName, IRSESystemType systemType, String connectionName, String hostName, String description, boolean createSubSystems) throws Exception
+ {
+ return createHost(profileName, systemType, connectionName, hostName, description, null, IRSEUserIdConstants.USERID_LOCATION_HOST, createSubSystems, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#createHost(org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public IHost createHost(IRSESystemType systemType, String connectionName, String hostName, String description)
+ throws Exception
+ {
+ ISystemProfile profile = getSystemProfileManager().getDefaultPrivateSystemProfile();
+ if (profile == null)
+ profile = getSystemProfileManager().getActiveSystemProfiles()[0];
+ return createHost(profile.getName(), systemType, connectionName, hostName, description);
+ }
+
+ /**
+ * Return the previous connection as would be shown in the view
+ */
+ protected IHost getPreviousHost(IHost conn)
+ {
+ IHost prevConn = null;
+ ISystemHostPool pool = conn.getHostPool();
+ int pos = pool.getHostPosition(conn);
+ if (pos > 0)
+ prevConn = pool.getHost(pos - 1);
+ else
+ {
+ IHost allConns[] = getHosts();
+ if (allConns != null)
+ {
+ pos = getHostPositionInView(conn);
+ if (pos > 0)
+ prevConn = allConns[pos - 1];
+ }
+ }
+ return prevConn;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#updateHost(org.eclipse.rse.core.model.IHost, org.eclipse.rse.core.IRSESystemType, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)
+ */
+ public void updateHost(IHost conn, IRSESystemType systemType, String connectionName, String hostName, String description, String defaultUserId, int defaultUserIdLocation)
+ {
+ lastException = null;
+ boolean connectionNameChanged = !connectionName.equalsIgnoreCase(conn.getAliasName());
+ boolean hostNameChanged = !hostName.equalsIgnoreCase(conn.getHostName());
+ String orgDefaultUserId = conn.getDefaultUserId();
+ boolean defaultUserIdChanged = false;
+ if ((defaultUserId == null) || (orgDefaultUserId == null))
+ {
+ if (orgDefaultUserId != defaultUserId)
+ defaultUserIdChanged = true;
+ }
+ else
+ defaultUserIdChanged = !conn.compareUserIds(defaultUserId, orgDefaultUserId); // d43219
+ //!defaultUserId.equalsIgnoreCase(orgDefaultUserId);
+
+ try
+ {
+ if (connectionNameChanged)
+ renameHost(conn, connectionName);
+ conn.getHostPool().updateHost(conn, systemType, connectionName, hostName, description, defaultUserId, defaultUserIdLocation);
+ }
+ catch (SystemMessageException exc)
+ {
+ RSECorePlugin.getDefault().getLogger().logError("Exception in updateConnection for " + connectionName, exc); //$NON-NLS-1$
+ lastException = exc;
+ return;
+ }
+ catch (Exception exc)
+ {
+ RSECorePlugin.getDefault().getLogger().logError("Exception in updateConnection for " + connectionName, exc); //$NON-NLS-1$
+ lastException = exc;
+ return;
+ }
+ boolean skipUpdate = (defaultUserIdChanged && !hostNameChanged && !connectionNameChanged);
+ if (!skipUpdate) fireEvent(new SystemResourceChangeEvent(
+ //conn,ISystemResourceChangeEvent.EVENT_CHANGE,this));
+ conn, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, this)); // only update simple property sheet values here
+ if (!skipUpdate) fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
+ conn, null);
+
+ if (hostNameChanged || defaultUserIdChanged)
+ {
+ ISubSystem[] subsystems = getSubSystems(conn); // get list of related subsystems
+ for (int idx = 0; idx < subsystems.length; idx++)
+ {
+ if (hostNameChanged || (subsystems[idx].getLocalUserId() == null))
+ {
+ try
+ {
+ if (subsystems[idx].isConnected()) subsystems[idx].disconnect(); // MJB: added conditional for defect 45754
+ if (defaultUserIdChanged)
+ {
+ subsystems[idx].getConnectorService().clearCredentials();
+ }
+ subsystems[idx].getConnectorService().clearPassword(false, true);
+ }
+ catch (Exception exc)
+ {
+ } // msg already shown
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#setHostOffline(org.eclipse.rse.core.model.IHost, boolean)
+ */
+ public void setHostOffline(IHost conn, boolean offline)
+ {
+ if (conn.isOffline() != offline)
+ {
+ conn.setOffline(offline);
+ saveHost(conn);
+ fireEvent(new SystemResourceChangeEvent(conn, ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE, null));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#deleteHost(org.eclipse.rse.core.model.IHost)
+ */
+ public void deleteHost(IHost conn)
+ {
+ Vector affectedSubSystemFactories = getSubSystemFactories(conn);
+ for (int idx = 0; idx < affectedSubSystemFactories.size(); idx++)
+ {
+ ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).deleteSubSystemsByConnection(conn);
+ }
+ conn.getHostPool().deleteHost(conn); // delete from memory and from disk.
+ ////Listening to Events now
+ //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
+ fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_REMOVED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
+ conn, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#renameHost(org.eclipse.rse.core.model.IHost, java.lang.String)
+ */
+ public void renameHost(IHost conn, String newName) throws Exception
+ {
+ // first, pre-test for folder-in-use error:
+
+ // it looks good, so proceed...
+ String oldName = conn.getAliasName();
+
+
+ // DKM - changing how this is done since there are services with different configurations now
+ ISubSystem[] subsystems = conn.getSubSystems();
+ for (int i = 0; i < subsystems.length; i++)
+ {
+ ISubSystem ss = subsystems[i];
+ ss.getSubSystemConfiguration().renameSubSystemsByConnection(conn, newName);
+ }
+
+ /*
+ Vector affectedSubSystemFactories = getSubSystemFactories(conn);
+ for (int idx = 0; idx < affectedSubSystemFactories.size(); idx++)
+ ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).renameSubSystemsByConnection(conn, newName);
+ */
+ conn.getHostPool().renameHost(conn, newName); // rename in memory and disk
+ ////Listening to events now
+ //SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
+ fireModelChangeEvent(
+ ISystemModelChangeEvents.SYSTEM_RESOURCE_RENAMED,
+ ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION,
+ conn, oldName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#moveHosts(java.lang.String, org.eclipse.rse.core.model.IHost[], int)
+ * FIXME PROBLEM: CAN'T RE-ORDER FOLDERS SO CAN WE SUPPORT THIS ACTION?
+ */
+ public void moveHosts(String profileName, IHost conns[], int delta)
+ {
+ ISystemHostPool pool = getHostPool(profileName);
+ pool.moveHosts(conns, delta);
+ ////Listening to Event now
+ //SystemPreferencesManager.setConnectionNamesOrder();
+ //fireEvent(new SystemResourceChangeEvent(pool.getSystemConnections(),ISystemResourceChangeEvent.EVENT_MOVE_MANY,this));
+ SystemResourceChangeEvent event = new SystemResourceChangeEvent(conns, ISystemResourceChangeEvents.EVENT_MOVE_MANY, this);
+ event.setPosition(delta);
+ fireEvent(event);
+ // fire new model change event, which BPs might listen for...
+ for (int idx=0; idxtrue
if there are any matching subsystem configurations not yet instantiated.
+ */
+ public boolean hasInactiveSubsystemConfigurations(IRSESystemType systemType)
+ {
+ if (subsystemConfigurationProxies != null)
+ {
+ for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++)
+ {
+ if (!subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()
+ && subsystemConfigurationProxies[idx].appliesToSystemType(systemType))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#areAllSubSystemsConnected(org.eclipse.rse.core.model.IHost)
+ */
+ public boolean areAllSubSystemsConnected(IHost conn)
+ {
+ boolean all = true;
+ if (hasInactiveSubsystemConfigurations(conn.getSystemType())) {
+ //any uninitialized subsystem configuration that applies to the system type can not be connected.
+ //TODO this may change in the future: We might want to have markup in the plugin.xml
+ //to check whether a subsystem configuration is actually connectable or not
+ return false;
+ }
+
+ //May force load subsystem configurations here because there are no inactive ones for our system type.
+ //Do we need to force load actual subsystems too, just to check if they are connected?
+ ISubSystem[] subsystems = getSubSystems(conn);
+ if (subsystems == null) {
+ //If there are no subsystems, they are all connected.
+ return true;
+ }
+
+ for (int idx = 0; all && (idx < subsystems.length); idx++)
+ {
+ ISubSystem ss = subsystems[idx];
+ if (!ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect())
+ {
+ //we ignore unconnected subsystems that can not be connected anyways.
+ return false;
+ }
+ }
+ return all;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#disconnectAllSubSystems(org.eclipse.rse.core.model.IHost)
+ */
+ public void disconnectAllSubSystems(IHost conn)
+ {
+ // get subsystems lazily, because not instantiated ones cannot be disconnected anyways.
+ ISubSystem[] subsystems = getSubSystems(conn);
+ if (subsystems == null)
+ return;
+
+ // dy: defect 47281, user repeatedly prompted to disconnect if there is an open file
+ // and they keep hitting cancel.
+ boolean cancelled = false;
+ for (int idx = 0; idx < subsystems.length && !cancelled; idx++)
+ {
+ ISubSystem ss = subsystems[idx];
+ if (ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect())
+ {
+ try
+ {
+ //ss.getConnectorService().disconnect(); defect 40675
+ ss.disconnect();
+ }
+ catch (InterruptedException exc)
+ {
+ System.out.println("Cancelled"); //$NON-NLS-1$
+ cancelled = true;
+ }
+ catch (Exception exc)
+ {
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#connectedStatusChange(org.eclipse.rse.core.subsystems.ISubSystem, boolean, boolean)
+ */
+ public void connectedStatusChange(ISubSystem subsystem, boolean connected, boolean wasConnected)
+ {
+ connectedStatusChange(subsystem, connected, wasConnected, true);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.core.model.ISystemRegistry#connectedStatusChange(org.eclipse.rse.core.subsystems.ISubSystem, boolean, boolean, boolean)
+ */
+ public void connectedStatusChange(ISubSystem subsystem, boolean connected, boolean wasConnected, boolean collapseTree)
+ {
+ //System.out.println("INSIDE CONNECTEDSTATUSCHANGE: "+connected+" vs "+wasConnected);
+ IHost conn = subsystem.getHost();
+ //int eventId = ISystemResourceChangeEvent.EVENT_CHANGE;
+ //int eventId = ISystemResourceChangeEvent.EVENT_PROPERTY_CHANGE;
+ if (connected != wasConnected)
+ {
+ int eventId = ISystemResourceChangeEvents.EVENT_ICON_CHANGE;
+ fireEvent(new SystemResourceChangeEvent(conn, eventId, this));
+
+ SystemResourceChangeEvent event = new SystemResourceChangeEvent(subsystem, eventId, conn);
+ fireEvent(event);
+
+ // DKM
+ // fire for each subsystem
+ ISubSystem[] sses = getSubSystems(conn);
+ for (int i = 0; i < sses.length; i++)
+ {
+ ISubSystem ss = sses[i];
+ if (ss != subsystem)
+ {
+ SystemResourceChangeEvent sevent = new SystemResourceChangeEvent(ss, eventId, conn);
+ fireEvent(sevent);
+
+ sevent.setType(ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE); // update vrm
+ fireEvent(sevent);
+ }
+ }
+
+
+ // DY: Conditioning of property change event type has been removed so
+ // that the connected property is updated on a disconnect.
+ //if (connected)
+ event.setType(ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE); // update vrm
+
+ fireEvent(event);
+ }
+ if (!connected && wasConnected && collapseTree)
+ {
+ invalidateFiltersFor(subsystem);
+ fireEvent(new SystemResourceChangeEvent(subsystem, ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE, this));
+
+ ISubSystem[] sses = getSubSystems(conn);
+ for (int i = 0; i < sses.length; i++)
+ {
+ ISubSystem ss = sses[i];
+ if (ss != subsystem && !ss.isConnected())
+ {
+ invalidateFiltersFor(ss);
+ SystemResourceChangeEvent sevent = new SystemResourceChangeEvent(ss, ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE, conn);
+ fireEvent(sevent);
+ }
+ }
+ }
+ }
+
+ // ----------------------------
+ // RESOURCE EVENT METHODS...
+ // ----------------------------
+
+ /**
+ * Register your interest in being told when a system resource such as a connection is changed.
+ */
+ public void addSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ listenerManager.addSystemResourceChangeListener(l);
+ listenerCount++;
+ }
+ /**
+ * De-Register your interest in being told when a system resource such as a connection is changed.
+ */
+ public void removeSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ listenerManager.removeSystemResourceChangeListener(l);
+ listenerCount--;
+ }
+ /**
+ * Query if the ISystemResourceChangeListener is already listening for SystemResourceChange events
+ */
+ public boolean isRegisteredSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ return listenerManager.isRegisteredSystemResourceChangeListener(l);
+ }
+ /**
+ * Notify all listeners of a change to a system resource such as a connection.
+ * You would not normally call this as the methods in this class call it when appropriate.
+ */
+ public void fireEvent(ISystemResourceChangeEvent event)
+ {
+ Object src = event.getSource();
+ if (src instanceof ISystemFilter)
+ {
+ IRSEBaseReferencingObject[] references = ((ISystemFilter)src).getReferencingObjects();
+ for (int i = 0; i < references.length; i++)
+ {
+ IRSEBaseReferencingObject ref = references[i];
+ if (ref instanceof ISystemContainer)
+ {
+ ((ISystemContainer)ref).markStale(true);
+ }
+ }
+ }
+
+ if (onMainThread()) {
+ listenerManager.notify(event);
+ }
+ else {
+ runOnMainThread(new NotifyResourceChangedRunnable(event));
+ }
+
+ }
+ /**
+ * Notify a specific listener of a change to a system resource such as a connection.
+ */
+ public void fireEvent(ISystemResourceChangeListener l, ISystemResourceChangeEvent event)
+ {
+ if (onMainThread()) {
+ l.systemResourceChanged(event);
+ }
+ else {
+ runOnMainThread(new ResourceChangedRunnable(event, l));
+ }
+ }
+
+ /**
+ * Return the listener manager such that the SystemRegistryUI
+ * can re-use it for posting events that can only be posted
+ * in UI.
+ * @return the System resource change listener manager
+ * used by the registry.
+ */
+ public SystemResourceChangeManager getResourceChangeManager() {
+ return listenerManager;
+ }
+
+ // ----------------------------
+ // MODEL RESOURCE EVENT METHODS...
+ // ----------------------------
+
+ /**
+ * Register your interest in being told when an RSE model resource is changed.
+ * These are model events, not GUI-optimized events.
+ */
+ public void addSystemModelChangeListener(ISystemModelChangeListener l)
+ {
+ modelListenerManager.addSystemModelChangeListener(l);
+ modelListenerCount++;
+ }
+ /**
+ * De-Register your interest in being told when an RSE model resource is changed.
+ */
+ public void removeSystemModelChangeListener(ISystemModelChangeListener l)
+ {
+ modelListenerManager.removeSystemModelChangeListener(l);
+ modelListenerCount--;
+ }
+
+ private boolean onMainThread()
+ {
+ return Display.getCurrent() != null;
+ }
+
+ private void runOnMainThread(Runnable runnable)
+ {
+ Display.getDefault().asyncExec(runnable);
+ }
+
+ /**
+ * Notify all listeners of a change to a system model resource such as a connection.
+ * You would not normally call this as the methods in this class call it when appropriate.
+ */
+ public void fireEvent(ISystemModelChangeEvent event)
+ {
+ if (onMainThread()) {
+ modelListenerManager.notify(event);
+ }
+ else {
+ // fire this on the main thread
+ runOnMainThread(new NotifyModelChangedRunnable(event));
+ }
+ }
+ /**
+ * Notify all listeners of a change to a system model resource such as a connection.
+ * This one takes the information needed and creates the event for you.
+ */
+ public void fireModelChangeEvent(int eventType, int resourceType, Object resource, String oldName)
+ {
+ if (modelEvent == null)
+ modelEvent = new SystemModelChangeEvent();
+ modelEvent.setEventType(eventType);
+ modelEvent.setResourceType(resourceType);
+ modelEvent.setResource(resource);
+ modelEvent.setOldName(oldName);
+
+ if (onMainThread()) {
+ modelListenerManager.notify(modelEvent);
+ }
+ else {
+ // fire this one the main thread
+ runOnMainThread(new NotifyModelChangedRunnable(modelEvent));
+ }
+ }
+
+
+
+ /**
+ * Notify a specific listener of a change to a system model resource such as a connection.
+ */
+ public void fireEvent(ISystemModelChangeListener l, ISystemModelChangeEvent event)
+ {
+ if (onMainThread()) {
+ l.systemModelResourceChanged(event);
+ }
+ else {
+ runOnMainThread(new ModelResourceChangedRunnable(event, l));
+ }
+ }
+
+ // --------------------------------
+ // REMOTE RESOURCE EVENT METHODS...
+ // --------------------------------
+
+ /**
+ * Register your interest in being told when a remote resource is changed.
+ * These are model events, not GUI-optimized events.
+ */
+ public void addSystemRemoteChangeListener(ISystemRemoteChangeListener l)
+ {
+ remoteListManager.addSystemRemoteChangeListener(l);
+ remoteListCount++;
+ }
+ /**
+ * De-Register your interest in being told when a remote resource is changed.
+ */
+ public void removeSystemRemoteChangeListener(ISystemRemoteChangeListener l)
+ {
+ remoteListManager.removeSystemRemoteChangeListener(l);
+ remoteListCount--;
+ }
+
+ /**
+ * Query if the ISystemRemoteChangeListener is already listening for SystemRemoteChange events
+ */
+ public boolean isRegisteredSystemRemoteChangeListener(ISystemRemoteChangeListener l)
+ {
+ return remoteListManager.isRegisteredSystemRemoteChangeListener(l);
+ }
+
+ /**
+ * Notify all listeners of a change to a remote resource such as a file.
+ * You would not normally call this as the methods in this class call it when appropriate.
+ */
+ public void fireEvent(ISystemRemoteChangeEvent event)
+ {
+ if (onMainThread()) {
+ remoteListManager.notify(event);
+ }
+ else {
+ runOnMainThread(new RemoteChangedRunnable(event));
+ }
+ }
+
+ /**
+ * Notify all listeners of a change to a remote resource such as a file.
+ * This one takes the information needed and creates the event for you.
+ * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents}
+ * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter
+ * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent.
+ * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be
+ * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection.
+ * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename
+ */
+ public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName)
+ {
+ if (resourceParent instanceof ISystemContainer)
+ {
+ ((ISystemContainer)resourceParent).markStale(true);
+ }
+ // mark stale any filters that reference this object
+ invalidateFiltersFor(resourceParent, subsystem);
+
+ if (remoteEvent == null)
+ remoteEvent = new SystemRemoteChangeEvent();
+ remoteEvent.setEventType(eventType);
+ remoteEvent.setResource(resource);
+ remoteEvent.setResourceParent(resourceParent);
+ remoteEvent.setOldName(oldName);
+ remoteEvent.setSubSystem(subsystem);
+
+ if (onMainThread())
+ {
+ remoteListManager.notify(remoteEvent);
+ }
+ else
+ {
+ runOnMainThread(new RemoteChangedRunnable(remoteEvent));
+ }
+ }
+
+ /**
+ * Notify all listeners of a change to a remote resource such as a file.
+ * This one takes the information needed and creates the event for you.
+ * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents}
+ * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter
+ * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent.
+ * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be
+ * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection.
+ * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename
+ * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent.
+ * This saves sending a separate event to reveal and select the new created resource on a create event, for example.
+ */
+ public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName, Object originatingViewer)
+ {
+ if (resourceParent instanceof ISystemContainer)
+ {
+ ((ISystemContainer)resourceParent).markStale(true);
+ }
+ // mark stale any filters that reference this object
+ invalidateFiltersFor(resourceParent, subsystem);
+
+ //if (remoteEvent == null)
+ remoteEvent = new SystemRemoteChangeEvent();
+ remoteEvent.setEventType(eventType);
+ remoteEvent.setResource(resource);
+ remoteEvent.setResourceParent(resourceParent);
+ remoteEvent.setOldName(oldName);
+ remoteEvent.setSubSystem(subsystem);
+ remoteEvent.setOriginatingViewer(originatingViewer);
+
+ if (onMainThread())
+ {
+ remoteListManager.notify(remoteEvent);
+ }
+ else
+ {
+ runOnMainThread(new RemoteChangedRunnable(remoteEvent));
+ }
+ }
+
+ /**
+ * Returns the implementation of ISystemRemoteElement for the given
+ * object. Returns null if this object does not adaptable to this.
+ */
+ protected IRemoteObjectIdentifier getRemoteObjectIdentifier(Object o)
+ {
+ //Try 1: element already an instance of IRemoteObjectIdentifier?
+ if (o instanceof IRemoteObjectIdentifier) {
+ return (IRemoteObjectIdentifier)o;
+ }
+ //Try 2: adapts to IRemoteObjectIdentifier (non-UI code only!)
+ IRemoteObjectIdentifier adapter = null;
+ if (o instanceof IAdaptable) {
+ adapter = (IRemoteObjectIdentifier)((IAdaptable)o).getAdapter(IRemoteObjectIdentifier.class);
+ if (adapter!=null) return adapter;
+ } else if (o==null) {
+ return null;
+ }
+ //Try 3: IRemoteObjectIdentifier via factories.
+ //TODO Try loadAdapter() to force lazy loading?
+ adapter = (IRemoteObjectIdentifier)Platform.getAdapterManager().getAdapter(o, IRemoteObjectIdentifier.class);
+ if (adapter==null) {
+ //Try 4: ISystemDragDropAdapter, fallback to old factories provided via AbstractSystemViewRemoteAdapterFactory
+ //This is a fallback for pre-RSE-3.0 code and may introduce UI dependency!
+ if (o instanceof IAdaptable) {
+ //TODO Try loadAdapter() to force lazy loading?
+ adapter = (ISystemDragDropAdapter)((IAdaptable)o).getAdapter(ISystemDragDropAdapter.class);
+ if (adapter!=null) return adapter;
+ }
+ adapter = (ISystemDragDropAdapter)Platform.getAdapterManager().getAdapter(o, ISystemDragDropAdapter.class);
+ }
+ return adapter;
+ }
+
+ private String getRemoteResourceAbsoluteName(Object remoteResource)
+ {
+ if (remoteResource == null)
+ return null;
+ String remoteResourceName = null;
+ if (remoteResource instanceof String)
+ remoteResourceName = (String)remoteResource;
+ else if (remoteResource instanceof SystemFilterReference)
+ {
+ ISystemFilterReference ref = (ISystemFilterReference)remoteResource;
+ ISubSystem ss = ref.getSubSystem();
+ remoteResource = ss.getTargetForFilter(ref);
+ IRemoteObjectIdentifier rid = getRemoteObjectIdentifier(remoteResource);
+ if (rid == null)
+ return null;
+ remoteResourceName = rid.getAbsoluteName(remoteResource);
+ }
+ else
+ {
+ IRemoteObjectIdentifier rid = getRemoteObjectIdentifier(remoteResource);
+ if (rid == null)
+ return null;
+ remoteResourceName = rid.getAbsoluteName(remoteResource);
+ }
+ return remoteResourceName;
+ }
+
+ private List findFilterReferencesFor(ISubSystem subsystem)
+ {
+ List results = new ArrayList();
+ if (subsystem != null)
+ {
+ ISystemFilterPoolReferenceManager refmgr = subsystem.getFilterPoolReferenceManager();
+ if (refmgr != null)
+ {
+ ISystemFilterReference[] refs = refmgr.getSystemFilterReferences(subsystem);
+ for (int i = 0; i < refs.length; i++)
+ {
+ ISystemFilterReference filterRef = refs[i];
+
+ if (!filterRef.isStale() && filterRef.hasContents(SystemChildrenContentsType.getInstance()))
+ {
+ results.add(filterRef);
+ }
+ }
+
+ }
+ }
+ return results;
+
+ }
+
+ public List findFilterReferencesFor(Object resource, ISubSystem subsystem)
+ {
+ return findFilterReferencesFor(resource, subsystem, true);
+ }
+
+ public List findFilterReferencesFor(Object resource, ISubSystem subsystem, boolean onlyCached)
+ {
+ String elementName = getRemoteResourceAbsoluteName(resource);
+ List results = new ArrayList();
+ if (subsystem != null && elementName != null && subsystem.getSubSystemConfiguration().supportsFilters())
+ {
+ ISystemFilterReference[] refs = subsystem.getFilterPoolReferenceManager().getSystemFilterReferences(subsystem);
+ for (int i = 0; i < refs.length; i++)
+ {
+ ISystemFilterReference filterRef = refs[i];
+
+ if (!onlyCached || (!filterRef.isStale() && filterRef.hasContents(SystemChildrenContentsType.getInstance())))
+
+ {
+ // #1
+ if (subsystem.doesFilterMatch(filterRef.getReferencedFilter(), elementName))
+ {
+ results.add(filterRef); // found a match!
+
+ }
+ // #2
+ else if (subsystem.doesFilterListContentsOf(filterRef.getReferencedFilter(),elementName))
+ {
+ results.add(filterRef); // found a match!
+ }
+ }
+ }
+
+
+ }
+ return results;
+
+ }
+
+ public void invalidateFiltersFor(ISubSystem subsystem)
+ {
+ if (subsystem != null)
+ {
+
+ List results = findFilterReferencesFor(subsystem);
+ for (int i = 0; i < results.size(); i++)
+ {
+ ((ISystemFilterReference)results.get(i)).markStale(true);
+ }
+ }
+ }
+
+ public void invalidateFiltersFor(Object resourceParent, ISubSystem subsystem)
+ {
+ if (subsystem != null)
+ {
+
+ List results = findFilterReferencesFor(resourceParent, subsystem);
+ for (int i = 0; i < results.size(); i++)
+ {
+ ((ISystemFilterReference)results.get(i)).markStale(true);
+ }
+ }
+ }
+
+ /**
+ * Notify a specific listener of a change to a remote resource such as a file.
+ */
+ public void fireEvent(ISystemRemoteChangeListener l, ISystemRemoteChangeEvent event)
+ {
+ if (onMainThread()) {
+ l.systemRemoteResourceChanged(event);
+ }
+ else {
+ runOnMainThread(new RemoteResourceChangedRunnable(event, l));
+ }
+
+ }
+
+ // ----------------------------
+ // PREFERENCE EVENT METHODS...
+ // ----------------------------
+
+ /**
+ * Register your interest in being told when a system preference changes
+ */
+ public void addSystemPreferenceChangeListener(ISystemPreferenceChangeListener l)
+ {
+ preferenceListManager.addSystemPreferenceChangeListener(l);
+ }
+ /**
+ * De-Register your interest in being told when a system preference changes
+ */
+ public void removeSystemPreferenceChangeListener(ISystemPreferenceChangeListener l)
+ {
+ preferenceListManager.removeSystemPreferenceChangeListener(l);
+ }
+ /**
+ * Notify all listeners of a change to a system preference
+ * You would not normally call this as the methods in this class call it when appropriate.
+ */
+ public void fireEvent(ISystemPreferenceChangeEvent event)
+ {
+ if (onMainThread()) {
+ preferenceListManager.notify(event);
+ }
+ else {
+ runOnMainThread(new NotifyPreferenceChangedRunnable(event));
+ }
+ }
+ /**
+ * Notify a specific listener of a change to a system preference
+ */
+ public void fireEvent(ISystemPreferenceChangeListener l, ISystemPreferenceChangeEvent event)
+ {
+ if (onMainThread()) {
+ l.systemPreferenceChanged(event);
+ }
+ else {
+ runOnMainThread(new PreferenceChangedRunnable(event, l));
+ }
+ }
+
+ // ----------------------------
+ // MISCELLANEOUS METHODS...
+ // ----------------------------
+
+ /**
+ * Load everything into memory. Needed for pervasive operations like rename and copy
+ */
+ public void loadAll()
+ {
+ // step 0_a: force every subsystem factory to be active
+ ISubSystemConfigurationProxy[] proxies = getSubSystemConfigurationProxies();
+ if (proxies != null)
+ {
+ for (int idx = 0; idx < proxies.length; idx++)
+ proxies[idx].getSubSystemConfiguration();
+ }
+
+ // step 0_b: force every subsystem of every connection to be active!
+ IHost[] connections = getHosts();
+ for (int idx = 0; idx < connections.length; idx++)
+ getSubSystems(connections[idx]);
+ }
+
+ /**
+ * Return last exception object caught in any method, or null if no exception.
+ * This has the side effect of clearing the last exception.
+ */
+ public Exception getLastException()
+ {
+ Exception last = lastException;
+ lastException = null;
+ return last;
+ }
+
+ // ----------------------------
+ // SAVE / RESTORE METHODS...
+ // ----------------------------
+
+ /**
+ * Save everything!
+ */
+ public boolean save()
+ {
+ ISystemProfile[] notSaved = RSECorePlugin.getThePersistenceManager().commitProfiles(5000);
+ return notSaved.length > 0;
+ }
+
+ /**
+ * Save specific connection pool
+ * @return true if saved ok, false if error encountered. If false, call getLastException().
+ */
+ public boolean saveHostPool(ISystemHostPool pool)
+ {
+ return pool.commit();
+ }
+
+ /**
+ * Save specific connection
+ * @return true if saved ok, false if error encountered. If false, call getLastException().
+ */
+ public boolean saveHost(IHost conn)
+ {
+ return conn.commit();
+ }
+
+ /**
+ * Restore all connections within active profiles
+ * @return true if restored ok, false if error encountered. If false, call getLastException().
+ */
+ public boolean restore()
+ {
+ boolean ok = true;
+ lastException = null;
+ /*
+ SystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager();
+
+ SystemHostPool pool = null;
+ SystemPreferencesManager prefmgr = SystemPreferencesManager.getPreferencesManager();
+ if (!RSECorePlugin.getThePersistenceManager().restore(profileManager))
+ {
+ SystemProfile[] profiles = profileManager.getActiveSystemProfiles();
+ for (int idx = 0; idx < profiles.length; idx++)
+ {
+ try
+ {
+ pool = SystemHostPoolImpl.getSystemConnectionPool(profiles[idx]);
+ Host[] conns = pool.getHosts();
+ pool.orderHosts(prefmgr.getConnectionNamesOrder(conns, pool.getName()));
+ }
+ catch (Exception exc)
+ {
+ lastException = exc;
+ RSECorePlugin.getDefault().getLogger().logError("Exception in restore for connection pool " + profiles[idx].getName(), exc);
+ }
+ }
+ }
+ */
+ return ok;
+ }
+ public boolean contains(ISchedulingRule rule)
+ {
+ return rule == this;
+ }
+ public boolean isConflicting(ISchedulingRule rule)
+ {
+ return rule == this;
+ }
+ public ISystemFilterStartHere getSystemFilterStartHere() {
+ return SystemFilterStartHere.getInstance();
+ }
+
+ // ----------------------------------
+ // SYSTEMVIEWINPUTPROVIDER METHODS...
+ // ----------------------------------
+
+ /**
+ * Return the child objects to constitute the root elements in the system view tree.
+ * We return all connections that have an enabled system type.
+ */
+ public Object[] getSystemViewRoots()
+ {
+ //DKM - only return enabled connections now
+ IHost[] connections = getHosts();
+ List result = new ArrayList();
+ for (int i = 0; i < connections.length; i++) {
+ IHost con = connections[i];
+ IRSESystemType sysType = con.getSystemType();
+ // sysType can be null if workspace contains a host that is no longer defined by the workbench
+ if (sysType != null && sysType.isEnabled()) {
+ // Note: System types without registered subsystems get disabled by the default
+ // AbstractRSESystemType implementation itself! There is no need to re-check this here again.
+ result.add(con);
+ }
+ }
+ return result.toArray();
+ }
+
+ /**
+ * Return true if {@link #getSystemViewRoots()} will return a non-empty list
+ * We return true if there are any connections for any active profile.
+ */
+ public boolean hasSystemViewRoots()
+ {
+ return (getHostCount() > 0);
+ }
+
+ /**
+ * Return true if we are listing connections or not, so we know whether
+ * we are interested in connection-add events
+ */
+ public boolean showingConnections()
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setViewer(java.lang.Object)
+ */
+ public void setViewer(Object viewer)
+ {
+ this.viewer = viewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getViewer()
+ */
+ public Object getViewer()
+ {
+ return viewer;
+ }
+
+
+}//SystemRegistryImpl
Index: src/org/eclipse/rse/internal/core/model/SystemPostableEventNotifier.java
===================================================================
RCS file: src/org/eclipse/rse/internal/core/model/SystemPostableEventNotifier.java
diff -N src/org/eclipse/rse/internal/core/model/SystemPostableEventNotifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/rse/internal/core/model/SystemPostableEventNotifier.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,63 @@
+/********************************************************************************
+ * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
+ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
+ ********************************************************************************/
+
+package org.eclipse.rse.internal.core.model;
+import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
+import org.eclipse.rse.core.events.ISystemResourceChangeListener;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * To support posted events versus synchronous events, this class encapsulates
+ * the code to execute via the run() method.
+ * true
if the listener is already registered
+ */
+ public boolean isRegisteredSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ synchronized(lockObject) {
+ return listeners.contains(l);
+ }
+ }
+
+ /**
+ * Add a listener to list of listeners.
+ * If this object is already in the list, this does nothing.
+ * @param l the listener to add
+ */
+ public void addSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ synchronized(lockObject) {
+ if (!listeners.contains(l))
+ listeners.add(l);
+ }
+ }
+
+ /**
+ * Remove a listener from the list of listeners.
+ * If this object is not in the list, this does nothing.
+ * @param l the listener to remove
+ */
+ public void removeSystemResourceChangeListener(ISystemResourceChangeListener l)
+ {
+ synchronized(lockObject) {
+ //Thread-safety: create a new List when removing, to avoid problems in notify()
+ listeners = new ArrayList(listeners);
+ listeners.remove(l);
+ }
+ }
+
+ /**
+ * Notify all registered listeners of the given event.
+ * @param event the event to send
+ */
+ public void notify(ISystemResourceChangeEvent event)
+ {
+ //Thread-safe event firing: fire events on a current snapshot of the list.
+ //If not done that way, and a thread removes a listener while event firing
+ //is in progress, an ArrayIndexOutOfBoundException might occur.
+ List currentListeners;
+ synchronized(lockObject) {
+ currentListeners = listeners;
+ }
+ for (int idx=0; idx