summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java78
1 files changed, 78 insertions, 0 deletions
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..eaf716e
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java
@@ -0,0 +1,78 @@
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 *******************************************************************************/
11package org.yocto.bc.ui.actions;
12
13import java.io.IOException;
14import java.util.Map;
15
16import org.eclipse.core.resources.IProject;
17import org.eclipse.core.resources.IResource;
18import org.eclipse.core.runtime.CoreException;
19import org.eclipse.jface.action.IAction;
20import org.eclipse.jface.viewers.ISelection;
21import org.eclipse.jface.viewers.IStructuredSelection;
22import org.eclipse.jface.wizard.WizardDialog;
23import org.eclipse.ui.IWorkbenchWindow;
24import org.eclipse.ui.IWorkbenchWindowActionDelegate;
25
26import org.yocto.bc.ui.Activator;
27import org.yocto.bc.ui.builder.BitbakeCommanderNature;
28import org.yocto.bc.ui.wizards.variable.VariableWizard;
29
30/**
31 * Action to launch the Variable Wizard.
32 * @author kgilmer
33 *
34 */
35public class LaunchVariableWizardAction implements IWorkbenchWindowActionDelegate {
36
37 private IWorkbenchWindow window;
38 private Map session;
39
40 public void dispose() {
41 }
42
43 public void init(IWorkbenchWindow window) {
44 this.window = window;
45 }
46
47 public void run(IAction action) {
48 VariableWizard wizard = new VariableWizard(session);
49
50 WizardDialog wd = new WizardDialog(window.getShell(), wizard);
51 wd.create();
52 wd.open();
53 }
54
55 public void selectionChanged(IAction action, ISelection selection) {
56 session = null;
57
58 if (selection instanceof IStructuredSelection) {
59 Object element = ((IStructuredSelection)selection).getFirstElement();
60
61 if (element instanceof IResource) {
62 IProject p = ((IResource)element).getProject();
63
64 try {
65 if (p.isOpen() && p.hasNature(BitbakeCommanderNature.NATURE_ID)) {
66 session = Activator.getBBSession(((IResource)element).getProject().getLocationURI().getPath());
67 }
68 } catch (IOException e) {
69 e.printStackTrace();
70 } catch (CoreException e) {
71 e.printStackTrace();
72 }
73 }
74 }
75
76 action.setEnabled(session != null);
77 }
78} \ No newline at end of file