mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
[162081] subsystemConfigurations should use "id" instead of "name" to reference systemTypes
This commit is contained in:
parent
ce4e99f5cc
commit
b69b48a074
10 changed files with 705 additions and 386 deletions
|
@ -16,11 +16,20 @@
|
|||
|
||||
package org.eclipse.rse.core.subsystems;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* Interface to SubSystemConfigurationExtension class
|
||||
* Internal use, not likely you will ever need to use it or access it directly.
|
||||
*/
|
||||
public interface ISubSystemConfigurationProxy {
|
||||
|
||||
/**
|
||||
* Return value of the <samp>id</samp> xml attribute.
|
||||
* Return unique id of this configuration.
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Return value of the <samp>name</samp> xml attribute.
|
||||
* Return name of this factory. Matches value in name attribute in extension point xml
|
||||
|
@ -34,14 +43,31 @@ public interface ISubSystemConfigurationProxy {
|
|||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Return value of the <samp>id</samp> xml attribute.
|
||||
* Return unique id of this configuration.
|
||||
* Returns the bundle which have declared the subsystem
|
||||
* configuration associated with this proxy.
|
||||
*
|
||||
* @return The declaring bundle.
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
public Bundle getDeclaringBundle();
|
||||
|
||||
/**
|
||||
* Return value of the <samp>systemTypes</samp> xml attribute.
|
||||
* Return the system types this subsystem configuration supports.
|
||||
* Return the system type names this subsystem configuration supports.
|
||||
*/
|
||||
public String getDeclaredSystemTypeNames();
|
||||
|
||||
/**
|
||||
* Return value of the <samp>systemTypeIds</samp> xml attribute.
|
||||
* Return the system type ids this subsystem configuration supports.
|
||||
*/
|
||||
public String getDeclaredSystemTypeIds();
|
||||
|
||||
/**
|
||||
* Returns the list of system types the subsystem configuration is supporting.
|
||||
* The list is combined from the list of currently registered system types cleaned
|
||||
* up by the ones not matching the declared system type names and ids.
|
||||
*
|
||||
* @return The list of supported system types or an empty list.
|
||||
*/
|
||||
public String[] getSystemTypes();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#Tue Jan 30 22:33:44 CET 2007
|
||||
#Fri Feb 09 09:55:49 CET 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
|
||||
org.eclipse.jdt.core.compiler.compliance=1.4
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
|
@ -29,14 +29,14 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
|
|||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
|
@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
|
|||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.3
|
||||
org.eclipse.jdt.core.compiler.source=1.4
|
||||
|
|
|
@ -203,38 +203,40 @@ public class SystemHostCombo extends Composite implements ISelectionProvider, IS
|
|||
* @param ssFactoryCategory Only connections with subsystems owned by factories of this category are returned.
|
||||
* @param showLabel true if a 'Connection' label is to be included in this composite
|
||||
*/
|
||||
public SystemHostCombo(Composite parent, int style, IHost defaultConnection, boolean showNewButton, String ssFactoryCategory, boolean showLabel)
|
||||
{
|
||||
super(parent, style);
|
||||
public SystemHostCombo(Composite parent, int style, IHost defaultConnection, boolean showNewButton, String ssFactoryCategory, boolean showLabel) {
|
||||
super(parent, style);
|
||||
if (showNewButton) // this is expensive, so only need to do this if New is enabled
|
||||
{
|
||||
ISubSystemConfigurationProxy[] ssfProxies = RSEUIPlugin.getTheSystemRegistry().getSubSystemConfigurationProxiesByCategory(ssFactoryCategory);
|
||||
Vector vTypes = new Vector();
|
||||
for (int idx=0; idx<ssfProxies.length; idx++)
|
||||
{
|
||||
String[] types = ssfProxies[idx].getSystemTypes();
|
||||
for (int jdx=0; jdx<types.length; jdx++)
|
||||
{
|
||||
if (!vTypes.contains(types[jdx]))
|
||||
vTypes.addElement(types[jdx]);
|
||||
}
|
||||
}
|
||||
restrictSystemTypesTo = new String[vTypes.size()];
|
||||
for (int idx=0; idx<vTypes.size(); idx++)
|
||||
restrictSystemTypesTo[idx] = (String)vTypes.elementAt(idx);
|
||||
}
|
||||
init(parent, showNewButton, showLabel);
|
||||
ISubSystemConfigurationProxy[] ssfProxies = RSEUIPlugin.getTheSystemRegistry().getSubSystemConfigurationProxiesByCategory(ssFactoryCategory);
|
||||
Vector vTypes = new Vector();
|
||||
for (int idx = 0; idx < ssfProxies.length; idx++) {
|
||||
// Do not call ISubSystemConfigurationProxy.getSystemTypes() directly. If
|
||||
// some one has overriden ISubSystemConfiguration.getSystemTypes(), the
|
||||
// proxy cannot return the correct list anymore. This is especially important
|
||||
// if the systemType <--> subsystemConfiguration association is dynamic!
|
||||
String[] types = ssfProxies[idx].getSubSystemConfiguration().getSystemTypes();
|
||||
for (int jdx = 0; jdx < types.length; jdx++) {
|
||||
if (!vTypes.contains(types[jdx]))
|
||||
vTypes.addElement(types[jdx]);
|
||||
}
|
||||
}
|
||||
restrictSystemTypesTo = new String[vTypes.size()];
|
||||
for (int idx = 0; idx < vTypes.size(); idx++)
|
||||
restrictSystemTypesTo[idx] = (String)vTypes.elementAt(idx);
|
||||
}
|
||||
init(parent, showNewButton, showLabel);
|
||||
populateSSFactoryCategory = ssFactoryCategory;
|
||||
populateConnectionCombo(connectionCombo, defaultConnection, ssFactoryCategory);
|
||||
setConnectionToolTipText();
|
||||
addOurConnectionSelectionListener();
|
||||
populateConnectionCombo(connectionCombo, defaultConnection, ssFactoryCategory);
|
||||
setConnectionToolTipText();
|
||||
addOurConnectionSelectionListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto-uppercase. When enabled, all non-quoted values are uppercases when added to the history.
|
||||
* Set auto-uppercase. When enabled, all non-quoted values are uppercases when added to the
|
||||
* history.
|
||||
* <p>
|
||||
* 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)
|
||||
{
|
||||
|
|
|
@ -6,33 +6,11 @@
|
|||
<meta.schema plugin="org.eclipse.rse.ui" id="subsystemConfigurations" name="Subsystem Configurations"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point allows tool-writers to extend the capability
|
||||
of the Remote System Explorer,
|
||||
by identifying a subsystem configuration that produces a subsystem
|
||||
whenever a new connection is created.
|
||||
This subsystem appears under the connection when it is expanded
|
||||
in the Remote Systems view of
|
||||
the Remote System Explorer perspective. The subsystem configuration
|
||||
is called by the Remote System
|
||||
framework when the user creates a new connection, when the connection's
|
||||
system type is one of the
|
||||
types identified as supported by this subsystem configuration extension.
|
||||
|
||||
This extension point allows tool-writers to extend the capability of the Remote System Explorer, by identifying a subsystem configuration that produces a subsystem whenever a new connection is created. This subsystem appears under the connection when it is expanded in the Remote Systems view of the Remote System Explorer perspective. The subsystem configuration is called by the Remote System framework when the user creates a new connection, when the connection's system type is one of the types identified as supported by this subsystem configuration extension.
|
||||
<p>
|
||||
There is one subsystem
|
||||
object per connection, and the role of a subsystem is to allow
|
||||
users to work with remote resources
|
||||
for the remote system identified by the containing connection.
|
||||
Defining a subsystem configuration involves more than the single subsystem
|
||||
configuration class. There must
|
||||
also be a subsystem class defined, and a system class defined.
|
||||
There may also be other classes
|
||||
defined, such as classes for the content area of wizards for
|
||||
defining filters, user actions
|
||||
and compile commands, if the subsystem configuration wishes to support
|
||||
these. See the developer documentation for the Remote System Explorer
|
||||
for documentation details on defining
|
||||
subsystems.
|
||||
There is one subsystem object per connection, and the role of a subsystem is to allow
|
||||
users to work with remote resourcesfor the remote system identified by the containing connection. Defining a subsystem configuration involves more than the single subsystem
|
||||
configuration class. There must also be a subsystem class defined, and a system class defined. There may also be other classes defined, such as classes for the content area of wizards for defining filters, user actions and compile commands, if the subsystem configuration wishes to support these. See the developer documentation for the Remote System Explorer for documentation details on defining subsystems.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
@ -157,26 +135,25 @@ These appear in configuration and properties pages for subsystems.
|
|||
<attribute name="systemTypes" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A semicolon separated list of system type names that subsystems from this configuration support.
|
||||
For example, "Unix;Linux". If not specified, defaults to all system types.
|
||||
A semicolon separated list of system type names that subsystems from this configuration support. For example, "Unix;Linux".
|
||||
If not specified and the "systemTypeIds" attribute is not specified, defaults to all system types.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="systemTypeIds" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A semicolon separated list of system type ids that subsystems from this configuration support. For example, "org.eclipse.rse.systemtype.unix;org.eclipse.rse.systemtype.linux".
|
||||
If not specified and the "systemTypes" attribute is not specified, defaults to all system types.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="category" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
This optional attribute allows subsystem providers to classify
|
||||
the type of remote resources
|
||||
that are listed by this subsystem configuration. It is possible for
|
||||
multiple subsystem factories to
|
||||
support the same remote resource category. This category is used
|
||||
in the popupMenus and
|
||||
propertyPages extension points, to scope actions and property
|
||||
pages to only remote resources
|
||||
of a particular category, via their <samp>subsystemconfigurationCategory</samp> attribute.
|
||||
For example, if listing database resources
|
||||
you might specify a
|
||||
category of "database".
|
||||
This optional attribute allows subsystem providers to classify the type of remote resources that are listed by this subsystem configuration. It is possible for
|
||||
multiple subsystem factories to support the same remote resource category. This category is used in the popupMenus and propertyPages extension points, to scope actions and property pages to only remote resources of a particular category, via their <samp>subsystemconfigurationCategory</samp> attribute.
|
||||
For example, if listing database resources you might specify a category of "database".
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
@ -218,11 +195,9 @@ Note that ServiceSubSystems that share the same service should always use the sa
|
|||
</pre>
|
||||
</p>
|
||||
|
||||
<p>Defining the xml for the extension point is easy. There is a fair amount to know about
|
||||
creating the classes needed for a subsystem configuration, however. For this information, consult
|
||||
the Remote System Explorer developer documention, including the JavaDoc for the supplied
|
||||
classes and interfaces for this task.
|
||||
</p>
|
||||
<p>
|
||||
Defining the xml for the extension point is easy. There is a fair amount to know about
|
||||
creating the classes needed for a subsystem configuration, however. For this information, consult the Remote System Explorer developer documention, including the JavaDoc for the supplied classes and interfaces for this task.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
@ -234,8 +209,7 @@ classes and interfaces for this task.
|
|||
The provider of subsystem factories must implement the interface
|
||||
<samp>org.eclipse.rse.core.subsystems.ISubSystemConfiguration</samp>,
|
||||
although it is not recommended to create a new class from scratch.
|
||||
Rather, it is highly recommended
|
||||
to use the supplied base class <samp>org.eclipse.rse.core.subsystems.SubSystemConfiguration</samp>.
|
||||
Rather, it is highly recommended to use the supplied base class <samp>org.eclipse.rse.core.subsystems.SubSystemConfiguration</samp>.
|
||||
This base class pre-supplies much functionality, including support for
|
||||
persisting properties and metadata, and support for filters.
|
||||
</documentation>
|
||||
|
@ -266,6 +240,7 @@ available at http://www.eclipse.org/legal/epl-v10.html
|
|||
|
||||
Contributors:
|
||||
IBM Corporation - initial API and implementation
|
||||
Uwe Stieber (Wind River) - systemTypeIds attribute extensions
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
|
|
@ -11,23 +11,26 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Uwe Stieber (Wind River) - systemTypeIds attribute extension and dynamic association
|
||||
* of system types.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.core.internal.subsystems;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.IRSESystemType;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
//import org.eclipse.rse.core.subsystems.IConnectorService;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
||||
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
|
||||
|
@ -35,351 +38,439 @@ import org.eclipse.rse.ui.ISystemIconConstants;
|
|||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a registered subsystem factory extension.
|
||||
*/
|
||||
public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy
|
||||
{
|
||||
// private String name,description,id,types,vendor, category, systemClassName;
|
||||
private String name,description,id,types,vendor, category;
|
||||
private int priority;
|
||||
private String[] systemTypes;
|
||||
private List typesArray;
|
||||
private boolean allTypes = false;
|
||||
private ImageDescriptor image, liveImage;
|
||||
private IConfigurationElement element = null;
|
||||
private ISubSystemConfiguration object = null;
|
||||
private boolean firstSubSystemQuery = true;
|
||||
//private SystemLogFile logFile = null;
|
||||
|
||||
|
||||
/**
|
||||
public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy {
|
||||
// The associated configuration element this proxy is wrapping
|
||||
private IConfigurationElement element = null;
|
||||
|
||||
// The subsystem configuration id
|
||||
private String id;
|
||||
// The subsystem configuration name
|
||||
private String name;
|
||||
// The subsystem configuration description
|
||||
private String description;
|
||||
// The list of associated system types by name as it appears in the plugin.xml
|
||||
private String systemTypeNames;
|
||||
// The list of associated system types by id as it appears in the plugin.xml
|
||||
private String systemTypeIds;
|
||||
|
||||
// The list of resolved system types supported by this subsystem configuration. This
|
||||
// list is build from the list of registered system types cleaned up by the ones not
|
||||
// matching either by name or id.
|
||||
private List resolvedSystemTypes;
|
||||
|
||||
// Flag to mark if the subsystem configuration supports all registered system types
|
||||
private boolean allTypes = false;
|
||||
|
||||
// The subsystem configuration vendor
|
||||
private String vendor;
|
||||
// The remote system resource category
|
||||
private String category;
|
||||
// The subsystem configuration priority
|
||||
private int priority;
|
||||
// The subsystem configuration image
|
||||
private ImageDescriptor image;
|
||||
// The subsystem configuration live image
|
||||
private ImageDescriptor liveImage;
|
||||
|
||||
// The subsystem configuration implementation class
|
||||
private ISubSystemConfiguration configuration = null;
|
||||
// Flag to mark if the subsystem configration class has been initialized.
|
||||
// We need this flag as the class may fail to load and we cannot determine it
|
||||
// only by the null value of the field configuration.
|
||||
private boolean subSystemConfigurationInitialized = false;
|
||||
|
||||
private final ISystemTypeMatcher systemTypeMatcher;
|
||||
|
||||
// Internal classes encapsulating the logic to match the declared system types against
|
||||
// a specific given one.
|
||||
|
||||
private static interface ISystemTypeMatcher {
|
||||
/**
|
||||
* Checks if the specified system type is matched by this pattern.
|
||||
*/
|
||||
public boolean matches(IRSESystemType systemType);
|
||||
}
|
||||
|
||||
private final class SystemTypeMatcher implements ISystemTypeMatcher {
|
||||
private final class SystemTypeNamePattern implements ISystemTypeMatcher {
|
||||
private final Pattern pattern;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public SystemTypeNamePattern(Pattern pattern) {
|
||||
assert pattern != null;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.internal.subsystems.SubSystemConfigurationProxy.ISystemTypePattern#matches(org.eclipse.rse.core.IRSESystemType)
|
||||
*/
|
||||
public boolean matches(IRSESystemType systemType) {
|
||||
assert systemType != null;
|
||||
return pattern.matcher(systemType.getName()).matches();
|
||||
}
|
||||
}
|
||||
|
||||
private final class SystemTypeIdPattern implements ISystemTypeMatcher {
|
||||
private final Pattern pattern;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public SystemTypeIdPattern(Pattern pattern) {
|
||||
assert pattern != null;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.internal.subsystems.SubSystemConfigurationProxy.ISystemTypePattern#matches(org.eclipse.rse.core.IRSESystemType)
|
||||
*/
|
||||
public boolean matches(IRSESystemType systemType) {
|
||||
assert systemType != null;
|
||||
return pattern.matcher(systemType.getId()).matches();
|
||||
}
|
||||
}
|
||||
|
||||
// List of patterns to match. The order is preserved. Names comes before ids.
|
||||
private final List patterns = new LinkedList();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param declaredSystemTypeNames The list of declared system type names. Might be <code>null</code>.
|
||||
* @param declaredSystemTypeIds The list of declared system type ids. Might be <code>null</code>.
|
||||
*/
|
||||
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; idx<v.size(); idx++)
|
||||
systemTypes[idx] = (String)v.elementAt(idx);
|
||||
}
|
||||
}
|
||||
return systemTypes;
|
||||
}
|
||||
/**
|
||||
* Return true if this factory supports all system types
|
||||
*/
|
||||
public boolean supportsAllSystemTypes()
|
||||
{
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getDeclaringBundle()
|
||||
*/
|
||||
public Bundle getDeclaringBundle() {
|
||||
assert element != null;
|
||||
return Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getDeclaredSystemTypeIds()
|
||||
*/
|
||||
public String getDeclaredSystemTypeIds() {
|
||||
return systemTypeIds;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getDeclaredSystemTypeNames()
|
||||
*/
|
||||
public String getDeclaredSystemTypeNames() {
|
||||
return "*".equals(systemTypeNames) ? null : systemTypeNames; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy#getSystemTypes()
|
||||
*/
|
||||
public String[] getSystemTypes() {
|
||||
if (resolvedSystemTypes == null) {
|
||||
resolvedSystemTypes = new LinkedList();
|
||||
|
||||
// If the subsystem configuration supports all system types, just add all
|
||||
// currently registered system types to th resolved list
|
||||
if (supportsAllSystemTypes()) {
|
||||
String[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
|
||||
if (systemTypes != null) resolvedSystemTypes.addAll(Arrays.asList(systemTypes));
|
||||
} else {
|
||||
// We have to match the given lists of system type names and ids against
|
||||
// the list of available system types. As the list of system types cannot
|
||||
// change ones it has been initialized, we filter out the not matching ones
|
||||
// here directly.
|
||||
IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
|
||||
for (int i = 0; i < systemTypes.length; i++) {
|
||||
IRSESystemType systemType = systemTypes[i];
|
||||
if (isMatchingDeclaredSystemTypes(systemType)) {
|
||||
resolvedSystemTypes.add(systemType.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (String[])resolvedSystemTypes.toArray(new String[resolvedSystemTypes.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified system type is supported by this subsystem configuration.
|
||||
*
|
||||
* @param systemType The system type to check. Must be not <code>null</code>.
|
||||
* @return <code>True</code> if the system type is supported by this subsystem configuration, <code>false</code> 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$
|
||||
}
|
||||
|
||||
}
|
|
@ -13,4 +13,12 @@ pluginName=RSE Unit Tests
|
|||
providerName=Eclipse.org
|
||||
|
||||
testSubSystemName = Tests
|
||||
testSubSystemDescription = Test Subsystem
|
||||
testSubSystemDescription = Test Subsystem
|
||||
|
||||
testSubSystem2Name = Tests2
|
||||
testSubSystem2Description = Test Subsystem 2
|
||||
|
||||
testSubSystem3Name = Tests3
|
||||
testSubSystem3Description = Test Subsystem 3
|
||||
|
||||
testSystemTypeDescription = RSE Test plugin internal system type
|
||||
|
|
|
@ -28,5 +28,41 @@
|
|||
icon="icons/systemconnection.gif"
|
||||
priority="50000">
|
||||
</configuration>
|
||||
|
||||
<configuration
|
||||
id="org.eclipse.rse.tests.subsystems.TestSubSystem2"
|
||||
systemTypeIds="org.eclipse.rse.tests.*"
|
||||
name="%testSubSystem2Name"
|
||||
class="org.eclipse.rse.tests.internal.testsubsystem.TestSubSystemConfiguration"
|
||||
category="users"
|
||||
vendor="%providerName"
|
||||
description="%testSubSystem2Description"
|
||||
iconlive="icons/systemconnectionlive.gif"
|
||||
icon="icons/systemconnection.gif"
|
||||
priority="100000">
|
||||
</configuration>
|
||||
|
||||
<configuration
|
||||
id="org.eclipse.rse.tests.subsystems.TestSubSystem3"
|
||||
systemTypes="*n?x"
|
||||
name="%testSubSystem3Name"
|
||||
class="org.eclipse.rse.tests.internal.testsubsystem.TestSubSystemConfiguration"
|
||||
category="users"
|
||||
vendor="%providerName"
|
||||
description="%testSubSystem3Description"
|
||||
iconlive="icons/systemconnectionlive.gif"
|
||||
icon="icons/systemconnection.gif"
|
||||
priority="2000">
|
||||
</configuration>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.rse.core.systemTypes">
|
||||
<systemType
|
||||
description="%testSystemTypeDescription"
|
||||
enableOffline="false"
|
||||
id="org.eclipse.rse.tests.testSystemType"
|
||||
name="Tests Only">
|
||||
</systemType>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -14,6 +14,7 @@ import junit.framework.Test;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite;
|
||||
import org.eclipse.rse.tests.core.registries.RSERegistriesTestSuite;
|
||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
|
||||
import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite;
|
||||
|
@ -51,6 +52,7 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder {
|
|||
|
||||
// add the single test suites to the overall one here.
|
||||
suite.addTest(RSEInternalFrameworkTestSuite.suite());
|
||||
suite.addTest(RSERegistriesTestSuite.suite());
|
||||
suite.addTest(RSEConnectionTestSuite.suite());
|
||||
suite.addTest(RSEFileSubsystemTestSuite.suite());
|
||||
suite.addTest(RSETestSubsystemTestSuite.suite());
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*******************************************************************************
|
||||
* 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 junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||
|
||||
public class RSERegistriesTestSuite extends DelegatingTestSuiteHolder {
|
||||
/**
|
||||
* Standard Java application main method. Allows to launch the test
|
||||
* suite from outside as part of nightly runs, headless runs or other.
|
||||
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
|
||||
* it is explicitly supposed to output the test output to the shell the
|
||||
* test suite has been launched from.
|
||||
* <p>
|
||||
* @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.
|
||||
* <p>
|
||||
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
|
||||
* the JUnit plug-in test launcher will fail to detect this class!</b>
|
||||
* <p>
|
||||
* @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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue