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 e8f35ef..41a5c00 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 @@ -28,8 +28,6 @@ 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; @@ -41,14 +39,10 @@ import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; 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; @@ -66,9 +60,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 static final String LISTVIEWWIDTH="250px"; private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); - + protected String headingTitle; protected HashMap tabularResourcePropertiesMap; protected VerticalLayoutContainer vl; @@ -108,6 +102,8 @@ public class TabularResourceProperties extends FramedPanel { protected TextButton saveButton; protected TextButton validationsButton; + protected ArrayList licencesList; + public TabularResourceProperties(String name, EventBus eventBus) { super(); setId(name); @@ -118,11 +114,12 @@ public class TabularResourceProperties extends FramedPanel { vl.setScrollMode(ScrollMode.AUTO); vl.setAdjustForScroll(true); - initInformation(); - this.add(vl); + retrieveLicencesList(); } - + + + public void addTabularResource() { trFieldSet = new FieldSet(); trFieldSet.setHeadingText("Tabular Resource"); @@ -181,47 +178,16 @@ public class TabularResourceProperties extends FramedPanel { LicenceDataPropertiesCombo propsLicenceData = GWT .create(LicenceDataPropertiesCombo.class); storeCombo = new ListStore(propsLicenceData.id()); + storeCombo.addAll(licencesList); - 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.setWidth(191); + propsLicenceData.licence()); + comboLicences.setMinListWidth(250); comboLicences.setEditable(false); comboLicences.setTypeAhead(false); comboLicences.setTriggerAction(TriggerAction.ALL); - + Log.trace("Combo Licence created"); // / @@ -309,11 +275,10 @@ public class TabularResourceProperties extends FramedPanel { new Margins(2))); vl.add(trFieldSet); - + add(vl); } - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + protected void retrieveLicencesList() { TDGWTServiceAsync.INSTANCE .getLicences(new AsyncCallback>() { @@ -327,14 +292,12 @@ public class TabularResourceProperties extends FramedPanel { 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)); - + Log.trace("loaded " + result.size() + " LicenceData"); + licencesList = result; + initInformation(); } }); @@ -385,15 +348,24 @@ 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 - * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * */ -public interface LicenceDataPropertiesCombo extends - PropertyAccess { - +public interface LicenceDataPropertiesCombo extends PropertyAccess { + @Path("id") ModelKeyProvider id(); - + LabelProvider licence(); - + + @Path("licence") + ValueProvider licenceValueProvider(); } \ No newline at end of file