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.services.RouteManagerEditor;
16: import com.xoetrope.editor.eclipse.visualizer.DataVisualiser;
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 XuiProShowRouteManagerAction implements
27: IWorkbenchWindowActionDelegate {
28: private IWorkbenchWindow window;
29:
30: /**
31: * The constructor.
32: */
33: public XuiProShowRouteManagerAction() {
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: RouteManagerEditor routeEditor = new RouteManagerEditor();
44: Shell shell = window.getShell();
45: routeEditor.createPartControl(shell);
46: IViewSite site = routeEditor.getViewSite();
47: try {
48: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
49: .getActivePage().showView("XUIPRO_ROUTEMANAGER");
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
65: .setEnabled(XEditorProjectManager
66: .isUserRegistered("pro"));
67: }
68:
69: /**
70: * We can use this method to dispose of any system resources we previously
71: * allocated.
72: *
73: * @see IWorkbenchWindowActionDelegate#dispose
74: */
75: public void dispose() {
76: }
77:
78: /**
79: * We will cache window object in order to be able to provide parent shell for
80: * the message dialog.
81: *
82: * @see IWorkbenchWindowActionDelegate#init
83: */
84: public void init(IWorkbenchWindow window) {
85: this.window = window;
86: }
87: }
|