use of com.ray3k.skincomposer.UndoableManager.CustomDrawableUndoable 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;
}
}
Aggregations