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