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:
18: /**
19: * Our sample action implements workbench action delegate. The action proxy will
20: * be created by the workbench and shown in the UI. When the user tries to use
21: * the action, this delegate will be created and execution will be delegated to
22: * it.
23: *
24: * @see IWorkbenchWindowActionDelegate
25: */
26: public class XuiProShowProductsAction implements
27: IWorkbenchWindowActionDelegate {
28: private IWorkbenchWindow window;
29:
30: /**
31: * The constructor.
32: */
33: public XuiProShowProductsAction() {
34: }
35:
36: /**
37: * The action has been activated. The argument of the method represents the
38: * 'real' action sitting in the workbench UI.
39: *
40: * @see IWorkbenchWindowActionDelegate#run
41: */
42: public void run(IAction action) {
43: final XEditorProject currentProject = (XEditorProject) XProjectManager
44: .getCurrentProject();
45: SwingUtilities.invokeLater(new Runnable() {
46: public void run() {
47: XCatalogueWizardDialog wd = new XCatalogueWizardDialog(
48: currentProject);
49: XEditorUtilities.centreDialog(wd);
50: wd.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.setEnabled(XEditorProjectManager
64: .isUserRegistered("XUI Pro"));
65: }
66:
67: /**
68: * We can use this method to dispose of any system resources we previously
69: * allocated.
70: *
71: * @see IWorkbenchWindowActionDelegate#dispose
72: */
73: public void dispose() {
74: }
75:
76: /**
77: * We will cache window object in order to be able to provide parent shell for
78: * the message dialog.
79: *
80: * @see IWorkbenchWindowActionDelegate#init
81: */
82: public void init(IWorkbenchWindow window) {
83: this.window = window;
84: }
85: }
|