01: /*
02: * To change this template, choose Tools | Templates
03: * and open the template in the editor.
04: */
05:
06: package com.xoetrope.editor.netbeans.actions;
07:
08: import com.xoetrope.carousel.langed.EdLangMgr;
09: import com.xoetrope.editor.netbeans.langed.LanguageEditor;
10: import net.xoetrope.editor.project.XEditorProjectManager;
11: import org.openide.util.HelpCtx;
12: import org.openide.util.NbBundle;
13: import org.openide.util.actions.CallableSystemAction;
14:
15: /**
16: *
17: * @author kingsley.elmes
18: */
19: public class MachineLanguageAction extends CallableSystemAction {
20: public MachineLanguageAction() {
21: super ();
22: }
23:
24: public void performAction() {
25: LanguageEditor langEd = LanguageEditor.getInstance();
26: langEd.runMachineTranslation();
27: }
28:
29: public String getName() {
30: return NbBundle.getMessage(SetLanguageAction.class,
31: "LBL_MachineLanguageAction");
32: }
33:
34: public HelpCtx getHelpCtx() {
35: return HelpCtx.DEFAULT_HELP;
36: // If you will provide context help then use:
37: // return new HelpCtx(ShowLanguageEditorAction.class);
38: }
39:
40: protected boolean asynchronous() {
41: // performAction() should run in event thread
42: return false;
43: }
44:
45: public boolean isEnabled() {
46: try {
47: Object obj = XEditorProjectManager.getCurrentProject();
48: boolean check = XEditorProjectManager
49: .isUserRegistered("XUI Pro Localization")
50: && (obj != null);
51: if (!check) {
52: return false;
53: }
54:
55: LanguageEditor langEd = LanguageEditor.getInstance();
56: if ((langEd != null) && (!langEd.isOpened())) {
57: return false;
58: }
59:
60: EdLangMgr langMgr = (EdLangMgr) XEditorProjectManager
61: .getCurrentProject().getObject("LanguageManager");
62: if (langMgr.getNumLangs() == 0) {
63: return false;
64: }
65: } catch (Exception ex) {
66: return false;
67: }
68: return true;
69: }
70: }
|