summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java')
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java125
1 files changed, 125 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java
new file mode 100644
index 0000000..4cf30e4
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java
@@ -0,0 +1,125 @@
1/*******************************************************************************
2 * Copyright (c) 2011 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.remotetools.actions;
12import java.lang.reflect.InvocationTargetException;
13import org.eclipse.core.commands.AbstractHandler;
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
16
17import org.eclipse.core.runtime.NullProgressMonitor;
18import org.eclipse.rse.core.model.IHost;
19import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper;
20import org.eclipse.rse.internal.terminals.ui.views.RSETerminalConnector;
21import org.eclipse.rse.internal.terminals.ui.views.TerminalViewTab;
22import org.eclipse.rse.internal.terminals.ui.views.TerminalViewer;
23import org.eclipse.rse.internal.terminals.ui.views.TerminalsUI;
24import org.eclipse.rse.services.terminals.ITerminalShell;
25import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
26import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
27import org.eclipse.swt.custom.CTabItem;
28import org.eclipse.swt.events.DisposeEvent;
29import org.eclipse.swt.events.DisposeListener;
30import org.eclipse.swt.widgets.Shell;
31import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
32import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
33import org.eclipse.ui.IWorkbenchWindow;
34import org.eclipse.ui.handlers.HandlerUtil;
35import org.yocto.remote.utils.RemoteHelper;
36
37public class SystemtapHandler extends AbstractHandler {
38 protected SystemtapSettingDialog setting;
39 protected String changeTerm="export TERM=vt100;";
40 protected String localConnection="LOCALHOST";
41 protected IWorkbenchWindow window;
42 protected Shell shell;
43
44 public Object execute(ExecutionEvent event) throws ExecutionException {
45
46 this.window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
47 shell = window.getShell();
48 setting=new SystemtapSettingDialog(
49 shell, "Systemtap"
50 );
51
52
53 if(setting.open() == BaseSettingDialog.OK) {
54
55 String metadata_location = ((SystemtapSettingDialog)setting).getMetadataLocation();
56 String builddir_location = ((SystemtapSettingDialog)setting).getBuilddirLocation();
57 String remote_host = ((SystemtapSettingDialog)setting).getRemoteHost();
58 String user_id = ((SystemtapSettingDialog)setting).getUserID();
59 String systemtap_script = ((SystemtapSettingDialog)setting).getSystemtapScript();
60 String systemtap_args = ((SystemtapSettingDialog)setting).getSystemtapArgs();
61 RemoteHelper.waitForRSEInitCompletition();
62 IHost host = RemoteHelper.getRemoteConnectionByName(localConnection);
63 if (host == null)
64 host = RemoteHelper.createLocalConnection();
65 final ITerminalServiceSubSystem terminalSubSystem = RemoteHelper.getTerminalSubSystem(host);
66
67 if (terminalSubSystem != null) {
68 TerminalsUI terminalsUI = TerminalsUI.getInstance();
69 TerminalViewer terminalViewer = terminalsUI.activateTerminalsView();
70 SystemtapModel op = new SystemtapModel(metadata_location,builddir_location, remote_host, user_id, systemtap_script,
71 systemtap_args,window.getShell().getDisplay());
72 try {
73 op.setHost(host);
74 op.preProcess(new NullProgressMonitor());
75 } catch (InvocationTargetException e) {
76 e.printStackTrace();
77 } catch (InterruptedException e) {
78 e.printStackTrace();
79 }
80 CTabItem tab = terminalViewer.getTabFolder().createTabItem(
81 host, changeTerm + "cd " + metadata_location+ ";" + "source oe-init-build-env " + builddir_location + ";" + "crosstap " + user_id + "@" + remote_host + " " + systemtap_script + " " + systemtap_args +"\r");
82 try {
83 tab.addDisposeListener(new DisposeListener() {
84 public void widgetDisposed(DisposeEvent e) {
85 Object source = e.getSource();
86 if (source instanceof CTabItem) {
87 CTabItem currentItem = (CTabItem) source;
88 ITerminalShell shell= getTerminalShellFromTab(currentItem);
89 if(shell!=null) {
90 shell.exit();
91 }
92 }
93 }
94 });
95 } catch(Exception e) {
96 e.printStackTrace();
97 }
98 TerminalElement element = TerminalServiceHelper.createTerminalElement(tab, terminalSubSystem);
99 terminalSubSystem.addChild(element);
100 }
101
102 }
103 return false;
104 }
105
106 protected ITerminalShell getTerminalShellFromTab(CTabItem item) {
107 ITerminalShell terminalShell = null;
108 ITerminalViewControl terminalViewControl = (ITerminalViewControl)item.getData(TerminalViewTab.DATA_KEY_CONTROL);
109 ITerminalConnector terminalConnector = terminalViewControl.getTerminalConnector();
110 if (terminalConnector instanceof RSETerminalConnector) {
111 RSETerminalConnector rseTerminalConnector = (RSETerminalConnector) terminalConnector;
112 terminalShell = rseTerminalConnector.getTerminalHostShell();
113 }
114 return terminalShell;
115 }
116
117 protected void initialize(ExecutionEvent event) throws ExecutionException {
118 this.window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
119 shell = window.getShell();
120 setting=new SystemtapSettingDialog(
121 shell, "Systemtap"
122 );
123 }
124
125}