001: package com.xoetrope.editor.netbeans.langed;
002:
003: import com.xoetrope.carousel.langed.*;
004: import java.awt.BorderLayout;
005:
006: import org.openide.text.CloneableEditorSupport;
007: import org.openide.util.NbBundle;
008: import org.openide.windows.CloneableTopComponent;
009: import org.openide.windows.Mode;
010: import org.openide.windows.WindowManager;
011: import com.xoetrope.carousel.langed.LangEdDesktop;
012: import net.xoetrope.xui.XProjectManager;
013: import net.xoetrope.editor.project.XEditorProject;
014:
015: /**
016: * An openable window available to the IDE's window manager.
017: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
018: * the GNU Public License (GPL), please see license.txt for more details. If
019: * you make commercial use of this software you must purchase a commercial
020: * license from Xoetrope.</p>
021: * <p> $Revision: 1.11 $</p>
022: */
023: public class LanguageEditor extends CloneableTopComponent {
024: private LangEdDesktop langEdDesktop;
025: private XEditorProject currentProject;
026:
027: public LanguageEditor() {
028: currentProject = (XEditorProject) XProjectManager
029: .getCurrentProject();
030: currentProject.setObject("LanguageEditor", this );
031: initComponents();
032: //setCloseOperation(CLOSE_LAST);
033: // Display name of this window (not needed if you use the DataObject constructor):
034: setName(NbBundle.getMessage(LanguageEditor.class,
035: "LBL_LanguageEditorName")
036: + " (" + currentProject.getProjectTitle() + ")");
037: // You may set the icon, but often it is better to set the icon for an associated mode instead:
038: // setIcon(Utilities.loadImage("com/xoetrope/carousel/langed/LanguageEditorIcon.gif"));
039: // Use the Component Inspector to set tool-tip text. This will be saved
040: // automatically. Other JComponent properties you may need to save yuorself.
041: // At any time you can affect the node selection:
042: // setActivatedNodes(new Node[] {...});
043:
044: currentProject.setObject("LanguageEditor", this );
045: }
046:
047: public static LanguageEditor getInstance() {
048: XEditorProject currentProject = (XEditorProject) XProjectManager
049: .getCurrentProject();
050: if (currentProject instanceof XEditorProject) {
051: Object obj = currentProject.getObject("LanguageEditor");
052: if (obj == null) {
053: LanguageEditor langEd = new LanguageEditor();
054: return langEd;
055: } else
056: return (LanguageEditor) obj;
057: }
058: return null;
059: }
060:
061: public void componentClosed() {
062: XEditorProject currentProject = (XEditorProject) XProjectManager
063: .getCurrentProject();
064: if (currentProject instanceof XEditorProject)
065: currentProject.setObject("LanguageEditor", null);
066: }
067:
068: public int getPersistenceType() {
069: return PERSISTENCE_NEVER;
070: }
071:
072: public String preferredID() {
073: return "XuiProLanguageEditor";
074: }
075:
076: public void open() {
077: Mode mode = WindowManager.getDefault().findMode(
078: CloneableEditorSupport.EDITOR_MODE);
079: if (mode != null)
080: mode.dockInto(this );
081: super .open();
082: }
083:
084: protected boolean closeLast() {
085: componentClosed();
086: // You might want to prompt the user first and maybe return false:
087: return true;
088: }
089:
090: /** This method is called from within the constructor to
091: * initialize the form.
092: * WARNING: Do NOT modify this code. The content of this method is
093: * always regenerated by the FormEditor.
094: */
095: private void initComponents() {
096: setBorder(null);
097: setLayout(new BorderLayout());
098: langEdDesktop = new LangEdDesktop(null, true, null, null);
099: add(langEdDesktop, BorderLayout.CENTER);
100: }
101:
102: /**
103: * Scan the pages of a project for new strings
104: */
105: public void scanProject() {
106: langEdDesktop.scanCurrentProject();
107: }
108:
109: /**
110: * Add a new language to the project
111: */
112: public void addLanguage() {
113: langEdDesktop.newLanguage();
114: }
115:
116: /**
117: * Set the currently used language
118: */
119: public void setCurrentLang() {
120: langEdDesktop.setCurrentLang();
121: }
122:
123: /**
124: * Show the machine language editor
125: */
126: public void runMachineTranslation() {
127: langEdDesktop.runMachineTranslation();
128: }
129:
130: /**
131: * Run in live translation mode
132: */
133: public void runLiveTranslation() {
134: langEdDesktop.runLiveTranslation();
135: }
136:
137: /**
138: * Configure the spell checker
139: */
140: public void setupSpelling() {
141: langEdDesktop.setupSpelling();
142: }
143:
144: /**
145: * Do the spell check
146: */
147: public void checkSpelling() {
148: langEdDesktop.checkSpelling();
149: }
150: }
|