use of com.cburch.draw.actions.ModelRemoveAction in project logisim-evolution by reds-heig.
the class SelectTool method keyTyped.
@Override
public void keyTyped(Canvas canvas, KeyEvent e) {
char ch = e.getKeyChar();
Selection selected = canvas.getSelection();
if ((ch == '\u0008' || ch == '\u007F') && !selected.isEmpty()) {
ArrayList<CanvasObject> toRemove = new ArrayList<CanvasObject>();
for (CanvasObject shape : selected.getSelected()) {
if (shape.canRemove()) {
toRemove.add(shape);
}
}
if (!toRemove.isEmpty()) {
e.consume();
CanvasModel model = canvas.getModel();
canvas.doAction(new ModelRemoveAction(model, toRemove));
selected.clearSelected();
repaintArea(canvas);
}
} else if (ch == '\u001b' && !selected.isEmpty()) {
selected.clearSelected();
repaintArea(canvas);
}
}
use of com.cburch.draw.actions.ModelRemoveAction 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