Search in sources :

Example 1 with Undoable

use of com.ray3k.skincomposer.Undoable in project skin-composer by raeleus.

the class DialogDrawables method result.

@Override
protected void result(Object object) {
    instance = null;
    if (object != null) {
        if (object instanceof DrawableData) {
            main.getProjectData().setChangesSaved(false);
            DrawableData drawable = (DrawableData) object;
            Undoable undoable;
            if (property != null) {
                undoable = new DrawableUndoable(main.getRootTable(), main.getAtlasData(), property, property.value, drawable.name);
            } else {
                undoable = new UndoableManager.CustomDrawableUndoable(main, customProperty, drawable.name);
            }
            main.getUndoableManager().addUndoable(undoable, true);
        } else if (object instanceof Boolean) {
            if (property != null) {
                if ((boolean) object) {
                    main.getProjectData().setChangesSaved(false);
                    DrawableUndoable undoable = new DrawableUndoable(main.getRootTable(), main.getAtlasData(), property, property.value, null);
                    main.getUndoableManager().addUndoable(undoable, true);
                    main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + property.name + "\"");
                } else {
                    boolean hasDrawable = false;
                    for (DrawableData drawable : main.getAtlasData().getDrawables()) {
                        if (drawable.name.equals(property.value)) {
                            hasDrawable = true;
                            break;
                        }
                    }
                    if (!hasDrawable) {
                        main.getProjectData().setChangesSaved(false);
                        main.getUndoableManager().clearUndoables();
                        property.value = null;
                        main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + property.name + "\"");
                        main.getRootTable().refreshStyleProperties(true);
                    }
                }
            } else if (customProperty != null) {
                if ((boolean) object) {
                    main.getProjectData().setChangesSaved(false);
                    CustomDrawableUndoable undoable = new CustomDrawableUndoable(main, customProperty, null);
                    main.getUndoableManager().addUndoable(undoable, true);
                    main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + customProperty.getName() + "\"");
                } else {
                    boolean hasDrawable = false;
                    for (DrawableData drawable : main.getAtlasData().getDrawables()) {
                        if (drawable.name.equals(customProperty.getValue())) {
                            hasDrawable = true;
                            break;
                        }
                    }
                    if (!hasDrawable) {
                        main.getProjectData().setChangesSaved(false);
                        main.getUndoableManager().clearUndoables();
                        customProperty.setValue(null);
                        main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + customProperty.getName() + "\"");
                        main.getRootTable().refreshStyleProperties(true);
                    }
                }
            }
        }
    }
    // todo: do proper implementation of event handling with fire(), etc.
    if (listener != null) {
        listener.handle(null);
        listener = null;
    }
}
Also used : CustomDrawableUndoable(com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable) DrawableUndoable(com.ray3k.skincomposer.UndoableManager.DrawableUndoable) Undoable(com.ray3k.skincomposer.Undoable) CustomDrawableUndoable(com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable) DrawableUndoable(com.ray3k.skincomposer.UndoableManager.DrawableUndoable) DrawableData(com.ray3k.skincomposer.data.DrawableData) UndoableManager(com.ray3k.skincomposer.UndoableManager) CustomDrawableUndoable(com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable) CustomDrawableUndoable(com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable)

Aggregations

Undoable (com.ray3k.skincomposer.Undoable)1 UndoableManager (com.ray3k.skincomposer.UndoableManager)1 CustomDrawableUndoable (com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable)1 DrawableUndoable (com.ray3k.skincomposer.UndoableManager.DrawableUndoable)1 DrawableData (com.ray3k.skincomposer.data.DrawableData)1