summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java')
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java280
1 files changed, 280 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java
new file mode 100644
index 0000000..760715c
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java
@@ -0,0 +1,280 @@
1/*******************************************************************************
2 * Copyright (c) 2010 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;
12
13import java.io.File;
14
15import org.eclipse.jface.dialogs.Dialog;
16import org.eclipse.jface.dialogs.IDialogSettings;
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.events.SelectionAdapter;
19import org.eclipse.swt.events.SelectionEvent;
20import org.eclipse.swt.layout.GridData;
21import org.eclipse.swt.layout.GridLayout;
22import org.eclipse.swt.widgets.Button;
23import org.eclipse.swt.widgets.Composite;
24import org.eclipse.swt.widgets.Control;
25import org.eclipse.swt.widgets.DirectoryDialog;
26import org.eclipse.swt.widgets.FileDialog;
27import org.eclipse.swt.widgets.Label;
28import org.eclipse.swt.widgets.Shell;
29import org.eclipse.swt.widgets.Text;
30import org.yocto.remote.utils.CommonHelper;
31import org.yocto.sdk.remotetools.Activator;
32import org.yocto.sdk.remotetools.Messages;
33import org.yocto.sdk.remotetools.SWTFactory;
34
35public class SystemtapSettingDialog extends Dialog {
36
37 static protected String TITLE="Systemtap Crosstap";
38 protected String title;
39 protected String metadata_location;
40 protected String builddir_location;
41 protected String systemtap_script;
42 protected String user_id;
43 protected String remote_host;
44 protected String systemtap_args;
45 protected boolean okPressed;
46 protected Button metadataLocationBtn;
47 protected Button builddirLocationBtn;
48 protected Button systemtapScriptBtn;
49 protected Text userIDText;
50 protected Text remoteHostText;
51 protected Text systemtapArgsText;
52 protected Text systemtapScriptText;
53 protected Text metadataLocationText;
54 protected Text builddirLocationText;
55
56 protected SystemtapSettingDialog(Shell parentShell, String title) {
57 super(parentShell);
58 this.title = title;
59 this.okPressed = false;
60 setShellStyle(getShellStyle() | SWT.RESIZE);
61 }
62
63 @Override
64 protected void configureShell(Shell newShell) {
65 super.configureShell(newShell);
66 newShell.setText(title);
67 }
68
69 public boolean isOKPressed() {
70 return okPressed;
71 }
72
73 public String getSystemtapScript() {
74 return systemtap_script;
75 }
76
77 public String getMetadataLocation() {
78 return metadata_location;
79 }
80
81 public String getBuilddirLocation() {
82 return builddir_location;
83 }
84
85 public String getRemoteHost() {
86 return remote_host;
87 }
88
89 public String getUserID() {
90 return user_id;
91 }
92
93 public String getSystemtapArgs() {
94 return systemtap_args;
95 }
96 @Override
97 protected Control createDialogArea(Composite parent) {
98 Composite comp=(Composite)super.createDialogArea(parent);
99 GridLayout topLayout = new GridLayout();
100 comp.setLayout(topLayout);
101
102 /*argument*/
103 SWTFactory.createVerticalSpacer(comp, 1);
104 createInternal(comp);
105
106 return comp;
107 }
108
109 protected void createInternal(Composite parent)
110 {
111 Composite projComp = new Composite(parent, SWT.NONE);
112 GridLayout projLayout = new GridLayout();
113 projLayout.numColumns = 2;
114 projLayout.marginHeight = 0;
115 projLayout.marginWidth = 0;
116 projComp.setLayout(projLayout);
117 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
118 projComp.setLayoutData(gd);
119
120 Label label = new Label(projComp, SWT.NONE);
121 label.setText(Messages.Metadata_Location);
122 Composite textContainer = new Composite(projComp, SWT.NONE);
123 textContainer.setLayout(new GridLayout(2, false));
124 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
125 metadataLocationText = (Text)addTextControl(textContainer, metadata_location);
126 metadataLocationBtn = addDirSelectButton(textContainer, metadataLocationText);
127
128 label = new Label(projComp, SWT.NONE);
129 label.setText(Messages.Builddir_Location);
130 textContainer = new Composite(projComp, SWT.NONE);
131 textContainer.setLayout(new GridLayout(2, false));
132 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
133 builddirLocationText = (Text)addTextControl(textContainer, builddir_location);
134 builddirLocationBtn = addDirSelectButton(textContainer, builddirLocationText);
135
136 label = new Label(projComp, SWT.NONE);
137 label.setText(Messages.User_ID);
138 userIDText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
139
140 if(user_id!=null)
141 userIDText.setText(user_id);
142 gd = new GridData(GridData.FILL_HORIZONTAL);
143 gd.horizontalSpan = 1;
144 userIDText.setLayoutData(gd);
145
146 label = new Label(projComp, SWT.NONE);
147 label.setText(Messages.Remote_Host);
148
149 remoteHostText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
150 if(remote_host != null)
151 remoteHostText.setText(remote_host);
152 gd = new GridData(GridData.FILL_HORIZONTAL);
153 gd.horizontalSpan = 1;
154 remoteHostText.setLayoutData(gd);
155
156 label = new Label(projComp, SWT.NONE);
157 label.setText(Messages.Systemtap_Script);
158 textContainer = new Composite(projComp, SWT.NONE);
159 textContainer.setLayout(new GridLayout(2, false));
160 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
161 systemtapScriptText = (Text)addTextControl(textContainer, systemtap_script);
162 systemtapScriptBtn = addFileSelectButton(textContainer, systemtapScriptText);
163
164 label = new Label(projComp, SWT.NONE);
165 label.setText(Messages.Systemtap_Args);
166
167 systemtapArgsText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
168 if(systemtap_args != null)
169 systemtapArgsText.setText(systemtap_args);
170 gd = new GridData(GridData.FILL_HORIZONTAL);
171 gd.horizontalSpan = 1;
172 systemtapArgsText.setLayoutData(gd);
173 }
174
175 private Control addTextControl(final Composite parent, String value) {
176 final Text text;
177
178 text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
179 text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
180 if (value != null)
181 text.setText(value);
182 text.setSize(10, 150);
183 return (Control)text;
184 }
185
186 private Button addDirSelectButton(final Composite parent, final Text text) {
187 Button button = new Button(parent, SWT.PUSH | SWT.LEAD);
188 button.setText("Browse");
189 button.addSelectionListener(new SelectionAdapter() {
190 @Override
191 public void widgetSelected(SelectionEvent event) {
192 String dirName;
193
194 dirName = new DirectoryDialog(parent.getShell()).open();
195 if (dirName != null) {
196 text.setText(dirName);
197 }
198 }
199 });
200 return button;
201 }
202
203 private Button addFileSelectButton(final Composite parent, final Text text) {
204 Button button = new Button(parent, SWT.PUSH | SWT.LEAD);
205 button.setText("Browse");
206 button.addSelectionListener(new SelectionAdapter() {
207 @Override
208 public void widgetSelected(SelectionEvent event) {
209 String fileName;
210
211 fileName = new FileDialog(parent.getShell()).open();
212 if (fileName != null) {
213 text.setText(fileName);
214 }
215 }
216 });
217 return button;
218 }
219
220 @Override
221 protected void okPressed() {
222 IDialogSettings settings = Activator.getDefault().getDialogSettings();
223 metadata_location = metadataLocationText.getText();
224 if ( (metadata_location == null) || metadata_location.isEmpty()) {
225 CommonHelper.showErrorDialog("SystemTap Error", null, "Please specify your metadata location!");
226 return;
227 }
228 File metadata_dir = new File(metadata_location);
229 if (!metadata_dir.exists()) {
230 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified metadata location does not exist!");
231 return;
232 }
233 if (!metadata_dir.isDirectory()) {
234 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified metadata location is not a directory!");
235 return;
236 }
237 builddir_location = builddirLocationText.getText();
238 if ( (builddir_location == null) || builddir_location.isEmpty()) {
239 CommonHelper.showErrorDialog("SystemTap Error", null, "Please specify your builddir location!");
240 return;
241 }
242 File builddir_dir = new File(builddir_location);
243 if (!builddir_dir.exists()) {
244 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified builddir location does not exist!");
245 }
246 if (!metadata_dir.isDirectory()) {
247 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified builddir location is not a directory!");
248 return;
249 }
250 user_id = userIDText.getText();
251 if ( (user_id == null) || user_id.isEmpty()) {
252 CommonHelper.showErrorDialog("SystemTap Error", null, "Please specify remote user id!");
253 return;
254 }
255
256 remote_host = remoteHostText.getText();
257 if ( (remote_host == null) || remote_host.isEmpty()) {
258 CommonHelper.showErrorDialog("SystemTap Error", null, "Please specify remote host IP!");
259 return;
260 }
261
262 systemtap_script = systemtapScriptText.getText();
263 if ( (systemtap_script == null) || systemtap_script.isEmpty()) {
264 CommonHelper.showErrorDialog("SystemTap Error", null, "Please specify your systemtap script");
265 return;
266 }
267 File script_file = new File(systemtap_script);
268 if (!script_file.exists()) {
269 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified systemtap script does not exist!");
270 return;
271 }
272 if (!script_file.isFile()) {
273 CommonHelper.showErrorDialog("SystemTap Error", null, "The specified systemtap script is not a file!");
274 return;
275 }
276 systemtap_args = systemtapArgsText.getText();
277 okPressed = true;
278 super.okPressed();
279 }
280}