Java Code Examples for java.awt.event.InputMethodEvent.consume()

The following are Jave code examples for showing how to use consume() of the java.awt.event.InputMethodEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: EditorComponentImpl.java   Source Code and License Vote up 6 votes
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
  super.processInputMethodEvent(e);
  if (!e.isConsumed()) {
    switch (e.getID()) {
      case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
        myEditor.replaceInputMethodText(e);
        // No breaks over here.

        //noinspection fallthrough
      case InputMethodEvent.CARET_POSITION_CHANGED:
        myEditor.inputMethodCaretPositionChanged(e);
        break;
    }
    e.consume();
  }
}
 
Example 2
Project: smoothcsv   File: CsvGridSheetTable.java   Source Code and License Vote up 6 votes
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
  super.processInputMethodEvent(e);
  if (Env.getOS() == Env.OS_WINDOWS) {
    return;
  }

  if (!e.isConsumed()) {
    // Try to install the editor
    CsvGridEditorComponent editorComponent = editQuickly();
    if (editorComponent != null) {
      editorComponent.ignoreNextKeyEvent();
      if (MacroRecorder.isRecording()) {
        MacroRecorder.getInstance().recordCommand("grid:StartQuickEdit");
      }
      editorComponent.processInputMethodEvent(e);
    }
    e.consume();
  }
}
 
Example 3
Project: tools-idea   File: EditorComponentImpl.java   Source Code and License Vote up 6 votes
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
  super.processInputMethodEvent(e);
  if (!e.isConsumed()) {
    switch (e.getID()) {
      case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
        myEditor.replaceInputMethodText(e);
        // No breaks over here.

        //noinspection fallthrough
      case InputMethodEvent.CARET_POSITION_CHANGED:
        myEditor.inputMethodCaretPositionChanged(e);
        break;
    }
    e.consume();
  }
}
 
Example 4
Project: OpenJSharp   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 5
Project: jdk8u-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 6
Project: openjdk-jdk10   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 7
Project: openjdk9   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 8
Project: jdk8u_jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 9
Project: lookaside_java-1.8.0-openjdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 10
Project: infobip-open-jdk-8   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 11
Project: jdk8u-dev-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 12
Project: jdk7-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 13
Project: openjdk-source-code-learn   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 14
Project: OLD-OpenJDK8   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 15
Project: openjdk-jdk7u-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 5 votes
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 16
Project: NBModeler   File: EditControlImpl.java   Source Code and License Vote up 4 votes
@Override
    public void inputMethodTextChanged(InputMethodEvent event) {
        if (!ime_Cached) {
            ime_SelectionStartPos = m_Field.getSelectionStart();
            ime_SelectionEndPos = m_Field.getSelectionEnd();
            if (ime_SelectionStartPos != ime_SelectionEndPos) {
                ime_InitialLoc = Math.min(ime_SelectionStartPos, ime_SelectionEndPos);
            } else {
                ime_InitialLoc = m_Field.getCaretPosition();
            }
            ime_Cached = true;
            ime_CachedChars = new StringBuffer();
        }

        int committedCharacterCount = event.getCommittedCharacterCount();
        CharacterIterator iter = event.getText();
        if (iter != null && ((iter.getEndIndex() - iter.getBeginIndex()) > committedCharacterCount)) {
            if (ime_CachedChars != null) {
                char ch = iter.first();
                for (int i = 0; i < committedCharacterCount; i++) {
                    ime_CachedChars.append(ch);
                    ch = iter.next();
                }
            }
        } else {

            // Push the caret back as part of faking the text input.
            int pos = ime_InitialLoc;
            setCurrentPosition(pos);
            // Fake the key input since handleTypedChar() does the right things.

            if (ime_CachedChars != null) {
                for (int i = 0; i < ime_CachedChars.length(); i++) {
                    handleTypedChar(ime_CachedChars.charAt(i));
                    setCurrentPosition(++pos);
                }
            }

            if (iter != null) {
                for (char ch = iter.first(); ch != CharacterIterator.DONE; ch = iter.next()) {
                    handleTypedChar(ch);
                    setCurrentPosition(++pos);
                }
            }
//	 for(int i = ime_SelectionStartPos; i < ime_SelectionEndPos; i++) {
//	     m_Translator.handleKeyDown(127);
//	 }	   
            ime_Cached = false;
            ime_CachedChars = null;

            event.consume();

            //commit the changes to the edit control
            setModified(true);
//         m_Translator.setModified(true);
//         if (getCurrentField() != null)
//         {
//            getCurrentField().setModified(true);
//         }
//         if (getAssociatedParent() != null)
//         {
//                if (getAssociatedParent() instanceof ProjectTreeCellEditor)
//            {
//               ((ProjectTreeCellEditor)getAssociatedParent()).stopCellEditing();
//            }
//         }
        }
    }
 
Example 17
Project: infobip-open-jdk-8   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 18
Project: jdk8u-dev-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 19
Project: jdk7-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 20
Project: openjdk-source-code-learn   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 21
Project: OLD-OpenJDK8   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}
 
Example 22
Project: openjdk-jdk7u-jdk   File: CompositionAreaHandler.java   Source Code and License Vote up 4 votes
public void inputMethodTextChanged(InputMethodEvent event) {
    AttributedCharacterIterator text = event.getText();
    int committedCharacterCount = event.getCommittedCharacterCount();

    // extract composed text and prepare it for display
    composedText = null;
    caret = null;
    if (text != null
            && committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {

        // Create the composition area if necessary
        if (compositionArea == null) {
             createCompositionArea();
        }

        // copy the composed text
        AttributedString composedTextString;
        composedTextString = new AttributedString(text,
                text.getBeginIndex() + committedCharacterCount, // skip over committed text
                text.getEndIndex(), IM_ATTRIBUTES);
        composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
        composedText = composedTextString.getIterator();
        caret = event.getCaret();
    }

    if (compositionArea != null) {
        compositionArea.setText(composedText, caret);
    }

    // send any committed text to the text component
    if (committedCharacterCount > 0) {
        inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
                                                 text, committedCharacterCount);

        // this may have changed the text location, so reposition the window
        if (isCompositionAreaVisible()) {
            compositionArea.updateWindowLocation();
        }
    }

    // event has been handled, so consume it
    event.consume();
}