diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions')
6 files changed, 647 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobAction.java new file mode 100644 index 0000000..e92fac0 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobAction.java | |||
@@ -0,0 +1,84 @@ | |||
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 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.actions; | ||
12 | |||
13 | import org.eclipse.ui.PlatformUI; | ||
14 | import org.eclipse.ui.IWorkbench; | ||
15 | import org.eclipse.ui.IWorkbenchPage; | ||
16 | import org.eclipse.ui.IWorkbenchWindow; | ||
17 | |||
18 | import org.eclipse.core.resources.IProject; | ||
19 | import org.eclipse.core.resources.IResource; | ||
20 | import org.eclipse.core.runtime.IAdaptable; | ||
21 | import org.eclipse.jface.action.IAction; | ||
22 | import org.eclipse.jface.viewers.ISelection; | ||
23 | import org.eclipse.jface.viewers.IStructuredSelection; | ||
24 | |||
25 | import org.eclipse.swt.widgets.Shell; | ||
26 | |||
27 | import org.yocto.bc.ui.builder.BitbakeCommanderNature; | ||
28 | |||
29 | |||
30 | public class LaunchHobAction { | ||
31 | private static final String DIALOG_TITLE = "Launch HOB"; | ||
32 | |||
33 | public void run(IAction action) { | ||
34 | IResource resource = getSelectedResource(); | ||
35 | if (resource == null) | ||
36 | return; | ||
37 | |||
38 | IProject project = resource.getProject(); | ||
39 | LaunchHobDialog hobDialog = new LaunchHobDialog(new Shell(), DIALOG_TITLE, project); | ||
40 | hobDialog.open(); | ||
41 | String buildDir = hobDialog.getBuildDir(); | ||
42 | |||
43 | if (buildDir != null) { | ||
44 | try { | ||
45 | BitbakeCommanderNature.launchHob(project,buildDir); | ||
46 | } catch (Exception e){ | ||
47 | System.out.println(e.getMessage()); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | } | ||
52 | |||
53 | public void dispose() { | ||
54 | |||
55 | } | ||
56 | |||
57 | private IResource getSelectedResource() { | ||
58 | IWorkbench iworkbench = PlatformUI.getWorkbench(); | ||
59 | if (iworkbench == null){ | ||
60 | return null; | ||
61 | } | ||
62 | IWorkbenchWindow iworkbenchwindow = iworkbench.getActiveWorkbenchWindow(); | ||
63 | if (iworkbenchwindow == null) { | ||
64 | return null; | ||
65 | } | ||
66 | IWorkbenchPage iworkbenchpage = iworkbenchwindow.getActivePage(); | ||
67 | if (iworkbenchpage == null) { | ||
68 | return null; | ||
69 | } | ||
70 | ISelection sel = iworkbenchpage.getSelection(); | ||
71 | |||
72 | if (!(sel instanceof IStructuredSelection)) | ||
73 | return null; | ||
74 | IStructuredSelection ss = (IStructuredSelection) sel; | ||
75 | Object element = ss.getFirstElement(); | ||
76 | if (element instanceof IResource) | ||
77 | return (IResource) element; | ||
78 | if (!(element instanceof IAdaptable)) | ||
79 | return null; | ||
80 | IAdaptable adaptable = (IAdaptable)element; | ||
81 | Object adapter = adaptable.getAdapter(IResource.class); | ||
82 | return (IResource) adapter; | ||
83 | } | ||
84 | } | ||
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobDialog.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobDialog.java new file mode 100644 index 0000000..861360d --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobDialog.java | |||
@@ -0,0 +1,328 @@ | |||
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 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.actions; | ||
12 | |||
13 | import java.util.Map; | ||
14 | import java.util.Iterator; | ||
15 | import java.util.Map.Entry; | ||
16 | import java.util.ArrayList; | ||
17 | import java.util.HashMap; | ||
18 | import java.util.HashSet; | ||
19 | import java.io.File; | ||
20 | import java.io.IOException; | ||
21 | |||
22 | import org.eclipse.jface.dialogs.Dialog; | ||
23 | import org.eclipse.jface.dialogs.IDialogConstants; | ||
24 | |||
25 | import org.eclipse.swt.SWT; | ||
26 | import org.eclipse.swt.events.ModifyEvent; | ||
27 | import org.eclipse.swt.events.ModifyListener; | ||
28 | import org.eclipse.swt.events.SelectionAdapter; | ||
29 | import org.eclipse.swt.events.SelectionEvent; | ||
30 | import org.eclipse.swt.events.SelectionListener; | ||
31 | import org.eclipse.swt.layout.GridData; | ||
32 | import org.eclipse.swt.layout.GridLayout; | ||
33 | import org.eclipse.swt.widgets.Button; | ||
34 | import org.eclipse.swt.widgets.Combo; | ||
35 | import org.eclipse.swt.widgets.Composite; | ||
36 | import org.eclipse.swt.widgets.Control; | ||
37 | import org.eclipse.swt.widgets.DirectoryDialog; | ||
38 | import org.eclipse.swt.widgets.Display; | ||
39 | import org.eclipse.swt.widgets.Label; | ||
40 | import org.eclipse.swt.widgets.MessageBox; | ||
41 | import org.eclipse.swt.widgets.Shell; | ||
42 | import org.eclipse.swt.widgets.Widget; | ||
43 | |||
44 | import org.eclipse.core.resources.IProject; | ||
45 | import org.eclipse.core.resources.IProjectDescription; | ||
46 | import org.eclipse.core.resources.ICommand; | ||
47 | |||
48 | import org.yocto.bc.ui.builder.BitbakeBuilder; | ||
49 | import org.yocto.bc.ui.builder.BitbakeCommanderNature; | ||
50 | |||
51 | public class LaunchHobDialog extends Dialog { | ||
52 | private String title; | ||
53 | private Button buildButton; | ||
54 | private SelectionListener fSelectionListener; | ||
55 | private ModifyListener fModifyListener; | ||
56 | private Combo build_dir_combo; | ||
57 | |||
58 | private IProject project; | ||
59 | private Shell shell; | ||
60 | private String build_dir; | ||
61 | |||
62 | public LaunchHobDialog(Shell parentShell, String dialogTitle, IProject project) { | ||
63 | super(parentShell); | ||
64 | this.shell = parentShell; | ||
65 | this.project = project; | ||
66 | this.title = dialogTitle; | ||
67 | setShellStyle(getShellStyle() | SWT.RESIZE); | ||
68 | |||
69 | fSelectionListener= new SelectionListener() { | ||
70 | public void widgetDefaultSelected(SelectionEvent e) {} | ||
71 | |||
72 | public void widgetSelected(SelectionEvent e) { | ||
73 | controlChanged(e.widget); | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | fModifyListener= new ModifyListener() { | ||
78 | public void modifyText(ModifyEvent e) { | ||
79 | controlModified(e.widget); | ||
80 | } | ||
81 | }; | ||
82 | |||
83 | } | ||
84 | |||
85 | public String getBuildDir() { | ||
86 | return build_dir; | ||
87 | } | ||
88 | @Override | ||
89 | protected Control createDialogArea(Composite parent) { | ||
90 | final Composite result = (Composite) super.createDialogArea(parent); | ||
91 | |||
92 | try { | ||
93 | createComposite(result); | ||
94 | } catch (Exception e) { | ||
95 | // TODO Auto-generated catch block | ||
96 | System.out.println("Have you ever set the project specific Yocto Settings?"); | ||
97 | System.out.println(e.getMessage()); | ||
98 | } | ||
99 | |||
100 | return result; | ||
101 | } | ||
102 | |||
103 | private void createComposite(Composite composite) throws Exception{ | ||
104 | Label root_label, sysroot_label; | ||
105 | |||
106 | GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
107 | GridLayout layout = new GridLayout(2, false); | ||
108 | composite.setLayout(layout); | ||
109 | |||
110 | gd= new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
111 | gd.horizontalSpan= 2; | ||
112 | composite.setLayoutData(gd); | ||
113 | |||
114 | Label build_dir_label = new Label(composite, SWT.NONE); | ||
115 | build_dir_label.setText("Bitbake build directory: "); | ||
116 | Composite 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 | build_dir_combo = new Combo(textContainer, SWT.DROP_DOWN); | ||
121 | build_dir_combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); | ||
122 | initializeBuildCombo(); | ||
123 | |||
124 | Button buildButton = addDirSelectButton(textContainer, build_dir_combo); | ||
125 | |||
126 | //we add the listener at the end for avoiding the useless event trigger when control | ||
127 | //changed or modified. | ||
128 | buildButton.addSelectionListener(fSelectionListener); | ||
129 | build_dir_combo.addModifyListener(fModifyListener); | ||
130 | } | ||
131 | |||
132 | private Button addDirSelectButton(final Composite parent, final Combo combo) { | ||
133 | Button button = new Button(parent, SWT.PUSH | SWT.LEAD); | ||
134 | button.setText("Browse"); | ||
135 | button.addSelectionListener(new SelectionAdapter() { | ||
136 | @Override | ||
137 | public void widgetSelected(SelectionEvent event) { | ||
138 | String dirName = new DirectoryDialog(parent.getShell()).open(); | ||
139 | |||
140 | if (dirName != null) { | ||
141 | combo.add(dirName); | ||
142 | combo.setText(dirName); | ||
143 | } | ||
144 | } | ||
145 | }); | ||
146 | return button; | ||
147 | } | ||
148 | @Override | ||
149 | protected void configureShell(Shell newShell) { | ||
150 | super.configureShell(newShell); | ||
151 | newShell.setText(title); | ||
152 | } | ||
153 | |||
154 | protected void buttonPressed(int buttonId) { | ||
155 | if (buttonId == IDialogConstants.OK_ID) { | ||
156 | try { | ||
157 | build_dir = build_dir_combo.getText().toString(); | ||
158 | updateBuildSpec(build_dir); | ||
159 | super.buttonPressed(buttonId); | ||
160 | } catch (Exception e) { | ||
161 | // TODO Auto-generated catch block | ||
162 | System.out.println(e.getMessage()); | ||
163 | } | ||
164 | } | ||
165 | else if (buttonId == IDialogConstants.CANCEL_ID) | ||
166 | { | ||
167 | super.buttonPressed(buttonId); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | private boolean validateInput() { | ||
172 | boolean valid = false; | ||
173 | String build_dir = build_dir_combo.getText().toString(); | ||
174 | if ((build_dir == null) || build_dir.isEmpty()) { | ||
175 | Display display = Display.getCurrent(); | ||
176 | Shell shell = new Shell(display); | ||
177 | MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); | ||
178 | msgBox.setText("Yocto Configuration Error"); | ||
179 | msgBox.setMessage("The specified build directory is empty!"); | ||
180 | msgBox.open(); | ||
181 | if (shell != null) | ||
182 | shell.dispose(); | ||
183 | return valid; | ||
184 | } | ||
185 | String project_path = project.getLocation().toString(); | ||
186 | File project_dir_file = new File(project_path); | ||
187 | File build_dir_file = new File(build_dir); | ||
188 | try { | ||
189 | if (isSubDirectory(project_dir_file, build_dir_file)) { | ||
190 | Display display = Display.getCurrent(); | ||
191 | Shell shell = new Shell(display); | ||
192 | MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); | ||
193 | msgBox.setText("Yocto Configuration Error"); | ||
194 | msgBox.setMessage("The specified build directory is a sub-dir of project path: " + project_path); | ||
195 | msgBox.open(); | ||
196 | if (shell != null) | ||
197 | shell.dispose(); | ||
198 | } else | ||
199 | valid = true; | ||
200 | } catch (IOException e) { | ||
201 | System.out.println(e.getMessage()); | ||
202 | } | ||
203 | return valid; | ||
204 | } | ||
205 | |||
206 | private boolean isSubDirectory(File baseDir, File subDir) throws IOException { | ||
207 | baseDir = baseDir.getCanonicalFile(); | ||
208 | subDir = subDir.getCanonicalFile(); | ||
209 | |||
210 | File parentFile = subDir; | ||
211 | while (parentFile != null) { | ||
212 | if (baseDir.equals(parentFile)) { | ||
213 | return true; | ||
214 | } | ||
215 | parentFile = parentFile.getParentFile(); | ||
216 | } | ||
217 | return false; | ||
218 | } | ||
219 | |||
220 | private void controlChanged(Widget widget) { | ||
221 | |||
222 | if (widget == buildButton) | ||
223 | { | ||
224 | } | ||
225 | } | ||
226 | |||
227 | private void controlModified(Widget widget) { | ||
228 | if (widget == build_dir_combo) | ||
229 | { | ||
230 | |||
231 | } | ||
232 | } | ||
233 | |||
234 | private void initializeBuildCombo() | ||
235 | { | ||
236 | ArrayList<String> items = new ArrayList<String> (); | ||
237 | |||
238 | try { | ||
239 | IProjectDescription desc = project.getDescription(); | ||
240 | |||
241 | ICommand[] buildSpec = desc.getBuildSpec(); | ||
242 | if ((buildSpec != null) && (buildSpec.length != 0)) | ||
243 | { | ||
244 | for (int i = 0; i < buildSpec.length; i++) { | ||
245 | ICommand cmd = buildSpec[i]; | ||
246 | if (cmd.getBuilderName().equalsIgnoreCase(BitbakeBuilder.HOB_BUILD_ID)) | ||
247 | { | ||
248 | Map<String, String> args = cmd.getArguments(); | ||
249 | if ((args != null) && !args.isEmpty()) | ||
250 | { | ||
251 | Iterator entries = args.entrySet().iterator(); | ||
252 | while (entries.hasNext()) { | ||
253 | Entry thisEntry = (Entry) entries.next(); | ||
254 | String key = (String)thisEntry.getKey(); | ||
255 | if (key.equalsIgnoreCase(BitbakeCommanderNature.BUILD_DIR_KEY)) { | ||
256 | build_dir_combo.removeAll(); | ||
257 | build_dir_combo.setItems(getValues((String)thisEntry.getValue())); | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | } catch (Exception e) { | ||
265 | System.out.println(e.getMessage()); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | private String[] getValues(String value) { | ||
270 | |||
271 | if ((value != null) && !value.isEmpty()) | ||
272 | { | ||
273 | String[] pieces = value.split(","); | ||
274 | for (int i = 0; i < pieces.length; i++) | ||
275 | { | ||
276 | int start = pieces[i].indexOf("["); | ||
277 | if (start >= 0) | ||
278 | pieces[i] = pieces[i].substring(start+1); | ||
279 | int end = pieces[i].indexOf("]"); | ||
280 | if (end >= 0) | ||
281 | pieces[i] = pieces[i].substring(0, end); | ||
282 | pieces[i] = pieces[i].trim(); | ||
283 | } | ||
284 | return pieces; | ||
285 | } | ||
286 | return null; | ||
287 | } | ||
288 | |||
289 | private void updateBuildSpec(String build_dir) | ||
290 | { | ||
291 | try { | ||
292 | String[] items = build_dir_combo.getItems(); | ||
293 | HashSet values = new HashSet(); | ||
294 | Map<String, String> args = new HashMap<String, String>(); | ||
295 | values.add(build_dir); | ||
296 | for (int i = 0; i < items.length; i++) { | ||
297 | values.add(items[i]); | ||
298 | } | ||
299 | args.put(BitbakeCommanderNature.BUILD_DIR_KEY, values.toString()); | ||
300 | IProjectDescription desc = project.getDescription(); | ||
301 | ICommand[] buildSpec = desc.getBuildSpec(); | ||
302 | boolean found = false; | ||
303 | if ((buildSpec != null) || (buildSpec.length != 0)) { | ||
304 | for (int i = 0; i < buildSpec.length; i++) { | ||
305 | ICommand cmd = buildSpec[i]; | ||
306 | if (cmd.getBuilderName().equalsIgnoreCase(BitbakeBuilder.HOB_BUILD_ID)) { | ||
307 | cmd.setArguments(args); | ||
308 | desc.setBuildSpec(buildSpec); | ||
309 | found = true; | ||
310 | break; | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | if (!found) { | ||
315 | ICommand[] newBuildSpec = new ICommand[buildSpec.length + 1]; | ||
316 | System.arraycopy(buildSpec, 0, newBuildSpec, 0, buildSpec.length); | ||
317 | ICommand cmd = desc.newCommand(); | ||
318 | cmd.setBuilderName(BitbakeBuilder.HOB_BUILD_ID); | ||
319 | cmd.setArguments(args); | ||
320 | newBuildSpec[newBuildSpec.length - 1] = cmd; | ||
321 | desc.setBuildSpec(newBuildSpec); | ||
322 | } | ||
323 | project.setDescription(desc, null); | ||
324 | } catch (Exception e) { | ||
325 | System.out.println(e.getMessage()); | ||
326 | } | ||
327 | } | ||
328 | } | ||
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobHandler.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobHandler.java new file mode 100644 index 0000000..002075a --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchHobHandler.java | |||
@@ -0,0 +1,50 @@ | |||
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 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.actions; | ||
12 | |||
13 | import org.eclipse.core.commands.ExecutionEvent; | ||
14 | import org.eclipse.core.commands.ExecutionException; | ||
15 | import org.eclipse.core.commands.IHandlerListener; | ||
16 | import org.eclipse.core.commands.IHandler; | ||
17 | |||
18 | public class LaunchHobHandler implements IHandler { | ||
19 | |||
20 | public Object execute(ExecutionEvent event) throws ExecutionException { | ||
21 | LaunchHobAction a = new LaunchHobAction(); | ||
22 | a.run(null); | ||
23 | return null; | ||
24 | } | ||
25 | |||
26 | public void addHandlerListener(IHandlerListener handlerListener) { | ||
27 | // TODO Auto-generated method stub | ||
28 | |||
29 | } | ||
30 | |||
31 | public void dispose() { | ||
32 | // TODO Auto-generated method stub | ||
33 | |||
34 | } | ||
35 | |||
36 | public boolean isEnabled() { | ||
37 | // TODO Auto-generated method stub | ||
38 | return true; | ||
39 | } | ||
40 | |||
41 | public boolean isHandled() { | ||
42 | // TODO Auto-generated method stub | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | public void removeHandlerListener(IHandlerListener handlerListener) { | ||
47 | // TODO Auto-generated method stub | ||
48 | |||
49 | } | ||
50 | } | ||
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewBitBakeProjectWizardAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewBitBakeProjectWizardAction.java new file mode 100644 index 0000000..b8b3144 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewBitBakeProjectWizardAction.java | |||
@@ -0,0 +1,48 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2009 Ken Gilmer | ||
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 | * Ken Gilmer - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.actions; | ||
12 | |||
13 | import org.eclipse.jface.action.IAction; | ||
14 | import org.eclipse.jface.viewers.ISelection; | ||
15 | import org.eclipse.jface.viewers.IStructuredSelection; | ||
16 | import org.eclipse.jface.wizard.WizardDialog; | ||
17 | import org.eclipse.ui.IWorkbenchWindow; | ||
18 | import org.eclipse.ui.IWorkbenchWindowActionDelegate; | ||
19 | |||
20 | import org.yocto.bc.ui.wizards.importProject.ImportYoctoProjectWizard; | ||
21 | |||
22 | public class LaunchNewBitBakeProjectWizardAction implements IWorkbenchWindowActionDelegate { | ||
23 | |||
24 | private IWorkbenchWindow window; | ||
25 | private IStructuredSelection selection; | ||
26 | |||
27 | public void dispose() { | ||
28 | } | ||
29 | |||
30 | public void init(IWorkbenchWindow window) { | ||
31 | this.window = window; | ||
32 | } | ||
33 | |||
34 | public void run(IAction action) { | ||
35 | ImportYoctoProjectWizard wizard = new ImportYoctoProjectWizard(); | ||
36 | |||
37 | wizard.init(window.getWorkbench(), selection); | ||
38 | WizardDialog wd = new WizardDialog(window.getShell(), wizard); | ||
39 | wd.create(); | ||
40 | wd.open(); | ||
41 | } | ||
42 | |||
43 | public void selectionChanged(IAction action, ISelection selection) { | ||
44 | if (selection instanceof IStructuredSelection) { | ||
45 | this.selection = (IStructuredSelection) selection; | ||
46 | } | ||
47 | } | ||
48 | } \ No newline at end of file | ||
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewRecipeWizardAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewRecipeWizardAction.java new file mode 100644 index 0000000..d30d37b --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchNewRecipeWizardAction.java | |||
@@ -0,0 +1,48 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2009 Ken Gilmer | ||
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 | * Ken Gilmer - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.actions; | ||
12 | |||
13 | import org.eclipse.jface.action.IAction; | ||
14 | import org.eclipse.jface.viewers.ISelection; | ||
15 | import org.eclipse.jface.viewers.IStructuredSelection; | ||
16 | import org.eclipse.jface.wizard.WizardDialog; | ||
17 | import org.eclipse.ui.IWorkbenchWindow; | ||
18 | import org.eclipse.ui.IWorkbenchWindowActionDelegate; | ||
19 | |||
20 | import org.yocto.bc.ui.wizards.NewBitBakeFileRecipeWizard; | ||
21 | |||
22 | public class LaunchNewRecipeWizardAction implements IWorkbenchWindowActionDelegate { | ||
23 | |||
24 | private IWorkbenchWindow window; | ||
25 | private IStructuredSelection selection; | ||
26 | |||
27 | public void dispose() { | ||
28 | } | ||
29 | |||
30 | public void init(IWorkbenchWindow window) { | ||
31 | this.window = window; | ||
32 | } | ||
33 | |||
34 | public void run(IAction action) { | ||
35 | NewBitBakeFileRecipeWizard wizard = new NewBitBakeFileRecipeWizard(); | ||
36 | |||
37 | wizard.init(window.getWorkbench(), selection); | ||
38 | WizardDialog wd = new WizardDialog(window.getShell(), wizard); | ||
39 | wd.create(); | ||
40 | wd.open(); | ||
41 | } | ||
42 | |||
43 | public void selectionChanged(IAction action, ISelection selection) { | ||
44 | if (selection instanceof IStructuredSelection) { | ||
45 | this.selection = (IStructuredSelection) selection; | ||
46 | } | ||
47 | } | ||
48 | } \ No newline at end of file | ||
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java new file mode 100644 index 0000000..3104564 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java | |||
@@ -0,0 +1,89 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2013 Ken Gilmer, 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 | * Ken Gilmer - initial API and implementation | ||
10 | * Ioana Grigoropol (Intel) - adapt class for remote support | ||
11 | *******************************************************************************/ | ||
12 | package org.yocto.bc.ui.actions; | ||
13 | |||
14 | import java.io.IOException; | ||
15 | import java.lang.reflect.InvocationTargetException; | ||
16 | import java.util.Map; | ||
17 | |||
18 | import org.eclipse.core.resources.IProject; | ||
19 | import org.eclipse.core.resources.IResource; | ||
20 | import org.eclipse.core.runtime.CoreException; | ||
21 | import org.eclipse.core.runtime.NullProgressMonitor; | ||
22 | import org.eclipse.jface.action.IAction; | ||
23 | import org.eclipse.jface.viewers.ISelection; | ||
24 | import org.eclipse.jface.viewers.IStructuredSelection; | ||
25 | import org.eclipse.jface.wizard.WizardDialog; | ||
26 | import org.eclipse.ui.IWorkbenchWindow; | ||
27 | import org.eclipse.ui.IWorkbenchWindowActionDelegate; | ||
28 | import org.yocto.bc.ui.Activator; | ||
29 | import org.yocto.bc.ui.builder.BitbakeCommanderNature; | ||
30 | import org.yocto.bc.ui.model.ProjectInfo; | ||
31 | import org.yocto.bc.ui.wizards.variable.VariableWizard; | ||
32 | |||
33 | /** | ||
34 | * Action to launch the Variable Wizard. | ||
35 | * @author kgilmer | ||
36 | * | ||
37 | */ | ||
38 | public class LaunchVariableWizardAction implements IWorkbenchWindowActionDelegate { | ||
39 | |||
40 | private IWorkbenchWindow window; | ||
41 | private Map session; | ||
42 | |||
43 | public void dispose() { | ||
44 | } | ||
45 | |||
46 | public void init(IWorkbenchWindow window) { | ||
47 | this.window = window; | ||
48 | } | ||
49 | |||
50 | public void run(IAction action) { | ||
51 | VariableWizard wizard = new VariableWizard(session); | ||
52 | |||
53 | WizardDialog wd = new WizardDialog(window.getShell(), wizard); | ||
54 | wd.create(); | ||
55 | wd.open(); | ||
56 | } | ||
57 | |||
58 | public void selectionChanged(IAction action, ISelection selection) { | ||
59 | session = null; | ||
60 | |||
61 | if (selection instanceof IStructuredSelection) { | ||
62 | Object element = ((IStructuredSelection)selection).getFirstElement(); | ||
63 | |||
64 | if (element instanceof IResource) { | ||
65 | IProject p = ((IResource)element).getProject(); | ||
66 | |||
67 | try { | ||
68 | if (p.isAccessible() && p.isOpen() && p.hasNature(BitbakeCommanderNature.NATURE_ID)) { | ||
69 | IProject proj = ((IResource)element).getProject(); | ||
70 | ProjectInfo projInfo = Activator.getProjInfo(proj.getLocationURI()); | ||
71 | session = Activator.getBBSession(projInfo, new NullProgressMonitor()); | ||
72 | } | ||
73 | } catch (IOException e) { | ||
74 | e.printStackTrace(); | ||
75 | } catch (CoreException e) { | ||
76 | e.printStackTrace(); | ||
77 | } catch (InvocationTargetException e) { | ||
78 | e.printStackTrace(); | ||
79 | } catch (InterruptedException e) { | ||
80 | e.printStackTrace(); | ||
81 | } catch (Exception e) { | ||
82 | e.printStackTrace(); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | action.setEnabled(session != null); | ||
88 | } | ||
89 | } | ||