1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.remote
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.runtime
.Status
;
16 import org
.eclipse
.rse
.core
.model
.IHost
;
17 import org
.eclipse
.rse
.core
.model
.IRSECallback
;
18 import org
.eclipse
.rse
.core
.subsystems
.ICommunicationsListener
;
19 import org
.eclipse
.rse
.core
.subsystems
.IConnectorService
;
20 import org
.eclipse
.rse
.core
.subsystems
.ISubSystem
;
21 import org
.eclipse
.rse
.services
.IService
;
22 import org
.eclipse
.rse
.services
.shells
.IShellService
;
23 import org
.eclipse
.rse
.services
.terminals
.ITerminalService
;
24 import org
.eclipse
.rse
.subsystems
.files
.core
.servicesubsystem
.IFileServiceSubSystem
;
27 * <b><u>RemoteSystemProxy</u></b>
29 * RemoteSystemProxy implementation.
32 public class RemoteSystemProxy
implements IRemoteSystemProxy
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
42 public RemoteSystemProxy(IHost host
) {
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellService(org.eclipse.rse.core.model.IHost)
53 public IShellService
getShellService() {
54 ISubSystem ss
= getShellServiceSubSystem();
56 return (IShellService
)ss
.getSubSystemConfiguration().getService(fHost
).getAdapter(IShellService
.class);
62 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalService()
65 public ITerminalService
getTerminalService() {
66 ISubSystem ss
= getTerminalServiceSubSystem();
68 return (ITerminalService
)ss
.getSubSystemConfiguration().getService(fHost
).getAdapter(ITerminalService
.class);
74 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellServiceSubSystem()
77 public ISubSystem
getShellServiceSubSystem() {
81 ISubSystem
[] subSystems
= fHost
.getSubSystems();
82 IShellService ssvc
= null;
83 for (int i
= 0; subSystems
!= null && i
< subSystems
.length
; i
++) {
84 IService svc
= subSystems
[i
].getSubSystemConfiguration().getService(fHost
);
86 ssvc
= (IShellService
)svc
.getAdapter(IShellService
.class);
96 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalServiceSubSystem()
99 public ISubSystem
getTerminalServiceSubSystem() {
103 ISubSystem
[] subSystems
= fHost
.getSubSystems();
104 ITerminalService ssvc
= null;
105 for (int i
= 0; subSystems
!= null && i
< subSystems
.length
; i
++) {
106 IService svc
= subSystems
[i
].getSubSystemConfiguration().getService(fHost
);
108 ssvc
= (ITerminalService
)svc
.getAdapter(ITerminalService
.class);
110 return subSystems
[i
];
119 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
122 public IFileServiceSubSystem
getFileServiceSubSystem() {
126 ISubSystem
[] subSystems
= fHost
.getSubSystems();
127 for (int i
= 0; subSystems
!= null && i
< subSystems
.length
; i
++) {
128 if (subSystems
[i
] instanceof IFileServiceSubSystem
) {
129 return (IFileServiceSubSystem
)subSystems
[i
];
136 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
139 public void connect(IRSECallback callback
) throws ExecutionException
{
140 ISubSystem shellSubSystem
= getShellServiceSubSystem();
141 if (shellSubSystem
!= null) {
142 if (!shellSubSystem
.isConnected()) {
144 shellSubSystem
.connect(false, callback
);
145 } catch (Exception e
) {
146 throw new ExecutionException(e
.toString(), e
);
149 callback
.done(Status
.OK_STATUS
, null);
155 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#disconnect()
158 public void disconnect() throws ExecutionException
{
159 ISubSystem shellSubSystem
= getShellServiceSubSystem();
160 if (shellSubSystem
!= null) {
162 shellSubSystem
.disconnect();
163 } catch (Exception e
) {
164 throw new ExecutionException(e
.toString(), e
);
170 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#createCommandShell()
173 public ICommandShell
createCommandShell() throws ExecutionException
{
174 ICommandShell shell
= new CommandShell(this);
180 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#addCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
183 public void addCommunicationListener(ICommunicationsListener listener
) {
184 IConnectorService
[] css
= fHost
.getConnectorServices();
185 for (IConnectorService cs
: css
) {
186 cs
.addCommunicationsListener(listener
);
191 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#removeCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
194 public void removeCommunicationListener(ICommunicationsListener listener
) {
195 IConnectorService
[] css
= fHost
.getConnectorServices();
196 for (IConnectorService cs
: css
) {
197 cs
.removeCommunicationsListener(listener
);