49 lines
1.2 KiB
Java
49 lines
1.2 KiB
Java
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor;
|
|
|
|
import com.google.gwt.core.client.JavaScriptObject;
|
|
|
|
public class JSONEditorWrapper extends JavaScriptObject {
|
|
|
|
// 6131f0d902ad3d2580412d14
|
|
|
|
protected JSONEditorWrapper() {
|
|
}
|
|
|
|
public static native JSONEditorWrapper init(String divID) /*-{
|
|
var container = $doc.getElementById(divID);
|
|
var options = {
|
|
modes : ['code','tree'],
|
|
search: true,
|
|
onError : function(error) {
|
|
console.log("JSONEditorWrapper 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 String getText() /*-{
|
|
console.log("this.get(): " +this.getText());
|
|
return this.getText();
|
|
}-*/;
|
|
|
|
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);
|
|
}-*/;
|
|
} |