Added Licences
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@99418 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
56dfeca9e1
commit
66d29e9aaf
|
@ -3,17 +3,36 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.sdmximportwidget.client;
|
package org.gcube.portlets.user.td.sdmximportwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
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.sdmx.SDMXImportSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.sdmximportwidget.client.licence.LicenceDataPropertiesCombo;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
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.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.user.client.Command;
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
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.FramedPanel;
|
||||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
@ -21,6 +40,7 @@ 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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
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.event.HideEvent.HideHandler;
|
||||||
|
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.DateField;
|
||||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
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.FieldSet;
|
||||||
|
@ -57,7 +77,9 @@ public class SDMXTableDetailCard extends WizardCard {
|
||||||
|
|
||||||
protected TextButton checkButton;
|
protected TextButton checkButton;
|
||||||
|
|
||||||
// protected ComboBox<Agencies> combo=null;
|
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
|
||||||
|
protected ComboBox<LicenceData> comboLicences;
|
||||||
|
|
||||||
|
|
||||||
TabResource detail = new TabResource();
|
TabResource detail = new TabResource();
|
||||||
|
|
||||||
|
@ -121,12 +143,90 @@ public class SDMXTableDetailCard extends WizardCard {
|
||||||
p.add(new FieldLabel(validUntilTo, "Valid Until To"),
|
p.add(new FieldLabel(validUntilTo, "Valid Until To"),
|
||||||
new VerticalLayoutData(1, -1));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
// Combo Licences
|
||||||
|
LicenceDataPropertiesCombo propsLicenceData = GWT
|
||||||
|
.create(LicenceDataPropertiesCombo.class);
|
||||||
|
ListStore<LicenceData> storeCombo = new ListStore<LicenceData>(
|
||||||
|
propsLicenceData.id());
|
||||||
|
|
||||||
|
Log.debug("StoreCombo created");
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<LicenceData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<LicenceData>>() {
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<LicenceData>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loader = new ListLoader<ListLoadConfig, ListLoadResult<LicenceData>>(
|
||||||
|
proxy) {
|
||||||
|
@Override
|
||||||
|
protected ListLoadConfig newLoadConfig() {
|
||||||
|
return (ListLoadConfig) new ListLoadConfigBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, LicenceData, ListLoadResult<LicenceData>>(
|
||||||
|
storeCombo));
|
||||||
|
Log.trace("LoaderCombo created");
|
||||||
|
|
||||||
|
comboLicences = new ComboBox<LicenceData>(storeCombo,
|
||||||
|
propsLicenceData.licence()) {
|
||||||
|
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
public void execute() {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Log.trace("Combo Licence created");
|
||||||
|
|
||||||
|
// /
|
||||||
|
p.add(new FieldLabel(comboLicences, "Licence"),
|
||||||
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
tableDetailPanel.add(form);
|
tableDetailPanel.add(form);
|
||||||
|
|
||||||
setContent(tableDetailPanel);
|
setContent(tableDetailPanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<LicenceData>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getLicences(new AsyncCallback<ArrayList<LicenceData>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
getEventBus()
|
||||||
|
.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<LicenceData> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " ColumnData");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<LicenceData>(
|
||||||
|
result));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Command sayNextCard = new Command() {
|
Command sayNextCard = new Command() {
|
||||||
|
@ -243,6 +343,10 @@ public class SDMXTableDetailCard extends WizardCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(comboLicences.getCurrentValue()!=null&& comboLicences.getCurrentValue().getLicence()!=null){
|
||||||
|
detail.setLicence(comboLicences.getCurrentValue().getLicence());
|
||||||
|
}
|
||||||
|
|
||||||
importSession.setTabResource(detail);
|
importSession.setTabResource(detail);
|
||||||
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
||||||
importSession);
|
importSession);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmximportwidget.client.licence;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface LicenceDataPropertiesCombo extends
|
||||||
|
PropertyAccess<LicenceData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<LicenceData> id();
|
||||||
|
|
||||||
|
LabelProvider<LicenceData> licence();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue