/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The InputMethodContext class provides methods that input methods
* can use to communicate with their client components.
* It is a subclass of InputContext, which provides methods for use by
* components.
*
* @author JavaSoft International
*/
public class InputMethodContext
private boolean dispatchingCommittedText;
// Creation of the context's composition area handler is
// delayed until we really need a composition area.
static private boolean belowTheSpotInputRequested;
private boolean inputMethodSupportsBelowTheSpot;
static {
// check whether we should use below-the-spot input
// get property from command line
// get property from awt.properties file
if (inputStyle == null) {
}
}
/**
* Constructs an InputMethodContext.
*/
public InputMethodContext() {
super();
}
}
boolean useBelowTheSpotInput() {
}
private boolean haveActiveClient() {
}
// implements java.awt.im.spi.InputMethodContext.dispatchInputMethodEvent
// We need to record the client component as the source so
// that we have correct information if we later have to break up this
// event into key events.
source = getClientComponent();
if (haveActiveClient() && !useBelowTheSpotInput()) {
} else {
}
}
}
/**
* Dispatches committed text to a client component.
* Called by composition window.
*
* @param client The component that the text should get dispatched to.
* @param text The iterator providing access to the committed
* (and possible composed) text.
* @param committedCharacterCount The number of committed characters in the text.
*/
int committedCharacterCount) {
// note that the client is not always the current client component -
// some host input method adapters may dispatch input method events
// through the Java event queue, and we may have switched clients while
// the event was in the queue.
if (committedCharacterCount == 0
return;
}
dispatchingCommittedText = true;
try {
// active client -> send text as InputMethodEvent
} else {
// passive client -> send text as KeyEvents
}
}
} finally {
dispatchingCommittedText = false;
}
}
// some host input method adapters may dispatch input method events
// through the Java event queue. If the component that the event is
// intended for isn't an active client, or if we're using below-the-spot
// input, we need to dispatch this event
// to the input window. Note that that component is not necessarily the
// current client component, since we may have switched clients while
// the event was in the queue.
if (event instanceof InputMethodEvent) {
|| (useBelowTheSpotInput() && !dispatchingCommittedText)) {
}
} else {
// make sure we don't dispatch our own key events back to the input method
if (!dispatchingCommittedText) {
super.dispatchEvent(event);
}
}
}
/**
* Gets this context's composition area handler, creating it if necessary.
* If requested, it grabs the composition area for use by this context.
* The composition area's text is not updated.
*/
synchronized(compositionAreaHandlerLock) {
if (compositionAreaHandler == null) {
compositionAreaHandler = new CompositionAreaHandler(this);
}
if (grab) {
}
return compositionAreaHandler;
}
}
/**
* Grabs the composition area for use by this context.
* If doUpdate is true, updates the composition area with previously sent
* composed text.
*/
synchronized(compositionAreaHandlerLock) {
if (compositionAreaHandler != null) {
} else {
// if this context hasn't seen a need for a composition area yet,
// just close it without creating the machinery
}
}
}
/**
* Releases and closes the composition area if it is currently owned by
* this context's composition area handler.
*/
void releaseCompositionArea() {
synchronized(compositionAreaHandlerLock) {
if (compositionAreaHandler != null) {
}
}
}
/**
* Calls CompositionAreaHandler.isCompositionAreaVisible() to see
* whether the composition area is visible or not.
* Notice that this method is always called on the AWT event dispatch
* thread.
*/
boolean isCompositionAreaVisible() {
if (compositionAreaHandler != null) {
}
return false;
}
/**
* Calls CompositionAreaHandler.setCompositionAreaVisible to
* show or hide the composition area.
* As isCompositionAreaVisible method, it is always called
* on AWT event dispatch thread.
*/
if (compositionAreaHandler != null) {
}
}
/**
* Calls the current client component's implementation of getTextLocation.
*/
}
/**
* Calls the current client component's implementation of getLocationOffset.
*/
return getReq().getLocationOffset(x, y);
}
/**
* Calls the current client component's implementation of getInsertPositionOffset.
*/
public int getInsertPositionOffset() {
return getReq().getInsertPositionOffset();
}
/**
* Calls the current client component's implementation of getCommittedText.
*/
int endIndex,
Attribute[] attributes) {
}
/**
* Calls the current client component's implementation of getCommittedTextLength.
*/
public int getCommittedTextLength() {
return getReq().getCommittedTextLength();
}
/**
* Calls the current client component's implementation of cancelLatestCommittedText.
*/
}
/**
* Calls the current client component's implementation of getSelectedText.
*/
}
if (haveActiveClient() && !useBelowTheSpotInput()) {
return getClientComponent().getInputMethodRequests();
} else {
return getCompositionAreaHandler(false);
}
}
// implements java.awt.im.spi.InputMethodContext.createInputMethodWindow
}
// implements java.awt.im.spi.InputMethodContext.createInputMethodJFrame
}
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (isSwing) {
} else {
if (toolkit instanceof InputMethodSupport) {
}
}
throw new InternalError("Input methods must be supported");
}
/**
* @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification
*/
}
/**
* Disables or enables decorations for the composition window.
*/
if (compositionAreaHandler != null) {
}
}
}