summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src')
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Activator.java79
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/LocalJob.java101
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Messages.java62
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/SWTFactory.java642
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspElement.java88
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspPropertyElement.java65
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoJSONHelper.java89
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java123
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java216
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/DialogHandler.java42
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/IBaseConstants.java27
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/LatencytopHandler.java35
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileHandler.java55
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileModel.java171
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PerfHandler.java30
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java48
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopModel.java109
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java131
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SimpleSettingDialog.java54
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java70
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java88
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapSettingDialog.java280
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Handler.java59
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Model.java166
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2SettingDialog.java104
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/UstSettingDialogBase.java170
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/YoctoBspHandler.java38
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/messages.properties49
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/BaseFileView.java140
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewTab.java457
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewer.java139
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPAction.java32
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPProgressDialog.java47
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPThread.java92
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/ErrorCollectorThread.java19
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelArchGetter.java23
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelBranchesGetter.java28
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/MainPage.java498
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/OutputCollectorThread.java19
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/PropertiesPage.java498
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/QemuArchGetter.java27
-rw-r--r--plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java99
42 files changed, 5309 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Activator.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Activator.java
new file mode 100644
index 0000000..33de5c1
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Activator.java
@@ -0,0 +1,79 @@
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;
12
13import org.eclipse.core.runtime.jobs.IJobManager;
14import org.eclipse.core.runtime.jobs.Job;
15import org.eclipse.jface.resource.ImageDescriptor;
16import org.eclipse.ui.plugin.AbstractUIPlugin;
17import org.osgi.framework.BundleContext;
18
19/**
20 * The activator class controls the plug-in life cycle
21 */
22public class Activator extends AbstractUIPlugin {
23
24 // The plug-in ID
25 public static final String PLUGIN_ID = "org.yocto.sdk.remotetools"; //$NON-NLS-1$
26
27 // The shared instance
28 private static Activator plugin;
29
30 /**
31 * The constructor
32 */
33 public Activator() {
34 }
35
36 /*
37 * (non-Javadoc)
38 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
39 */
40 public void start(BundleContext context) throws Exception {
41 super.start(context);
42 plugin = this;
43 }
44
45 /*
46 * (non-Javadoc)
47 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
48 */
49 public void stop(BundleContext context) throws Exception {
50
51 //cancel all jobs before plugin stop
52 IJobManager jobMan = Job.getJobManager();
53 jobMan.cancel(LocalJob.LOCAL_JOB_FAMILY);
54 jobMan.join(LocalJob.LOCAL_JOB_FAMILY, null);
55
56 plugin = null;
57 super.stop(context);
58 }
59
60 /**
61 * Returns the shared instance
62 *
63 * @return the shared instance
64 */
65 public static Activator getDefault() {
66 return plugin;
67 }
68
69 /**
70 * Returns an image descriptor for the image file at the given
71 * plug-in relative path
72 *
73 * @param path the path
74 * @return the image descriptor
75 */
76 public static ImageDescriptor getImageDescriptor(String path) {
77 return imageDescriptorFromPlugin(PLUGIN_ID, path);
78 }
79}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/LocalJob.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/LocalJob.java
new file mode 100644
index 0000000..5b082a0
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/LocalJob.java
@@ -0,0 +1,101 @@
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 *******************************************************************************/
11
12package org.yocto.sdk.remotetools;
13
14import java.io.File;
15import java.io.IOException;
16
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.core.runtime.IStatus;
19import org.eclipse.core.runtime.Status;
20import org.eclipse.core.runtime.jobs.Job;
21import org.eclipse.ui.IWorkbenchWindow;
22import org.eclipse.jface.dialogs.MessageDialog;
23import org.eclipse.swt.SWTException;
24
25public class LocalJob extends Job {
26
27 public static final String LOCAL_JOB_FAMILY = "localJobFamily";
28 private String[] cmdarray;
29 private String[] envp;
30 private File dir;
31 private int exitValue;
32 private Exception exception;
33 private IWorkbenchWindow window;
34
35 public LocalJob(String name, String[] cmdarray, String[] envp, File dir, IWorkbenchWindow window) {
36 super(name);
37 this.cmdarray=cmdarray;
38 this.envp=envp;
39 this.dir=dir;
40 this.window=window;
41 this.exitValue=0;
42 this.exception=null;
43 }
44
45 @Override
46 protected IStatus run(IProgressMonitor monitor) {
47 Process p=null;
48 boolean cancel=false;
49
50 try {
51 //start process
52 p=Runtime.getRuntime().exec(cmdarray,envp,dir);
53
54 //wait for completion
55 while (!cancel) {
56
57 if(monitor.isCanceled())
58 cancel=true;
59
60 try {
61 exitValue=p.exitValue();
62 break;
63 }catch (IllegalThreadStateException e) {
64 }
65
66 Thread.sleep(500);
67 }
68
69 }catch (IOException e) {
70 exception=e;
71 }catch (InterruptedException e){
72 cancel=true;
73 }finally {
74 if(p!=null)
75 p.destroy();
76 }
77 try {
78 if(exitValue!=0 || exception!=null) {
79 window.getWorkbench().getDisplay().syncExec(new Runnable() {
80 public void run() {
81 MessageDialog.openError(window.getShell(),
82 Messages.LocalJob_Title,
83 Messages.ErrorLocalJob + ": " + getName() +
84 (exitValue!=0 ? "\n\tExit value: " + new Integer(exitValue).toString() : new String("")) +
85 (exception!=null ? "\n\t" + exception.getMessage() : new String (""))
86 );
87 }
88 });
89 }
90 }catch (SWTException e) {
91 e.printStackTrace();
92 }catch (Exception e) {
93 e.printStackTrace();
94 }
95 return (cancel!=true) ? Status.OK_STATUS : Status.CANCEL_STATUS;
96 }
97
98 public boolean belongsTo(Object family) {
99 return family == LOCAL_JOB_FAMILY;
100 }
101}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Messages.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Messages.java
new file mode 100644
index 0000000..cbf2b05
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/Messages.java
@@ -0,0 +1,62 @@
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;
12
13import org.eclipse.osgi.util.NLS;
14
15public class Messages extends NLS {
16
17 private static final String BUNDLE_NAME = "org.yocto.sdk.remotetools.messages"; //$NON-NLS-1$
18
19 public static String ErrorNoSubsystem;
20 public static String ErrorConnectSubsystem;
21 public static String ErrorNoHost;
22 public static String ErrorNoRemoteService;
23
24 public static String ErrorOprofileViewer;
25 public static String ErrorOprofile;
26 public static String ErrorLttvGui;
27 public static String ErrorUstProject;
28
29 public static String InfoDownload;
30 public static String InfoUpload;
31
32 public static String BaseSettingDialog_Connection;
33 public static String BaseSettingDialog_New;
34 public static String BaseSettingDialog_Properties;
35 public static String Usttrace_Argument_Text;
36 public static String Usttrace_Application_Text;
37 public static String Usttrace_Trace_Loc_Text;
38 public static String Powertop_Time_Text;
39 public static String Powertop_ShowPid_Text;
40 public static String TerminalViewer_text;
41 //public static String Systemtap_KO_Text;
42 public static String Metadata_Location;
43 public static String Builddir_Location;
44 public static String User_ID;
45 public static String Remote_Host;
46 public static String Systemtap_Script;
47 public static String Systemtap_Args;
48 public static String Import_to_Project;
49
50 public static String LocalJob_Title;
51 public static String ErrorLocalJob;
52 public static String RemoteShellExec_1;
53 public static String RemoteShellExec_2;
54
55 static {
56 // initialize resource bundle
57 NLS.initializeMessages(BUNDLE_NAME, Messages.class);
58 }
59
60 private Messages() {
61 }
62}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/SWTFactory.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/SWTFactory.java
new file mode 100644
index 0000000..27b5dae
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/SWTFactory.java
@@ -0,0 +1,642 @@
1/*******************************************************************************
2 * Copyright (c) 2000, 2010 IBM Corporation and others.
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 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.remotetools;
12
13import org.eclipse.core.runtime.Assert;
14import org.eclipse.jface.dialogs.IDialogConstants;
15import org.eclipse.jface.layout.PixelConverter;
16import org.eclipse.jface.resource.JFaceResources;
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.custom.CLabel;
19import org.eclipse.swt.custom.ViewForm;
20import org.eclipse.swt.graphics.Font;
21import org.eclipse.swt.graphics.Image;
22import org.eclipse.swt.layout.GridData;
23import org.eclipse.swt.layout.GridLayout;
24import org.eclipse.swt.widgets.Button;
25import org.eclipse.swt.widgets.Combo;
26import org.eclipse.swt.widgets.Composite;
27import org.eclipse.swt.widgets.Group;
28import org.eclipse.swt.widgets.Label;
29import org.eclipse.swt.widgets.Layout;
30import org.eclipse.swt.widgets.Text;
31import org.eclipse.ui.forms.widgets.ExpandableComposite;
32
33/**
34 * Factory class to create some SWT resources.
35 */
36public class SWTFactory {
37
38 /**
39 * Returns a width hint for a button control.
40 */
41 public static int getButtonWidthHint(Button button) {
42 /*button.setFont(JFaceResources.getDialogFont());*/
43 PixelConverter converter= new PixelConverter(button);
44 int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
45 return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
46 }
47
48 /**
49 * Sets width and height hint for the button control.
50 * <b>Note:</b> This is a NOP if the button's layout data is not
51 * an instance of <code>GridData</code>.
52 *
53 * @param the button for which to set the dimension hint
54 */
55 public static void setButtonDimensionHint(Button button) {
56 Assert.isNotNull(button);
57 Object gd= button.getLayoutData();
58 if (gd instanceof GridData) {
59 ((GridData)gd).widthHint= getButtonWidthHint(button);
60 ((GridData)gd).horizontalAlignment = GridData.FILL;
61 }
62 }
63
64 /**
65 * Creates a check box button using the parents' font
66 * @param parent the parent to add the button to
67 * @param label the label for the button
68 * @param image the image for the button
69 * @param checked the initial checked state of the button
70 * @param hspan the horizontal span to take up in the parent composite
71 * @return a new checked button set to the initial checked state
72 * @since 3.3
73 */
74 public static Button createCheckButton(Composite parent, String label, Image image, boolean checked, int hspan) {
75 Button button = new Button(parent, SWT.CHECK);
76 button.setFont(parent.getFont());
77 button.setSelection(checked);
78 if(image != null) {
79 button.setImage(image);
80 }
81 if(label != null) {
82 button.setText(label);
83 }
84 GridData gd = new GridData();
85 gd.horizontalSpan = hspan;
86 button.setLayoutData(gd);
87 setButtonDimensionHint(button);
88 return button;
89 }
90
91 /**
92 * Creates and returns a new push button with the given
93 * label and/or image.
94 *
95 * @param parent parent control
96 * @param label button label or <code>null</code>
97 * @param image image of <code>null</code>
98 *
99 * @return a new push button
100 */
101 public static Button createPushButton(Composite parent, String label, Image image) {
102 Button button = new Button(parent, SWT.PUSH);
103 button.setFont(parent.getFont());
104 if (image != null) {
105 button.setImage(image);
106 }
107 if (label != null) {
108 button.setText(label);
109 }
110 GridData gd = new GridData();
111 button.setLayoutData(gd);
112 setButtonDimensionHint(button);
113 return button;
114 }
115
116 /**
117 * Creates and returns a new push button with the given
118 * label and/or image.
119 *
120 * @param parent parent control
121 * @param label button label or <code>null</code>
122 * @param image image of <code>null</code>
123 * @param fill the alignment for the new button
124 *
125 * @return a new push button
126 * @since 3.4
127 */
128 public static Button createPushButton(Composite parent, String label, Image image, int fill) {
129 Button button = new Button(parent, SWT.PUSH);
130 button.setFont(parent.getFont());
131 if (image != null) {
132 button.setImage(image);
133 }
134 if (label != null) {
135 button.setText(label);
136 }
137 GridData gd = new GridData(fill);
138 button.setLayoutData(gd);
139 setButtonDimensionHint(button);
140 return button;
141 }
142
143 /**
144 * Creates and returns a new push button with the given
145 * label, tooltip and/or image.
146 *
147 * @param parent parent control
148 * @param label button label or <code>null</code>
149 * @param tooltip the tooltip text for the button or <code>null</code>
150 * @param image image of <code>null</code>
151 *
152 * @return a new push button
153 * @since 3.6
154 */
155 public static Button createPushButton(Composite parent, String label, String tooltip, Image image) {
156 Button button = createPushButton(parent, label, image);
157 button.setToolTipText(tooltip);
158 return button;
159 }
160
161 /**
162 * Creates and returns a new radio button with the given
163 * label.
164 *
165 * @param parent parent control
166 * @param label button label or <code>null</code>
167 *
168 * @return a new radio button
169 */
170 public static Button createRadioButton(Composite parent, String label) {
171 Button button = new Button(parent, SWT.RADIO);
172 button.setFont(parent.getFont());
173 if (label != null) {
174 button.setText(label);
175 }
176 GridData gd = new GridData();
177 button.setLayoutData(gd);
178 setButtonDimensionHint(button);
179 return button;
180 }
181
182 /**
183 * Creates and returns a new radio button with the given
184 * label.
185 *
186 * @param parent parent control
187 * @param label button label or <code>null</code>
188 * @param hspan the number of columns to span in the parent composite
189 *
190 * @return a new radio button
191 * @since 3.6
192 */
193 public static Button createRadioButton(Composite parent, String label, int hspan) {
194 Button button = new Button(parent, SWT.RADIO);
195 button.setFont(parent.getFont());
196 if (label != null) {
197 button.setText(label);
198 }
199 GridData gd = new GridData(GridData.BEGINNING);
200 gd.horizontalSpan = hspan;
201 button.setLayoutData(gd);
202 setButtonDimensionHint(button);
203 return button;
204 }
205
206 /**
207 * Creates a new label widget
208 * @param parent the parent composite to add this label widget to
209 * @param text the text for the label
210 * @param hspan the horizontal span to take up in the parent composite
211 * @return the new label
212 * @since 3.2
213 *
214 */
215 public static Label createLabel(Composite parent, String text, int hspan) {
216 Label l = new Label(parent, SWT.NONE);
217 l.setFont(parent.getFont());
218 l.setText(text);
219 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
220 gd.horizontalSpan = hspan;
221 gd.grabExcessHorizontalSpace = false;
222 l.setLayoutData(gd);
223 return l;
224 }
225
226 /**
227 * Creates a new label widget
228 * @param parent the parent composite to add this label widget to
229 * @param text the text for the label
230 * @param font the font for the label
231 * @param hspan the horizontal span to take up in the parent composite
232 * @return the new label
233 * @since 3.3
234 */
235 public static Label createLabel(Composite parent, String text, Font font, int hspan) {
236 Label l = new Label(parent, SWT.NONE);
237 l.setFont(font);
238 l.setText(text);
239 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
240 gd.horizontalSpan = hspan;
241 l.setLayoutData(gd);
242 return l;
243 }
244
245 /**
246 * Creates a wrapping label
247 * @param parent the parent composite to add this label to
248 * @param text the text to be displayed in the label
249 * @param hspan the horizontal span that label should take up in the parent composite
250 * @param wrapwidth the width hint that the label should wrap at
251 * @return a new label that wraps at a specified width
252 * @since 3.3
253 */
254 public static Label createWrapLabel(Composite parent, String text, int hspan, int wrapwidth) {
255 Label l = new Label(parent, SWT.NONE | SWT.WRAP);
256 l.setFont(parent.getFont());
257 l.setText(text);
258 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
259 gd.horizontalSpan = hspan;
260 gd.widthHint = wrapwidth;
261 l.setLayoutData(gd);
262 return l;
263 }
264
265 /**
266 * Creates a new <code>CLabel</code> that will wrap at the specified width and has the specified image
267 * @param parent the parent to add this label to
268 * @param text the text for the label
269 * @param image the image for the label
270 * @param hspan the h span to take up in the parent
271 * @param wrapwidth the with to wrap at
272 * @return a new <code>CLabel</code>
273 * @since 3.3
274 */
275 public static CLabel createWrapCLabel(Composite parent, String text, Image image, int hspan, int wrapwidth) {
276 CLabel label = new CLabel(parent, SWT.NONE | SWT.WRAP);
277 label.setFont(parent.getFont());
278 if(text != null) {
279 label.setText(text);
280 }
281 if(image != null) {
282 label.setImage(image);
283 }
284 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
285 gd.horizontalSpan = hspan;
286 gd.widthHint = wrapwidth;
287 label.setLayoutData(gd);
288 return label;
289 }
290
291 /**
292 * Creates a wrapping label
293 * @param parent the parent composite to add this label to
294 * @param text the text to be displayed in the label
295 * @param hspan the horizontal span that label should take up in the parent composite
296 * @return a new label that wraps at a specified width
297 * @since 3.3
298 */
299 public static Label createWrapLabel(Composite parent, String text, int hspan) {
300 Label l = new Label(parent, SWT.NONE | SWT.WRAP);
301 l.setFont(parent.getFont());
302 l.setText(text);
303 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
304 gd.horizontalSpan = hspan;
305 l.setLayoutData(gd);
306 return l;
307 }
308
309 /**
310 * Creates a new text widget
311 * @param parent the parent composite to add this text widget to
312 * @param hspan the horizontal span to take up on the parent composite
313 * @return the new text widget
314 * @since 3.2
315 *
316 */
317 public static Text createSingleText(Composite parent, int hspan) {
318 Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);
319 t.setFont(parent.getFont());
320 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
321 gd.horizontalSpan = hspan;
322 t.setLayoutData(gd);
323 return t;
324 }
325
326 /**
327 * Creates a new text widget
328 * @param parent the parent composite to add this text widget to
329 * @param style the style bits for the text widget
330 * @param hspan the horizontal span to take up on the parent composite
331 * @param fill the fill for the grid layout
332 * @return the new text widget
333 * @since 3.3
334 */
335 public static Text createText(Composite parent, int style, int hspan, int fill) {
336 Text t = new Text(parent, style);
337 t.setFont(parent.getFont());
338 GridData gd = new GridData(fill);
339 gd.horizontalSpan = hspan;
340 t.setLayoutData(gd);
341 return t;
342 }
343
344 /**
345 * Creates a new text widget
346 * @param parent the parent composite to add this text widget to
347 * @param style the style bits for the text widget
348 * @param hspan the horizontal span to take up on the parent composite
349 * @return the new text widget
350 * @since 3.3
351 */
352 public static Text createText(Composite parent, int style, int hspan) {
353 Text t = new Text(parent, style);
354 t.setFont(parent.getFont());
355 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
356 gd.horizontalSpan = hspan;
357 t.setLayoutData(gd);
358 return t;
359 }
360
361 /**
362 * Creates a new text widget
363 * @param parent the parent composite to add this text widget to
364 * @param style the style bits for the text widget
365 * @param hspan the horizontal span to take up on the parent composite
366 * @param width the desired width of the text widget
367 * @param height the desired height of the text widget
368 * @param fill the fill style for the widget
369 * @return the new text widget
370 * @since 3.3
371 */
372 public static Text createText(Composite parent, int style, int hspan, int width, int height, int fill) {
373 Text t = new Text(parent, style);
374 t.setFont(parent.getFont());
375 GridData gd = new GridData(fill);
376 gd.horizontalSpan = hspan;
377 gd.widthHint = width;
378 gd.heightHint = height;
379 t.setLayoutData(gd);
380 return t;
381 }
382
383 /**
384 * Creates a new text widget
385 * @param parent the parent composite to add this text widget to
386 * @param style the style bits for the text widget
387 * @param hspan the horizontal span to take up on the parent composite
388 * @param text the initial text, not <code>null</code>
389 * @return the new text widget
390 * @since 3.6
391 */
392 public static Text createText(Composite parent, int style, int hspan, String text) {
393 Text t = new Text(parent, style);
394 t.setFont(parent.getFont());
395 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
396 gd.horizontalSpan = hspan;
397 t.setLayoutData(gd);
398 t.setText(text);
399 return t;
400 }
401
402 /**
403 * Creates a Group widget
404 * @param parent the parent composite to add this group to
405 * @param text the text for the heading of the group
406 * @param columns the number of columns within the group
407 * @param hspan the horizontal span the group should take up on the parent
408 * @param fill the style for how this composite should fill into its parent
409 * @return the new group
410 * @since 3.2
411 *
412 */
413 public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) {
414 Group g = new Group(parent, SWT.NONE);
415 g.setLayout(new GridLayout(columns, false));
416 g.setText(text);
417 g.setFont(parent.getFont());
418 GridData gd = new GridData(fill);
419 gd.horizontalSpan = hspan;
420 g.setLayoutData(gd);
421 return g;
422 }
423
424 /**
425 * Creates a Composite widget
426 * @param parent the parent composite to add this composite to
427 * @param font the font to set on the control
428 * @param columns the number of columns within the composite
429 * @param hspan the horizontal span the composite should take up on the parent
430 * @param fill the style for how this composite should fill into its parent
431 * @return the new group
432 * @since 3.3
433 */
434 public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) {
435 Composite g = new Composite(parent, SWT.NONE);
436 g.setLayout(new GridLayout(columns, false));
437 g.setFont(font);
438 GridData gd = new GridData(fill);
439 gd.horizontalSpan = hspan;
440 g.setLayoutData(gd);
441 return g;
442 }
443
444 /**
445 * Creates an ExpandibleComposite widget
446 * @param parent the parent to add this widget to
447 * @param style the style for ExpandibleComposite expanding handle, and layout
448 * @param label the label for the widget
449 * @param hspan how many columns to span in the parent
450 * @param fill the fill style for the widget
451 * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code>
452 * @return a new ExpandibleComposite widget
453 * @since 3.6
454 */
455 public static ExpandableComposite createExpandibleComposite(Composite parent, int style, String label, int hspan, int fill) {
456 ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, style);
457 ex.setText(label);
458 ex.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
459 GridData gd = new GridData(fill);
460 gd.horizontalSpan = hspan;
461 ex.setLayoutData(gd);
462 return ex;
463 }
464
465 /**
466 * Creates a composite that uses the parent's font and has a grid layout
467 * @param parent the parent to add the composite to
468 * @param columns the number of columns the composite should have
469 * @param hspan the horizontal span the new composite should take up in the parent
470 * @param fill the fill style of the composite {@link GridData}
471 * @return a new composite with a grid layout
472 *
473 * @since 3.3
474 */
475 public static Composite createComposite(Composite parent, int columns, int hspan, int fill) {
476 Composite g = new Composite(parent, SWT.NONE);
477 g.setLayout(new GridLayout(columns, false));
478 g.setFont(parent.getFont());
479 GridData gd = new GridData(fill);
480 gd.horizontalSpan = hspan;
481 g.setLayoutData(gd);
482 return g;
483 }
484
485 /**
486 * Creates a vertical spacer for separating components. If applied to a
487 * <code>GridLayout</code>, this method will automatically span all of the columns of the parent
488 * to make vertical space
489 *
490 * @param parent the parent composite to add this spacer to
491 * @param numlines the number of vertical lines to make as space
492 * @since 3.3
493 */
494 public static void createVerticalSpacer(Composite parent, int numlines) {
495 Label lbl = new Label(parent, SWT.NONE);
496 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
497 Layout layout = parent.getLayout();
498 if(layout instanceof GridLayout) {
499 gd.horizontalSpan = ((GridLayout)parent.getLayout()).numColumns;
500 }
501 gd.heightHint = numlines;
502 lbl.setLayoutData(gd);
503 }
504
505 /**
506 * creates a horizontal spacer for separating components
507 * @param comp
508 * @param numlines
509 * @since 3.3
510 */
511 public static void createHorizontalSpacer(Composite comp, int numlines) {
512 Label lbl = new Label(comp, SWT.NONE);
513 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
514 gd.horizontalSpan = numlines;
515 lbl.setLayoutData(gd);
516 }
517
518 /**
519 * Creates a Composite widget
520 * @param parent the parent composite to add this composite to
521 * @param font the font to set on the control
522 * @param columns the number of columns within the composite
523 * @param hspan the horizontal span the composite should take up on the parent
524 * @param fill the style for how this composite should fill into its parent
525 * @param marginwidth the width of the margin to place on the sides of the composite (default is 5, specified by GridLayout)
526 * @param marginheight the height of the margin to place o the top and bottom of the composite
527 * @return the new composite
528 * @since 3.3
529 */
530 public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill, int marginwidth, int marginheight) {
531 Composite g = new Composite(parent, SWT.NONE);
532 GridLayout layout = new GridLayout(columns, false);
533 layout.marginWidth = marginwidth;
534 layout.marginHeight = marginheight;
535 g.setLayout(layout);
536 g.setFont(font);
537 GridData gd = new GridData(fill);
538 gd.horizontalSpan = hspan;
539 g.setLayoutData(gd);
540 return g;
541 }
542
543 /**
544 * Creates a {@link ViewForm}
545 * @param parent
546 * @param style
547 * @param cols
548 * @param span
549 * @param fill
550 * @param marginwidth
551 * @param marginheight
552 * @return a new {@link ViewForm}
553 * @since 3.6
554 */
555 public static ViewForm createViewform(Composite parent, int style, int cols, int span, int fill, int marginwidth, int marginheight) {
556 ViewForm form = new ViewForm(parent, style);
557 form.setFont(parent.getFont());
558 GridLayout layout = new GridLayout(cols, false);
559 layout.marginWidth = marginwidth;
560 layout.marginHeight = marginheight;
561 form.setLayout(layout);
562 GridData gd = new GridData(fill);
563 gd.horizontalSpan = span;
564 form.setLayoutData(gd);
565 return form;
566 }
567
568 /**
569 * Creates a Composite widget
570 * @param parent the parent composite to add this composite to
571 * @param font the font to set on the control
572 * @param columns the number of columns within the composite
573 * @param hspan the horizontal span the composite should take up on the parent
574 * @param fill the style for how this composite should fill into its parent
575 * @param marginwidth the width of the margin to place on the sides of the composite (default is 5, specified by GridLayout)
576 * @param marginheight the height of the margin to place o the top and bottom of the composite
577 * @return the new composite
578 * @since 3.6
579 */
580 public static Composite createComposite(Composite parent, Font font, int style, int columns, int hspan, int fill, int marginwidth, int marginheight) {
581 Composite g = new Composite(parent, style);
582 GridLayout layout = new GridLayout(columns, false);
583 layout.marginWidth = marginwidth;
584 layout.marginHeight = marginheight;
585 g.setLayout(layout);
586 g.setFont(font);
587 GridData gd = new GridData(fill);
588 gd.horizontalSpan = hspan;
589 g.setLayoutData(gd);
590 return g;
591 }
592
593 /**
594 * This method is used to make a combo box
595 * @param parent the parent composite to add the new combo to
596 * @param style the style for the Combo
597 * @param hspan the horizontal span to take up on the parent composite
598 * @param fill how the combo will fill into the composite
599 * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code>
600 * @param items the item to put into the combo
601 * @return a new Combo instance
602 * @since 3.3
603 */
604 public static Combo createCombo(Composite parent, int style, int hspan, int fill, String[] items) {
605 Combo c = new Combo(parent, style);
606 c.setFont(parent.getFont());
607 GridData gd = new GridData(fill);
608 gd.horizontalSpan = hspan;
609 c.setLayoutData(gd);
610 if (items != null){
611 c.setItems(items);
612 }
613 // Some platforms open up combos in bad sizes without this, see bug 245569
614 c.setVisibleItemCount(30);
615 c.select(0);
616 return c;
617 }
618
619 /**
620 * This method is used to make a combo box with a default fill style of GridData.FILL_HORIZONTAL
621 * @param parent the parent composite to add the new combo to
622 * @param style the style for the Combo
623 * @param hspan the horizontal span to take up on the parent composite
624 * @param items the item to put into the combo
625 * @return a new Combo instance
626 * @since 3.3
627 */
628 public static Combo createCombo(Composite parent, int style, int hspan, String[] items) {
629 Combo c = new Combo(parent, style);
630 c.setFont(parent.getFont());
631 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
632 gd.horizontalSpan = hspan;
633 c.setLayoutData(gd);
634 if (items != null){
635 c.setItems(items);
636 }
637 // Some platforms open up combos in bad sizes without this, see bug 245569
638 c.setVisibleItemCount(30);
639 c.select(0);
640 return c;
641 }
642}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspElement.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspElement.java
new file mode 100644
index 0000000..e7bf054
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspElement.java
@@ -0,0 +1,88 @@
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;
12
13public class YoctoBspElement {
14 private String metadataLoc;
15 private String buildLoc;
16 private String bspName;
17 private String bspOutLoc;
18 private String karch;
19 private String qarch;
20 private boolean validPropertiesFile;
21
22 public YoctoBspElement()
23 {
24 this.metadataLoc = "";
25 this.buildLoc = "";
26 this.bspName = "";
27 this.bspOutLoc = "";
28 this.karch = "";
29 this.qarch = "";
30 this.validPropertiesFile = false;
31 }
32
33 public String getMetadataLoc() {
34 return metadataLoc;
35 }
36
37 public void setMetadataLoc(String value) {
38 metadataLoc = value;
39 }
40
41 public String getBuildLoc() {
42 return buildLoc;
43 }
44
45 public void setBuildLoc(String value) {
46 buildLoc = value;
47 }
48
49 public String getBspName() {
50 return bspName;
51 }
52
53 public void setBspName(String value) {
54 this.bspName = value;
55 }
56
57 public String getBspOutLoc() {
58 return bspOutLoc;
59 }
60
61 public void setBspOutLoc(String value) {
62 this.bspOutLoc = value;
63 }
64
65 public String getKarch() {
66 return karch;
67 }
68
69 public void setKarch(String value) {
70 this.karch = value;
71 }
72
73 public String getQarch() {
74 return qarch;
75 }
76
77 public void setQarch(String value) {
78 this.qarch = value;
79 }
80
81 public boolean getValidPropertiesFile() {
82 return validPropertiesFile;
83 }
84
85 public void setValidPropertiesFile(boolean value) {
86 this.validPropertiesFile = value;
87 }
88}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspPropertyElement.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspPropertyElement.java
new file mode 100644
index 0000000..e88b4bd
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoBspPropertyElement.java
@@ -0,0 +1,65 @@
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;
12
13public class YoctoBspPropertyElement implements Comparable<YoctoBspPropertyElement>{
14 private String name;
15 private String type;
16 private String value;
17 private String defaultValue;
18
19 public YoctoBspPropertyElement()
20 {
21 this.name = "";
22 this.type = "";
23 this.value = "";
24 this.defaultValue = "";
25 }
26
27 public String getName() {
28 return name;
29 }
30
31 public void setName(String value) {
32 name = value;
33 }
34
35 public String getType() {
36 return type;
37 }
38
39 public void setType(String value) {
40 type = value;
41 }
42
43 public String getDefaultValue() {
44 return defaultValue;
45 }
46
47 public void setDefaultValue(String value) {
48 this.defaultValue = value;
49 }
50
51 public String getValue() {
52 return value;
53 }
54
55 public void setValue(String value) {
56 this.value = value;
57 }
58
59 @Override
60 public int compareTo(YoctoBspPropertyElement o) {
61 return type.compareTo(o.type);
62 }
63
64
65}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoJSONHelper.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoJSONHelper.java
new file mode 100644
index 0000000..37ce54d
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/YoctoJSONHelper.java
@@ -0,0 +1,89 @@
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;
12
13import java.io.IOException;
14import java.io.FileWriter;
15import java.util.Iterator;
16import java.util.Set;
17import java.util.HashSet;
18import java.io.FileReader;
19
20import org.json.simple.JSONObject;
21import org.json.simple.JSONValue;
22
23public class YoctoJSONHelper {
24 private static final String PROPERTIES_FILE = "/tmp/properties.json";
25 private static final String PROPERTY_VALUE_FILE = "/tmp/propertyvalues.json";
26
27 private static HashSet<YoctoBspPropertyElement> properties;
28
29 public static HashSet<YoctoBspPropertyElement> getProperties() throws Exception {
30
31 properties = new HashSet<YoctoBspPropertyElement>();
32 try {
33
34 JSONObject obj = (JSONObject)JSONValue.parse(new FileReader(PROPERTIES_FILE));
35 Set<String> keys = obj.keySet();
36 if (!keys.isEmpty()) {
37 Iterator<String> iter = keys.iterator();
38 while (iter.hasNext()) {
39 String key = (String)iter.next();
40 if (validKey(key)) {
41 JSONObject value_obj = (JSONObject)obj.get(key);
42 YoctoBspPropertyElement elem = new YoctoBspPropertyElement();
43 elem.setName(key);
44 String type = (String)value_obj.get("type");
45 elem.setType(type);
46 if (type.contentEquals("boolean")) {
47 elem.setDefaultValue((String)value_obj.get("default"));
48 }
49 properties.add(elem);
50 }
51 }
52 }
53
54 } catch (Exception e) {
55 throw e;
56 }
57 return properties;
58 }
59
60 public static void createBspJSONFile(HashSet<YoctoBspPropertyElement> properties) {
61 try {
62 JSONObject obj = new JSONObject();
63 if (!properties.isEmpty()) {
64 Iterator<YoctoBspPropertyElement> it = properties.iterator();
65 while (it.hasNext()) {
66 // Get property
67 YoctoBspPropertyElement propElem = (YoctoBspPropertyElement)it.next();
68 obj.put(propElem.getName(), propElem.getValue());
69 }
70 }
71
72 FileWriter file = new FileWriter(PROPERTY_VALUE_FILE);
73 file.write(obj.toJSONString());
74 file.flush();
75 file.close();
76
77 } catch (IOException e) {
78 e.printStackTrace();
79 }
80 }
81
82 private static boolean validKey(String key) {
83 if (key.contains("kernel"))
84 return false;
85 if (key.contentEquals("qemuarch"))
86 return false;
87 return true;
88 }
89}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java
new file mode 100644
index 0000000..dacd192
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java
@@ -0,0 +1,123 @@
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.IOException;
14import java.io.InputStream;
15import java.lang.reflect.InvocationTargetException;
16
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.core.runtime.SubProgressMonitor;
19import org.eclipse.jface.operation.IRunnableWithProgress;
20import org.eclipse.rse.core.model.IHost;
21import org.yocto.remote.utils.RSEHelper;
22import org.yocto.remote.utils.RemoteShellExec;
23
24abstract public class BaseModel implements IRunnableWithProgress {
25 protected IHost host;
26 protected String taskName;
27 protected String localScript;
28 protected String remoteExec;
29 protected String localFile;
30 protected String remoteFile;
31
32 private static final int WORKLOAD = 100;
33
34 private static final int INIT_PERCENT = 5;
35 private static final int PRE_PROCESS_PERCENT = 30;
36 private static final int PROCESS_PERCENT = 30;
37 private static final int POST_PROCESS_PERCENT = 30;
38 private static final int CLEAN_PERCENT = 5;
39
40 private static final String RUN_MSG = "Running task: ";
41 private static final String INIT_MSG = "Initializing ";
42 private static final String PRE_PROCESS_MSG = "Preparing ";
43 private static final String PROCESS_MSG = "Processing ";
44 private static final String POST_PROCESS_MSG = "Finishing ";
45 private static final String CLEAN_MSG = "Cleaning ";
46 private static final String DOTS = "...";
47 private static final String FAILED_ERR_MSG = " failed with exit code ";
48
49 public void preProcess(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException{
50 //upload script to remote
51 try {
52 RSEHelper.putRemoteFileInPlugin(host, localScript, remoteExec, monitor);
53 }catch (InterruptedException e){
54 throw e;
55 }catch (InvocationTargetException e) {
56 throw e;
57 }catch (Exception e) {
58 throw new InvocationTargetException(e, e.getMessage());
59 }
60 }
61 public void postProcess(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException{}
62
63 abstract public void process(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException;
64
65 public BaseModel(IHost host, String taskName, String localScript, String remoteExec) {
66 this.host = host;
67 this.taskName = taskName;
68 this.localScript = localScript;
69 this.remoteExec = remoteExec;
70 }
71 protected void init(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
72 }
73
74 protected void clean(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
75 }
76
77 public void run(IProgressMonitor monitor) throws InvocationTargetException,
78 InterruptedException {
79
80 try {
81 monitor.beginTask(RUN_MSG + taskName, WORKLOAD);
82
83 monitor.subTask(INIT_MSG + taskName + DOTS);
84 init(new SubProgressMonitor(monitor, INIT_PERCENT));
85
86 monitor.subTask(PRE_PROCESS_MSG + taskName + DOTS);
87 preProcess(new SubProgressMonitor(monitor, PRE_PROCESS_PERCENT));
88
89 monitor.subTask(PROCESS_MSG + taskName + DOTS);
90 process(new SubProgressMonitor(monitor, PROCESS_PERCENT));
91
92 monitor.subTask(POST_PROCESS_MSG + taskName + DOTS);
93 postProcess(new SubProgressMonitor(monitor, POST_PROCESS_PERCENT));
94 } catch (InterruptedException e){
95 throw new InterruptedException("User cancelled!");
96 } catch (InvocationTargetException e) {
97 throw e;
98 } finally {
99 monitor.subTask(CLEAN_MSG + taskName + DOTS);
100 clean(new SubProgressMonitor(monitor, CLEAN_PERCENT));
101 monitor.done();
102 }
103 }
104
105 protected void getDataFile(IProgressMonitor monitor) throws Exception {
106 RSEHelper.getRemoteFile( host, localFile, remoteFile, monitor);
107 }
108 protected void runRemoteShellExec(IProgressMonitor monitor, String args, boolean cancelable) throws Exception {
109 try {
110 RemoteShellExec exec = new RemoteShellExec(host, remoteExec);
111 exec.start(null, args, monitor);
112 monitor.worked(1);
113 checkTerminate(exec.getInputStream());
114 int exit_code = exec.waitFor(cancelable ? monitor : null);
115 exec.terminate();
116 if(exit_code != 0)
117 throw new Exception(taskName + FAILED_ERR_MSG + new Integer(exit_code).toString());
118 } finally {
119 monitor.done();
120 }
121 }
122 protected void checkTerminate(InputStream inputStream) throws IOException {}
123}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java
new file mode 100644
index 0000000..7845959
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java
@@ -0,0 +1,216 @@
1/*******************************************************************************
2 * Copyright (c) 2006, 2010 PalmSource, Inc. and others.
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 * Ewa Matejska (PalmSource) - initial API and implementation
10 * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
11 * Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
12 * Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
13 * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
14 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
15 * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
16 * Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
17 * Anna Dushistova (MontaVista) - [223728] [remotecdt] connection combo is not populated until RSE is activated
18 * Anna Dushistova (MontaVista) - [267951] [remotecdt] Support systemTypes without files subsystem
19 * Lianhao Lu (Intel) - Modified for internal use
20 *******************************************************************************/
21
22package org.yocto.sdk.remotetools.actions;
23
24import org.yocto.remote.utils.RSEHelper;
25import org.yocto.sdk.remotetools.Messages;
26import org.yocto.sdk.remotetools.SWTFactory;
27import org.eclipse.jface.dialogs.Dialog;
28import org.eclipse.jface.dialogs.IDialogConstants;
29import org.eclipse.rse.core.model.IHost;
30import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
31import org.eclipse.swt.SWT;
32import org.eclipse.swt.events.ModifyEvent;
33import org.eclipse.swt.events.ModifyListener;
34import org.eclipse.swt.events.SelectionAdapter;
35import org.eclipse.swt.events.SelectionEvent;
36import org.eclipse.swt.layout.GridData;
37import org.eclipse.swt.layout.GridLayout;
38import org.eclipse.swt.widgets.Button;
39import org.eclipse.swt.widgets.Combo;
40import org.eclipse.swt.widgets.Composite;
41import org.eclipse.swt.widgets.Control;
42import org.eclipse.swt.widgets.Label;
43import org.eclipse.swt.widgets.Shell;
44
45public class BaseSettingDialog extends Dialog {
46
47 protected String title;
48 protected String curConn; //current rse connection name
49 protected IHost conn;//rse IHost
50
51 protected Button newRemoteConnectionButton;
52 protected Label connectionLabel;
53 protected Combo connectionCombo;
54 protected SystemNewConnectionAction action = null;
55
56
57 protected BaseSettingDialog(Shell parentShell,String title, String connection) {
58 super(parentShell);
59 this.title=title;
60 this.curConn=connection;
61 }
62
63 @Override
64 protected void configureShell(Shell newShell) {
65 super.configureShell(newShell);
66 newShell.setText(title);
67 }
68
69 @Override
70 protected Control createDialogArea(Composite parent) {
71 Composite comp = (Composite)super.createDialogArea(parent);
72 GridLayout topLayout = new GridLayout();
73 comp.setLayout(topLayout);
74
75 /* The RSE Connection dropdown with New button. */
76 SWTFactory.createVerticalSpacer(comp, 1);
77 createRemoteConnectionGroup(comp);
78
79 return comp;
80 }
81
82
83 @Override
84 protected void createButtonsForButtonBar(Composite parent) {
85 super.createButtonsForButtonBar(parent);
86 updateCurConn();
87 }
88
89 protected void createRemoteConnectionGroup(Composite parent) {
90 Composite projComp = new Composite(parent, SWT.NONE);
91 GridLayout projLayout = new GridLayout();
92 projLayout.numColumns = 6;
93 projLayout.marginHeight = 0;
94 projLayout.marginWidth = 0;
95 projComp.setLayout(projLayout);
96 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
97 projComp.setLayoutData(gd);
98
99 connectionLabel = new Label(projComp, SWT.NONE);
100 connectionLabel.setText(Messages.BaseSettingDialog_Connection);
101 gd = new GridData();
102 gd.horizontalSpan = 1;
103 connectionLabel.setLayoutData(gd);
104
105 connectionCombo = new Combo(projComp, SWT.DROP_DOWN | SWT.READ_ONLY);
106 gd = new GridData(GridData.FILL_HORIZONTAL);
107 gd.horizontalSpan = 4;
108 connectionCombo.setLayoutData(gd);
109 connectionCombo.addModifyListener(new ModifyListener() {
110
111 public void modifyText(ModifyEvent e) {
112 //setDirty(true);
113 //updateLaunchConfigurationDialog();
114 //useDefaultsFromConnection();
115 updateCurConn();
116 }
117 });
118
119 newRemoteConnectionButton = SWTFactory.createPushButton(projComp,
120 Messages.BaseSettingDialog_New, null);
121 newRemoteConnectionButton.addSelectionListener(new SelectionAdapter() {
122
123 public void widgetSelected(SelectionEvent evt) {
124 handleNewRemoteConnectionSelected();
125 //updateLaunchConfigurationDialog();
126 updateConnectionPulldown();
127 }
128 });
129 gd = new GridData();
130 gd.horizontalSpan = 1;
131 newRemoteConnectionButton.setLayoutData(gd);
132
133 updateConnectionPulldown();
134 }
135
136 protected boolean updateOkButton() {
137 boolean ret=false;
138 Button button=getButton(IDialogConstants.OK_ID);
139 if(button!=null)
140 button.setEnabled(false);
141 IHost currentConnectionSelected = getCurrentConnection();
142 if (currentConnectionSelected != null) {
143 if (RSEHelper.isHostViable(currentConnectionSelected) && button != null){
144 button.setEnabled(true);
145 ret=true;
146 }
147 }
148 return ret;
149 }
150
151 protected void updateCurConn() {
152 IHost currentConnectionSelected = getCurrentConnection();
153 if (currentConnectionSelected != null) {
154 if (RSEHelper.isHostViable(currentConnectionSelected))
155 curConn=currentConnectionSelected.getAliasName();
156 }
157 updateOkButton();
158 }
159
160 protected IHost getCurrentConnection() {
161 int currentSelection = connectionCombo.getSelectionIndex();
162 String remoteConnection = currentSelection >= 0 ? connectionCombo
163 .getItem(currentSelection) : null;
164 return RSEHelper.getRemoteConnectionByName(remoteConnection);
165 }
166
167 protected void handleNewRemoteConnectionSelected() {
168 if (action == null) {
169 action = new SystemNewConnectionAction(getShell(),
170 false, false, null);
171 }
172
173 try {
174 action.run();
175 } catch (Exception e) {
176 // Ignore
177 }
178 }
179
180 protected void updateConnectionPulldown() {
181 int index=-1;
182 RSEHelper.waitForRSEInitCompletition();
183 // already initialized
184 connectionCombo.removeAll();
185 IHost[] connections = RSEHelper.getSuitableConnections();
186 for (int i = 0; i < connections.length; i++) {
187 connectionCombo.add(connections[i].getAliasName());
188 if(connections[i].getAliasName().equals(curConn))
189 index=i;
190 }
191
192 if(index>=0) {
193 connectionCombo.select(index);
194 }else if (connections.length > 0) {
195 connectionCombo.select(connections.length - 1);
196 }
197
198 //TODO
199 //connectionCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT,true);
200 connectionCombo.pack(true);
201 connectionCombo.layout();
202 connectionCombo.getParent().layout();
203
204 updateCurConn();
205 }
206
207 @Override
208 protected void okPressed() {
209 conn=getCurrentConnection();
210 super.okPressed();
211 }
212
213 public IHost getHost() {
214 return conn;
215 }
216}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/DialogHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/DialogHandler.java
new file mode 100644
index 0000000..231de77
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/DialogHandler.java
@@ -0,0 +1,42 @@
1/*******************************************************************************
2 * Copyright (c) 2013 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 org.eclipse.core.commands.ExecutionEvent;
14import org.eclipse.core.commands.ExecutionException;
15import org.eclipse.rse.core.model.IHost;
16import org.eclipse.ui.IWorkbenchWindow;
17import org.eclipse.ui.handlers.HandlerUtil;
18import org.yocto.remote.utils.TerminalHandler;
19
20abstract public class DialogHandler extends TerminalHandler {
21
22 protected BaseSettingDialog setting;
23
24 abstract protected String getDialogTitle();
25
26 protected void initialize(ExecutionEvent event) throws ExecutionException{
27 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
28 shell = window.getShell();
29 setting = new SimpleSettingDialog(shell, getDialogTitle(), getConnnectionName());
30 }
31
32 @Override
33 public Object execute(ExecutionEvent event) throws ExecutionException {
34 initialize(event);
35
36 if(setting.open() == BaseSettingDialog.OK) {
37 IHost currentHost = setting.getHost();
38 execute(currentHost);
39 }
40 return null;
41 }
42}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/IBaseConstants.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/IBaseConstants.java
new file mode 100644
index 0000000..d4bbe12
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/IBaseConstants.java
@@ -0,0 +1,27 @@
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
13public interface IBaseConstants {
14 public static final String TCF_TYPE_ID="org.eclipse.tcf.rse.systemType";//$NON-NLS-1$
15
16 public static final String QUALIFIER="org.yocto.sdk.remotetools";//$NON-NLS-1$
17
18 public static final String CONNECTION_NAME_OPROFILE = QUALIFIER + "connection.oprofile"; //$NON-NLS-1$
19 public static final String CONNECTION_NAME_UST = QUALIFIER + "connection.ust"; //$NON-NLS-1$
20 public static final String CONNECTION_NAME_POWERTOP = QUALIFIER + "connection.powertop"; //$NON-NLS-1$
21 public static final String CONNECTION_NAME_LATENCYTOP = QUALIFIER + "connection.latencytop"; //$NON-NLS-1$
22 public static final String CONNECTION_NAME_PERF = QUALIFIER + "connection.perf"; //$NON-NLS-1$
23 public static final String CONNECTION_NAME_SYSTEMTAP = QUALIFIER + "connection.systemtap"; //$NON-NLS-1$
24
25 public static final String DIALOG_TITLE_LATENCYTOP = "Latencytop"; //$NON-NLS-1$
26 public static final String DIALOG_TITLE_PERF = "Perf"; //$NON-NLS-1$
27}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/LatencytopHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/LatencytopHandler.java
new file mode 100644
index 0000000..1088dee
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/LatencytopHandler.java
@@ -0,0 +1,35 @@
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
13
14public class LatencytopHandler extends DialogHandler {
15
16 protected String changeTerm = "export TERM=xterm;";
17 private static String initCmd="export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin; cd; sudo latencytop\r";
18
19 @Override
20 protected String getInitCmd() {
21 return initCmd;
22 }
23 @Override
24 protected String changeTerm() {
25 return changeTerm;
26 }
27 @Override
28 protected String getConnnectionName() {
29 return IBaseConstants.CONNECTION_NAME_LATENCYTOP;
30 }
31 @Override
32 protected String getDialogTitle() {
33 return IBaseConstants.DIALOG_TITLE_LATENCYTOP;
34 }
35}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileHandler.java
new file mode 100644
index 0000000..980737f
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileHandler.java
@@ -0,0 +1,55 @@
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 org.eclipse.core.commands.AbstractHandler;
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
16import org.eclipse.jface.dialogs.MessageDialog;
17import org.eclipse.ui.IWorkbenchWindow;
18import org.eclipse.ui.PlatformUI;
19import org.eclipse.ui.handlers.HandlerUtil;
20import org.eclipse.ui.progress.IProgressService;
21
22public class OprofileHandler extends AbstractHandler {
23
24 public Object execute(ExecutionEvent event) throws ExecutionException {
25
26 if(OprofileModel.checkAvail()!=true) {
27 return null;
28 }
29
30 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
31
32 SimpleSettingDialog setting=new SimpleSettingDialog(
33 window.getShell(),
34 "Oprofile",
35 IBaseConstants.CONNECTION_NAME_OPROFILE
36 );
37
38 if(setting.open()==BaseSettingDialog.OK) {
39 IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
40 OprofileModel op=new OprofileModel(setting.getHost(),window);
41 try {
42 progressService.busyCursorWhile(op);
43 }catch (InterruptedException e) {
44 //user cancelled
45 }catch (Exception e) {
46 e.printStackTrace();
47 MessageDialog.openError(window.getShell(),
48 "Oprofile",
49 (e.getCause() != null) ? e.getCause().getMessage() : e.getMessage());
50 }
51 }
52 return null;
53 }
54
55}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileModel.java
new file mode 100644
index 0000000..7fbe7c6
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/OprofileModel.java
@@ -0,0 +1,171 @@
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.BufferedReader;
14import java.io.File;
15import java.io.FileReader;
16import java.io.IOException;
17import java.lang.reflect.InvocationTargetException;
18
19import org.eclipse.core.runtime.IProgressMonitor;
20import org.eclipse.core.runtime.SubProgressMonitor;
21import org.eclipse.jface.preference.IPreferenceStore;
22import org.eclipse.rse.core.model.IHost;
23import org.eclipse.ui.IWorkbenchWindow;
24import org.yocto.remote.utils.CommonHelper;
25import org.yocto.sdk.ide.YoctoSDKPlugin;
26import org.yocto.sdk.ide.preferences.PreferenceConstants;
27import org.yocto.sdk.remotetools.LocalJob;
28import org.yocto.sdk.remotetools.Messages;
29
30public class OprofileModel extends BaseModel {
31
32 private static final String REMOTE_EXEC = "/tmp/yocto_tool.sh";
33 private static final String LOCAL_SCRIPT = "resources/yocto_tool.sh";
34
35 private static final String LOCAL_EXEC = "oprofile-viewer";
36
37 private static final String TASK_NAME = "oprofile command";
38
39 private IWorkbenchWindow window;
40 public OprofileModel(IHost host, IWorkbenchWindow window) {
41 super(host, TASK_NAME, LOCAL_SCRIPT, REMOTE_EXEC);
42 this.window = window;
43 }
44
45 private void startServer(IProgressMonitor monitor) throws Exception {
46 String args="start -d oprofile-server";
47 runRemoteShellExec(monitor, args, true);
48 }
49
50 private void stopServer(IProgressMonitor monitor) throws Exception {
51 String args = "stop -d oprofile-server";
52 runRemoteShellExec(monitor, args, false);
53 }
54
55 private String getSearchPath()
56 {
57 try
58 {
59 String search=null;
60 IPreferenceStore store = YoctoSDKPlugin.getDefault().getPreferenceStore();
61 String env_script=store.getString(PreferenceConstants.TOOLCHAIN_ROOT) +
62 "/" +
63 "environment-setup-" +
64 store.getString(PreferenceConstants.TOOLCHAIN_TRIPLET);
65 File file = new File(env_script);
66
67 if (file.exists()) {
68 BufferedReader input = new BufferedReader(new FileReader(file));
69
70 try
71 {
72 String line = null;
73
74 while ((line = input.readLine()) != null)
75 {
76 if (!line.startsWith("export"))
77 continue;
78 String sKey = line.substring("export".length() + 1, line.indexOf('='));
79 if(!sKey.equals("PATH"))
80 continue;
81 String sValue = line.substring(line.indexOf('=') + 1);
82 if (sValue.startsWith("\"") && sValue.endsWith("\""))
83 sValue = sValue.substring(sValue.indexOf('"') + 1, sValue.lastIndexOf('"'));
84 /* If PATH ending with $PATH, we need to join with current system path */
85 if (sKey.equalsIgnoreCase("PATH")) {
86 if (sValue.lastIndexOf("$PATH") >= 0)
87 sValue = sValue.substring(0, sValue.lastIndexOf("$PATH")) + System.getenv("PATH");
88 }
89 search=sValue;
90 //System.out.printf("get env key %s value %s\n", sKey, sValue);
91 }
92
93 }
94 finally {
95 input.close();
96 }
97 }
98
99 return search;
100
101 }
102 catch (IOException e)
103 {
104 e.printStackTrace();
105 return null;
106 }
107
108 }
109
110 @Override
111 public void process(IProgressMonitor monitor)
112 throws InvocationTargetException, InterruptedException {
113
114 boolean stopServer=true;
115
116 try {
117 try {
118 monitor.beginTask("Starting oprofile", 100);
119 //start oprofile-server
120 monitor.subTask("Starting oprofile-server");
121 startServer(new SubProgressMonitor(monitor,80));
122
123 //start local oprofile-viewer
124 monitor.subTask("oprofile-viewer is running locally");
125 String searchPath=getSearchPath();
126
127 new LocalJob("oprofile-viewer",
128 (searchPath!=null) ?
129 new String[] {LOCAL_EXEC,"-h",host.getHostName(),"-s",searchPath} :
130 new String[] {LOCAL_EXEC,"-h",host.getHostName()},
131 null,
132 null,
133 window).schedule();
134 //we can't stop server because the oprofile-viewer is running asynchronously
135 stopServer=false;
136
137 }catch (InterruptedException e) {
138 throw e;
139 }finally {
140 //stop oprofile-server
141 if(stopServer) {
142 monitor.subTask("Stopping oprofile-viewer");
143 stopServer(new SubProgressMonitor(monitor,30));
144 }
145 }
146 }catch (InterruptedException e){
147 throw e;
148 }catch (InvocationTargetException e) {
149 throw e;
150 }catch (Exception e){
151 throw new InvocationTargetException(e, e.getMessage());
152 }finally {
153 monitor.done();
154 }
155 }
156
157 static public boolean checkAvail() {
158 boolean ret=CommonHelper.isExecAvail(LOCAL_EXEC);
159
160 if(ret==false) {
161 CommonHelper.showErrorDialog("Oprofile", null,Messages.ErrorOprofileViewer);
162 }else {
163 ret=CommonHelper.isExecAvail("opreport");
164 if(ret==false) {
165 CommonHelper.showErrorDialog("Oprofile", null,Messages.ErrorOprofile);
166 }
167 }
168 return ret;
169 }
170
171}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PerfHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PerfHandler.java
new file mode 100644
index 0000000..f3f9e49
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PerfHandler.java
@@ -0,0 +1,30 @@
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
13
14public class PerfHandler extends DialogHandler {
15
16 private static String initCmd="cd; perf\r";
17
18 @Override
19 protected String getInitCmd() {
20 return initCmd;
21 }
22 @Override
23 protected String getConnnectionName() {
24 return IBaseConstants.CONNECTION_NAME_PERF;
25 }
26 @Override
27 protected String getDialogTitle() {
28 return IBaseConstants.DIALOG_TITLE_PERF;
29 }
30}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java
new file mode 100644
index 0000000..152f142
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java
@@ -0,0 +1,48 @@
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 org.eclipse.core.commands.AbstractHandler;
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
16import org.eclipse.jface.dialogs.MessageDialog;
17import org.eclipse.ui.IWorkbenchWindow;
18import org.eclipse.ui.PlatformUI;
19import org.eclipse.ui.handlers.HandlerUtil;
20import org.eclipse.ui.progress.IProgressService;
21
22public class PowertopHandler extends AbstractHandler {
23
24 public Object execute(ExecutionEvent event) throws ExecutionException {
25 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
26
27 PowertopSettingDialog setting=new PowertopSettingDialog(
28 window.getShell()
29 );
30
31 if(setting.open()==BaseSettingDialog.OK) {
32 IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
33 PowertopModel op=new PowertopModel(setting.getHost(),setting.getTime(),setting.getShowPid(),window.getShell().getDisplay());
34 try {
35 progressService.busyCursorWhile(op);
36 }catch (InterruptedException e) {
37 //user cancelled
38 }catch (Exception e) {
39 e.printStackTrace();
40 MessageDialog.openError(window.getShell(),
41 "Powertop",
42 (e.getCause() != null) ? e.getCause().getMessage() : e.getMessage());
43 }
44 }
45 return null;
46 }
47
48}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopModel.java
new file mode 100644
index 0000000..79bef61
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopModel.java
@@ -0,0 +1,109 @@
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;
14import java.lang.reflect.InvocationTargetException;
15import java.text.SimpleDateFormat;
16import java.util.Calendar;
17
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.core.runtime.SubProgressMonitor;
20import org.eclipse.rse.core.model.IHost;
21import org.eclipse.swt.widgets.Display;
22import org.eclipse.ui.IWorkbenchPage;
23import org.eclipse.ui.PartInitException;
24import org.eclipse.ui.PlatformUI;
25import org.yocto.sdk.remotetools.views.BaseFileView;
26
27public class PowertopModel extends BaseModel {
28
29 private static final String REMOTE_EXEC = "/tmp/yocto_tool.sh";
30 private static final String LOCAL_SCRIPT = "resources/yocto_tool.sh";
31
32 private static final String REMOTE_FILE_PREFIX = "/tmp/yocto-powertop-";
33 private static final String LOCAL_FILE_SUFFIX = ".local";
34
35 private static final String TASK_NAME = "powertop command";
36
37 private Float time;
38 private boolean showpid;
39 Display display;
40
41 public PowertopModel(IHost host, Float time,boolean showpid,Display display) {
42 super(host, TASK_NAME, LOCAL_SCRIPT, REMOTE_EXEC);
43 this.time=time;
44 this.showpid=showpid;
45 this.display=display;
46 }
47
48 @Override
49 public void postProcess(IProgressMonitor monitor)
50 throws InvocationTargetException, InterruptedException {
51 try {
52 new File(localFile).delete();
53 }catch (Exception e) {
54
55 }
56 }
57
58 private void generateData(IProgressMonitor monitor) throws Exception {
59 String currentDate = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(Calendar.getInstance().getTime()).toString();
60 remoteFile = new String(REMOTE_FILE_PREFIX + currentDate);
61 localFile = new String(remoteFile + LOCAL_FILE_SUFFIX);
62
63 String args = "start -l " + remoteFile + " powertop --debug --time " + time.toString();
64 if(showpid)
65 args += " -p";
66 runRemoteShellExec(monitor, args, true);
67 }
68
69 @Override
70 public void process(IProgressMonitor monitor)
71 throws InvocationTargetException, InterruptedException {
72
73 monitor.beginTask("Running powertop", 100);
74 try {
75 //running powertop
76 monitor.subTask("Generating powertop data file remotely");
77 generateData(new SubProgressMonitor(monitor,30));
78 //download datafile
79 monitor.subTask("Downloading powertop data file");
80 getDataFile(new SubProgressMonitor(monitor,30));
81 //show it in the powertop view
82 display.syncExec(new Runnable() {
83 public void run() {
84 BaseFileView view;
85 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
86 try {
87 view=(BaseFileView) page.showView("org.yocto.sdk.remotetools.views.PowerTopView");
88 }catch (PartInitException e) {
89 e.printStackTrace();
90 return;
91 }
92 view.setInput(localFile);
93 page.bringToTop(view);
94 }
95 });
96
97 }catch (InterruptedException e){
98 throw e;
99 }catch (InvocationTargetException e) {
100 throw e;
101 }catch (Exception e){
102 throw new InvocationTargetException(e, e.getMessage());
103 }finally {
104 monitor.done();
105 }
106
107 }
108
109}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java
new file mode 100644
index 0000000..bb41a4a
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopSettingDialog.java
@@ -0,0 +1,131 @@
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 org.eclipse.jface.dialogs.IDialogConstants;
14import org.eclipse.jface.dialogs.IDialogSettings;
15import org.eclipse.swt.SWT;
16import org.eclipse.swt.events.ModifyEvent;
17import org.eclipse.swt.events.ModifyListener;
18import org.eclipse.swt.layout.GridData;
19import org.eclipse.swt.layout.GridLayout;
20import org.eclipse.swt.widgets.Button;
21import org.eclipse.swt.widgets.Composite;
22import org.eclipse.swt.widgets.Control;
23import org.eclipse.swt.widgets.Label;
24import org.eclipse.swt.widgets.Shell;
25import org.eclipse.swt.widgets.Text;
26import org.yocto.sdk.remotetools.Activator;
27import org.yocto.sdk.remotetools.Messages;
28import org.yocto.sdk.remotetools.SWTFactory;
29
30public class PowertopSettingDialog extends BaseSettingDialog {
31
32 static protected String TITLE="Powertop";
33
34 protected boolean showPid=false;
35 protected Float time;
36 protected Button showPidButton;
37 protected Text timeText;
38
39 protected PowertopSettingDialog(Shell parentShell, String title, String conn) {
40 super(parentShell,title,conn);
41 }
42
43 public PowertopSettingDialog(Shell parentShell) {
44 this(parentShell,
45 TITLE,
46 Activator.getDefault().getDialogSettings().get(IBaseConstants.CONNECTION_NAME_POWERTOP)
47 );
48 }
49
50 public boolean getShowPid() {
51 return showPid;
52 }
53
54 public Float getTime() {
55 return time;
56 }
57
58 @Override
59 protected Control createDialogArea(Composite parent) {
60 Composite comp=(Composite)super.createDialogArea(parent);
61 GridLayout topLayout = new GridLayout();
62 comp.setLayout(topLayout);
63
64 /*argument*/
65 SWTFactory.createVerticalSpacer(comp, 1);
66 createInternal(comp);
67
68 updateOkButton();
69 return comp;
70 }
71
72 protected void createInternal(Composite parent)
73 {
74 Composite projComp = new Composite(parent, SWT.NONE);
75 GridLayout projLayout = new GridLayout();
76 projLayout.numColumns = 4;
77 projLayout.marginHeight = 0;
78 projLayout.marginWidth = 0;
79 projComp.setLayout(projLayout);
80 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
81 projComp.setLayoutData(gd);
82
83 Label label = new Label(projComp, SWT.NONE);
84 label.setText(Messages.Powertop_Time_Text);
85 gd = new GridData();
86 gd.horizontalSpan = 1;
87 label.setLayoutData(gd);
88
89 timeText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
90 timeText.setText("5");
91 timeText.addModifyListener(new ModifyListener() {
92 public void modifyText(ModifyEvent e) {
93 updateOkButton();
94 }
95 });
96 gd = new GridData(GridData.FILL_HORIZONTAL);
97 gd.horizontalSpan = 3;
98 timeText.setLayoutData(gd);
99 }
100
101 @Override
102 protected boolean updateOkButton() {
103 boolean ret=super.updateOkButton();
104 if(ret==true) {
105 try {
106 Float.valueOf(timeText.getText());
107 }catch (Exception e) {
108 Button button=getButton(IDialogConstants.OK_ID);
109 if(button!=null)
110 button.setEnabled(false);
111 ret=false;
112 }
113 }
114 return ret;
115 }
116
117 @Override
118 protected void okPressed() {
119 IDialogSettings settings = Activator.getDefault().getDialogSettings();
120 // store the value of the generate sections checkbox
121 if(getCurrentConnection()==null) {
122 settings.put(IBaseConstants.CONNECTION_NAME_POWERTOP,
123 (String)null);
124 }else {
125 settings.put(IBaseConstants.CONNECTION_NAME_POWERTOP,
126 getCurrentConnection().getAliasName());
127 }
128 time=new Float(timeText.getText());
129 super.okPressed();
130 }
131}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SimpleSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SimpleSettingDialog.java
new file mode 100644
index 0000000..140d892
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SimpleSettingDialog.java
@@ -0,0 +1,54 @@
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 org.yocto.sdk.remotetools.Activator;
14import org.eclipse.jface.dialogs.IDialogSettings;
15import org.eclipse.swt.widgets.Composite;
16import org.eclipse.swt.widgets.Control;
17import org.eclipse.swt.widgets.Shell;
18
19public class SimpleSettingDialog extends BaseSettingDialog {
20
21 private final String connPropName;
22 /*
23 protected SimpleSettingDialog(Shell parentShell, String title, String conn) {
24 super(parentShell,title,conn);
25 }
26 */
27
28 public SimpleSettingDialog(Shell parentShell, String title, String connPropertyName) {
29 super(parentShell,
30 title,
31 Activator.getDefault().getDialogSettings().get(connPropertyName)
32 );
33 connPropName=connPropertyName;
34 }
35
36 @Override
37 protected Control createDialogArea(Composite parent) {
38 return super.createDialogArea(parent);
39 }
40
41 @Override
42 protected void okPressed() {
43 IDialogSettings settings = Activator.getDefault().getDialogSettings();
44 // store the value of the generate sections checkbox
45 if(getCurrentConnection()==null) {
46 settings.put(connPropName,
47 (String)null);
48 }else {
49 settings.put(connPropName,
50 getCurrentConnection().getAliasName());
51 }
52 super.okPressed();
53 }
54}
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..f5d34d8
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapHandler.java
@@ -0,0 +1,70 @@
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 org.eclipse.core.commands.AbstractHandler;
13import org.eclipse.core.commands.ExecutionEvent;
14import org.eclipse.core.commands.ExecutionException;
15import org.eclipse.jface.dialogs.MessageDialog;
16import org.eclipse.swt.widgets.Shell;
17import org.eclipse.ui.IWorkbenchWindow;
18import org.eclipse.ui.PlatformUI;
19import org.eclipse.ui.handlers.HandlerUtil;
20import org.eclipse.ui.progress.IProgressService;
21
22public class SystemtapHandler extends AbstractHandler {
23 protected SystemtapSettingDialog setting;
24 protected String changeTerm="export TERM=vt100;";
25 protected IWorkbenchWindow window;
26 protected Shell shell;
27
28 public Object execute(ExecutionEvent event) throws ExecutionException {
29
30 this.window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
31 shell = window.getShell();
32 setting=new SystemtapSettingDialog(
33 shell, "Systemtap"
34 );
35
36
37 if(setting.open() == BaseSettingDialog.OK) {
38
39 String metadata_location = ((SystemtapSettingDialog)setting).getMetadataLocation();
40 String builddir_location = ((SystemtapSettingDialog)setting).getBuilddirLocation();
41 String remote_host = ((SystemtapSettingDialog)setting).getRemoteHost();
42 String user_id = ((SystemtapSettingDialog)setting).getUserID();
43 String systemtap_script = ((SystemtapSettingDialog)setting).getSystemtapScript();
44 String systemtap_args = ((SystemtapSettingDialog)setting).getSystemtapArgs();
45 IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
46 SystemtapModel op = new SystemtapModel(metadata_location, builddir_location, remote_host, user_id, systemtap_script,
47 systemtap_args,window.getShell().getDisplay());
48 try {
49 progressService.busyCursorWhile(op);
50 }catch (InterruptedException e) {
51 //user cancelled
52 }catch (Exception e) {
53 e.printStackTrace();
54 MessageDialog.openError(window.getShell(),
55 "Systemtap",
56 e.getMessage());
57 }
58 }
59 return false;
60 }
61
62 protected void initialize(ExecutionEvent event) throws ExecutionException {
63 this.window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
64 shell = window.getShell();
65 setting=new SystemtapSettingDialog(
66 shell, "Systemtap"
67 );
68 }
69
70}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java
new file mode 100644
index 0000000..bb2fa2d
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java
@@ -0,0 +1,88 @@
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;
14import java.lang.reflect.InvocationTargetException;
15
16import org.eclipse.core.runtime.IProgressMonitor;
17import org.eclipse.swt.widgets.Display;
18import org.eclipse.ui.console.ConsolePlugin;
19import org.eclipse.ui.console.IConsole;
20import org.eclipse.ui.console.IConsoleManager;
21import org.eclipse.ui.console.MessageConsole;
22import org.yocto.remote.utils.ShellSession;
23
24public class SystemtapModel extends BaseModel {
25 protected static final String DEFAULT_INIT_SCRIPT = "oe-init-build-env";
26 protected static final String SYSTEMTAP_CONSOLE = "Systemtap Console";
27
28 private static final String TASK_NAME = "systemtap command";
29
30 protected MessageConsole sessionConsole;
31 private String metadata_location;
32 private String builddir_location;
33 private String remote_host;
34 private String user_id;
35 private String systemtap_script;
36 private String systemtap_args;
37
38 Display display;
39
40 public SystemtapModel(String metadata_location, String builddir_location, String remote_host, String user_id, String systemtap_script, String systemtap_args, Display display) {
41 super(null, TASK_NAME, "", "");
42 this.metadata_location = metadata_location;
43 this.builddir_location = builddir_location;
44 this.remote_host = remote_host;
45 this.user_id = user_id;
46 this.systemtap_script = systemtap_script;
47 this.systemtap_args = systemtap_args;
48 this.display = display;
49 if (sessionConsole == null) {
50 IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
51 IConsole[] existing = conMan.getConsoles();
52 for (int i = 0; i < existing.length; i++)
53 if (SYSTEMTAP_CONSOLE.equals(existing[i].getName())) {
54 sessionConsole = (MessageConsole) existing[i];
55 break;
56 }
57 if (sessionConsole == null) {
58 sessionConsole = new MessageConsole(SYSTEMTAP_CONSOLE, null);
59 conMan.addConsoles(new IConsole[] { sessionConsole });
60 }
61 }
62
63 ConsolePlugin.getDefault().getConsoleManager().showConsoleView(sessionConsole);
64 }
65
66 @Override
67 public void preProcess(IProgressMonitor monitor)
68 throws InvocationTargetException, InterruptedException {}
69
70 @Override
71 public void process(IProgressMonitor monitor)
72 throws InvocationTargetException, InterruptedException {
73 try {
74 ShellSession shell = new ShellSession(ShellSession.SHELL_TYPE_BASH,
75 new File(this.metadata_location), new File(this.builddir_location),
76 DEFAULT_INIT_SCRIPT, sessionConsole.newOutputStream());
77 boolean acceptedKey = shell.ensureKnownHostKey(user_id, remote_host);
78 if (acceptedKey) {
79 String crosstapCmd = "crosstap " + user_id + "@" + remote_host + " " + systemtap_script;
80 if (systemtap_args != null)
81 crosstapCmd = crosstapCmd + " " + systemtap_args;
82 shell.execute(crosstapCmd);
83 }
84 } catch (Exception e) {
85 throw new InvocationTargetException(e,e.getMessage());
86 }
87 }
88}
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}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Handler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Handler.java
new file mode 100644
index 0000000..9e18097
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Handler.java
@@ -0,0 +1,59 @@
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 org.eclipse.core.commands.AbstractHandler;
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
16import org.eclipse.jface.dialogs.MessageDialog;
17import org.eclipse.ui.IWorkbenchWindow;
18import org.eclipse.ui.PlatformUI;
19import org.eclipse.ui.handlers.HandlerUtil;
20import org.eclipse.ui.progress.IProgressService;
21
22import org.yocto.sdk.remotetools.Messages;
23
24public class Ust2Handler extends AbstractHandler {
25
26 public Object execute(ExecutionEvent event) throws ExecutionException {
27
28 //if(UstModel.checkAvail()!=true) {
29 // return null;
30 //}
31
32 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
33
34 Ust2SettingDialog setting=new Ust2SettingDialog(
35 window.getShell()
36 );
37
38 if(setting.open()==BaseSettingDialog.OK) {
39 IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
40 String project = setting.getProject();
41 if (project == null) {
42 MessageDialog.openError(window.getShell(), "Lttng-ust", Messages.ErrorUstProject);
43 return null;
44 }
45 Ust2Model op=new Ust2Model(setting.getHost(),setting.getTrace(), project, window);
46 try {
47 progressService.busyCursorWhile(op);
48 }catch (InterruptedException e) {
49 //user cancelled
50 }catch (Exception e) {
51 e.printStackTrace();
52 MessageDialog.openError(window.getShell(),
53 "Ust",
54 (e.getCause() != null) ? e.getCause().getMessage() : e.getMessage());
55 }
56 }
57 return null;
58 }
59}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Model.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Model.java
new file mode 100644
index 0000000..8dcc5b3
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Model.java
@@ -0,0 +1,166 @@
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.BufferedReader;
14import java.io.File;
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.InputStreamReader;
18import java.lang.reflect.InvocationTargetException;
19
20import org.eclipse.core.resources.IFolder;
21import org.eclipse.core.resources.IProject;
22import org.eclipse.core.resources.IResource;
23import org.eclipse.core.resources.IWorkspaceRoot;
24import org.eclipse.core.resources.ResourcesPlugin;
25import org.eclipse.core.runtime.IPath;
26import org.eclipse.core.runtime.IProgressMonitor;
27import org.eclipse.core.runtime.Path;
28import org.eclipse.core.runtime.SubProgressMonitor;
29import org.eclipse.rse.core.model.IHost;
30import org.eclipse.ui.IWorkbenchWindow;
31
32public class Ust2Model extends BaseModel {
33
34 private static final String REMOTE_EXEC = "/tmp/ust_tar.sh";
35 private static final String LOCAL_SCRIPT = "resources/ust_tar.sh";
36
37 private static final String LOCAL_FILE_SUFFIX = ".local.tar";
38 private static final String REMOTE_FILE_SUFFIX = ".tar";
39 private static final String LOCAL_EXEC = "lttv-gui";
40 private static final String TRACE_FOLDER_NAME = "Traces";
41 private static final String DATAFILE_PREFIX = "ustfile:";
42
43 private static final String TASK_NAME = "ust2trace command";
44
45 private String trace_loc;
46
47 private String prj_name;
48
49 private IWorkbenchWindow window;
50
51 public Ust2Model(IHost host, String trace, String project, IWorkbenchWindow window) {
52 super(host, TASK_NAME, LOCAL_SCRIPT, REMOTE_EXEC);
53 trace_loc = trace;
54
55 prj_name = project;
56 this.window = window;
57 }
58
59 @Override
60 protected void checkTerminate(InputStream is) throws IOException {
61 String temp;
62 BufferedReader in = new BufferedReader(new InputStreamReader(is));
63 while((temp = in.readLine())!=null) {
64 int idx = temp.indexOf(DATAFILE_PREFIX);
65 if(idx != -1) {
66 remoteFile = temp.substring(idx + DATAFILE_PREFIX.length());
67 break;
68 }
69 }
70 }
71
72 private void generateData(IProgressMonitor monitor) throws Exception {
73 runRemoteShellExec(monitor, trace_loc, true);
74 if(remoteFile == null)
75 throw new Exception("Ust: null remote data file");
76 if(remoteFile.endsWith(REMOTE_FILE_SUFFIX)==false)
77 throw new Exception("Wrong ust data file " + remoteFile);
78
79 localFile = new String(remoteFile.substring(0, remoteFile.length()-4) + LOCAL_FILE_SUFFIX);
80 }
81
82 private void importToProject(IProgressMonitor monitor) throws Exception {
83 ProcessBuilder pb = new ProcessBuilder("tar", "fx", localFile);
84 pb.directory(new File("/tmp"));
85 Process p=pb.start();
86 if(p.waitFor()!=0)
87 throw new Exception("extract ust data files failed");
88
89 String traceName = localFile.substring(0,localFile.length()-LOCAL_FILE_SUFFIX.length());
90
91 IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
92 IPath full_path = wsroot.getFullPath();
93 IProject project = wsroot.getProject(prj_name);
94 IFolder traceFolder = project.getFolder(TRACE_FOLDER_NAME);
95 if (!traceFolder.exists()) {
96 throw new Exception("Can't find file trace folder in selected project.");
97 }
98
99 String trace_str = traceName.substring(0, traceName.indexOf('-'));
100 traceFolder.createLink(new Path(trace_str), IResource.REPLACE, monitor);
101 for (IResource resource:traceFolder.members()) {
102 String extension = resource.getFileExtension();
103 if (extension != null)
104 continue;
105 else {
106 //traceFolder.setPersistentProperty(TmfCommonConstants.TRACETYPE, "org.eclipse.linuxtools.tmf.ui.type.ctf");
107 //resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, "org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace");
108 //traceFolder.setPersistentProperty(TmfCommonConstants.TRACEICON, "icons/obj16/garland16.png");
109 //traceFolder.touch(null);
110 }
111 }
112 }
113
114 private String[] generateViewerParam() throws Exception {
115 String viewerParam=new String(LOCAL_EXEC);
116 int i;
117
118 ProcessBuilder pb = new ProcessBuilder("tar", "fx", localFile);
119 pb.directory(new File("/tmp"));
120 Process p=pb.start();
121 if(p.waitFor()!=0)
122 throw new Exception("extract ust data files failed");
123 File f=new File(localFile.substring(0,localFile.length()-LOCAL_FILE_SUFFIX.length()));
124 File []subdir=f.listFiles();
125
126 for (i=0;i<subdir.length;i++) {
127 if(subdir[i].isDirectory()) {
128 viewerParam=viewerParam.concat(" -t " + subdir[i].getAbsolutePath());
129 }
130 }
131
132 return viewerParam.split(" ");
133 }
134
135 @Override
136 public void process(IProgressMonitor monitor)
137 throws InvocationTargetException, InterruptedException {
138 // TODO Auto-generated method stub
139
140 String datafile;
141
142 monitor.beginTask("Running ust", 100);
143 try {
144 //preparing remote trace
145
146 monitor.subTask("Preparing user space lttng data file remotely");
147 generateData(new SubProgressMonitor(monitor,30));
148
149 //download datafile to local
150 monitor.subTask("Downloading user space lttng data file");
151 getDataFile(new SubProgressMonitor(monitor,30));
152
153 //extract datafile and import to lttng project
154 importToProject(new SubProgressMonitor(monitor,30));
155
156 }catch (InterruptedException e){
157 throw e;
158 }catch (InvocationTargetException e) {
159 throw e;
160 }catch (Exception e){
161 throw new InvocationTargetException(e, e.getMessage());
162 }finally {
163 monitor.done();
164 }
165 }
166}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2SettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2SettingDialog.java
new file mode 100644
index 0000000..9fd7876
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2SettingDialog.java
@@ -0,0 +1,104 @@
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 org.yocto.sdk.remotetools.Activator;
14import org.yocto.sdk.remotetools.Messages;
15import org.eclipse.jface.dialogs.IDialogConstants;
16import org.eclipse.swt.SWT;
17import org.eclipse.swt.events.ModifyEvent;
18import org.eclipse.swt.events.ModifyListener;
19
20import org.eclipse.swt.layout.GridData;
21import org.eclipse.swt.layout.GridLayout;
22import org.eclipse.swt.widgets.Button;
23
24import org.eclipse.swt.widgets.Composite;
25
26import org.eclipse.swt.widgets.Label;
27import org.eclipse.swt.widgets.Shell;
28import org.eclipse.swt.widgets.Text;
29
30
31public class Ust2SettingDialog extends UstSettingDialogBase {
32
33 static protected String TITLE="Lttng2.0 User Tracing Import";
34
35 protected String trace;
36 protected Text traceText;
37
38 protected Ust2SettingDialog(Shell parentShell, String title, String conn) {
39 super(parentShell,title,conn);
40 }
41
42 public Ust2SettingDialog(Shell parentShell) {
43 this(parentShell,
44 TITLE,
45 Activator.getDefault().getDialogSettings().get(IBaseConstants.CONNECTION_NAME_UST)
46 );
47 }
48
49 public String getTrace() {
50 return trace;
51 }
52
53 @Override
54 protected void okPressed() {
55
56 trace=traceText.getText();
57
58 super.okPressed();
59 }
60
61 protected void createArgument(Composite parent)
62 {
63 Composite projComp = new Composite(parent, SWT.NONE);
64 GridLayout projLayout = new GridLayout();
65 projLayout.numColumns = 4;
66 projLayout.marginHeight = 0;
67 projLayout.marginWidth = 0;
68 projComp.setLayout(projLayout);
69 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
70 projComp.setLayoutData(gd);
71
72 Label label = new Label(projComp, SWT.NONE);
73 label.setText(Messages.Usttrace_Trace_Loc_Text);
74 gd = new GridData();
75 gd.horizontalSpan = 4;
76 label.setLayoutData(gd);
77
78 traceText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
79 traceText.addModifyListener(new ModifyListener() {
80 public void modifyText(ModifyEvent e) {
81 updateOkButton();
82 }
83 });
84 if(trace!=null)
85 traceText.setText(trace);
86 gd = new GridData(GridData.FILL_HORIZONTAL);
87 gd.horizontalSpan = 1;
88 traceText.setLayoutData(gd);
89 }
90
91 @Override
92 protected boolean updateOkButton() {
93 boolean ret=super.updateOkButton();
94 if(ret==true) {
95 if(traceText.getText().isEmpty() || !traceText.getText().endsWith("/ust")) {
96 Button button=getButton(IDialogConstants.OK_ID);
97 if(button!=null)
98 button.setEnabled(false);
99 ret=false;
100 }
101 }
102 return ret;
103 }
104}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/UstSettingDialogBase.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/UstSettingDialogBase.java
new file mode 100644
index 0000000..70b0816
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/UstSettingDialogBase.java
@@ -0,0 +1,170 @@
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 org.yocto.sdk.remotetools.Activator;
14import org.yocto.sdk.remotetools.Messages;
15import org.yocto.sdk.remotetools.SWTFactory;
16import org.eclipse.jface.dialogs.IDialogSettings;
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.events.ModifyEvent;
19import org.eclipse.swt.events.ModifyListener;
20import org.eclipse.swt.layout.GridData;
21import org.eclipse.swt.layout.GridLayout;
22import org.eclipse.swt.widgets.Combo;
23import org.eclipse.swt.widgets.Composite;
24import org.eclipse.swt.widgets.Control;
25import org.eclipse.swt.widgets.Label;
26import org.eclipse.swt.widgets.Shell;
27import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
28import org.eclipse.core.resources.IWorkspaceRoot;
29import org.eclipse.core.resources.ResourcesPlugin;
30import org.eclipse.core.resources.IProject;
31
32
33public class UstSettingDialogBase extends BaseSettingDialog {
34 protected Label projectLabel;
35 protected Combo projectCombo;
36 protected String curProject = null;
37
38 protected UstSettingDialogBase(Shell parentShell, String title, String conn) {
39 super(parentShell,title,conn);
40 }
41
42 public String getProject() {
43 return curProject;
44 }
45
46 @Override
47 protected void okPressed() {
48 IDialogSettings settings = Activator.getDefault().getDialogSettings();
49 // store the value of the generate sections checkbox
50 if(getCurrentConnection()==null) {
51 settings.put(IBaseConstants.CONNECTION_NAME_UST,
52 (String)null);
53 }else {
54 settings.put(IBaseConstants.CONNECTION_NAME_UST,
55 getCurrentConnection().getAliasName());
56 }
57 super.okPressed();
58 }
59
60 @Override
61 protected Control createDialogArea(Composite parent) {
62 Composite comp=(Composite)super.createDialogArea(parent);
63 GridLayout topLayout = new GridLayout();
64 comp.setLayout(topLayout);
65
66 /*argument*/
67 SWTFactory.createVerticalSpacer(comp, 1);
68 createImportProjectGroup(comp);
69 createArgument(comp);
70
71 updateOkButton();
72 return comp;
73 }
74
75 protected void createImportProjectGroup(Composite parent) {
76 Composite projComp = new Composite(parent, SWT.NONE);
77 GridLayout projLayout = new GridLayout();
78 projLayout.numColumns = 6;
79 projLayout.marginHeight = 0;
80 projLayout.marginWidth = 0;
81 projComp.setLayout(projLayout);
82 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
83 projComp.setLayoutData(gd);
84
85 projectLabel = new Label(projComp, SWT.NONE);
86 projectLabel.setText(Messages.Import_to_Project);
87 gd = new GridData();
88 gd.horizontalSpan = 1;
89 projectLabel.setLayoutData(gd);
90
91 projectCombo = new Combo(projComp, SWT.DROP_DOWN | SWT.READ_ONLY);
92 gd = new GridData(GridData.FILL_HORIZONTAL);
93 gd.horizontalSpan = 4;
94 projectCombo.setLayoutData(gd);
95 projectCombo.addModifyListener(new ModifyListener() {
96
97 public void modifyText(ModifyEvent e) {
98 updateCurProject();
99 }
100 });
101
102 updateProjectPulldown();
103 }
104
105 protected void updateCurProject() {
106 IProject currentProjectSelected = getCurrentProject();
107
108 if (currentProjectSelected != null)
109 curProject = currentProjectSelected.getName();
110
111 updateOkButton();
112 }
113
114 protected IProject getCurrentProject() {
115 if (projectCombo.getItemCount() == 0)
116 return null;
117 int currentSelection = projectCombo.getSelectionIndex();
118 String importProject = currentSelection >= 0 ? projectCombo
119 .getItem(currentSelection) : null;
120 IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
121 IProject project = wsroot.getProject(importProject);
122 return project;
123 }
124
125 protected void updateProjectPulldown() {
126 int index=-1;
127
128 projectCombo.removeAll();
129 IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
130 IProject[] projects = wsroot.getProjects();
131
132 for (int i = 0; i < projects.length; ++i) {
133 try {
134 if (projects[i].isOpen() && projects[i].hasNature(TmfProjectNature.ID)) {
135 String projName = projects[i].getName();
136 projectCombo.add(projName);
137 if (curProject != null)
138 if (projName.matches(curProject))
139 index = i;
140 }
141 } catch (Exception e) {
142 // TODO Auto-generated catch block
143 e.printStackTrace();
144 }
145 }
146
147 if(index>=0) {
148 projectCombo.select(index);
149 }else if (projectCombo.getItemCount()> 0) {
150 projectCombo.select(projectCombo.getItemCount() - 1);
151 }
152
153 //TODO
154 //connectionCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT,true);
155 projectCombo.pack(true);
156 projectCombo.layout();
157 projectCombo.getParent().layout();
158
159 updateCurProject();
160 }
161 protected void createArgument(Composite parent)
162 {
163 }
164
165 @Override
166 protected boolean updateOkButton() {
167 boolean ret=super.updateOkButton();
168 return ret;
169 }
170}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/YoctoBspHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/YoctoBspHandler.java
new file mode 100644
index 0000000..c97afb6
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/YoctoBspHandler.java
@@ -0,0 +1,38 @@
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 org.eclipse.core.commands.AbstractHandler;
14import org.eclipse.core.commands.ExecutionEvent;
15import org.eclipse.core.commands.ExecutionException;
16import org.eclipse.jface.wizard.WizardDialog;
17import org.eclipse.ui.IWorkbenchWindow;
18import org.eclipse.ui.handlers.HandlerUtil;
19
20import org.yocto.sdk.remotetools.wizards.bsp.YoctoBSPWizard;
21
22public class YoctoBspHandler extends AbstractHandler {
23
24 public Object execute(ExecutionEvent event) throws ExecutionException {
25
26 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
27 // Instantiates and initializes the wizard
28 YoctoBSPWizard bspWizard = new YoctoBSPWizard();
29 //bspWizard.init(window.getWorkbench(), (IStructuredSelection)selection);
30 // Instantiates the wizard container with the wizard and opens it
31 WizardDialog dialog = new WizardDialog(window.getShell(), bspWizard);
32 //dialog.create();
33 dialog.open();
34 //YoctoBspDialog setting=new YoctoBspDialog(window.getShell());
35 //setting.open();
36 return null;
37 }
38}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/messages.properties b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/messages.properties
new file mode 100644
index 0000000..2d6d8af
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/messages.properties
@@ -0,0 +1,49 @@
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################################################################################
11
12# NLS_MESSAGEFORMAT_VAR
13# NLS_ENCODING=UTF-8
14
15ErrorNoSubsystem=No subsystem found.
16ErrorConnectSubsystem=Could not connect to the remote system.
17ErrorNoHost=No remote host found.
18ErrorNoRemoteService=No remote TCF service found.
19ErrorOprofileViewer=Local application "oprofile-viewer" is NOT installed.\nPlease goto http://git.yoctoproject.org/cgit/cgit.cgi/oprofileui to install OprofileUI.
20ErrorOprofile=Oprofile is NOT installed on the local host.\n Please goto http://oprofile.sourceforge.net to install Oprofile.
21ErrorLttvGui=Local application "lttv-gui" is NOT installed.\nPlease goto http://lttng.org to install LTTng Viewer.
22ErrorUstProject=No Lttng Project selected. If the list is empty, please create a Lttng project under File->New!
23
24InfoDownload=Downloading
25InfoUpload=Uploading
26
27BaseSettingDialog_Connection=Connection
28BaseSettingDialog_New=New
29BaseSettingDialog_Properties=Properties
30Usttrace_Argument_Text=Argument
31Usttrace_Application_Text=Application
32Usttrace_Trace_Loc_Text=Ust directory path
33Powertop_Time_Text=Time to gather data(sec)
34Powertop_ShowPid_Text=show pids in wakeups list
35TerminalViewer_text=This view is dedicated to Yocto Remote tools. Please use the "Yocto Remote Tools" menu to open the view.
36//Systemtap_KO_Text=Kernel Module:
37Metadata_Location=Metadata Location:
38Builddir_Location=Build dir Location:
39User_ID=User ID:
40Remote_Host=Remote Host:
41Systemtap_Script=Systemtap Script:
42Systemtap_Args=Systemtap Args:
43Import_to_Project=Import to project:
44
45LocalJob_Title=Launching local application
46ErrorLocalJob=Failed in launching local application
47
48RemoteShellExec_1=Executing {0} {1}
49RemoteShellExec_2=Could not create the hostShellProcess.\n \ No newline at end of file
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/BaseFileView.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/BaseFileView.java
new file mode 100644
index 0000000..a5801c7
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/BaseFileView.java
@@ -0,0 +1,140 @@
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.views;
12
13
14import java.io.BufferedReader;
15import java.io.FileReader;
16import java.util.ArrayList;
17
18import org.eclipse.swt.widgets.Composite;
19import org.eclipse.ui.part.*;
20import org.eclipse.jface.viewers.*;
21import org.eclipse.swt.graphics.Image;
22import org.eclipse.ui.*;
23import org.eclipse.swt.SWT;
24
25
26/**
27 * This sample class demonstrates how to plug-in a new
28 * workbench view. The view shows data obtained from the
29 * model. The sample creates a dummy model on the fly,
30 * but a real implementation would connect to the model
31 * available either in this or another plug-in (e.g. the workspace).
32 * The view is connected to the model using a content provider.
33 * <p>
34 * The view uses a label provider to define how model
35 * objects should be presented in the view. Each
36 * view can present the same model objects using
37 * different labels and icons, if needed. Alternatively,
38 * a single label provider can be shared between views
39 * in order to ensure that objects of the same type are
40 * presented in the same way everywhere.
41 * <p>
42 */
43
44public class BaseFileView extends ViewPart {
45
46 /**
47 * The ID of the view as specified by the extension.
48 */
49 public static final String ID = "org.yocto.sdk.remotetools.views.BaseFileView";
50
51 private TableViewer viewer;
52
53 private String filename;
54
55 /*
56 * The content provider class is responsible for
57 * providing objects to the view. It can wrap
58 * existing objects in adapters or simply return
59 * objects as-is. These objects may be sensitive
60 * to the current input of the view, or ignore
61 * it and always show the same content
62 * (like Task List, for example).
63 */
64
65 class ViewContentProvider implements IStructuredContentProvider {
66 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
67 if(newInput instanceof String)
68 filename=(String)newInput;
69 }
70 public void dispose() {
71 }
72 public Object[] getElements(Object parent) {
73 ArrayList <String> elements=new ArrayList <String>();
74 BufferedReader in;
75 String line;
76 try {
77 in=new BufferedReader(new FileReader(filename));
78 }catch (Exception e) {
79 return new String [] {"Invalid file " + filename};
80 }
81
82 try {
83 do {
84 line=in.readLine();
85 if(line!=null)
86 elements.add(line);
87 }while(line!=null);
88 }catch (Exception e) {
89 e.printStackTrace();
90 }
91 return (String[]) elements.toArray(new String[elements.size()]);
92 }
93 }
94 class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
95 public String getColumnText(Object obj, int index) {
96 return getText(obj);
97 }
98 public Image getColumnImage(Object obj, int index) {
99 //return getImage(obj);
100 return null;
101 }
102 public Image getImage(Object obj) {
103 return PlatformUI.getWorkbench().
104 getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
105 }
106 }
107
108 /**
109 * The constructor.
110 */
111 public BaseFileView() {
112 }
113
114 public BaseFileView(String file) {
115 this();
116 this.filename=file;
117 }
118
119 /**
120 * This is a callback that will allow us
121 * to create the viewer and initialize it.
122 */
123 public void createPartControl(Composite parent) {
124 viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
125 viewer.setContentProvider(new ViewContentProvider());
126 viewer.setLabelProvider(new ViewLabelProvider());
127 viewer.setInput(filename);
128 }
129
130 public void setInput(String filename) {
131 viewer.setInput(filename);
132 }
133
134 /**
135 * Passing the focus request to the viewer's control.
136 */
137 public void setFocus() {
138 viewer.getControl().setFocus();
139 }
140} \ No newline at end of file
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewTab.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewTab.java
new file mode 100644
index 0000000..bbb2d02
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewTab.java
@@ -0,0 +1,457 @@
1/*******************************************************************************
2 * Copyright (c) 2002, 2009 IBM Corporation and others.
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 * Initial Contributors:
9 * The following IBM employees contributed to the Remote System Explorer
10 * component that contains this file: David McKnight, Kushal Munir,
11 * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
12 * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
13 *
14 * Contributors:
15 * David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
16 * Yu-Fen Kuo (MontaVista) - Adapted from CommandsViewWorkbook
17 * Anna Dushistova (MontaVista) - Adapted from CommandsViewWorkbook
18 * Yu-Fen Kuo (MontaVista) - [227572] RSE Terminal doesn't reset the "connected" state when the shell exits
19 * Martin Oberhuber (Wind River) - [227571] RSE Terminal should honor Encoding set on the IHost
20 * Michael Scharf (Wind River) - [236203] [rseterminal] Potentially UI blocking code in TerminalViewTab.createTabItem
21 * Anna Dushistova (MontaVista) - [244437] [rseterminal] Possible race condition when multiple Terminals are launched after each other
22 * Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package
23 * Anna Dushistova (MontaVista) - [267609] [rseterminal] The first "Launch Terminal" command creates no terminal tab
24 ********************************************************************************/
25package org.yocto.sdk.remotetools.views;
26
27import java.io.UnsupportedEncodingException;
28
29import org.eclipse.core.runtime.IAdaptable;
30import org.eclipse.jface.action.IMenuListener;
31import org.eclipse.jface.action.IMenuManager;
32import org.eclipse.jface.action.MenuManager;
33import org.eclipse.jface.action.Separator;
34import org.eclipse.jface.resource.FontRegistry;
35import org.eclipse.jface.util.IPropertyChangeListener;
36import org.eclipse.jface.util.PropertyChangeEvent;
37import org.eclipse.rse.core.model.IHost;
38import org.eclipse.swt.SWT;
39import org.eclipse.swt.custom.CTabFolder;
40import org.eclipse.swt.custom.CTabItem;
41import org.eclipse.swt.events.DisposeEvent;
42import org.eclipse.swt.events.DisposeListener;
43import org.eclipse.swt.events.MenuEvent;
44import org.eclipse.swt.events.MenuListener;
45import org.eclipse.swt.graphics.Font;
46import org.eclipse.swt.layout.FillLayout;
47import org.eclipse.swt.layout.GridData;
48import org.eclipse.swt.widgets.Composite;
49import org.eclipse.swt.widgets.Control;
50import org.eclipse.swt.widgets.Display;
51import org.eclipse.swt.widgets.Menu;
52import org.eclipse.tm.internal.terminal.control.ITerminalListener;
53import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
54import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
55import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll;
56import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy;
57import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCut;
58import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste;
59import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll;
60import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
61import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
62import org.eclipse.ui.PlatformUI;
63import org.eclipse.ui.themes.IThemeManager;
64
65/**
66 * This is the desktop view wrapper of the System View viewer.
67 */
68public class TerminalViewTab extends Composite {
69
70 public static String DATA_KEY_CONTROL = "$_control_$"; //$NON-NLS-1$
71
72 private final CTabFolder tabFolder;
73
74 private IPropertyChangeListener propertyChangeListener;
75
76 private Menu menu;
77
78 private boolean fMenuAboutToShow;
79
80 private TerminalActionCopy fActionEditCopy;
81
82 private TerminalActionCut fActionEditCut;
83
84 private TerminalActionPaste fActionEditPaste;
85
86 private TerminalActionClearAll fActionEditClearAll;
87
88 private TerminalActionSelectAll fActionEditSelectAll;
89
90 protected class TerminalContextMenuHandler implements MenuListener,
91 IMenuListener {
92 public void menuHidden(MenuEvent event) {
93 fMenuAboutToShow = false;
94 fActionEditCopy.updateAction(fMenuAboutToShow);
95 }
96
97 public void menuShown(MenuEvent e) {
98
99 }
100
101 public void menuAboutToShow(IMenuManager menuMgr) {
102 fMenuAboutToShow = true;
103 fActionEditCopy.updateAction(fMenuAboutToShow);
104 fActionEditCut.updateAction(fMenuAboutToShow);
105 fActionEditSelectAll.updateAction(fMenuAboutToShow);
106 fActionEditPaste.updateAction(fMenuAboutToShow);
107 fActionEditClearAll.updateAction(fMenuAboutToShow);
108 }
109 }
110
111 public TerminalViewTab(final Composite parent, TerminalViewer viewer) {
112 super(parent, SWT.NONE);
113 tabFolder = new CTabFolder(this, SWT.NONE);
114 tabFolder.setLayout(new FillLayout());
115 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
116 setLayout(new FillLayout());
117 tabFolder.setBackground(parent.getBackground());
118 tabFolder.setSimple(false);
119 tabFolder.setUnselectedImageVisible(false);
120 tabFolder.setUnselectedCloseVisible(false);
121
122 tabFolder.setMinimizeVisible(false);
123 tabFolder.setMaximizeVisible(false);
124//TODO setupActions();
125 }
126
127 public void dispose() {
128 if (propertyChangeListener != null) {
129 IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager();
130 mgr.removePropertyChangeListener(propertyChangeListener);
131 propertyChangeListener = null;
132 }
133 if (!tabFolder.isDisposed()) {
134 tabFolder.dispose();
135 }
136 super.dispose();
137 }
138
139 public CTabFolder getFolder() {
140 return tabFolder;
141 }
142
143 public void remove(Object root) {
144
145 }
146
147 public int getItemCount(){
148 return tabFolder.getItemCount();
149 }
150
151 public CTabItem getSelectedTab() {
152 if (tabFolder.getItemCount() > 0) {
153 int index = tabFolder.getSelectionIndex();
154 CTabItem item = tabFolder.getItem(index);
155 return item;
156 }
157
158 return null;
159 }
160
161 public void showCurrentPage() {
162 tabFolder.setFocus();
163 }
164
165 public void showPageFor(Object root) {
166 for (int i = 0; i < tabFolder.getItemCount(); i++) {
167 CTabItem item = tabFolder.getItem(i);
168 if (item.getData() == root) {
169 tabFolder.setSelection(item);
170 }
171
172 }
173 }
174
175 public void showPageFor(String tabName) {
176 for (int i = 0; i < tabFolder.getItemCount(); i++) {
177 CTabItem item = tabFolder.getItem(i);
178 if (item.getText().equals(tabName)) {
179 tabFolder.setSelection(item);
180 return;
181 }
182
183 }
184 }
185
186 public void disposePageFor(String tabName) {
187 for (int i = 0; i < tabFolder.getItemCount(); i++) {
188 CTabItem item = tabFolder.getItem(i);
189 if (item.getText().equals(tabName)) {
190 item.dispose();
191 return;
192 }
193
194 }
195 }
196
197 public void propertyChange(PropertyChangeEvent e) {
198 // for now always update
199 if (tabFolder!=null) {
200 CTabItem[] items = tabFolder.getItems();
201 for (int i=0; i<items.length; i++) {
202 Object control = items[i].getData(DATA_KEY_CONTROL);
203 if (control instanceof ITerminalViewControl) {
204 updateTheme((ITerminalViewControl) control);
205 }
206 }
207 }
208 }
209
210 public void updateTheme(final ITerminalViewControl control) {
211 if (control != null) {
212 IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager();
213 Font font;
214 FontRegistry fr = mgr.getCurrentTheme().getFontRegistry();
215 if (fr.hasValueFor("terminal.views.view.font.definition")) { //$NON-NLS-1$
216 //Terminal View font if available
217 font = fr.get("terminal.views.view.font.definition"); //$NON-NLS-1$
218 } else if (fr.hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$
219 //fallback: "Remote Shell Font"
220 font = fr.get("REMOTE_COMMANDS_VIEW_FONT"); //$NON-NLS-1$
221 } else {
222 //fallback: "Basic Text Font"
223 font = fr.get("org.eclipse.jface.textfont"); //$NON-NLS-1$
224 }
225 control.setFont(font);
226 if (propertyChangeListener == null) {
227 final TerminalViewTab myself = this;
228 propertyChangeListener = new IPropertyChangeListener() {
229 public void propertyChange(PropertyChangeEvent event) {
230 myself.propertyChange(event);
231 }
232 };
233 mgr.addPropertyChangeListener(propertyChangeListener);
234 }
235 }
236 }
237/* TODO
238 public CTabItem createTabItem(IAdaptable root,
239 final String initialWorkingDirCmd,final String initialCmd) {
240 final CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
241 setTabTitle(root, item);
242
243 item.setData(root);
244 Composite c = new Composite(tabFolder, SWT.NONE);
245 c.setLayout(new FillLayout());
246
247 tabFolder.getParent().layout(true);
248 if (root instanceof IHost) {
249 final IHost host = (IHost) root;
250
251 ITerminalConnector connector = new TCFTerminalConnector(host);
252 ITerminalViewControl terminalControl = TerminalViewControlFactory
253 .makeControl(new ITerminalListener()
254 {
255
256 public void setState(final TerminalState state) {
257 if (state == TerminalState.CLOSED
258 || state == TerminalState.CONNECTED) {
259 Display.getDefault().asyncExec(new Runnable() {
260 public void run() {
261 if (!item.isDisposed()) {
262 final ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper
263 .getTerminalSubSystem(host);
264
265 if (state == TerminalState.CONNECTED)
266 TerminalServiceHelper
267 .updateTerminalShellForTerminalElement(item);
268
269 setTabImage(host, item);
270 ISystemRegistry registry = RSECorePlugin
271 .getTheSystemRegistry();
272 registry
273 .fireEvent(new SystemResourceChangeEvent(
274 terminalServiceSubSystem,
275 ISystemResourceChangeEvents.EVENT_REFRESH,
276 terminalServiceSubSystem));
277 }
278 if (state == TerminalState.CONNECTED) {
279
280 if (initialWorkingDirCmd != null) {
281 Object data = item
282 .getData(DATA_KEY_CONTROL);
283 if (data instanceof ITerminalViewControl)
284 ((ITerminalViewControl) data)
285 .pasteString(initialWorkingDirCmd);
286 }
287 }
288 }
289 });
290 }
291
292 }
293
294 public void setTerminalTitle(String title) {
295
296 }
297 },
298 c, new ITerminalConnector[] { connector });
299 // Specify Encoding for Terminal
300 try {
301 terminalControl.setEncoding(host.getDefaultEncoding(true));
302 } catch (UnsupportedEncodingException e) {
303 // ignore and allow fallback to default encoding
304 }
305 terminalControl.setConnector(connector);
306 item.setData(DATA_KEY_CONTROL, terminalControl);
307 updateTheme(terminalControl);
308 terminalControl.connectTerminal();
309 }
310 item.setControl(c);
311 tabFolder.setSelection(item);
312 item.addDisposeListener(new DisposeListener() {
313
314 public void widgetDisposed(DisposeEvent e) {
315 Object source = e.getSource();
316 if (source instanceof CTabItem) {
317 CTabItem currentItem = (CTabItem) source;
318 Object data = currentItem.getData(DATA_KEY_CONTROL);
319 if (data instanceof ITerminalViewControl) {
320 ((ITerminalViewControl) data).disposeTerminal();
321 }
322 data = currentItem.getData();
323 if (data instanceof IHost) {
324 TerminalServiceHelper.removeTerminalElementFromHost(
325 currentItem, (IHost) data);
326 }
327 }
328
329 }
330
331 });
332
333 setupContextMenus();
334 return item;
335
336 }
337
338 protected void setupActions() {
339 fActionEditCopy = new TerminalActionCopy() {
340 protected ITerminalViewControl getTarget() {
341 return getCurrentTerminalViewControl();
342 }
343 };
344 fActionEditCut = new TerminalActionCut() {
345 protected ITerminalViewControl getTarget() {
346 return getCurrentTerminalViewControl();
347 }
348 };
349 fActionEditPaste = new TerminalActionPaste() {
350 protected ITerminalViewControl getTarget() {
351 return getCurrentTerminalViewControl();
352 }
353 };
354 fActionEditClearAll = new TerminalActionClearAll() {
355 protected ITerminalViewControl getTarget() {
356 return getCurrentTerminalViewControl();
357 }
358 };
359 fActionEditSelectAll = new TerminalActionSelectAll() {
360 protected ITerminalViewControl getTarget() {
361 return getCurrentTerminalViewControl();
362 }
363 };
364 }
365
366 protected void setupContextMenus() {
367 ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
368 if (terminalViewControl == null)
369 return;
370
371 if (menu == null) {
372 MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
373 menu = menuMgr.createContextMenu(tabFolder);
374 loadContextMenus(menuMgr);
375 TerminalContextMenuHandler contextMenuHandler = new TerminalContextMenuHandler();
376 menuMgr.addMenuListener(contextMenuHandler);
377 menu.addMenuListener(contextMenuHandler);
378 }
379 Control ctlText = terminalViewControl.getControl();
380 ctlText.setMenu(menu);
381 }
382
383 protected void loadContextMenus(IMenuManager menuMgr) {
384 menuMgr.add(fActionEditCopy);
385 menuMgr.add(fActionEditPaste);
386 menuMgr.add(new Separator());
387 menuMgr.add(fActionEditClearAll);
388 menuMgr.add(fActionEditSelectAll);
389 menuMgr.add(new Separator());
390
391 // Other plug-ins can contribute there actions here
392 menuMgr.add(new Separator("Additions")); //$NON-NLS-1$
393 }
394
395 private void setTabTitle(IAdaptable root, CTabItem titem) {
396 ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
397 .getAdapter(ISystemViewElementAdapter.class);
398 if (va != null) {
399 updateWithUniqueTitle(va.getName(root), titem);
400 setTabImage(root, titem);
401 }
402 }
403
404 private void setTabImage(IAdaptable root, CTabItem titem) {
405 ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
406 .getAdapter(ISystemViewElementAdapter.class);
407 if (va != null) {
408 if (root instanceof IHost) {
409 ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper
410 .getTerminalSubSystem((IHost) root);
411 TerminalElement element = terminalServiceSubSystem
412 .getChild(titem.getText());
413 if (element != null) {
414 va = (ISystemViewElementAdapter) element
415 .getAdapter(ISystemViewElementAdapter.class);
416 titem
417 .setImage(va.getImageDescriptor(element)
418 .createImage());
419 return;
420 }
421 }
422
423 titem.setImage(va.getImageDescriptor(root).createImage());
424 }
425 }
426
427 private void updateWithUniqueTitle(String title, CTabItem currentItem) {
428 CTabItem[] items = tabFolder.getItems();
429 int increment = 1;
430 String temp = title;
431 for (int i = 0; i < items.length; i++) {
432 if (items[i] != currentItem) {
433 String name = items[i].getText();
434 if (name != null) {
435 if (name.equals(temp)) {
436 temp = title + " " + increment++; //$NON-NLS-1$
437 }
438 }
439
440 }
441 }
442 currentItem.setText(temp);
443 }
444
445 private ITerminalViewControl getCurrentTerminalViewControl() {
446 if (tabFolder != null && !tabFolder.isDisposed()) {
447 CTabItem item = tabFolder.getSelection();
448 if (item != null && !item.isDisposed()) {
449 Object data = item.getData(DATA_KEY_CONTROL);
450 if (data instanceof ITerminalViewControl)
451 return ((ITerminalViewControl) data);
452 }
453 }
454 return null;
455 }
456*/
457}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewer.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewer.java
new file mode 100644
index 0000000..65a562b
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/views/TerminalViewer.java
@@ -0,0 +1,139 @@
1/********************************************************************************
2 * Copyright (c) 2002, 2009 IBM Corporation and others. All rights reserved.
3 * This program and the accompanying materials are made available under the terms
4 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
5 * available at http://www.eclipse.org/legal/epl-v10.html
6 *
7 * Initial Contributors:
8 * The following IBM employees contributed to the Remote System Explorer
9 * component that contains this file: David McKnight, Kushal Munir,
10 * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
11 * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
12 *
13 * Contributors:
14 * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
15 * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
16 * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
17 * Martin Oberhuber (Wind River) - [174945] Remove obsolete icons from rse.shells.ui
18 * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
19 * David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
20 * Kevin Doyle (IBM) - [198534] Shell Menu Enablement Issue's
21 * Radoslav Gerganov(ProSyst) - [181563] Fix hardcoded Ctrl+Space for remote shell content assist
22 * Yu-Fen Kuo (MontaVista) - Adapted from SystemCommandsViewPart
23 * Anna Dushistova (MontaVista) - Adapted from SystemCommandsViewPart
24 * Yu-Fen Kuo (MontaVista) - [227572] RSE Terminal doesn't reset the "connected" state when the shell exits
25 * Anna Dushistova (MontaVista) - [228577] [rseterminal] Clean up RSE Terminal impl
26 * Anna Dushistova (MontaVista) - [238257] Request a help text when no tab is open in "Remote Shell", "Remote Monitor" and "Terminals" views
27 * Anna Dushistova (MontaVista) - [235097] [rseterminal] Cannot activate RSE Terminals View with the keyboard
28 * Anna Dushistova (MontaVista) - [267609] [rseterminal] The first "Launch Terminal" command creates no terminal tab
29 *********************************************************************************/
30package org.yocto.sdk.remotetools.views;
31
32import org.yocto.sdk.remotetools.Messages;
33
34import org.eclipse.jface.action.IMenuManager;
35import org.eclipse.jface.viewers.ISelection;
36import org.eclipse.jface.viewers.ISelectionChangedListener;
37import org.eclipse.jface.viewers.SelectionChangedEvent;
38import org.eclipse.swt.SWT;
39import org.eclipse.swt.events.SelectionEvent;
40import org.eclipse.swt.events.SelectionListener;
41import org.eclipse.swt.widgets.Composite;
42import org.eclipse.swt.widgets.Label;
43import org.eclipse.ui.ISelectionListener;
44import org.eclipse.ui.ISelectionService;
45import org.eclipse.ui.IWorkbenchPart;
46import org.eclipse.ui.part.PageBook;
47import org.eclipse.ui.part.ViewPart;
48
49public class TerminalViewer extends ViewPart implements ISelectionListener,
50 SelectionListener, ISelectionChangedListener/*,
51 ISystemResourceChangeListener,*/{
52
53 private TerminalViewTab tabFolder;
54
55 private PageBook pagebook;
56
57 private Label noTabShownLabel;
58
59 public static String VIEW_ID = "org.eclipse.rse.terminals.ui.view.TerminalView"; //$NON-NLS-1$
60
61 public void createPartControl(Composite parent) {
62 pagebook = new PageBook(parent, SWT.NONE);
63
64 tabFolder = new TerminalViewTab(pagebook, this);
65 tabFolder.getFolder().addSelectionListener(this);
66
67 // Page 2: Nothing selected
68 noTabShownLabel = new Label(pagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
69 noTabShownLabel.setText(Messages.TerminalViewer_text);
70 showEmptyPage();
71
72
73 ISelectionService selectionService = getSite().getWorkbenchWindow()
74 .getSelectionService();
75 selectionService.addSelectionListener(this);
76/*
77 ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
78
79 registry.addSystemResourceChangeListener(this);
80*/
81 }
82
83 public void setFocus() {
84 tabFolder.setFocus();
85 }
86
87 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
88 // TODO Auto-generated method stub
89
90 }
91
92 public void widgetDefaultSelected(SelectionEvent e) {
93 // TODO Auto-generated method stub
94
95 }
96
97 public void widgetSelected(SelectionEvent e) {
98 // TODO Auto-generated method stub
99
100 }
101
102 public void selectionChanged(SelectionChangedEvent event) {
103 // TODO Auto-generated method stub
104
105 }
106/*
107 public void systemResourceChanged(ISystemResourceChangeEvent event) {
108 if (event.getType() == ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_REMOVED) {
109 Object source = event.getSource();
110 if (source instanceof TerminalElement) {
111 tabFolder.disposePageFor(((TerminalElement) source).getName());
112 }
113 }else if(event.getType() == ISystemResourceChangeEvents.EVENT_REFRESH){
114 if(tabFolder.getItemCount() == 0)
115 showEmptyPage();
116 else
117 showTabsPage();
118 }
119 }
120*/
121
122 public void menuAboutToShow(IMenuManager manager) {
123 // TODO Auto-generated method stub
124
125 }
126
127 public TerminalViewTab getTabFolder() {
128 return tabFolder;
129 }
130
131 private void showEmptyPage() {
132 pagebook.showPage(noTabShownLabel);
133 }
134
135 private void showTabsPage(){
136 pagebook.showPage(tabFolder);
137 }
138
139} \ No newline at end of file
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPAction.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPAction.java
new file mode 100644
index 0000000..171f181
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPAction.java
@@ -0,0 +1,32 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * Stores a list of items from the output of a background thread and the error message if something went wrong
5 * @author ioana.grigoropol
6 *
7 */
8public class BSPAction {
9 private String[] items;
10 private String message;
11
12 BSPAction(String[] items, String message){
13 this.setItems(items);
14 this.setMessage(message);
15 }
16
17 public String[] getItems() {
18 return items;
19 }
20
21 public void setItems(String[] items) {
22 this.items = items;
23 }
24
25 public String getMessage() {
26 return message;
27 }
28
29 public void setMessage(String message) {
30 this.message = message;
31 }
32} \ No newline at end of file
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPProgressDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPProgressDialog.java
new file mode 100644
index 0000000..8d5864c
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPProgressDialog.java
@@ -0,0 +1,47 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3import org.eclipse.core.runtime.IProgressMonitor;
4import org.eclipse.jface.dialogs.ProgressMonitorDialog;
5import org.eclipse.jface.operation.IRunnableWithProgress;
6import org.eclipse.swt.widgets.Shell;
7
8/**
9 * Creates a progress monitor dialog that will run in the background a BSPThread and display a custom message
10 * @author ioana.grigoropol
11 *
12 */
13public class BSPProgressDialog extends ProgressMonitorDialog{
14 String displayMessage;
15 BSPThread getterThread;
16 Shell shell;
17
18
19 public BSPProgressDialog(Shell parent, BSPThread getterThread, String displayMessage) {
20 super(parent);
21 this.shell = parent;
22 this.getterThread = getterThread;
23 this.displayMessage = displayMessage;
24 }
25
26 public void run(boolean showProgressDialog){
27 try {
28 if (showProgressDialog)
29 super.run(true, true, new IRunnableWithProgress(){
30 @Override
31 public void run(IProgressMonitor monitor) {
32 monitor.beginTask(displayMessage + " ...", 100);
33 getterThread.run();
34 monitor.done();
35 }
36 });
37 else
38 getterThread.run();
39 } catch (Exception e) {
40 getterThread.getBspAction().setMessage(e.getMessage());
41 }
42 }
43
44 public BSPAction getBspAction() {
45 return getterThread.getBspAction();
46 }
47}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPThread.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPThread.java
new file mode 100644
index 0000000..f6b19ac
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPThread.java
@@ -0,0 +1,92 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3import java.io.BufferedReader;
4import java.io.InputStreamReader;
5import java.util.ArrayList;
6
7/**
8 * Receives a command to be run on a separate thread in the background
9 * It contains an BSPAction object that will collect the output & error
10 * Output lines are processed and collected into the items of BSPAction
11 * @author ioana.grigoropol
12 *
13 */
14public abstract class BSPThread implements Runnable {
15 public static final String SUCCESS = "success";
16 public static final String ERROR = "error";
17
18 private BSPAction bspAction;
19 private String command;
20
21 /**
22 * Receives the command to be run in the background
23 * @param command
24 */
25 public BSPThread(String command) {
26 this.command = command;
27 this.bspAction = new BSPAction(null, null);
28 }
29
30 @Override
31 public void run() {
32 ArrayList<String> values = new ArrayList<String>();
33
34 try {
35 ProcessBuilder builder = new ProcessBuilder(new String[] {"bash", "-c", command});
36 // redirect error stream to collect both output & error
37 builder.redirectErrorStream(true);
38 Process process = builder.start();
39 BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
40 String line = null;
41 String errorMessage = "";
42 while ( (line = br.readLine()) != null) {
43 String[] result = processLine(line);
44 String status = result[0];
45 String value = result[1];
46 if (status.equals(ERROR) && !value.isEmpty()) {
47 errorMessage += value;
48 continue;
49 }
50 if (!value.isEmpty())
51 values.add(value);
52 }
53 int exitVal = process.waitFor();
54
55 // if the background process did not exit with 0 code, we should set the status accordingly
56 if (exitVal != 0) {
57 bspAction.setMessage(errorMessage);
58 bspAction.setItems(null);
59 }
60 } catch (Exception e) {
61 bspAction.setMessage(e.getMessage());
62 bspAction.setItems(null);
63 }
64 if (!values.isEmpty()) {
65 bspAction.setMessage(null);
66 bspAction.setItems(values.toArray(new String[values.size()]));
67 }
68 }
69
70 /**
71 * Each command ran in the background will have a different output and a different way of processing it
72 * @param line
73 * @return
74 */
75 protected abstract String[] processLine(String line);
76
77 public BSPAction getBspAction() {
78 return bspAction;
79 }
80
81 public void setBspAction(BSPAction bspAction) {
82 this.bspAction = bspAction;
83 }
84
85 public String getCommand() {
86 return command;
87 }
88
89 public void setCommand(String command) {
90 this.command = command;
91 }
92}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/ErrorCollectorThread.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/ErrorCollectorThread.java
new file mode 100644
index 0000000..d39ac28
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/ErrorCollectorThread.java
@@ -0,0 +1,19 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * BSPThread that ignores the output of the process and returns an error if the process exits with non zero code
5 * @author ioana.grigoropol
6 *
7 */
8public class ErrorCollectorThread extends BSPThread{
9
10 public ErrorCollectorThread(String command) {
11 super(command);
12 }
13
14 @Override
15 protected String[] processLine(String line) {
16 return null;
17 }
18
19}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelArchGetter.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelArchGetter.java
new file mode 100644
index 0000000..833057a
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelArchGetter.java
@@ -0,0 +1,23 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * BSPThread that processes the output of "yocto-bsp list karch"
5 * @author ioana.grigoropol
6 *
7 */
8public class KernelArchGetter extends BSPThread{
9
10 public KernelArchGetter(String command) {
11 super(command);
12 }
13
14 @Override
15 protected String[] processLine(String line) {
16 if (line.contains(":"))
17 return new String[]{SUCCESS, ""};
18 line = line.replaceAll("^\\s+", "");
19 line = line.replaceAll("\\s+$", "");
20 return new String[]{SUCCESS, line};
21 }
22
23}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelBranchesGetter.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelBranchesGetter.java
new file mode 100644
index 0000000..4caea2c
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/KernelBranchesGetter.java
@@ -0,0 +1,28 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * BSPThread that processes the output lines from running command "yocto-bsp list" for the selected kernel
5 * @author ioana.grigoropol
6 *
7 */
8public class KernelBranchesGetter extends BSPThread {
9
10 public KernelBranchesGetter(String command) {
11 super(command);
12 }
13
14 @Override
15 protected String[] processLine(String line) {
16 // [TODO : Ioana]: find a better way to identify error lines
17 if (!line.startsWith("["))
18 return new String[]{ERROR, line + "\n"};
19
20 String[] items = line.split(",");
21
22 String value = items[0];
23 value = value.replace("[\"", "");
24 value = value.replaceAll("\"$", "");
25 return new String[]{SUCCESS, value};
26 }
27
28}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/MainPage.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/MainPage.java
new file mode 100644
index 0000000..ea6544f
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/MainPage.java
@@ -0,0 +1,498 @@
1/*******************************************************************************
2 * Copyright (c) 2012 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.wizards.bsp;
12
13import java.io.BufferedReader;
14import java.io.File;
15import java.io.InputStream;
16import java.io.InputStreamReader;
17
18import org.eclipse.core.runtime.IStatus;
19import org.eclipse.core.runtime.Status;
20import org.eclipse.jface.wizard.WizardPage;
21import org.eclipse.swt.SWT;
22import org.eclipse.swt.events.FocusEvent;
23import org.eclipse.swt.events.FocusListener;
24import org.eclipse.swt.events.ModifyEvent;
25import org.eclipse.swt.events.ModifyListener;
26import org.eclipse.swt.events.SelectionAdapter;
27import org.eclipse.swt.events.SelectionEvent;
28import org.eclipse.swt.layout.GridData;
29import org.eclipse.swt.layout.GridLayout;
30import org.eclipse.swt.widgets.Button;
31import org.eclipse.swt.widgets.Combo;
32import org.eclipse.swt.widgets.Composite;
33import org.eclipse.swt.widgets.Control;
34import org.eclipse.swt.widgets.DirectoryDialog;
35import org.eclipse.swt.widgets.Label;
36import org.eclipse.swt.widgets.Text;
37import org.eclipse.swt.widgets.Widget;
38import org.yocto.sdk.remotetools.YoctoBspElement;
39
40/**
41 *
42 * Setting up the parameters for creating the new Yocto BSP
43 *
44 * @author jzhang
45 */
46public class MainPage extends WizardPage {
47 public static final String PAGE_NAME = "Main";
48 private static final String KARCH_CMD = "yocto-bsp list karch";
49 private static final String QARCH_CMD = "yocto-bsp list qemu property qemuarch";
50 private static final String BSP_SCRIPT = "yocto-bsp";
51 private static final String PROPERTIES_CMD_PREFIX = "yocto-bsp list ";
52 private static final String PROPERTIES_CMD_SURFIX = " properties -o ";
53 private static final String PROPERTIES_FILE = "/tmp/properties.json";
54
55 private Button btnMetadataLoc;
56 private Text textMetadataLoc;
57 private Label labelMetadata;
58
59 private Button btnBspOutputLoc;
60 private Text textBspOutputLoc;
61 private Label labelBspOutput;
62
63 private Button btnBuildLoc;
64 private Text textBuildLoc;
65 private Label labelBuildLoc;
66
67 private boolean buildDirChecked;
68 private BuildLocationListener buildLocationListener;
69
70 private Text textBspName;
71 private Label labelBspName;
72
73 private Combo comboKArch;
74 private Label labelKArch;
75
76 private Combo comboQArch;
77 private Label labelQArch;
78
79 private YoctoBspElement bspElem;
80
81 public MainPage(YoctoBspElement element) {
82 super(PAGE_NAME, "yocto-bsp Main page", null);
83
84 setMessage("Enter the required fields(with *) to create new Yocto Project BSP!");
85 this.bspElem = element;
86 }
87
88 @Override
89 public void createControl(Composite parent) {
90 setErrorMessage(null);
91 Composite composite = new Composite(parent, SWT.NONE);
92 GridLayout layout = new GridLayout(2, false);
93 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
94 composite.setLayout(layout);
95 gd.horizontalSpan = 2;
96 composite.setLayoutData(gd);
97
98 labelMetadata = new Label(composite, SWT.NONE);
99 labelMetadata.setText("Metadata location*: ");
100 Composite textContainer = new Composite(composite, SWT.NONE);
101 textContainer.setLayout(new GridLayout(2, false));
102 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
103 textMetadataLoc = (Text)addTextControl(textContainer, "");
104 textMetadataLoc.setEnabled(false);
105 textMetadataLoc.addModifyListener(new ModifyListener() {
106 @Override
107 public void modifyText(ModifyEvent e) {
108 controlChanged(e.widget);
109 }
110 });
111 setBtnMetadataLoc(addFileSelectButton(textContainer, textMetadataLoc));
112
113 labelBuildLoc = new Label(composite, SWT.NONE);
114 labelBuildLoc.setText("Build location: ");
115
116 textContainer = new Composite(composite, SWT.NONE);
117 textContainer.setLayout(new GridLayout(2, false));
118 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
119
120 textBuildLoc = (Text)addTextControl(textContainer, "");
121 buildLocationListener = new BuildLocationListener("");
122 textBuildLoc.addFocusListener(buildLocationListener);
123
124 setBtnBuilddirLoc(addFileSelectButton(textContainer, textBuildLoc));
125
126 labelBspName = new Label(composite, SWT.NONE);
127 labelBspName.setText("BSP Name*: ");
128
129 textContainer = new Composite(composite, SWT.NONE);
130 textContainer.setLayout(new GridLayout(2, false));
131 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
132
133 textBspName = (Text)addTextControl(textContainer, "");
134 textBspName.addModifyListener(new ModifyListener() {
135 @Override
136 public void modifyText(ModifyEvent e) {
137 controlChanged(e.widget);
138 }
139 });
140
141 labelBspOutput = new Label(composite, SWT.NONE);
142 labelBspOutput.setText("BSP output location: ");
143
144 textContainer = new Composite(composite, SWT.NONE);
145 textContainer.setLayout(new GridLayout(2, false));
146 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
147
148 textBspOutputLoc = (Text)addTextControl(textContainer, "");
149 textBspOutputLoc.addModifyListener(new ModifyListener() {
150 @Override
151 public void modifyText(ModifyEvent e) {
152 controlChanged(e.widget);
153 }
154 });
155 setBtnBspOutLoc(addFileSelectButton(textContainer, textBspOutputLoc));
156
157 labelKArch = new Label(composite, SWT.NONE);
158 labelKArch.setText("Kernel Architecture*: ");
159
160 textContainer = new Composite(composite, SWT.NONE);
161 textContainer.setLayout(new GridLayout(2, false));
162 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
163
164 comboKArch = new Combo(textContainer, SWT.READ_ONLY);
165 comboKArch.setLayout(new GridLayout(2, false));
166 comboKArch.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
167 comboKArch.setEnabled(false);
168 comboKArch.addModifyListener(new ModifyListener() {
169 @Override
170 public void modifyText(ModifyEvent e) {
171 controlChanged(e.widget);
172 }
173 });
174
175 labelQArch = new Label(composite, SWT.NONE);
176 labelQArch.setText("Qemu Architecture(* for karch as qemu): ");
177 labelQArch.setEnabled(false);
178
179 textContainer = new Composite(composite, SWT.NONE);
180 textContainer.setLayout(new GridLayout(2, false));
181 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
182
183 comboQArch = new Combo(textContainer, SWT.READ_ONLY);
184 comboQArch.setLayout(new GridLayout(2, false));
185 comboQArch.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
186 comboQArch.setEnabled(false);
187 comboQArch.addModifyListener(new ModifyListener() {
188 @Override
189 public void modifyText(ModifyEvent e) {
190 controlChanged(e.widget);
191 }
192 });
193
194 setControl(composite);
195 validatePage();
196 }
197
198 private Control addTextControl(final Composite parent, String value) {
199 final Text text;
200
201 text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
202 text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
203 text.setText(value);
204 text.setSize(10, 150);
205
206 return text;
207 }
208
209 private Button addFileSelectButton(final Composite parent, final Text text) {
210 Button button = new Button(parent, SWT.PUSH | SWT.LEAD);
211 button.setText("Browse...");
212 button.addSelectionListener(new SelectionAdapter() {
213 @Override
214 public void widgetSelected(SelectionEvent event) {
215 String dirName = new DirectoryDialog(parent.getShell()).open();
216 if (dirName != null) {
217 text.setText(dirName);
218 }
219 }
220 });
221 return button;
222 }
223
224 private void controlChanged(Widget widget) {
225 Status status = new Status(IStatus.OK, "not_used", 0, "", null);
226 setErrorMessage(null);
227 String metadataLoc = textMetadataLoc.getText();
228
229 if (widget == textMetadataLoc) {
230 resetKarchCombo();
231 if (metadataLoc.length() == 0) {
232 status = new Status(IStatus.ERROR, "not_used", 0, "Meta data location can't be empty!", null);
233 } else {
234 File meta_data = new File(metadataLoc);
235 if (!meta_data.exists() || !meta_data.isDirectory()) {
236 status = new Status(IStatus.ERROR, "not_used", 0,
237 "Invalid meta data location: Make sure it exists and is a directory!", null);
238 } else {
239 File bspScript = new File(metadataLoc + "/scripts/" + BSP_SCRIPT);
240 if (!bspScript.exists() || !bspScript.canExecute())
241 status = new Status(IStatus.ERROR, "not_used", 0,
242 "Make sure yocto-bsp exists under \"" + metadataLoc + "/scripts\" and is executable!", null);
243 else {
244 kernelArchesHandler();
245 }
246 }
247 }
248 } else if (widget == comboKArch) {
249 String selection = comboKArch.getText();
250 if (!bspElem.getKarch().contentEquals(selection))
251 bspElem = new YoctoBspElement();
252 if (selection.matches("qemu")) {
253 labelQArch.setEnabled(true);
254 comboQArch.setEnabled(true);
255 } else {
256 labelQArch.setEnabled(false);
257 comboQArch.setEnabled(false);
258 }
259 }
260
261 String buildDir = textBuildLoc.getText();
262 String outputDir = textBspOutputLoc.getText();
263 String bspName = textBspName.getText();
264
265 if (bspName.contains(" ")) {
266 status = new Status(IStatus.ERROR, "not_used", 0,
267 "BSP name contains space which is not allowed!", null);
268 }
269
270 if (!outputDir.isEmpty()){
271 if (outputDir.matches(buildDir)) {
272 status = new Status(IStatus.ERROR, "not_used", 0,
273 "You've set BSP output directory the same as build directory, please leave output directory empty for this scenario!", null);
274 } else {
275 File outputDirectory = new File(outputDir);
276 if (outputDirectory.exists()){
277 status = new Status(IStatus.ERROR, "not_used", 0,
278 "Your BSP output directory points to an exiting directory!", null);
279 }
280 }
281 } else if (buildDir.startsWith(metadataLoc) && !bspName.isEmpty()) {
282 String bspDirStr = metadataLoc + "/meta-" + bspName;
283 File bspDir = new File(bspDirStr);
284 if (bspDir.exists()) {
285 status = new Status(IStatus.ERROR, "not_used", 0,
286 "Your BSP with name: " + bspName + " already exist under directory: " + bspDirStr + ", please change your bsp name!", null);
287 }
288 }
289
290 if (status.getSeverity() == IStatus.ERROR)
291 setErrorMessage(status.getMessage());
292
293 getWizard().getContainer().updateButtons();
294 canFlipToNextPage();
295 }
296
297 private Status checkBuildDir() {
298
299 String metadataLoc = textMetadataLoc.getText();
300 String buildLoc = textBuildLoc.getText();
301
302 if (buildLoc.isEmpty()) {
303 buildLoc = metadataLoc + "/build";
304 return createBuildDir(buildLoc);
305 } else {
306 File buildLocDir = new File(buildLoc);
307 if (!buildLocDir.exists()) {
308 return createBuildDir(buildLoc);
309 } else if (buildLocDir.isDirectory()) {
310 return createBuildDir(buildLoc);
311 } else {
312 return new Status(IStatus.ERROR, "not_used", 0, "Invalid build location: Make sure the build location is a directory!", null);
313 }
314 }
315 }
316
317 private Status createBuildDir(String buildLoc) {
318 String metadataDir = textMetadataLoc.getText();
319
320 // if we do not change the directory to metadata location the script will be looked into the directory indicated by user.dir system property
321 // system.property usually points to the location from where eclipse was started
322 String createBuildDirCmd = "cd " + metadataDir + ";source " + metadataDir + "/oe-init-build-env " + buildLoc;
323
324 try {
325 ProcessBuilder builder = new ProcessBuilder(new String[] {"bash", "-c", createBuildDirCmd});
326 Process proc = builder.start();
327 InputStream errorStream = proc.getErrorStream();
328 InputStreamReader isr = new InputStreamReader(errorStream);
329 BufferedReader br = new BufferedReader(isr);
330 String line = null;
331 String status = "";
332 while ( (line = br.readLine()) != null) {
333 status += line;
334 }
335
336 if (proc.waitFor() != 0)
337 return new Status(IStatus.ERROR, "not_used", 0, status, null);;
338 return new Status(IStatus.OK, "not_used", 0, "", null);
339 } catch (Exception e) {
340 return new Status(IStatus.ERROR, "not_used", 0, e.getMessage(), null);
341 }
342 }
343
344 public YoctoBspElement getBSPElement() {
345 return this.bspElem;
346 }
347
348
349 private void resetKarchCombo() {
350 comboKArch.deselectAll();
351 comboQArch.deselectAll();
352 comboKArch.setEnabled(false);
353 labelQArch.setEnabled(false);
354 comboQArch.setEnabled(false);
355 }
356
357 private void kernelArchesHandler() {
358 BSPAction kArchesAction = getKArches();
359 if (kArchesAction.getMessage() == null && kArchesAction.getItems().length != 0) {
360 comboKArch.setItems(kArchesAction.getItems());
361 comboKArch.setEnabled(true);
362 } else if (kArchesAction.getMessage() != null){
363 setErrorMessage(kArchesAction.getMessage());
364 return;
365 }
366 BSPAction qArchesAction = getQArches();
367 if (qArchesAction.getMessage() == null && qArchesAction.getItems().length != 0) {
368 comboQArch.setItems(qArchesAction.getItems());
369 } else if (qArchesAction.getMessage() != null)
370 setErrorMessage(qArchesAction.getMessage());
371
372 }
373
374 @Override
375 public boolean canFlipToNextPage(){
376 String err = getErrorMessage();
377 if (err != null)
378 return false;
379 else if (!validatePage())
380 return false;
381 return true;
382 }
383
384
385 public boolean validatePage() {
386 String metadataLoc = textMetadataLoc.getText();
387 String bspname = textBspName.getText();
388 String karch = comboKArch.getText();
389 String qarch = comboQArch.getText();
390 if (metadataLoc.isEmpty() ||
391 bspname.isEmpty() ||
392 karch.isEmpty()) {
393 return false;
394 } else if (karch.matches("qemu") && qarch.isEmpty()) {
395 return false;
396 }
397
398 bspElem.setBspName(bspname);
399 if (!textBspOutputLoc.getText().isEmpty())
400 bspElem.setBspOutLoc(textBspOutputLoc.getText());
401 else
402 bspElem.setBspOutLoc("");
403 if (!textBuildLoc.getText().isEmpty()) {
404 checkBuildDir();
405 bspElem.setBuildLoc(textBuildLoc.getText());
406 } else {
407 bspElem.setBuildLoc(metadataLoc + "/build");
408 if (!buildDirChecked) {
409 checkBuildDir();
410 buildDirChecked = true;
411 }
412 }
413 bspElem.setMetadataLoc(metadataLoc);
414 bspElem.setKarch(karch);
415 bspElem.setQarch(qarch);
416
417
418 if (!bspElem.getValidPropertiesFile()) {
419 boolean validPropertiesFile = true;
420 BSPAction action = createPropertiesFile();
421 if (action.getMessage() != null) {
422 validPropertiesFile = false;
423 setErrorMessage(action.getMessage());
424 }
425 bspElem.setValidPropertiesFile(validPropertiesFile);
426 }
427 return true;
428 }
429
430 private BSPAction createPropertiesFile() {
431 String createPropertiesCmd = bspElem.getMetadataLoc() + "/scripts/" +
432 PROPERTIES_CMD_PREFIX + bspElem.getKarch() +
433 PROPERTIES_CMD_SURFIX + PROPERTIES_FILE;
434 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new ErrorCollectorThread(createPropertiesCmd), "Creating properties file ");
435 progressDialog.run(false);
436 return progressDialog.getBspAction();
437 }
438
439 private BSPAction getKArches() {
440 String getKArchCmd = textMetadataLoc.getText() + "/scripts/" + KARCH_CMD;
441 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new KernelArchGetter(getKArchCmd), "Loading kernel architectures ");
442 progressDialog.run(false);
443 return progressDialog.getBspAction();
444 }
445
446 private BSPAction getQArches() {
447 String getQArchCmd = textMetadataLoc.getText() + "/scripts/" + QARCH_CMD;
448 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new QemuArchGetter(getQArchCmd), "Loading Qemu architectures ");
449 progressDialog.run(false);
450 return progressDialog.getBspAction();
451 }
452
453 public Button getBtnMetadataLoc() {
454 return btnMetadataLoc;
455 }
456
457 public void setBtnMetadataLoc(Button btnMetadataLoc) {
458 this.btnMetadataLoc = btnMetadataLoc;
459 }
460
461 public Button getBtnBspOutLoc() {
462 return btnBspOutputLoc;
463 }
464
465 public void setBtnBspOutLoc(Button btnBspOutLoc) {
466 this.btnBspOutputLoc = btnBspOutLoc;
467 }
468
469 public Button getBtnBuilddirLoc() {
470 return btnBuildLoc;
471 }
472
473 public void setBtnBuilddirLoc(Button btnBuilddirLoc) {
474 this.btnBuildLoc = btnBuilddirLoc;
475 }
476
477 class BuildLocationListener implements FocusListener{
478 String value;
479 boolean changed;
480
481 BuildLocationListener(String value){
482 this.value = value;
483 }
484 @Override
485 public void focusGained(FocusEvent e) {
486 value = ((Text)e.getSource()).getText();
487 }
488
489 @Override
490 public void focusLost(FocusEvent e) {
491 if(!((Text)e.getSource()).getText().equals(value)) {
492 checkBuildDir();
493 buildDirChecked = true;
494 }
495 }
496
497 }
498}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/OutputCollectorThread.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/OutputCollectorThread.java
new file mode 100644
index 0000000..df5fba5
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/OutputCollectorThread.java
@@ -0,0 +1,19 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * BSPThread that returns all the output lines of the process execution
5 * @author ioana.grigoropol
6 *
7 */
8public class OutputCollectorThread extends BSPThread{
9
10 public OutputCollectorThread(String command) {
11 super(command);
12 }
13
14 @Override
15 protected String[] processLine(String line) {
16 return new String[]{SUCCESS, line};
17 }
18
19}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/PropertiesPage.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/PropertiesPage.java
new file mode 100644
index 0000000..18149e7
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/PropertiesPage.java
@@ -0,0 +1,498 @@
1/*******************************************************************************
2 * Copyright (c) 2012 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.wizards.bsp;
12
13import java.util.ArrayList;
14import java.util.Collections;
15import java.util.Enumeration;
16import java.util.HashSet;
17import java.util.Hashtable;
18import java.util.Iterator;
19
20import org.eclipse.jface.dialogs.MessageDialog;
21import org.eclipse.jface.wizard.WizardPage;
22import org.eclipse.swt.SWT;
23import org.eclipse.swt.custom.ScrolledComposite;
24import org.eclipse.swt.events.SelectionEvent;
25import org.eclipse.swt.events.SelectionListener;
26import org.eclipse.swt.layout.GridData;
27import org.eclipse.swt.layout.GridLayout;
28import org.eclipse.swt.widgets.Button;
29import org.eclipse.swt.widgets.Combo;
30import org.eclipse.swt.widgets.Composite;
31import org.eclipse.swt.widgets.Control;
32import org.eclipse.swt.widgets.Group;
33import org.eclipse.swt.widgets.Label;
34import org.eclipse.swt.widgets.Text;
35import org.eclipse.swt.widgets.Widget;
36import org.yocto.sdk.remotetools.YoctoBspElement;
37import org.yocto.sdk.remotetools.YoctoBspPropertyElement;
38import org.yocto.sdk.remotetools.YoctoJSONHelper;
39/**
40 *
41 * Setting up the parameters for creating the new Yocto BSP
42 *
43 * @author jzhang
44 */
45public class PropertiesPage extends WizardPage {
46 private static final String PAGE_NAME = "Properties";
47 private static final String VALUES_CMD_PREFIX = "yocto-bsp list ";
48 private static final String VALUES_CMD_SURFIX = " property ";
49 private static final String KERNEL_CHOICE = "kernel_choice";
50 private static final String DEFAULT_KERNEL = "use_default_kernel";
51 private static final String SMP_NAME = "smp";
52 private static final String EXISTING_KBRANCH_NAME = "existing_kbranch";
53 private static final String NEED_NEW_KBRANCH_NAME = "need_new_kbranch";
54 private static final String NEW_KBRANCH_NAME = "new_kbranch";
55 private static final String QARCH_NAME = "qemuarch";
56
57 private static final String KERNEL_CHOICES = "choices";
58 private static final String KERNEL_BRANCHES = "branches";
59
60 private Hashtable<YoctoBspPropertyElement, Control> propertyControlMap;
61 HashSet<YoctoBspPropertyElement> properties;
62
63 private ScrolledComposite composite;
64 private Composite controlContainer = null;
65
66 private YoctoBspElement bspElem = null;
67 private boolean kArchChanged = false;
68
69 private Combo kernelCombo;
70 private Combo branchesCombo;
71
72 private Button newBranchButton;
73 private Button existingBranchButton;
74
75 private Button smpButton;
76
77 private Group kGroup = null;
78 private Group kbGroup = null;
79// private Group otherSettingsGroup = null;
80 private Group propertyGroup = null;
81
82 public PropertiesPage(YoctoBspElement element) {
83 super(PAGE_NAME, "yocto-bsp Properties page", null);
84 this.bspElem = element;
85 }
86
87 public void onEnterPage(YoctoBspElement element) {
88 if (!element.getValidPropertiesFile()) {
89 setErrorMessage("There's no valid properties file created, please choose \"Back\" to reselect kernel architecture!");
90 return;
91 }
92
93 if (this.bspElem == null || this.bspElem.getKarch().isEmpty() || !this.bspElem.getKarch().contentEquals(element.getKarch())) {
94 kArchChanged = true;
95 } else
96 kArchChanged = false;
97
98 this.bspElem = element;
99 try {
100 if (kArchChanged) {
101 updateKernelValues(KERNEL_CHOICES, KERNEL_CHOICE);
102
103 if (propertyGroup != null) {
104 for (Control cntrl : propertyGroup.getChildren()) {
105 cntrl.dispose();
106 }
107 }
108
109 properties = YoctoJSONHelper.getProperties();
110
111 if (!properties.isEmpty()) {
112
113 if (!element.getQarch().isEmpty()) {
114 YoctoBspPropertyElement qarch_elem = new YoctoBspPropertyElement();
115 qarch_elem.setName(QARCH_NAME);
116 qarch_elem.setValue(element.getQarch());
117 properties.add(qarch_elem);
118 }
119
120 propertyControlMap = new Hashtable<YoctoBspPropertyElement, Control>();
121
122 ArrayList<YoctoBspPropertyElement> propertiesList = new ArrayList<YoctoBspPropertyElement>(properties);
123 Collections.sort(propertiesList, Collections.reverseOrder());
124
125 Iterator<YoctoBspPropertyElement> it = propertiesList.iterator();
126 Composite comp = new Composite(propertyGroup, SWT.FILL);
127 GridLayout layout = new GridLayout(2, false);
128 GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1);
129 comp.setLayoutData(data);
130 comp.setLayout(layout);
131
132 while (it.hasNext()) {
133 // Get property
134 YoctoBspPropertyElement propElem = it.next();
135 String type = propElem.getType();
136 String name = propElem.getName();
137 if (type.contentEquals("edit")) {
138 new Label (propertyGroup, SWT.FILL).setText(name + ":");
139
140 Composite textContainer = new Composite(propertyGroup, SWT.NONE);
141 textContainer.setLayout(new GridLayout(1, false));
142 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
143 Text text = new Text(textContainer, SWT.BORDER | SWT.SINGLE);
144 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
145 propertyControlMap.put(propElem, text);
146
147 } else if (type.contentEquals("boolean")) {
148 String default_value = propElem.getDefaultValue();
149 Composite labelContainer = new Composite(propertyGroup, SWT.NONE);
150 labelContainer.setLayout(new GridLayout(2, false));
151 labelContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, false, 2, 1));
152 Button button = new Button(propertyGroup, SWT.CHECK);
153 button.setText(name);
154 if (default_value.equalsIgnoreCase("y")) {
155 button.setSelection(true);
156 } else
157 button.setSelection(false);
158 propertyControlMap.put(propElem, button);
159 } else if (type.contentEquals("choicelist")) {
160 new Label (propertyGroup, SWT.NONE).setText(name + ":");
161
162 Composite textContainer = new Composite(propertyGroup, SWT.NONE);
163 textContainer.setLayout(new GridLayout(1, false));
164 textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
165 Combo combo = new Combo(textContainer, SWT.READ_ONLY);
166 combo.setLayout(new GridLayout(2, false));
167 combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
168 combo.setItems(getBSPComboProperties(name));
169 propertyControlMap.put(propElem, combo);
170 }
171 }
172 }
173 composite.setMinSize(controlContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
174 composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
175 controlContainer.pack();
176 this.composite.layout(true, true);
177 }
178 } catch (Exception e) {
179 e.printStackTrace();
180 }
181
182
183 }
184
185
186 @Override
187 public void createControl(Composite parent) {
188 this.composite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
189 GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
190 GridLayout layout = new GridLayout(2, true);
191 this.composite.setLayout(layout);
192
193 gd= new GridData(SWT.FILL, SWT.FILL, true, false);
194 gd.horizontalSpan = 2;
195 this.composite.setLayoutData(gd);
196
197 setControl(this.composite);
198
199 controlContainer = new Composite(composite, SWT.NONE);
200 controlContainer.setLayout(new GridLayout(1, true));
201 controlContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
202
203 kGroup = new Group(controlContainer, SWT.FILL);
204 kGroup.setLayout(new GridLayout(2, false));
205 GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
206 kGroup.setLayoutData(data);
207 kGroup.setText("Kernel Settings:");
208
209 new Label (kGroup, SWT.NONE).setText("Kernel:");
210 Composite textContainer = new Composite(kGroup, SWT.NONE);
211 textContainer.setLayout(new GridLayout(1, false));
212 textContainer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
213
214 kernelCombo = new Combo(textContainer, SWT.READ_ONLY);
215 kernelCombo.setLayout(new GridLayout(2, false));
216 kernelCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
217
218 kernelCombo.addSelectionListener(new SelectionListener() {
219
220 @Override
221 public void widgetSelected(SelectionEvent e) {
222 controlChanged(e.widget);
223 }
224
225 @Override
226 public void widgetDefaultSelected(SelectionEvent e) {
227 }
228 });
229
230 kbGroup = new Group(kGroup, SWT.FILL);
231 kbGroup.setLayout(new GridLayout(2, true));
232 data = new GridData(SWT.FILL, SWT.FILL, true, false);
233 data.horizontalSpan = 2;
234 kbGroup.setLayoutData(data);
235 kbGroup.setText("Branch Settings:");
236
237 textContainer = new Composite(kbGroup, SWT.NONE);
238 textContainer.setLayout(new GridLayout(2, false));
239 textContainer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
240
241 new Label(textContainer, SWT.NONE).setText("Kernel branch:");
242
243 branchesCombo = new Combo(textContainer, SWT.READ_ONLY);
244 branchesCombo.setLayout(new GridLayout(1, false));
245 branchesCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
246 branchesCombo.addSelectionListener(new SelectionListener() {
247
248 @Override
249 public void widgetSelected(SelectionEvent e) {
250 controlChanged(e.widget);
251 }
252
253 @Override
254 public void widgetDefaultSelected(SelectionEvent e) {
255 }
256 });
257 branchesCombo.setSize(200, 200);
258
259 newBranchButton = new Button(kbGroup, SWT.RADIO);
260 newBranchButton.setText("Create a new branch from an existing one");
261 newBranchButton.setSelection(true);
262 newBranchButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
263 SelectionListener listener = new SelectionListener() {
264 @Override
265 public void widgetDefaultSelected(SelectionEvent e) {}
266
267 @Override
268 public void widgetSelected(SelectionEvent e) {
269 controlChanged(e.widget);
270 }
271 };
272
273 newBranchButton.addSelectionListener(listener);
274
275 existingBranchButton = new Button(kbGroup, SWT.RADIO);
276 existingBranchButton.setText("Use existing branch");
277 existingBranchButton.setSelection(false);
278 existingBranchButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
279 existingBranchButton.addSelectionListener(listener);
280
281// otherSettingsGroup = new Group(controlContainer, SWT.FILL);
282// otherSettingsGroup.setLayout(new GridLayout(2, true));
283// data = new GridData(SWT.FILL, SWT.FILL, true, false);
284// data.horizontalSpan = 2;
285// otherSettingsGroup.setLayoutData(data);
286// otherSettingsGroup.setText("Other Settings:");
287
288 smpButton = new Button(kGroup, SWT.CHECK);
289 smpButton.setText("Enable SMP support");
290 smpButton.setSelection(true);
291
292 propertyGroup = new Group(controlContainer, SWT.NONE);
293 propertyGroup.setLayout(new GridLayout(2, false));
294 data = new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1);
295 propertyGroup.setLayoutData(data);
296 propertyGroup.setText("BSP specific settings:");
297
298 this.composite.layout(true, true);
299
300 composite.setContent(controlContainer);
301 composite.setExpandHorizontal(true);
302 composite.setExpandVertical(true);
303 composite.setMinSize(controlContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
304 controlContainer.pack();
305 composite.pack();
306 }
307
308 @Override
309 public boolean canFlipToNextPage() {
310 return false;
311 }
312
313 public HashSet<YoctoBspPropertyElement> getProperties() {
314 String kcSelection = kernelCombo.getText();
315 String kbSelection = branchesCombo.getText();
316 YoctoBspPropertyElement kcElement = new YoctoBspPropertyElement();
317 kcElement.setName(KERNEL_CHOICE);
318 kcElement.setValue(kcSelection);
319 properties.add(kcElement);
320 YoctoBspPropertyElement defaultElement = new YoctoBspPropertyElement();
321 defaultElement.setName(DEFAULT_KERNEL);
322 defaultElement.setValue("n");
323 properties.add(defaultElement);
324
325 YoctoBspPropertyElement smpElement = new YoctoBspPropertyElement();
326 smpElement.setName(SMP_NAME);
327 if (smpButton.getSelection())
328 smpElement.setValue("y");
329 else
330 smpElement.setValue("n");
331 properties.add(smpElement);
332
333 YoctoBspPropertyElement newKbElement = new YoctoBspPropertyElement();
334 YoctoBspPropertyElement kbElement = new YoctoBspPropertyElement();
335
336 newKbElement.setName(NEED_NEW_KBRANCH_NAME);
337 if (newBranchButton.getSelection()) {
338 newKbElement.setValue("y");
339 properties.add(newKbElement);
340 kbElement.setName(NEW_KBRANCH_NAME);
341 kbElement.setValue(kbSelection);
342 properties.add(kbElement);
343 } else {
344 newKbElement.setValue("n");
345 properties.add(newKbElement);
346 kbElement.setName(EXISTING_KBRANCH_NAME);
347 kbElement.setValue(kbSelection);
348 properties.add(kbElement);
349 }
350
351 return properties;
352 }
353
354 public boolean validatePage() {
355 if (kernelCombo == null)
356 return false;
357
358 if ((kernelCombo != null) && (branchesCombo != null)) {
359 String kcSelection = kernelCombo.getText();
360 String kbSelection = branchesCombo.getText();
361 if ((kcSelection == null) || (kbSelection == null) || (kcSelection.isEmpty()) || (kbSelection.isEmpty())) {
362 setErrorMessage("Please choose a kernel and a specific branch!");
363 return false;
364 }
365 }
366 if ((propertyControlMap != null)) {
367 if (!propertyControlMap.isEmpty()) {
368 Enumeration<YoctoBspPropertyElement> keys = propertyControlMap.keys();
369 while (keys.hasMoreElements()) {
370 YoctoBspPropertyElement key = keys.nextElement();
371 Control control = propertyControlMap.get(key);
372 String type = key.getType();
373
374 if (type.contentEquals("edit")) {
375 String text_value = ((Text)control).getText();
376 if (text_value == null) {
377 setErrorMessage("Field "+ key.getName() +" is not set. All of the field on this screen must be set!");
378 return false;
379 } else {
380 key.setValue(text_value);
381 }
382 } else if (type.contentEquals("choicelist")) {
383 String choice_value = ((Combo)control).getText();
384 if (choice_value == null) {
385 setErrorMessage("Field "+ key.getName() +" is not set. All of the field on this screen must be set!");
386 return false;
387 } else {
388 key.setValue(choice_value);
389 }
390 } else {
391 boolean button_select = ((Button)control).getSelection();
392 if (button_select)
393 key.setValue("y");
394 else
395 key.setValue("n");
396 }
397 updateProperties(key);
398 }
399 }
400 }
401 return true;
402 }
403
404 private void updateProperties(YoctoBspPropertyElement element) {
405 Iterator<YoctoBspPropertyElement> it = properties.iterator();
406
407 while (it.hasNext()) {
408 YoctoBspPropertyElement propElem = it.next();
409 if (propElem.getName().contentEquals(element.getName())) {
410 properties.remove(propElem);
411 properties.add(element);
412 break;
413 } else
414 continue;
415 }
416 }
417 private void controlChanged(Widget widget) {
418 setErrorMessage(null);
419
420 String kernel_choice = kernelCombo.getText();
421 if ((kernel_choice == null) || (kernel_choice.isEmpty())) {
422 setErrorMessage("Please choose kernel !");
423 return;
424 }
425 if (widget == kernelCombo) {
426 updateKernelValues(KERNEL_BRANCHES, "\\\"" + kernel_choice + "\\\"." + NEW_KBRANCH_NAME);
427 } else if (widget == branchesCombo) {
428 setErrorMessage(null);
429 branchesCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT);
430 } else if (widget == newBranchButton || widget == existingBranchButton) {
431 if (newBranchButton.getSelection()) {
432 updateKernelValues(KERNEL_BRANCHES, "\"" + kernel_choice + "\"." + NEW_KBRANCH_NAME);
433 } else {
434 updateKernelValues(KERNEL_BRANCHES, "\"" + kernel_choice + "\"." + EXISTING_KBRANCH_NAME);
435 }
436 branchesCombo.deselectAll();
437 }
438 canFlipToNextPage();
439 getWizard().getContainer().updateButtons();
440 this.composite.layout(true, true);
441 composite.pack();
442 }
443
444 private void updateKernelValues(final String value, String property) {
445 String build_dir = "";
446 if ((bspElem.getBuildLoc() == null) || bspElem.getBuildLoc().isEmpty())
447 build_dir = bspElem.getMetadataLoc()+"/build";
448 else
449 build_dir = bspElem.getBuildLoc();
450
451 String metadataLoc = bspElem.getMetadataLoc();
452 String valuesCmd = "source " + metadataLoc + "/oe-init-build-env;" + metadataLoc + "/scripts/" + VALUES_CMD_PREFIX + bspElem.getKarch() + VALUES_CMD_SURFIX + property;
453 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new KernelBranchesGetter(valuesCmd), "Loading Kernel " + value);
454 if (value.equals(KERNEL_CHOICES))
455 progressDialog.run(false);
456 else if (value.equals(KERNEL_BRANCHES))
457 progressDialog.run(true);
458
459 BSPAction action = progressDialog.getBspAction();
460 if (action.getItems() != null) {
461 if (value.equals(KERNEL_CHOICES)) {
462 kernelCombo.setItems(action.getItems());
463 kernelCombo.pack();
464 kernelCombo.deselectAll();
465 branchesCombo.setEnabled(false);
466 branchesCombo.deselectAll();
467 } else if (value.equals(KERNEL_BRANCHES)) {
468 branchesCombo.setItems(action.getItems());
469 branchesCombo.pack();
470 branchesCombo.setEnabled(true);
471 }
472 composite.setMinSize(controlContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
473 } else if (action.getMessage() != null)
474 MessageDialog.openError(getShell(), "Yocto-BSP", action.getMessage());
475 composite.setMinSize(controlContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
476 }
477
478 private String[] getBSPComboProperties(String property) {
479 String build_dir = "";
480 if ((bspElem.getBuildLoc() == null) || bspElem.getBuildLoc().isEmpty())
481 build_dir = bspElem.getMetadataLoc()+"/build";
482 else
483 build_dir = bspElem.getBuildLoc();
484
485 String valuesCmd = "export BUILDDIR=" + build_dir + ";" + bspElem.getMetadataLoc() + "/scripts/" + VALUES_CMD_PREFIX + bspElem.getKarch() + VALUES_CMD_SURFIX + property;
486 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new KernelBranchesGetter(valuesCmd), "Loading property " + property + "values");
487 progressDialog.run(false);
488 BSPAction action = progressDialog.getBspAction();
489
490 if (action.getItems() != null) {
491 return action.getItems();
492 } else if (action.getMessage() != null) {
493 MessageDialog.openError(getShell(), "Yocto-BSP", action.getMessage());
494 return new String[]{};
495 }
496 return new String[]{};
497 }
498}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/QemuArchGetter.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/QemuArchGetter.java
new file mode 100644
index 0000000..e235695
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/QemuArchGetter.java
@@ -0,0 +1,27 @@
1package org.yocto.sdk.remotetools.wizards.bsp;
2
3/**
4 * BSPThread that processes the output of running "yocto-bsp list qemu property qemuarch"
5 * @author ioana.grigoropol
6 *
7 */
8public class QemuArchGetter extends BSPThread {
9
10 public QemuArchGetter(String command) {
11 super(command);
12 }
13
14 @Override
15 protected String[] processLine(String line) {
16 if (!line.startsWith("["))
17 return new String[]{ERROR, line + "\n"};
18
19 String[] values = line.split(",");
20
21 String value = values[0];
22 value = value.replace("[\"", "");
23 value = value.replaceAll("\"$", "");
24 return new String[]{SUCCESS, value};
25 }
26
27}
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java
new file mode 100644
index 0000000..3ab24c0
--- /dev/null
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java
@@ -0,0 +1,99 @@
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.wizards.bsp;
12
13import java.util.HashSet;
14
15import org.eclipse.jface.dialogs.MessageDialog;
16import org.eclipse.jface.wizard.IWizardPage;
17import org.eclipse.jface.wizard.Wizard;
18import org.yocto.sdk.remotetools.YoctoBspElement;
19import org.yocto.sdk.remotetools.YoctoBspPropertyElement;
20import org.yocto.sdk.remotetools.YoctoJSONHelper;
21
22/**
23 * A wizard for creating Yocto BSP.
24 *
25 * @author jzhang
26 *
27 */
28public class YoctoBSPWizard extends Wizard {
29 private static final String CREATE_CMD = "/scripts/yocto-bsp create ";
30 private static final String PROPERTY_VALUE_FILE = "/tmp/propertyvalues.json";
31
32 private MainPage mainPage;
33 private PropertiesPage propertiesPage;
34 private final YoctoBspElement bspElem;
35
36 public YoctoBSPWizard() {
37 super();
38 bspElem = new YoctoBspElement();
39 }
40
41 @Override
42 public IWizardPage getNextPage(IWizardPage page) {
43 propertiesPage.onEnterPage(mainPage.getBSPElement());
44 return propertiesPage;
45 }
46
47 @Override
48 public void addPages() {
49 mainPage = new MainPage(bspElem);
50 addPage(mainPage);
51 propertiesPage = new PropertiesPage(bspElem);
52 addPage(propertiesPage);
53 }
54
55 private BSPAction createBSP(){
56 YoctoBspElement element = mainPage.getBSPElement();
57 String createBspCmd = element.getMetadataLoc() + CREATE_CMD +
58 element.getBspName() + " " + element.getKarch();
59
60 if (!element.getBspOutLoc().isEmpty())
61 createBspCmd = createBspCmd + " -o " + element.getBspOutLoc();
62 else
63 createBspCmd = createBspCmd + " -o " + element.getMetadataLoc() + "/meta-" + element.getBspName();
64 createBspCmd = createBspCmd + " -i " + PROPERTY_VALUE_FILE;
65
66 BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new OutputCollectorThread(createBspCmd), "Creating BSP ");
67 progressDialog.run(true);
68 return progressDialog.getBspAction();
69 }
70
71 @Override
72 public boolean performFinish() {
73 if (propertiesPage.validatePage()) {
74 HashSet<YoctoBspPropertyElement> properties = propertiesPage.getProperties();
75 YoctoJSONHelper.createBspJSONFile(properties);
76
77 BSPAction createBSPAction = createBSP();
78 if (createBSPAction.getMessage() != null && !createBSPAction.getMessage().isEmpty()) {
79 MessageDialog.openError(getShell(),"Yocto-BSP", createBSPAction.getMessage());
80 return false;
81 } else {
82 String message = "";
83 for (String item : createBSPAction.getItems())
84 message += item + "\n";
85 MessageDialog.openInformation(getShell(), "Yocto-BSP", message);
86 return true;
87 }
88 } else {
89 MessageDialog.openError(getShell(), "Yocto-BSP", "Property settings contains error!");
90 return false;
91 }
92
93 }
94
95 @Override
96 public boolean canFinish() {
97 return (mainPage.validatePage() && propertiesPage.validatePage());
98 }
99}