diff --git a/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java b/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java index fb8a812..7212870 100644 --- a/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java +++ b/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java @@ -3,14 +3,17 @@ package org.gcube.portlets.user.td.informationwidget.client; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData; import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.informationwidget.client.custom.IconButton; +import org.gcube.portlets.user.td.informationwidget.client.licence.LicenceDataPropertiesCombo; import org.gcube.portlets.user.td.informationwidget.client.resources.ResourceBundle; import org.gcube.portlets.user.td.informationwidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.metadatawidget.client.TRMetadataAccordionPanel; @@ -24,6 +27,9 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.WidgetRequestTyp import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; @@ -34,6 +40,14 @@ import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.data.client.loader.RpcProxy; +import com.sencha.gxt.data.shared.ListStore; +import com.sencha.gxt.data.shared.loader.ListLoadConfig; +import com.sencha.gxt.data.shared.loader.ListLoadConfigBean; +import com.sencha.gxt.data.shared.loader.ListLoadResult; +import com.sencha.gxt.data.shared.loader.ListLoadResultBean; +import com.sencha.gxt.data.shared.loader.ListLoader; +import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding; import com.sencha.gxt.widget.core.client.FramedPanel; import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; @@ -43,6 +57,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.form.CheckBox; +import com.sencha.gxt.widget.core.client.form.ComboBox; import com.sencha.gxt.widget.core.client.form.DateField; import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.FieldSet; @@ -50,8 +65,9 @@ import com.sencha.gxt.widget.core.client.form.TextArea; import com.sencha.gxt.widget.core.client.form.TextField; public class TabularResourceProperties extends FramedPanel { + private static final String LISTVIEWWIDTH="250px"; private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); - + protected String headingTitle; protected HashMap tabularResourcePropertiesMap; protected VerticalLayoutContainer vl; @@ -73,6 +89,10 @@ public class TabularResourceProperties extends FramedPanel { protected CheckBox validField; protected CheckBox finalizedField; + protected ListLoader> loader; + protected ComboBox comboLicences; + protected ListStore storeCombo; + protected TextField typeField; protected IconButton btnShare; @@ -155,6 +175,54 @@ public class TabularResourceProperties extends FramedPanel { layoutTabularResource.add(new FieldLabel(validUntilToField, "Valid Until To"), new VerticalLayoutData(1, -1)); + // // + // Combo Licences + LicenceDataPropertiesCombo propsLicenceData = GWT + .create(LicenceDataPropertiesCombo.class); + storeCombo = new ListStore(propsLicenceData.id()); + + Log.debug("StoreCombo created"); + + RpcProxy> proxy = new RpcProxy>() { + + public void load(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + loadData(loadConfig, callback); + } + }; + + loader = new ListLoader>( + proxy) { + @Override + protected ListLoadConfig newLoadConfig() { + return (ListLoadConfig) new ListLoadConfigBean(); + } + + }; + + loader.addLoadHandler(new LoadResultListStoreBinding>( + storeCombo)); + Log.trace("LoaderCombo created"); + + comboLicences = new ComboBox(storeCombo, + propsLicenceData.licence()) { + + protected void onAfterFirstAttach() { + super.onAfterFirstAttach(); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + public void execute() { + loader.load(); + } + }); + } + }; + comboLicences.getListView().setWidth(LISTVIEWWIDTH); + Log.trace("Combo Licence created"); + + // / + layoutTabularResource.add(new FieldLabel(comboLicences, "Licence"), + new VerticalLayoutData(1, -1)); + // / ownerField = new TextField(); ownerField.setReadOnly(true); ownerField.setValue(""); @@ -239,6 +307,35 @@ public class TabularResourceProperties extends FramedPanel { } + protected void loadData(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + TDGWTServiceAsync.INSTANCE + .getLicences(new AsyncCallback>() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("load combo failure:" + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error retrieving licences."); + } + callback.onFailure(caught); + } + + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " ColumnData"); + callback.onSuccess(new ListLoadResultBean( + result)); + + } + + }); + + } + protected void updateTabularResource(TabResource tabResource) { this.tabResource = tabResource; Log.debug(tabResource.toString()); @@ -279,6 +376,19 @@ public class TabularResourceProperties extends FramedPanel { } } + + if (tabResource.getLicence() != null + && !tabResource.getLicence().isEmpty()) { + List listLicence = storeCombo.getAll(); + for (int i=0; ig.panichi@isti.cnr.it + * + */ +public interface LicenceDataPropertiesCombo extends + PropertyAccess { + + @Path("id") + ModelKeyProvider id(); + + LabelProvider licence(); + + +} \ No newline at end of file