2013-10-24 16:07:25 +02:00
|
|
|
package org.gcube.portlets.user.td.informationwidget.client;
|
2013-10-24 12:16:53 +02:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2013-10-25 20:11:06 +02:00
|
|
|
|
2013-10-24 16:07:25 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.TabResource;
|
|
|
|
|
2013-10-24 18:40:24 +02:00
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
2013-10-24 12:16:53 +02:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
|
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
|
|
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
|
|
|
|
|
|
|
public class TabularResourceProperties extends ContentPanel {
|
|
|
|
protected String headingTitle;
|
|
|
|
protected HashMap<String, String> tabularResourcePropertiesMap;
|
|
|
|
protected VerticalLayoutContainer vl;
|
|
|
|
protected EventBus eventBus;
|
2013-10-28 09:36:49 +01:00
|
|
|
|
|
|
|
protected FieldSet fieldSet;
|
|
|
|
|
|
|
|
protected TextField nameField;
|
|
|
|
protected TextArea descriptionField;
|
|
|
|
protected TextField agencyField;
|
|
|
|
protected TextField dateField;
|
|
|
|
protected TextArea rightField;
|
2013-10-24 12:16:53 +02:00
|
|
|
|
|
|
|
public TabularResourceProperties(String name, EventBus eventBus) {
|
|
|
|
super();
|
|
|
|
setId(name);
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
initInformation();
|
2013-10-24 12:16:53 +02:00
|
|
|
|
|
|
|
FramedPanel panel = new FramedPanel();
|
|
|
|
panel.setHeaderVisible(false);
|
|
|
|
panel.setBodyStyle("background: none; padding: 2px; min-width:310px;");
|
|
|
|
|
|
|
|
vl = new VerticalLayoutContainer();
|
|
|
|
panel.add(vl);
|
|
|
|
this.add(panel);
|
|
|
|
|
2013-10-25 20:11:06 +02:00
|
|
|
|
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
public void addTabularResource(TabResource tabResource) {
|
2013-10-28 09:36:49 +01:00
|
|
|
fieldSet = new FieldSet();
|
2013-10-24 12:16:53 +02:00
|
|
|
fieldSet.setHeadingText("Tabular Resource");
|
|
|
|
fieldSet.setCollapsible(true);
|
2013-10-28 09:36:49 +01:00
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer();
|
|
|
|
fieldSet.add(layoutTabularResource);
|
2013-10-28 09:36:49 +01:00
|
|
|
|
|
|
|
nameField = new TextField();
|
2013-10-24 12:16:53 +02:00
|
|
|
nameField.setReadOnly(true);
|
|
|
|
nameField.setValue(tabResource.getName());
|
|
|
|
layoutTabularResource.add(new FieldLabel(nameField, "Name"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
descriptionField = new TextArea();
|
2013-10-24 12:16:53 +02:00
|
|
|
descriptionField.setReadOnly(true);
|
|
|
|
descriptionField.setValue(tabResource.getDescription());
|
|
|
|
layoutTabularResource.add(new FieldLabel(descriptionField,
|
|
|
|
"Description"), new VerticalLayoutData(1, -1));
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
agencyField = new TextField();
|
2013-10-24 12:16:53 +02:00
|
|
|
agencyField.setReadOnly(true);
|
|
|
|
agencyField.setValue(tabResource.getAgency());
|
|
|
|
layoutTabularResource.add(new FieldLabel(agencyField, "Agency"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
dateField = new TextField();
|
2013-10-24 12:16:53 +02:00
|
|
|
dateField.setReadOnly(true);
|
|
|
|
dateField.setValue(tabResource.getDate());
|
|
|
|
layoutTabularResource.add(new FieldLabel(dateField, "Date"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
rightField = new TextArea();
|
2013-10-24 12:16:53 +02:00
|
|
|
rightField.setReadOnly(true);
|
|
|
|
rightField.setValue(tabResource.getRight());
|
|
|
|
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
|
|
|
|
|
|
|
vl.add(fieldSet);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
protected void updateTabularResource(TabResource tabResource) {
|
|
|
|
nameField.setValue(tabResource.getName());
|
|
|
|
descriptionField.setValue(tabResource.getDescription());
|
|
|
|
agencyField.setValue(tabResource.getAgency());
|
|
|
|
dateField.setValue(tabResource.getDate());
|
|
|
|
rightField.setValue(tabResource.getRight());
|
|
|
|
}
|
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
public void addTable(TabResource tabResource) {
|
|
|
|
FieldSet fieldSet = new FieldSet();
|
|
|
|
fieldSet.setHeadingText("Table");
|
|
|
|
fieldSet.setCollapsible(true);
|
2013-10-28 09:36:49 +01:00
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
|
|
|
|
VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer();
|
|
|
|
fieldSet.add(layoutTabularResource);
|
|
|
|
|
|
|
|
vl.add(fieldSet);
|
|
|
|
|
|
|
|
}
|
2013-10-25 20:11:06 +02:00
|
|
|
|
|
|
|
public void update(){
|
|
|
|
TDGWTServiceAsync.INSTANCE
|
|
|
|
.getTabResourceInformation(new AsyncCallback<TabResource>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(TabResource result) {
|
2013-10-28 09:36:49 +01:00
|
|
|
updateTabularResource(result);
|
2013-10-25 20:11:06 +02:00
|
|
|
Log.info("Retrived TR:" + result.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
AlertMessageBox d = new AlertMessageBox("Error",
|
|
|
|
"Error retrienving properties: "
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
d.addHideHandler(new HideHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onHide(HideEvent event) {
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
d.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
2013-10-24 12:16:53 +02:00
|
|
|
|
2013-10-28 09:36:49 +01:00
|
|
|
public void initInformation(){
|
|
|
|
TDGWTServiceAsync.INSTANCE
|
|
|
|
.getTabResourceInformation(new AsyncCallback<TabResource>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(TabResource result) {
|
|
|
|
addTabularResource(result);
|
|
|
|
Log.info("Retrived TR:" + result.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
AlertMessageBox d = new AlertMessageBox("Error",
|
|
|
|
"Error retrienving properties: "
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
d.addHideHandler(new HideHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onHide(HideEvent event) {
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
d.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-24 12:16:53 +02:00
|
|
|
}
|