#21990 Integrated with JSONEditor, Improved general CSS
parent
a551e572c5
commit
48d19b6f10
@ -0,0 +1,111 @@
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.MyJSONEditor;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Random;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class EditModeRecord.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 17, 2021
|
||||
*/
|
||||
public class EditModeRecord extends Composite {
|
||||
|
||||
private static EditModeRecordUiBinder uiBinder = GWT.create(EditModeRecordUiBinder.class);
|
||||
|
||||
@UiField
|
||||
FlowPanel rawUpdatePanel;
|
||||
|
||||
@UiField
|
||||
FlowPanel filesUpdatePanel;
|
||||
|
||||
private BaseConcessioneDV selectedConcessione;
|
||||
|
||||
/**
|
||||
* The Interface EditModeRecordUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 17, 2021
|
||||
*/
|
||||
interface EditModeRecordUiBinder extends UiBinder<Widget, EditModeRecord> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new edits the mode record.
|
||||
*
|
||||
* @param selectedConcessione the selected concessione
|
||||
* @param type the type
|
||||
*/
|
||||
public EditModeRecord(BaseConcessioneDV selectedConcessione, RECORD_TYPE type) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.selectedConcessione = selectedConcessione;
|
||||
|
||||
final FlowPanel fp = new FlowPanel();
|
||||
fp.getElement().setId("jsoneditor"+Random.nextInt());
|
||||
fp.setHeight("400px");
|
||||
rawUpdatePanel.add(fp);
|
||||
|
||||
GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), type, new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String jsonData) {
|
||||
GWT.log("Instance JSON Editor with: "+jsonData);
|
||||
//jsonEditor = ExternalLib.instanceJSONEditor(fp.getElement().getId(), jsonData);
|
||||
//String updated = ExternalLib.getUpdatedJSON(jsonEditor);
|
||||
|
||||
//JSONEditor constuctor = new JSONEditor(fp.getElement(),"{}");
|
||||
final MyJSONEditor jsEditor = MyJSONEditor.init(fp.getElement().getId());
|
||||
jsEditor.setName(selectedConcessione.getNome());
|
||||
// JSONValue jsValue = JSONParser.parse(jsonData);
|
||||
// JSONObject extraJSONObject = jsValue.isObject();
|
||||
jsEditor.set(jsonData);
|
||||
|
||||
new Timer() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
jsEditor.setMode("tree");
|
||||
|
||||
}
|
||||
}.schedule(200);
|
||||
|
||||
|
||||
//GWT.log("Updated: "+updated.toString());
|
||||
//org.gcube.portlets.user.geoportaldataentry.client.ui.utils.JSONEditor editor = JE.jsoneditor(fp.getElement(), jsonData);
|
||||
//rawUpdatePanel.add(new Widget(editor));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<ui:style>
|
||||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
</ui:style>
|
||||
|
||||
<g:HTMLPanel>
|
||||
|
||||
<b:TabPanel tabPosition="left" ui:field="tabPanel">
|
||||
<b:Tab icon="PENCIL" active="true" heading="Edit the code"
|
||||
ui:field="tabRawUpdate">
|
||||
<b:Heading size="3">Raw Project Editor</b:Heading>
|
||||
<g:FlowPanel ui:field="rawUpdatePanel">
|
||||
</g:FlowPanel>
|
||||
</b:Tab>
|
||||
<b:Tab icon="UPLOAD_ALT" heading="Update File/s"
|
||||
ui:field="tabUploadFiles">
|
||||
<b:Heading size="3">Update the file/s</b:Heading>
|
||||
<b:Label>By choosing a section (e.g. "RELAZIONE di
|
||||
SCAVO") and
|
||||
uploading new file/s the old one/s will be replaced</b:Label>
|
||||
<g:FlowPanel ui:field="filesUpdatePanel">
|
||||
</g:FlowPanel>
|
||||
</b:Tab>
|
||||
</b:TabPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
@ -0,0 +1,48 @@
|
||||
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);
|
||||
}-*/;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
|
||||
|
||||
/**
|
||||
* The Class ExternalLib.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 17, 2021
|
||||
*/
|
||||
public class ExternalLib {
|
||||
|
||||
/**
|
||||
* To pretty print JSON. calls the externa js lib 'pretty-print-json'
|
||||
*
|
||||
* @param jsonData the json data
|
||||
* @return the string
|
||||
*/
|
||||
public static native String toPrettyPrintJSON(String jsonData)/*-{
|
||||
//console.log(jsonData);
|
||||
var objJSON = JSON.parse(jsonData);
|
||||
return $wnd.prettyPrintJson.toHtml(objJSON);
|
||||
}-*/;
|
||||
}
|
Loading…
Reference in New Issue