diff options
Diffstat (limited to 'rse/examples/org.eclipse.rse.examples.tutorial/src')
17 files changed, 0 insertions, 2273 deletions
diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/RSESamplesPlugin.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/RSESamplesPlugin.java deleted file mode 100644 index 4e523495a..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/RSESamplesPlugin.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessageFile; -import org.osgi.framework.BundleContext; - -import samples.subsystems.DeveloperSubSystemConfigurationAdapterFactory; - -/** - * The activator class controls the plug-in life cycle - */ -public class RSESamplesPlugin extends SystemBasePlugin { - //The shared instance. - private static RSESamplesPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - private static SystemMessageFile messageFile = null; - - /** - * The constructor. - */ - public RSESamplesPlugin() { - super(); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.rse.core.SystemBasePlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - messageFile = getMessageFile("rseSamplesMessages.xml"); //$NON-NLS-1$ - - IAdapterManager manager = Platform.getAdapterManager(); - samples.model.DeveloperAdapterFactory factory = new samples.model.DeveloperAdapterFactory(); - manager.registerAdapters(factory, samples.model.TeamResource.class); - manager.registerAdapters(factory, samples.model.DeveloperResource.class); - - DeveloperSubSystemConfigurationAdapterFactory sscaf = new DeveloperSubSystemConfigurationAdapterFactory(); - sscaf.registerWithManager(manager); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.rse.core.SystemBasePlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - resourceBundle = null; - } - - /** - * Returns the shared instance. - * @return the shared instance - */ - public static RSESamplesPlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - * @return the singleton Workspace from Eclipse Resources plugin - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - * @see java.util.ResourceBundle#getString(String) - * - * @param key the key for the desired string - * @return the string for the given key - */ - public static String getResourceString(String key) { - ResourceBundle bundle= RSESamplesPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Return the plugin's Resource bundle. - * @return the Resource bundle - */ - public ResourceBundle getResourceBundle() { - try { - if (resourceBundle == null) - resourceBundle = ResourceBundle.getBundle("samples.rseSamplesResources"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - resourceBundle = null; - } - return resourceBundle; - } - - /** - * @see AbstractUIPlugin#initializeDefaultPreferences - */ - //protected void initializeDefaultPreferences(IPreferenceStore store) - //{ - // super.initializeDefaultPreferences(store); - // //RSESamplesPreferencePage.initDefaults(store); - //} - - /** - * Initialize the image registry by declaring all of the required graphics. - */ - protected void initializeImageRegistry() - { - String path = getIconPath(); - putImageInRegistry("ICON_ID_TEAM", path + "team.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - putImageInRegistry("ICON_ID_DEVELOPER", path + "developer.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - putImageInRegistry("ICON_ID_TEAMFILTER", path + "teamFilter.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - putImageInRegistry("ICON_ID_DEVELOPERFILTER", path + "developerFilter.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Load a message file for this plugin. - * @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder. - * @return a message file object containing the parsed contents of the message file, or null if not found. - */ - public SystemMessageFile getMessageFile(String messageFileName) - { - return loadMessageFile(getBundle(), messageFileName); - } - - /** - * Return our message file. - * - * @return the RSE message file - */ - public static SystemMessageFile getPluginMessageFile() - { - return messageFile; - } - - /** - * Retrieve a message from this plugin's message file, - * or <code>null</code> if the message cannot be found. - * @see SystemMessageFile#getMessage(String) - * - * @param msgId message id - * @return the message object referenced by the given id - */ - public static SystemMessage getPluginMessage(String msgId) - { - return getMessage(messageFile, msgId); - } -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperAdapterFactory.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperAdapterFactory.java deleted file mode 100644 index 8bfbb4a80..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperAdapterFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.model; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.ui.views.properties.IPropertySource; - -/** - * This factory maps requests for an adapter object from a given remote object. - */ -public class DeveloperAdapterFactory extends AbstractSystemRemoteAdapterFactory - implements IAdapterFactory -{ - private TeamResourceAdapter teamAdapter = new TeamResourceAdapter(); - private DeveloperResourceAdapter developerAdapter = new DeveloperResourceAdapter(); - - /** - * Constructor for DeveloperAdapterFactory. - */ - public DeveloperAdapterFactory() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - ISystemViewElementAdapter adapter = null; - if (adaptableObject instanceof TeamResource) - adapter = teamAdapter; - else if (adaptableObject instanceof DeveloperResource) - adapter = developerAdapter; - // these lines are very important! - if ((adapter != null) && (adapterType == IPropertySource.class)) - adapter.setPropertySourceInput(adaptableObject); - return adapter; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResource.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResource.java deleted file mode 100644 index 017fd46be..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResource.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.model; - -import org.eclipse.rse.core.subsystems.AbstractResource; -import org.eclipse.rse.core.subsystems.ISubSystem; - -/** - * This models a remote resource representing a developer defined on a particular system. - */ -public class DeveloperResource extends AbstractResource { - - private String name; - private String id; - private String deptNbr; - - /** - * Default constructor for DeveloperResource. - */ - public DeveloperResource() - { - super(); - } - - /** - * Constructor for DeveloperResource when given parent subsystem. - * @param parentSubSystem the parent subsystem - */ - public DeveloperResource(ISubSystem parentSubSystem) - { - super(parentSubSystem); - } - - /** - * Returns the name. - * @return String - */ - public String getName() - { - return name; - } - - /** - * Sets the name. - * @param name The name to set - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the id. - * @return String - */ - public String getId() - { - return id; - } - - /** - * Sets the id. - * @param id The id to set - */ - public void setId(String id) - { - this.id = id; - } - /** - * Returns the deptNbr. - * @return String - */ - public String getDeptNbr() - { - return deptNbr; - } - - /** - * Sets the deptNbr. - * @param deptNbr The deptNbr to set - */ - public void setDeptNbr(String deptNbr) - { - this.deptNbr = deptNbr; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResourceAdapter.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResourceAdapter.java deleted file mode 100644 index 40cf4c3dd..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/DeveloperResourceAdapter.java +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.model; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.SystemMenuManager; -import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import samples.RSESamplesPlugin; - -/** - * This is the adapter which enables us to work with our remote developer resources. - */ -public class DeveloperResourceAdapter extends AbstractSystemViewAdapter - implements ISystemRemoteElementAdapter -{ - - /** - * Constructor - */ - public DeveloperResourceAdapter() { - 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) - { - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(Object) - */ - public ImageDescriptor getImageDescriptor(Object object) - { - return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_DEVELOPER"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getText(java.lang.Object) - */ - public String getText(Object element) - { - return ((DeveloperResource)element).getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getAbsoluteName(java.lang.Object) - */ - public String getAbsoluteName(Object object) - { - DeveloperResource devr = (DeveloperResource)object; - return "Devr_" + devr.getId(); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object) - */ - public String getType(Object element) - { - return RSESamplesPlugin.getResourceString("property.devr_resource.type"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(Object) - */ - public Object getParent(Object o) - { - return null; // not really used, which is good because it is ambiguous - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) - { - return false; - } - - /** - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(Object) - */ - public Object[] getChildren(Object o) - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyDescriptors() - */ - protected IPropertyDescriptor[] internalGetPropertyDescriptors() - { - // the following array should be made static to it isn't created every time - PropertyDescriptor[] ourPDs = new PropertyDescriptor[2]; - ourPDs[0] = new PropertyDescriptor("devr_id", //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("property.devr_id.name")); //$NON-NLS-1$ - ourPDs[0].setDescription( - RSESamplesPlugin.getResourceString("property.devr_id.desc")); //$NON-NLS-1$ - ourPDs[1] = new PropertyDescriptor("devr_dept", //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("property.devr_dept.name")); //$NON-NLS-1$ - ourPDs[1].setDescription( - RSESamplesPlugin.getResourceString("property.devr_dept.desc")); //$NON-NLS-1$ - return ourPDs; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#internalGetPropertyValue(java.lang.Object) - */ - protected Object internalGetPropertyValue(Object key) - { - // propertySourceInput holds the currently selected object - DeveloperResource devr = (DeveloperResource)propertySourceInput; - if (key.equals("devr_id")) //$NON-NLS-1$ - return devr.getId(); - else if (key.equals("devr_dept")) //$NON-NLS-1$ - return devr.getDeptNbr(); - return null; - } - // -------------------------------------- - // ISystemRemoteElementAdapter methods... - // -------------------------------------- - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object) - */ - public String getAbsoluteParentName(Object element) - { - return "root"; // not really applicable as we have no unique hierarchy //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object) - */ - public String getSubSystemConfigurationId(Object element) - { - return "samples.subsystems.factory"; // as declared in extension in plugin.xml //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object) - */ - public String getRemoteTypeCategory(Object element) - { - return "developers"; // Course grained. Same for all our remote resources. //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object) - */ - public String getRemoteType(Object element) - { - return "developer"; // Fine grained. Unique to this resource type. //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object) - */ - public String getRemoteSubType(Object element) - { - return null; // Very fine grained. We don't use it. - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object) - */ - public boolean refreshRemoteObject(Object oldElement, Object newElement) - { - DeveloperResource oldDevr= (DeveloperResource)oldElement; - DeveloperResource newDevr = (DeveloperResource)newElement; - newDevr.setName(oldDevr.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 - { - return null; // maybe this would be a Department obj, if we fully fleshed out our model - } - - /* (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 - { - // developers names do not have to be unique! So we don't need to implement this! - return null; - - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object) - */ - public boolean supportsUserDefinedActions(Object object) { - return false; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResource.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResource.java deleted file mode 100644 index 25856ec7d..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResource.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.model; - -import org.eclipse.rse.core.subsystems.AbstractResource; -import org.eclipse.rse.core.subsystems.ISubSystem; - -/** - * This models a remote resource representing a team defined on a particular system. - */ -public class TeamResource extends AbstractResource { - - private String name; - private DeveloperResource[] developers; - - /** - * Default constructor - */ - public TeamResource() - { - super(); - } - /** - * Constructor for TeamResource when given a parent subsystem. - * @param parentSubSystem the parent subsystem - */ - public TeamResource(ISubSystem parentSubSystem) - { - super(parentSubSystem); - } - - /** - * Returns the name. - * @return String - */ - public String getName() - { - return name; - } - - /** - * Sets the name. - * @param name The name to set - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the developers. - * @return DeveloperResource[] - */ - public DeveloperResource[] getDevelopers() - { - return developers; - } - - /** - * Sets the developers. - * @param developers The developers to set - */ - public void setDevelopers(DeveloperResource[] developers) - { - this.developers = developers; - } - - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResourceAdapter.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResourceAdapter.java deleted file mode 100644 index ba88b090d..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/model/TeamResourceAdapter.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.model; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.SystemMenuManager; -import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.views.properties.IPropertyDescriptor; - -import samples.RSESamplesPlugin; -import samples.subsystems.DeveloperSubSystem; - -/** - * This is the adapter which enables us to work with our remote team resources. - */ -public class TeamResourceAdapter extends AbstractSystemViewAdapter implements - ISystemRemoteElementAdapter { - - /** - * Constructor. - */ - public TeamResourceAdapter() { - 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) - { - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object element) - { - return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_TEAM"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getText(java.lang.Object) - */ - public String getText(Object element) - { - return ((TeamResource)element).getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getAbsoluteName(java.lang.Object) - */ - public String getAbsoluteName(Object object) - { - TeamResource team = (TeamResource)object; - return "Team_"+team.getName(); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getType(java.lang.Object) - */ - public String getType(Object element) - { - return RSESamplesPlugin.getResourceString("property.team_resource.type"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object element) - { - return null; // not really used, which is good because it is ambiguous - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) - { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object element) - { - return ((TeamResource)element).getDevelopers(); - } - - /* (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; - } - - /** - * Intercept of parent method to indicate these objects - * can be renamed using the RSE-supplied rename action. - * - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#canRename(java.lang.Object) - */ - public boolean canRename(Object element) - { - return true; - } - - /** - * Intercept of parent method to actually do the rename. RSE supplies the rename GUI, but - * defers the action work of renaming to this adapter method. - * - * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#doRename(Shell, Object, String) - */ - public boolean doRename(Shell shell, Object element, String newName) - { - ((TeamResource)element).setName(newName); - return true; - } - - // -------------------------------------- - // ISystemRemoteElementAdapter methods... - // -------------------------------------- - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object) - */ - public String getAbsoluteParentName(Object element) - { - return "root"; // not really applicable as we have no unique hierarchy //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object) - */ - public String getSubSystemConfigurationId(Object element) - { - return "samples.subsystems.factory"; // as declared in extension in plugin.xml //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object) - */ - public String getRemoteTypeCategory(Object element) - { - return "developers"; // Course grained. Same for all our remote resources. //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object) - */ - public String getRemoteType(Object element) - { - return "team"; // Fine grained. Unique to this resource type. //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object) - */ - public String getRemoteSubType(Object element) - { - return null; // Very fine grained. We don't use it. - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object) - */ - public boolean refreshRemoteObject(Object oldElement, Object newElement) - { - TeamResource oldTeam = (TeamResource)oldElement; - TeamResource newTeam = (TeamResource)newElement; - newTeam.setName(oldTeam.getName()); - return false; // If developer objects held references to their team names, we'd have to return true - } - - /* (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; // maybe this would be a Project or Roster object, or leave as null if this is the root - } - - /* (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 - { - DeveloperSubSystem ourSS = (DeveloperSubSystem)getSubSystem(element); - TeamResource[] allTeams = ourSS.getAllTeams(); - String[] allNames = new String[allTeams.length]; - for (int idx=0; idx<allTeams.length; idx++) - allNames[idx] = allTeams[idx].getName(); - return allNames; // Return list of all team names - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object) - */ - public boolean supportsUserDefinedActions(Object object) { - return false; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/rseSamplesResources.properties b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/rseSamplesResources.properties deleted file mode 100644 index dfc96663b..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/rseSamplesResources.properties +++ /dev/null @@ -1,56 +0,0 @@ -################################################################################ -# Copyright (c) 2006 IBM Corporation. All rights reserved. -# This program and the accompanying materials are made available under the terms -# of the Eclipse Public License v1.0 which accompanies this distribution, and is -# available at http://www.eclipse.org/legal/epl-v10.html -# -# Initial Contributors: -# The following IBM employees contributed to the Remote System Explorer -# component that contains this file: David McKnight, Kushal Munir, -# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, -# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. -# -# Contributors: -# Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. -################################################################################ - -# NLS_MESSAGEFORMAT_VAR -# NLS_ENCODING=UTF-8 - -# Tutorial #2: Creating a Remote Resource Property Page -pp.size.label=Size -pp.size.tooltip=Cumulative size, in bytes -pp.files.label=Files -pp.files.tooltip=Cumulative number of files -pp.folders.label=Folders -pp.folders.tooltip=Cumulative number of folders -pp.stopButton.label=Stop -pp.stopButton.tooltip=Cancel the thread - -# Tutorial #3: Creating a Subsystem Configuration -connectorservice.devr.name=DeveloperConnectorService -connectorservice.devr.desc=Manages connections to faked remote developer resources. - -property.devr_resource.type=Developer resource -property.devr_id.name=Id -property.devr_id.desc=ID number -property.devr_dept.name=Department -property.devr_dept.desc=Department number -property.team_resource.type=Team resource -filter.default.name=All Teams - -# Tutorial #3a: Adding a Custom Filter -property.type.teamfilter=Team filter -property.type.devrfilter=Developer filter - -filter.team.dlgtitle=Change Team Filter -filter.team.pagetitle=Team Filter -filter.team.pagetext=Create a new filter to list teams - -filter.devr.dlgtitle=Change Developer Filter -filter.devr.pagetitle=Developer Filter -filter.devr.pagetext=Create a new filter to list developers -filter.devr.teamprompt.label=Parent team -filter.devr.teamprompt.tooltip=Specify the team within which to list developers -filter.devr.devrprompt.label=Developers -filter.devr.devrprompt.tooltip=Specify a simple or generic developer name pattern diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java deleted file mode 100644 index 14b1b640a..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.subsystems.AbstractConnectorService; - -import samples.RSESamplesPlugin; - -/** - * Our system class that manages connecting to, and disconnecting from, - * our remote server-side code. - */ -public class DeveloperConnectorService extends AbstractConnectorService { - - private boolean connected = false; - - /** - * Constructor for DeveloperConnectorService. - * @param host - */ - public DeveloperConnectorService(IHost host) - { - super( - RSESamplesPlugin.getResourceString("connectorservice.devr.name"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("connectorservice.devr.desc"), //$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); - // pretend. Normally, we'd connect to our remote server-side code here - 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); - // pretend. Normally, we'd disconnect from our remote server-side code here - connected=false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsRemoteServerLaunching() - */ - public boolean supportsRemoteServerLaunching() - { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#hasRemoteServerLauncherProperties() - */ - public boolean hasRemoteServerLauncherProperties() - { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsServerLaunchProperties() - */ - public boolean supportsServerLaunchProperties() - { - return false; - } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - return false; - } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return false; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorServiceManager.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorServiceManager.java deleted file mode 100644 index 5c61f70ee..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorServiceManager.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -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; - -/** - * This class manages our DeveloperConnectorService objects, so that if we - * ever have multiple subsystem factories, different subsystems can share - * the same IConnectorService object if they share the communication layer. - */ -public class DeveloperConnectorServiceManager extends - AbstractConnectorServiceManager { - - private static DeveloperConnectorServiceManager inst; - - /** - * Constructor for DeveloperConnectorServiceManager. - */ - public DeveloperConnectorServiceManager() - { - super(); - } - - /** - * Return singleton instance - * @return the singleton instance - */ - public static DeveloperConnectorServiceManager getTheDeveloperConnectorServiceManager() - { - if (inst == null) - inst = new DeveloperConnectorServiceManager(); - return inst; - } - - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager#createConnectorService(org.eclipse.rse.model.IHost) - */ - public IConnectorService createConnectorService(IHost host) - { - return new DeveloperConnectorService(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 IDeveloperSubSystem); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager#getSubSystemCommonInterface(org.eclipse.rse.core.subsystems.ISubSystem) - */ - public Class getSubSystemCommonInterface(ISubSystem subsystem) - { - return IDeveloperSubSystem.class; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperFilterStringEditPane.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperFilterStringEditPane.java deleted file mode 100644 index 1a31ec23f..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperFilterStringEditPane.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************** - * 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 - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.filters.SystemFilterStringEditPane; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import samples.RSESamplesPlugin; - -/** - * Our specialized filter string edit pane for developer filters. - */ -public class DeveloperFilterStringEditPane extends SystemFilterStringEditPane { - - // gui widgets - private Text textTeam, textDevr; - - /** - * Constructor for DeveloperFilterStringEditPane. - * @param shell - parent window - */ - public DeveloperFilterStringEditPane(Shell shell) - { - super(shell); - } - - /** - * Override of parent method. - * This is where we populate the client area. - * @param parent - the composite that will be the parent of the returned client area composite - * @return Control - a client-area composite populated with widgets. - * - * @see org.eclipse.rse.ui.SystemWidgetHelpers - */ - public Control createContents(Composite parent) - { - // Inner composite - int nbrColumns = 1; - Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); - ((GridLayout)composite_prompts.getLayout()).marginWidth = 0; - - // CREATE TEAM-PARENT PROMPT - textTeam = SystemWidgetHelpers.createLabeledTextField( - composite_prompts, - null, - RSESamplesPlugin.getResourceString("filter.devr.teamprompt.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("filter.devr.teamprompt.tooltip") //$NON-NLS-1$ - ); - - // CREATE DEVELOPER PROMPT - textDevr = SystemWidgetHelpers.createLabeledTextField( - composite_prompts, - null, - RSESamplesPlugin.getResourceString("filter.devr.devrprompt.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("filter.devr.devrprompt.tooltip") //$NON-NLS-1$ - ); - - resetFields(); - doInitializeFields(); - - // add keystroke listeners... - textTeam.addModifyListener( - new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - validateStringInput(); - } - } - ); - textDevr.addModifyListener( - new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - validateStringInput(); - } - } - ); - return composite_prompts; - } - - /** - * Override of parent method. - * Return the control to recieve initial focus. - * - * @see org.eclipse.rse.ui.filters.SystemFilterStringEditPane#getInitialFocusControl() - */ - public Control getInitialFocusControl() - { - return textTeam; - } - - /** - * Override of parent method. - * Initialize the input fields based on the inputFilterString, and perhaps refProvider. - * This can be called before createContents, so test for null widgets first! - * Prior to this being called, resetFields is called to set the initial default state prior to input - */ - protected void doInitializeFields() - { - if (textTeam == null) - return; // do nothing - if (inputFilterString != null) - { - int idx = inputFilterString.indexOf('/'); - if (idx < 0) - textTeam.setText(inputFilterString); - else - { - textTeam.setText(inputFilterString.substring(0,idx)); - textDevr.setText(inputFilterString.substring(idx+1)); - } - } - } - /** - * Override of parent method. - * This is called in the change filter dialog when the user selects "new", or selects another string. - */ - protected void resetFields() - { - textTeam.setText(""); //$NON-NLS-1$ - textDevr.setText("*"); //$NON-NLS-1$ - } - /** - * Override of parent method. - * Called by parent to decide if information is complete enough to enable finish. - */ - protected boolean areFieldsComplete() - { - if ((textTeam == null) || (textDevr == null)) - return false; - else - return (textTeam.getText().trim().length()>0) && (textDevr.getText().trim().length()>0); - } - - /** - * Override of parent method. - * Get the filter string in its current form. - * Functional opposite of doInitializeFields, which tears apart the input string in update mode, - * to populate the GUIs. This method creates the filter string from the information in the GUI. - * - * @see org.eclipse.rse.ui.filters.SystemFilterStringEditPane#getFilterString() - */ - public String getFilterString() - { - if ((textTeam == null) || (textDevr == null)) - return inputFilterString; // return what we were given. - else - { - String teamName = textTeam.getText().trim(); - String devrName = textDevr.getText().trim(); - return teamName + "/" + devrName; //$NON-NLS-1$ - } - } - - /** - * Override of parent method. - * Does complete verification of input fields. If this - * method returns null, there are no errors and the dialog or wizard can close. - * - * @return error message if there is one, else null if ok - */ - public SystemMessage verify() - { - errorMessage = null; - - /* - Control controlInError = null; - errorMessage = validateTeamInput(); // todo: implement if we want to syntax check input - if (errorMessage != null) - controlInError = textTeam; - else - { - errorMessage = validateDevrInput(); // todo: implement to syntax check input - if (errorMessage != null) - controlInError = textDevr; - } - - if (errorMessage != null) - { - if (controlInError != null) - controlInError.setFocus(); - } - */ - return errorMessage; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystem.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystem.java deleted file mode 100644 index bc08b71c3..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystem.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -import java.util.Vector; - -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.services.clientserver.NamePatternMatcher; - -import samples.model.DeveloperResource; -import samples.model.TeamResource; - -/** - * This is our subsystem, which manages the remote connection and resources for - * a particular system connection object. - */ -public class DeveloperSubSystem extends SubSystem -{ - private TeamResource[] teams; // faked-out master list of teams - private Vector devVector = new Vector(); // faked-out master list of developers - private static int employeeId = 123456; // employee Id factory - - /** - * @param host - * @param connectorService - */ - public DeveloperSubSystem(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) { - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.ISubSystem#uninitializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) - */ - public void uninitializeSubSystem(IProgressMonitor monitor) { - } - - /** - * For drag and drop, and clipboard support of remote objects. - * - * Return the remote object within the subsystem that corresponds to - * the specified unique ID. Because each subsystem maintains it's own - * objects, it's the responsability of the subsystem to determine - * how an ID (or key) for a given object maps to the real object. - * By default this returns null. - * - * @param key internal unique ID for object - * @return Object identified by the given key - */ - public Object getObjectWithAbsoluteName(String key) - { - // Functional opposite of getAbsoluteName(Object) in our resource adapters - if (key.startsWith("Team_")) //$NON-NLS-1$ - { - String teamName = key.substring(5); - TeamResource[] allTeams = getAllTeams(); - for (int idx=0; idx<allTeams.length; idx++) - if (allTeams[idx].getName().equals(teamName)) - return allTeams[idx]; - } - else if (key.startsWith("Devr_")) //$NON-NLS-1$ - { - String devrId = key.substring(5); - DeveloperResource[] devrs = getAllDevelopers(); - for (int idx=0; idx<devrs.length; idx++) - if (devrs[idx].getId().equals(devrId)) - return devrs[idx]; - } - return null; - } - - /** - * When a filter is expanded, this is called for each filter string in the filter. - * Using the criteria of the filter string, it must return objects representing remote resources. - * For us, this will be an array of TeamResource objects. - * - * @param monitor - the progress monitor in effect while this operation performs - * @param filterString - one of the filter strings from the expanded filter. - */ - protected Object[] internalResolveFilterString(IProgressMonitor monitor, String filterString) - throws java.lang.reflect.InvocationTargetException, - java.lang.InterruptedException - { - int slashIdx = filterString.indexOf('/'); - if (slashIdx < 0) - { - // Fake it out for now and return dummy list. - // In reality, this would communicate with remote server-side code/data. - TeamResource[] allTeams = getAllTeams(); - - // Now, subset master list, based on filter string... - NamePatternMatcher subsetter = new NamePatternMatcher(filterString); - Vector v = new Vector(); - for (int idx=0; idx<allTeams.length; idx++) - { - if (subsetter.matches(allTeams[idx].getName())) - v.addElement(allTeams[idx]); - } - TeamResource[] teams = new TeamResource[v.size()]; - for (int idx=0; idx<v.size(); idx++) - teams[idx] = (TeamResource)v.elementAt(idx); - return teams; - } - else - { - String teamName = filterString.substring(0, slashIdx); - String devrName = filterString.substring(slashIdx+1); - TeamResource[] allTeams = getAllTeams(); - TeamResource match = null; - for (int idx=0; (match==null) && (idx<allTeams.length); idx++) - if (allTeams[idx].getName().equals(teamName)) - match = allTeams[idx]; - if (match != null) - { - DeveloperResource[] allDevrs = match.getDevelopers(); - // Now, subset master list, based on filter string... - NamePatternMatcher subsetter = new NamePatternMatcher(devrName); - Vector v = new Vector(); - for (int idx=0; idx<allDevrs.length; idx++) - { - if (subsetter.matches(allDevrs[idx].getName())) - v.addElement(allDevrs[idx]); - } - DeveloperResource[] devrs = new DeveloperResource[v.size()]; - for (int idx=0; idx<v.size(); idx++) - devrs[idx] = (DeveloperResource)v.elementAt(idx); - return devrs; - } - } - return null; - } - - /** - * When a remote resource is expanded, this is called to return the children of the resource, if - * the resource's adapter states the resource object is expandable. <br> - * For us, it is a Team resource that was expanded, and an array of Developer resources will be returned. - * - * @param monitor - the progress monitor in effect while this operation performs - * @param parent - the parent resource object being expanded - * @param filterString - typically defaults to "*". In future additional user-specific quick-filters may be supported. - */ - protected Object[] internalResolveFilterString(IProgressMonitor monitor, Object parent, String filterString) - throws java.lang.reflect.InvocationTargetException, - java.lang.InterruptedException - { - // typically we ignore the filter string as it is always "*" - // until support is added for "quick filters" the user can specify/select - // at the time they expand a remote resource. - - TeamResource team = (TeamResource)parent; - return team.getDevelopers(); - } - - // ------------------ - // Our own methods... - // ------------------ - /** - * Get the list of all teams. Normally this would involve a trip the server, but we - * fake it out and return a hard-coded local list. - * @return array of all teams - */ - public TeamResource[] getAllTeams() - { - if (teams == null) - teams = createTeams("Team ", 4); - return teams; - } - /** - * Get the list of all developers. Normally this would involve a trip the server, but we - * fake it out and return a hard-coded local list. - * @return array of all developers - */ - public DeveloperResource[] getAllDevelopers() - { - DeveloperResource[] allDevrs = new DeveloperResource[devVector.size()]; - for (int idx=0; idx<allDevrs.length; idx++) - allDevrs[idx] = (DeveloperResource)devVector.elementAt(idx); - return allDevrs; - } - /* - * Create and return a dummy set of teams - */ - private TeamResource[] createTeams(String prefix, int howMany) - { - TeamResource[] teams = new TeamResource[howMany]; - for (int idx=0; idx<teams.length; idx++) - { - teams[idx] = new TeamResource(this); - teams[idx].setName(prefix + (idx+1)); - teams[idx].setDevelopers(createDevelopers(teams[idx].getName()+" developer",idx+1)); - } - return teams; - } - - /* - * Create and return a dummy set of developers - */ - private DeveloperResource[] createDevelopers(String prefix, int nbr) - { - DeveloperResource[] devrs = new DeveloperResource[nbr]; - for (int idx=0; idx<devrs.length; idx++) - { - devrs[idx] = new DeveloperResource(this); - devrs[idx].setName(prefix + (idx+1)); - devrs[idx].setId(Integer.toString(employeeId++)); - devrs[idx].setDeptNbr(Integer.toString((idx+1)*100)); - devVector.add(devrs[idx]); // update master list - } - return devrs; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java deleted file mode 100644 index 9e1865d5a..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -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 samples.RSESamplesPlugin; - -/** - * This is our subsystem factory, which creates instances of our subsystems, - * and supplies the subsystem and filter actions to their popup menus. - */ -public class DeveloperSubSystemConfiguration extends SubSystemConfiguration { - - /** - * Constructor for DeveloperSubSystemConfiguration. - */ - public DeveloperSubSystemConfiguration() { - super(); - } - - /** - * Create an instance of our subsystem. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#createSubSystemInternal(org.eclipse.rse.core.model.IHost) - */ - public ISubSystem createSubSystemInternal(IHost conn) { - return new DeveloperSubSystem(conn, getConnectorService(conn)); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#getConnectorService(org.eclipse.rse.model.IHost) - */ - public IConnectorService getConnectorService(IHost host) { - return DeveloperConnectorServiceManager.getTheDeveloperConnectorServiceManager() - .getConnectorService(host, IDeveloperSubSystem.class); - } - - /** - * Intercept of parent method that creates an initial default filter pool. - * We intercept so that we can create an initial filter in that pool, which will - * list all teams. - */ - 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$ - //--tutorial part 1 - //mgr.createSystemFilter(defaultPool, "All teams", strings); - //--tutorial part 2 - ISystemFilter filter = mgr.createSystemFilter(defaultPool, - RSESamplesPlugin.getResourceString("filter.default.name"), //$NON-NLS-1$ - strings); - filter.setType("team"); //$NON-NLS-1$ - } catch (Exception exc) {} - return defaultPool; - } - - /** - * Intercept of parent method so we can supply our own value shown in the property - * sheet for the "type" property when a filter is selected within our subsystem. - * - * Requires this line in rseSamplesResources.properties: property.type.teamfilter=Team filter - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#getTranslatedFilterTypeProperty(org.eclipse.rse.core.filters.ISystemFilter) - */ - public String getTranslatedFilterTypeProperty(ISystemFilter selectedFilter) - { - //--tutorial part 1 - //return RSESamplesPlugin.getResourceString("property.type.teamfilter"); //$NON-NLS-1$ - //--tutorial part 2 - String type = selectedFilter.getType(); - if (type == null) - type = "team"; //$NON-NLS-1$ - if (type.equals("team")) //$NON-NLS-1$ - return RSESamplesPlugin.getResourceString("property.type.teamfilter"); //$NON-NLS-1$ - else - return RSESamplesPlugin.getResourceString("property.type.devrfilter"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchProperties(org.eclipse.rse.model.IHost) - */ - public boolean supportsServerLaunchProperties(IHost host) { - return false; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapter.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapter.java deleted file mode 100644 index f82290144..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapter.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.core.filters.ISystemFilter; -import org.eclipse.rse.core.filters.ISystemFilterPool; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.ui.filters.actions.SystemChangeFilterAction; -import org.eclipse.rse.ui.filters.actions.SystemNewFilterAction; -import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter; -import org.eclipse.swt.widgets.Shell; - -import samples.RSESamplesPlugin; - -/** - * Adds functionality to the basic SubSystemConfiguration. - */ -public class DeveloperSubSystemConfigurationAdapter extends - SubSystemConfigurationAdapter -{ - - /** - * Constructor for DeveloperSubSystemConfigurationAdapter. - */ - public DeveloperSubSystemConfigurationAdapter() - { - super(); - } - - /** - * Override of parent method, to affect what is returned for the New Filter-> actions. - * We intercept here, versus getNewFilterPoolFilterAction, so that we can return multiple - * actions versus just one. - */ - protected IAction[] getNewFilterPoolFilterActions(ISubSystemConfiguration factory, ISystemFilterPool selectedPool, Shell shell) - { - SystemNewFilterAction teamAction = (SystemNewFilterAction)super.getNewFilterPoolFilterAction(factory, selectedPool, shell); - teamAction.setWizardPageTitle(RSESamplesPlugin.getResourceString("filter.team.pagetitle")); //$NON-NLS-1$ - teamAction.setPage1Description(RSESamplesPlugin.getResourceString("filter.team.pagetext")); //$NON-NLS-1$ - teamAction.setType("team"); //$NON-NLS-1$ - teamAction.setText(RSESamplesPlugin.getResourceString("filter.team.pagetitle") + "..."); //$NON-NLS-1$ //$NON-NLS-2$ - - SystemNewFilterAction devrAction = (SystemNewFilterAction)super.getNewFilterPoolFilterAction(factory, selectedPool, shell); - devrAction.setWizardPageTitle(RSESamplesPlugin.getResourceString("filter.devr.pagetitle")); //$NON-NLS-1$ - devrAction.setPage1Description(RSESamplesPlugin.getResourceString("filter.devr.pagetext")); //$NON-NLS-1$ - devrAction.setType("devr"); //$NON-NLS-1$ - devrAction.setText(RSESamplesPlugin.getResourceString("filter.devr.pagetitle") + "..."); //$NON-NLS-1$ //$NON-NLS-2$ - devrAction.setFilterStringEditPane(new DeveloperFilterStringEditPane(shell)); - - IAction[] actions = new IAction[2]; - actions[0] = teamAction; - actions[1] = devrAction; - return actions; - } - - /** - * Override of parent method for returning the change-filter action, so we can affect it. - */ - protected IAction getChangeFilterAction(ISubSystemConfiguration factory, ISystemFilter selectedFilter, Shell shell) - { - SystemChangeFilterAction action = (SystemChangeFilterAction)super.getChangeFilterAction(factory, selectedFilter, shell); - String type = selectedFilter.getType(); - if (type == null) - type = "team"; //$NON-NLS-1$ - if (type.equals("team")) //$NON-NLS-1$ - { - action.setDialogTitle(RSESamplesPlugin.getResourceString("filter.team.dlgtitle")); //$NON-NLS-1$ - } - else - { - action.setDialogTitle(RSESamplesPlugin.getResourceString("filter.devr.dlgtitle")); //$NON-NLS-1$ - action.setFilterStringEditPane(new DeveloperFilterStringEditPane(shell)); - } - return action; - } - - /** - * Override of parent method for returning the image for filters in our subsystem. - * @see org.eclipse.rse.ui.view.SubSystemConfigurationAdapter#getSystemFilterImage(org.eclipse.rse.core.filters.ISystemFilter) - */ - public ImageDescriptor getSystemFilterImage(ISystemFilter filter) - { - String type = filter.getType(); - if (type == null) - type = "team"; //$NON-NLS-1$ - if (type.equals("team")) //$NON-NLS-1$ - return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_TEAMFILTER"); //$NON-NLS-1$ - else - return RSESamplesPlugin.getDefault().getImageDescriptor("ICON_ID_DEVELOPERFILTER"); //$NON-NLS-1$ - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapterFactory.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapterFactory.java deleted file mode 100644 index 3ad6da7b0..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfigurationAdapterFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation and Wind River Systems, Inc. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; - -/** - * @see IAdapterFactory - */ -public class DeveloperSubSystemConfigurationAdapterFactory implements - IAdapterFactory { - - private ISubSystemConfigurationAdapter ssConfigAdapter = new DeveloperSubSystemConfigurationAdapter(); - - /** - * @see IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() - { - return new Class[] {ISubSystemConfigurationAdapter.class}; - } - - /** - * Called by our plugin's startup method to register our adaptable object types - * with the platform. We prefer to do it here to isolate/encapsulate all factory - * logic in this one place. - * @param manager Platform adapter manager - */ - public void registerWithManager(IAdapterManager manager) - { - manager.registerAdapters(this, DeveloperSubSystemConfiguration.class); - } - - /** - * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) - { - Object adapter = null; - if (adaptableObject instanceof DeveloperSubSystemConfiguration) - adapter = ssConfigAdapter; - - return adapter; - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/IDeveloperSubSystem.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/IDeveloperSubSystem.java deleted file mode 100644 index 226d2b867..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/IDeveloperSubSystem.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation and Wind River Systems, Inc. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.subsystems; - -public interface IDeveloperSubSystem { - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/actions/ShowJarContents.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/actions/ShowJarContents.java deleted file mode 100644 index d2e58ef73..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/actions/ShowJarContents.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.ui.actions; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteError; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteOutput; -import org.eclipse.rse.services.shells.IHostOutput; -import org.eclipse.rse.services.shells.IHostShell; -import org.eclipse.rse.services.shells.IHostShellChangeEvent; -import org.eclipse.rse.services.shells.IHostShellOutputListener; -import org.eclipse.rse.services.shells.IShellService; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem; - -/** - * An action that runs a command to display the contents of a Jar file. - * The plugin.xml file restricts this action so it only appears for .jar files. - */ -public class ShowJarContents extends SystemAbstractRemoteFilePopupMenuExtensionAction { - - /** - * Constructor for ShowJarContents. - */ - public ShowJarContents() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction#run() - */ - public void run() { - IRemoteFile selectedFile = getFirstSelectedRemoteFile(); - String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath(); //$NON-NLS-1$ - try { - runCommand(cmdToRun); - } catch(Exception e) { - String excType = e.getClass().getName(); - MessageDialog.openError(getShell(), excType, excType+": "+e.getLocalizedMessage()); //$NON-NLS-1$ - e.printStackTrace(); - } - } - - public IRemoteCmdSubSystem getRemoteCmdSubSystem() { - //get the Command subsystem associated with the current host - IHost myHost = getSubSystem().getHost(); - IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost); - for (int i=0; i<subsys.length; i++) { - if (subsys[i].getSubSystemConfiguration().supportsCommands()) { - return subsys[i]; - } - } - return null; - } - - public void runCommand(String command) throws Exception - { - IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem(); - if (cmdss!=null && cmdss.isConnected()) { - //Option A: run the command invisibly through SubSystem API - //runCommandInvisibly(cmdss, command); - //Option B: run the command invisibly through Service API - //runCommandInvisiblyService(cmdss, command); - //Option C: run the command in a visible shell - RemoteCommandHelpers.runUniversalCommand(getShell(), command, ".", cmdss); //$NON-NLS-1$ - } else { - MessageDialog.openError(getShell(), "No command subsystem", "Found no command subsystem"); - } - } - - public static class StdOutOutputListener implements IHostShellOutputListener { - public void shellOutputChanged(IHostShellChangeEvent event) { - IHostOutput[] lines = event.getLines(); - for(int i=0; i<lines.length; i++) { - System.out.println(lines[i]); - } - } - } - - /** New version of running commands through IShellService / IHostShell */ - public void runCommandInvisiblyService(IRemoteCmdSubSystem cmdss, String command) throws Exception - { - if (cmdss instanceof IShellServiceSubSystem) { - IShellService shellService = ((IShellServiceSubSystem)cmdss).getShellService(); - String [] environment = new String[1]; - environment[0] = "AAA=BBB"; //$NON-NLS-1$ - String initialWorkingDirectory = "."; //$NON-NLS-1$ - - IHostShell hostShell = shellService.launchShell(new NullProgressMonitor(), initialWorkingDirectory, environment); - hostShell.addOutputListener(new StdOutOutputListener()); - //hostShell.writeToShell("pwd"); //$NON-NLS-1$ - //hostShell.writeToShell("echo ${AAA}"); //$NON-NLS-1$ - //hostShell.writeToShell("env"); //$NON-NLS-1$ - hostShell.writeToShell(command); - hostShell.writeToShell("exit"); //$NON-NLS-1$ - } - } - - /** Old version of running commands through the command subsystem */ - public void runCommandInvisibly(IRemoteCmdSubSystem cmdss, String command) throws Exception - { - command = command + cmdss.getParentRemoteCmdSubSystemConfiguration().getCommandSeparator() + "exit"; //$NON-NLS-1$ - Object[] result = cmdss.runCommand(command, null, false); - if (result.length>0 && result[0] instanceof IRemoteCommandShell) { - IRemoteCommandShell cs = (IRemoteCommandShell)result[0]; - while (cs.isActive()) { - Thread.sleep(1000); - } - Object[] output = cs.listOutput(); - for (int i=0; i<output.length; i++) { - if (output[i] instanceof RemoteOutput) { - System.out.println(((RemoteOutput)output[i]).getText()); - } else if (output[i] instanceof RemoteError) { - System.err.println(((RemoteError)output[i]).getText()); - } - } - cmdss.removeShell(cs); - } - } - -} diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/propertypages/FolderInfoPropertyPage.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/propertypages/FolderInfoPropertyPage.java deleted file mode 100644 index a9316e3ff..000000000 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/ui/propertypages/FolderInfoPropertyPage.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation and Wind River Systems, Inc. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. - ********************************************************************************/ - -package samples.ui.propertypages; - -import org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; - -import samples.RSESamplesPlugin; - -/** - * A sample property page for a remote object, which in this case is scoped via the - * extension point xml to only apply to folder objects. - */ -public class FolderInfoPropertyPage - extends SystemAbstractRemoteFilePropertyPageExtensionAction - implements SelectionListener -{ - // gui widgets... - private Label sizeLabel, filesLabel, foldersLabel; - private Button stopButton; - // state... - private int totalSize = 0; - private int totalFolders = 0; - private int totalFiles = 0; - private boolean stopped = false; - private Thread workerThread; - private Runnable guiUpdater; - - /** - * Constructor for FolderInfoPropertyPage. - */ - public FolderInfoPropertyPage() - { - super(); - } - - // -------------------------- - // Parent method overrides... - // -------------------------- - - - /* (non-Javadoc) - * @see org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction#createContentArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createContentArea(Composite parent) - { - Composite composite = SystemWidgetHelpers.createComposite(parent, 2); - // draw the gui - sizeLabel = SystemWidgetHelpers.createLabeledLabel(composite, - RSESamplesPlugin.getResourceString("pp.size.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("pp.size.tooltip"), //$NON-NLS-1$ - false); - filesLabel = SystemWidgetHelpers.createLabeledLabel(composite, - RSESamplesPlugin.getResourceString("pp.files.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("pp.files.tooltip"), //$NON-NLS-1$ - false); - foldersLabel = SystemWidgetHelpers.createLabeledLabel(composite, - RSESamplesPlugin.getResourceString("pp.folders.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("pp.folders.tooltip"), //$NON-NLS-1$ - false); - stopButton = SystemWidgetHelpers.createPushButton(composite, null, - RSESamplesPlugin.getResourceString("pp.stopButton.label"), //$NON-NLS-1$ - RSESamplesPlugin.getResourceString("pp.stopButton.tooltip") //$NON-NLS-1$ - ); - stopButton.addSelectionListener(this); - - setValid(false); // Disable OK button until thread is done - - // show "Processing..." message - setMessage(RSESamplesPlugin.getPluginMessage("RSSG1002")); //$NON-NLS-1$ - - // create instance of Runnable to allow asynchronous GUI updates from background thread - guiUpdater = new RunnableGUIClass(); - // spawn a thread to calculate the information - workerThread = new RunnableClass(getRemoteFile()); - workerThread.start(); - - return composite; - } - - /** - * Intercept from PreferencePage. Called when user presses Cancel button. - * We stop the background thread. - * @see org.eclipse.jface.preference.PreferencePage#performCancel() - */ - public boolean performCancel() - { - killThread(); - return true; - } - - /** - * Intercept from DialogPage. Called when dialog going away. - * If the user presses the X to close this dialog, we - * need to stop that background thread. - */ - public void dispose() - { - killThread(); - super.dispose(); - } - - /** - * Private method to kill our background thread. - * Control doesn't return until it ends. - */ - private void killThread() - { - if (!stopped && workerThread.isAlive()) - { - stopped = true; - try { - workerThread.join(); // wait for thread to end - } catch (InterruptedException exc) {} - } - } - - // ------------------------------------------- - // Methods from SelectionListener interface... - // ------------------------------------------- - - /** - * From SelectionListener - * @see SelectionListener#widgetSelected(SelectionEvent) - */ - public void widgetSelected(SelectionEvent event) - { - if (event.getSource() == stopButton) - { - stopped = true; - stopButton.setEnabled(false); - } - } - /** - * From SelectionListener - * @see SelectionListener#widgetDefaultSelected(SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent event) - { - } - - // ---------------- - // Inner classes... - // ---------------- - /** - * Inner class encapsulating the background work to be done, so it may be executed - * in background thread. - */ - private class RunnableClass extends Thread - { - IRemoteFile inputFolder; - - RunnableClass(IRemoteFile inputFolder) - { - this.inputFolder = inputFolder; - } - - public void run() - { - if (stopped) - return; - walkFolder(inputFolder); - updateGUI(); - if (!stopped) - { - stopped = true; - updateGUI(); - } - } - - /** - * Recursively walk a folder, updating the running tallies. - * Update the GUI after processing each subfolder. - */ - private void walkFolder(IRemoteFile currFolder) - { - try - { - IRemoteFile[] folders = currFolder.getParentRemoteFileSubSystem().listFoldersAndFiles( currFolder, null); - if ((folders != null) && (folders.length>0)) - { - for (int idx=0; !stopped && (idx<folders.length); idx++) - { - // is this a folder? - if (folders[idx].isDirectory()) - { - ++totalFolders; - walkFolder(folders[idx]); - updateGUI(); - } - // is this a file? - else - { - ++totalFiles; - totalSize += folders[idx].getLength(); - } - } - } - } - catch (SystemMessageException e) - { - - } - } // end of walkFolder method - - } // end of inner class - - /** - * Inner class encapsulating the GUI work to be done from the - * background thread. - */ - private class RunnableGUIClass implements Runnable - { - public void run() - { - if (stopButton.isDisposed()) - return; - if (!stopped) - { - sizeLabel.setText(Integer.toString(totalSize)); - filesLabel.setText(Integer.toString(totalFiles)); - foldersLabel.setText(Integer.toString(totalFolders)); - } - else if (stopped) - { - setValid(true); // re-enable OK button - stopButton.setEnabled(false); // disable Stop button - clearMessage(); // clear "Processing..." message - } - } - } - - - /** - * Update the GUI with the current status - */ - private void updateGUI() - { - Display.getDefault().asyncExec(guiUpdater); - } - - -} |