001: /**
002: * Caption: Zaval Java Resource Editor
003: * @author: Victor Krapivin
004: * @version: 2.0
005: *
006: * Zaval JRC Editor is a visual editor which allows you to manipulate
007: * localization strings for all Java based software with appropriate
008: * support embedded.
009: *
010: * For more info on this product read Zaval Java Resource Editor User's Guide
011: * (It comes within this package).
012: * The latest product version is always available from the product's homepage:
013: * http://www.zaval.org/products/jrc-editor/
014: * and from the SourceForge:
015: * http://sourceforge.net/projects/zaval0002/
016: *
017: * Contacts:
018: * Support : support@zaval.org
019: * Change Requests : change-request@zaval.org
020: * Feedback : feedback@zaval.org
021: * Other : info@zaval.org
022: *
023: * Copyright (C) 2001-2002 Zaval Creative Engineering Group (http://www.zaval.org)
024: *
025: * This program is free software; you can redistribute it and/or
026: * modify it under the terms of the GNU General Public License
027: * (version 2) as published by the Free Software Foundation.
028: *
029: * This program is distributed in the hope that it will be useful,
030: * but WITHOUT ANY WARRANTY; without even the implied warranty of
031: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
032: * GNU General Public License for more details.
033: *
034: * You should have received a copy of the GNU General Public License
035: * along with this program; if not, write to the Free Software
036: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
037: *
038: */package org.zaval.tools.i18n.translator;
039:
040: import java.awt.*;
041: import org.zaval.awt.*;
042: import java.util.*;
043: import java.lang.*;
044: import java.awt.im.*;
045:
046: public class TextAreaWrap {
047: private EmulatedTextArea tf1 = null;
048: private TextArea tf2 = null;
049: private int flavor;
050:
051: public static final int NATIVE = 1;
052: public static final int PJAVA = 2;
053:
054: static Character.Subset[] usedInputs = {
055: Character.UnicodeBlock.ARABIC,
056: Character.UnicodeBlock.ARMENIAN,
057: Character.UnicodeBlock.BASIC_LATIN,
058: Character.UnicodeBlock.BENGALI,
059: Character.UnicodeBlock.BOPOMOFO,
060: Character.UnicodeBlock.CJK_COMPATIBILITY,
061: Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS,
062: Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION,
063: Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS,
064: Character.UnicodeBlock.CURRENCY_SYMBOLS,
065: Character.UnicodeBlock.CYRILLIC,
066: Character.UnicodeBlock.DEVANAGARI,
067: Character.UnicodeBlock.DINGBATS,
068: Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS,
069: Character.UnicodeBlock.GENERAL_PUNCTUATION,
070: Character.UnicodeBlock.GEORGIAN,
071: Character.UnicodeBlock.GREEK,
072: Character.UnicodeBlock.GREEK_EXTENDED,
073: Character.UnicodeBlock.GUJARATI,
074: Character.UnicodeBlock.GURMUKHI,
075: Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO,
076: Character.UnicodeBlock.HANGUL_JAMO,
077: Character.UnicodeBlock.HANGUL_SYLLABLES,
078: Character.UnicodeBlock.HEBREW,
079: Character.UnicodeBlock.HIRAGANA,
080: Character.UnicodeBlock.KANBUN,
081: Character.UnicodeBlock.KANNADA,
082: Character.UnicodeBlock.KATAKANA,
083: Character.UnicodeBlock.LAO,
084: Character.UnicodeBlock.LATIN_1_SUPPLEMENT,
085: Character.UnicodeBlock.LATIN_EXTENDED_A,
086: Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL,
087: Character.UnicodeBlock.LATIN_EXTENDED_B,
088: Character.UnicodeBlock.MALAYALAM,
089: Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.TAMIL,
090: Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.THAI,
091: Character.UnicodeBlock.TIBETAN,
092:
093: InputSubset.FULLWIDTH_DIGITS, InputSubset.FULLWIDTH_LATIN,
094: InputSubset.HALFWIDTH_KATAKANA, InputSubset.HANJA,
095: InputSubset.KANJI, InputSubset.LATIN,
096: InputSubset.LATIN_DIGITS, InputSubset.SIMPLIFIED_HANZI,
097: InputSubset.TRADITIONAL_HANZI };
098:
099: public TextAreaWrap() {
100: flavor = PJAVA;
101: String kind = System.getProperty("inputControls");
102: if (kind != null && kind.equals("native"))
103: flavor = NATIVE;
104: initControls();
105: }
106:
107: public TextAreaWrap(int flavor) {
108: this .flavor = flavor;
109: initControls();
110: }
111:
112: private void initControls() {
113: if (flavor == NATIVE) {
114: tf2 = new TextArea("", 3, 20, TextArea.SCROLLBARS_NONE);
115: tf2.enableInputMethods(true);
116: } else
117: tf1 = new EmulatedTextArea(true, false, 3, 20);
118: }
119:
120: public String getText() {
121: return flavor == NATIVE ? tf2.getText() : tf1.getText();
122: }
123:
124: public void setText(String text) {
125: if (flavor == NATIVE) {
126: tf2.setText(text);
127: } else
128: tf1.setText(text);
129: }
130:
131: public void setVisible(boolean show) {
132: if (flavor == NATIVE)
133: tf2.setVisible(show);
134: else
135: tf1.setVisible(show);
136: }
137:
138: public void requestFocus() {
139: if (flavor == NATIVE)
140: requestFocus();
141: else
142: tf1.requestFocus();
143: }
144:
145: public Component getControl() {
146: return flavor == NATIVE ? (Component) tf2 : (Component) tf1;
147: }
148:
149: public void setLocale(Locale l) {
150: if (flavor == NATIVE) {
151: tf2.setLocale(l);
152: }
153: if (getControl().getInputContext() != null)
154: getControl().getInputContext().setCharacterSubsets(
155: usedInputs);
156: }
157:
158: public void selectAll() {
159: if (flavor == NATIVE)
160: tf2.selectAll();
161: else
162: tf1.selectAll();
163: }
164:
165: public Rectangle getCursorShape() {
166: if (flavor == NATIVE)
167: return null;
168: else
169: return tf1.getCursorShape();
170: }
171: }
|