Search in sources :

Example 1 with UndoDeleteAction

use of com.bladecoder.engineeditor.undo.UndoDeleteAction in project bladecoder-adventure-engine by bladecoder.

the class ActionList method delete.

@Override
protected void delete() {
    if (list.getSelection().size() == 0)
        return;
    multiClipboard.clear();
    int pos = list.getSelectedIndex();
    for (Action e : getSortedSelection()) {
        if (e instanceof EndAction)
            continue;
        int pos2 = list.getItems().indexOf(e, true);
        list.getItems().removeValue(e, true);
        int idx = parent.getActions().indexOf(e);
        parent.getActions().remove(e);
        multiClipboard.add(e);
        // TRANSLATIONS
        if (scope.equals(ScopePanel.WORLD_SCOPE))
            Ctx.project.getI18N().putTranslationsInElement(e, true);
        else
            Ctx.project.getI18N().putTranslationsInElement(e, false);
        // UNDO
        Ctx.project.getUndoStack().add(new UndoDeleteAction(parent, e, idx));
        if (isControlAction(e))
            deleteControlAction(pos2, (AbstractControlAction) e);
    }
    if (list.getItems().size == 0) {
        list.getSelection().clear();
    } else if (pos >= list.getItems().size) {
        list.getSelection().choose(list.getItems().get(list.getItems().size - 1));
    } else {
        list.getSelection().choose(list.getItems().get(pos));
    }
    toolbar.disablePaste(false);
    Ctx.project.setModified();
}
Also used : AbstractControlAction(com.bladecoder.engine.actions.AbstractControlAction) UndoDeleteAction(com.bladecoder.engineeditor.undo.UndoDeleteAction) AbstractIfAction(com.bladecoder.engine.actions.AbstractIfAction) CommentAction(com.bladecoder.engine.actions.CommentAction) EndAction(com.bladecoder.engine.actions.EndAction) Action(com.bladecoder.engine.actions.Action) AbstractControlAction(com.bladecoder.engine.actions.AbstractControlAction) DisableActionAction(com.bladecoder.engine.actions.DisableActionAction) UndoDeleteAction(com.bladecoder.engineeditor.undo.UndoDeleteAction) EndAction(com.bladecoder.engine.actions.EndAction)

Aggregations

AbstractControlAction (com.bladecoder.engine.actions.AbstractControlAction)1 AbstractIfAction (com.bladecoder.engine.actions.AbstractIfAction)1 Action (com.bladecoder.engine.actions.Action)1 CommentAction (com.bladecoder.engine.actions.CommentAction)1 DisableActionAction (com.bladecoder.engine.actions.DisableActionAction)1 EndAction (com.bladecoder.engine.actions.EndAction)1 UndoDeleteAction (com.bladecoder.engineeditor.undo.UndoDeleteAction)1