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