diff options
Diffstat (limited to 'org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java')
-rw-r--r-- | org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java new file mode 100644 index 000000000..bb69e50c2 --- /dev/null +++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2010 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.ui; + +import org.eclipse.osee.ote.service.IOteClientService; +import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; + +public class RemoteConsoleLauncher extends ServiceTracker { + + private OteRemoteConsole remoteConsole; + + private final IOteConsoleService oteConsoleService; + + public RemoteConsoleLauncher(IOteConsoleService oteConsoleService) { + super(TestCoreGuiPlugin.getContext(), IOteClientService.class.getName(), null); + this.oteConsoleService = oteConsoleService; + } + + @Override + public Object addingService(ServiceReference reference) { + IOteClientService clientService = (IOteClientService) super.addingService(reference); + remoteConsole = new OteRemoteConsole(oteConsoleService); + clientService.addConnectionListener(remoteConsole); + return clientService; + } + + @Override + public void close() { + if (remoteConsole != null) { + IOteClientService service = (IOteClientService) getService(); + service.removeConnectionListener(remoteConsole); + remoteConsole.close(); + } + super.close(); + } + + @Override + public void removedService(ServiceReference reference, Object service) { + if (remoteConsole != null) { + remoteConsole.close(); + remoteConsole = null; + } + super.removedService(reference, service); + } +} |