geoportal-data-entry-app/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java

48 lines
1.1 KiB
Java

package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor;
import com.google.gwt.core.client.JavaScriptObject;
public class MyJSONEditor extends JavaScriptObject {
// 6131f0d902ad3d2580412d14
protected MyJSONEditor() {
}
public static native MyJSONEditor init(String divID) /*-{
var container = $doc.getElementById(divID);
var options = {
modes : ['code','tree'],
search: true,
onError : function(error) {
console.log("MyJSONEditor error: " + error)
}
};
console.log("container is: " + container);
return new $wnd.JSONEditor(container, options);
}-*/;
public final native void set(String json) /*-{
var toJSONObject = JSON.parse(json);
// set json
console.log("displayng JSON: " + toJSONObject);
this.set(toJSONObject);
this.refresh();
}-*/;
public final native void get() /*-{
this.get();
}-*/;
public final native void onError() /*-{
this.onError(error);
}-*/;
public final native void setMode(String mode) /*-{
this.setMode(mode);
}-*/;
public final native void setName(String rootName) /*-{
this.setName(rootName);
}-*/;
}