use of com.ray3k.skincomposer.UndoableManager.CustomFontUndoable in project skin-composer by raeleus.
the class DialogFonts method result.
@Override
protected void result(Object object) {
if (styleProperty != null) {
if (object instanceof FontData) {
main.getProjectData().setChangesSaved(false);
FontData font = (FontData) object;
FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, font.getName());
main.getUndoableManager().addUndoable(undoable, true);
} else if (object instanceof FreeTypeFontData) {
main.getProjectData().setChangesSaved(false);
FreeTypeFontData font = (FreeTypeFontData) object;
FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, font.name);
main.getUndoableManager().addUndoable(undoable, true);
} else if (object instanceof Boolean) {
if ((boolean) object) {
FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, null);
main.getUndoableManager().addUndoable(undoable, true);
main.getProjectData().setChangesSaved(false);
main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + styleProperty.name + "\"");
main.getRootTable().refreshStyleProperties(true);
} else {
boolean hasFont = false;
for (FontData font : main.getJsonData().getFonts()) {
if (font.getName().equals(styleProperty.value)) {
hasFont = true;
break;
}
}
for (FreeTypeFontData font : main.getJsonData().getFreeTypeFonts()) {
if (font.name.equals(styleProperty.value)) {
hasFont = true;
break;
}
}
if (!hasFont) {
styleProperty.value = null;
main.getProjectData().setChangesSaved(false);
main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + styleProperty.name + "\"");
main.getRootTable().refreshStyleProperties(true);
}
}
}
} else if (customProperty != null) {
if (object instanceof FontData) {
main.getProjectData().setChangesSaved(false);
FontData font = (FontData) object;
CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, font.getName());
main.getUndoableManager().addUndoable(undoable, true);
} else if (object instanceof FreeTypeFontData) {
main.getProjectData().setChangesSaved(false);
FreeTypeFontData font = (FreeTypeFontData) object;
CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, font.name);
main.getUndoableManager().addUndoable(undoable, true);
} else if (object instanceof Boolean) {
if ((boolean) object) {
CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, null);
main.getUndoableManager().addUndoable(undoable, true);
main.getProjectData().setChangesSaved(false);
main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + customProperty.getName() + "\"");
main.getRootTable().refreshStyleProperties(true);
} else {
boolean hasFont = false;
for (FontData font : main.getJsonData().getFonts()) {
if (font.getName().equals(customProperty.getValue())) {
hasFont = true;
break;
}
}
if (!hasFont) {
customProperty.setValue(null);
main.getProjectData().setChangesSaved(false);
main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + customProperty.getName() + "\"");
main.getRootTable().refreshStyleProperties(true);
}
}
}
}
if (listener != null) {
listener.handle(null);
}
main.getRootTable().refreshPreview();
}
Aggregations