01: package com.xoetrope.editor.eclipse;
02:
03: import net.xoetrope.editor.project.XEditorProjectManager;
04:
05: import org.eclipse.jface.action.IAction;
06: import org.eclipse.jface.viewers.ISelection;
07: import org.eclipse.swt.widgets.Shell;
08: import org.eclipse.ui.IViewSite;
09: import org.eclipse.ui.IWorkbenchWindow;
10: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
11: import org.eclipse.ui.PartInitException;
12: import org.eclipse.ui.PlatformUI;
13: import org.eclipse.jface.dialogs.MessageDialog;
14:
15: import com.xoetrope.editor.eclipse.visualizer.DataVisualiser;
16:
17: /**
18: * Our sample action implements workbench action delegate. The action proxy will
19: * be created by the workbench and shown in the UI. When the user tries to use
20: * the action, this delegate will be created and execution will be delegated to
21: * it.
22: *
23: * @see IWorkbenchWindowActionDelegate
24: */
25: public class XuiProShowVisualizerAction implements
26: IWorkbenchWindowActionDelegate {
27: private IWorkbenchWindow window;
28:
29: /**
30: * The constructor.
31: */
32: public XuiProShowVisualizerAction() {
33: }
34:
35: /**
36: * The action has been activated. The argument of the method represents the
37: * 'real' action sitting in the workbench UI.
38: *
39: * @see IWorkbenchWindowActionDelegate#run
40: */
41: public void run(IAction action) {
42: DataVisualiser dataVisualiser = new DataVisualiser();
43: Shell shell = window.getShell();
44: dataVisualiser.createPartControl(shell);
45: //langEd.createPartControl( window.getShell() );
46: IViewSite site = dataVisualiser.getViewSite();
47: try {
48: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
49: .getActivePage().showView("XUIPRO_VISUALIZER");
50: } catch (PartInitException e) {
51: // TODO Auto-generated catch block
52: e.printStackTrace();
53: }
54: }
55:
56: /**
57: * Selection in the workbench has been changed. We can change the state of the
58: * 'real' action here if we want, but this can only happen after the delegate
59: * has been created.
60: *
61: * @see IWorkbenchWindowActionDelegate#selectionChanged
62: */
63: public void selectionChanged(IAction action, ISelection selection) {
64: action.setEnabled(XEditorProjectManager
65: .isUserRegistered("XUI 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: }
|