Update internal packages export in LTTng 2.0 control + update java doc
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / remote / RemoteSystemProxy.java
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote;
13
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;
25
26 /**
27 * <p>
28 * RemoteSystemProxy implementation.
29 * </p>
30 *
31 * @author Bernd Hufmann
32 */
33 public class RemoteSystemProxy implements IRemoteSystemProxy {
34
35 // ------------------------------------------------------------------------
36 // Attributes
37 // ------------------------------------------------------------------------
38 private IHost fHost;
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 public RemoteSystemProxy(IHost host) {
44 fHost = host;
45 }
46
47 // ------------------------------------------------------------------------
48 // Operations
49 // ------------------------------------------------------------------------
50 /* (non-Javadoc)
51 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellService(org.eclipse.rse.core.model.IHost)
52 */
53 @Override
54 public IShellService getShellService() {
55 ISubSystem ss = getShellServiceSubSystem();
56 if (ss != null) {
57 return (IShellService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(IShellService.class);
58 }
59 return null;
60 }
61
62 /* (non-Javadoc)
63 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalService()
64 */
65 @Override
66 public ITerminalService getTerminalService() {
67 ISubSystem ss = getTerminalServiceSubSystem();
68 if (ss != null) {
69 return (ITerminalService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(ITerminalService.class);
70 }
71 return null;
72 }
73
74 /* (non-Javadoc)
75 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellServiceSubSystem()
76 */
77 @Override
78 public ISubSystem getShellServiceSubSystem() {
79 if (fHost == null) {
80 return null;
81 }
82 ISubSystem[] subSystems = fHost.getSubSystems();
83 IShellService ssvc = null;
84 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
85 IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
86 if (svc!=null) {
87 ssvc = (IShellService)svc.getAdapter(IShellService.class);
88 if (ssvc != null) {
89 return subSystems[i];
90 }
91 }
92 }
93 return null;
94 }
95
96 /* (non-Javadoc)
97 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalServiceSubSystem()
98 */
99 @Override
100 public ISubSystem getTerminalServiceSubSystem() {
101 if (fHost == null) {
102 return null;
103 }
104 ISubSystem[] subSystems = fHost.getSubSystems();
105 ITerminalService ssvc = null;
106 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
107 IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
108 if (svc!=null) {
109 ssvc = (ITerminalService)svc.getAdapter(ITerminalService.class);
110 if (ssvc != null) {
111 return subSystems[i];
112 }
113 }
114 }
115 return null;
116 }
117
118 /*
119 * (non-Javadoc)
120 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
121 */
122 @Override
123 public IFileServiceSubSystem getFileServiceSubSystem() {
124 if (fHost == null) {
125 return null;
126 }
127 ISubSystem[] subSystems = fHost.getSubSystems();
128 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
129 if (subSystems[i] instanceof IFileServiceSubSystem) {
130 return (IFileServiceSubSystem)subSystems[i];
131 }
132 }
133 return null;
134 }
135
136 /* (non-Javadoc)
137 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
138 */
139 @Override
140 public void connect(IRSECallback callback) throws ExecutionException {
141 ISubSystem shellSubSystem = getShellServiceSubSystem();
142 if (shellSubSystem != null) {
143 if (!shellSubSystem.isConnected()) {
144 try {
145 shellSubSystem.connect(false, callback);
146 } catch (Exception e) {
147 throw new ExecutionException(e.toString(), e);
148 }
149 } else {
150 callback.done(Status.OK_STATUS, null);
151 }
152 }
153 }
154
155 /* (non-Javadoc)
156 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#disconnect()
157 */
158 @Override
159 public void disconnect() throws ExecutionException {
160 ISubSystem shellSubSystem = getShellServiceSubSystem();
161 if (shellSubSystem != null) {
162 try {
163 shellSubSystem.disconnect();
164 } catch (Exception e) {
165 throw new ExecutionException(e.toString(), e);
166 }
167 }
168 }
169
170 /* (non-Javadoc)
171 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#createCommandShell()
172 */
173 @Override
174 public ICommandShell createCommandShell() throws ExecutionException {
175 ICommandShell shell = new CommandShell(this);
176 shell.connect();
177 return shell;
178 }
179
180 /* (non-Javadoc)
181 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#addCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
182 */
183 @Override
184 public void addCommunicationListener(ICommunicationsListener listener) {
185 IConnectorService[] css = fHost.getConnectorServices();
186 for (IConnectorService cs : css) {
187 cs.addCommunicationsListener(listener);
188 }
189 }
190
191 /* (non-Javadoc)
192 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#removeCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
193 */
194 @Override
195 public void removeCommunicationListener(ICommunicationsListener listener) {
196 IConnectorService[] css = fHost.getConnectorServices();
197 for (IConnectorService cs : css) {
198 cs.removeCommunicationsListener(listener);
199 }
200 }
201 }
This page took 0.035487 seconds and 6 git commands to generate.