Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2014-11-28 10:20:01 +0000
committerBernd Hufmann2014-12-02 20:42:36 +0000
commitcd055d37e68c1d61d9acb4571b4f656c0636b561 (patch)
tree6e1fc6d792e4c2b1040ff7983c0f6a32825f4d8a
parent67a0ee8c965da2ec4bee77707481a01cf3b00380 (diff)
downloadorg.eclipse.linuxtools-cd055d37e68c1d61d9acb4571b4f656c0636b561.tar.gz
org.eclipse.linuxtools-cd055d37e68c1d61d9acb4571b4f656c0636b561.tar.xz
org.eclipse.linuxtools-cd055d37e68c1d61d9acb4571b4f656c0636b561.zip
Bug 453499: Allow for programmatically adding a connection to the
Control UI Change-Id: I0b0dab26c455c371d7fab8fb0aaedf2f4401c19d Signed-off-by: Markus Schorn <markus.schorn@windriver.com> Reviewed-on: https://git.eclipse.org/r/37239 Tested-by: Hudson CI Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties5
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml10
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/Workaround_Bug449362.java2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java66
4 files changed, 68 insertions, 15 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
index e6e6b245b1..cc7216bdf1 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2013 Ericsson
+# Copyright (c) 2013, 2014 Ericsson and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
@@ -138,3 +138,6 @@ commands.control.snapshot=Record Snapshot
commands.control.snapshot.description=Record a snapshot
preference.page.control.name=LTTng Tracer Control Preferences
+
+commandParameter.remoteServicesId.name = Remote Services ID
+commandParameter.connectionName.name = Connection Name \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
index 5cee5d2f37..2d7aa9821e 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
@@ -31,6 +31,16 @@
description="%commands.control.new.description"
id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.newConnection"
name="%commands.control.new">
+ <commandParameter
+ id="org.eclipse.linuxtools.lttng2.control.ui.remoteServicesIdParameter"
+ name="%commandParameter.remoteServicesId.name"
+ optional="true">
+ </commandParameter>
+ <commandParameter
+ id="org.eclipse.linuxtools.lttng2.control.ui.connectionNameParameter"
+ name="%commandParameter.connectionName.name"
+ optional="true">
+ </commandParameter>
</command>
<command
categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/Workaround_Bug449362.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/Workaround_Bug449362.java
index 494f7e40f6..c710b3d05d 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/Workaround_Bug449362.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/Workaround_Bug449362.java
@@ -20,7 +20,7 @@ import org.eclipse.ui.IStartup;
/**
* Collection of workarounds needed for dealing with the RSE adapter.
*/
-class Workaround_Bug449362 {
+public class Workaround_Bug449362 {
private static final String RSE_ADAPTER_ID = "org.eclipse.ptp.remote.RSERemoteServices"; //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java
index d7da522a23..9defc96c0e 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java
@@ -13,15 +13,20 @@
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers;
+import java.util.Map;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.Workaround_Bug449362;
import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.INewConnectionDialog;
import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent;
import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteServices;
+import org.eclipse.remote.core.RemoteServices;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
@@ -29,13 +34,30 @@ import org.eclipse.ui.PlatformUI;
/**
* <p>
- * Command handler for creation new connection for trace control.
+ * Command handler for creation of a new connection for trace control.
+ * <br> By supplying arguments for the parameters with id {@link #PARAMETER_REMOTE_SERVICES_ID} and
+ * {@link #PARAMETER_CONNECTION_NAME}, the caller can specify the remote connection that will
+ * be added to the trace control. In case one of the optional arguments is not supplied, the handler
+ * opens a dialog for selecting a remote connection.
* </p>
*
* @author Bernd Hufmann
*/
public class NewConnectionHandler extends BaseControlViewHandler {
+ /**
+ * Id of the parameter for the remote services id.
+ * @see NewConnectionHandler
+ * @see IRemoteServices#getId()
+ */
+ public static final String PARAMETER_REMOTE_SERVICES_ID = "org.eclipse.linuxtools.lttng2.control.ui.remoteServicesIdParameter"; //$NON-NLS-1$
+ /**
+ * Id of the parameter for the name of the remote connection.
+ * @see NewConnectionHandler
+ * @see IRemoteServices#getName()
+ */
+ public static final String PARAMETER_CONNECTION_NAME = "org.eclipse.linuxtools.lttng2.control.ui.connectionNameParameter"; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
@@ -54,24 +76,17 @@ public class NewConnectionHandler extends BaseControlViewHandler {
return false;
}
- // Open dialog box for the node name and address
- final INewConnectionDialog dialog = TraceControlDialogFactory.getInstance().getNewConnectionDialog();
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- IRemoteConnection host = dialog.getConnection();
- if (host != null) {
+ IRemoteConnection connection = getConnection(event.getParameters());
+ if (connection != null) {
fLock.lock();
try {
// successful creation of host
TargetNodeComponent node = null;
- if (!fRoot.containsChild(host.getName())) {
- node = new TargetNodeComponent(host.getName(), fRoot, host);
+ if (!fRoot.containsChild(connection.getName())) {
+ node = new TargetNodeComponent(connection.getName(), fRoot, connection);
fRoot.addChild(node);
} else {
- node = (TargetNodeComponent)fRoot.getChild(host.getName());
+ node = (TargetNodeComponent)fRoot.getChild(connection.getName());
}
node.connect();
@@ -82,6 +97,31 @@ public class NewConnectionHandler extends BaseControlViewHandler {
return null;
}
+ private static IRemoteConnection getConnection(Map<?,?> parameters) {
+ // First check whether arguments have been supplied
+ Object remoteServicesId = parameters.get(PARAMETER_REMOTE_SERVICES_ID);
+ Object connectionName = parameters.get(PARAMETER_CONNECTION_NAME);
+ if (remoteServicesId != null && connectionName != null) {
+ if (!Workaround_Bug449362.triggerRSEStartup(remoteServicesId.toString())) {
+ // Skip the connection in order to avoid an infinite loop
+ } else {
+ IRemoteServices rs = RemoteServices.getRemoteServices(remoteServicesId.toString());
+ if (rs != null) {
+ return rs.getConnectionManager().getConnection(connectionName.toString());
+ }
+ }
+ return null;
+ }
+
+ // Without the arguments, open dialog box for the node name and address
+ final INewConnectionDialog dialog = TraceControlDialogFactory.getInstance().getNewConnectionDialog();
+ if (dialog.open() == Window.OK) {
+ return dialog.getConnection();
+ }
+
+ return null;
+ }
+
@Override
public boolean isEnabled() {

Back to the top