diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemConnectAllSubSystemsAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemConnectAllSubSystemsAction.java index 17d0fcb5066..8579b8aa7ac 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemConnectAllSubSystemsAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemConnectAllSubSystemsAction.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect() + * Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false) ********************************************************************************/ package org.eclipse.rse.internal.ui.actions; @@ -57,12 +58,15 @@ public class SystemConnectAllSubSystemsAction extends SystemBaseAction List failedSystems = new ArrayList(); try { + //forced instantiation of all subsystems ISubSystem[] subsystems = _connection.getSubSystems(); for (int i = 0; i < subsystems.length; i++) { ISubSystem subsystem = subsystems[i]; IConnectorService system = subsystem.getConnectorService(); - if (!subsystem.isConnected() && !failedSystems.contains(system)) + if (!subsystem.isConnected() + && subsystem.getSubSystemConfiguration().supportsSubSystemConnect() + && !failedSystems.contains(system)) { try { diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemDisconnectAllSubSystemsAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemDisconnectAllSubSystemsAction.java index d1414f86134..cb2e6105f73 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemDisconnectAllSubSystemsAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemDisconnectAllSubSystemsAction.java @@ -17,11 +17,14 @@ package org.eclipse.rse.internal.ui.actions; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.actions.SystemBaseAction; @@ -29,7 +32,7 @@ import org.eclipse.swt.widgets.Shell; /** - * This is the action forconnecting all subsystems for a given connection. + * This is the action for disconnecting all subsystems for a given connection. */ public class SystemDisconnectAllSubSystemsAction extends SystemBaseAction { @@ -49,6 +52,25 @@ public class SystemDisconnectAllSubSystemsAction extends SystemBaseAction // TODO help for connect all //setHelp(RSEUIPlugin.HELPPREFIX+"actn0022"); } + + private static ISubSystem[] getDisconnectableSubsystems(Object element) + { + ISubSystem[] result = null; + if (element instanceof IHost) { + IHost host = (IHost)element; + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + ISubSystem[] ss = sr.getSubSystems(host, false); + List l = new ArrayList(); + for (int i=0; i0); + } } /** diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java index 43e2665cf4a..210ea25155c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java @@ -29,6 +29,7 @@ * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections * Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread + * Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false) ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -592,13 +593,17 @@ public class SystemViewConnectionAdapter { if (element instanceof IHost) { + IHost host = (IHost)element; ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); - if (((IHost)element).getSystemType().isLocal()) - { - // local is always connected so always allow delete - return true; - } - return !sr.isAnySubSystemConnected((IHost)element); + //do not allow delete if any subsystem is connected but supports disconnect. + //specifically, this allows deletion of "Local" which is always connected (but does not support disconnect) + //need to get subsystems from registry instead of host in order to be lazy: + //subsystems which are not yet instantiated do not need to be considered. + ISubSystem[] ss = sr.getSubSystems(host, false); + for (int i=0; i 0) - //{ - subsystems = new ISubSystem[v.size()]; - for (int idx = 0; idx < v.size(); idx++) - subsystems[idx] = (ISubSystem) v.elementAt(idx); - //} + subsystems = (ISubSystem[])v.toArray(new ISubSystem[v.size()]); } return subsystems; } @@ -1148,44 +1149,6 @@ public class SystemRegistry implements ISystemRegistry return dataStream.toString(); } - - /** - * Return list of subsystem objects for a given connection, but does not force - * as-yet-non-restored subsystems to come to life. - *

- * To protect against crashes, if there are no subsystems, an array of length zero is returned. - */ - public ISubSystem[] getSubSystemsLazily(IHost conn) - { - ISubSystem[] subsystems = null; - Vector v = new Vector(); - - if (subsystemConfigurationProxies != null) - { - for (int idx = 0; idx < subsystemConfigurationProxies.length; idx++) - { - if (subsystemConfigurationProxies[idx].appliesToSystemType(conn.getSystemType()) && subsystemConfigurationProxies[idx].isSubSystemConfigurationActive()) - { - ISubSystemConfiguration factory = subsystemConfigurationProxies[idx].getSubSystemConfiguration(); - if (factory != null) - { - ISubSystem[] sss = factory.getSubSystems(conn, ISubSystemConfiguration.LAZILY); - if (sss != null) - for (int jdx = 0; jdx < sss.length; jdx++) - v.addElement(sss[jdx]); - } - } - } - //if (v.size() > 0) - //{ - subsystems = new ISubSystem[v.size()]; - for (int idx = 0; idx < v.size(); idx++) - subsystems[idx] = (ISubSystem) v.elementAt(idx); - //} - } - return subsystems; - } - public ISubSystem[] getSubsystems(IHost connection, Class subsystemInterface) { List matches = new ArrayList(); @@ -2355,7 +2318,7 @@ public class SystemRegistry implements ISystemRegistry public boolean isAnySubSystemConnected(IHost conn) { boolean any = false; - ISubSystem[] subsystems = getSubSystemsLazily(conn); + ISubSystem[] subsystems = getSubSystems(conn, false); if (subsystems == null) return false; for (int idx = 0; !any && (idx < subsystems.length); idx++) @@ -2366,6 +2329,29 @@ public class SystemRegistry implements ISystemRegistry } return any; } + + /** + * Check if there are any subsystem configurations that have not yet been instantiated + * and apply to the given system type. + * @param systemType the system type to check + * @return true 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) @@ -2374,15 +2360,27 @@ public class SystemRegistry implements ISystemRegistry public boolean areAllSubSystemsConnected(IHost conn) { boolean all = true; - ISubSystem[] subsystems = getSubSystemsLazily(conn); - if (subsystems == null) + 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()) + if (!ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect()) { + //we ignore unconnected subsystems that can not be connected anyways. return false; } } @@ -2395,18 +2393,18 @@ public class SystemRegistry implements ISystemRegistry */ public void disconnectAllSubSystems(IHost conn) { - - ISubSystem[] subsystems = getSubSystemsLazily(conn); + // get subsystems lazily, because not instantiated ones cannot be disconnected anyways. + ISubSystem[] subsystems = getSubSystems(conn, false); if (subsystems == null) return; - // dy: defect 47281, user repeaetedly prompted to disconnect if there is an open file + // 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()) + if (ss.isConnected() && ss.getSubSystemConfiguration().supportsSubSystemConnect()) { try { @@ -2415,7 +2413,7 @@ public class SystemRegistry implements ISystemRegistry } catch (InterruptedException exc) { - System.out.println("Cacnelled"); //$NON-NLS-1$ + System.out.println("Cancelled"); //$NON-NLS-1$ cancelled = true; } catch (Exception exc)