Search in sources :

Example 1 with ModelEditTextAction

use of com.cburch.draw.actions.ModelEditTextAction in project logisim-evolution by reds-heig.

the class TextTool method commitText.

private void commitText(Canvas canvas) {
    Text cur = curText;
    boolean isNew = isTextNew;
    String newText = field.getText();
    if (cur == null) {
        return;
    }
    cancelText(canvas);
    if (isNew) {
        if (!newText.equals("")) {
            cur.setText(newText);
            canvas.doAction(new ModelAddAction(canvas.getModel(), cur));
        }
    } else {
        String oldText = cur.getText();
        if (newText.equals("")) {
            canvas.doAction(new ModelRemoveAction(canvas.getModel(), cur));
        } else if (!oldText.equals(newText)) {
            canvas.doAction(new ModelEditTextAction(canvas.getModel(), cur, newText));
        }
    }
}
Also used : ModelAddAction(com.cburch.draw.actions.ModelAddAction) ModelRemoveAction(com.cburch.draw.actions.ModelRemoveAction) Text(com.cburch.draw.shapes.Text) ModelEditTextAction(com.cburch.draw.actions.ModelEditTextAction)

Aggregations

ModelAddAction (com.cburch.draw.actions.ModelAddAction)1 ModelEditTextAction (com.cburch.draw.actions.ModelEditTextAction)1 ModelRemoveAction (com.cburch.draw.actions.ModelRemoveAction)1 Text (com.cburch.draw.shapes.Text)1