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: * Add a language to the project
17: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
18: * the GNU Public License (GPL), please see license.txt for more details. If
19: * you make commercial use of this software you must purchase a commercial
20: * license from Xoetrope.</p>
21: * <p> $Revision: 1.2 $</p>
22: * @author kingsley.elmes
23: */
24: public class SetLanguageAction extends CallableSystemAction {
25: public SetLanguageAction() {
26: super ();
27: }
28:
29: public void performAction() {
30: LanguageEditor langEd = LanguageEditor.getInstance();
31: langEd.setCurrentLang();
32: }
33:
34: public String getName() {
35: return NbBundle.getMessage(SetLanguageAction.class,
36: "LBL_SetLanguageAction");
37: }
38:
39: public HelpCtx getHelpCtx() {
40: return HelpCtx.DEFAULT_HELP;
41: // If you will provide context help then use:
42: // return new HelpCtx(ShowLanguageEditorAction.class);
43: }
44:
45: protected boolean asynchronous() {
46: // performAction() should run in event thread
47: return false;
48: }
49:
50: public boolean isEnabled() {
51: try {
52: Object obj = XEditorProjectManager.getCurrentProject();
53: boolean check = XEditorProjectManager
54: .isUserRegistered("XUI Pro Localization")
55: && (obj != null);
56: if (!check) {
57: return false;
58: }
59:
60: LanguageEditor langEd = LanguageEditor.getInstance();
61: if ((langEd != null) && (langEd.isOpened())) {
62: return false;
63: }
64:
65: EdLangMgr langMgr = (EdLangMgr) XEditorProjectManager
66: .getCurrentProject().getObject("LanguageManager");
67: if (langMgr.getNumLangs() == 0) {
68: return false;
69: }
70: } catch (Exception ex) {
71: return false;
72: }
73: return true;
74: }
75: }
|