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 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.i18n.client.DateTimeFormat;
|
|
||||||
import com.google.gwt.user.client.Command;
|
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.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.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.container.VerticalLayoutContainer;
|
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.event.HideEvent.HideHandler;
|
||||||
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;
|
||||||
|
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.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 {
|
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%";
|
private static final String TABLEDETAILPANELWIDTH = "100%";
|
||||||
protected final String TABLEDETAILPANELHEIGHT = "100%";
|
private static final String TABLEDETAILPANELHEIGHT = "100%";
|
||||||
protected final String FORMWIDTH = "538px";
|
private static final String FORMWIDTH = "538px";
|
||||||
|
|
||||||
protected ExtractCodelistSession extractCodelistSession;
|
|
||||||
protected ExtractCodelistDetailsCard thisCard;
|
|
||||||
|
|
||||||
protected VerticalLayoutContainer p;
|
private static final int LABEL_WIDTH = 0;
|
||||||
protected VerticalPanel tableDetailPanel;
|
|
||||||
|
|
||||||
protected TextField name;
|
|
||||||
/*protected TextArea description;
|
|
||||||
protected TextArea rights;
|
|
||||||
protected DateField validFrom;
|
|
||||||
protected DateField validUntilTo;
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
|
private TabResource detail;
|
||||||
protected ComboBox<LicenceData> comboLicences;*/
|
|
||||||
|
|
||||||
protected TabResource detail;
|
|
||||||
|
|
||||||
|
|
||||||
public ExtractCodelistDetailsCard(final ExtractCodelistSession extractCodelistSession) {
|
public ExtractCodelistDetailsCard(final ExtractCodelistSession extractCodelistSession) {
|
||||||
super("Codelist Detail", "");
|
super("Codelist Detail", "");
|
||||||
|
@ -80,118 +83,39 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
||||||
name.setEmptyText("Enter a name...");
|
name.setEmptyText("Enter a name...");
|
||||||
name.setAllowBlank(false);
|
name.setAllowBlank(false);
|
||||||
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
|
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));
|
|
||||||
|
|
||||||
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));
|
automaticallyAttachTrue = new Radio();
|
||||||
Log.trace("LoaderCombo created");
|
automaticallyAttachTrue.setBoxLabel("True");
|
||||||
|
automaticallyAttachTrue.setValue(true);
|
||||||
|
|
||||||
comboLicences = new ComboBox<LicenceData>(storeCombo,
|
automaticallyAttachFalse = new Radio();
|
||||||
propsLicenceData.licence()) {
|
automaticallyAttachFalse.setBoxLabel("False");
|
||||||
|
|
||||||
protected void onAfterFirstAttach() {
|
ToggleGroup automticallyAttachGroup = new ToggleGroup();
|
||||||
super.onAfterFirstAttach();
|
automticallyAttachGroup.add(automaticallyAttachTrue);
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
automticallyAttachGroup.add(automaticallyAttachFalse);
|
||||||
public void execute() {
|
|
||||||
loader.load();
|
HorizontalPanel automaticallyAttachPanel = new HorizontalPanel();
|
||||||
}
|
automaticallyAttachPanel.add(automaticallyAttachTrue);
|
||||||
});
|
automaticallyAttachPanel.add(automaticallyAttachFalse);
|
||||||
}
|
|
||||||
};
|
new ToolTip(automaticallyAttachPanel, new ToolTipConfig(
|
||||||
comboLicences.setEditable(false);
|
"Automatically attach the generated codelist"));
|
||||||
comboLicences.setTypeAhead(false);
|
FieldLabel fieldViewColumns=new FieldLabel(automaticallyAttachPanel, "Automatically Attach");
|
||||||
comboLicences.setTriggerAction(TriggerAction.ALL);
|
fieldViewColumns.setLabelWidth(LABEL_WIDTH);
|
||||||
Log.trace("Combo Licence created");
|
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
|
||||||
|
p.add(fieldViewColumns, new VerticalLayoutData(1, -1));
|
||||||
// /
|
|
||||||
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() {
|
||||||
|
@ -255,45 +179,22 @@ public class ExtractCodelistDetailsCard extends WizardCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean getAutomaticallyAttach() {
|
||||||
|
if(automaticallyAttachTrue.getValue()){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void goNext() {
|
protected void goNext() {
|
||||||
try {
|
try {
|
||||||
detail= new TabResource();
|
detail= new TabResource();
|
||||||
detail.setName(name.getCurrentValue());
|
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.setTabResource(detail);
|
||||||
|
extractCodelistSession.setAutomaticallyAttach(getAutomaticallyAttach());
|
||||||
ExtractCodelistOperationInProgressCard extractCodelistOperationInProgressCard = new ExtractCodelistOperationInProgressCard(
|
ExtractCodelistOperationInProgressCard extractCodelistOperationInProgressCard = new ExtractCodelistOperationInProgressCard(
|
||||||
extractCodelistSession);
|
extractCodelistSession);
|
||||||
getWizardWindow().addCard(extractCodelistOperationInProgressCard);
|
getWizardWindow().addCard(extractCodelistOperationInProgressCard);
|
||||||
|
|
Loading…
Reference in New Issue