Bug 459931 - Update PTP for new Remote API
Signed-off-by: Greg Watson <g.watson@computer.org>
diff --git a/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/Activator.java b/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/Activator.java
index 98b5ae9..2245570 100644
--- a/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/Activator.java
+++ b/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/Activator.java
@@ -11,6 +11,7 @@
import org.eclipse.ptp.core.IPTPLaunchConfigurationConstants;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@@ -88,13 +89,27 @@
try {
ILaunchDelegate[] delegates = localCfg.getDelegates(runSet);
for (ILaunchDelegate delegate : delegates) {
- if ("org.eclipse.ptp.rcp.sysmon.launch".equals(delegate.getId())) {
+ if ("org.eclipse.ptp.rcp.sysmon.launch".equals(delegate.getId())) { //$NON-NLS-1$
localCfg.setPreferredDelegate(runSet, delegate);
break;
}
}
} catch (CoreException e) {
+ // Ignore
}
}
}
+
+ /**
+ * Return the OSGi service with the given service interface.
+ *
+ * @param service
+ * service interface
+ * @return the specified service or null if it's not registered
+ */
+ public static <T> T getService(Class<T> service) {
+ final BundleContext context = plugin.getBundle().getBundleContext();
+ final ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
}
diff --git a/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/launch/ui/SysMonApplicationTab.java b/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/launch/ui/SysMonApplicationTab.java
index 5eedbc9..7911f2b 100644
--- a/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/launch/ui/SysMonApplicationTab.java
+++ b/org.eclipse.ptp.rcp.sysmon/src/org/eclipse/ptp/rcp/sysmon/launch/ui/SysMonApplicationTab.java
@@ -18,23 +18,18 @@
*******************************************************************************/
package org.eclipse.ptp.rcp.sysmon.launch.ui;
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ptp.core.IPTPLaunchConfigurationConstants;
-import org.eclipse.ptp.launch.RMLaunchUtils;
import org.eclipse.ptp.launch.ui.LaunchImages;
import org.eclipse.ptp.launch.ui.tabs.LaunchConfigurationTab;
+import org.eclipse.ptp.rcp.sysmon.Activator;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
-import org.eclipse.remote.ui.IRemoteUIServices;
-import org.eclipse.remote.ui.RemoteUIServices;
+import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
+import org.eclipse.remote.ui.IRemoteUIFileService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -218,36 +213,17 @@
*/
protected void handleApplicationButtonSelected() {
String initPath = appText.getText();
-
- final IRemoteConnection[] conn = new IRemoteConnection[1];
- try {
- getLaunchConfigurationDialog().run(false, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- conn[0] = RMLaunchUtils.getRemoteConnection(getLaunchConfiguration(), monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e.getCause());
- }
- }
- });
- } catch (InvocationTargetException e) {
- // Ignore
- } catch (InterruptedException e) {
- // Ignore
- }
- if (conn[0] != null) {
- IRemoteUIServices remoteUIServices = RemoteUIServices.getRemoteUIServices(conn[0].getRemoteServices());
- if (remoteUIServices != null) {
- IRemoteUIFileManager fileManager = remoteUIServices.getUIFileManager();
- if (fileManager != null) {
- fileManager.setConnection(conn[0]);
- fileManager.showConnections(false);
- String path = fileManager.browseFile(getShell(), Messages.SysMonApplicationTab_Select_application_to_execute,
- initPath, 0);
- if (path != null) {
- appText.setText(path.toString());
- }
+ IRemoteLaunchConfigService launchSvc = Activator.getService(IRemoteLaunchConfigService.class);
+ IRemoteConnection conn = launchSvc.getActiveConnection(getLaunchConfiguration());
+ if (conn != null) {
+ IRemoteUIFileService fileSvc = conn.getConnectionType().getService(IRemoteUIFileService.class);
+ if (fileSvc != null) {
+ fileSvc.setConnection(conn);
+ fileSvc.showConnections(false);
+ String path = fileSvc.browseFile(getShell(), Messages.SysMonApplicationTab_Select_application_to_execute, initPath,
+ 0);
+ if (path != null) {
+ appText.setText(path.toString());
}
}
} else {