Added Licences
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-extractcodelist-widget@99416 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b7c0c20b3d
commit
e7bfcb4ded
|
@ -1,18 +1,43 @@
|
|||
package org.gcube.portlets.user.td.extractcodelistwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.extractcodelistwidget.client.licence.LicenceDataPropertiesCombo;
|
||||
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.extract.ExtractCodelistSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||
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.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
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.i18n.client.DateTimeFormat;
|
||||
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.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.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.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;
|
||||
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||
|
@ -25,7 +50,9 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
|||
*
|
||||
*/
|
||||
public class ExtractCodelistDetailsCard extends WizardCard {
|
||||
protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
protected final String TABLEDETAILPANELWIDTH = "100%";
|
||||
protected final String TABLEDETAILPANELHEIGHT = "100%";
|
||||
protected final String FORMWIDTH = "538px";
|
||||
|
@ -39,8 +66,15 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
protected TextField name;
|
||||
protected TextArea description;
|
||||
protected TextArea rights;
|
||||
protected DateField validFrom;
|
||||
protected DateField validUntilTo;
|
||||
|
||||
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
|
||||
protected ComboBox<LicenceData> comboLicences;
|
||||
|
||||
protected TabResource detail = new TabResource();
|
||||
|
||||
|
||||
public ExtractCodelistDetailsCard(final ExtractCodelistSession extractCodelistSession) {
|
||||
super("Codelist Detail", "");
|
||||
|
@ -84,6 +118,62 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
rights.setEmptyText("Enter rights...");
|
||||
rights.setAllowBlank(false);
|
||||
p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1));
|
||||
|
||||
validFrom = new DateField();
|
||||
validFrom.setValue(new Date());
|
||||
p.add(new FieldLabel(validFrom, "Valid From"), new VerticalLayoutData(
|
||||
1, -1));
|
||||
|
||||
validUntilTo = new DateField();
|
||||
p.add(new FieldLabel(validUntilTo, "Valid Until To"),
|
||||
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);
|
||||
|
||||
|
@ -92,6 +182,38 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
}
|
||||
|
||||
|
||||
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
|
||||
public void setup() {
|
||||
Command sayNextCard = new Command() {
|
||||
|
@ -158,7 +280,36 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
detail.setName(name.getCurrentValue());
|
||||
detail.setDescription(description.getCurrentValue());
|
||||
detail.setRight(rights.getCurrentValue());
|
||||
|
||||
Date vFrom = validFrom.getCurrentValue();
|
||||
if (vFrom == null) {
|
||||
Log.debug("Valid From is null");
|
||||
} else {
|
||||
try {
|
||||
detail.setValidFrom(sdf.format(vFrom));
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error parsing Valid From "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Date vUntilTo = validUntilTo.getCurrentValue();
|
||||
if (vUntilTo == null) {
|
||||
Log.debug("Valid Until To is null");
|
||||
} else {
|
||||
try {
|
||||
detail.setValidUntilTo(sdf.format(vUntilTo));
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error parsing Valid Until To "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if(comboLicences.getCurrentValue()!=null&& comboLicences.getCurrentValue().getLicence()!=null){
|
||||
detail.setLicence(comboLicences.getCurrentValue().getLicence());
|
||||
}
|
||||
|
||||
|
||||
extractCodelistSession.setTabResource(detail);
|
||||
|
||||
ExtractCodelistOperationInProgressCard csvOperationInProgressCard = new ExtractCodelistOperationInProgressCard(
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.portlets.user.td.extractcodelistwidget.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