Methods Summary |
---|
private void | acceptSelection()
sendText(true);
rawText.setLength(0);
transliteratedText = null;
transliterated = false;
|
public void | activate()
if (!statusWindow.isVisible()) {
statusWindow.setVisible(true);
}
updateStatusWindow(locale);
|
void | closeLookupWindow()
if (lookupList != null) {
lookupList.setVisible(false);
lookupList = null;
}
|
public void | deactivate(boolean isTemporary)
closeLookupWindow();
|
public void | dispatchEvent(java.awt.AWTEvent event)
if (event.getID() == KeyEvent.KEY_TYPED) {
KeyEvent e = (KeyEvent) event;
if (handleCharacter(e.getKeyChar())) {
e.consume();
}
}
|
public void | dispose()
closeLookupWindow();
|
public void | endComposition()
if (rawText.length() != 0) {
acceptSelection();
}
closeLookupWindow();
|
public java.lang.Object | getControlObject()
return null;
|
public java.util.Locale | getLocale()
return locale;
|
private boolean | handleCharacter(char ch)
// if the lookup window is active...
if (lookupList != null) {
if (ch == ' ") {
if (++lookupSelection == lookupCandidateCount) {
lookupSelection = 0;
}
selectCandidate(lookupSelection);
return true;
} else if (ch == '\n") {
acceptSelection();
closeLookupWindow();
return true;
}
// otherwise, if the Latin letters have already been
// transliterated to Arabic or Hebrew (transliterated state)
} else if (transliterated) {
if (ch == ' ") {
showDerivedWords();
return true;
} else if (ch == '\n") {
acceptSelection();
return true;
} else {
Toolkit.getDefaultToolkit().beep();
return true;
}
// initial state - we need to transliterate from Latin to Hebrew
} else {
if (ch == ' ") {
transliterateLatinToRoot();
return true;
} else if (ch == '\n") {
if (rawText.length() != 0) {
acceptSelection();
return true;
}
} else if (ch == '\b") {
if (rawText.length() != 0) {
rawText.setLength(rawText.length() - 1);
sendText(false);
return true;
}
// if a Latin letter is entered...
} else if (Character.UnicodeBlock.of(ch) ==
Character.UnicodeBlock.BASIC_LATIN && Character.isLetter(ch)) {
rawText.append(ch);
sendText(false);
return true;
// if we are already in the middle of composition, don't allow a
// character other than a Latin letter to be entered.
} else if (rawText.length() != 0) {
Toolkit.getDefaultToolkit().beep();
return true;
}
}
return false;
|
public void | hideWindows()
closeLookupWindow();
statusWindow.hide();
|
public boolean | isCompositionEnabled()
return true;
|
private java.util.Properties | loadProperties(java.lang.String fileName)
Properties props = new Properties();
InputStream stream = this.getClass().getResourceAsStream(fileName);
props.load(stream);
stream.close();
return props;
|
public void | notifyClientWindowChange(java.awt.Rectangle location)
|
void | openLookupWindow()
lookupList = new LookupList(this, inputMethodContext, lookupCandidates);
lookupList.selectCandidate(lookupSelection);
|
public void | reconvert()
throw new UnsupportedOperationException();
|
public void | removeNotify()
|
void | selectCandidate(int candidate)
lookupSelection = candidate;
lookupList.selectCandidate(lookupSelection);
transliteratedText = (String) lookupCandidates.elementAt(lookupSelection);
sendText(false);
|
private void | sendText(boolean committed)
String text;
InputMethodHighlight highlight;
int committedCharacterCount = 0;
TextHitInfo caret = null;
if (transliterated) {
text = transliteratedText;
highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT;
} else {
text = new String(rawText);
highlight = InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT;
}
AttributedString as = new AttributedString(text);
if (committed) {
committedCharacterCount = text.length();
} else if (text.length() > 0) {
as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT, highlight);
caret = TextHitInfo.leading(text.length());
}
inputMethodContext.dispatchInputMethodEvent(
InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
as.getIterator(),
committedCharacterCount,
caret,
null);
|
public void | setCharacterSubsets(java.lang.Character$Subset[] subsets)
|
public void | setCompositionEnabled(boolean enable)
throw new UnsupportedOperationException();
|
public void | setInputMethodContext(java.awt.im.spi.InputMethodContext context)
inputMethodContext = context;
if (statusWindow == null) {
statusWindow = context.createInputMethodWindow(
"ArabicHebrew Input Method",
false);
Label label = new Label();
label.setBackground(Color.white);
statusWindow.add(label);
updateStatusWindow(locale);
label.setSize(200, 50);
statusWindow.pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
statusWindow.setLocation(d.width - statusWindow.getWidth(),
d.height - statusWindow.getHeight());
}
|
public boolean | setLocale(java.util.Locale locale)
for (int i = 0; i < SUPPORTED_LOCALES.length; i++) {
if (locale.equals(SUPPORTED_LOCALES[i])) {
this.locale = locale;
if (statusWindow != null) {
updateStatusWindow(locale);
}
return true;
}
}
return false;
|
private void | showDerivedWords()
String lookupName;
lookupName = rawText.toString() + "_" + locale + ".properties";
Properties lookupList;
String lookupString;
try {
lookupList = loadProperties(lookupName);
} catch (IOException e) {
// no lookup information
return;
}
lookupCandidates = new Vector();
lookupCandidateCount = 1;
while (true) {
lookupString = (String)lookupList.getProperty(
String.valueOf(lookupCandidateCount));
if (lookupString == null) {
lookupCandidateCount--;
break;
}
lookupCandidates.add(lookupString);
lookupCandidateCount++;
}
lookupSelection = 0;
openLookupWindow();
|
private void | transliterateLatinToRoot()
String lookupName;
lookupName = rawText.toString();
String localeLookupName = lookupName + "_" + locale;
while (true) {
transliteratedText = (String) arabichebrewNames.get(localeLookupName);
if (transliteratedText != null) {
break;
}
int index = localeLookupName.lastIndexOf("_");
if (index == -1) {
break;
}
localeLookupName = localeLookupName.substring(0, index);
}
if (transliteratedText != null) {
transliterated = true;
sendText(false);
} else {
Toolkit.getDefaultToolkit().beep();
}
|
void | updateStatusWindow(java.util.Locale locale)
Label label = (Label) statusWindow.getComponent(0);
String localeName = locale == null ? "null" : locale.getDisplayName();
label.setText(localeName + " IME Active");
|