From dc383c52f36182360313a1fccd4c8be8cdb8150f Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 10 Apr 2008 15:32:51 +0000 Subject: [PATCH] [218304] Improve deferred adapter loading --- .../daytime/subsystems/DaytimeSubSystem.java | 34 +- .../subsystems/DeveloperSubSystem.java | 76 ++-- .../rse/core/subsystems/ISubSystem.java | 58 +-- .../subsystems/files/core/Activator.java | 17 +- .../FileServiceSubSystem.java | 321 ++++++++-------- .../core/subsystems/RemoteFileSubSystem.java | 287 +++++++------- .../subsystems/processes/core/Activator.java | 17 +- .../impl/RemoteProcessSubSystemImpl.java | 61 +-- .../ProcessServiceSubSystem.java | 43 ++- .../subsystems/shells/core/Activator.java | 17 +- .../core/subsystems/RemoteCmdSubSystem.java | 176 ++++----- .../ShellServiceSubSystem.java | 3 + .../SystemViewFilterPoolReferenceAdapter.java | 138 ++++--- .../SystemViewFilterReferenceAdapter.java | 171 +++++---- .../ui/view/SystemViewSubSystemAdapter.java | 359 ++++++++++-------- ...temTeamViewSubSystemConfigurationNode.java | 50 ++- .../SystemChangeFilterPropertyPage.java | 110 +++--- .../eclipse/rse/ui/view/SystemTableView.java | 285 +++++++------- .../RSEDefaultNewConnectionWizard.java | 56 +-- .../rse/core/subsystems/SubSystem.java | 101 +++-- .../internal/testsubsystem/TestSubSystem.java | 34 +- 21 files changed, 1280 insertions(+), 1134 deletions(-) diff --git a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystem.java b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystem.java index dc341931ef5..3dc8084649d 100644 --- a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystem.java +++ b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystem.java @@ -1,15 +1,16 @@ /******************************************************************************* * Copyright (c) 2006, 2008 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 - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation + * 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: + * Martin Oberhuber (Wind River) - initial API and implementation * David Dykstal (IBM) - [217556] remove service subsystem types * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.examples.daytime.subsystems; @@ -43,8 +44,8 @@ import org.eclipse.rse.ui.model.ISystemRegistryUI; */ public class DaytimeSubSystem extends SubSystem { - private IDaytimeService fDaytimeService; - + private IDaytimeService fDaytimeService; + public DaytimeSubSystem(IHost host, IConnectorService connectorService, IDaytimeService daytimeService) { super(host, connectorService); fDaytimeService = daytimeService; @@ -52,8 +53,9 @@ public class DaytimeSubSystem extends SubSystem { public void initializeSubSystem(IProgressMonitor monitor) { //This is called after connect - expand the daytime node. - //May be called in worker thread. - //TODO find a more elegant solution for expanding the item, e.g. use implicit connect like filters + // Always called in worker thread. + super.initializeSubSystem(monitor); + //TODO find a more elegant solution for expanding the item, e.g. use implicit connect like filters final ISystemRegistryUI sr = RSEUIPlugin.getTheSystemRegistryUI(); final SystemResourceChangeEvent event = new SystemResourceChangeEvent(this, ISystemResourceChangeEvents.EVENT_SELECT_EXPAND, null); //TODO bug 150919: postEvent() should not be necessary asynchronously @@ -62,15 +64,15 @@ public class DaytimeSubSystem extends SubSystem { public void run() { sr.postEvent(event); } }); } - + public boolean hasChildren() { return isConnected(); } - + public IDaytimeService getDaytimeService() { return fDaytimeService; } - + public Object[] getChildren() { if (isConnected()) { try { @@ -90,7 +92,7 @@ public class DaytimeSubSystem extends SubSystem { } public void uninitializeSubSystem(IProgressMonitor monitor) { - //nothing to do + super.uninitializeSubSystem(monitor); } public Class getServiceType() { @@ -99,7 +101,7 @@ public class DaytimeSubSystem extends SubSystem { public void switchServiceFactory(ISubSystemConfiguration factory) { // not applicable here - + } } 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 index 6971e6cff89..6ba698393bb 100644 --- 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 @@ -1,17 +1,18 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008 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 + * 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, + * 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. + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package samples.subsystems; @@ -35,7 +36,7 @@ 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 + private static int employeeId = 123456; // employee Id factory /** * @param host @@ -45,23 +46,28 @@ public class DeveloperSubSystem extends SubSystem super(host, connectorService); } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SubSystem#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) + /* + * (non-Javadoc) + * @see SubSystem#initializeSubSystem(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) { + super.initializeSubSystem(monitor); } /* * (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SubSystem#getObjectWithAbsoluteName(java.lang.String) + * @see ISubSystem#uninitializeSubSystem(IProgressMonitor) */ - public Object getObjectWithAbsoluteName(String key) throws Exception + public void uninitializeSubSystem(IProgressMonitor monitor) { + super.uninitializeSubSystem(monitor); + } + + /* + * (non-Javadoc) + * + * @see SubSystem#getObjectWithAbsoluteName(String, IProgressMonitor) + */ + public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception { // Functional opposite of getAbsoluteName(Object) in our resource adapters if (key.startsWith("Team_")) //$NON-NLS-1$ @@ -78,10 +84,10 @@ public class DeveloperSubSystem extends SubSystem DeveloperResource[] devrs = getAllDevelopers(); for (int idx=0; idxSubSystem class * instead. @@ -73,7 +74,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I /** * Set the connector service for this subsystem - * + * * @param connectorService connector service object to set */ public void setConnectorService(IConnectorService connectorService); @@ -90,14 +91,25 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I public IHost getHost(); /** - * Called on each subsystem associated with a particular {@link IConnectorService} after it connects. - * @param monitor A progress monitor supporting progress reporting and cancellation. + * Called on each subsystem associated with a particular + * {@link IConnectorService} after it connects successfully. This call is + * always made on a background Thread, so it's allowed to be long-running. + * + * @param monitor a progress monitor that can be used to show progress + * during long-running operation. Cancellation is typically not + * supported since it might leave the system in an inconsistent + * state. */ public void initializeSubSystem(IProgressMonitor monitor); /** - * Called on each subsystem associated with a particular {@link IConnectorService} after it disconnects - * @param monitor A progress monitor supporting progress reporting and cancellation. + * Called on each subsystem associated with a particular + * {@link IConnectorService} after it disconnects + * + * @param monitor a progress monitor that can be used to show progress + * during long-running operation. Cancellation is typically not + * supported since it might leave the system in an inconsistent + * state. */ public void uninitializeSubSystem(IProgressMonitor monitor); @@ -142,14 +154,14 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I /** * Check if the subsystem is connected, and connect if it's not. - * + * * This is a convenience method which first checks whether the subsystem is * already connected. If not, it automatically checks if it's running on the * dispatch thread or not, and calls the right connect() * method as appropriate. It also performs some exception parsing, * converting Exceptions from connect() into SystemMessageException that can * be displayed to the user by using a method in it. - * + * * @throws SystemMessageException in case of an error connecting * @since org.eclipse.rse.core 3.0 */ @@ -352,7 +364,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * Return the CacheManager for this subsystem. If the SubSystem returns true for * supportsCaching() then it must return a valid CacheManager, otherwise it is free * to return null. - * + * * @see #supportsCaching() */ public ICacheManager getCacheManager(); @@ -381,15 +393,15 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I /** * Synchronously connect to the remote system. - * + * * Clients are expected to call this method on a background * thread with an existing progress monitor. A signon prompt * may optionally be forced even if the password is cached * in memory or on disk. - * + * * The framework will take care of switching to the UI thread * for requesting a password from the user if necessary. - * + * * @param monitor the progress monitor. Must not be null. * @param forcePrompt forces the prompt dialog to be displayed * even if the password is currently in memory. @@ -411,7 +423,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I *

* Override internalConnect if you want, but by default it calls * getConnectorService().connect(IProgressMonitor). - * + * * @param forcePrompt forces the prompt dialog even if the password is in mem * @param callback to call after connect is complete. * May be null. @@ -530,7 +542,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * @param key Identifies property to set * @param value Value to set property to * @return Object interpretable by subsystem. Might be a Boolean, or the might be new value for confirmation. - * + * * @deprecated this shouldn't be used */ public Object setProperty(Object subject, String key, String value) throws Exception; @@ -542,7 +554,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * @param subject Identifies which object to get the properties of * @param key Identifies property to get value of * @return String The value of the requested key. - * + * * @deprecated this shouldn't be used */ public String getProperty(Object subject, String key) throws Exception; @@ -555,7 +567,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * @param keys Identifies the properties to set * @param values Values to set properties to. One to one mapping to keys by index number * @return Object interpretable by subsystem. Might be a Boolean, or the might be new values for confirmation. - * + * * @deprecated this shouldn't be used */ public Object setProperties(Object subject, String[] keys, String[] values) throws Exception; @@ -567,7 +579,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * @param subject Identifies which object to get the properties of * @param keys Identifies properties to get value of * @return The values of the requested keys. - * + * * @deprecated this shouldn't be used */ public String[] getProperties(Object subject, String[] keys) throws Exception; @@ -622,7 +634,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I /** * Returns the interface type (i.e. a Class object that is an Interface) of * a service subsystem. - * + * * @return the service interface on which this service subsystem is * implemented. If this subsystem is not a service subsystem it must * return null. @@ -638,7 +650,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * {@link #canSwitchTo(ISubSystemConfiguration)}. If the configuration is * not compatible with this subsystem then this must do nothing and must * answer false to {@link #canSwitchTo(ISubSystemConfiguration)}. - * + * * @param configuration the configuration to which to switch. * @since org.eclipse.rse.core 3.0 */ @@ -647,7 +659,7 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I /** * Determine is this subsystem is compatible with this specified * configuration. - * + * * @param configuration the configuration which may be switched to * @return true if the subsystem can switch to this configuration, false * otherwise. Subsystems which are not service subsystems must diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java index b9240fa8b0a..791071bbdb5 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java @@ -15,13 +15,12 @@ * Martin Oberhuber (Wind River) - [180519][api] declaratively register adapter factories * Martin Oberhuber (wind River) - [203105] Decouple recursive plugin activation of UI adapters * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileEmpty; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -47,20 +46,6 @@ public class Activator extends AbstractUIPlugin { */ public void start(BundleContext context) throws Exception { super.start(context); - - // make sure that required adapters factories are loaded - //(will typically activate org.eclipse.rse.files.ui) - //TODO Check that this does not fire up the UI if we want to be headless - //Decouple from the current Thread - new Thread("files.ui adapter loader") { //$NON-NLS-1$ - public void run() { - Platform.getAdapterManager().loadAdapter(new RemoteFileEmpty(), "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ - } - }.start(); - // Others (RemoteSearchResultSet, RemoteSearchResult, - // RemoteFileSystemConfigurationAdapter will be available - // automatically once the plugin is loaded - } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java index 46f065705bc..8ef569645c3 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java @@ -7,10 +7,10 @@ * * 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, + * 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) - Fix 158534 - NPE in upload/download after conflict * Martin Oberhuber (Wind River) - Fix 162962 - recursive removeCachedRemoteFile() @@ -25,15 +25,16 @@ * David McKnight (IBM) - [162195] new APIs for upload multi and download multi * David McKnight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text) * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated - * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND * David McKnight (IBM) - [209704] added supportsEncodingConversion() * David Dykstal (IBM) - [197036] pulling up subsystem switch logic * David Dykstal (IBM) - [217556] remove service subsystem types - * Martin Oberhuber (Wind River) - [219098][api] FileServiceSubSystem should not be final + * Martin Oberhuber (Wind River) - [219098][api] FileServiceSubSystem should not be final * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * Kevin Doyle (IBM) - [224162] SystemEditableRemoteFile.saveAs does not work because FileServiceSubSytem.upload does invalid check + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.servicesubsystem; @@ -84,16 +85,16 @@ import org.eclipse.rse.ui.SystemBasePlugin; /** * Generic Subsystem implementation for remote files. - * + * * Clients may instantiate this class from their subsystem configurations. *

* Extending (overriding) this class is discouraged: configuration of the subsystem - * behavior should be done by providing a custom {@link IFileService} implementation + * behavior should be done by providing a custom {@link IFileService} implementation * wherever possible. */ -public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileServiceSubSystem +public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileServiceSubSystem { - + protected ILanguageUtilityFactory _languageUtilityFactory; protected IFileService _hostFileService; protected ISearchService _hostSearchService; @@ -105,16 +106,16 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe _hostFileService = hostFileService; _hostFileToRemoteFileAdapter = fileAdapter; _hostSearchService = searchService; - + } - + /* (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#isCaseSensitive() */ public boolean isCaseSensitive() { return getFileService().isCaseSensitive(); } - + public IRemoteFileContext getContextFor(IRemoteFile file) { return getContext(file); @@ -124,27 +125,27 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { return getDefaultContextNoFilterString(); } - + public IFileService getFileService() { return _hostFileService; } - + public void setFileService(IFileService service) { _hostFileService = service; } - + public ISearchService getSearchService() { return _hostSearchService; } - + public void setSearchService(ISearchService service) { _hostSearchService = service; } - + public IHostFileToRemoteFileAdapter getHostFileToRemoteFileAdapter() { return _hostFileToRemoteFileAdapter; @@ -154,43 +155,43 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { _hostFileToRemoteFileAdapter = hostFileAdapter; } - + /** - * Constructs an IRemoteFile object given - * an unqualified file or folder name and its parent folder object. + * Constructs an IRemoteFile object given + * an unqualified file or folder name and its parent folder object. * @param parent Folder containing the folder or file * @param folderOrFileName Un-qualified folder or file name * @param monitor the progress monitor * @return an IRemoteFile object for the file. * @see IRemoteFile */ - public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException + public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException { // for bug 207095, implicit connect if the connection is not connected checkIsConnected(monitor); String fullPath = parent.getAbsolutePath() + getSeparator() + folderOrFileName; IRemoteFile file = getCachedRemoteFile(fullPath); - if (file != null && !file.isStale()) + if (file != null && !file.isStale()) { return file; } - + IHostFile node = getFile(parent.getAbsolutePath(), folderOrFileName, monitor); return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); } - + /** - * Constructs and returns an IRemoteFile object given a fully-qualified + * Constructs and returns an IRemoteFile object given a fully-qualified * file or folder name. * @param folderOrFileName Fully qualified folder or file name * @param monitor the progress monitor * @return The constructed IRemoteFile * @see IRemoteFile */ - public IRemoteFile getRemoteFileObject(String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException + public IRemoteFile getRemoteFileObject(String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException { String fofName = folderOrFileName; @@ -202,19 +203,19 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe if (file != null && !file.isStale()) { return file; } - + // for bug 207095, implicit connect if the connection is not connected checkIsConnected(monitor); - + if (fofName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR)) { fofName = fofName.substring(0, fofName.length() - ArchiveHandlerManager.VIRTUAL_SEPARATOR.length()); - } - + } + int j = fofName.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR); if (j == -1) { - if (fofName.equals("/")) //$NON-NLS-1$ + if (fofName.equals("/")) //$NON-NLS-1$ { try { @@ -222,18 +223,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } catch (Exception e) { - + } - } - + } + if (fofName.equals(".")) { //$NON-NLS-1$ IRemoteFile userHome = getUserHome(); if (userHome == null){ - - // with 207095, it's possible that we could be trying to get user home when not connected - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + + // with 207095, it's possible that we could be trying to get user home when not connected + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_ERROR_UNEXPECTED, - IStatus.ERROR, + IStatus.ERROR, CommonMessages.MSG_ERROR_UNEXPECTED); throw new SystemMessageException(msg); } @@ -260,22 +261,22 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } return null; } - + int lastSep = fofName.lastIndexOf(sep); - - if (lastSep > -1) - { + + if (lastSep > -1) + { String parentPath = fofName.substring(0, lastSep); - - + + if (parentPath.length() == 0) parentPath = "/"; //$NON-NLS-1$ String name = fofName.substring(lastSep + 1, fofName.length()); - + IHostFile node = getFile(parentPath, name, monitor); if (node != null) { IRemoteFile parent = null; - if (!node.isRoot()) + if (!node.isRoot()) { //parent = getRemoteFileObject(parentPath); } @@ -304,7 +305,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe * @return The IRemoteFile that is the user's home directory on this remote file system. * The remote file system is assumed to have a concept of a home directory. */ - protected IRemoteFile getUserHome() + protected IRemoteFile getUserHome() { if (_userHome != null) { @@ -319,7 +320,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe if (userHome == null) { return null; } - + IRemoteFile parent = null; if (!userHome.getParentPath().equals(".")) //$NON-NLS-1$ { @@ -328,7 +329,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe //parent = getRemoteFileObject(userHome.getParentPath()); } catch (Exception e) - { + { } } root = getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, userHome); @@ -340,53 +341,53 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { return getFileService().list(parentPath, fileNameFilter, fileType, monitor); } - - + + protected IHostFile getFile(String parentPath, String fileName, IProgressMonitor monitor) throws SystemMessageException { return getFileService().getFile(parentPath, fileName, monitor); } - + protected IHostFile[] getRoots(IProgressMonitor monitor) throws InterruptedException, SystemMessageException { return getFileService().getRoots(monitor); } public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, - IProgressMonitor monitor) throws SystemMessageException + IProgressMonitor monitor) throws SystemMessageException { // for bug 207095, implicit connect if the connection is not connected checkIsConnected(monitor); - + String[] parentPaths = new String[folderOrFileNames.length]; String[] names = new String[folderOrFileNames.length]; - String sep = null; + String sep = null; for (int i = 0; i < folderOrFileNames.length; i++) { String fofName = folderOrFileNames[i]; if (sep == null) sep = PathUtility.getSeparator(fofName); - + String parentPath = null; String name = null; int lastSep = fofName.lastIndexOf(sep); - - if (lastSep > -1) - { + + if (lastSep > -1) + { parentPath = fofName.substring(0, lastSep); - + if (parentPath.length() == 0) parentPath = "/"; //$NON-NLS-1$ name = fofName.substring(lastSep + 1, fofName.length()); } - + parentPaths[i] = parentPath; names[i] = name; } - + RemoteFileContext context = getDefaultContext(); IHostFile[] nodes = getFileService().getFileMultiple(parentPaths, names, monitor); - return getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, nodes); + return getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, nodes); } @@ -405,26 +406,26 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { parentPaths[i] = parents[i].getAbsolutePath(); } - + IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, monitor); RemoteFileContext context = getDefaultContext(); - + IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); - + // caching for (int i = 0; i < parents.length; i++) { IRemoteFile parent = parents[i]; String parentPath = parentPaths[i]; String filter = fileNameFilters[i]; - + List underParent = new ArrayList(); // what files are under this one? for (int j = 0; j < farr.length; j++) { IRemoteFile child = farr[j]; String childParentPath = child.getParentPath(); - + if (parentPath.equals(childParentPath)) { underParent.add(child); @@ -433,7 +434,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe if (underParent.size() > 0) { parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); - } + } } return farr; @@ -455,26 +456,26 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { parentPaths[i] = parents[i].getAbsolutePath(); } - + IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileType, monitor); RemoteFileContext context = getDefaultContext(); - + IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); - + // caching for (int i = 0; i < parents.length; i++) { IRemoteFile parent = parents[i]; String parentPath = parentPaths[i]; String filter = fileNameFilters[i]; - + List underParent = new ArrayList(); // what files are under this one? for (int j = 0; j < farr.length; j++) { IRemoteFile child = farr[j]; String childParentPath = child.getParentPath(); - + if (parentPath.equals(childParentPath)) { underParent.add(child); @@ -483,18 +484,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe if (underParent.size() > 0) { parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); - } + } } return farr; } - + /** - * Return a list of remote folders and/or files in the given folder. + * Return a list of remote folders and/or files in the given folder. *

- * The files part of the list is filtered by the given file name filter. - * It can be null for no filtering. + * The files part of the list is filtered by the given file name filter. + * It can be null for no filtering. * This version is called by RemoteFileSubSystemImpl's resolveFilterString(s). * @param parent The parent folder to list folders and files in * @param fileNameFilter The name pattern to subset the file list by, or null to return all files. @@ -507,20 +508,20 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe String parentPath = null; if (parent != null) { parentPath = parent.getAbsolutePath(); - } else { + } else { parentPath = "/"; //$NON-NLS-1$ } - + if (parent != null && !parent.canRead()) { String msgTxt = NLS.bind(SystemFileResources.MSG_FOLDER_UNREADABLE, parentPath); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ISystemFileMessageIds.MSG_FOLDER_UNREADABLE, IStatus.INFO, msgTxt); throw new SystemMessageException(msg); } - - IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); + + IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); if (parent != null) @@ -529,8 +530,8 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } - - public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException + + public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException { IHostFile[] roots = null; try @@ -539,18 +540,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } catch (SystemMessageException e) { - + } - + IRemoteFile[] results = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, roots); return results; } - + protected boolean isBinary(String localEncoding, String hostEncoding, String remotePath) { - return RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(remotePath); + return RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(remotePath); } - + protected boolean isBinary(IRemoteFile source) { return source.isBinary(); // always use preferences (whether xml or not) @@ -573,18 +574,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe remoteFileName = avp.getName(); } getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, srcEncoding, rmtEncoding, monitor); - + // notify that the file was uploaded ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, remotePath, remoteParentPath, this)); } } - + /* * (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#upload(java.lang.String, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws SystemMessageException + public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws SystemMessageException { String remoteParentPath = destination.getParentPath(); String remoteFileName = destination.getName(); @@ -595,29 +596,29 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { String msgTxt = NLS.bind(SystemFileResources.MSG_FILE_CANNOT_BE_SAVED, remoteFileName, getHostName()); String msgDetails = SystemFileResources.MSG_FILE_CANNOT_BE_SAVED_DETAILS; - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ISystemFileMessageIds.MSG_FILE_CANNOT_BE_SAVED, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); } getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, encoding, hostEncoding, monitor); - + // notify that the file was uploaded ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, destination, destination.getParentRemoteFile(), this)); } - + public void uploadMultiple(String[] sources, String[] srcEncodings, String[] remotePaths, String[] rmtEncodings, - IProgressMonitor monitor) throws SystemMessageException + IProgressMonitor monitor) throws SystemMessageException { // create list of stuff File[] sourceFiles = new File[sources.length]; boolean[] isBinaries = new boolean[sources.length]; String[] remoteParentPaths = new String[sources.length]; String[] remoteFileNames = new String[sources.length]; - + // gather info for (int i = 0; i < sources.length; i++) { @@ -636,16 +637,16 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } } else // unexpected - { + { // throw an exception here //SystemMessage msg = RSEUIPlugin.getPluginMessage("RSEF5003").makeSubstitution(remoteFileNames[i], getHostName()); //$NON-NLS-1$ //throw new SystemMessageException(msg); } } - + // upload getFileService().uploadMultiple(sourceFiles, remoteParentPaths, remoteFileNames, isBinaries, srcEncodings, rmtEncodings, monitor); - + // notification // notify that the file was uploaded ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); @@ -659,43 +660,43 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe public void uploadMultiple(String[] sources, IRemoteFile[] destinations, String[] encodings, IProgressMonitor monitor) - throws SystemMessageException -{ + throws SystemMessageException +{ // create list of stuff File[] sourceFiles = new File[sources.length]; boolean[] isBinaries = new boolean[sources.length]; String[] remoteParentPaths = new String[sources.length]; String[] remoteFileNames = new String[sources.length]; String[] hostEncodings = new String[sources.length]; - + // gather info for (int i = 0; i < sources.length; i++) { sourceFiles[i] = new File(sources[i]); IRemoteFile destination = destinations[i]; - + remoteParentPaths[i] = destination.getAbsolutePath(); remoteFileNames[i] = destination.getName(); - + if (!destination.canWrite()) { String msgTxt = NLS.bind(SystemFileResources.MSG_FILE_CANNOT_BE_SAVED, remoteFileNames[i], getHostName()); String msgDetails = SystemFileResources.MSG_FILE_CANNOT_BE_SAVED_DETAILS; - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ISystemFileMessageIds.MSG_FILE_CANNOT_BE_SAVED, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); } - + hostEncodings[i] = destination.getEncoding(); isBinaries[i] = isBinary(encodings[i], hostEncodings[i], destination.getAbsolutePath()); - + } - + // upload getFileService().uploadMultiple(sourceFiles, remoteParentPaths, remoteFileNames, isBinaries, encodings, hostEncodings, monitor); - + // notification // notify that the file was uploaded ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); @@ -711,7 +712,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe * (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#download(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public void download(IRemoteFile file, String localpath, String encoding, IProgressMonitor monitor) throws SystemMessageException + public void download(IRemoteFile file, String localpath, String encoding, IProgressMonitor monitor) throws SystemMessageException { //Fixing bug 158534. TODO remove when bug 162688 is fixed. if (monitor==null) { @@ -719,7 +720,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } String parentPath = file.getParentPath(); File localFile = new File(localpath); - + // FIXME why are we using file.getEncoding() instead of the specified encoding? getFileService().download(parentPath, file.getName(), localFile, isBinary(file), file.getEncoding(), monitor); if (monitor.isCanceled()) @@ -734,22 +735,22 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } } - + public void downloadMultiple(IRemoteFile[] sources, String[] destinations, String[] encodings, IProgressMonitor monitor) - throws SystemMessageException + throws SystemMessageException { //Fixing bug 158534. TODO remove when bug 162688 is fixed. if (monitor==null) { monitor = new NullProgressMonitor(); } - + // get arrays of parent paths and local files String[] parentPaths = new String[sources.length]; String[] names = new String[sources.length]; boolean[] isBinaries = new boolean[sources.length]; File[] localFiles = new File[sources.length]; - + for (int i = 0; i < sources.length; i++) { IRemoteFile file = sources[i]; @@ -758,7 +759,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe isBinaries[i] = isBinary(file); localFiles[i] = new File(destinations[i]); } - + getFileService().downloadMultiple(parentPaths, names, localFiles, isBinaries, encodings, monitor); if (monitor.isCanceled()) { @@ -772,31 +773,31 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { // notify that the file was downloaded ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); - + for (int r = 0; r < sources.length; r++) { IRemoteFile file = sources[r]; sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DOWNLOADED, file, file.getParentRemoteFile(), this)); } - } + } } - + /* * (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#copy(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException + public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); return service.copy(sourceFolderOrFile.getParentPath(), sourceFolderOrFile.getName(), targetFolder.getAbsolutePath(), newName, monitor); } - - public boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException + + public boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String[] sourceParents = new String[sourceFolderOrFiles.length]; String[] sourceNames = new String[sourceFolderOrFiles.length]; - + for (int i = 0; i < sourceFolderOrFiles.length; i++) { sourceParents[i] = sourceFolderOrFiles[i].getParentPath(); @@ -805,7 +806,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe return service.copyBatch(sourceParents, sourceNames, targetFolder.getAbsolutePath(), monitor); } - public IRemoteFile getParentFolder(IRemoteFile folderOrFile, IProgressMonitor monitor) + public IRemoteFile getParentFolder(IRemoteFile folderOrFile, IProgressMonitor monitor) { try { @@ -817,7 +818,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } } - public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws SystemMessageException + public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String parent = fileToCreate.getParentPath(); @@ -826,7 +827,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), fileToCreate.getParentRemoteFile(), newFile); } - public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException + public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String parent = folderToCreate.getParentPath(); @@ -835,12 +836,12 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), folderToCreate.getParentRemoteFile(), newFolder); } - public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException + public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException { return createFolder(folderToCreate, monitor); } - public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException + public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String parent = folderOrFile.getParentPath(); @@ -849,10 +850,10 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe folderOrFile.markStale(true); return result; } - - public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException + + public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException { - + String[] parents = new String[folderOrFiles.length]; String[] names = new String[folderOrFiles.length]; for (int i = 0; i < folderOrFiles.length; i++) @@ -867,7 +868,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe return service.deleteBatch(parents, names, monitor); } - public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException + public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException { removeCachedRemoteFile(folderOrFile); IFileService service = getFileService(); @@ -878,8 +879,8 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe folderOrFile.getHostFile().renameTo(newPath); return result; } - - public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException + + public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String srcParent = sourceFolderOrFile.getParentPath(); @@ -892,21 +893,21 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe return result; } - public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException + public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException { String name = folderOrFile.getName(); String parent = folderOrFile.getParentPath(); return _hostFileService.setLastModified(parent, name, newDate, monitor); } - public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException + public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException { String name = folderOrFile.getName(); String parent = folderOrFile.getParentPath(); return _hostFileService.setReadOnly(parent, name, readOnly, monitor); } - public ILanguageUtilityFactory getLanguageUtilityFactory() + public ILanguageUtilityFactory getLanguageUtilityFactory() { if (_languageUtilityFactory == null) { @@ -914,13 +915,13 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } return _languageUtilityFactory; } - + public void setLanguageUtilityFactory(ILanguageUtilityFactory factory) { _languageUtilityFactory = factory; } - - public void search(IHostSearchResultConfiguration searchConfig) + + public void search(IHostSearchResultConfiguration searchConfig) { ISearchService searchService = getSearchService(); if (searchService != null) @@ -930,7 +931,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe } } - public void cancelSearch(IHostSearchResultConfiguration searchConfig) + public void cancelSearch(IHostSearchResultConfiguration searchConfig) { ISearchService searchService = getSearchService(); if (searchService != null) @@ -938,7 +939,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe searchService.cancelSearch(searchConfig, null); } } - + public IHostSearchResultConfiguration createSearchConfiguration(IHostSearchResultSet resultSet, Object searchTarget, SystemSearchString searchString) { ISearchService searchService = getSearchService(); @@ -946,7 +947,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { IFileServiceSubSystemConfiguration factory = (IFileServiceSubSystemConfiguration)getParentRemoteFileSubSystemConfiguration(); if (factory != null) - { + { return factory.createSearchConfiguration(getHost(), resultSet, searchTarget, searchString); } } @@ -982,7 +983,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe { return IFileService.class; } - + public void initializeSubSystem(IProgressMonitor monitor) { super.initializeSubSystem(monitor); @@ -991,9 +992,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe public void uninitializeSubSystem(IProgressMonitor monitor) { - super.uninitializeSubSystem(monitor); getFileService().uninitService(monitor); _userHome = null; + super.uninitializeSubSystem(monitor); } /** @@ -1003,22 +1004,22 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe public String getRemoteEncoding() { try { - + IHost host = getHost(); - + // get the encoding from the host that was not set by the remote system String encoding = host.getDefaultEncoding(false); - + // get the encoding from the host that was set by querying a remote system // this allows us to pick up the host encoding that may have been set by another subsystem if (encoding == null) { encoding = getFileService().getEncoding(null); - + if (encoding != null) { host.setDefaultEncoding(encoding, true); } } - + if (encoding != null) { return encoding; } @@ -1029,7 +1030,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe catch (SystemMessageException e) { SystemBasePlugin.logMessage(e.getSystemMessage()); } - + return super.getRemoteEncoding(); } @@ -1046,18 +1047,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe * @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { - return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); + return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); } public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException { - return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, options, monitor), remoteParent, remoteFile, this); + return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, options, monitor), remoteParent, remoteFile, this); } - + /** * Defers to the file service. */ public boolean supportsEncodingConversion(){ return getFileService().supportsEncodingConversion(); } - + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java index ec698561344..d391378151b 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java @@ -7,16 +7,16 @@ * * 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, + * 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) - Fix 162962 - recursive removeCachedRemoteFile() * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem - * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * David McKnight (IBM) - [196664] prevent unnecessary query on the parent * Rupen Mardirossian (IBM) - [204307] listFolders now deals with a null parameter for fileNameFilter preventing NPE @@ -25,6 +25,7 @@ * David McKnight (IBM) - [211472] [api][breaking] IRemoteObjectResolver.getObjectWithAbsoluteName() needs a progress monitor * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -49,6 +50,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilterReference; @@ -87,7 +89,7 @@ import org.eclipse.ui.dialogs.PropertyPage; /** * Specialization for file subsystem factories. - * It is subclassed via use of a Rose model and MOF/EMF, or better yet + * It is subclassed via use of a Rose model and MOF/EMF, or better yet * by subclassing {@link FileServiceSubSystem}. *

* For your convenience, there is built-in name filtering support. To use it, @@ -96,7 +98,7 @@ import org.eclipse.ui.dialogs.PropertyPage; *

  • {@link #setListValues(int, String)} or {@link #setListValues(int, String, String)} to set the filter criteria *
  • {@link #accept(String, boolean)} to test a given name for a match * - * + * *

    This class returns instances of {@link RemoteFile} objects. */ @@ -115,10 +117,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi protected RemoteFileContext DEFAULT_CONTEXT_NOFILTERSTRING = null; protected ArrayList _searchHistory; - + // all created IRemoteFiles mapped in cache to quick retrieval protected HashMap _cachedRemoteFiles = new HashMap(); - + /** * Default constructor. Do not call directly! Rather, use the mof generated factory method to create. * After instantiation, be sure to call {@link #setSubSystemConfiguration(ISubSystemConfiguration)}. @@ -136,7 +138,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { return true; } - + /** * Return parent subsystem factory, cast to a RemoteFileSubSystemConfiguration * Assumes {@link #setSubSystemConfiguration(ISubSystemConfiguration)} has already been called. @@ -192,7 +194,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi // -------------------------------- // FILE SYSTEM ATTRIBUTE METHODS... - // -------------------------------- + // -------------------------------- /** * Return in string format the character used to separate folders. Eg, "\" or "/". *
    @@ -206,7 +208,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * Return in character format the character used to separate folders. Eg, "\" or "/" *
    * Shortcut to {@link #getParentRemoteFileSubSystemConfiguration()}.getSeparatorChar() - */ + */ public char getSeparatorChar() { return getParentRemoteFileSubSystemConfiguration().getSeparatorChar(); @@ -215,7 +217,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * Return in string format the character used to separate paths. Eg, ";" or ":" *
    * Shortcut to {@link #getParentRemoteFileSubSystemConfiguration()}.getPathSeparator() - */ + */ public String getPathSeparator() { return getParentRemoteFileSubSystemConfiguration().getPathSeparator(); @@ -224,7 +226,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * Return in char format the character used to separate paths. Eg, ";" or ":" *
    * Shortcut to {@link #getParentRemoteFileSubSystemConfiguration()}.getPathSeparatorChar() - */ + */ public char getPathSeparatorChar() { return getParentRemoteFileSubSystemConfiguration().getPathSeparatorChar(); @@ -237,15 +239,15 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi public String getLineSeparator() { return getParentRemoteFileSubSystemConfiguration().getLineSeparator(); - } + } // ------------------------------------- - // GUI methods + // GUI methods // ------------------------------------- /** * Return the single property page to show in the tabbed notebook for the - * for SubSystem property of the parent Connection. Return null if no + * for SubSystem property of the parent Connection. Return null if no * page is to be contributed for this. You are limited to a single page, * so you may have to compress. It is recommended you prompt for the port * if applicable since the common base subsystem property page is not shown @@ -259,28 +261,28 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi // ------------------------- // Filter Testing Methods... // ------------------------- - + /** * @see org.eclipse.rse.core.subsystems.SubSystem#doesFilterMatch(org.eclipse.rse.core.filters.ISystemFilter, java.lang.String) */ public boolean doesFilterMatch(ISystemFilter filter, String remoteObjectAbsoluteName) { - + if (filter.isPromptable() || !doesFilterTypeMatch(filter, remoteObjectAbsoluteName)) { return false; } - + boolean would = false; String[] strings = filter.getFilterStrings(); - + if (strings != null) { - + for (int idx = 0; !would && (idx < strings.length); idx++) { - + // for "Drives" filter on Windows, only return match if the absolute path is a drive letter if (strings[idx].equals("*")) { //$NON-NLS-1$ IPath path = new Path(remoteObjectAbsoluteName); - + if (path.segmentCount() == 0) { return true; } @@ -296,12 +298,12 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } } } - + return would; } /** - * Return true if the given remote object name will pass the filtering criteria for + * Return true if the given remote object name will pass the filtering criteria for * the given filter string. *

    * Subclasses need to override this. @@ -328,24 +330,24 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi String container = rffs.getPath(); if (container == null) return false; - + if (container.equals(".")) //$NON-NLS-1$ { - try + try { container = getRemoteFileObject(container, new NullProgressMonitor()).getAbsolutePath(); } catch (Exception e) { - + } - //return true; + //return true; } - + // DKM - if the filter and the remote object are the same if (container.equals(remoteObjectAbsoluteName)) return true; - + // trick: use filter string code to parse remote absolute name RemoteFileFilterString rmtName = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration(), remoteObjectAbsoluteName); boolean pathMatch = false; @@ -376,7 +378,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi /** * Return true if the given filter string lists the contents of the given remote object. * For example, if given a folder, return true if the given filter string - * lists the contents of that folder. Used in impact analysis when a remote object is + * lists the contents of that folder. Used in impact analysis when a remote object is * created, deleted, renamed, copied or moved, so as to establish which filters need to be * refreshed or collapsed (if the folder is deleted, say). *

    @@ -389,11 +391,11 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { RemoteFileFilterString rffs = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration(), filterString.getString()); String container = rffs.getPath(); - + if (container == null) return false; boolean affected = false; - + String remoteObjectContainer = remoteObjectAbsoluteName; int lastSep = remoteObjectAbsoluteName.lastIndexOf(getSeparator()); if (lastSep != -1) @@ -410,7 +412,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi // "Univ Filter String Testing '" + container + "' versus '" + remoteObjectAbsoluteName + "' => " + affected); return affected; } - + // ------------------------------- @@ -434,15 +436,15 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException { - + if (!isConnected()) { return null; } - + Object[] children = null; Vector vChildren = new Vector(); Vector vMessages = new Vector(); - + boolean oneSuccess = false; boolean success = false; if (filterStrings == null) @@ -451,27 +453,27 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi System.out.println("connection == "+getHostAliasName()); //$NON-NLS-1$ return null; } - + // TODO - change this to use listMulti to be more efficient for (int idx=0; idx * Can be used to filter out redundant entries in the concatenated list, if this * is desired. @@ -591,7 +593,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } } - + private String fixFilterString(IRemoteFileSubSystemConfiguration rfssf, String filterString) { boolean windows = !rfssf.isUnixStyle(); @@ -604,10 +606,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi else filterString = filterString.substring(1); } - + return filterString; } - + /** * Actually resolve an absolute filter string. This is called by the * run(IProgressMonitor monitor) method, which in turn is called by resolveFilterString. @@ -617,7 +619,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { IRemoteFileSubSystemConfiguration rfssf = getParentRemoteFileSubSystemConfiguration(); filterString = fixFilterString(rfssf, filterString); - + RemoteFileFilterString fs = new RemoteFileFilterString(rfssf, filterString); currFilterString = fs; @@ -629,11 +631,11 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi boolean showFiles = fs.getShowFiles(); String path = fs.getPath(); boolean windows = !rfssf.isUnixStyle(); - + if (windows && (path != null) && !path.endsWith(rfssf.getSeparator())) path = path + rfssf.getSeparatorChar(); - - String filter = fs.getFileOrTypes(); + + String filter = fs.getFileOrTypes(); IRemoteFile parent = null; try { @@ -643,9 +645,9 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { SystemBasePlugin.logError("RemoteFileSubSystemImpl.logError()", e); //$NON-NLS-1$ } - + boolean parentExists = true; - + if (parent != null) { parentExists = parent.exists(); } @@ -660,20 +662,20 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi boolean hasFolderContents = !parent.isStale() && parent.hasContents(RemoteFolderChildrenContentsType.getInstance(), filter); boolean hasFileAndFolderContents = !parent.isStale() && parent.hasContents(RemoteChildrenContentsType.getInstance(), filter); if (showDirs && showFiles) - { - if (hasFileAndFolderContents) + { + if (hasFileAndFolderContents) { // has everything } else if (hasFileContents) { // already have the files, now add the folders - list(parent, filter, IFileService.FILE_TYPE_FOLDERS, monitor); + list(parent, filter, IFileService.FILE_TYPE_FOLDERS, monitor); } else if (hasFolderContents) { // already have the folders, now add the files - list(parent, filter, IFileService.FILE_TYPE_FILES, monitor); + list(parent, filter, IFileService.FILE_TYPE_FILES, monitor); } else { @@ -709,7 +711,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi else if (parent != null && !parentExists) { children = new SystemMessageObject[1]; String msgTxt = NLS.bind(SystemFileResources.FILEMSG_FILE_NOTFOUND, parent.getAbsolutePath()); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ISystemFileMessageIds.FILEMSG_FILE_NOTFOUND, IStatus.ERROR, msgTxt); children[0] = new SystemMessageObject(msg, ISystemMessageObject.MSGTYPE_ERROR, null); @@ -822,7 +824,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } return internalResolveOneFilterString(parent, fs, true, monitor); } - + catch (SystemMessageException e) { SystemMessageObject[] children = new SystemMessageObject[1]; @@ -843,7 +845,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi //String path = fs.getPath(); //String filter = fs.getFile(); //System.out.println("...path='"+path+"', filter='"+filter+"', showDirs="+showDirs+", showFiles="+showFiles); - //System.out.println("...toStringNoSwitches='"+filterString+"'"); + //System.out.println("...toStringNoSwitches='"+filterString+"'"); Object[] children = null; if (parent != null) { @@ -875,7 +877,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi return listRoots(getDefaultContext(), monitor); } - + /** * Return a list of all remote folders and files in the given folder. The list is not subsetted. * @param parents The parent folders to list folders and files in @@ -889,10 +891,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$ } - + return listMultiple(parents, fileNameFilters, fileTypes, monitor); } - + /** * Return a list of all remote folders and files in the given folder. The list is not subsetted. * @param parents The parent folders to list folders and files in @@ -906,10 +908,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$ } - + return listMultiple(parents, fileNameFilters, fileType, monitor); } - + /** * Return a list of all remote folders and files in the given folder. The list is not subsetted. * @param parent The parent folder to list folders and files in @@ -919,7 +921,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { return list(parent, IFileService.FILE_TYPE_FILES_AND_FOLDERS, monitor); } - + /** * Return a list of all remote folders and files in the given folder. The list is not subsetted. * @param parent The parent folder to list folders and files in @@ -932,10 +934,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } /** - * Return a list of remote folders and files in the given folder. + * Return a list of remote folders and files in the given folder. *

    * The files part of the list is subsetted by the given file name filter. It can be null for no subsetting. - * + * * @param parent The parent folder to list folders and files in * @param fileNameFilter The name pattern to subset the file list by, or null to return all files. * @param fileType the type of file @@ -952,7 +954,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi RemoteFileContext context = new RemoteFileContext(this, parent, filterString); return list(parent, fileNameFilter, context, fileType, monitor); } - + /** @@ -968,29 +970,29 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getRemoteSearchResultObject(java.lang.String) */ public IRemoteSearchResult getRemoteSearchResultObject(String key) throws SystemMessageException { - + int idx = key.indexOf(IHostSearchResult.SEARCH_RESULT_DELIMITER); - + if (idx != -1) { String remoteFilePath = key.substring(0, idx); IRemoteFile remoteFile = getRemoteFileObject(remoteFilePath, new NullProgressMonitor()); - + if (remoteFile != null) { - + int jdx = idx + IHostSearchResult.SEARCH_RESULT_DELIMITER.length() + IHostSearchResult.SEARCH_RESULT_OPEN_DELIMITER.length(); - + int kdx = key.indexOf(IHostSearchResult.SEARCH_RESULT_INDEX_DELIMITER, jdx); - + String searchString = key.substring(jdx, kdx); - + Object[] children = remoteFile.getContents(RemoteSearchResultsContentsType.getInstance(), searchString); - + if (children != null) { - + int ldx = key.indexOf(IHostSearchResult.SEARCH_RESULT_CLOSE_DELIMITER, kdx+1); - + int index = Integer.valueOf(key.substring(kdx+1, ldx)).intValue(); - + if (children.length > index) { IRemoteSearchResult result = (IRemoteSearchResult)(children[index]); return result; @@ -1010,8 +1012,8 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi else { return null; } - } - + } + /** * Overrideable Override this method to provide optimized implementation * Given a set of fully qualified file or folder names, return an ISystemResourceSet object for it. @@ -1027,30 +1029,17 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } return results; } - + /** - * Return the object within the subsystem that corresponds to - * the specified unique ID. + * Return the object within the subsystem that corresponds to the specified + * unique ID. * - * For remote files, assuming the key is the absolute path of - * a file, this is simply a wrapper to getRemoteFileObject(). - * - * @see SubSystem#getObjectWithAbsoluteName(String) - * @param monitor the progress monitor - * @param key the unique id of the remote object. - * Must not be null. - * @return the remote object instance, or null if no - * object is found with the given id. - * @throws Exception in case an error occurs contacting the remote - * system while retrieving the requested remote object. - * Extenders are encouraged to throw {@link SystemMessageException} - * in order to support good user feedback in case of errors. - * Since exceptions should only occur while retrieving new - * remote objects during startup, clients are typically allowed - * to ignore these exceptions and treat them as if the remote - * object were simply not there. + * For remote files, assuming the key is the absolute path of a file, this + * is simply a wrapper to getRemoteFileObject(). + * + * @see SubSystem#getObjectWithAbsoluteName(String, IProgressMonitor) */ public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception { @@ -1062,9 +1051,9 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi // look to see if there is a search result delimiter // if not, the key must be for a file if (key.lastIndexOf(IHostSearchResult.SEARCH_RESULT_DELIMITER) < 0) { - + IRemoteFile remoteFile = getRemoteFileObject(key, monitor); - + if (remoteFile != null) { return remoteFile; } @@ -1084,12 +1073,12 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi - - + + @@ -1236,18 +1225,22 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { } return rc; - } // end runCmd method + } // end runCmd method public void initializeSubSystem(IProgressMonitor monitor) { + super.initializeSubSystem(monitor); + // load UI plugin for adapters right after successful connect + Platform.getAdapterManager().loadAdapter(new RemoteFileEmpty(), "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ getConnectorService().addCommunicationsListener(this); } - + public void uninitializeSubSystem(IProgressMonitor monitor) { getConnectorService().removeCommunicationsListener(this); + super.uninitializeSubSystem(monitor); } - + /** * Store the IRemoteFile in a hashmap to quick subsequent retrieval * @param file the file @@ -1264,7 +1257,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi _cachedRemoteFiles.put(path, file); return; } - + // replace file under parent if (oldFile instanceof RemoteFile) { RemoteFile roldFile = (RemoteFile)oldFile; @@ -1276,11 +1269,11 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi else if (oldFile != null && oldFile.getParentRemoteFile() != null) { oldFile.getParentRemoteFile().replaceContent(oldFile, file); } - + // preserve persistent information from old file to new if (oldFile != null) oldFile.copyContentsTo(file); - + } _cachedRemoteFiles.put(path, file); } @@ -1306,7 +1299,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi { if (_cachedRemoteFiles.size() > 0) { - path = path.replaceAll("//", "/"); //$NON-NLS-1$ //$NON-NLS-2$ + path = path.replaceAll("//", "/"); //$NON-NLS-1$ //$NON-NLS-2$ if (path.endsWith("\\") || (path.endsWith("/") && path.length() > 1)) //$NON-NLS-1$ //$NON-NLS-2$ { path = path.substring(0, path.length() - 1); @@ -1314,12 +1307,12 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi if (_cachedRemoteFiles.containsKey(path)) { {return (IRemoteFile)_cachedRemoteFiles.get(path);} - } + } } return null; } - + protected void removeCachedRemoteFile(IRemoteFile file) { if (file != null) @@ -1353,24 +1346,24 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi _cachedRemoteFiles.remove(file.getAbsolutePath()); } } - + protected void removeCachedRemoteFile(String path) { _cachedRemoteFiles.remove(path); } - + public void communicationsStateChange(CommunicationsEvent e) { switch (e.getState()) { - case CommunicationsEvent.AFTER_DISCONNECT : + case CommunicationsEvent.AFTER_DISCONNECT : _cachedRemoteFiles.clear(); // DKM - taking this out because it causes an exception when the event occurs in Modal Context - //ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + //ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); //sr.connectedStatusChange(this, false, true, true); getConnectorService().removeCommunicationsListener(this); - + break; case CommunicationsEvent.BEFORE_DISCONNECT : @@ -1380,7 +1373,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi break; } } - + /** * @see ICommunicationsListener#isPassiveCommunicationsListener() */ @@ -1393,11 +1386,11 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * Returns -1 by default. Subclasses should override if necessary. * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getUnusedPort() */ - public int getUnusedPort() + public int getUnusedPort() { return -1; } - + /** * Returns the address found by calling InetAddress.getLocalHost(). If that * call returns the local loopback address, it returns null. @@ -1407,49 +1400,49 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getLocalAddress() */ public InetAddress getLocalAddress() { - + InetAddress addr = null; - + try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException e) { SystemBasePlugin.logError("Error occured trying to get local host address", e); //$NON-NLS-1$ } - - // if the address is the loopback address + + // if the address is the loopback address if (addr != null && addr.isLoopbackAddress()) { return null; } - + return addr; } - - + + public Object getTargetForFilter(ISystemFilterReference filterRef) { - String firstFilterString = filterRef.getReferencedFilter().getFilterStrings()[0]; - RemoteFileFilterString fs = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration(), firstFilterString); + String firstFilterString = filterRef.getReferencedFilter().getFilterStrings()[0]; + RemoteFileFilterString fs = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration(), firstFilterString); try { // change target to be referenced remote folder return getRemoteFileObject(fs.getPath(), new NullProgressMonitor()); } catch (Exception e) - { + { } return null; } - + /** * @deprecated */ public void cancelSearch(IHostSearchResultConfiguration searchConfig) { // TODO Auto-generated method stub - + } - + /** * Returns true by default. Subclasses should override if they do not support encodings. * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#supportsEncoding() @@ -1458,7 +1451,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi public boolean supportsEncoding() { return true; } - + /** * Returns the local platform encoding if the default encoding of the host was not set. * Subclasses should override to return the actual remote encoding. @@ -1466,16 +1459,16 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi */ public String getRemoteEncoding() { IHost host = getHost(); - + // get the encoding from the host that was not by the remote system String encoding = host.getDefaultEncoding(false); - + // get the encoding from the host that was set by querying a remote system // this allows us to pick up the host encoding that may have been set by another subsystem if (encoding == null) { encoding = host.getDefaultEncoding(true); } - + if (encoding != null) { return encoding; } diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/internal/subsystems/processes/core/Activator.java b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/internal/subsystems/processes/core/Activator.java index 4c752b5b772..33229cbb1d0 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/internal/subsystems/processes/core/Activator.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/internal/subsystems/processes/core/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008 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 @@ -13,13 +13,12 @@ * Contributors: * Martin Oberhuber (Wind River) - [180519][api] declaratively register rse.processes.ui adapter factories * Martin Oberhuber (wind River) - [203105] Decouple recursive plugin activation of UI adapters + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.internal.subsystems.processes.core; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessImpl; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -41,18 +40,6 @@ public class Activator extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); - - // make sure that required adapters factories are loaded - //(will typically activate org.eclipse.rse.processes.ui) - //TODO Check that this does not fire up the UI if we want to be headless - //Decouple from the current Thread - new Thread("processes.ui adapter loader") { //$NON-NLS-1$ - public void run() { - Platform.getAdapterManager().loadAdapter(new RemoteProcessImpl(null,null), - "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ - } - }.start(); - //others will be loaded automatically when the processes.ui plugin is activated } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemImpl.java b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemImpl.java index bc0dc526191..a4821feaaf4 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemImpl.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemImpl.java @@ -1,18 +1,19 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008s 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 + * 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, + * 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) - [182454] improve getAbsoluteName() documentation - * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.subsystems.processes.core.subsystem.impl; @@ -20,6 +21,7 @@ package org.eclipse.rse.subsystems.processes.core.subsystem.impl; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.CommunicationsEvent; import org.eclipse.rse.core.subsystems.ICommunicationsListener; @@ -35,7 +37,7 @@ import org.eclipse.rse.ui.SystemBasePlugin; /** * Default implementation of the IRemoteProcessSubSystem interface. - *

    + *

    * Some of the methods are simply convenience methods - these are * implemented here, whereas the real work takes place in the * ProcessServiceSubSystem. @@ -44,12 +46,12 @@ import org.eclipse.rse.ui.SystemBasePlugin; public abstract class RemoteProcessSubSystemImpl extends SubSystem implements IRemoteProcessSubSystem, ICommunicationsListener { - + public RemoteProcessSubSystemImpl(IHost host, IConnectorService connectorService) { super(host, connectorService); } - + /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessSubSystem#getParentRemoteProcessSubSystemConfiguration() */ @@ -65,7 +67,7 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements { return true; } - + /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#communicationsStateChange(org.eclipse.rse.core.subsystems.CommunicationsEvent) */ @@ -75,9 +77,9 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements { case CommunicationsEvent.BEFORE_CONNECT : break; - case CommunicationsEvent.AFTER_DISCONNECT : + case CommunicationsEvent.AFTER_DISCONNECT : getConnectorService().removeCommunicationsListener(this); - + break; case CommunicationsEvent.BEFORE_DISCONNECT : @@ -87,23 +89,27 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements break; } } - + /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) */ public void initializeSubSystem(IProgressMonitor monitor) { - getConnectorService().addCommunicationsListener(this); + super.initializeSubSystem(monitor); + // load UI plugin for adapters right after successful connect + Platform.getAdapterManager().loadAdapter(new RemoteProcessImpl(null, null), "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ + getConnectorService().addCommunicationsListener(this); } - + /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#uninitializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) */ public void uninitializeSubSystem(IProgressMonitor monitor) { - getConnectorService().removeCommunicationsListener(this); + getConnectorService().removeCommunicationsListener(this); + super.uninitializeSubSystem(monitor); } - + /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessSubSystem#getParentProcess(org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess) */ @@ -111,7 +117,7 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements { return process.getParentRemoteProcess(); } - + /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(org.eclipse.core.runtime.IProgressMonitor, java.lang.String) */ @@ -122,7 +128,7 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements if (!isConnected()) { return null; } - + HostProcessFilterImpl rpf = new HostProcessFilterImpl(filterString); IRemoteProcessContext context = new RemoteProcessContext(this, null, rpf); IRemoteProcess[] ps = null; @@ -134,9 +140,9 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements { displayAsyncMsg(e); } - return ps; + return ps; } - + /** * At this point there is only one root process, the 'init' process with pid 1 */ @@ -161,11 +167,12 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements { return true; } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SubSystem#getObjectWithAbsoluteName(java.lang.String) + + /* + * (non-Javadoc) + * @see SubSystem#getObjectWithAbsoluteName(String, IProgressMonitor) */ - public Object getObjectWithAbsoluteName(String key) throws Exception + public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception { try { @@ -174,7 +181,7 @@ public abstract class RemoteProcessSubSystemImpl extends SubSystem implements } catch (NumberFormatException e) { - return super.getObjectWithAbsoluteName(key); + return super.getObjectWithAbsoluteName(key, monitor); } } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/servicesubsystem/ProcessServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/servicesubsystem/ProcessServiceSubSystem.java index 17809ebb3d6..e9c980363f2 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/servicesubsystem/ProcessServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/servicesubsystem/ProcessServiceSubSystem.java @@ -1,21 +1,22 @@ /******************************************************************************** * Copyright (c) 2006, 2008 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 + * 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, + * 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) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * David Dykstal (IBM) - [197036] refactored switch configuration * David Dykstal (IBM) - [217556] remove service subsystem types * David McKnight (IBM) - [220524] internalSwitchServiceSubSystemConfiguration -> internalSwitchSubSystemConfiguration + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.subsystems.processes.servicesubsystem; @@ -40,18 +41,18 @@ import org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSub * The subsystem that, coupled with a ProcessService implementation, * can query and kill remote processes on a remote system. */ -public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implements IProcessServiceSubSystem +public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implements IProcessServiceSubSystem { protected IProcessService _hostProcessService; protected IHostProcessToRemoteProcessAdapter _hostProcessToRemoteProcessAdapter; - + public ProcessServiceSubSystem(IHost host, IConnectorService connectorService, IProcessService hostProcessService, IHostProcessToRemoteProcessAdapter adapter) { super(host, connectorService); _hostProcessService = hostProcessService; _hostProcessToRemoteProcessAdapter = adapter; } - + /** * @return the process service associated with this subsystem. */ @@ -68,7 +69,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen { _hostProcessService = service; } - + /** * @return the associated adapter for converting IHostProcess objects to IRemoteProcess objects */ @@ -76,7 +77,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen { return _hostProcessToRemoteProcessAdapter; } - + /** * Sets the associated adapter for converting IHostProcess objects to IRemoteProcess objects */ @@ -90,7 +91,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen * certain pid. * @param pid The pid of the process to return */ - public IRemoteProcess getRemoteProcessObject(long pid) throws SystemMessageException + public IRemoteProcess getRemoteProcessObject(long pid) throws SystemMessageException { checkIsConnected(new NullProgressMonitor()); HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); @@ -103,7 +104,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#getSignalTypes() */ - public String[] getSignalTypes() throws SystemMessageException + public String[] getSignalTypes() throws SystemMessageException { return getProcessService().getSignalTypes(); } @@ -111,7 +112,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#kill(org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess, java.lang.String) */ - public boolean kill(IRemoteProcess process, String signal) throws SystemMessageException + public boolean kill(IRemoteProcess process, String signal) throws SystemMessageException { checkIsConnected(new NullProgressMonitor()); return getProcessService().kill(process.getPid(), signal, null); @@ -120,7 +121,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#listAllProcesses(org.eclipse.rse.services.clientserver.processes.IHostProcessFilter, org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessContext) */ - public IRemoteProcess[] listAllProcesses(IHostProcessFilter processFilter, IRemoteProcessContext context, IProgressMonitor monitor) throws InterruptedException, SystemMessageException + public IRemoteProcess[] listAllProcesses(IHostProcessFilter processFilter, IRemoteProcessContext context, IProgressMonitor monitor) throws InterruptedException, SystemMessageException { checkIsConnected(monitor); IHostProcess[] processes = getProcessService().listAllProcesses(processFilter, monitor); @@ -150,21 +151,21 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#internalSwitchSubSystemConfiguration(org.eclipse.rse.core.subsystems.ISubSystemConfiguration) */ - protected void internalSwitchSubSystemConfiguration(ISubSystemConfiguration configuration) + protected void internalSwitchSubSystemConfiguration(ISubSystemConfiguration configuration) { IProcessServiceSubSystemConfiguration config = (IProcessServiceSubSystemConfiguration) configuration; IHost host = getHost(); setProcessService(config.getProcessService(host)); setHostProcessToRemoteProcessAdapter(config.getHostProcessAdapter()); } - + /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#canSwitchTo(org.eclipse.rse.core.subsystems.ISubSystemConfiguration) */ public boolean canSwitchTo(ISubSystemConfiguration configuration) { return configuration instanceof IProcessServiceSubSystemConfiguration; } - + /* (non-Javadoc) * @see org.eclipse.rse.core.servicesubsystem.ISubSystem#getServiceType() */ @@ -172,7 +173,7 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen { return IProcessService.class; } - + /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) */ @@ -181,14 +182,14 @@ public class ProcessServiceSubSystem extends RemoteProcessSubSystemImpl implemen super.initializeSubSystem(monitor); getProcessService().initService(monitor); } - + /* (non-Javadoc) * @see org.eclipse.rse.subsystems.processes.core.subsystem.impl.RemoteProcessSubSystemImpl#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) */ public void uninitializeSubSystem(IProgressMonitor monitor) { - super.uninitializeSubSystem(monitor); getProcessService().uninitService(monitor); + super.uninitializeSubSystem(monitor); } - + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/core/Activator.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/core/Activator.java index 00377a0c3a2..4fa76186599 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/core/Activator.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/core/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008 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 @@ -13,13 +13,12 @@ * Contributors: * Martin Oberhuber (Wind River) - [180519] declaratively register rse.shells.ui. adapter factories * Martin Oberhuber (wind River) - [203105] Decouple recursive plugin activation of UI adapters + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.internal.subsystems.shells.core; -import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.subsystems.shells.core.model.RemoteOutput; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -43,18 +42,6 @@ public class Activator extends AbstractUIPlugin { */ public void start(BundleContext context) throws Exception { super.start(context); - - // make sure that required adapters factories are loaded - //(will typically activate org.eclipse.rse.shells.ui) - //TODO Check that this does not fire up the UI if we want to be headless - //Decouple from the current Thread - new Thread("shells.ui adapter loader") { //$NON-NLS-1$ - public void run() { - Platform.getAdapterManager().loadAdapter(new RemoteOutput(null,""), "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }.start(); - // Others (IRemoteError, ShellServiceSubSystemConfigurationAdapter - // will be available automatically once the shells.ui plugin is loaded } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java index 4bfb8a7b947..69ffd7cdb87 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java @@ -7,17 +7,18 @@ * * 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, + * 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) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() + * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.subsystems.shells.core.subsystems; @@ -30,6 +31,7 @@ import java.util.StringTokenizer; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.events.ISystemResourceChangeEvents; @@ -43,6 +45,7 @@ import org.eclipse.rse.core.subsystems.CommunicationsEvent; import org.eclipse.rse.core.subsystems.ICommunicationsListener; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.IRemoteSystemEnvVar; +import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.SubSystem; import org.eclipse.rse.internal.subsystems.shells.core.ShellStrings; import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteSystemEnvVar; @@ -50,6 +53,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.subsystems.shells.core.model.RemoteOutput; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -63,7 +67,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { private static String COMMAND_SHELLS_MEMENTO = "commandshells"; //$NON-NLS-1$ private static String ENVIRONMENT_VARS = "EnvironmentVariables"; //$NON-NLS-1$ - + protected ArrayList _cmdShells; protected IRemoteCommandShell _defaultShell; @@ -76,6 +80,12 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd _cmdShells = new ArrayList(); } + public void initializeSubSystem(IProgressMonitor monitor) { + super.initializeSubSystem(monitor); + // load UI plugin for adapters right after successful connect + Platform.getAdapterManager().loadAdapter(new RemoteOutput(null, ""), "org.eclipse.rse.ui.view.ISystemViewElementAdapter"); //$NON-NLS-1$ //$NON-NLS-2$ + } + /** * Return parent subsystem factory, cast to a RemoteCmdSubSystemConfiguration */ @@ -87,7 +97,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Long running list processing calls this method to check for a user-cancel * event. If user did cancel, an exception is thrown. - * + * * @return true if caller wants to cancel */ public boolean checkForCancel(IProgressMonitor monitor) @@ -95,7 +105,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd if ((monitor != null) && monitor.isCanceled()) { String msgTxt = NLS.bind(ShellStrings.MSG_CONNECT_FAILED, getHostName()); - + throw new OperationCanceledException(msgTxt); } return false; @@ -207,7 +217,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd } /** - * + * */ protected String[] getEnvVarsAsStringArray() { IPropertySet environmentVariables = getEnvironmentVariables(); @@ -303,9 +313,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Lists the possible commands for the given context - * - * @param context - * the context for a command + * + * @param context the context for a command * @return the list of possible commands */ public ICandidateCommand[] getCandidateCommands(Object context) @@ -362,7 +371,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd * This default implementation just returns "=" (the only invalid character * is the = sign.) Subclasses can override this to provide a more * comprehensive list. - * + * * @see org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem#getInvalidEnvironmentVariableNameCharacters() */ public String getInvalidEnvironmentVariableNameCharacters() @@ -388,7 +397,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd * Actually resolve an absolute filter string. This is called by the * run(IProgressMonitor monitor) method, which in turn is called by * resolveFilterString. - * + * * @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(String,IProgressMonitor) */ protected Object[] internalResolveFilterString(String filterString, IProgressMonitor monitor) @@ -413,7 +422,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Get the default running command shell for this command subsystem. If no * such shell exists or is running, a new one is launched. - * + * * @return the default running command shell */ public IRemoteCommandShell getDefaultShell() throws Exception @@ -432,7 +441,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Get all command shells and transient commands that have been run or are * running for this command subsystem. - * + * * @return the list of running command shells and commands */ public IRemoteCommandShell[] getShells() @@ -447,7 +456,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Determine whether the command subsystem can run a shell - * + * * @return whether a shell can be run or not */ public boolean canRunShell() @@ -457,7 +466,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Determine whether the command subsystem can run a command - * + * * @return whether a command can be run or not */ public boolean canRunCommand() @@ -466,25 +475,13 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd } /** - * Return the object within the subsystem that corresponds to the - * specified unique ID. - * For remote command, the key is determined by the command ID - * and the ouput ID. - * - * @param key the unique id of the remote object. - * Must not be null. - * @return the remote object instance, or null if no - * object is found with the given id. - * @throws Exception in case an error occurs contacting the remote - * system while retrieving the requested remote object. - * Extenders are encouraged to throw {@link SystemMessageException} - * in order to support good user feedback in case of errors. - * Since exceptions should only occur while retrieving new - * remote objects during startup, clients are typically allowed - * to ignore these exceptions and treat them as if the remote - * object were simply not there. + * Return the object within the subsystem that corresponds to the specified + * unique ID. For remote command, the key is determined by the command ID + * and the output ID. + * + * @see ISubSystem#getObjectWithAbsoluteName(String, IProgressMonitor) */ - public Object getObjectWithAbsoluteName(String key) throws Exception + public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception { String cmdKey = key; String outKey = null; @@ -515,7 +512,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd return theCmd; } //fallback to return filter reference or similar - return super.getObjectWithAbsoluteName(key); + return super.getObjectWithAbsoluteName(key, monitor); } // called by subsystem on disconnect @@ -585,7 +582,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { this.shell = shellWindow; IRemoteCommandShell[] results = null; - + String shellStr = null; IPropertySet set = getPropertySet("Remote"); //$NON-NLS-1$ if (set != null) @@ -626,7 +623,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd public void cancelAllShells() { - + for (int i = _cmdShells.size() - 1; i >= 0; i--) { IRemoteCommandShell cmdShell = (IRemoteCommandShell) _cmdShells.get(i); @@ -650,7 +647,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd Display.getDefault().asyncExec(new Refresh(this)); } - + public class Refresh implements Runnable { private RemoteCmdSubSystem _ss; @@ -659,7 +656,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd _ss = ss; } - public void run() + public void run() { ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); registry.fireEvent(new SystemResourceChangeEvent(_ss, ISystemResourceChangeEvents.EVENT_REFRESH, _ss)); @@ -677,14 +674,14 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd _cmdShell = cmdShell; } - public void run() + public void run() { ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); registry.fireEvent(new SystemResourceChangeEvent(_cmdShell, ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_REMOVED, null)); registry.fireEvent(new SystemResourceChangeEvent(_ss, ISystemResourceChangeEvents.EVENT_REFRESH, _ss)); } } - + /** * @see ICommunicationsListener#isPassiveCommunicationsListener() @@ -754,7 +751,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd } return environmentVariables; } - + public IPropertySet createPropertySet(String name) { IPropertySet result = null; if (name.equals(ENVIRONMENT_VARS)) { @@ -768,13 +765,15 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * overridden so that for universal we don't need to do in modal thread - * @deprecated + * + * @deprecated use + * {@link #runCommand(String, Object, boolean, IProgressMonitor)} */ public Object[] runCommand(String command, Object context, boolean interpretOutput) throws Exception { return internalRunCommand(command, context, interpretOutput, null); } - + /** * overridden so that for universal we don't need to do in modal thread */ @@ -785,8 +784,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * overridden so that for universal we don't need to do in modal thread - * - * @deprecated + * + * @deprecated use {@link #runShell(Object, IProgressMonitor)} */ public IRemoteCommandShell runShell(Object context) throws Exception { @@ -803,48 +802,49 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd Refresh refreshOnMain = new Refresh(this); Display.getDefault().asyncExec(refreshOnMain); - + return cmdShell; } - - - + + + /** * overridden so that for universal we don't need to do in modal thread */ public IRemoteCommandShell runShell(Object context, IProgressMonitor monitor) throws Exception { IRemoteCommandShell cmdShell = internalRunShell(context, monitor); - + Refresh refreshOnMain = new Refresh(this); Display.getDefault().asyncExec(refreshOnMain); return cmdShell; } - - + + /** * Execute a remote command. This is only applicable if the subsystem * factory reports true for supportsCommands(). - * + * * @param command Command to be executed remotely. - * @param context context of a command (i.e. working directory). null is - * valid and means to use the default context. + * @param context context of a command (i.e. working directory). + * null is valid and means to use the default + * context. * @return Array of objects that are the result of running this command. * Typically, these are messages logged by the command. - * - * @deprecated + * + * @deprecated use {@link #runCommand(String, Object, IProgressMonitor)} */ public Object[] runCommand(String command, Object context) throws Exception { return runCommand(command, context, true); } - + /** * Execute a remote command. This is only applicable if the subsystem * factory reports true for supportsCommands(). - * + * * @param command Command to be executed remotely. * @param context context of a command (i.e. working directory). null is * valid and means to use the default context. @@ -856,8 +856,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd return runCommand(command, context, true, monitor); } - - + + /** * Send a command as input to a running command shell. * @param input the command to invoke in the shell. @@ -872,7 +872,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd if (ok) { internalSendCommandToShell(input, commandObject, monitor); - } + } else SystemBasePlugin.logDebugMessage(this.getClass().getName(), "in SubSystemImpl.sendCommandToShell: isConnected() returning false!"); //$NON-NLS-1$ @@ -880,7 +880,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Cancel a shell or running command. - * + * * @param commandObject the shell or command to cancel. */ public void cancelShell(Object commandObject) throws Exception @@ -914,7 +914,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd "in SubSystemImpl.cancelShell: isConnected() returning false!"); //$NON-NLS-1$ } } - + /** * Cancel a shell or running command. * @param commandObject the shell or command to cancel. @@ -925,7 +925,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd boolean ok = true; if (!isConnected()) ok = promptForPassword(); - + if (ok) { internalCancelShell(commandObject, monitor); @@ -940,7 +940,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Remove and Cancel a shell or running command. - * + * * @param commandObject the shell or command to cancel. */ public void removeShell(Object commandObject) throws Exception @@ -988,14 +988,11 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Creates a new RunCommandJob - * - * @param cmd - * The remote command to run - * @param runContext - * The context in which to run the command - * @param runInterpret - * Whether or not to interpret results of the command as RSE - * objects + * + * @param cmd The remote command to run + * @param runContext The context in which to run the command + * @param runInterpret Whether or not to interpret results of the + * command as RSE objects */ public RunCommandJob(String cmd, Object runContext, boolean runInterpret) { @@ -1032,9 +1029,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Creates a new RunShellJob - * - * @param runContext - * the context within which the shell will be ran + * + * @param runContext the context within which the shell will be ran */ public RunShellJob(Object runContext) { @@ -1049,7 +1045,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd int totalWorkUnits = IProgressMonitor.UNKNOWN; if (!implicitConnect(false, mon, msg, totalWorkUnits)){ - + String msgTxt = NLS.bind(ShellStrings.MSG_CONNECT_FAILED, getHostName()); throw new Exception(msgTxt); } @@ -1069,9 +1065,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Constructs a new CancelShellJob - * - * @param runContext - * The context for the cancelled shell + * + * @param runContext The context for the cancelled shell */ public CancelShellJob(Object runContext) { @@ -1107,11 +1102,9 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Constructs a new SendCommandToShellJob - * - * @param cmd - * The command to send to the shell - * @param runContext - * The context in which the command is to be run + * + * @param cmd The command to send to the shell + * @param runContext The context in which the command is to be run */ public SendCommandToShellJob(String cmd, Object runContext) { @@ -1130,7 +1123,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd if (!implicitConnect(false, mon, msg, totalWorkUnits)){ String msgTxt = NLS.bind(ShellStrings.MSG_CONNECT_FAILED, getHostName()); - + throw new Exception(msgTxt); } internalSendCommandToShell(_cmd, _runContext, mon); @@ -1147,9 +1140,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd /** * Constructs a new RemoveShellJob - * - * @param runContext - * the context for the removed shell + * + * @param runContext the context for the removed shell */ public RemoveShellJob(Object runContext) { diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/servicesubsystem/ShellServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/servicesubsystem/ShellServiceSubSystem.java index c740c1411eb..47d3ffc2dec 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/servicesubsystem/ShellServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/servicesubsystem/ShellServiceSubSystem.java @@ -19,6 +19,7 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * David McKnight (IBM) - [220524] internalSwitchServiceSubSystemConfiguration -> internalSwitchSubSystemConfiguration * Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem; @@ -240,6 +241,7 @@ public final class ShellServiceSubSystem extends RemoteCmdSubSystem implements I public void initializeSubSystem(IProgressMonitor monitor) { + super.initializeSubSystem(monitor); getShellService().initService(monitor); } @@ -247,6 +249,7 @@ public final class ShellServiceSubSystem extends RemoteCmdSubSystem implements I { cancelAllShells(); getShellService().uninitService(monitor); + super.uninitializeSubSystem(monitor); } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java index 25acbebc497..d6ebd844ed4 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java @@ -7,16 +7,17 @@ * * 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, + * 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: * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util - * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread + * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -53,19 +54,19 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; * Adapter for displaying SystemFilterPool reference objects in tree views. * These are children of SubSystem objects */ -public class SystemViewFilterPoolReferenceAdapter +public class SystemViewFilterPoolReferenceAdapter extends AbstractSystemViewAdapter { protected String translatedType; //protected Object parent; - + // for reset property support //private String original_userId, original_port; // ------------------- // property descriptors // ------------------- - private static PropertyDescriptor[] propertyDescriptorArray = null; - + private static PropertyDescriptor[] propertyDescriptorArray = null; + /** * Returns any actions that should be contributed to the popup menu * for the given subsystem object. @@ -84,43 +85,48 @@ public class SystemViewFilterPoolReferenceAdapter ISystemFilterPool pool = getFilterPool(element); ISubSystemConfiguration ssFactory = getSubSystemConfiguration(pool); ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class); - - IAction[] actions = adapter.getFilterPoolActions(menu, selection, shell, menuGroup, ssFactory, pool); - if (actions != null) - { - for (int idx=0; idxOverridden from parent.
    - * Returns the subsystem that contains this object. - */ + * Returns the subsystem that contains this object. + */ public ISubSystem getSubSystem(Object element) { ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element; return (ISubSystem)ref.getProvider(); } - + /** * Returns an image descriptor for the image. More efficient than getting the image. * @param element The element for which an image is desired @@ -132,7 +138,17 @@ public class SystemViewFilterPoolReferenceAdapter ISystemFilterPoolManagerProvider provider = pool.getProvider(); if (provider != null) { ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) provider.getAdapter(ISubSystemConfigurationAdapter.class); - poolImage = adapter.getSystemFilterPoolImage(pool); + if (adapter != null) { + // Lazy Loading: Customized filter pool images will only be + // available once the bundle that declares the + // ISubSystemConfigurationAdapter has been activated. Until + // that time, a default image is shown. Clients who want + // their customized images be available earlier need to + // provision for more eager loading of their bundles at the + // right time (e.g. when expanding the SubSystem node, + // rather than when connecting). + poolImage = adapter.getSystemFilterPoolImage(pool); + } } } if (poolImage == null) { @@ -140,7 +156,7 @@ public class SystemViewFilterPoolReferenceAdapter } return poolImage; } - + private ISystemFilterPool getFilterPool(Object element) { ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element; @@ -161,7 +177,7 @@ public class SystemViewFilterPoolReferenceAdapter } return result; } - + /** * Return the name of this object, which may be different than the display text ({#link #getText(Object)}. *

    @@ -171,14 +187,14 @@ public class SystemViewFilterPoolReferenceAdapter { return getFilterPool(element).getName(); } - + /* * (non-Javadoc) * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object) */ public String getAbsoluteName(Object element) { - //TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change + //TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change ISystemFilterPoolReference filterPoolRef = (ISystemFilterPoolReference)element; ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider(); ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem); @@ -188,7 +204,7 @@ public class SystemViewFilterPoolReferenceAdapter String absoluteName = parentAbsoluteName + "." + managerName + "." + referenceName; //$NON-NLS-1$ //$NON-NLS-2$ return absoluteName; } - + /** * Return the type label for this object */ @@ -197,8 +213,8 @@ public class SystemViewFilterPoolReferenceAdapter if (translatedType == null) translatedType = SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_TYPE_VALUE; return translatedType; - } - + } + /** * Return the parent of this object */ @@ -206,8 +222,8 @@ public class SystemViewFilterPoolReferenceAdapter { ISystemFilterPoolReference fpr = (ISystemFilterPoolReference)element; return SubSystemHelpers.getParentSubSystem(fpr); - } - + } + /** * Return the children of this object. * For filter pools, this is a list of filters. @@ -218,7 +234,7 @@ public class SystemViewFilterPoolReferenceAdapter ISubSystem ss = getSubSystem(element); return fpRef.getSystemFilterReferences(ss); } - + /** * Return true if this object has children */ @@ -233,7 +249,7 @@ public class SystemViewFilterPoolReferenceAdapter } return count > 0; } - + // Property sheet descriptors defining all the properties we expose in the Property Sheet /** * Return our unique property descriptors @@ -253,7 +269,7 @@ public class SystemViewFilterPoolReferenceAdapter // Related connection propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP); - } + } return propertyDescriptorArray; } /** @@ -261,7 +277,7 @@ public class SystemViewFilterPoolReferenceAdapter */ protected Object internalGetPropertyValue(Object key) { - String name = (String)key; + String name = (String)key; //SystemFilterPoolReference ref = getFilterPoolReference(propertySourceInput); ISystemFilterPool pool = getFilterPool(propertySourceInput); if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL)) @@ -269,22 +285,22 @@ public class SystemViewFilterPoolReferenceAdapter else if (name.equals(ISystemPropertyConstants.P_PROFILE)) return pool.getSystemFilterPoolManager().getName(); else if (name.equals(ISystemPropertyConstants.P_RELATED_CONNECTION)) - return (pool.getOwningParentName()==null) ? getTranslatedNotApplicable() : pool.getOwningParentName(); + return (pool.getOwningParentName()==null) ? getTranslatedNotApplicable() : pool.getOwningParentName(); else return null; - } - + } + // FOR COMMON DELETE ACTIONS /** * Return true if this object is deletable by the user. If so, when selected, * the Edit->Delete menu item will be enabled. */ public boolean canDelete(Object element) - { - ISystemFilterPool fp = getFilterPool(element); + { + ISystemFilterPool fp = getFilterPool(element); return fp.isDeletable(); } - + /** * Perform the delete action. * This physically deletes the filter pool and all references. @@ -294,24 +310,24 @@ public class SystemViewFilterPoolReferenceAdapter ISystemFilterPool fp = getFilterPool(element); ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager(); fpMgr.deleteSystemFilterPool(fp); - //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp); + //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp); //ssParentFactory.deleteFilterPool(fp); return true; } - + // FOR COMMON RENAME ACTIONS /** * Return true if this object is renamable by the user. If so, when selected, * the Rename menu item will be enabled. */ public boolean canRename(Object element) - { + { if (!canDelete(element)) return false; ISystemFilterPool fp = getFilterPool(element); return !fp.isNonRenamable(); } - + /** * Perform the rename action. Assumes uniqueness checking was done already. */ @@ -320,10 +336,10 @@ public class SystemViewFilterPoolReferenceAdapter ISystemFilterPool fp = getFilterPool(element); ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager(); fpMgr.renameSystemFilterPool(fp,name); - //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp); + //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp); //ssParentFactory.renameFilterPool(fp,name); return true; - } + } /** * Return a validator for verifying the new name is correct. */ @@ -340,7 +356,7 @@ public class SystemViewFilterPoolReferenceAdapter String[] names = mgr.getSystemFilterPoolNames(); ISystemValidator nameValidator = new ValidatorFilterPoolName(names); return nameValidator; - } + } /** * Parent override. *

    @@ -390,7 +406,7 @@ public class SystemViewFilterPoolReferenceAdapter /** * This is a local RSE artifact so returning false - * + * * @param element the object to check * @return false since this is not remote */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java index aa1f027218a..0aa070064ec 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java @@ -7,10 +7,10 @@ * * 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, + * 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: * David Dykstal (IBM) - moved SystemsPreferencesManager to a new package * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references @@ -19,12 +19,13 @@ * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed + * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core * Kevin Doyle (IBM) - [187707] Added separator between New Folder and New File in context menu * David McKnight (IBM) - [199566] Remove synchronzied from internalGetChildren * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread * David McKnight (IBM) - [210563] error messages need to be shown if incurred during filter expansion + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -85,15 +86,15 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; * Adapter for displaying SystemFilterReference objects in tree views. * These are children of SystemFilterPoolReference and SystemFilterReference objects */ -public class SystemViewFilterReferenceAdapter +public class SystemViewFilterReferenceAdapter extends AbstractSystemViewAdapter { - //private static String translatedFilterString = null; + //private static String translatedFilterString = null; // ------------------- - // property descriptors + // property descriptors // ------------------- private static PropertyDescriptor[] propertyDescriptorArray = null; - //private SystemComboBoxPropertyDescriptor filterStringsDescriptor, filtersDescriptor; + //private SystemComboBoxPropertyDescriptor filterStringsDescriptor, filtersDescriptor; /** * Returns any actions that should be contributed to the popup menu @@ -113,26 +114,34 @@ public class SystemViewFilterReferenceAdapter IHost currentConnection = currentSubSystem.getHost(); ssFactory.setConnection(currentConnection); ssFactory.setCurrentSelection(selection.toArray()); - ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class); - - IAction[] actions = adapter.getFilterActions(menu, selection, shell, menuGroup, ssFactory, filter); - if (actions != null) - { - for (int idx = 0; idx < actions.length; idx++) + ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class); + if (adapter != null) { + // Lazy Loading: Specialized actions on filters are available only + // after the bundle that declares the ISubSystemConfigurationAdapter + // has been loaded, which typically is after connecting. We do not + // load the bundle here because this code is executed as part of + // showing a context menu. Subsystems who want their actions to be + // available earlier need to provide them by static plugin.xml + // markup or provision for more eager loading of their bundle, e.g. + // through Platform.getAdapterManager().loadAdapter() at the right + // time. + IAction[] actions = adapter.getFilterActions(menu, selection, shell, menuGroup, ssFactory, filter); + if (actions != null) { - IAction action = actions[idx]; - if (action instanceof SystemNewFilterAction) - menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new Separator()); - menu.add(menuGroup, action); + for (int idx = 0; idx < actions.length; idx++) { + IAction action = actions[idx]; + if (action instanceof SystemNewFilterAction) + menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new Separator()); + menu.add(menuGroup, action); + } } - } - actions = adapter.getFilterReferenceActions(menu, selection, shell, menuGroup, ssFactory, getFilterReference(selection.getFirstElement())); - if (actions != null) - { - for (int idx = 0; idx < actions.length; idx++) + actions = adapter.getFilterReferenceActions(menu, selection, shell, menuGroup, ssFactory, getFilterReference(selection.getFirstElement())); + if (actions != null) { - IAction action = actions[idx]; - menu.add(menuGroup, action); + for (int idx = 0; idx < actions.length; idx++) { + IAction action = actions[idx]; + menu.add(menuGroup, action); + } } } } @@ -141,7 +150,7 @@ public class SystemViewFilterReferenceAdapter { return SubSystemHelpers.getParentSubSystemConfiguration(filter); } - + /** * Overridden from parent.
    * Returns the subsystem that contains this object. @@ -153,7 +162,7 @@ public class SystemViewFilterReferenceAdapter else return null; } - + /** * Returns an image descriptor for the image. More efficient than getting the image. * @param element The element for which an image is desired @@ -165,9 +174,17 @@ public class SystemViewFilterReferenceAdapter ISystemFilter filter = getFilter(element); if (filter.getProvider() != null) // getProvider() returns the subsystem factory { - ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)filter.getProvider().getAdapter(ISubSystemConfigurationAdapter.class); - filterImage = adapter.getSystemFilterImage(filter); + if (adapter != null) { + // Lazy Loading: Customized Filter Images will be available only + // after the bundle that declares the + // ISubSystemConfigurationAdapter has been loaded. Until that + // time, a default filter image is used. Extenders who want to + // see their filter images right away need to provision for + // eager loading of their bundles at the right time (i.e. when + // expanding the Subsystem node). + filterImage = adapter.getSystemFilterImage(filter); + } } if (filterImage == null) filterImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTER_ID); @@ -178,7 +195,7 @@ public class SystemViewFilterReferenceAdapter { return (ISystemFilterReference) element; // get referenced object } - + private ISystemFilter getFilter(Object element) { return getFilterReference(element).getReferencedFilter(); // get master object @@ -191,7 +208,7 @@ public class SystemViewFilterReferenceAdapter { return getFilter(element).getName(); } - + /** * Return the name of this object, which may be different than the display text ({#link #getText(Object)}. *

    @@ -201,14 +218,14 @@ public class SystemViewFilterReferenceAdapter { return getFilter(element).getName(); } - + /* * (non-Javadoc) * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object) */ public String getAbsoluteName(Object element) { - //TODO consider caching the absolute name in the FilterReference to avoid unnecessary String operations - the name won't ever change + //TODO consider caching the absolute name in the FilterReference to avoid unnecessary String operations - the name won't ever change ISystemFilterPoolReference filterPoolReference = getFilterReference(element).getParentSystemFilterReferencePool(); ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(filterPoolReference); String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(filterPoolReference) : ""; //$NON-NLS-1$ @@ -268,17 +285,17 @@ public class SystemViewFilterReferenceAdapter ISubSystem subsystem = element.getSubSystem(); ISubSystemConfiguration configuration = subsystem.getSubSystemConfiguration(); Object adapter = Platform.getAdapterManager().getAdapter(configuration, ISubSystemConfigurationAdapter.class); - - if (adapter instanceof ISubSystemConfigurationAdapter) + + if (adapter instanceof ISubSystemConfigurationAdapter) { children = ((ISubSystemConfigurationAdapter)adapter).applyViewFilters(element, children); } - + return children; } /* - * Returns the children of the specified element. If a monitor is passed in then + * Returns the children of the specified element. If a monitor is passed in then * the context is assumed to be modal and, as such, the modal version of ss.resolveFilterStrings * is called rather than the main thread version. */ @@ -299,7 +316,7 @@ public class SystemViewFilterReferenceAdapter try { ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class); - + ISystemFilter newFilter = adapter.createFilterByPrompting(ssf, fRef, getShell()); if (newFilter == null) { @@ -341,14 +358,14 @@ public class SystemViewFilterReferenceAdapter else { /* - // show filter strings + // show filter strings if (ssf.showFilterStrings()) { SystemFilterStringReference[] refFilterStrings = fRef.getSystemFilterStringReferences(); if ((nestedFilterReferences == null) || (nestedFilterReferences.length == 0)) return refFilterStrings; if ((refFilterStrings == null) || (refFilterStrings.length == 0)) - return nestedFilterReferences; + return nestedFilterReferences; int nbrChildren = nestedFilterReferences.length + refFilterStrings.length; children = new Object[nbrChildren]; int idx=0; @@ -365,10 +382,10 @@ public class SystemViewFilterReferenceAdapter try { - + // hack to propogate type filters down from connection in select dialogs... ISystemViewInputProvider inputProvider = getInput(); - if ((inputProvider != null) && (inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl) && + if ((inputProvider != null) && (inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl) && (filterStrings != null) && (filterStrings.length > 0)) { SystemSelectRemoteObjectAPIProviderImpl ip = (SystemSelectRemoteObjectAPIProviderImpl) inputProvider; @@ -380,11 +397,11 @@ public class SystemViewFilterReferenceAdapter filterStrings = adorned; } } - + boolean doQuery = true; - if (!referencedFilter.isTransient() && + if (!referencedFilter.isTransient() && ssf.supportsFilterCaching() && - !fRef.isStale() && + !fRef.isStale() && fRef.hasContents(SystemChildrenContentsType.getInstance())) { doQuery = false; @@ -409,7 +426,7 @@ public class SystemViewFilterReferenceAdapter if (doQuery) { Object[] allChildren = null; - + if (monitor == null) { allChildren = ss.resolveFilterStrings(filterStrings, new NullProgressMonitor()); @@ -418,7 +435,7 @@ public class SystemViewFilterReferenceAdapter { allChildren = ss.resolveFilterStrings(filterStrings, monitor); } - + if (allChildren == null) { // System.out.println("filter children == null!"); //$NON-NLS-1$ @@ -430,7 +447,7 @@ public class SystemViewFilterReferenceAdapter // error to display return allChildren; // nothing to sort or cache - just show the error } - + if (nestedFilterReferences != null) { int nbrNestedFilters = nestedFilterReferences.length; @@ -440,8 +457,8 @@ public class SystemViewFilterReferenceAdapter children[idx] = nestedFilterReferences[idx]; for (int jdx = 0; jdx < allChildren.length; jdx++) children[idx++] = allChildren[jdx]; - - + + if (!referencedFilter.isTransient() && ssf.supportsFilterCaching()) { fRef.setContents(SystemChildrenContentsType.getInstance(), children); @@ -449,7 +466,7 @@ public class SystemViewFilterReferenceAdapter } } } - + } catch (InterruptedException exc) { @@ -474,13 +491,13 @@ public class SystemViewFilterReferenceAdapter * That is, if the referenced filter has nested filters or filter strings. */ public boolean hasChildren(IAdaptable element) - { + { ISystemFilterReference fRef = getFilterReference(element); ISystemFilter referencedFilter = fRef.getReferencedFilter(); - + ISubSystemConfiguration factory = getSubSystemConfiguration(referencedFilter); if (factory.supportsFilterChildren()) - { + { int nbrNestedFilters = referencedFilter.getSystemFilterCount(); int nbrFilterStrings = referencedFilter.getFilterStringCount(); return (nbrNestedFilters > 0) || (nbrFilterStrings > 0); @@ -521,7 +538,7 @@ public class SystemViewFilterReferenceAdapter *

  • name="filterType". The value is tested against the non-translated filter type. Note all subsystems * support different types of filters. *
  • name="showChangeFilterStringsPropertyPage". The value is tested against the call to the subsystem factory method showChangeFilterStringsPropertyPage(SystemFilter). - * Compares against "true" (default) or "false". + * Compares against "true" (default) or "false". * */ public boolean testAttribute(Object target, String name, String value) @@ -542,7 +559,7 @@ public class SystemViewFilterReferenceAdapter if (value.equals("true")) //$NON-NLS-1$ return ssf.showChangeFilterStringsPropertyPage(ref.getReferencedFilter()); else - return !ssf.showChangeFilterStringsPropertyPage(ref.getReferencedFilter()); + return !ssf.showChangeFilterStringsPropertyPage(ref.getReferencedFilter()); } else return super.testAttribute(target, name, value); @@ -566,7 +583,7 @@ public class SystemViewFilterReferenceAdapter // number filter strings propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP); // Related connection - propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTION_PRIVATE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP); + propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTION_PRIVATE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP); } return propertyDescriptorArray; } @@ -713,13 +730,13 @@ public class SystemViewFilterReferenceAdapter ISystemFilter filter = getFilter(element); return !filter.isPromptable(); } - - + + /** * Don't show generic "Show in Table" if the factory asks not to */ public boolean showGenericShowInTableAction(Object element) - { + { ISystemFilter filter = getFilter(element); ISubSystemConfiguration ssParentFactory = getSubSystemConfiguration(filter); return ssParentFactory.showGenericShowInTableOnFilter(); @@ -827,7 +844,7 @@ public class SystemViewFilterReferenceAdapter // ------------------------------------------ // METHODS TO SUPPORT COMMON DRAG AND DROP FUNCTION... - // ------------------------------------------ + // ------------------------------------------ /** * drag support is handled directly for filter references, rather than delegated here. */ @@ -837,7 +854,7 @@ public class SystemViewFilterReferenceAdapter if (fRef != null) { if (getSubSystemConfiguration(fRef.getReferencedFilter()).supportsFilterStringExport()) - { + { return true; } } @@ -860,11 +877,11 @@ public class SystemViewFilterReferenceAdapter { return true; } - + if (!fRef.getReferencedFilter().isNonChangable()) - { + { if (factory.supportsMultiStringFilters()) - { + { return true; } } @@ -872,7 +889,7 @@ public class SystemViewFilterReferenceAdapter } return false; } - + public ISystemResourceSet doDrag(SystemRemoteResourceSet set, IProgressMonitor monitor) { return set; @@ -909,13 +926,13 @@ public class SystemViewFilterReferenceAdapter else if (from instanceof IAdaptable) { ISystemRemoteElementAdapter radapter = (ISystemRemoteElementAdapter) ((IAdaptable) from).getAdapter(ISystemRemoteElementAdapter.class); - + { - + String newFilterStr = radapter.getFilterStringFor(from); if (newFilterStr != null) { - filter.addFilterString(newFilterStr); + filter.addFilterString(newFilterStr); return fRef; } } @@ -929,10 +946,10 @@ public class SystemViewFilterReferenceAdapter * compatable. */ public boolean validateDrop(Object src, Object target, boolean sameSystem) - { + { if (!sameSystem) { - if (src instanceof IResource) + if (src instanceof IResource) { return true; } @@ -964,7 +981,7 @@ public class SystemViewFilterReferenceAdapter return true; } } - // check if src has a filter string + // check if src has a filter string else if (src instanceof IAdaptable) { ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter) ((IAdaptable) src).getAdapter(ISystemRemoteElementAdapter.class); @@ -980,20 +997,20 @@ public class SystemViewFilterReferenceAdapter } return false; } - - + + /* * Return whether deferred queries are supported. - * Defer to the subsystem configuration. + * Defer to the subsystem configuration. */ public boolean supportsDeferredQueries(ISubSystem subSys) { return subSys.getSubSystemConfiguration().supportsDeferredQueries(); } - + /** * This is a local RSE artifact so returning false - * + * * @param element the object to check * @return false since this is not remote */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java index bae3f6cb308..5546b573aee 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java @@ -1,15 +1,15 @@ /******************************************************************************** * Copyright (c) 2002, 2008 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 + * 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, + * 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: * David Dykstal (IBM) - 180562: remove implementation of IRSEUserIdConstants * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation @@ -20,11 +20,13 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * Martin Oberhuber (Wind River) - [195399] Improve String display for default port 0 * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.internal.ui.view; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IAction; import org.eclipse.jface.resource.ImageDescriptor; @@ -34,7 +36,9 @@ import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; import org.eclipse.rse.internal.ui.SystemResources; +import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.SystemMenuManager; @@ -55,25 +59,25 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; * Adapter for displaying SubSystem objects in tree views. * These are children of SystemConnection objects */ -public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter +public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { protected String translatedType; // for reset property support private String original_portData; - private SystemInheritablePropertyData original_userIdData = new SystemInheritablePropertyData(); - //private SystemInheritablePropertyData original_portData = new SystemInheritablePropertyData(); + private SystemInheritablePropertyData original_userIdData = new SystemInheritablePropertyData(); + //private SystemInheritablePropertyData original_portData = new SystemInheritablePropertyData(); private TextPropertyDescriptor propertyPortDescriptor; private boolean changed_userId, changed_port; private boolean port_editable = true; // ------------------- // property descriptors // ------------------- - private PropertyDescriptor[] propertyDescriptorArray = null; - //private SystemInheritablePropertyData portData = new SystemInheritablePropertyData(); + private PropertyDescriptor[] propertyDescriptorArray = null; + //private SystemInheritablePropertyData portData = new SystemInheritablePropertyData(); //private SystemInheritableTextPropertyDescriptor portDescriptor; - private SystemInheritablePropertyData userIdData = new SystemInheritablePropertyData(); + private SystemInheritablePropertyData userIdData = new SystemInheritablePropertyData(); private SystemInheritableTextPropertyDescriptor userIdDescriptor = null; - + /** * Returns any actions that should be contributed to the popup menu * for the given subsystem object. @@ -88,49 +92,92 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { // does not make sense adding unique actions per multi-selection if (selection.size() == 1) { - Object element = selection.getFirstElement(); + Object element = selection.getFirstElement(); ISubSystem ss = (ISubSystem)element; ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class); - - IAction[] actions = adapter.getSubSystemActions(menu, selection, shell, menuGroup, ssFactory, ss); - if (actions != null) - { - for (int idx=0; idx0)); - // DY: Defect 42735, check if user has temporarilly overrode the userid + // DY: Defect 42735, check if user has temporarilly overrode the userid // for this connection via the signon dialog - if (subsys.isConnected()) + if (subsys.isConnected()) { String connectedId = subsys.getConnectorService().getUserId(); //On Local subsystems, connectedId==null. Phil. - if (data.getIsLocal() && connectedId!=null && !connectedId.equals(localUserId)) + if (data.getIsLocal() && connectedId!=null && !connectedId.equals(localUserId)) { data.setLocalValue(connectedId); data.setIsLocal(true); } - else if (connectedId!=null && !connectedId.equals(parentUserId)) + else if (connectedId!=null && !connectedId.equals(parentUserId)) { data.setLocalValue(connectedId); data.setIsLocal(true); } } - + return data; } @@ -329,12 +376,12 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter boolean notApplicable = (!ssFactory.isPortEditable() && (iPort <= 0)); if (!notApplicable) { - data.setInheritedValue("0"); - data.setInheritedDisplayString(NLS.bind(SystemPropertyResources.RESID_PORT_DYNAMICSELECT, "0")); //$NON-NLS-1$ + data.setInheritedValue("0"); + data.setInheritedDisplayString(NLS.bind(SystemPropertyResources.RESID_PORT_DYNAMICSELECT, "0")); //$NON-NLS-1$ data.setIsLocal(iPort != 0); } data.setNotApplicable(notApplicable); - getPortDescriptor().setEditable(!notApplicable); + getPortDescriptor().setEditable(!notApplicable); //data.printDetails(); return data; } @@ -342,10 +389,10 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter private String getPortString(ISubSystem ss) { - //return getPortPropertyData(portData, ss); + //return getPortPropertyData(portData, ss); int iPort = ss.getConnectorService().getPort(); ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); - boolean notApplicable = (!ssFactory.isPortEditable() && (iPort <= 0)); + boolean notApplicable = (!ssFactory.isPortEditable() && (iPort <= 0)); if (notApplicable) return getTranslatedNotApplicable(); else @@ -353,17 +400,17 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter return Integer.toString(iPort); } } - + /** * Returns the current value for the named property. * The parent handles P_TEXT and P_TYPE only, and we augment that here. * @param property the name of the property as named by its property descriptor * @return the current value of the property */ - public Object getPropertyValue(Object property) + public Object getPropertyValue(Object property) { - String name = (String)property; - ISubSystem ss = (ISubSystem)propertySourceInput; + String name = (String)property; + ISubSystem ss = (ISubSystem)propertySourceInput; if (name.equals(ISystemPropertyConstants.P_USERID)) return setUserIdPropertyData(userIdData, ss); else if (name.equals(ISystemPropertyConstants.P_PORT)) @@ -390,7 +437,7 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter // connection is offline return SystemResources.RESID_OFFLINE_LABEL; } - + IConnectorService system = ss.getConnectorService(); boolean connected = false; if (system == null) @@ -398,14 +445,14 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter System.out.println("SystemViewSubSystemAdapter: Error! system is null for subsystem "+ss.getClass().getName()); //$NON-NLS-1$ SystemBasePlugin.logError("SystemViewSubSystemAdapter: Error! system is null for subsystem "+ss.getClass().getName(), null); //$NON-NLS-1$ } - else + else connected = system.isConnected(); return connected ? getTranslatedYes() : getTranslatedNo(); } else return super.getPropertyValue(name); - } - + } + /** * Returns itself */ @@ -414,17 +461,17 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter if (element instanceof ISubSystem) return (ISubSystem)element; else - return null; + return null; } - + /** * Return our unique property values */ public Object internalGetPropertyValue(Object key) { return null; - } - + } + // because this node has some editable properties, these overrides of our // parent class are needed as callbacks from the PropertySheet window. /** @@ -436,29 +483,35 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter if (this.propertySourceInput == propertySourceInput) return; super.setPropertySourceInput(propertySourceInput); - ISubSystem ss = (ISubSystem)propertySourceInput; - ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); - original_userIdData = setUserIdPropertyData(original_userIdData,ss); - //original_portData = setPortPropertyData(original_portData,ss); + ISubSystem ss = (ISubSystem)propertySourceInput; + ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); + original_userIdData = setUserIdPropertyData(original_userIdData,ss); + //original_portData = setPortPropertyData(original_portData,ss); original_portData = getPortString(ss); changed_userId = changed_port = false; - + ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class); - if (userIdDescriptor != null) - { - - userIdDescriptor.setValidator(adapter.getUserIdValidator(ssFactory)); + if (adapter != null) { + // Lazy Loading: Since this is called from opening a context + // menu, Dynamic Validator will only be available once the + // ISubSystemConfigurationAdapter is loaded, i.e. after + // connecting. + // If a subsystem wants to provision for having the validator + // available earlier, it needs to eagerly load the bundle that + // declares its ISubSystemConfigurationAdapter. + if (userIdDescriptor != null) { + userIdDescriptor.setValidator(adapter.getUserIdValidator(ssFactory)); + } + // getPortDescriptor().setValidator((ICellEditorValidator)ssFactory.getPortValidator()); + if (propertyPortDescriptor != null) { + propertyPortDescriptor.setValidator(adapter.getPortValidator(ssFactory)); + } } - - //getPortDescriptor().setValidator((ICellEditorValidator)ssFactory.getPortValidator()); - if (propertyPortDescriptor != null) - { - propertyPortDescriptor.setValidator(adapter.getPortValidator(ssFactory)); - } + ss.getConnectorService().getPort(); port_editable = ssFactory.isPortEditable(); } - + /** * Returns whether the property value has changed from the default. * Only applicable for editable properties. @@ -466,16 +519,16 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter * @return true if the value of the specified property has changed * from its original default value; false otherwise. */ - public boolean isPropertySet(Object propertyObject) + public boolean isPropertySet(Object propertyObject) { - String property = (String)propertyObject; + String property = (String)propertyObject; boolean changed = false; if (property.equals(ISystemPropertyConstants.P_USERID)) changed = changed_userId; else if (property.equals(ISystemPropertyConstants.P_PORT)) - changed = changed_port && port_editable; - return changed; - } + changed = changed_port && port_editable; + return changed; + } /** * Change the subsystem user Id value @@ -484,13 +537,13 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { //int whereToUpdate = USERID_LOCATION_SUBSYSTEM; String userId = data.getLocalValue(); // will be "" if !data.getIsLocal(), which results in wiping out local override - ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration(); + ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration(); // unlike with connection objects, we don't ever allow the user to change the parent's - // userId value, even if it is empty, when working with subsystems. There is too much + // userId value, even if it is empty, when working with subsystems. There is too much // ambiquity as the parent could be the connnection or the user preferences setting for this // system type. Because of this decision, we don't need to tell updateSubSystem(...) where // to update, as it always the local subsystem. - ssFactory.updateSubSystem(subsys, true, userId, false, subsys.getConnectorService().getPort()); + ssFactory.updateSubSystem(subsys, true, userId, false, subsys.getConnectorService().getPort()); } /** * Change the subsystem port value @@ -500,11 +553,11 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter String port = data.getLocalValue(); // will be "" if !data.getIsLocal(), which results in wiping out local override Integer portInteger = null; if (data.getIsLocal() && (port.length()>0)) - portInteger = new Integer(port); + portInteger = new Integer(port); else portInteger = new Integer(0); - SubSystemConfiguration ssFactory = subsys.getParentSubSystemConfiguration(); - ssFactory.updateSubSystem((Shell)null, subsys, false, subsys.getLocalUserId(), true, portInteger); + SubSystemConfiguration ssFactory = subsys.getParentSubSystemConfiguration(); + ssFactory.updateSubSystem((Shell)null, subsys, false, subsys.getLocalUserId(), true, portInteger); } */ /** @@ -518,11 +571,11 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter Integer portInteger = null; if (port.length()>0) { - try + try { - portInteger = new Integer(port); - } - catch (Exception exc) + portInteger = new Integer(port); + } + catch (Exception exc) { return; } @@ -532,12 +585,12 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter portInteger = new Integer(0); } int portInt = portInteger.intValue(); - ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration(); + ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration(); ssFactory.updateSubSystem(subsys, false, subsys.getLocalUserId(), true, portInt); subsys.commit(); } - + /** * Called when user selects the reset button in property sheet. */ @@ -545,10 +598,10 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { String property = (String)propertyObject; ISubSystem ss = (ISubSystem)propertySourceInput; - ss.getSubSystemConfiguration(); + ss.getSubSystemConfiguration(); if (property.equals(ISystemPropertyConstants.P_USERID)) { - updateUserId(ss, original_userIdData); + updateUserId(ss, original_userIdData); changed_userId = false; } else if (property.equals(ISystemPropertyConstants.P_PORT)) @@ -557,29 +610,29 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter updatePort(ss, original_portData); changed_port = false; } - } + } /** * Called when user changes property via property sheet. */ public void setPropertyValue(Object property, Object value) { - String name = (String)property; + String name = (String)property; ISubSystem ss = (ISubSystem)propertySourceInput; ss.getSubSystemConfiguration(); //System.out.println("inside setPropVal: " + property + ", value: " + value); if (name.equals(ISystemPropertyConstants.P_USERID)) { - updateUserId(ss, (SystemInheritablePropertyData)value); + updateUserId(ss, (SystemInheritablePropertyData)value); changed_userId = true; } else if (name.equals(ISystemPropertyConstants.P_PORT)) { //System.out.println("inside setPropVal: " + property + ", value: " + value); - //updatePort(ss, (SystemInheritablePropertyData)value); + //updatePort(ss, (SystemInheritablePropertyData)value); updatePort(ss, (String)value); changed_port = true; } - } + } /** * Override of {@link AbstractSystemViewAdapter#testAttribute(Object, String, String)}. We add @@ -588,9 +641,9 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter *
  • name="serverLaunchPP". Returns "true" if the given subsystem supports the Server Launch Settings * property page, which is determined by calling it's factory's {@link ISubSystemConfiguration#supportsServerLaunchProperties(org.eclipse.rse.core.model.IHost)} method. * - * + * * This property is used to filter the existence of the Server Launch Settings property page. - * + * * @see org.eclipse.ui.IActionFilter#testAttribute(Object, String, String) */ public boolean testAttribute(Object target, String name, String value) @@ -624,7 +677,7 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter } return super.testAttribute(target, name, value); } - + // FOR COMMON DELETE ACTIONS /** * Return true if we should show the delete action in the popup for the given element. @@ -633,32 +686,32 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter public boolean showDelete(Object element) { return canDelete(element); - } - + } + /** * Return true if this object is deletable by the user. If so, when selected, * the Edit->Delete menu item will be enabled. */ public boolean canDelete(Object element) { - //System.out.println("INSIDE ISDELETABLE FOR SUBSYSTEM VIEW ADAPTER: "+element); - ISubSystem ss = (ISubSystem)element; - ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); + //System.out.println("INSIDE ISDELETABLE FOR SUBSYSTEM VIEW ADAPTER: "+element); + ISubSystem ss = (ISubSystem)element; + ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration(); return ssFactory.isSubSystemsDeletable(); } - + /** * Perform the delete action. */ public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) { - //System.out.println("INSIDE DODELETE FOR SUBSYSTEM VIEW ADAPTER: "+element); - ISubSystem ss = (ISubSystem)element; - ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + //System.out.println("INSIDE DODELETE FOR SUBSYSTEM VIEW ADAPTER: "+element); + ISubSystem ss = (ISubSystem)element; + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); sr.deleteSubSystem(ss); return true; - } - + } + // FOR COMMON RENAME ACTIONS /** * Return true if we should show the rename action in the popup for the given element. @@ -667,16 +720,16 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter public boolean showRename(Object element) { return canRename(element); - } + } /** * Return true if this object is renamable by the user. If so, when selected, * the Rename menu item will be enabled. */ public boolean canRename(Object element) - { + { return canDelete(element); // same rules for both delete and rename } - + /** * Perform the rename action. Assumes uniqueness checking was done already. */ @@ -686,8 +739,8 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter ISubSystemConfiguration parentSSFactory = ss.getSubSystemConfiguration(); parentSSFactory.renameSubSystem(ss,name); // renames, and saves to disk return true; - } - + } + /** * Return a validator for verifying the new name is correct on a rename action. * The default implementation is not to support rename hence this method returns @@ -697,28 +750,28 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { return null; } - + // FOR COMMON DRAG AND DROP ACTIONS /** - * Indicates whether the subsystem can be dragged. - * Can't be used for physical copies but rather + * Indicates whether the subsystem can be dragged. + * Can't be used for physical copies but rather * for views (like the Scratchpad) */ public boolean canDrag(Object element) { return true; } - + /** * Returns the subsystem (no phyiscal operation required to drag and subsystem (because it's local) */ public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor) { - return element; + return element; } - - - + + + // ------------------------------------------------------------ // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER... @@ -752,10 +805,10 @@ public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter { return ISystemMementoConstants.MEMENTO_KEY_SUBSYSTEM; } - + /** * This is a local RSE artifact so returning false - * + * * @param element the object to check * @return false since this is not remote */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java index f52522d5ff7..3bd2f032acd 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java @@ -1,18 +1,19 @@ /******************************************************************************** - * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2008 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 + * 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, + * 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) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.internal.ui.view.team; @@ -23,13 +24,16 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; import org.eclipse.rse.internal.ui.SystemResources; +import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter; +import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter; /** * This class represents a child node under category nodes, in the Team view. - * It represents expandable subsystem factories such as "Files" or "iSeries Objects". + * It represents expandable subsystem factories such as "Files" or "iSeries Objects". */ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable { @@ -38,7 +42,7 @@ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable private ISubSystemConfiguration ssf; private SystemTeamViewCategoryNode parentCategory; private String name = null; - + /** * Constructor */ @@ -57,11 +61,11 @@ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable */ public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - + return Platform.getAdapterManager().getAdapter(this, adapterType); + } + /** - * Compare this node to another. + * Compare this node to another. */ public boolean equals(Object o) { @@ -78,7 +82,7 @@ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable else return super.equals(o); } - + /** * Return this node's image * @return the image to show in the tree, for this node @@ -86,7 +90,21 @@ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable public ImageDescriptor getImageDescriptor() { ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class); - return adapter.getImage(ssf); + if (adapter != null) { + return adapter.getImage(ssf); + } else { + // Fall back to using the Proxy -- see also + // SystemViewSubSystemAdapter.getImageDescriptor() + ISubSystemConfigurationProxy proxy = ssf.getSubSystemConfigurationProxy(); + SubSystemConfigurationProxyAdapter proxyAdapter = (SubSystemConfigurationProxyAdapter) Platform.getAdapterManager().getAdapter(proxy, + SubSystemConfigurationProxyAdapter.class); + if (proxyAdapter != null) { + return proxyAdapter.getImageDescriptor(); + } else { + SystemBasePlugin.logWarning("Unexpected error: SubSystemConfiguration has no adapter and no proxyAdapter: " + ssf.getId()); //$NON-NLS-1$ + return null; + } + } } /** @@ -116,9 +134,9 @@ public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable buf.append(")"); //$NON-NLS-1$ name = buf.toString(); } - return name; + return name; } - + /** * Convert to string. We call getLabel() */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemChangeFilterPropertyPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemChangeFilterPropertyPage.java index 7770c948ace..5935337e49c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemChangeFilterPropertyPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemChangeFilterPropertyPage.java @@ -1,26 +1,28 @@ /******************************************************************************** - * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2008 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 + * 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, + * 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) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.ui.propertypages; + +import org.eclipse.core.runtime.Platform; import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider; import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider; import org.eclipse.rse.core.filters.ISystemFilterReference; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.core.subsystems.SubSystemConfiguration; import org.eclipse.rse.core.subsystems.SubSystemHelpers; import org.eclipse.rse.internal.ui.SystemPropertyResources; import org.eclipse.rse.services.clientserver.messages.SystemMessage; @@ -32,30 +34,33 @@ import org.eclipse.rse.ui.filters.SystemChangeFilterPane; import org.eclipse.rse.ui.filters.SystemFilterStringEditPane; import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter; import org.eclipse.rse.ui.validators.ISystemValidator; +import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; /** - * This is the property page for changing filters. This page used to be the Change dialog. - * The plugin.xml file registers this for objects of class org.eclipse.rse.internal.filters.SystemFilter or - * org.eclipse.rse.filters.SystemFilterReference. + * This is the property page for changing filters. This page used to be the + * Change dialog. The plugin.xml file registers this for objects of class + * org.eclipse.rse.internal.filters.SystemFilter or + * org.eclipse.rse.filters.SystemFilterReference. *

    - * If you have your own change filter dialog (versus configuring ours) you must configure this - * pane yourself by overriding {@link SubSystemConfiguration#customizeChangeFilterPropertyPage(SystemChangeFilterPropertyPage, ISystemFilter, Shell)} - * and configuring the pane as described in that method's javadoc. + * If you have your own change filter dialog (versus configuring ours) you must + * configure this pane yourself by overriding + * {@link SubSystemConfigurationAdapter#customizeChangeFilterPropertyPage(ISubSystemConfiguration, SystemChangeFilterPropertyPage, ISystemFilter, Shell)} + * and configuring the pane as described in that method's javadoc. */ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage implements ISystemPageCompleteListener, ISystemChangeFilterPaneEditPaneSupplier { - + protected String errorMessage; protected boolean initDone = false; - - protected SystemChangeFilterPane changeFilterPane; + + protected SystemChangeFilterPane changeFilterPane; protected SystemFilterStringEditPane editPane; - + /** * Constructor for SystemFilterPropertyPage */ @@ -83,12 +88,12 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage * provider itself (eg subsystem) *

    * This is passed into the filter and filter string wizards and dialogs in case it is needed - * for context. + * for context. */ public void setSystemFilterPoolReferenceManagerProvider(ISystemFilterPoolReferenceManagerProvider provider) { changeFilterPane.setSystemFilterPoolReferenceManagerProvider(provider); - } + } /** * Configuration method
    * Set the contextual system filter pool manager provider. Will be non-null if the @@ -96,13 +101,13 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage * provider itself (eg subsystemconfiguration) *

    * This is passed into the filter and filter string wizards and dialogs in case it is needed - * for context. + * for context. */ public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider provider) { changeFilterPane.setSystemFilterPoolManagerProvider(provider); - } - + } + /** * Configuration method
    * Set the Parent Filter Pool prompt label and tooltip text. @@ -129,7 +134,7 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage changeFilterPane.setListLabel(label, tip); } /** - * Set the string to show as the first item in the list. + * Set the string to show as the first item in the list. * The default is "New filter string" */ public void setNewListItemText(String label) @@ -152,7 +157,7 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage } /** * Configuration method
    - * Set the error message to use when the user is editing or creating a filter string, and the + * Set the error message to use when the user is editing or creating a filter string, and the * Apply processing detects a duplicate filter string in the list. */ public void setDuplicateFilterStringErrorMessage(SystemMessage msg) @@ -183,9 +188,9 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage { changeFilterPane.setSupportsMultipleStrings(multi); } - + // OVERRIDABLE METHODS... - + /** * Create the page's GUI contents. * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) @@ -196,46 +201,51 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage if (shell == null) { System.out.println("Damn, shell is still null!"); //$NON-NLS-1$ - + } changeFilterPane.setShell(shell); - + ISystemFilter selectedFilter = getFilter(); if (selectedFilter.isPromptable()) { int nbrColumns = 1; Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); /*Label test =*/ SystemWidgetHelpers.createLabel(composite_prompts, SystemPropertyResources.RESID_TERM_NOTAPPLICABLE, nbrColumns, false); - return composite_prompts; + return composite_prompts; } - + if (getElement() instanceof ISystemFilterReference) { ISystemFilterReference filterRef = (ISystemFilterReference)getElement(); changeFilterPane.setSystemFilterPoolReferenceManagerProvider(filterRef.getProvider()); - } - changeFilterPane.setSystemFilterPoolManagerProvider(selectedFilter.getProvider()); - + } + changeFilterPane.setSystemFilterPoolManagerProvider(selectedFilter.getProvider()); + ISubSystemConfiguration ssf = SubSystemHelpers.getParentSubSystemConfiguration(selectedFilter); ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class); + if (adapter == null) { + // lazy loading: load adapter if necessary + Platform.getAdapterManager().loadAdapter(ssf, ISubSystemConfigurationAdapter.class.getName()); + adapter = (ISubSystemConfigurationAdapter) ssf.getAdapter(ISubSystemConfigurationAdapter.class); + } adapter.customizeChangeFilterPropertyPage(ssf, this, selectedFilter, shell); - + changeFilterPane.setInputObject(getElement()); - + /* // ensure the page has no special buttons - noDefaultAndApplyButton(); + noDefaultAndApplyButton(); // Inner composite - int nbrColumns = 2; - Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); - + int nbrColumns = 2; + Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); + Label test = SystemWidgetHelpers.createLabel(composite_prompts, "Testing", nbrColumns); - if (!initDone) - doInitializeFields(); - + if (!initDone) + doInitializeFields(); + return composite_prompts; */ return changeFilterPane.createContents(parent); @@ -243,9 +253,9 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage /** * Intercept of parent so we can reset the default button */ - protected void contributeButtons(Composite parent) + protected void contributeButtons(Composite parent) { - super.contributeButtons(parent); + super.contributeButtons(parent); getShell().setDefaultButton(changeFilterPane.getApplyButton()); // defect 46129 } @@ -255,7 +265,7 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage * Return true if ok, false if there is an error. */ protected boolean verifyPageContents() - { + { return true; } @@ -270,7 +280,7 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage else return ((ISystemFilterReference)element).getReferencedFilter(); } - + /** * Called by parent when user presses OK */ @@ -298,16 +308,16 @@ public class SystemChangeFilterPropertyPage extends SystemBasePropertyPage //super.setPageComplete(complete); super.setValid(complete); // we'll see if this is the right thing to do } - + /** * Return our edit pane. Overriding this is an alternative to calling setEditPane. - * Method is declared in {@link ISystemChangeFilterPaneEditPaneSupplier}. + * Method is declared in {@link ISystemChangeFilterPaneEditPaneSupplier}. */ public SystemFilterStringEditPane getFilterStringEditPane(Shell shell) { // this method is called from SystemChangeFilterPane via callback if (editPane == null) editPane = new SystemFilterStringEditPane(shell); - return editPane; - } + return editPane; + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableView.java index 831fde2a315..b4044e8b493 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableView.java @@ -1,15 +1,15 @@ /******************************************************************************** * Copyright (c) 2002, 2008 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 + * 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, + * 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: * Kevin Doyle (IBM) - [187736] Marked _objectInput stale when new resource created * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core @@ -19,6 +19,7 @@ * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.ui.view; @@ -134,14 +135,14 @@ import org.eclipse.ui.views.properties.IPropertyDescriptor; */ public class SystemTableView extends TableViewer - implements IMenuListener, + implements IMenuListener, ISystemDeleteTarget, ISystemRenameTarget, ISystemSelectAllTarget, ISystemResourceChangeListener, ISystemRemoteChangeListener, ISystemShellProvider, ISelectionChangedListener, ISelectionProvider { - // inner class to support cell editing + // inner class to support cell editing private ICellModifier cellModifier = new ICellModifier() { public Object getValue(Object element, String property) @@ -183,14 +184,14 @@ public class SystemTableView private class HeaderSelectionListener extends SelectionAdapter { - + public HeaderSelectionListener() { _upI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEUP_ID); _downI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEDOWN_ID); } - - + + /** * Handles the case of user selecting the * header area. @@ -220,13 +221,13 @@ public class SystemTableView { tcolumn.setImage(_upI); } - } + } else { setSorter(new SystemTableViewSorter(column, SystemTableView.this, _columnManager)); tcolumn.setImage(_downI); } - + // unset image of other columns TableColumn[] allColumns = table.getColumns(); for (int i = 0; i < allColumns.length; i++) @@ -264,9 +265,9 @@ public class SystemTableView // Note the Edit menu actions are set in SystemViewPart. Here we use these // actions from our own popup menu actions. private SystemCommonDeleteAction _deleteAction; - // for global delete menu item + // for global delete menu item private SystemCommonRenameAction _renameAction; - // for common rename menu item + // for common rename menu item private SystemCommonSelectAllAction _selectAllAction; // for common Ctrl+A select-all @@ -278,7 +279,7 @@ public class SystemTableView protected boolean _selectionEnableDeleteAction; protected boolean _selectionEnableRenameAction; - + protected boolean _selectionIsRemoteObject = true; protected boolean _selectionFlagsUpdated = false; @@ -286,38 +287,38 @@ public class SystemTableView private int[] _lastWidths = null; private int _charWidth = 3; - + private boolean _showColumns = true; private Image _upI; private Image _downI; protected boolean menuListenerAdded = false; - + private static final int LEFT_BUTTON = 1; - private int mouseButtonPressed = LEFT_BUTTON; + private int mouseButtonPressed = LEFT_BUTTON; /** * Constructor for the table view - * + * */ public SystemTableView(Table table, ISystemMessageLine msgLine) { super(table); _layout = new TableLayout(); _messageLine = msgLine; - + _columnManager = new SystemTableViewColumnManager(this); _provider = getProvider(); _columnSelectionListener = new HeaderSelectionListener(); setContentProvider(_provider); - - setLabelProvider(new SystemDecoratingLabelProvider(_provider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); + + setLabelProvider(new SystemDecoratingLabelProvider(_provider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); //setLabelProvider(_provider); _filter = new SystemTableViewFilter(); addFilter(_filter); - + _charWidth = table.getFont().getFontData()[0].getHeight() / 2; computeLayout(); @@ -334,9 +335,9 @@ public class SystemTableView sr.addSystemRemoteChangeListener(this); initDragAndDrop(); - + table.setVisible(false); - + // key listening for delete press getControl().addKeyListener(new KeyAdapter() { @@ -345,19 +346,19 @@ public class SystemTableView handleKeyPressed(e); } }); - getControl().addMouseListener(new MouseAdapter() + getControl().addMouseListener(new MouseAdapter() { - public void mouseDown(MouseEvent e) + public void mouseDown(MouseEvent e) { - mouseButtonPressed = e.button; //d40615 + mouseButtonPressed = e.button; //d40615 } - }); - - + }); + + _upI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_ARROW_UP_ID); _downI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_ARROW_DOWN_ID); } - + protected SystemTableViewProvider getProvider() { if (_provider == null) @@ -366,12 +367,12 @@ public class SystemTableView } return _provider; } - + public void showColumns(boolean flag) { _showColumns = flag; } - + public Layout getLayout() { @@ -441,7 +442,7 @@ public class SystemTableView } /** - * Convenience method for retrieving the view adapter for an object + * Convenience method for retrieving the view adapter for an object */ protected ISystemViewElementAdapter getViewAdapter(Object obj) { @@ -452,7 +453,7 @@ public class SystemTableView } /** - * Convenience method for retrieving the view adapter for an object's children + * Convenience method for retrieving the view adapter for an object's children */ public ISystemViewElementAdapter getAdapterForContents() { @@ -475,9 +476,9 @@ public class SystemTableView Object[] children = provider.getChildren(object); return getVisibleDescriptors(children); } - + private IPropertyDescriptor[] getVisibleDescriptors(Object[] children) - { + { if (children != null && children.length > 0) { IAdaptable child = (IAdaptable) children[0]; @@ -491,14 +492,14 @@ public class SystemTableView { return _columnManager; } - + public IPropertyDescriptor getNameDescriptor(Object object) { SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); Object[] children = provider.getChildren(object); return getNameDescriptor(children); } - + private IPropertyDescriptor getNameDescriptor(Object[] children) { if (children != null && children.length > 0) @@ -519,7 +520,7 @@ public class SystemTableView Object[] children = provider.getChildren(_objectInput); return getFormatsIn(children); } - + private IPropertyDescriptor[] getCustomDescriptors(ISystemViewElementAdapter adapter) { return _columnManager.getVisibleDescriptors(adapter); @@ -538,7 +539,7 @@ public class SystemTableView { ISystemViewElementAdapter ad = (ISystemViewElementAdapter) adapter; ad.setPropertySourceInput(child); - + IPropertyDescriptor[] descriptors = getCustomDescriptors(ad); for (int i = 0; i < descriptors.length; i++) { @@ -547,9 +548,17 @@ public class SystemTableView try { Object key = descriptor.getId(); - Object propertyValue = ad.getPropertyValue(key, false); - results.add(propertyValue.getClass()); + if (propertyValue != null) { + // FIXME Since we're only checking the FIRST element + // in the list of elements for its descriptor, we + // might get null here if the first element is + // invalid - although other elements might be valid. + // This issue is tracked in + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193329#c5 + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=187571 + results.add(propertyValue.getClass()); + } } catch (Exception e) { @@ -561,7 +570,7 @@ public class SystemTableView } return results; - } + } public void computeLayout() { @@ -578,7 +587,7 @@ public class SystemTableView return editor; } - + private boolean sameDescriptors(IPropertyDescriptor[] descriptors1, IPropertyDescriptor[] descriptors2) { if (descriptors1 == null || descriptors2 == null) @@ -603,7 +612,7 @@ public class SystemTableView /** * Determines what columns should be shown in this view. The columns may change * anytime the view input changes. The columns in the control are modified and - * columns may be added or deleted as necessary to make it conform to the + * columns may be added or deleted as necessary to make it conform to the * new data. */ public void computeLayout(boolean force) @@ -612,7 +621,7 @@ public class SystemTableView return; if (_objectInput == null) return; - + SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); Object[] children = provider.getChildren(_objectInput); @@ -621,17 +630,17 @@ public class SystemTableView { return; } - + IPropertyDescriptor[] descriptors = getVisibleDescriptors(children); IPropertyDescriptor nameDescriptor = getNameDescriptor(children); - + int n = descriptors.length; // number of columns we need (name column + other columns) if (nameDescriptor != null) n += 1; if (n == 0) return; // there is nothing to lay out! - + if (sameDescriptors(descriptors,_uniqueDescriptors) && !force) { setLastColumnWidths(getCurrentColumnWidths()); @@ -660,7 +669,7 @@ public class SystemTableView int alignment = SWT.LEFT; int weight = 100; if (i == 0) - { + { // this is the first column -- treat it special //name = SystemPropertyResources.RESID_PROPERTY_NAME_LABEL; name = SystemResources.RESID_RENAME_COLHDG_OLDNAME; @@ -725,15 +734,15 @@ public class SystemTableView // find a default totalWidth = 500; } - + int[] lastWidths = getLastColumnWidths(); if (numColumns > 1) { - // check if previous widths can be used + // check if previous widths can be used if (lastWidths != null && lastWidths.length == numColumns) { - + // use previously established widths setCurrentColumnWidths(lastWidths); } @@ -749,7 +758,7 @@ public class SystemTableView columns[0].setWidth(firstWidth); for (int i = 1; i < numColumns; i++) { - + columns[i].setWidth(averageWidth); } setLastColumnWidths(getCurrentColumnWidths()); @@ -758,23 +767,23 @@ public class SystemTableView table.setHeaderVisible(true); } else - { - - if (numColumns == 1) - { + { + + if (numColumns == 1) + { int width = totalWidth; if (lastWidths != null && lastWidths.length == 1) { width = (totalWidth > lastWidths[0]) ? totalWidth : lastWidths[0]; } - - + + int maxWidth = provider.getMaxCharsInColumnZero() * _charWidth; if (maxWidth > width) { width = maxWidth; } - + if (width > 0) { columns[0].setWidth(width); @@ -826,27 +835,27 @@ public class SystemTableView /** * Initialize drag and drop support for this view. - * - */ - protected void initDragAndDrop() + * + */ + protected void initDragAndDrop() { int ops = DND.DROP_COPY | DND.DROP_MOVE; - Transfer[] dragtransfers = new Transfer[] - { PluginTransfer.getInstance(), + Transfer[] dragtransfers = new Transfer[] + { PluginTransfer.getInstance(), EditorInputTransfer.getInstance() - }; - - Transfer[] droptransfers = new Transfer[] - { PluginTransfer.getInstance(), + }; + + Transfer[] droptransfers = new Transfer[] + { PluginTransfer.getInstance(), FileTransfer.getInstance(), EditorInputTransfer.getInstance() - }; - + }; + addDragSupport(ops | DND.DROP_DEFAULT, dragtransfers, new SystemViewDataDragAdapter(this)); addDropSupport(ops | DND.DROP_DEFAULT, droptransfers, new SystemViewDataDropAdapter(this)); } - /** + /** * Used to asynchronously update the view whenever properties change. * @see org.eclipse.rse.core.events.ISystemResourceChangeListener#systemResourceChanged(org.eclipse.rse.core.events.ISystemResourceChangeEvent) */ @@ -868,7 +877,7 @@ public class SystemTableView if (child == ((ISystemFilterReference)_objectInput).getReferencedFilter()) { SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - + if (provider != null) { if (!madeChange) @@ -876,7 +885,7 @@ public class SystemTableView provider.flushCache(); madeChange = true; } - + computeLayout(); try { @@ -889,7 +898,7 @@ public class SystemTableView } } - } + } } break; case ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE : @@ -900,19 +909,19 @@ public class SystemTableView { Widget w = findItem(child); if (w != null) - { + { updateItem(w, child); } } catch (Exception e) { - + } } return; //break; - - case ISystemResourceChangeEvents.EVENT_DELETE: + + case ISystemResourceChangeEvents.EVENT_DELETE: case ISystemResourceChangeEvents.EVENT_DELETE_MANY: { if (child instanceof ISystemFilterReference) @@ -921,11 +930,11 @@ public class SystemTableView if (w != null) { remove(child); - } + } } } - break; - + break; + case ISystemResourceChangeEvents.EVENT_ADD : case ISystemResourceChangeEvents.EVENT_ADD_RELATIVE : { @@ -948,7 +957,7 @@ public class SystemTableView } } break; - + case ISystemResourceChangeEvents.EVENT_REFRESH: case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE: { @@ -962,9 +971,9 @@ public class SystemTableView { Widget w = findItem(child); if (w != null && w.getData() != _objectInput) - { + { //child is the children of this table input. - //Need to refresh the whole view to handler + //Need to refresh the whole view to handler //And we need to make _objectInput to stale, otherwise deleted object //could not be removed from the table. if (_objectInput instanceof ISystemContainer) @@ -978,7 +987,7 @@ public class SystemTableView { SystemBasePlugin.logError(e.getMessage()); } - + } break; default : @@ -993,8 +1002,8 @@ public class SystemTableView if (provider != null) { if (!madeChange) - { - provider.flushCache(); + { + provider.flushCache(); madeChange = true; } @@ -1023,7 +1032,7 @@ public class SystemTableView Object remoteResourceParent = event.getResourceParent(); Object remoteResource = event.getResource(); List remoteResourceNames = null; - if (remoteResource instanceof List) { + if (remoteResource instanceof List) { remoteResourceNames = (List) remoteResource; remoteResource = remoteResourceNames.get(0); } @@ -1040,7 +1049,7 @@ public class SystemTableView refresh(); return; } - + switch (eventType) { // -------------------------- @@ -1123,7 +1132,7 @@ public class SystemTableView { ((ISystemContainer)_objectInput).markStale(true); } - + provider.flushCache(); madeChange = true; @@ -1200,10 +1209,10 @@ public class SystemTableView { provider.flushCache(); } - + refresh(); } - + } break; */ @@ -1232,19 +1241,19 @@ public class SystemTableView public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection sel = (IStructuredSelection)event.getSelection(); + IStructuredSelection sel = (IStructuredSelection)event.getSelection(); Object firstSelection = sel.getFirstElement(); if (firstSelection == null) return; - + _selectionFlagsUpdated = false; ISystemViewElementAdapter adapter = getViewAdapter(firstSelection); if (adapter != null) { displayMessage(adapter.getStatusLineText(firstSelection)); - if ((mouseButtonPressed == LEFT_BUTTON)) - adapter.selectionChanged(firstSelection); - } + if ((mouseButtonPressed == LEFT_BUTTON)) + adapter.selectionChanged(firstSelection); + } else clearMessage(); } @@ -1282,7 +1291,7 @@ public class SystemTableView * Everything below is basically stuff copied and pasted from SystemsView * -There needs to be cleaning up of the below code as some of this stuff * is broken for the table view - * + * * public void createStandardGroups(IMenuManager menu) { @@ -1315,7 +1324,7 @@ public class SystemTableView menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORGANIZE)); // rename,move,copy,delete,bookmark,refactoring menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORDER)); - // move up, move down + // move up, move down menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_GENERATE)); // getters/setters, etc. Typically in editor menu.add(new Separator(ISystemContextMenuConstants.GROUP_SEARCH)); @@ -1346,7 +1355,7 @@ public class SystemTableView if (_propertyDialogAction == null) { _propertyDialogAction = new PropertyDialogAction(new SameShellProvider(getShell()), this); - //propertyDialogAction.setToolTipText(" "); + //propertyDialogAction.setToolTipText(" "); } _propertyDialogAction.selectionChanged(getSelection()); return _propertyDialogAction; @@ -1447,7 +1456,7 @@ public class SystemTableView } /** * Required method from ISystemDeleteTarget - * Decides whether to enable the delete menu item. + * Decides whether to enable the delete menu item. * Assumes scanSelections() has already been called */ public boolean canDelete() @@ -1515,7 +1524,7 @@ public class SystemTableView return ok; } - + /** * Decides whether to even show the properties menu item. * Assumes scanSelections() has already been called @@ -1523,7 +1532,7 @@ public class SystemTableView protected boolean showProperties() { return _selectionShowPropertiesAction; } - + // --------------------------- // ISYSTEMRENAMETARGET METHODS // --------------------------- @@ -1551,7 +1560,7 @@ public class SystemTableView setUser(true); } - public IStatus runInWorkspace(IProgressMonitor monitor) + public IStatus runInWorkspace(IProgressMonitor monitor) { ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); Object element = null; @@ -1561,7 +1570,7 @@ public class SystemTableView String oldName = null; Vector fileNamesRenamed = new Vector(); boolean ok = true; - + try { int steps = elements.length; monitor.beginTask(renameMessage, steps); @@ -1571,21 +1580,21 @@ public class SystemTableView adapter = (ISystemViewElementAdapter)elementAdapters[i]; remoteAdapter = getRemoteAdapter(element); Object parentElement = getParentForContent(element); - if (remoteAdapter != null) + if (remoteAdapter != null) { oldName = remoteAdapter.getName(element); oldFullName = remoteAdapter.getAbsoluteName(element); // pre-rename monitor.subTask(getRenamingMessage(oldName).getLevelOneText()); } ok = adapter.doRename(null, element, newNames[i], monitor); - if (ok) + if (ok) { fileNamesRenamed.add(oldName); if (remoteAdapter != null) { // Don't think we need to do findItem and updateItem here. sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, element, parentElement, adapter.getSubSystem(element), new String[]{oldFullName}, this); - + } else @@ -1593,7 +1602,7 @@ public class SystemTableView } monitor.worked(1); } - } + } catch (SystemMessageException exc) { ok = false; //If this operation is canceled, need to display a proper message to the user. @@ -1620,7 +1629,7 @@ public class SystemTableView exc); ok = false; } - + return Status.OK_STATUS; } } @@ -1637,7 +1646,7 @@ public class SystemTableView } /** * Required method from ISystemRenameTarget - * Decides whether to enable the rename menu item. + * Decides whether to enable the rename menu item. * Assumes scanSelections() has already been called */ public boolean canRename() @@ -1648,32 +1657,32 @@ public class SystemTableView } // default implementation - // in default table, parent is input + // in default table, parent is input protected Object getParentForContent(Object element) { return _objectInput; } /** - * Get the specific "Renaming %1..." + * Get the specific "Renaming %1..." */ protected SystemMessage getRenamingMessage(String oldName) { - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_RENAMEGENERIC_PROGRESS); + SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_RENAMEGENERIC_PROGRESS); msg.makeSubstitution(oldName); return msg; } - + /** * Required method from ISystemRenameTarget */ public boolean doRename(String[] newNames) { - + IStructuredSelection selection = (IStructuredSelection) getSelection(); Iterator elements = selection.iterator(); - - + + Object[] renameElements = new Object[newNames.length]; Object[] elementAdapters = new Object[newNames.length]; int i = 0; @@ -1689,7 +1698,7 @@ public class SystemTableView RenameJob renameJob = new RenameJob(newNames, renameElements, elementAdapters, renameMessageText); renameJob.schedule(); return true; - + } /** @@ -1707,7 +1716,7 @@ public class SystemTableView ((ISystemViewElementAdapter) adapter).setViewer(this); return adapter; } - + /** * Return true if select all should be enabled for the given object. @@ -1720,9 +1729,9 @@ public class SystemTableView } /** * When this action is run via Edit->Select All or via Ctrl+A, perform the - * select all action. For a tree view, this should select all the children + * select all action. For a tree view, this should select all the children * of the given selected object. You can use the passed in selected object - * or ignore it and query the selected object yourself. + * or ignore it and query the selected object yourself. */ public void doSelectAll(IStructuredSelection selection) { @@ -1739,9 +1748,9 @@ public class SystemTableView public void menuAboutToShow(IMenuManager manager) { SystemView.createStandardGroups(manager); - + fillContextMenu(manager); - + if (!menuListenerAdded) { if (manager instanceof MenuManager) @@ -1794,7 +1803,7 @@ public class SystemTableView menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getRenameAction()); } - // ADAPTER SPECIFIC ACTIONS + // ADAPTER SPECIFIC ACTIONS SystemMenuManager ourMenu = new SystemMenuManager(menu); Iterator elements = selection.iterator(); @@ -1817,7 +1826,7 @@ public class SystemTableView AbstractSystemViewAdapter aVA = (AbstractSystemViewAdapter)nextAdapter; // add remote actions aVA.addCommonRemoteActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS); - + // add dynamic menu popups aVA.addDynamicPopupMenuActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADDITIONS); } @@ -1830,7 +1839,7 @@ public class SystemTableView if ((items[idx] instanceof ActionContributionItem) && (((ActionContributionItem) items[idx]).getAction() instanceof ISystemAction)) { ISystemAction item = (ISystemAction) (((ActionContributionItem) items[idx]).getAction()); - //item.setShell(getShell()); + //item.setShell(getShell()); //item.setSelection(selection); //item.setViewer(this); item.setInputs(getShell(), this, selection); @@ -1839,8 +1848,8 @@ public class SystemTableView { SystemSubMenuManager item = (SystemSubMenuManager) items[idx]; //item.setShell(getShell()); - //item.setSelection(selection); - //item.setViewer(this); + //item.setSelection(selection); + //item.setViewer(this); item.setInputs(getShell(), this, selection); } } @@ -1857,7 +1866,7 @@ public class SystemTableView // PROPERTIES ACTION... // This is supplied by the system, so we pretty much get it for free. It finds the // registered propertyPages extension points registered for the selected object's class type. - //propertyDialogAction.selectionChanged(selection); + //propertyDialogAction.selectionChanged(selection); if (showProperties()) { @@ -1867,7 +1876,7 @@ public class SystemTableView menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, pdAction); } } - + // OPEN IN NEW PERSPECTIVE ACTION... if (fromSystemViewPart && showOpenViewActions()) if (!_selectionIsRemoteObject) { @@ -1927,7 +1936,7 @@ public class SystemTableView if (_selectionShowRenameAction) _selectionShowRenameAction = adapter.showRename(element); - + if (_selectionShowPropertiesAction) _selectionShowPropertiesAction = adapter.showProperties(element); @@ -2004,7 +2013,7 @@ public class SystemTableView */ } } - + /** * Display a message/status on the message/status line */ @@ -2022,5 +2031,5 @@ public class SystemTableView _messageLine.clearMessage(); } - + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java index 51f0a2efc6e..a860c049c82 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java @@ -1,26 +1,27 @@ /******************************************************************************** * Copyright (c) 2000, 2008 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 + * 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, + * 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: * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType - * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() + * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Uwe Stieber (Wind River) - [192202] Default RSE new connection wizard does not allow to query created host instance anymore * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code * David Dykstal (IBM) - [168976][api] move ISystemNewConnectionWizardPage from core to UI + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading ********************************************************************************/ package org.eclipse.rse.ui.wizards.newconnection; @@ -33,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.Vector; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; @@ -70,7 +72,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar private ISystemProfile privateProfile = null; private IHost selectedContext = null; private static String lastProfile = null; - private IHost createdHost = null; + private IHost createdHost = null; /** * Constructor. @@ -90,7 +92,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar */ public void dispose() { super.dispose(); - + mainPage = null; subsystemConfigurationSuppliedWizardPages = null; ssfWizardPagesPerSystemType.clear(); @@ -115,7 +117,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar subsystemConfigurationSuppliedWizardPages = getAdditionalWizardPages(systemType); } } - + /** * Creates the wizard pages. This method is an override from the parent Wizard class. */ @@ -123,9 +125,9 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar try { // reset the remembered created host instance createdHost = null; - + mainPage = createMainPage(getSystemType()); - + SystemConnectionForm form = mainPage.getSystemConnectionForm(); if (form != null) { form.setCurrentlySelectedConnection(selectedContext); @@ -137,10 +139,10 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar // there had been a default connection name explicitly set from outside. if (defaultConnectionName != null) form.setConnectionName(defaultConnectionName); else form.setConnectionName(""); //$NON-NLS-1$ - + if (defaultHostName != null) form.setHostName(defaultHostName); } - + if (mainPage != null && getSystemType() != null) mainPage.setSystemType(getSystemType()); updateDefaultSelectedProfile(); @@ -188,12 +190,12 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar /** * Calculates the default profile name to propose on the default new * connection wizard main page. - * + * *

     	 * Expected order of default profile selection:
     	 *   1. If a connection is selected, the default profile is the one from the connection.
     	 *   2. If the wizard remembered the last profile and this last remembered profile is still
    -	 *      available and active, the remembered last profile is the default profile. 
    +	 *      available and active, the remembered last profile is the default profile.
     	 *   3. If the default private system profile is availabe and active, the default private system profile
     	 *      is the default profile.
     	 *   4. The first non-empty profile from the list of active profiles is the default profile.
    @@ -207,7 +209,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     
     		List profileNames = activeProfileNames != null ? Arrays.asList(activeProfileNames) : new ArrayList();
     		mainPage.getSystemConnectionForm().setProfileNames(activeProfileNames);
    -		
    +
     		// 1. If a connection is selected, the default profile is the one from the connection.
     		String defaultProfileName = selectedContext != null ? selectedContext.getSystemProfileName() : null;
     		if (defaultProfileName == null || !profileNames.contains(defaultProfileName)) {
    @@ -222,7 +224,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     				if (defaultPrivateProfile != null) defaultProfileName = defaultPrivateProfile.getName();
     				if (defaultProfileName == null || !profileNames.contains(defaultProfileName)) {
     					// 4. The first non-empty profile from the list of active profiles is the default profile.
    -					//    Note: The profile names get normalized within the constructor.  
    +					//    Note: The profile names get normalized within the constructor.
     					if (profileNames.size() > 0) defaultProfileName = (String)profileNames.get(0);
     				}
     			}
    @@ -236,9 +238,9 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     			if (selectedContext == null || !defaultProfileName.equals(selectedContext.getSystemProfileName()))
     				lastProfile = defaultProfileName;
     		}
    -		
    +
     	}
    -	
    +
     	/**
     	 * Set the currently selected context. Used to better default entry fields.
     	 */
    @@ -376,17 +378,17 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     	/**
     	 * Returns the create host instance once the user pressed finished. The created
     	 * host instance will be reset to null once the wizard got disposed.
    -	 * 
    +	 *
     	 * @return The created host instance or null.
     	 */
     	public IHost getCreatedHost() {
     		return createdHost;
     	}
    -		
    +
     	/**
     	 * Private method to get all the wizard pages from all the subsystem factories, given a
     	 * system type.
    -	 * 
    +	 *
     	 * @param systemType The system type to query the additional subsystem service pages for. Must be not null.
     	 */
     	private ISystemNewConnectionWizardPage[] getAdditionalWizardPages(IRSESystemType systemType) {
    @@ -400,6 +402,14 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     			ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType, true);
     			for (int idx = 0; idx < factories.length; idx++) {
     				ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)factories[idx].getAdapter(ISubSystemConfigurationAdapter.class);
    +				if (adapter == null) {
    +					// try to activate bundle - FIXME should perhaps be done
    +					// earlier in the action that shows the wizard dialog?
    +					// And, is it really necessary to get the wizard pages that
    +					// early already?
    +					Platform.getAdapterManager().loadAdapter(factories[idx], ISubSystemConfigurationAdapter.class.getName());
    +					adapter = (ISubSystemConfigurationAdapter) factories[idx].getAdapter(ISubSystemConfigurationAdapter.class);
    +				}
     
     				ISystemNewConnectionWizardPage[] pages = adapter.getNewConnectionWizardPages(factories[idx], this);
     				if (pages != null) {
    @@ -418,7 +428,7 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
     	}
     
     	/**
    -	 * Return true if there are additional pages. This decides whether to enable the Next button 
    +	 * Return true if there are additional pages. This decides whether to enable the Next button
     	 *  on the main page
     	 */
     	protected boolean hasAdditionalPages() {
    diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java
    index 5f95da7cf27..ba00fb3c5f0 100644
    --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java
    +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java
    @@ -3,13 +3,13 @@
      * 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) - 141803: Fix cpu usage 100% while connecting
      * David Dykstal (IBM) - 168870: moved SystemPreferencesManager to a new package
    @@ -35,6 +35,7 @@
      * David McKnight   (IBM)        - [220309] [nls] Some GenericMessages and SubSystemResources should move from UI to Core
      * David McKnight   (IBM)        - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
      * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception
    + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
      ********************************************************************************/
     
     package org.eclipse.rse.core.subsystems;
    @@ -137,14 +138,12 @@ import org.eclipse.ui.progress.WorkbenchJob;
      * 
  • {@link #internalGetProperties(Object subject, String[] keys, IProgressMonitor monitor)} *
  • {@link #internalSetProperties(Object subject, String[] keys, String[] values, IProgressMonitor monitor)} * - * + * */ public abstract class SubSystem extends RSEModelObject implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider { - - protected static final String SUBSYSTEM_FILE_NAME = "subsystem"; //$NON-NLS-1$ //protected transient SubSystemConfiguration parentFactory = null; @@ -182,11 +181,12 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider protected IHost _host; - protected String _name = null; protected String _subsystemConfigurationId = null; protected boolean _hidden = false; + private boolean _isInitialized = false; + /** * @generated This field/method will be replaced during code generation. @@ -495,7 +495,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider /* * (non-Javadoc) - * + * * @see org.eclipse.rse.core.subsystems.ISubSystem#checkIsConnected(org.eclipse.core.runtime.IProgressMonitor) */ public void checkIsConnected(IProgressMonitor monitor) throws SystemMessageException @@ -806,7 +806,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * when they do not find a reference for the key themselves. *

    * @see org.eclipse.rse.core.subsystems.IRemoteObjectResolver#getObjectWithAbsoluteName(String, IProgressMonitor) - * + * * @param key the unique id of the remote object. * Must not be null. * @param monitor the progress monitor @@ -2007,13 +2007,23 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider return false; } /** - * Return the children of this subsystem, to populate the GUI subtree of this subsystem. - * By default, this method: + * Return the children of this subsystem, to populate the GUI subtree of + * this subsystem. By default, this method: *
      - *
    • Returns the filter pool references of this subsystem, if supportsFilters() is true for our factory. - *
    • If supportsFilters() is false from our factory, returns null + *
    • Returns the filter pool references of this subsystem, if + * supportsFilters() is true for our factory. + *
    • If supportsFilters() is false from our factory, returns null *
    * So, be sure to override this method IF you do not support filters. + * + * Lazy Loading: Note that if your subsystem does not support connecting, + * and you do not support filters, here is a good point to ensure that the + * bundles which declare your UI adapters get loaded, since the default code + * which overriders usually place in + * {@link #initializeSubSystem(IProgressMonitor)} is not called in that + * case. Similarly, if your subsystem declares custom images for filters or + * filter pools, overriding the getChildren() call here to first load your + * filter adapters and THEN super.getChildren() is a good idea. */ public Object[] getChildren() { @@ -2073,7 +2083,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider /** * Resolve an absolute filter string. - * + * * This is only applicable if the subsystem * factory reports true for {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsFilters()}, * which is the default. Otherwise, {@link org.eclipse.rse.core.subsystems.SubSystem#getChildren()} @@ -2112,6 +2122,10 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider if (isConnected()) { + if (!supportsConnecting && !_isInitialized) { + // Lazy Loading: Load adapters (e.g. Local Subsystem) + initializeSubSystem(monitor); + } Object[] results = internalResolveFilterString(filterString, monitor); if (sortResults && (results!=null)) results = sortResolvedFilterStringObjects(results); @@ -2149,6 +2163,10 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider } if (isConnected()) { + if (!supportsConnecting && !_isInitialized) { + // Lazy Loading: Load adapters (e.g. Local Subsystem) + initializeSubSystem(monitor); + } Object[] results = internalResolveFilterStrings(filterStrings, monitor); if (sortResults && (results!=null)) results = sortResolvedFilterStringObjects(results); @@ -2197,6 +2215,10 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider { if (isConnected()) { + if (!supportsConnecting && !_isInitialized) { + // Lazy Loading: Load adapters (e.g. Local Subsystem) + initializeSubSystem(monitor); + } Object[] results= internalResolveFilterString(parent, filterString, monitor); if (sortResults && (results!=null)) results = sortResolvedFilterStringObjects(results); @@ -2226,7 +2248,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * @param key Identifies property to set * @param value Value to set property to * @return Object interpretable by subsystem. Might be a Boolean, or the might be new value for confirmation. - * + * * @deprecated this shouldn't be used */ public Object setProperty(Object subject, String key, String value) @@ -2242,7 +2264,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * @param subject Identifies which object to get the properties of * @param key Identifies property to get value of * @return String The value of the requested key. - * + * * @deprecated this shouldn't be used */ public String getProperty(Object subject, String key) @@ -2259,7 +2281,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * @param keys the array of propertie keys to set. * @param values the array of values to set. The value at a certain index corresponds to the property key at the same index. * @return Object interpretable by subsystem. Might be a Boolean, or the might be new values for confirmation. - * + * * @deprecated this shouldn't be used */ public Object setProperties(Object subject, String[] keys, String[] values) @@ -2269,26 +2291,37 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider } /** - * Initialize this subsystem instance after the corresponding {@link IConnectorService} connect method finishes. - * This method should be overridden if any initialization for the subsystem needs - * to occur at this time - *

    The default implementation currently does nothing, but overriding methods should call super. - * @param monitor a monitor that can be used to show progress or provide cancellation. + * Initialize this subsystem instance after the corresponding + * {@link IConnectorService} connect method finishes. This method should be + * overridden if any initialization for the subsystem needs to occur at this + * time. + *

    + * The default implementation currently does nothing, but overriding methods + * should call super before doing any other work. + * + * @param monitor a progress monitor that can be used to show progress + * during long-running operation. Cancellation is typically not + * supported since it might leave the system in an inconsistent + * state. */ public void initializeSubSystem(IProgressMonitor monitor) { + _isInitialized = true; } /** - * Uninitialize this subsystem just after disconnect. - * The default implementation currently does nothing. - * Overriding methods should call super. - * @param monitor a progress monitor that can be used to show uninitialization progress can provide cancellation. + * Uninitialize this subsystem just after disconnect. The default + * implementation currently does nothing. Overriding methods should call + * super after doing their own work. + * + * @param monitor a progress monitor that can be used to show progress + * during long-running operation. Cancellation is typically not + * supported since it might leave the system in an inconsistent + * state. */ public void uninitializeSubSystem(IProgressMonitor monitor) { + _isInitialized = false; } - - /* * Connect to a remote system with a monitor. * Required for Bug 176603 @@ -2441,7 +2474,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * displaying for you. *

    * Override internalDisconnect if you want, but by default it calls getSystem().disconnect(IProgressMonitor). - * + * */ public void disconnect() throws Exception { @@ -2454,7 +2487,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * displaying for you. *

    * Override internalDisconnect if you want, but by default it calls getSystem().disconnect(IProgressMonitor). - * + * * @param collapseTree collapse the tree in the system view */ public void disconnect(boolean collapseTree) throws Exception @@ -2497,7 +2530,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * @param subject Identifies which object to get the properties of * @param keys the array of property keys. * @return the values for the given property keys. - * + * * @deprecated this shouldn't be used */ public String[] getProperties(Object subject, String[] keys) @@ -2511,7 +2544,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * Return the {@link org.eclipse.rse.core.subsystems.IConnectorService IConnectorService} object that represents the live connection for this system. * This must return an object that implements {@link IConnectorService}. A good starting point for that * is the base class {@link AbstractConnectorService}. - * + * * The connector service gets passed in to the constructor for the subsystem so there's normally no reason * to override this method. * @@ -2523,7 +2556,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider /** * Sets the {@link org.eclipse.rse.core.subsystems.IConnectorService IConnectorService} object that represents the live connection for this system. - * + * * @param connectorService the connector service */ public void setConnectorService(IConnectorService connectorService) @@ -2558,7 +2591,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider /** * Return the CacheManager for this subsystem. This is the default implementation * which just returns null. - * + * * @see #supportsCaching() */ public ICacheManager getCacheManager() @@ -2577,7 +2610,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider * - well, actually you can throw anything and we'll wrap it here in an InvocationTargetException *

  • do not worry about calling monitor.done() ... caller will do that. * - * + * */ private void internalConnect(IProgressMonitor monitor) throws InvocationTargetException, OperationCanceledException diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystem.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystem.java index 5e93768f3c6..e049edf2989 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystem.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystem.java @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: * Tobias Schwarz (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation - * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading *******************************************************************************/ package org.eclipse.rse.tests.internal.testsubsystem; @@ -26,8 +27,8 @@ 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. + * Simple test subsystem with branches and leaves. Further children can be added + * or removed via context menu actions. */ public class TestSubSystem extends SubSystem implements ITestSubSystem { @@ -35,8 +36,9 @@ public class TestSubSystem extends SubSystem implements ITestSubSystem { /** * Constructor. - * @param host - * @param connectorService + * + * @param host the host to connect + * @param connectorService connector service to use */ public TestSubSystem(IHost host, IConnectorService connectorService) { super(host, connectorService); @@ -45,7 +47,8 @@ public class TestSubSystem extends SubSystem implements ITestSubSystem { /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#initializeSubSystem(org.eclipse.core.runtime.IProgressMonitor) */ - public void initializeSubSystem(IProgressMonitor monitor) { + public void initializeSubSystem(IProgressMonitor monitor) { + super.initializeSubSystem(monitor); TestSubSystemContainerNode parent0 = new TestSubSystemContainerNode("0"); //$NON-NLS-1$ TestSubSystemContainerNode child0 = new TestSubSystemContainerNode("0:0"); //$NON-NLS-1$ parent0.addChildNode(child0); @@ -63,19 +66,20 @@ public class TestSubSystem extends SubSystem implements ITestSubSystem { */ public void uninitializeSubSystem(IProgressMonitor monitor) { fChildren.clear(); + super.uninitializeSubSystem(monitor); } /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystem#getObjectWithAbsoluteName(java.lang.String) */ - public Object getObjectWithAbsoluteName(String key) throws Exception { + public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception { ITestSubSystemNode[] childs = getChildNodes(); for (int i = 0; i < childs.length; i++) { if (childs[i].getName().equalsIgnoreCase(key)) { return childs[i]; } } - return super.getObjectWithAbsoluteName(key); + return super.getObjectWithAbsoluteName(key, monitor); } /* (non-Javadoc)