Home » Eclipse Projects » Target Management » programmatically use RSE(How to open a remote file from within an RCP application?)
programmatically use RSE [message #756714] |
Mon, 14 November 2011 19:04 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
Hi,
I'm not quite sure if I'm submitting this question in the right forum, but what I would like to do and don't know how is the following:
From within the RCP application I am develloping I want to access a remote file and use the default system editor to open it. The code may look like this:
IFileStore fileStore = EFS.getFileSystem(scheme).getStore(fileNameURI);
IEditorInput editorInput = new FileStoreEditorInput(fileStore);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
The scheme is either 'file' if the file is local (which works), or it is ftp if the file is remote, which does not work because there is no scheme defined for ftp.
I would need to implement a filesystem extension for the ftp scheme, but I guess there is already some implementation in the RSE/TM for that. Is it possible to use it like this?
Thanx!
Julia
[Updated on: Mon, 14 November 2011 19:05] Report message to a moderator
|
|
| |
Re: programmatically use RSE [message #758026 is a reply to message #756714] |
Wed, 16 November 2011 14:55 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hi Julia,
The "rse" scheme serves files in a protocol-agnostic way. If you want to
use RSE as the FTP EFS provider, one thing you could do is create an FTP
Only connection in RSE and then write some code like the following:
URI fileNameURI = new URI("rse", host, path, null);
IFileStore fileStore = EFS.getFileSystem(scheme).getStore(fileNameURI);
IEditorInput editorInput = new FileStoreEditorInput(fileStore);
IEditorDescriptor descriptor = IDE.getEditorDescriptor(name);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
descriptor.getId());
Dave
"julia.kurde" <forums-noreply@eclipse.org> wrote in message
news:j9rnvo$s5n$1@news.eclipse.org...
> Hi,
>
> I'm not quite sure if I'm submitting this question in the right forum, but
> what I would like to do and don't know how is the following:
>
> From within the RCP application I am develloping I want to access a remote
> file and use the default system editor to open it. The code may look like
> this:
>
>
> IFileStore fileStore = EFS.getFileSystem(scheme).getStore(fileNameURI);
> IEditorInput editorInput = new FileStoreEditorInput(fileStore);
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
> IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
>
>
> The scheme is either 'file' if the file is local (which works), or it is
> ftp if the file is remote, which does not work because there is no scheme
> defined for ftp.
> I would need to implement a filesystem extension for the ftp scheme, but I
> guess there is already some implementation in the RSE/TM for that. Is it
> possible to use it like this?
>
> Thanx!
> Julia
|
|
| |
Re: programmatically use RSE [message #758260 is a reply to message #758063] |
Tue, 22 November 2011 13:29 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
Hi Dave,
I had a closer look to it and it seems the problem is that
FileStoreEditorInput does not implement org.eclipse.ui.IPathEditorInput
as it is required for an external editor (see the javadoc of IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).
On the other hand for the local file system there is no problem. In the class IURIEditorInputAdapterFactory an Adapter is created: PathEditorInputAdapter.
But if the file system is different from EFS.getLocalFileSystem(), no adapter is created and the editor will not open.
How can I deal with this?
Thanx again!
Julia
[Updated on: Tue, 22 November 2011 14:21] Report message to a moderator
|
|
|
Re: programmatically use RSE [message #758295 is a reply to message #758260] |
Tue, 22 November 2011 15:31 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hi Julia,
I'm not sure whether this helps your scenario but one alternative to using
EFS is to use RSE directly like this:
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
IHost rseHost = sr.getHost(sr.getActiveSystemProfiles()[0], host);
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(rseHost);
IRemoteFile remoteFile = ss.getRemoteFileObject(path, monitor);
IFile file =
(IFile)UniversalFileTransferUtility.downloadResourceToWorkspace(remoteFile,
monitor);
IEditorInput editorInput = new FileEditorInput(file);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
EditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
"jule" <forums-noreply@eclipse.org> wrote in message
news:jag83k$v4v$1@news.eclipse.org...
> Hi Dave,
>
> I had a closer look to it and it seems the problem is that
> FileStoreEditorInput does not implement org.eclipse.ui.IPathEditorInput as
> it is required for an external editor (see the javadoc of
> IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).
> There are some implementations of IPathEditorInput, e.g.
> org.eclipse.ui.part.FileEditorInput. But this one needs an IFile Object,
> which I dont't know how to get from the IFileStore object.
> Another one is
> org.eclipse.ui.internal.ide.IURIEditorInputAdapterFactory.PathEditorInputAdapter,
> which wants an IFileStore object, but is internal.
>
> Thanx again!
> Julia
>
|
|
| | | |
Re: programmatically use RSE [message #758587 is a reply to message #758569] |
Wed, 23 November 2011 19:26 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hmm, maybe I need to step back for a moment. I was assuming that you had
already defined an RSE IHost but that might not be the case. If not, you'll
need to do that (either via the Remote Systems view or programmatically)
first. If you already have a connection defined, then I suppose you could
use this alternative to get at all the hosts and then find the one that's
applicable to you:
IHost[] hosts = sr.getHosts();
"jule" <forums-noreply@eclipse.org> wrote in message
news:jajbi0$8pp$1@news.eclipse.org...
> OK... we are one step further!
>
> Now, I'm getting my profile, which looks like this:
>
> SystemProfile:
> _isDirty true _isTainted true _propertySets LinkedHashMap<K,V> /* empty */
> _wasRestored false defaultPrivate true isActive true mgr
> SystemProfileManager
> name "juliasrechner"
> provider null suspended false
> But then I don't get the rseHost. The method
> sr.getHost(profiles[0], host);
> returns null. The host is a valid IP address, profiles are the ones I got
> from
> sr.getActiveSystemProfiles().
>
> I don't have the source of the SystemRegistry class so I can't follow this
> problem in more detail, sorry! Maybe it is related to the provider of the
> profile, which is null.
>
> Thanx for your patience!
> Julia
|
|
|
Re: programmatically use RSE [message #758597 is a reply to message #758587] |
Wed, 23 November 2011 20:08 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
You're right, I did not define any RSE IHost yet (sr.getHosts() returns an empty array). I have to do it programmatically, because the RCP application I'm working on runs independently from the Remote Systems view.
Maybe I shortly explain the scenario how I want to use the RSE.
The user has this RCP application on his computer. There he opens a DB table which is displayed in an eclipse editor. The table contains file names. Via a context menu the user can select an action that opens the file in an external editor. The URL where to look for the file is set in the user preferences, which I'm reading in the run() method of that action.
So, I guess in this run() method I have to check whether there is already an IHost defined, and if not, define one.
Or, maybe we have to go back to the solution with an adapter for an IPathEditorInput for FileStoreEditorInput?
I'm a little bit lost in the moment, sorry!
Julia
|
|
|
Re: programmatically use RSE [message #758606 is a reply to message #758597] |
Wed, 23 November 2011 20:38 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
You could try something like this to create your host:
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile =
systemRegistry.getSystemProfileManager().getDefaultPrivateSystemProfile();
String profileName = profile.getName();
String hostAlias = "myhost";
String hostname = "myhost";
String userId = "myid";
IRSESystemType systemType =
RSECorePlugin.getTheCoreRegistry().getSystemTypeById("org.eclipse.rse.systemtype.ftp");
IHost host = systemRegistry.createHost(profileName, systemType, hostAlias,
hostname, null, userId, IRSEUserIdConstants.USERID_LOCATION_HOST, null);
"jule" <forums-noreply@eclipse.org> wrote in message
news:jajjru$p68$1@news.eclipse.org...
> You're right, I did not define any RSE IHost yet (sr.getHosts() returns an
> empty array). I have to do it programmatically, because the RCP
> application I'm working on runs independently from the Remote Systems
> view.
> Maybe I shortly explain the scenario how I want to use the RSE.
> The user has this RCP application on his computer. There he opens a DB
> table which is displayed in an eclipse editor. The table contains file
> names. Via a context menu the user can select an action that opens the
> file in an external editor. The URL where to look for the file is set in
> the user preferences, which I'm reading in the run() method of that
> action.
> So, I guess in this run() method I have to check whether there is already
> an IHost defined, and if not, define one.
>
> Or, maybe we have to go back to the solution with an adapter for an
> IPathEditorInput for FileStoreEditorInput?
>
> I'm a little bit lost in the moment, sorry!
>
> Julia
|
|
| | | |
Re: programmatically use RSE [message #758865 is a reply to message #758842] |
Thu, 24 November 2011 20:06 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Julia,
In your case do you still have the waitForInitCompletion() call? Perhaps
that's what's preventing things from working. The following code did work
for me after RSE is loaded (after waitForInitCompletion()).
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
ISystemProfile profile =
systemRegistry.getSystemProfileManager().getDefaultPrivateSystemProfile();
String profileName = profile.getName();
IRSESystemType systemType =
RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID);
IHost newHost = systemRegistry.createHost(profileName, systemType,
hostAlias, hostname, null, userId, IRSEUserIdConstants.USERID_LOCATION_HOST,
null);
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(newHost);
IRemoteFile remoteFile = ss.getRemoteFileObject(path, monitor);
IFile file =
(IFile)UniversalFileTransferUtility.downloadResourceToWorkspace(remoteFile,
monitor);
IEditorInput editorInput = new FileEditorInput(file);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
EditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
Dave
"jule" <forums-noreply@eclipse.org> wrote in message
news:jaltm7$bdo$1@news.eclipse.org...
> Hi Dave,
>
> In the Remote System view I can create an SSH-only connection and browse
> the files, no problem! But trying this programmatically, I get again null
> for both, the configuration
>
> IRSESystemType systemType =
> RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID);
> RemoteFileUtility.getFileSubSystemConfiguration(systemType);
>
> as well as the file subsystem
> RemoteFileUtility.getFileSubSystem(rseHost);
>
> In the RCP Application I have to add every required plugin manually. So
> far I have
>
> <requires>
> <import plugin="org.eclipse.ui"/>
> <import plugin="org.eclipse.core.filesystem"/>
> <import plugin="org.eclipse.core.runtime"/>
> <import plugin="org.eclipse.ui.ide"/>
> <import plugin="org.eclipse.core.resources" version="3.7.100"/>
> <import plugin="org.eclipse.rse.core" version="3.2.1"/>
> <import plugin="org.eclipse.rse.subsystems.files.core"
> version="3.2.101"/>
> <import plugin="org.eclipse.rse.services" version="3.2.101"/>
> <import plugin="org.eclipse.rse.files.ui" version="3.2.1"/>
> </requires>
>
> Maybe that's not enough...
>
> Julia
|
|
|
Re: programmatically use RSE [message #758934 is a reply to message #758865] |
Fri, 25 November 2011 10:46 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
Hi Dave,
I'm doing exactly this, and I'm running into a NullPointerException in createHost.
Maybe the stack trace is helpful.
java.lang.NullPointerException
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createNode(RSEDOMExporter.java:332)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.populateRSEDOM(RSEDOMExporter.java:142)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createRSEDOM(RSEDOMExporter.java:92)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.save(RSEPersistenceManager.java:555)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.commitProfile(RSEPersistenceManager.java:257)
at org.eclipse.rse.internal.core.model.SystemProfileManager.commitSystemProfile(SystemProfileManager.java:117)
at org.eclipse.rse.internal.core.model.SystemProfile.commit(SystemProfile.java:272)
at org.eclipse.rse.internal.core.model.SystemProfileManager.commitProfiles(SystemProfileManager.java:108)
at org.eclipse.rse.internal.core.model.SystemProfileManager.runOperation(SystemProfileManager.java:99)
at org.eclipse.rse.internal.core.model.SystemProfileManager.run(SystemProfileManager.java:86)
at org.eclipse.rse.internal.core.model.SystemRegistry.createHost(SystemRegistry.java:1629)
at org.eclipse.rse.internal.core.model.SystemRegistry.createHost(SystemRegistry.java:1529)
at eub.lzhview.actions.OpenDocumentAction.internalRun(OpenDocumentAction.java:232)
at eub.lzhview.actions.OpenDocumentAction.access$0(OpenDocumentAction.java:96)
at eub.lzhview.actions.OpenDocumentAction$1.runInUIThread(OpenDocumentAction.java:89)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at eub.rcplzhview.Application.start(Application.java:22)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
!SESSION 2011-11-25 11:32:47.347 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_29
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments: -product eub.rcplzhview.JLZHView
Command-line arguments: -product eub.rcplzhview.JLZHView -data C:\JAVA\Workspace_jLZHview/../runtime-eub.rcplzhview.JLZHView -dev file:C:/JAVA/Workspace_jLZHview/.metadata/.plugins/org.eclipse.pde.core/eub.rcplzhview.JLZHView/dev.properties -os win32 -ws win32 -arch x86 -consoleLog
!ENTRY org.eclipse.ui 4 4 2011-11-25 11:33:08.378
!MESSAGE An internal error has occurred.
Unfortunatelly I can not look into the internal rse classes. The host still will be created though. The second time, because I check whether rseHost == null, createHost() is not called again, but the file system can not be loaded.
RemoteFileUtility.getFileSubSystem(rseHost);
returns null.
With the same parameters as I call createHost() in the code, I can create a connection in the Remote Systems view without any problem (SSH only, FTP does not work there either because of anonymous server).
My workaround for windows in the moment is to execute a command that uses the windows explorer:
String cmd = "explorer " + fileURL.toExternalForm();
Process process = Runtime.getRuntime().exec(cmd);
Very simple... But our application is supposed to run on Linux, too. So I need something platform independent. The RSE seemed a solution to me...
Do you think it's possible??
Julia
|
|
|
Re: programmatically use RSE [message #759004 is a reply to message #758934] |
Fri, 25 November 2011 14:47 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Julia, have you had a chance to debug this? For the stack it would appear
that either the host or it's system type are null. Can you check that?
"jule" <forums-noreply@eclipse.org> wrote in message
news:janrmb$302$1@news.eclipse.org...
> Hi Dave,
>
> I'm doing exactly this, and I'm running into a NullPointerException in
> createHost.
> Maybe the stack trace is helpful.
> java.lang.NullPointerException
> at
> org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createNode(RSEDOMExporter.java:332)
> at
> org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.populateRSEDOM(RSEDOMExporter.java:142)
> at
> org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createRSEDOM(RSEDOMExporter.java:92)
> at
> org.eclipse.rse.internal.persistence.RSEPersistenceManager.save(RSEPersistenceManager.java:555)
> at
> org.eclipse.rse.internal.persistence.RSEPersistenceManager.commitProfile(RSEPersistenceManager.java:257)
> at
> org.eclipse.rse.internal.core.model.SystemProfileManager.commitSystemProfile(SystemProfileManager.java:117)
> at
> org.eclipse.rse.internal.core.model.SystemProfile.commit(SystemProfile.java:272)
> at
> org.eclipse.rse.internal.core.model.SystemProfileManager.commitProfiles(SystemProfileManager.java:108)
> at
> org.eclipse.rse.internal.core.model.SystemProfileManager.runOperation(SystemProfileManager.java:99)
> at
> org.eclipse.rse.internal.core.model.SystemProfileManager.run(SystemProfileManager.java:86)
> at
> org.eclipse.rse.internal.core.model.SystemRegistry.createHost(SystemRegistry.java:1629)
> at
> org.eclipse.rse.internal.core.model.SystemRegistry.createHost(SystemRegistry.java:1529)
> at
> eub.lzhview.actions.OpenDocumentAction.internalRun(OpenDocumentAction.java:232)
> at
> eub.lzhview.actions.OpenDocumentAction.access$0(OpenDocumentAction.java:96)
> at
> eub.lzhview.actions.OpenDocumentAction$1.runInUIThread(OpenDocumentAction.java:89)
> at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at eub.rcplzhview.Application.start(Application.java:22)
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
> !SESSION 2011-11-25
> 11:32:47.347 -----------------------------------------------
> eclipse.buildId=unknown
> java.version=1.6.0_29
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
> Framework arguments: -product eub.rcplzhview.JLZHView
> Command-line arguments: -product eub.rcplzhview.JLZHView -data
> C:\JAVA\Workspace_jLZHview/../runtime-eub.rcplzhview.JLZHView -dev
> file:C:/JAVA/Workspace_jLZHview/.metadata/.plugins/org.eclipse.pde.core/eub.rcplzhview.JLZHView/dev.properties -
> os win32 -ws win32 -arch x86 -consoleLog
>
> !ENTRY org.eclipse.ui 4 4 2011-11-25 11:33:08.378
> !MESSAGE An internal error has occurred.
>
> Unfortunatelly I can not look into the internal rse classes. The host
> still will be created though. The second time, because I check whether
> rseHost == null, createHost() is not called again, but the file system can
> not be loaded. RemoteFileUtility.getFileSubSystem(rseHost);
> returns null.
> With the same parameters as I call createHost() in the code, I can create
> a connection in the Remote Systems view without any problem (SSH only, FTP
> does not work there either because of anonymous server).
>
> My workaround for windows in the moment is to execute a command that uses
> the windows explorer:
>
> String cmd = "explorer " + fileURL.toExternalForm();
> Process process = Runtime.getRuntime().exec(cmd);
>
> Very simple... But our application is supposed to run on Linux, too. So I
> need something platform independent. The RSE seemed a solution to me... Do
> you think it's possible??
>
> Julia
|
|
|
Re: programmatically use RSE [message #759031 is a reply to message #759004] |
Fri, 25 November 2011 17:18 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
Your right! I don't get any system type.
RSECorePlugin.getTheCoreRegistry().getSystemTypeById(id);
returns null for
id = IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID as well as for
id = IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID.
I just checked this also on another pc and it is the same.
The system types I get from
RSECorePlugin.getTheCoreRegistry().getSystemTypes();
are
Windows (org.eclipse.rse.systemtype.windows)
Linux (org.eclipse.rse.systemtype.linux)
Unix (org.eclipse.rse.systemtype.unix)
Local (org.eclipse.rse.systemtype.local)
Seems indeed some dependencies are missing.
[Updated on: Fri, 25 November 2011 17:36] Report message to a moderator
|
|
| | | | | | | |
Re: programmatically use RSE [message #759690 is a reply to message #759121] |
Tue, 29 November 2011 16:10 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hi Julia,
I'm not sure what's going on here in your scenario. Some things to
consisder are:
1) Try the scenario with a clean workspace.
2) For FTP, makes sure you have the following dependency:
org.apache.commons.net
3) After creating a connection, you may want to add credentials like this:
SystemSignonInformation info = new SystemSignonInformation(address, userId,
password, systemType);
PasswordPersistenceManager.getInstance().add(info, true, false);
4) Make sure your plugin(s) and launch configurations don't have any errors
before launching.
Dave
"jule" <forums-noreply@eclipse.org> wrote in message
news:jaquok$v2u$1@news.eclipse.org...
> rseHost.getSubSystems(); RemoteFileUtility.getFileSubSystems(rseHost);
> both return an empty array. The rseHost looks like this:
>
> rseHost Host (id=4401) _isDirty false _isTainted false _profile
> SystemProfile (id=4400) _propertySets LinkedHashMap<K,V> (id=4408)
> _wasRestored true aliasName "172.31.10.10" (id=4407) defaultUserId null
> description null hostName "172.31.10.10" (id=4409) offline false pool
> SystemHostPool (id=4410) previousUserIdKey "juliasrechner.172.31.10.10"
> (id=4411) promptable false systemType RSESystemType (id=4397) ucId false
> userIdCaseSensitive false
> The defaultUserId is null although I create the rseHost with a non-null
> string for the defaultUserId. I don't know why this is not kept. The
> systemType is SSH only.
|
|
| |
Re: programmatically use RSE [message #760822 is a reply to message #760545] |
Mon, 05 December 2011 11:40 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
The thing is solved!!
I'm pasting here the complete code. Maybe it is helpful for somebody...
URL fileURL = new URL(EDSPathURL , fileNames[i]); /* create URL from path set in user preferences */
URI fileNameURI = fileURL.toURI(); /* convert to URI */
String scheme = fileNameURI.getScheme();
String host = fileURL.getHost();
String path = fileURL.getPath();
IEditorInput editorInput;
if (scheme.equalsIgnoreCase("file")) { /* open local file */
IFileStore fileStore = EFS.getFileSystem(scheme).getStore(fileNameURI);
editorInput = new FileStoreEditorInput(fileStore);
} else if (scheme.equalsIgnoreCase("ftp")) { /* open file via ftp */
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
RSECorePlugin.waitForInitCompletion();
ISystemProfile profile = systemRegistry.getSystemProfileManager().getDefaultPrivateSystemProfile();
IHost rseHost = systemRegistry.getHost(profile, host);
if (rseHost == null) {
System.out.println("Create IHost... ");
String profileName = profile.getName();
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID);
int defaultUserIdLocation = IRSEUserIdConstants.USERID_LOCATION_HOST;
rseHost = systemRegistry.createHost(
profileName, /* Name of the system profile the connection is to be added to */
systemType, /* system type matching one of the system types defined via the systemTypes extension point */
host, /* unique connection name */
host, /* ip name of host */
null, /* optional description of the connection. Can be null */
null, /* userId to use as the default for the subsystems */
defaultUserIdLocation, /* one of the constants in IRSEUserIdConstants that tells us where to store the user Id */
null /* these are the configurators supplied by the subsystem configurations that pertain to the specified system type. Else null */
);
}
rseHost.setDefaultUserId("ftp");
rseHost.getConnectorServices()[0].setPassword("ftp", "", true, true); /* userID must be either 'ftp' or 'anonymous' for an anonymous connection. Otherwise comment this line out and a dialog will pop up for the user to enter a passwort */
rseHost.getConnectorServices()[0].connect(monitor);
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(rseHost);
IRemoteFile remoteFile = ss.getRemoteFileObject(path, monitor);
IFile file = (IFile) UniversalFileTransferUtility.downloadResourceToWorkspace(remoteFile, monitor);
editorInput = new FileEditorInput(file);
rseHost.getConnectorServices()[0].disconnect(monitor);
} else { /* scheme is neither local nor FTP only... do something else... */
}
String id = IDE.getEditorDescriptor(fileNames[i]).getId();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput, id);
When executing this code the server replies the following
220 "LZH-Schemata-FTP-Server."
USER anonymous
331 Please specify the password.
PASS ******
230 Login successful.
SYST
215 UNIX Type: L8
TYPE I
200 Switching to Binary mode.
PWD
257 "/"
NOOP
200 NOOP ok.
CWD /EDS
250 Directory successfully changed.
PORT 172,31,10,216,10,240
200 PORT command successful. Consider using PASV.
LIST -a
150 Here comes the directory listing.
226 Directory send OK.
QUIT
221 Goodbye.
By the way this works for passive as well for an active connection.
Finally, the required plugins in the dependencies are:
<import plugin="org.eclipse.rse.core" version="3.2.1"/>
<import plugin="org.eclipse.rse.subsystems.files.core" version="3.2.101"/>
<import plugin="org.eclipse.rse.subsystems.files.ftp" version="2.1.301"/>
<import plugin="org.eclipse.rse.services" version="3.2.101"/>
<import plugin="org.eclipse.rse.files.ui" version="3.2.1"/>
<import plugin="org.eclipse.rse.ui" version="3.2.1"/>
<import plugin="org.eclipse.rse.connectorservice.dstore" version="3.1.200"/>
Thanks, Dave, for discussions!
Regards, Julia
|
|
|
Re: programmatically use RSE [message #761063 is a reply to message #760822] |
Mon, 05 December 2011 20:48 |
David McKnight Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hi Julie,
Sorry I missed your last message. I'm glad you got everything working!
Dave
"jule" <forums-noreply@eclipse.org> wrote in message
news:jbiain$q69$1@news.eclipse.org...
> The thing is solved!!
> I'm pasting here the complete code. Maybe it is helpful for somebody...
>
> URL fileURL = new URL(EDSPathURL , fileNames[i]); /* create URL from path
> set in user preferences */
> URI fileNameURI = fileURL.toURI(); /* convert to URI */
> String scheme = fileNameURI.getScheme();
> String host = fileURL.getHost();
> String path = fileURL.getPath();
> IEditorInput editorInput;
>
> if (scheme.equalsIgnoreCase("file")) { /* open local file */
> IFileStore fileStore = EFS.getFileSystem(scheme).getStore(fileNameURI);
> editorInput = new FileStoreEditorInput(fileStore);
> } else if (scheme.equalsIgnoreCase("ftp")) { /* open file via ftp */
> ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
> RSECorePlugin.waitForInitCompletion();
>
> ISystemProfile profile =
> systemRegistry.getSystemProfileManager().getDefaultPrivateSystemProfile();
> IHost rseHost = systemRegistry.getHost(profile, host);
> if (rseHost == null) {
> System.out.println("Create IHost... ");
> String profileName = profile.getName();
> IRSESystemType systemType =
> RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID);
> int defaultUserIdLocation = IRSEUserIdConstants.USERID_LOCATION_HOST;
> rseHost = systemRegistry.createHost(
> profileName, /* Name of the system profile the connection is to
> be added to */
> systemType, /* system type matching one of the system types
> defined via the systemTypes extension point */
> host, /* unique connection name */
> host, /* ip name of host */
> null, /* optional description of the connection. Can be
> null */
> null, /* userId to use as the default for the subsystems
> */ defaultUserIdLocation, /* one of the constants in IRSEUserIdConstants
> that tells us where to store the user Id */
> null /* these are the configurators supplied by the
> subsystem configurations that pertain to the specified system type. Else
> null */
> );
> }
> rseHost.setDefaultUserId("ftp");
> rseHost.getConnectorServices()[0].setPassword("ftp", "", true, true); /*
> userID must be either 'ftp' or 'anonymous' for an anonymous connection.
> Otherwise comment this line out and a dialog will pop up for the user to
> enter a passwort */
> rseHost.getConnectorServices()[0].connect(monitor);
> IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(rseHost);
> IRemoteFile remoteFile = ss.getRemoteFileObject(path, monitor);
> IFile file = (IFile)
> UniversalFileTransferUtility.downloadResourceToWorkspace(remoteFile,
> monitor);
> editorInput = new FileEditorInput(file);
> rseHost.getConnectorServices()[0].disconnect(monitor);
> } else { /* scheme is neither local nor FTP only... do something else...
> */
> }
> String id = IDE.getEditorDescriptor(fileNames[i]).getId();
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
> id);
>
> When executing this code the server replies the following
>
> 220 "LZH-Schemata-FTP-Server."
>
> USER anonymous
> 331 Please specify the password.
>
> PASS ******
> 230 Login successful.
>
> SYST
> 215 UNIX Type: L8
>
> TYPE I
> 200 Switching to Binary mode.
>
> PWD
> 257 "/"
>
> NOOP
> 200 NOOP ok.
>
> CWD /EDS
> 250 Directory successfully changed.
>
> PORT 172,31,10,216,10,240
> 200 PORT command successful. Consider using PASV.
>
> LIST -a
> 150 Here comes the directory listing.
>
> 226 Directory send OK.
>
> QUIT
> 221 Goodbye.
>
> By the way this works for passive as well for an active connection.
> Finally, the required plugins in the dependencies are:
>
> <import plugin="org.eclipse.rse.core" version="3.2.1"/>
> <import plugin="org.eclipse.rse.subsystems.files.core"
> version="3.2.101"/>
> <import plugin="org.eclipse.rse.subsystems.files.ftp"
> version="2.1.301"/>
> <import plugin="org.eclipse.rse.services" version="3.2.101"/>
> <import plugin="org.eclipse.rse.files.ui" version="3.2.1"/>
> <import plugin="org.eclipse.rse.ui" version="3.2.1"/>
> <import plugin="org.eclipse.rse.connectorservice.dstore"
> version="3.1.200"/>
>
> Thanks, Dave, for discussions!
> Regards, Julia
|
|
|
Goto Forum:
Current Time: Thu Apr 25 22:27:54 GMT 2024
Powered by FUDForum. Page generated in 0.05718 seconds
|