1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[168810] Apply patch from Tobias Schwarz (WRS) adding a testsubsystem to the RSE junit test framework

This commit is contained in:
Uwe Stieber 2006-12-21 09:55:42 +00:00
parent d272dba8f7
commit d4de109d0a
26 changed files with 1468 additions and 5 deletions

View file

@ -15,7 +15,13 @@ Require-Bundle: org.junit,
org.eclipse.rse.subsystems.files.core,
org.eclipse.rse.subsystems.shells.core,
org.eclipse.rse.tests.framework,
org.eclipse.ui.views,
org.eclipse.rse.services
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.rse.tests,
org.eclipse.rse.tests.core,
org.eclipse.rse.tests.core.connection,
org.eclipse.rse.tests.testsubsystem,
org.eclipse.rse.tests.testsubsystem.interfaces
Bundle-ClassPath: rsetests.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

View file

@ -15,3 +15,6 @@
#
pluginName=RSE Unit Tests
providerName=Eclipse.org
testSubSystemName = Tests
testSubSystemDescription = Test Subsystem

View file

@ -14,4 +14,19 @@
<suite type="org.eclipse.rse.tests.files.RSEFileTestSuite" name="RSE File Test Suite"/>
<type name="org.eclipse.rse.tests.files.RSEFileTestSuite" class="org.eclipse.rse.tests.files.RSEFileTestSuite" />
</extension>
<extension point="org.eclipse.rse.ui.subsystemConfigurations">
<configuration
id="org.eclipse.rse.tests.subsystems.TestSubSystem"
systemTypes="Local;Windows"
name="%testSubSystemName"
class="org.eclipse.rse.tests.internal.testsubsystem.TestSubSystemConfiguration"
category="users"
vendor="%providerName"
description="%testSubSystemDescription"
iconlive="icons/systemconnectionlive.gif"
icon="icons/systemconnection.gif"
priority="50000">
</configuration>
</extension>
</plugin>

View file

@ -17,9 +17,15 @@ import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.tests.core.IRSETestLogCollectorDelegate;
import org.eclipse.rse.tests.internal.RSEDefaultTestLogCollectorDelegate;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.rse.tests.internal.testsubsystem.TestSubSystemAdapterFactory;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemConfiguration;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.osgi.framework.BundleContext;
/**
@ -27,7 +33,7 @@ import org.osgi.framework.BundleContext;
* class provides basic infra structure for accessing externalized
* string data.
*/
public class RSETestsPlugin extends AbstractUIPlugin {
public class RSETestsPlugin extends SystemBasePlugin {
// The shared plugin instance.
private static RSETestsPlugin plugin;
// The resource bundle associated with this plugin.
@ -138,6 +144,12 @@ public class RSETestsPlugin extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
addDelegate(defaultLogCollectorDelegate);
IAdapterManager manager = Platform.getAdapterManager();
TestSubSystemAdapterFactory subSystemAdapterFactory = new TestSubSystemAdapterFactory();
manager.registerAdapters(subSystemAdapterFactory, ITestSubSystem.class);
manager.registerAdapters(subSystemAdapterFactory, ITestSubSystemNode.class);
manager.registerAdapters(subSystemAdapterFactory, ITestSubSystemConfiguration.class);
}
/* (non-Javadoc)
@ -211,4 +223,14 @@ public class RSETestsPlugin extends AbstractUIPlugin {
public synchronized IRSETestLogCollectorDelegate[] getTestLogCollectorDelegates() {
return (IRSETestLogCollectorDelegate[])logCollectorDelegates.toArray(new IRSETestLogCollectorDelegate[logCollectorDelegates.size()]);
}
/**
* Initialize the image registry by declaring all of the required graphics.
*/
protected void initializeImageRegistry() {
String path = getIconPath();
putImageInRegistry("ICON_ID_BRANCH", path + "branch.gif"); //$NON-NLS-1$ //$NON-NLS-2$
putImageInRegistry("ICON_ID_LEAF", path + "leaf.gif"); //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -248,7 +248,8 @@ public class RSECoreTestCase extends TestCase {
* @see junit.framework.TestCase#run(junit.framework.TestResult)
*/
public final void run(TestResult result) {
if (isProperty(IRSECoreTestCaseProperties.PROP_FORCE_BACKGROUND_EXECUTION, false)) {
if (isProperty(IRSECoreTestCaseProperties.PROP_FORCE_BACKGROUND_EXECUTION, false)
|| !RSEWaitAndDispatchUtil.isDispatchThread()) {
// do not force test execution into background, just call super.run(result)
// from with the current thread.
result.addListener(TEST_LISTENER);
@ -273,7 +274,8 @@ public class RSECoreTestCase extends TestCase {
public void runBare() throws Throwable {
// If PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN is set to true,
// print the timing information including the tests setUp and tearDown methods.
if (isProperty(IRSECoreTestCaseProperties.PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN, true)) {
if (isProperty(IRSECoreTestCaseProperties.PROP_FORCE_BACKGROUND_EXECUTION, false)
|| !RSEWaitAndDispatchUtil.isDispatchThread()) {
// Print timing information here
long start = printTestStartInformation(getName());
try {
@ -293,7 +295,8 @@ public class RSECoreTestCase extends TestCase {
protected void runTest() throws Throwable {
// If PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN is set to false (default),
// print the timing information only the test method itself.
if (isProperty(IRSECoreTestCaseProperties.PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN, false)) {
if (isProperty(IRSECoreTestCaseProperties.PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN, false)
|| !RSEWaitAndDispatchUtil.isDispatchThread()) {
// Print timing information here and run the test.
long start = printTestStartInformation(getName());
try {

View file

@ -28,6 +28,15 @@ public final class RSEWaitAndDispatchUtil {
// nothing to do. The class cannot be instanciated.
}
/**
* Checks if the current thread is a dispatch (UI) thread or not.
*
* @return <code>True</code> if the current thread is a dispatch thread, <code>false</code> otherwise.
*/
public static boolean isDispatchThread() {
return Display.findDisplay(Thread.currentThread()) != null;
}
/**
* Blocks the calling thread from execution till the specified
* time out has exceeded. If the calling thread is an display thread,

View file

@ -0,0 +1,175 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.SubSystem;
import org.eclipse.rse.tests.testsubsystem.TestSubSystemContainerNode;
import org.eclipse.rse.tests.testsubsystem.TestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNodeContainer;
/**
* Simple test subsystem with branches and leafes.
* Further childs can be added or removed via context menu actions.
*/
public class TestSubSystem extends SubSystem implements ITestSubSystem {
private ArrayList fChildren = new ArrayList();
/**
* Constructor.
* @param host
* @param connectorService
*/
public TestSubSystem(IHost host, IConnectorService connectorService) {
super(host, connectorService);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor)
*/
public void initializeSubSystem(IProgressMonitor monitor) {
TestSubSystemContainerNode parent0 = new TestSubSystemContainerNode("0"); //$NON-NLS-1$
TestSubSystemContainerNode child0 = new TestSubSystemContainerNode("0:0"); //$NON-NLS-1$
parent0.addChildNode(child0);
parent0.addChildNode(new TestSubSystemContainerNode("0:1")); //$NON-NLS-1$
parent0.addChildNode(new TestSubSystemContainerNode("0:2")); //$NON-NLS-1$
parent0.addChildNode(new TestSubSystemNode("0:3;")); //$NON-NLS-1$
parent0.addChildNode(new TestSubSystemContainerNode("0:4")); //$NON-NLS-1$
child0.addChildNode(new TestSubSystemNode("0:0:0;")); //$NON-NLS-1$
addChildNode(parent0);
addChildNode(new TestSubSystemContainerNode("1")); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#uninitializeSubSystem(org.eclipse.core.runtime.IProgressMonitor)
*/
public void uninitializeSubSystem(IProgressMonitor monitor) {
fChildren.clear();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#getObjectWithAbsoluteName(java.lang.String)
*/
public Object getObjectWithAbsoluteName(String key) {
ITestSubSystemNode[] childs = getChildNodes();
for (int i = 0; i < childs.length; i++) {
if (childs[i].getName().equalsIgnoreCase(key)) {
return childs[i];
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(org.eclipse.core.runtime.IProgressMonitor, java.lang.String)
*/
protected Object[] internalResolveFilterString(IProgressMonitor monitor, String filterString) throws InvocationTargetException, InterruptedException {
ArrayList filteredChilds = new ArrayList();
ITestSubSystemNode[] childs = getChildNodes();
for (int i = 0; i < childs.length; i++) {
if (childs[i].getName().matches(filterString)) {
filteredChilds.add(childs[i]);
}
}
return filteredChilds.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, java.lang.String)
*/
protected Object[] internalResolveFilterString(IProgressMonitor monitor, Object parent, String filterString) throws InvocationTargetException, InterruptedException {
ArrayList filteredChilds = new ArrayList();
if (parent instanceof ITestSubSystemNodeContainer) {
ITestSubSystemNodeContainer container = (ITestSubSystemNodeContainer)parent;
ITestSubSystemNode[] childs = container.getChildNodes();
for (int i = 0; i < childs.length; i++) {
if (childs[i].getName().matches(filterString)) {
filteredChilds.add(childs[i]);
}
}
}
return filteredChilds.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#addChildNode(org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode)
*/
public boolean addChildNode(ITestSubSystemNode node) {
if (node != null && !fChildren.contains(node)) {
node.setSubSystem(this);
fChildren.add(node);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#removeChildNode(org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode)
*/
public boolean removeChildNode(ITestSubSystemNode node) {
if (node != null && fChildren.contains(node)) {
if (node instanceof ITestSubSystemNodeContainer) {
((ITestSubSystemNodeContainer)node).removeAllChildNodes();
}
fChildren.remove(node);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#removeAllChildNodes()
*/
public boolean removeAllChildNodes() {
if (!fChildren.isEmpty()) {
ITestSubSystemNode[] childs = getChildNodes();
for (int i = 0; i < childs.length; i++) {
if (childs[i] instanceof ITestSubSystemNodeContainer) {
((ITestSubSystemNodeContainer)childs[i]).removeAllChildNodes();
}
}
fChildren.clear();
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#hasChildNodes()
*/
public boolean hasChildNodes() {
return !fChildren.isEmpty();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#getChildNodeCount()
*/
public int getChildNodeCount() {
return fChildren.size();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#getChildNodes()
*/
public ITestSubSystemNode[] getChildNodes() {
return (ITestSubSystemNode[])fChildren.toArray(new ITestSubSystemNode[fChildren.size()]);
}
}

View file

@ -0,0 +1,151 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.SystemPerspectiveHelpers;
import org.eclipse.rse.tests.testsubsystem.TestSubSystemAddAction;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemAddTarget;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNodeContainer;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemView;
import org.eclipse.rse.ui.view.SystemViewSubSystemAdapter;
import org.eclipse.swt.widgets.Shell;
/**
* Adapter for subsystem node.
*/
public class TestSubSystemAdapter extends SystemViewSubSystemAdapter
implements ISystemRemoteElementAdapter, ITestSubSystemAddTarget {
/**
* Constructor.
*/
public TestSubSystemAdapter() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#canAdd(java.lang.Object)
*/
public boolean canAdd(Object element) {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#doAdd(org.eclipse.swt.widgets.Shell, java.lang.Object, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean doAdd(Shell shell, Object container, Object element, IProgressMonitor monitor) {
boolean added = false;
if (container instanceof ITestSubSystemNodeContainer && element instanceof ITestSubSystemNode) {
added = ((ITestSubSystemNodeContainer)container).addChildNode(((ITestSubSystemNode)element));
if (added) {
SystemView view = SystemPerspectiveHelpers.findRSEView();
if (view != null) {
view.expandSelected();
view.refresh(container, true);
}
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#showAdd(java.lang.Object)
*/
public boolean showAdd(Object element) {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
*/
public String getAbsoluteParentName(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(org.eclipse.swt.widgets.Shell, java.lang.Object)
*/
public Object getRemoteParent(Shell shell, Object element) throws Exception {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
*/
public String[] getRemoteParentNamesInUse(Shell shell, Object element) throws Exception {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
*/
public String getRemoteSubType(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
*/
public String getRemoteType(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
*/
public String getRemoteTypeCategory(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object)
*/
public String getSubSystemConfigurationId(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
*/
public boolean refreshRemoteObject(Object oldElement, Object newElement) {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object)
*/
public boolean supportsUserDefinedActions(Object object) {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#addActions(org.eclipse.rse.ui.SystemMenuManager, org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.swt.widgets.Shell, java.lang.String)
*/
public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell parent, String menuGroup) {
if (selection.size() == 1 && isTestSubSystemNodeContainer(selection.getFirstElement())) {
if (canAdd(selection.getFirstElement())) {
menu.add(menuGroup, new TestSubSystemAddAction("Add branch", true, getShell())); //$NON-NLS-1$
menu.add(menuGroup, new TestSubSystemAddAction("Add leaf", false, getShell())); //$NON-NLS-1$
}
}
}
/*
* Returns true if the element is a node container.
*/
private boolean isTestSubSystemNodeContainer(Object element) {
return element instanceof ITestSubSystemNodeContainer;
}
}

View file

@ -0,0 +1,59 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemConfiguration;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.ui.views.properties.IPropertySource;
/**
* Adapter factory for subsystem adapters.
*/
public class TestSubSystemAdapterFactory extends AbstractSystemRemoteAdapterFactory
implements IAdapterFactory {
private TestSubSystemAdapter subSystemAdapter = new TestSubSystemAdapter();
private TestSubSystemNodeAdapter subSystemNodeAdapter = new TestSubSystemNodeAdapter();
private TestSubSystemConfigurationAdapter SubSystemConfigAdapter = new TestSubSystemConfigurationAdapter();
/**
* Constructor.
*/
public TestSubSystemAdapterFactory() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
public Object getAdapter(Object adaptableObject, Class adapterType) {
Object adapter = null;
if (adaptableObject instanceof ITestSubSystem) {
adapter = subSystemAdapter;
}
if (adaptableObject instanceof ITestSubSystemNode) {
adapter = subSystemNodeAdapter;
}
if (adaptableObject instanceof ITestSubSystemConfiguration) {
adapter = SubSystemConfigAdapter;
}
if (adapter != null && adapter instanceof ISystemViewElementAdapter && adapterType == IPropertySource.class) {
((ISystemViewElementAdapter)adapter).setPropertySourceInput(adaptableObject);
}
return adapter;
}
}

View file

@ -0,0 +1,83 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import java.util.Vector;
import org.eclipse.rse.core.filters.ISystemFilter;
import org.eclipse.rse.core.filters.ISystemFilterPool;
import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemConfiguration;
public class TestSubSystemConfiguration extends SubSystemConfiguration implements ITestSubSystemConfiguration {
/**
* Constructor.
*/
public TestSubSystemConfiguration() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#createSubSystemInternal(org.eclipse.rse.core.model.IHost)
*/
public ISubSystem createSubSystemInternal(IHost conn) {
return new TestSubSystem(conn, getConnectorService(conn));
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#getConnectorService(org.eclipse.rse.core.model.IHost)
*/
public IConnectorService getConnectorService(IHost host) {
return TestSubSystemConnectorServiceManager.getInstance().getConnectorService(host, ITestSubSystem.class);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#createDefaultFilterPool(org.eclipse.rse.core.filters.ISystemFilterPoolManager)
*/
protected ISystemFilterPool createDefaultFilterPool(ISystemFilterPoolManager mgr) {
ISystemFilterPool defaultPool = null;
try {
defaultPool = mgr.createSystemFilterPool(getDefaultFilterPoolName(mgr.getName(), getId()), true); // true=>is deletable by user
Vector strings = new Vector();
strings.add(".*"); //$NON-NLS-1$
ISystemFilter filter = mgr.createSystemFilter(defaultPool, "All", strings); //$NON-NLS-1$
filter.setType("all"); //$NON-NLS-1$
}
catch (Exception exc) {
// ignore exception
}
return defaultPool;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#getTranslatedFilterTypeProperty(org.eclipse.rse.core.filters.ISystemFilter)
*/
public String getTranslatedFilterTypeProperty(ISystemFilter selectedFilter) {
String type = selectedFilter.getType();
if (type.equals("all")) //$NON-NLS-1$
return "testSubSystemFilter.all"; //$NON-NLS-1$
return "testSubSystemFilter"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchProperties(org.eclipse.rse.core.model.IHost)
*/
public boolean supportsServerLaunchProperties(IHost host) {
return false;
}
}

View file

@ -0,0 +1,25 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter;
/**
* Adapter for subsytsem configuration.
*/
public class TestSubSystemConfigurationAdapter extends SubSystemConfigurationAdapter {
/**
* Constructor.
*/
public TestSubSystemConfigurationAdapter() {
super();
}
}

View file

@ -0,0 +1,88 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.AbstractConnectorService;
public class TestSubSystemConnectorService extends AbstractConnectorService {
private boolean connected = false;
/**
* Constructor.
*
* @param host The RSE connection object.
*/
public TestSubSystemConnectorService(IHost host) {
super("TestSubSystemConnectorService", //$NON-NLS-1$
"The connector Service for the TestSubSystem", //$NON-NLS-1$
host, 0);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.IConnectorService#isConnected()
*/
public boolean isConnected() {
return connected;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#internalConnect(org.eclipse.core.runtime.IProgressMonitor)
*/
protected void internalConnect(IProgressMonitor monitor) throws Exception {
super.internalConnect(monitor);
connected = true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#internalDisconnect(org.eclipse.core.runtime.IProgressMonitor)
*/
public void internalDisconnect(IProgressMonitor monitor) throws Exception {
super.internalDisconnect(monitor);
connected = false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsRemoteServerLaunching()
*/
public boolean supportsRemoteServerLaunching() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#hasRemoteServerLauncherProperties()
*/
public boolean hasRemoteServerLauncherProperties() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsServerLaunchProperties()
*/
public boolean supportsServerLaunchProperties() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword()
*/
public boolean supportsPassword() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId()
*/
public boolean supportsUserId() {
return false;
}
}

View file

@ -0,0 +1,63 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
/**
* Test subsystem connector service manager. Singleton!
*/
public class TestSubSystemConnectorServiceManager extends AbstractConnectorServiceManager {
private static TestSubSystemConnectorServiceManager inst;
/**
* Private Constructor.
*/
private TestSubSystemConnectorServiceManager() {
super();
}
/**
* Returns the test subsystem connector service manager instance.
*
* @return The singleton instance.
*/
public static TestSubSystemConnectorServiceManager getInstance() {
if (inst == null)
inst = new TestSubSystemConnectorServiceManager();
return inst;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager#createConnectorService(org.eclipse.rse.core.model.IHost)
*/
public IConnectorService createConnectorService(IHost host) {
return new TestSubSystemConnectorService(host);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager#sharesSystem(org.eclipse.rse.core.subsystems.ISubSystem)
*/
public boolean sharesSystem(ISubSystem otherSubSystem) {
return (otherSubSystem instanceof ITestSubSystem);
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager#getSubSystemCommonInterface(org.eclipse.rse.core.subsystems.ISubSystem)
*/
public Class getSubSystemCommonInterface(ISubSystem subsystem) {
return ITestSubSystem.class;
}
}

View file

@ -0,0 +1,320 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal.testsubsystem;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.SystemPerspectiveHelpers;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.testsubsystem.TestSubSystemAddAction;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemAddTarget;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNodeContainer;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemView;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
/**
* Adapter for all nodes and container nodes.
*/
public class TestSubSystemNodeAdapter extends AbstractSystemViewAdapter
implements ISystemRemoteElementAdapter, ITestSubSystemAddTarget {
/**
* Constructor.
*/
public TestSubSystemNodeAdapter() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#addActions(org.eclipse.rse.ui.SystemMenuManager, org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.swt.widgets.Shell, java.lang.String)
*/
public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell parent, String menuGroup) {
if (selection.size() == 1 && isTestSubSystemNodeContainer(selection.getFirstElement())) {
if (canAdd(selection.getFirstElement())) {
menu.add(menuGroup, new TestSubSystemAddAction("Add branch", true, getShell())); //$NON-NLS-1$
menu.add(menuGroup, new TestSubSystemAddAction("Add leaf", false, getShell())); //$NON-NLS-1$
}
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getImageDescriptor(java.lang.Object)
*/
public ImageDescriptor getImageDescriptor(Object element) {
if (isTestSubSystemNodeContainer(element)) {
return RSETestsPlugin.getDefault().getImageDescriptor("ICON_ID_BRANCH"); //$NON-NLS-1$
}
else if (isTestSubSystemNode(element)) {
return RSETestsPlugin.getDefault().getImageDescriptor("ICON_ID_LEAF"); //$NON-NLS-1$
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getText(java.lang.Object)
*/
public String getText(Object element) {
if (isTestSubSystemNode(element)) {
return ((ITestSubSystemNode)element).getName();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getAbsoluteName(java.lang.Object)
*/
public String getAbsoluteName(Object element) {
if (isTestSubSystemNode(element)) {
ITestSubSystemNode node = (ITestSubSystemNode) element;
String absName = node.getName();
node = node.getParent();
while (node != null) {
absName = node.getName() + "/" + absName; //$NON-NLS-1$
node = node.getParent();
}
return absName;
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object)
*/
public String getType(Object element) {
if (isTestSubSystemNodeContainer(element))
return "testSubSystemContainerNode"; //$NON-NLS-1$
else if (isTestSubSystemNode(element))
return "testSubSystemNode"; //$NON-NLS-1$
else
return "unknown"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getParent(java.lang.Object)
*/
public Object getParent(Object element) {
if (isTestSubSystemNode(element))
return ((ITestSubSystemNode)element).getParent();
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(java.lang.Object)
*/
public boolean hasChildren(Object element) {
if (isTestSubSystemNodeContainer(element))
return ((ITestSubSystemNodeContainer)element).hasChildNodes();
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object element) {
if (isTestSubSystemNodeContainer(element))
return ((ITestSubSystemNodeContainer)element).getChildNodes();
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyDescriptors()
*/
protected IPropertyDescriptor[] internalGetPropertyDescriptors() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyValue(java.lang.Object)
*/
protected Object internalGetPropertyValue(Object key) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
*/
public String getAbsoluteParentName(Object element) {
if (isTestSubSystemNode(element))
if (((ITestSubSystemNode)element).getParent() != null)
return ((ITestSubSystemNode)element).getParent().getName();
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object)
*/
public String getSubSystemConfigurationId(Object element) {
return "testSubSystemConfigurationId"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
*/
public String getRemoteTypeCategory(Object element) {
return "testCategory"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
*/
public String getRemoteType(Object element) {
return "testType"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
*/
public String getRemoteSubType(Object element) {
return "testSubType"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
*/
public boolean refreshRemoteObject(Object oldElement, Object newElement) {
ITestSubSystemNode oldNode = (ITestSubSystemNode) oldElement;
ITestSubSystemNode newNode = (ITestSubSystemNode) newElement;
newNode.setName(oldNode.getName());
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(org.eclipse.swt.widgets.Shell, java.lang.Object)
*/
public Object getRemoteParent(Shell shell, Object element) throws Exception {
if (isTestSubSystemNode(element))
return ((ITestSubSystemNode)element).getParent();
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
*/
public String[] getRemoteParentNamesInUse(Shell shell, Object element) throws Exception {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object)
*/
public boolean supportsUserDefinedActions(Object object) {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#canDelete(java.lang.Object)
*/
public boolean canDelete(Object element) {
return isTestSubSystemNode(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showDelete(java.lang.Object)
*/
public boolean showDelete(Object element) {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#doDelete(org.eclipse.swt.widgets.Shell, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception {
if (isTestSubSystemNode(element)) {
ITestSubSystemNodeContainer parent = (ITestSubSystemNodeContainer)((ITestSubSystemNode)element).getParent();
if (parent == null) {
parent = (ITestSubSystemNodeContainer)((ITestSubSystemNode)element).getSubSystem();
}
if (parent != null && isTestSubSystemNodeContainer(parent))
return parent.removeChildNode(((ITestSubSystemNode)element));
}
return false;
}
/*
* Returns true if the element is a node.
*/
private boolean isTestSubSystemNode(Object element) {
return element instanceof ITestSubSystemNode;
}
/*
* Returns true if the element is a node container.
*/
private boolean isTestSubSystemNodeContainer(Object element) {
return element instanceof ITestSubSystemNodeContainer;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#canAdd(java.lang.Object)
*/
public boolean canAdd(Object element) {
return isTestSubSystemNodeContainer(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#doAdd(org.eclipse.swt.widgets.Shell, java.lang.Object, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean doAdd(Shell shell, Object container, Object element, IProgressMonitor monitor) {
boolean added = false;
if (isTestSubSystemNodeContainer(container) && isTestSubSystemNode(element)) {
added = ((ITestSubSystemNodeContainer)container).addChildNode(((ITestSubSystemNode)element));
if (added) {
SystemView view = SystemPerspectiveHelpers.findRSEView();
if (view != null) {
view.expandSelected();
view.refresh(container);
}
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.internal.testsubsystem.actions.ITestSubSystemAddTarget#showAdd(java.lang.Object)
*/
public boolean showAdd(Object element) {
return isTestSubSystemNodeContainer(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#canRename(java.lang.Object)
*/
public boolean canRename(Object element) {
return isTestSubSystemNode(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#doRename(org.eclipse.swt.widgets.Shell, java.lang.Object, java.lang.String)
*/
public boolean doRename(Shell shell, Object element, String name) throws Exception {
if (name != null && isTestSubSystemNode(element)) {
String oldName = ((ITestSubSystemNode)element).getName();
if (oldName == null || !oldName.equals(name)) {
((ITestSubSystemNode)element).setName(name);
return true;
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showRename(java.lang.Object)
*/
public boolean showRename(Object element) {
return isTestSubSystemNode(element);
}
}

View file

@ -0,0 +1,80 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemAddTarget;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNodeContainer;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.swt.widgets.Shell;
/**
* Add action for container nodes.
* This action can add branches or leafes.
*/
public class TestSubSystemAddAction extends SystemBaseAction {
private boolean fAddContainer = false;
/**
* Constructor.
* @param text The text of this action shwon in context menues.
* @param addContainer True if a container node should be added,
* False if a simple node should be added.
* @param shell The current shell.
*/
public TestSubSystemAddAction(String text, boolean addContainer, Shell shell) {
super(text, shell);
fAddContainer = addContainer;
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#getImageDescriptor()
*/
public ImageDescriptor getImageDescriptor() {
return RSETestsPlugin.getDefault().getImageDescriptor(fAddContainer ? "ICON_ID_BRANCH" : "ICON_ID_LEAF"); //$NON-NLS-1$//$NON-NLS-2$
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.actions.SystemBaseAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection) {
return selection.size() == 1 && checkObjectType(selection.getFirstElement());
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.actions.SystemBaseAction#checkObjectType(java.lang.Object)
*/
public boolean checkObjectType(Object selectedObject) {
return selectedObject instanceof ITestSubSystemNodeContainer;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.actions.SystemBaseAction#run()
*/
public void run() {
IStructuredSelection selection = getSelection();
Object object = selection.getFirstElement();
ISystemRemoteElementAdapter adapter = getRemoteAdapter(object);
if (adapter != null && adapter instanceof ITestSubSystemAddTarget && object instanceof ITestSubSystemNodeContainer) {
ITestSubSystemAddTarget addTarget = (ITestSubSystemAddTarget)adapter;
ITestSubSystemNodeContainer container = (ITestSubSystemNodeContainer)object;
String name = ((object instanceof ITestSubSystem) ? "" : adapter.getName(container) + ":") + container.getChildNodeCount(); //$NON-NLS-1$ //$NON-NLS-2$
ITestSubSystemNode node = fAddContainer ? new TestSubSystemContainerNode(name) : new TestSubSystemNode(name + ";"); //$NON-NLS-1$
addTarget.doAdd(getShell(), container, node, null);
}
}
}

View file

@ -0,0 +1,98 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem;
import java.util.ArrayList;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNodeContainer;
/**
* A simple container node (branch).
*/
public class TestSubSystemContainerNode extends TestSubSystemNode
implements ITestSubSystemNode, ITestSubSystemNodeContainer {
private ArrayList fChildren = new ArrayList();
/**
* Constructor.
* @param name The name of the conatiner node shown in the tree.
*/
public TestSubSystemContainerNode(String name) {
super(name);
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#addChildNode(org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode)
*/
public boolean addChildNode(ITestSubSystemNode node) {
if (node != null && !fChildren.contains(node)) {
node.setSubSystem(getSubSystem());
node.setParent(this);
fChildren.add(node);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#removeChildNode(org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode)
*/
public boolean removeChildNode(ITestSubSystemNode node) {
if (node != null && fChildren.contains(node)) {
if (node instanceof ITestSubSystemNodeContainer) {
((ITestSubSystemNodeContainer)node).removeAllChildNodes();
}
fChildren.remove(node);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#removeAllChildNodes()
*/
public boolean removeAllChildNodes() {
if (!fChildren.isEmpty()) {
ITestSubSystemNode[] childs = getChildNodes();
for (int i = 0; i < childs.length; i++) {
if (childs[i] instanceof ITestSubSystemNodeContainer) {
((ITestSubSystemNodeContainer)childs[i]).removeAllChildNodes();
}
}
fChildren.clear();
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#hasChildNodes()
*/
public boolean hasChildNodes() {
return !fChildren.isEmpty();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#getChildNodeCount()
*/
public int getChildNodeCount() {
return fChildren.size();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNodeContainer#getChildNodes()
*/
public ITestSubSystemNode[] getChildNodes() {
return (ITestSubSystemNode[])fChildren.toArray(new ITestSubSystemNode[fChildren.size()]);
}
}

View file

@ -0,0 +1,72 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem;
import org.eclipse.rse.core.subsystems.AbstractResource;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystemNode;
/**
* A simple node (leaf).
*/
public class TestSubSystemNode extends AbstractResource
implements ITestSubSystemNode {
private String fName;
private ITestSubSystemNode fParent;
/**
* Constructor.
* @param name The name for this node shown in the tree.
*/
public TestSubSystemNode(String name) {
super();
fName = name;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode#getName()
*/
public String getName() {
return fName;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode#setName(java.lang.String)
*/
public void setName(String name) {
fName = name;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode#setParent(org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode)
*/
public void setParent(ITestSubSystemNode parent) {
fParent = parent;
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.testsubsystem.ITestSubSystemNode#getParent()
*/
public ITestSubSystemNode getParent() {
return fParent;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractResource#getSubSystem()
*/
public ISubSystem getSubSystem() {
ISubSystem subSystem = super.getSubSystem();
if (subSystem == null && getParent() != null) {
subSystem = getParent().getSubSystem();
}
return subSystem;
}
}

View file

@ -0,0 +1,19 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem.interfaces;
import org.eclipse.rse.core.subsystems.ISubSystem;
/**
* Interface for the test subsystem.
*/
public interface ITestSubSystem extends ISubSystem, ITestSubSystemNodeContainer {
// only for internal use
}

View file

@ -0,0 +1,43 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem.interfaces;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.widgets.Shell;
/**
* Interface for UI parts that support add actions.
*/
public interface ITestSubSystemAddTarget {
/**
* Returns true if add action should be shown for the element.
* @param element Element for which add should be shown.
* @return True if add should be shown.
*/
public boolean showAdd(Object element);
/**
* Returns true if add action should be enabled for the element.
* @param element Element for which add should be enabled.
* @return True if add should be enabled.
*/
public boolean canAdd(Object element);
/**
* Add action of the element.
* @param shell The current shell.
* @param container The container to wich the element should be added.
* @param element The element to add to the container.
* @param monitor The progressmonitor if needed during the add operation.
* @return True, if the element was added to the container.
*/
public boolean doAdd(Shell shell, Object container, Object element, IProgressMonitor monitor);
}

View file

@ -0,0 +1,17 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem.interfaces;
/**
* Interface for the test subsystem configuration.
*/
public interface ITestSubSystemConfiguration {
// only for internal use
}

View file

@ -0,0 +1,56 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem.interfaces;
import org.eclipse.rse.core.subsystems.ISubSystem;
/**
* Interface for all test subsystem nodes.
*/
public interface ITestSubSystemNode {
/**
* Returns the name of this node shown in the tree.
* @return The name of the node.
*/
public String getName();
/**
* Set the name for this node.
* @param name The Name of this node.
*/
public void setName(String name);
/**
* Set the subsystem this node belongs to.
* This value should be set automatically when adding this node to a subsystem or other node.
* @param subSystem The subsystem.
*/
public void setSubSystem(ISubSystem subSystem);
/**
* Returns the subsystem this node belongs to.
* @return The subsystem.
*/
public ISubSystem getSubSystem();
/**
* Set the node container this node belongs to.
* This value should be set automatically when adding this node to a node container.
* @param parent The parent node container.
*/
public void setParent(ITestSubSystemNode parent);
/**
* Returns the parent node this node belongs to.
* @return The parent node.
*/
public ITestSubSystemNode getParent();
}

View file

@ -0,0 +1,56 @@
/* *******************************************************************************
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tobias Schwarz (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.testsubsystem.interfaces;
/**
* Interface for node container.
*/
public interface ITestSubSystemNodeContainer {
/**
* Adds the node to the list of childs if not already in the list.
* @param node The node that should be added to the list of childs.
* @return True if the node was added.
*/
public boolean addChildNode(ITestSubSystemNode node);
/**
* Removes the node from the list of childs.
* If the node is a node container, all children are removed recursively.
* @param node The node that should be removed from the list of childs.
* @return True if the node exists as a child and was removed.
*/
public boolean removeChildNode(ITestSubSystemNode node);
/**
* Removes all children of this container.
* If a hild node is a node container, all children are removed recursively.
* @return True if children were removed.
*/
public boolean removeAllChildNodes();
/**
* Returns true if this container has children.
* @return True if this node has children.
*/
public boolean hasChildNodes();
/**
* Returns the number of children.
* @return The number of children.
*/
public int getChildNodeCount();
/**
* Returns an array of all children.
* @return Array of children.
*/
public ITestSubSystemNode[] getChildNodes();
}