01: package com.xoetrope.editor.eclipse;
02:
03: import javax.swing.SwingUtilities;
04:
05: import net.xoetrope.editor.project.XEditorProjectManager;
06:
07: import org.eclipse.jface.action.IAction;
08: import org.eclipse.jface.viewers.ISelection;
09: import org.eclipse.ui.IWorkbenchWindow;
10: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
11:
12: import com.xoetrope.carousel.langed.LangEdDesktop;
13: import com.xoetrope.editor.eclipse.langed.LanguageEditor;
14:
15: /**
16: * Our sample action implements workbench action delegate. The action proxy will
17: * be created by the workbench and shown in the UI. When the user tries to use
18: * the action, this delegate will be created and execution will be delegated to
19: * it.
20: *
21: * @see IWorkbenchWindowActionDelegate
22: */
23: public class XuiProRunMachineTranslationAction extends
24: XuiProShowLanguageEditorAction {
25: public void run(IAction action) {
26: LanguageEditor languageEditor = getLanguageEditor();
27: if (languageEditor == null)
28: languageEditor = showEditor();
29:
30: final LangEdDesktop langEdDesktop = languageEditor
31: .getLangEdDesktop();
32: SwingUtilities.invokeLater(new Runnable() {
33: public void run() {
34: langEdDesktop.runMachineTranslation();
35: }
36: });
37: }
38:
39: /**
40: * Selection in the workbench has been changed. We can change the state of the
41: * 'real' action here if we want, but this can only happen after the delegate
42: * has been created.
43: *
44: * @see IWorkbenchWindowActionDelegate#selectionChanged
45: */
46: public void selectionChanged(IAction action, ISelection selection) {
47: action.setEnabled(XEditorProjectManager
48: .isUserRegistered("XUI Pro"));
49: }
50: }
|