use of com.ray3k.skincomposer.UndoableManager.CustomColorUndoable in project skin-composer by raeleus.
the class DialogColors method result.
@Override
protected void result(Object object) {
boolean pressedCancel = false;
if (styleProperty != null) {
if (object instanceof ColorData) {
projectData.setChangesSaved(false);
ColorData color = (ColorData) object;
ColorUndoable undoable = new ColorUndoable(rootTable, jsonData, styleProperty, styleProperty.value, color.getName());
undoableManager.addUndoable(undoable, true);
} else if (object instanceof Boolean) {
if ((boolean) object) {
projectData.setChangesSaved(false);
ColorUndoable undoable = new ColorUndoable(rootTable, jsonData, styleProperty, styleProperty.value, null);
undoableManager.addUndoable(undoable, true);
} else {
pressedCancel = true;
boolean hasColor = false;
for (ColorData color : jsonData.getColors()) {
if (color.getName().equals(styleProperty.value)) {
hasColor = true;
break;
}
}
if (!hasColor) {
projectData.setChangesSaved(false);
styleProperty.value = null;
rootTable.refreshStyleProperties(true);
}
}
}
} else if (customProperty != null) {
if (object instanceof ColorData) {
projectData.setChangesSaved(false);
ColorData color = (ColorData) object;
CustomColorUndoable undoable = new UndoableManager.CustomColorUndoable(main, customProperty, color.getName());
undoableManager.addUndoable(undoable, true);
} else if (object instanceof Boolean) {
if ((boolean) object) {
projectData.setChangesSaved(false);
CustomColorUndoable undoable = new UndoableManager.CustomColorUndoable(main, customProperty, null);
undoableManager.addUndoable(undoable, true);
rootTable.refreshStyleProperties(true);
} else {
pressedCancel = true;
boolean hasColor = false;
for (ColorData color : jsonData.getColors()) {
if (color.getName().equals(customProperty.getValue())) {
hasColor = true;
break;
}
}
if (!hasColor) {
projectData.setChangesSaved(false);
customProperty.setValue(null);
rootTable.refreshStyleProperties(true);
}
}
}
}
if (listener != null) {
if (object instanceof ColorData) {
listener.handle((ColorData) object, pressedCancel);
} else {
listener.handle(null, pressedCancel);
}
}
}
Aggregations