public void preserveValues(final Widget widget) {
   JITVisualizationWidget vWidget = (JITVisualizationWidget) widget;
   ControlLCAUtil.preserveValues(vWidget);
   IWidgetAdapter adapter = WidgetUtil.getAdapter(vWidget);
   adapter.preserve(PROP_VISIBLE, String.valueOf(vWidget.isVisible()));
   adapter.preserve(WIDGET_DATA, new JSVar(vWidget.getJSONData()));
   // only needed for custom variants (theming)
   WidgetLCAUtil.preserveCustomVariant(vWidget);
 }
 /**
  * Respond to selection events, set the value of selectedItem on the widget Java object, and
  * broadcast a SWT.Selection event to any listeners
  */
 public void readData(final Widget widget) {
   if (widget == null) return;
   JITVisualizationWidget visWidget = (JITVisualizationWidget) widget;
   String selectedNode = WidgetLCAUtil.readPropertyValue(visWidget, "selectedNode");
   if (selectedNode != null) {
     visWidget.setData("selectedNode", selectedNode);
     ControlLCAUtil.processSelection(visWidget, null, true);
   }
 }
  public void renderChanges(final Widget widget) throws IOException {
    JITVisualizationWidget vWidget = (JITVisualizationWidget) widget;
    JSWriter writer = JSWriter.getWriterFor(vWidget);
    writer.set(PROP_VISIBLE, PROP_VISIBLE, String.valueOf(vWidget.isVisible()));
    // We compare the JSON text directly because JSVar does not override Object.equals();
    IWidgetAdapter adapter = WidgetUtil.getAdapter(vWidget);
    JSVar oldValue = (JSVar) adapter.getPreserved(WIDGET_DATA);
    String jsonData = vWidget.getJSONData();
    if (jsonData != null && (oldValue == null || !jsonData.equals(oldValue.toString()))) {
      writer.set(WIDGET_DATA, WIDGET_DATA, new JSVar(jsonData));
    }
    ControlLCAUtil.writeChanges(vWidget);

    WidgetCommandQueue cmdQueue = (WidgetCommandQueue) vWidget.getAdapter(WidgetCommandQueue.class);
    if (cmdQueue != null) {
      while (cmdQueue.peek() != null) {
        Object[] functionCall = (Object[]) cmdQueue.poll();
        writer.call((String) functionCall[0], (Object[]) functionCall[1]);
      }
    }
  }