01: package com.xoetrope.editor.eclipse;
02:
03: import javax.swing.SwingUtilities;
04:
05: import net.xoetrope.editor.XEditorUtilities;
06: import net.xoetrope.editor.project.XEditorProject;
07: import net.xoetrope.editor.project.XEditorProjectManager;
08: import net.xoetrope.xui.XProjectManager;
09:
10: import org.eclipse.jface.action.IAction;
11: import org.eclipse.jface.viewers.ISelection;
12: import org.eclipse.ui.IWorkbenchWindow;
13: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
14: import org.eclipse.jface.dialogs.MessageDialog;
15:
16: import com.xoetrope.carousel.catalog.XCatalogueWizardDialog;
17: import com.xoetrope.carousel.survey.XSurveyWizard;
18:
19: /**
20: * Our sample action implements workbench action delegate. The action proxy will
21: * be created by the workbench and shown in the UI. When the user tries to use
22: * the action, this delegate will be created and execution will be delegated to
23: * it.
24: *
25: * @see IWorkbenchWindowActionDelegate
26: */
27: public class XuiProShowSurveyWizardAction implements
28: IWorkbenchWindowActionDelegate {
29: private IWorkbenchWindow window;
30:
31: /**
32: * The constructor.
33: */
34: public XuiProShowSurveyWizardAction() {
35: }
36:
37: /**
38: * The action has been activated. The argument of the method represents the
39: * 'real' action sitting in the workbench UI.
40: *
41: * @see IWorkbenchWindowActionDelegate#run
42: */
43: public void run(IAction action) {
44: final XEditorProject currentProject = (XEditorProject) XProjectManager
45: .getCurrentProject();
46: SwingUtilities.invokeLater(new Runnable() {
47: public void run() {
48: XSurveyWizard sw = new XSurveyWizard(currentProject);
49: XEditorUtilities.centreDialog(sw);
50: sw.setVisible(true);
51: }
52: });
53: }
54:
55: /**
56: * Selection in the workbench has been changed. We can change the state of the
57: * 'real' action here if we want, but this can only happen after the delegate
58: * has been created.
59: *
60: * @see IWorkbenchWindowActionDelegate#selectionChanged
61: */
62: public void selectionChanged(IAction action, ISelection selection) {
63: action
64: .setEnabled(XEditorProjectManager
65: .isUserRegistered("pro"));
66: }
67:
68: /**
69: * We can use this method to dispose of any system resources we previously
70: * allocated.
71: *
72: * @see IWorkbenchWindowActionDelegate#dispose
73: */
74: public void dispose() {
75: }
76:
77: /**
78: * We will cache window object in order to be able to provide parent shell for
79: * the message dialog.
80: *
81: * @see IWorkbenchWindowActionDelegate#init
82: */
83: public void init(IWorkbenchWindow window) {
84: this.window = window;
85: }
86: }
|