[411387] SystemRemoteFolderDialog should return a path when selecting 'My Home' or 'Root'
RFC PATCH 1/1 [411387] SystemRemoteFolderDialog should return a path when selecting 'My Home' or 'Root'
- when browsing to pick the project location, if "My Home" or "Root" get picked the project location remains empty
- this is caused by the RSEUIFileManager browseDirectory method
- the selection made in the SystemRemoteFolderDialog is an SystemFilterReference, and thus not a instance of IRemoteFile.
- if the selection is of type ISystemFilterReference:
- make sure that the children of the system filter are populated
- retrieve the adapter for the filter and populate the children list
- retrieve first child from the list & return parent path
- if the parent path is null for the first child:
- this is actually the root of the file system -> return path of this child
--- .../ptp/remote/rse/ui/RSEUIFileManager.java | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
core/org.eclipse.ptp.remote.rse.ui/src/org/eclipse/ptp/remote/rse/ui/RSEUIFileManager.java +26 -1
@@ -7,21 +7,27 @@ * * Contributors: * IBM Corporation - Initial API and implementation + * Ioana Grigoropol (Intel) - browseDirectory should return a path when selecting 'My Home' or 'Root' *******************************************************************************/ package org.eclipse.ptp.remote.rse.ui; import java.util.Vector; +import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.jface.window.Window; import org.eclipse.ptp.remote.core.IRemoteConnection; import org.eclipse.ptp.remote.core.IRemoteConnectionManager; import org.eclipse.ptp.remote.core.IRemoteServices; import org.eclipse.ptp.remote.rse.core.RSEConnection; import org.eclipse.ptp.remote.ui.IRemoteUIFileManager; +import org.eclipse.rse.core.filters.ISystemFilterReference; import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.SystemChildrenContentsType; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog; +import org.eclipse.rse.internal.ui.view.SystemViewFilterReferenceAdapter; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.swt.widgets.Shell; public class RSEUIFileManager implements IRemoteUIFileManager {
@@ -51,6 +57,25 @@ public class RSEUIFileManager implements IRemoteUIFileManager { if (retObj instanceof IRemoteFile) { IRemoteFile selectedFile = (IRemoteFile) retObj; return selectedFile.getAbsolutePath(); + } else if (retObj instanceof ISystemFilterReference){ + ISystemFilterReference selectedFile = (ISystemFilterReference)retObj; + + RSEUIPlugin plugin = RSEUIPlugin.getDefault(); + if (selectedFile.getContents(SystemChildrenContentsType.getInstance()) == null) { + // in order to make sure that the children of this SystemFilterReference are populated + // the method getChildren() of the underlying adapter must be invoked + IAdapterFactory factory = plugin.getSystemViewAdapterFactory(); + SystemViewFilterReferenceAdapter adapter = (SystemViewFilterReferenceAdapter)factory.getAdapter(selectedFile, ISystemFilterReference.class); + adapter.getChildren(selectedFile); + } + // now that the children are cached for the filter references we can try and access them + Object[] con = selectedFile.getContents(SystemChildrenContentsType.getInstance()); + if (con != null && con[0] instanceof IRemoteFile) { + IRemoteFile file = (IRemoteFile)con[0]; + if (file.getParentPath() == null) + return file.getAbsolutePath();// this is actually the root of the file system + return file.getParentPath(); + } } } return null;
@@ -134,4 +159,4 @@ public class RSEUIFileManager implements IRemoteUIFileManager { public void showConnections(boolean enable) { onlyConnection = !enable; } -} +}
Signature · 1 line
1.7.10.4