Added Table

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@85687 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-19 12:06:42 +00:00
parent 208cc427e5
commit 41839e6606
1 changed files with 106 additions and 77 deletions

View File

@ -2,9 +2,10 @@ package org.gcube.portlets.user.td.informationwidget.client;
import java.util.HashMap;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
import org.gcube.portlets.user.td.gwtservice.shared.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.TableData;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -26,74 +27,77 @@ public class TabularResourceProperties extends ContentPanel {
protected HashMap<String, String> tabularResourcePropertiesMap;
protected VerticalLayoutContainer vl;
protected EventBus eventBus;
protected FieldSet fieldSet;
protected FieldSet trFieldSet;
protected FieldSet tableFieldSet;
protected TextField nameField;
protected TextArea descriptionField;
protected TextField agencyField;
protected TextField dateField;
protected TextArea rightField;
protected TextField tableNameField;
protected TextField tableTypeNameField;
public TabularResourceProperties(String name, EventBus eventBus) {
super();
setId(name);
this.eventBus = eventBus;
vl = new VerticalLayoutContainer();
initInformation();
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);
this.add(panel);
}
public void addTabularResource(TabResource tabResource) {
fieldSet = new FieldSet();
fieldSet.setHeadingText("Tabular Resource");
fieldSet.setCollapsible(true);
public void addTabularResource() {
trFieldSet = new FieldSet();
trFieldSet.setHeadingText("Tabular Resource");
trFieldSet.setCollapsible(true);
VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer();
fieldSet.add(layoutTabularResource);
trFieldSet.add(layoutTabularResource);
nameField = new TextField();
nameField.setReadOnly(true);
nameField.setValue(tabResource.getName());
nameField.setValue("");
layoutTabularResource.add(new FieldLabel(nameField, "Name"),
new VerticalLayoutData(1, -1));
descriptionField = new TextArea();
descriptionField.setReadOnly(true);
descriptionField.setValue(tabResource.getDescription());
descriptionField.setValue("");
layoutTabularResource.add(new FieldLabel(descriptionField,
"Description"), new VerticalLayoutData(1, -1));
agencyField = new TextField();
agencyField.setReadOnly(true);
agencyField.setValue(tabResource.getAgency());
agencyField.setValue("");
layoutTabularResource.add(new FieldLabel(agencyField, "Agency"),
new VerticalLayoutData(1, -1));
dateField = new TextField();
dateField.setReadOnly(true);
dateField.setValue(tabResource.getDate());
dateField.setValue("");
layoutTabularResource.add(new FieldLabel(dateField, "Date"),
new VerticalLayoutData(1, -1));
rightField = new TextArea();
rightField.setReadOnly(true);
rightField.setValue(tabResource.getRight());
rightField.setValue("");
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
new VerticalLayoutData(1, -1));
vl.add(fieldSet);
vl.add(trFieldSet);
}
@ -104,80 +108,105 @@ public class TabularResourceProperties extends ContentPanel {
dateField.setValue(tabResource.getDate());
rightField.setValue(tabResource.getRight());
}
public void addTable(TabResource tabResource) {
FieldSet fieldSet = new FieldSet();
fieldSet.setHeadingText("Table");
fieldSet.setCollapsible(true);
public void addTable() {
tableFieldSet = new FieldSet();
tableFieldSet.setHeadingText("Table");
tableFieldSet.setCollapsible(true);
VerticalLayoutContainer layoutTable = new VerticalLayoutContainer();
tableFieldSet.add(layoutTable);
tableNameField = new TextField();
tableNameField.setReadOnly(true);
tableNameField.setValue("");
layoutTable.add(new FieldLabel(tableNameField, "Name"),
new VerticalLayoutData(1, -1));
VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer();
fieldSet.add(layoutTabularResource);
vl.add(fieldSet);
tableTypeNameField = new TextField();
tableTypeNameField.setReadOnly(true);
tableTypeNameField.setValue("");
layoutTable.add(new FieldLabel(tableTypeNameField, "Type"),
new VerticalLayoutData(1, -1));
vl.add(tableFieldSet);
}
public void update(){
protected void updateTable(TableData tableData) {
tableNameField.setValue(tableData.getName());
tableTypeNameField.setValue(tableData.getTypeName());
}
public void update() {
TDGWTServiceAsync.INSTANCE
.getTabResourceInformation(new AsyncCallback<TabResource>() {
@Override
public void onSuccess(TabResource result) {
updateTabularResource(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() {
.getTabResourceInformation(new AsyncCallback<TabResource>() {
@Override
public void onHide(HideEvent event) {
//
public void onSuccess(TabResource result) {
updateTabularResource(result);
Log.info("Retrived TR:" + result.getId());
getLastTable(result.getTrId());
}
@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();
}
});
d.show();
}
});
}
public void initInformation(){
protected void getLastTable(TRId trId) {
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() {
.getLastTable(trId,new AsyncCallback<TableData>() {
@Override
public void onHide(HideEvent event) {
//
public void onSuccess(TableData result) {
updateTable(result);
Log.info("Retrived LastTable:" + result.getName());
}
@Override
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
"Error retrienving Last Table: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
@Override
public void onHide(HideEvent event) {
//
}
});
d.show();
}
});
d.show();
}
});
}
public void initInformation() {
addTabularResource();
addTable();
update();
}
}