Search in sources :

Example 1 with TypingTarget

use of com.intellij.openapi.ui.TypingTarget in project intellij-community by JetBrains.

the class AlphaNumericTypeCommand method type.

protected ActionCallback type(final PlaybackContext context, final String text) {
    final ActionCallback result = new ActionCallback();
    inWriteSafeContext(() -> {
        TypingTarget typingTarget = findTarget(context);
        if (typingTarget != null) {
            typingTarget.type(text).doWhenDone(result.createSetDoneRunnable()).doWhenRejected(() -> typeByRobot(context.getRobot(), text).notify(result));
        } else {
            typeByRobot(context.getRobot(), text).notify(result);
        }
    });
    return result;
}
Also used : TypingTarget(com.intellij.openapi.ui.TypingTarget) ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 2 with TypingTarget

use of com.intellij.openapi.ui.TypingTarget in project intellij-community by JetBrains.

the class KeyCodeTypeCommand method _execute.

@Override
public ActionCallback _execute(final PlaybackContext context) {
    String text = getText().substring(PREFIX.length()).trim();
    int textDelim = text.indexOf(" ");
    final String codes;
    if (textDelim >= 0) {
        codes = text.substring(0, textDelim);
    } else {
        codes = text;
    }
    final String unicode;
    if (codes.length() + 1 < text.length()) {
        unicode = text.substring(textDelim + 1);
    } else {
        unicode = "";
    }
    final ActionCallback result = new ActionCallback();
    inWriteSafeContext(() -> {
        TypingTarget typingTarget = findTarget(context);
        if (typingTarget != null) {
            typingTarget.type(unicode).doWhenDone(result.createSetDoneRunnable()).doWhenRejected(() -> typeCodes(context, context.getRobot(), codes).notify(result));
        } else {
            typeCodes(context, context.getRobot(), codes).notify(result);
        }
    });
    return result;
}
Also used : TypingTarget(com.intellij.openapi.ui.TypingTarget) ActionCallback(com.intellij.openapi.util.ActionCallback)

Aggregations

TypingTarget (com.intellij.openapi.ui.TypingTarget)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2