Added Automatically Attach codelist
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-extractcodelist-widget@111502 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8609c9db41
commit
76f530a8d9
|
@ -5,9 +5,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
|||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||
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;
|
||||
|
@ -16,7 +17,10 @@ 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.Radio;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.tips.ToolTip;
|
||||
import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -25,31 +29,30 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
|||
*
|
||||
*/
|
||||
public class ExtractCodelistDetailsCard extends WizardCard {
|
||||
protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
//private static DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
protected final String TABLEDETAILPANELWIDTH = "100%";
|
||||
protected final String TABLEDETAILPANELHEIGHT = "100%";
|
||||
protected final String FORMWIDTH = "538px";
|
||||
|
||||
protected ExtractCodelistSession extractCodelistSession;
|
||||
protected ExtractCodelistDetailsCard thisCard;
|
||||
|
||||
protected VerticalLayoutContainer p;
|
||||
protected VerticalPanel tableDetailPanel;
|
||||
|
||||
protected TextField name;
|
||||
/*protected TextArea description;
|
||||
protected TextArea rights;
|
||||
protected DateField validFrom;
|
||||
protected DateField validUntilTo;
|
||||
private static final String TABLEDETAILPANELWIDTH = "100%";
|
||||
private static final String TABLEDETAILPANELHEIGHT = "100%";
|
||||
private static final String FORMWIDTH = "538px";
|
||||
|
||||
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
|
||||
protected ComboBox<LicenceData> comboLicences;*/
|
||||
private static final int LABEL_WIDTH = 0;
|
||||
|
||||
protected TabResource detail;
|
||||
|
||||
private static final int LABEL_PAD_WIDTH = 0;
|
||||
|
||||
private ExtractCodelistSession extractCodelistSession;
|
||||
private ExtractCodelistDetailsCard thisCard;
|
||||
|
||||
private VerticalLayoutContainer p;
|
||||
private VerticalPanel tableDetailPanel;
|
||||
|
||||
private TextField name;
|
||||
private Radio automaticallyAttachTrue;
|
||||
private Radio automaticallyAttachFalse;
|
||||
|
||||
private TabResource detail;
|
||||
|
||||
public ExtractCodelistDetailsCard(final ExtractCodelistSession extractCodelistSession) {
|
||||
super("Codelist Detail", "");
|
||||
|
@ -81,117 +84,38 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
name.setAllowBlank(false);
|
||||
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
|
||||
|
||||
/*
|
||||
description = new TextArea();
|
||||
description.setAllowBlank(false);
|
||||
description.setEmptyText("Enter a description...");
|
||||
description.setValue("File CSV");
|
||||
description.setAllowBlank(false);
|
||||
p.add(new FieldLabel(description, "Description"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
rights = new TextArea();
|
||||
rights.setEmptyText("Enter rights...");
|
||||
rights.setAllowBlank(false);
|
||||
p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1));
|
||||
///
|
||||
automaticallyAttachTrue = new Radio();
|
||||
automaticallyAttachTrue.setBoxLabel("True");
|
||||
automaticallyAttachTrue.setValue(true);
|
||||
|
||||
validFrom = new DateField();
|
||||
validFrom.setValue(new Date());
|
||||
p.add(new FieldLabel(validFrom, "Valid From"), new VerticalLayoutData(
|
||||
1, -1));
|
||||
automaticallyAttachFalse = new Radio();
|
||||
automaticallyAttachFalse.setBoxLabel("False");
|
||||
|
||||
validUntilTo = new DateField();
|
||||
p.add(new FieldLabel(validUntilTo, "Valid Until To"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
ToggleGroup automticallyAttachGroup = new ToggleGroup();
|
||||
automticallyAttachGroup.add(automaticallyAttachTrue);
|
||||
automticallyAttachGroup.add(automaticallyAttachFalse);
|
||||
|
||||
// Combo Licences
|
||||
LicenceDataPropertiesCombo propsLicenceData = GWT
|
||||
.create(LicenceDataPropertiesCombo.class);
|
||||
ListStore<LicenceData> storeCombo = new ListStore<LicenceData>(
|
||||
propsLicenceData.id());
|
||||
HorizontalPanel automaticallyAttachPanel = new HorizontalPanel();
|
||||
automaticallyAttachPanel.add(automaticallyAttachTrue);
|
||||
automaticallyAttachPanel.add(automaticallyAttachFalse);
|
||||
|
||||
Log.debug("StoreCombo created");
|
||||
new ToolTip(automaticallyAttachPanel, new ToolTipConfig(
|
||||
"Automatically attach the generated codelist"));
|
||||
FieldLabel fieldViewColumns=new FieldLabel(automaticallyAttachPanel, "Automatically Attach");
|
||||
fieldViewColumns.setLabelWidth(LABEL_WIDTH);
|
||||
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
|
||||
p.add(fieldViewColumns, new VerticalLayoutData(1, -1));
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
comboLicences.setEditable(false);
|
||||
comboLicences.setTypeAhead(false);
|
||||
comboLicences.setTriggerAction(TriggerAction.ALL);
|
||||
Log.trace("Combo Licence created");
|
||||
|
||||
// /
|
||||
p.add(new FieldLabel(comboLicences, "Licence"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
*/
|
||||
tableDetailPanel.add(form);
|
||||
|
||||
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
|
||||
public void setup() {
|
||||
|
@ -255,45 +179,22 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean getAutomaticallyAttach() {
|
||||
if(automaticallyAttachTrue.getValue()){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void goNext() {
|
||||
try {
|
||||
detail= new TabResource();
|
||||
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
|
||||
&& !comboLicences.getCurrentValue().getLicence().isEmpty()){
|
||||
detail.setLicence(comboLicences.getCurrentValue().getLicence());
|
||||
}
|
||||
*/
|
||||
|
||||
extractCodelistSession.setTabResource(detail);
|
||||
|
||||
extractCodelistSession.setAutomaticallyAttach(getAutomaticallyAttach());
|
||||
ExtractCodelistOperationInProgressCard extractCodelistOperationInProgressCard = new ExtractCodelistOperationInProgressCard(
|
||||
extractCodelistSession);
|
||||
getWizardWindow().addCard(extractCodelistOperationInProgressCard);
|
||||
|
|
Loading…
Reference in New Issue