public interface DockNodeContentSerializer
Optional interface for DockNode content that needs to be serialized.
Nodes that implement this interface can save and restore their content state across application sessions. This is useful for editors, property panels, etc. that contain user data that should be persisted.
Example implementation:
public class SerializableTextArea extends TextArea implements DockNodeContentSerializer {
@Override
public JsonObject serializeContent() {
JsonObject data = new JsonObject();
data.addProperty("text", getText());
data.addProperty("caretPosition", getCaretPosition());
return data;
}
@Override
public void deserializeContent(JsonObject data) {
if (data.has("text")) {
setText(data.get("text").getAsString());
}
if (data.has("caretPosition")) {
positionCaret(data.get("caretPosition").getAsInt());
}
}
}
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeContent(com.google.gson.JsonObject data) Deserializes the content state from a JSON object.com.google.gson.JsonObjectSerializes the content state to a JSON object.
-
Method Details
-
serializeContent
com.google.gson.JsonObject serializeContent()Serializes the content state to a JSON object.- Returns:
- JSON object containing the content state, or null if nothing to serialize
-
deserializeContent
void deserializeContent(com.google.gson.JsonObject data) Deserializes the content state from a JSON object.- Parameters:
data- JSON object containing the previously serialized content state
-