@SuppressWarnings("unchecked") // NOTE(zdwang): This is for (Point<Node>) action[1]
public void run(TypingExtractor extractor, Object... actions) throws HtmlMissing, HtmlInserted {
for (Object a : actions) {
Object[] action = (Object[]) a;
Point<Node> sel = getSelectionStart();
Text txt = sel == null ? null : sel.getContainer().<Text>cast();
Action type = (Action) action[0];
switch (type) {
case MOVE:
//extractor.flush();
setCaret((Point<Node>) action[1]);
break;
case TYPE:
String typed = (String) action[1];
extractor.somethingHappened(getSelectionStart());
if (sel.isInTextNode()) {
txt.insertData(sel.getTextOffset(), (String) action[1]);
moveCaret(((String) action[1]).length());
} else {
txt = Document.get().createTextNode(typed);
sel.getContainer().insertBefore(txt, sel.getNodeAfter());
setCaret(Point.inText((Node)txt, typed.length()));