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.TabResource; import com.allen_sauer.gwt.log.client.Log; 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 tabularResourcePropertiesMap; protected VerticalLayoutContainer vl; protected EventBus eventBus; // protected TDInformationServiceAsync service = GWT // .create(TDInformationService.class); public TabularResourceProperties(String name, EventBus eventBus) { super(); setId(name); this.eventBus = eventBus; TDGWTServiceAsync.INSTANCE .getTabResourceInformation(new AsyncCallback() { @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(); } }); 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); } public void addTabularResource(TabResource tabResource) { FieldSet fieldSet = new FieldSet(); fieldSet.setHeadingText("Tabular Resource"); fieldSet.setCollapsible(true); // form.add(fieldSet); VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer(); fieldSet.add(layoutTabularResource); // TextField idField = new TextField(); // idField.setReadOnly(true); // idField.setValue(String.valueOf(tabResource.getId())); // layoutTabularResource.add(new FieldLabel(idField, "Id"), new // VerticalLayoutData(1, -1)); TextField nameField = new TextField(); nameField.setReadOnly(true); nameField.setValue(tabResource.getName()); layoutTabularResource.add(new FieldLabel(nameField, "Name"), new VerticalLayoutData(1, -1)); TextArea descriptionField = new TextArea(); descriptionField.setReadOnly(true); descriptionField.setValue(tabResource.getDescription()); layoutTabularResource.add(new FieldLabel(descriptionField, "Description"), new VerticalLayoutData(1, -1)); TextField agencyField = new TextField(); agencyField.setReadOnly(true); agencyField.setValue(tabResource.getAgency()); layoutTabularResource.add(new FieldLabel(agencyField, "Agency"), new VerticalLayoutData(1, -1)); TextField dateField = new TextField(); dateField.setReadOnly(true); dateField.setValue(tabResource.getDate()); layoutTabularResource.add(new FieldLabel(dateField, "Date"), new VerticalLayoutData(1, -1)); TextArea rightField = new TextArea(); rightField.setReadOnly(true); rightField.setValue(tabResource.getRight()); layoutTabularResource.add(new FieldLabel(rightField, "Rights"), new VerticalLayoutData(1, -1)); vl.add(fieldSet); } public void addTable(TabResource tabResource) { FieldSet fieldSet = new FieldSet(); fieldSet.setHeadingText("Table"); fieldSet.setCollapsible(true); // form.add(fieldSet); VerticalLayoutContainer layoutTabularResource = new VerticalLayoutContainer(); fieldSet.add(layoutTabularResource); vl.add(fieldSet); } }