- * This method is part of ISystemCombo, so we must support it, but it does not apply this combo widget since the
- * contents are read-only. Hence, it does nothing!
+ * This method is part of ISystemCombo, so we must support it, but it does not apply this combo
+ * widget since the contents are read-only. Hence, it does nothing!
*/
public void setAutoUpperCase(boolean enable)
{
diff --git a/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd b/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd
index bc61bb9271d..da4c9a6c0c2 100644
--- a/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd
+++ b/rse/plugins/org.eclipse.rse.ui/schema/subsystemConfigurations.exsd
@@ -6,33 +6,11 @@
Note: Use only
+ * @param args The standard Java application command line parameters passed in.
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Combine all test into a suite and returns the test suite instance.
+ *
+ * Note: This method must be always called
+ * @return The test suite instance.
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite("RSE Registries Test Suite"); //$NON-NLS-1$
+ // add the single test suites to the overall one here.
+ suite.addTestSuite(SubSystemConfigurationProxyTestCase.class);
+
+ return suite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
+ */
+ public TestSuite getTestSuite() {
+ return (TestSuite)RSERegistriesTestSuite.suite();
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java
new file mode 100644
index 00000000000..af3ef6d6fb0
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Uwe Stieber (Wind River) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.rse.tests.core.registries;
+
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
+import org.eclipse.rse.tests.RSETestsPlugin;
+import org.eclipse.rse.tests.core.RSECoreTestCase;
+
+/**
+ * Tests the subsystem configuration proxy functionality.
+ *
+ * @author uwe.stieber@windriver.com
+ */
+public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase {
+
+ public void testSubSystemConfigurationProxy() {
+ ISystemRegistry systemRegistry = RSECorePlugin.getDefault().getSystemRegistry();
+ assertNotNull("Failed to fetch RSE system registry instance!", systemRegistry); //$NON-NLS-1$
+
+ // get all subsystem configuration proxies and pick out the ones from our
+ // tests plugin.
+ ISubSystemConfigurationProxy[] proxies = systemRegistry.getSubSystemConfigurationProxies();
+ for (int i = 0; i < proxies.length; i++) {
+ ISubSystemConfigurationProxy proxy = proxies[i];
+ if (proxy.getDeclaringBundle().equals(RSETestsPlugin.getDefault().getBundle())) {
+ // Thats one of the subsystem configurations declared in our test subsystem
+ assertNotNull("Unexpected retrun value null for proxy.toString()!", proxy.toString()); //$NON-NLS-1$
+ assertEquals("Proxy object changed hash code between two calls!", proxy.hashCode(), proxy.hashCode()); //$NON-NLS-1$
+ assertFalse("Unexpected return value true for proxy.equals(null)!", proxy.equals(null)); //$NON-NLS-1$
+ assertTrue("Unexpected return value false for proxy.equals(proxy)!", proxy.equals(proxy)); //$NON-NLS-1$
+
+ if (proxy.getDeclaredSystemTypeNames() == null && proxy.getDeclaredSystemTypeIds() == null) {
+ assertTrue("Proxy is not flagged to support all system types but should!", proxy.supportsAllSystemTypes()); //$NON-NLS-1$
+ } else {
+ assertFalse("Proxy is flagged to support all system types but should not!", proxy.supportsAllSystemTypes()); //$NON-NLS-1$
+ }
+
+ // a few specific value we test only for one well known test subsystem
+ if ("org.eclipse.rse.tests.subsystems.TestSubSystem".equals(proxy.getId())) { //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getDescription()!", "Test Subsystem", proxy.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getVendor()!", "Eclipse.org", proxy.getVendor()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getName()!", "Tests", proxy.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getDeclaredSystemTypeNames()!", "Local;Windows", proxy.getDeclaredSystemTypeNames()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNull("Unexpected return value non-null for proxy.getDeclaredSystemTypeIds()!", proxy.getDeclaredSystemTypeIds()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getPriority()!", 50000, proxy.getPriority()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$
+
+ // walk through all known system types. Only "Local" and "Windows" should match!
+ IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
+ assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$
+ for (int j = 0; j < systemTypes.length; j++) {
+ IRSESystemType systemType = systemTypes[j];
+ assertNotNull("Invalid null value in list of registered system types!", systemType); //$NON-NLS-1$
+ if ("Local".equalsIgnoreCase(systemType.getName()) || "Windows".equalsIgnoreCase(systemType.getName())) { //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Proxy is expected to be applicable, but returned not to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ } else {
+ assertFalse("Proxy is expected not to be applicable, but returned to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if ("org.eclipse.rse.tests.subsystems.TestSubSystem2".equals(proxy.getId())) { //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getDescription()!", "Test Subsystem 2", proxy.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getVendor()!", "Eclipse.org", proxy.getVendor()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getName()!", "Tests2", proxy.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getDeclaredSystemTypeIds()!", "org.eclipse.rse.tests.*", proxy.getDeclaredSystemTypeIds()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNull("Unexpected return value non-null for proxy.getDeclaredSystemTypeNames()!", proxy.getDeclaredSystemTypeNames()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getPriority()!", 100000, proxy.getPriority()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$
+
+ // walk through all known system types. All system types declared by the tests plugin are expected to match
+ IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
+ assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$
+ for (int j = 0; j < systemTypes.length; j++) {
+ IRSESystemType systemType = systemTypes[j];
+ assertNotNull("Invalid null value in list of registered system types!", systemType); //$NON-NLS-1$
+ if (systemType.getId().startsWith("org.eclipse.rse.tests.")) { //$NON-NLS-1$
+ assertTrue("Proxy is expected to be applicable, but returned not to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ } else {
+ assertFalse("Proxy is expected not to be applicable, but returned to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if ("org.eclipse.rse.tests.subsystems.TestSubSystem3".equals(proxy.getId())) { //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getDescription()!", "Test Subsystem 3", proxy.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getVendor()!", "Eclipse.org", proxy.getVendor()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getName()!", "Tests3", proxy.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Unexpected return value for proxy.getDeclaredSystemTypeNames()!", "*n?x", proxy.getDeclaredSystemTypeNames()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNull("Unexpected return value non-null for proxy.getDeclaredSystemTypeIds()!", proxy.getDeclaredSystemTypeIds()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getPriority()!", 2000, proxy.getPriority()); //$NON-NLS-1$
+ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$
+
+ // walk through all known system types. Only "Unix" and "Linux" should match!
+ IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
+ assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$
+ for (int j = 0; j < systemTypes.length; j++) {
+ IRSESystemType systemType = systemTypes[j];
+ assertNotNull("Invalid null value in list of registered system types!", systemType); //$NON-NLS-1$
+ if ("Unix".equalsIgnoreCase(systemType.getName()) || "Linux".equalsIgnoreCase(systemType.getName())) { //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Proxy is expected to be applicable, but returned not to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ } else {
+ assertFalse("Proxy is expected not to be applicable, but returned to be!", proxy.appliesToSystemType(systemType.getName())); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+}
null
.
+ * @param declaredSystemTypeIds The list of declared system type ids. Might be null
.
+ */
+ public SystemTypeMatcher(String declaredSystemTypeNames, String declaredSystemTypeIds) {
+ // Compile the list of patterns out of given lists of declared system types
+ if (declaredSystemTypeNames != null) {
+ String[] names = declaredSystemTypeNames.split(";"); //$NON-NLS-1$
+ if (names != null && names.length > 0) {
+ for (int i = 0; i < names.length; i++) {
+ SystemTypeNamePattern pattern = new SystemTypeNamePattern(Pattern.compile(makeRegex(names[i])));
+ patterns.add(pattern);
+ }
+ }
+ }
+
+ if (declaredSystemTypeIds != null) {
+ String[] ids = declaredSystemTypeIds.split(";"); //$NON-NLS-1$
+ if (ids != null && ids.length > 0) {
+ for (int i = 0; i < ids.length; i++) {
+ SystemTypeIdPattern pattern = new SystemTypeIdPattern(Pattern.compile(makeRegex(ids[i])));
+ patterns.add(pattern);
+ }
+ }
+ }
+ }
+
+ private String makeRegex(String pattern) {
+ assert pattern != null;
+ String translated = pattern;
+ if (translated.indexOf('.') != -1) translated = translated.replaceAll("\\.", "\\."); //$NON-NLS-1$ //$NON-NLS-2$
+ if (translated.indexOf(' ') != -1) translated = translated.replaceAll(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
+ if (translated.indexOf('*') != -1) translated = translated.replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (translated.indexOf('?') != -1) translated = translated.replaceAll("?", "."); //$NON-NLS-1$ //$NON-NLS-2$
+ return translated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.internal.subsystems.SubSystemConfigurationProxy.ISystemTypeMatcher#matches(org.eclipse.rse.core.IRSESystemType)
+ */
+ public boolean matches(IRSESystemType systemType) {
+ assert systemType != null;
+ if (!patterns.isEmpty()) {
+ Iterator iterator = patterns.iterator();
+ while (iterator.hasNext()) {
+ ISystemTypeMatcher matcher = (ISystemTypeMatcher)iterator.next();
+ if (matcher.matches(systemType)) return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
* Constructor
* @param element The IConfigurationElement for this factory's plugin
*/
public SubSystemConfigurationProxy(IConfigurationElement element) {
+ assert element != null;
+ // Read the single attributes from the configuration element
this.element = element;
this.id = element.getAttribute("id"); //$NON-NLS-1$
this.name = element.getAttribute("name").trim(); //$NON-NLS-1$
this.description = element.getAttribute("description").trim(); //$NON-NLS-1$
- this.types = element.getAttribute("systemTypes"); //$NON-NLS-1$
+ this.systemTypeNames = element.getAttribute("systemTypes"); //$NON-NLS-1$
+ this.systemTypeIds = element.getAttribute("systemTypeIds"); //$NON-NLS-1$
this.vendor = element.getAttribute("vendor"); //$NON-NLS-1$
this.category = element.getAttribute("category"); //$NON-NLS-1$
-// this.systemClassName = element.getAttribute("systemClass");
this.priority = Integer.MAX_VALUE;
-
+
String priorityStr = element.getAttribute("priority"); //$NON-NLS-1$
-
+
+ // Normalize the attributes now
try {
-
- if (priorityStr != null) {
- priority = Integer.parseInt(priorityStr);
- }
- }
- catch (NumberFormatException e) {
+ if (priorityStr != null) priority = Integer.parseInt(priorityStr);
+ } catch (NumberFormatException e) {
priority = Integer.MAX_VALUE;
SystemBasePlugin.logError("Exception reading priority for subsystem configuration " + name + " defined in plugin " + element.getDeclaringExtension().getNamespaceIdentifier(), e); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
if (vendor == null) vendor = "Unknown"; //$NON-NLS-1$
if (category == null) category = "Unknown"; //$NON-NLS-1$
- if (types == null) types = "*"; //$NON-NLS-1$
- this.allTypes = types.equals("*"); //$NON-NLS-1$
+
+ // We default to all system types if neither systemTypeNames nor systemTypeIds are specified.
+ if (systemTypeNames == null && systemTypeIds == null) systemTypeNames = "*"; //$NON-NLS-1$
+
+ this.allTypes = systemTypeNames.equals("*"); //$NON-NLS-1$
+
this.image = getPluginImage(element, element.getAttribute("icon")); //$NON-NLS-1$
- if (this.image == null) this.image = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTION_ID);
+ if (this.image == null) this.image = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTION_ID);
+
this.liveImage = getPluginImage(element, element.getAttribute("iconlive")); //$NON-NLS-1$
if (this.liveImage == null) this.liveImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTIONLIVE_ID);
- //createFolderTree();
+
+ systemTypeMatcher = new SystemTypeMatcher(getDeclaredSystemTypeNames(), getDeclaredSystemTypeIds());
}
- /**
- * Return the value of the "vendor" attribute
- */
- public String getVendor()
- {
- return vendor;
- }
- /**
- * Return the value of the "name" attribute
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getVendor()
*/
- public String getName()
- {
- return name;
- }
- /**
- * Return the value of the "description" attribute
+ public String getVendor() {
+ return vendor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getName()
*/
- public String getDescription()
- {
- return description;
- }
- /**
- * Return the value of the "id" attribute
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getDescription()
*/
- public String getId()
- {
- return id;
- }
- /**
- * Return all defined system types
+ public String getDescription() {
+ return description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getId()
*/
- public String[] getSystemTypes()
- {
- if (systemTypes == null)
- {
- if (allTypes)
- systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
- else
- {
- StringTokenizer tokens = new StringTokenizer(types,";"); //$NON-NLS-1$
- Vector v = new Vector();
- while (tokens.hasMoreTokens())
- v.addElement(tokens.nextToken());
- systemTypes = new String[v.size()];
- for (int idx=0; idxTrue
if the system type is supported by this subsystem configuration, false
otherwise.
+ */
+ protected boolean isMatchingDeclaredSystemTypes(IRSESystemType systemType) {
+ return systemTypeMatcher.matches(systemType);
+ }
+
+ /**
+ * Return true if this factory supports all system types
+ */
+ public boolean supportsAllSystemTypes() {
+ return allTypes;
+ }
+
/**
* Return the value of the "category" attribute
*/
- public String getCategory()
- {
- return category;
- }
-
- public ImageDescriptor getImage()
- {
- return image;
- }
-
- /**
- * Return image to use when this susystem is connection. Comes from icon attribute in extension point xml
- */
- public ImageDescriptor getLiveImage()
- {
- if (liveImage != null)
- return liveImage;
- else
- return image;
- }
-
- /**
+ public String getCategory() {
+ return category;
+ }
+
+ public ImageDescriptor getImage() {
+ return image;
+ }
+
+ /**
+ * Returns the live image to use when this susystem is connection.
+ * Comes from iconLive attribute in extension point xml.
+ */
+ public ImageDescriptor getLiveImage() {
+ if (liveImage != null) return liveImage;
+ return getImage();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getPriority()
*/
public int getPriority() {
return priority;
}
-
+
/**
- * Return true if this extension's systemTypes attribute matches the given system type
- */
- public boolean appliesToSystemType(String type)
- {
- if (allTypes)
- return true;
- else
- {
- List typesArray = getTypesArray();
- return typesArray.contains(type);
- }
- }
-
- private List getTypesArray()
- {
- if (typesArray == null)
- {
- typesArray = new ArrayList();
- StringTokenizer tokenizer = new StringTokenizer(types,";"); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens())
- {
- String type = tokenizer.nextToken();
- typesArray.add(type);
+ * Return true if this extension's systemTypes attribute matches the given system type name.
+ */
+ public boolean appliesToSystemType(String type) {
+ assert type != null;
+ if (allTypes) return true;
+ return Arrays.asList(getSystemTypes()).contains(type);
+ }
+
+ /**
+ * Retrieve image in given plugin's directory tree, given its file name.
+ * The file name should be relatively qualified with the subdir containing it.
+ */
+ protected ImageDescriptor getPluginImage(IConfigurationElement element, String fileName) {
+ URL path = getDeclaringBundle().getEntry("/"); //$NON-NLS-1$
+ URL fullPathString = null;
+ try {
+ fullPathString = new URL(path, fileName);
+ return ImageDescriptor.createFromURL(fullPathString);
+ } catch (MalformedURLException e) {
+ }
+ return null;
+ }
+
+ /**
+ * Return true if this subsystem factory has been instantiated yet.
+ * Use this when you want to avoid the side effect of starting the subsystem factory object.
+ */
+ public boolean isSubSystemConfigurationActive() {
+ return (configuration != null);
+ }
+
+ /**
+ * Return the subsystem factory's object, which is an instance of the class
+ * specified in the class attribute of the extender's xml for the factory extension point.
+ * The object is only instantiated once, and returned on each call to this.
+ */
+ public ISubSystemConfiguration getSubSystemConfiguration() {
+ if (!subSystemConfigurationInitialized && configuration == null) {
+ try {
+ Object executable = element.createExecutableExtension("class"); //$NON-NLS-1$
+ if (executable instanceof ISubSystemConfiguration) {
+ configuration = (ISubSystemConfiguration) executable;
+ configuration.setSubSystemConfigurationProxy(this); // side effect: restores filter pools
+ }
+ } catch (Exception exc) {
+ exc.printStackTrace();
+ SystemBasePlugin.logError("Unable to start subsystem factory " + id, exc); //$NON-NLS-1$
+ org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(SystemBasePlugin.getActiveWorkbenchShell());
+ mb.setText("Unexpected Error"); //$NON-NLS-1$
+ String errmsg = "Unable to start subsystem factory " + getName() + ". See log file for details"; //$NON-NLS-1$ //$NON-NLS-2$
+ mb.setMessage(errmsg);
+ mb.open();
}
- }
- return typesArray;
- }
-
- /**
- * Retrieve image in given plugin's directory tree, given its file name.
- * The file name should be relatively qualified with the subdir containing it.
- */
- protected ImageDescriptor getPluginImage(IConfigurationElement element, String fileName)
- {
- URL path = getBundle().getEntry("/"); //$NON-NLS-1$
- URL fullPathString = null;
- try {
- fullPathString = new URL(path,fileName);
- return ImageDescriptor.createFromURL(fullPathString);
- } catch (MalformedURLException e) {}
- return null;
- }
+
+ // Attempt to restore the subsystem configuration completely.
+ restore();
+
+ subSystemConfigurationInitialized = true;
+ }
+
+ return configuration;
+ }
- /**
- * Return true if this subsystem factory has been instantiated yet.
- * Use this when you want to avoid the side effect of starting the subsystem factory object.
- */
- public boolean isSubSystemConfigurationActive()
- {
- return (object != null);
- }
-
- /**
- * Return the subsystem factory's object, which is an instance of the class
- * specified in the class attribute of the extender's xml for the factory extension point.
- * The object is only instantiated once, and returned on each call to this.
- */
- public ISubSystemConfiguration getSubSystemConfiguration()
- {
- if ( firstSubSystemQuery == true && object == null )
- {
- try
- {
-// get the name space of the declaring extension
- String nameSpace = element.getDeclaringExtension().getNamespaceIdentifier();
- String extensionType = element.getAttribute("class"); //$NON-NLS-1$
-
- // use the name space to get the bundle
- Bundle bundle = Platform.getBundle(nameSpace);
-
- // if the bundle has not been uninstalled, then load the handler referred to in the
- // extension, and load it using the bundle
- // then register the handler
- if (bundle.getState() != Bundle.UNINSTALLED)
- {
- Class menuExtension = bundle.loadClass(extensionType);
-
- object = (ISubSystemConfiguration)menuExtension.getConstructors()[0].newInstance(null);
- }
-
- object.setSubSystemConfigurationProxy(this); // side effect: restores filter pools
- //System.out.println("*** STARTED SSFACTORY: " + id + " ***");
- } catch (Exception exc)
- {
- exc.printStackTrace();
- SystemBasePlugin.logError("Unable to start subsystem factory "+id,exc); //$NON-NLS-1$
- org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(SystemBasePlugin.getActiveWorkbenchShell());
- mb.setText("Unexpected Error"); //$NON-NLS-1$
- String errmsg = "Unable to start subsystem factory "+getName()+". See log file for details"; //$NON-NLS-1$ //$NON-NLS-2$
- mb.setMessage(errmsg);
- mb.open();
- }
- if (object != null)
- {
- try
- {
- if (object instanceof SubSystemConfiguration) // hoaky but works
- {
- SubSystemConfiguration ssFactory = (SubSystemConfiguration)object;
- ssFactory.restoreAllFilterPoolManagersForAllProfiles();
- }
- } catch (Exception exc)
- {
- SystemBasePlugin.logError("Error restoring subsystem for factory "+getName(),exc); //$NON-NLS-1$
- }
- }
- firstSubSystemQuery = false;
- }
- return object;
- }
-// /**
-// * Return an instance of the IConnectorService class identified by the "systemClass" attribute
-// * of this subsystemFactory extension point. Note each call to this method returns a
-// * new instance of the class, or null if no "systemClass" attribute was specified.
-// */
-// public IConnectorService getSystemObject()
-// {
-// if (systemClassName == null)
-// return null;
-// Object object = null;
-// try
-// {
-// object = (IConnectorService)element.createExecutableExtension("systemClass");
-// } catch (Exception exc)
-// {
-// SystemBasePlugin.logError("Unable to instantiate IConnectorService class "+ systemClassName + " for extension point " + id,exc);
-// org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(SystemBasePlugin.getActiveWorkbenchShell());
-// mb.setText("Unexpected Error");
-// String errmsg = "Unable to instantiate IConnectorService class " + systemClassName + " for extension point " + id +": " + exc.getClass().getName()+" - " + exc.getMessage();
-// mb.setMessage(errmsg);
-// mb.open();
-// }
-// return (IConnectorService)object;
-// }
-
/**
* Reset for a full refresh from disk, such as after a team synch.
*/
- public void reset()
- {
- if (object != null)
- object.reset();
- }
+ public void reset() {
+ if (configuration != null) configuration.reset();
+ }
/**
* After a reset, restore from disk
*/
- public void restore()
- {
- if (object != null)
- try
- {
- if (object instanceof SubSystemConfiguration) // hoaky but works
- {
- SubSystemConfiguration ssFactory = (SubSystemConfiguration)object;
- ssFactory.restoreAllFilterPoolManagersForAllProfiles();
- }
- } catch (Exception exc)
- {
- SystemBasePlugin.logError("Error restoring subsystem for factory "+getName(),exc); //$NON-NLS-1$
- }
+ public void restore() {
+ // If the subsystem configuration implementation is based on our default
+ // implementation, we can initiate the filter pool manager restore from here.
+ if (configuration instanceof SubSystemConfiguration) {
+ try {
+ ((SubSystemConfiguration)configuration).restoreAllFilterPoolManagersForAllProfiles();
+ } catch (Exception exc) {
+ SystemBasePlugin.logError("Error restoring subsystem for factory " + getName(), exc); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ if (o instanceof String)
+ return ((String)o).equals(id);
+ else if (o instanceof SubSystemConfigurationProxy)
+ return ((SubSystemConfigurationProxy)o).getId().equals(id);
+ else
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return id + "." + name; //$NON-NLS-1$
}
- // PRIVATE METHODS USED BY THIS CLASS AND THE FACTORY OBJECT CLASS IT WRAPPERS.
-
- protected IConfigurationElement getConfigurationElement()
- {
- return element;
- }
-
- protected Bundle getBundle()
- {
- String nameSpace = element.getDeclaringExtension().getNamespaceIdentifier();
- return Platform.getBundle(nameSpace);
- }
-
- // -----------------
- // COMMON METHODS...
- // -----------------
-
- public boolean equals(Object o)
- {
- if (o instanceof String)
- return ((String)o).equals(id);
- else if (o instanceof SubSystemConfigurationProxy)
- return ((SubSystemConfigurationProxy)o).getId().equals(id);
- else
- return false;
- }
-
- public int hashCode()
- {
- return id.hashCode();
- }
-
- public String toString()
- {
- return id+"."+name; //$NON-NLS-1$
- }
-
}
\ No newline at end of file
diff --git a/rse/tests/org.eclipse.rse.tests/plugin.properties b/rse/tests/org.eclipse.rse.tests/plugin.properties
index 3e652a064a2..578d463a617 100644
--- a/rse/tests/org.eclipse.rse.tests/plugin.properties
+++ b/rse/tests/org.eclipse.rse.tests/plugin.properties
@@ -13,4 +13,12 @@ pluginName=RSE Unit Tests
providerName=Eclipse.org
testSubSystemName = Tests
-testSubSystemDescription = Test Subsystem
\ No newline at end of file
+testSubSystemDescription = Test Subsystem
+
+testSubSystem2Name = Tests2
+testSubSystem2Description = Test Subsystem 2
+
+testSubSystem3Name = Tests3
+testSubSystem3Description = Test Subsystem 3
+
+testSystemTypeDescription = RSE Test plugin internal system type
diff --git a/rse/tests/org.eclipse.rse.tests/plugin.xml b/rse/tests/org.eclipse.rse.tests/plugin.xml
index 030c28bf30f..7ff0c5dacc1 100644
--- a/rse/tests/org.eclipse.rse.tests/plugin.xml
+++ b/rse/tests/org.eclipse.rse.tests/plugin.xml
@@ -28,5 +28,41 @@
icon="icons/systemconnection.gif"
priority="50000">
+
+ junit.textui.TestRunner
here as
+ * it is explicitly supposed to output the test output to the shell the
+ * test suite has been launched from.
+ * suite
! Otherwise
+ * the JUnit plug-in test launcher will fail to detect this class!
+ *