Fix NLS-related Javadoc warnings
[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, 2013 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.OperationCanceledException;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.rse.core.model.IHost;
18 import org.eclipse.rse.core.model.IRSECallback;
19 import org.eclipse.rse.core.subsystems.ICommunicationsListener;
20 import org.eclipse.rse.core.subsystems.IConnectorService;
21 import org.eclipse.rse.core.subsystems.ISubSystem;
22 import org.eclipse.rse.services.IService;
23 import org.eclipse.rse.services.shells.IShellService;
24 import org.eclipse.rse.services.terminals.ITerminalService;
25 import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
26
27 /**
28 * <p>
29 * RemoteSystemProxy implementation.
30 * </p>
31 *
32 * @author Bernd Hufmann
33 */
34 public class RemoteSystemProxy implements IRemoteSystemProxy {
35
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
39 private final IHost fHost;
40
41 // ------------------------------------------------------------------------
42 // Constructors
43 // ------------------------------------------------------------------------
44
45 /**
46 * Constructor
47 *
48 * @param host
49 * The host of this proxy
50 */
51 public RemoteSystemProxy(IHost host) {
52 fHost = host;
53 }
54
55 // ------------------------------------------------------------------------
56 // Operations
57 // ------------------------------------------------------------------------
58 /* (non-Javadoc)
59 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellService(org.eclipse.rse.core.model.IHost)
60 */
61 @Override
62 public IShellService getShellService() {
63 ISubSystem ss = getShellServiceSubSystem();
64 if (ss != null) {
65 return (IShellService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(IShellService.class);
66 }
67 return null;
68 }
69
70 /* (non-Javadoc)
71 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalService()
72 */
73 @Override
74 public ITerminalService getTerminalService() {
75 ISubSystem ss = getTerminalServiceSubSystem();
76 if (ss != null) {
77 return (ITerminalService)ss.getSubSystemConfiguration().getService(fHost).getAdapter(ITerminalService.class);
78 }
79 return null;
80 }
81
82 /* (non-Javadoc)
83 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getShellServiceSubSystem()
84 */
85 @Override
86 public ISubSystem getShellServiceSubSystem() {
87 if (fHost == null) {
88 return null;
89 }
90 ISubSystem[] subSystems = fHost.getSubSystems();
91 IShellService ssvc = null;
92 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
93 IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
94 if (svc!=null) {
95 ssvc = (IShellService)svc.getAdapter(IShellService.class);
96 if (ssvc != null) {
97 return subSystems[i];
98 }
99 }
100 }
101 return null;
102 }
103
104 /* (non-Javadoc)
105 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#getTerminalServiceSubSystem()
106 */
107 @Override
108 public ISubSystem getTerminalServiceSubSystem() {
109 if (fHost == null) {
110 return null;
111 }
112 ISubSystem[] subSystems = fHost.getSubSystems();
113 ITerminalService ssvc = null;
114 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
115 IService svc = subSystems[i].getSubSystemConfiguration().getService(fHost);
116 if (svc!=null) {
117 ssvc = (ITerminalService)svc.getAdapter(ITerminalService.class);
118 if (ssvc != null) {
119 return subSystems[i];
120 }
121 }
122 }
123 return null;
124 }
125
126 /*
127 * (non-Javadoc)
128 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
129 */
130 @Override
131 public IFileServiceSubSystem getFileServiceSubSystem() {
132 if (fHost == null) {
133 return null;
134 }
135 ISubSystem[] subSystems = fHost.getSubSystems();
136 for (int i = 0; subSystems != null && i < subSystems.length; i++) {
137 if (subSystems[i] instanceof IFileServiceSubSystem) {
138 return (IFileServiceSubSystem)subSystems[i];
139 }
140 }
141 return null;
142 }
143
144 @Override
145 public int getPort() {
146 if (getShellServiceSubSystem() != null) {
147 return getShellServiceSubSystem().getConnectorService().getPort();
148 }
149 return IRemoteSystemProxy.INVALID_PORT_NUMBER;
150 }
151
152 @Override
153 public void setPort(int port) {
154 if ((getShellServiceSubSystem() != null) && (port > 0)) {
155 getShellServiceSubSystem().getConnectorService().setPort(port);
156 }
157 }
158
159 /*
160 * (non-Javadoc)
161 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
162 */
163 @Override
164 public void connect(IRSECallback callback) throws ExecutionException {
165 ISubSystem shellSubSystem = getShellServiceSubSystem();
166 if (shellSubSystem != null) {
167 if (!shellSubSystem.isConnected()) {
168 try {
169 shellSubSystem.connect(false, callback);
170 } catch (OperationCanceledException e) {
171 callback.done(Status.CANCEL_STATUS, null);
172 }
173 catch (Exception e) {
174 throw new ExecutionException(e.toString(), e);
175 }
176 } else {
177 callback.done(Status.OK_STATUS, null);
178 }
179 }
180 }
181
182 /* (non-Javadoc)
183 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#disconnect()
184 */
185 @Override
186 public void disconnect() throws ExecutionException {
187 ISubSystem shellSubSystem = getShellServiceSubSystem();
188 if (shellSubSystem != null) {
189 try {
190 shellSubSystem.disconnect();
191 } catch (Exception e) {
192 throw new ExecutionException(e.toString(), e);
193 }
194 }
195 }
196
197 /* (non-Javadoc)
198 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#createCommandShell()
199 */
200 @Override
201 public ICommandShell createCommandShell() throws ExecutionException {
202 ICommandShell shell = new CommandShell(this);
203 shell.connect();
204 return shell;
205 }
206
207 /* (non-Javadoc)
208 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#addCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
209 */
210 @Override
211 public void addCommunicationListener(ICommunicationsListener listener) {
212 IConnectorService[] css = fHost.getConnectorServices();
213 for (IConnectorService cs : css) {
214 cs.addCommunicationsListener(listener);
215 }
216 }
217
218 /* (non-Javadoc)
219 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.util.IRemoteSystemProxy#removeCommunicationListener(org.eclipse.rse.core.subsystems.ICommunicationsListener)
220 */
221 @Override
222 public void removeCommunicationListener(ICommunicationsListener listener) {
223 IConnectorService[] css = fHost.getConnectorServices();
224 for (IConnectorService cs : css) {
225 cs.removeCommunicationsListener(listener);
226 }
227 }
228 }
This page took 0.035567 seconds and 5 git commands to generate.