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.services.ServiceManagerEditor;
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 XuiProShowServiceManagerAction implements
27: IWorkbenchWindowActionDelegate {
28: private IWorkbenchWindow window;
29:
30: /**
31: * The constructor.
32: */
33: public XuiProShowServiceManagerAction() {
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: ServiceManagerEditor serviceEditor = new ServiceManagerEditor();
44: Shell shell = window.getShell();
45: serviceEditor.createPartControl(shell);
46: IViewSite site = serviceEditor.getViewSite();
47: try {
48: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
49: .getActivePage().showView("XUIPRO_SERVICEMANAGER");
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: }
|