Adds support for loading a check box from JSON.
@@ -3,6 +3,8 @@ package com.valkryst.VTerminal.builder.component;
import com.valkryst.VTerminal.component.CheckBox;
import com.valkryst.VTerminal.misc.ColorFunctions;
import lombok.*;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
import java.awt.Color;
@@ -61,4 +63,77 @@ public class CheckBoxBuilder extends ComponentBuilder<CheckBox> {
backgroundColor_checked = backgroundColor_normal;
foregroundColor_checked = new Color(0xFFFFD72D, true);
}
+
+ @Override
+ public void parseJSON(final JSONObject jsonObject) {
+ super.parseJSON(jsonObject);
+
+
+ final String text = (String) jsonObject.get("text");
+
+ final Character emptyBoxChar = (Character) jsonObject.get("emptyBoxChar");
+ final Character checkedBoxChar = (Character) jsonObject.get("checkedBoxChar");
+
+ final Boolean isChecked = (Boolean) jsonObject.get("isChecked");
+
+ final Color backgroundColor_normal = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_normal"));
+ final Color foregroundColor_normal = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_normal"));
+
+ final Color backgroundColor_hover = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_hover"));
+ final Color foregroundColor_hover = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_hover"));
+
+ final Color backgroundColor_checked = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_checked"));
+ final Color foregroundColor_checked = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_checked"));
+
+
+ if (text != null) {
+ this.text = text;
+ }
+
+
+
+ if (emptyBoxChar != null) {
+ this.emptyBoxChar = emptyBoxChar;
+ }
+
+ if (checkedBoxChar != null) {
+ this.checkedBoxChar = checkedBoxChar;
+ }
+
+
+
+ if (isChecked != null) {
+ this.isChecked = isChecked;
+ }
+
+
+
+ if (backgroundColor_normal != null) {
+ this.backgroundColor_normal = backgroundColor_normal;
+ }
+
+ if (foregroundColor_normal != null) {
+ this.foregroundColor_normal = foregroundColor_normal;
+ }
+
+
+
+ if (backgroundColor_hover != null) {
+ this.backgroundColor_hover = backgroundColor_hover;
+ }
+
+ if (foregroundColor_hover != null) {
+ this.foregroundColor_hover = foregroundColor_hover;
+ }
+
+
+
+ if (backgroundColor_checked != null) {
+ this.backgroundColor_checked = backgroundColor_checked;
+ }
+
+ if (foregroundColor_checked != null) {
+ this.foregroundColor_checked = foregroundColor_checked;
+ }
+ }
}
