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));
}
}
}
Aggregations