Minor updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@86516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2e396928e5
commit
ffe61d9090
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.sdmximportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
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.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -17,9 +17,7 @@ import com.sencha.gxt.widget.core.client.button.TextButton;
|
|||
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.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
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;
|
||||
|
@ -99,50 +97,6 @@ public class SDMXTableDetailCard extends WizardCard {
|
|||
rights.setAllowBlank(false);
|
||||
p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1));
|
||||
|
||||
/*
|
||||
* ListStore<Agencies> agenciesStore = new
|
||||
* ListStore<Agencies>(agenciesProperties.key());
|
||||
*
|
||||
* RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>> proxy = new
|
||||
* RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>>() {
|
||||
*
|
||||
*
|
||||
* public void load(PagingLoadConfig loadConfig, final
|
||||
* AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||
* loadData(loadConfig, callback); } };
|
||||
*
|
||||
*
|
||||
* final PagingLoader<PagingLoadConfig, PagingLoadResult<Agencies>>
|
||||
* loader = new PagingLoader<PagingLoadConfig,
|
||||
* PagingLoadResult<Agencies>>(proxy);
|
||||
*
|
||||
* loader.setRemoteSort(false); loader.addLoadHandler(new
|
||||
* LoadResultListStoreBinding<PagingLoadConfig, Agencies,
|
||||
* PagingLoadResult<Agencies>>(agenciesStore));
|
||||
*
|
||||
* //agenciesStore.addAll(TestData.getStates());
|
||||
*
|
||||
* combo = new ComboBox<Agencies>(agenciesStore,
|
||||
* agenciesProperties.nameLabel());
|
||||
* addHandlersForEventObservation(combo,
|
||||
* agenciesProperties.nameLabel());
|
||||
*
|
||||
* combo.setLoader(loader); combo.setEmptyText("Enter Agency...");
|
||||
* combo.setTriggerAction(TriggerAction.ALL);
|
||||
* combo.setAllowBlank(false); combo.setForceSelection(true);
|
||||
* combo.setVisible(true);
|
||||
*/
|
||||
|
||||
// HorizontalLayoutContainer agenciesSelect= selectAgencies();
|
||||
// p.add(new FieldLabel(combo, "Agencies"), new VerticalLayoutData(1,
|
||||
// -1));
|
||||
|
||||
/*
|
||||
* FieldLabel comboLabel=new FieldLabel(combo, "");
|
||||
* comboLabel.setLabelSeparator(""); p.add(comboLabel, new
|
||||
* VerticalLayoutData(1, -1));
|
||||
*/
|
||||
|
||||
agencyName = new TextField();
|
||||
agencyName.setVisible(true);
|
||||
agencyName.setEmptyText("Enter Agency...");
|
||||
|
@ -151,89 +105,12 @@ public class SDMXTableDetailCard extends WizardCard {
|
|||
agencyNameLabel.setLabelSeparator("");
|
||||
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
|
||||
|
||||
checkButton = new TextButton("Save");
|
||||
checkButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
checkData();
|
||||
}
|
||||
});
|
||||
form.addButton(checkButton);
|
||||
|
||||
tableDetailPanel.add(form);
|
||||
|
||||
setContent(tableDetailPanel);
|
||||
|
||||
}
|
||||
|
||||
protected void checkData() {
|
||||
if (name.getValue() == null || name.getValue().isEmpty()
|
||||
|| !name.isValid() || description.getValue() == null
|
||||
|| description.getValue().isEmpty() || !description.isValid()
|
||||
|| rights.getValue() == null || rights.getValue().isEmpty()
|
||||
|| !rights.isValid() || agencyName.getValue() == null
|
||||
|| agencyName.getValue().isEmpty() || !agencyName.isValid()) {
|
||||
AlertMessageBox d = new AlertMessageBox("Attention!",
|
||||
"Fill in all fields");
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
@Override
|
||||
public void onHide(HideEvent event) {
|
||||
//
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
return;
|
||||
} else {
|
||||
name.setReadOnly(true);
|
||||
description.setReadOnly(true);
|
||||
rights.setReadOnly(true);
|
||||
agencyName.setReadOnly(true);
|
||||
checkButton.disable();
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* protected void loadData(PagingLoadConfig loadConfig, final
|
||||
* AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||
* TDGXTServiceAsync.INSTANCE.getAgencies(new
|
||||
* AsyncCallback<List<Agencies>>() {
|
||||
*
|
||||
* @Override public void onFailure(Throwable caught) {
|
||||
* callback.onFailure(caught); }
|
||||
*
|
||||
* @Override public void onSuccess(List<Agencies> result) {
|
||||
* Log.trace("loaded "+result.size()+" agencies"); for(int i=0;
|
||||
* i<result.size(); i++){ Agencies ag=result.get(i);
|
||||
* //if(ag.getId().compareTo()) }
|
||||
*
|
||||
* callback.onSuccess(new PagingLoadResultBean<Agencies>(result,
|
||||
* result.size(), 0)); } }); }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper to add handlers to observe events that occur on each combobox
|
||||
*
|
||||
* private <T> void addHandlersForEventObservation(final ComboBox<T> combo,
|
||||
* final LabelProvider<T> labelProvider) { combo.addValueChangeHandler(new
|
||||
* ValueChangeHandler<T>() {
|
||||
*
|
||||
* @Override public void onValueChange(ValueChangeEvent<T> event) {
|
||||
*
|
||||
* Info.display("Value Changed", "New value: " + (event.getValue()
|
||||
* == null ? combo.getValue() :
|
||||
* labelProvider.getLabel(event.getValue()) + "!")); } });
|
||||
*
|
||||
* combo.addSelectionHandler(new SelectionHandler<T>() {
|
||||
* @Override public void onSelection(SelectionEvent<T> event) {
|
||||
* Info.display("Agency Selected", "You selected " +
|
||||
* (event.getSelectedItem() == null ? combo.getValue() :
|
||||
* labelProvider.getLabel(event.getSelectedItem()) + "!")); } });
|
||||
* }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
|
@ -241,19 +118,7 @@ public class SDMXTableDetailCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
detail.setName(name.getCurrentValue());
|
||||
// detail.setAgency(combo.getSelectedText());
|
||||
detail.setAgency(agencyName.getCurrentValue());
|
||||
detail.setDescription(description.getCurrentValue());
|
||||
detail.setRight(rights.getCurrentValue());
|
||||
|
||||
importSession.setTabResource(detail);
|
||||
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
||||
importSession);
|
||||
getWizardWindow().addCard(sdmxOperationInProgressCard);
|
||||
Log.info("NextCard SDMXOperationInProgressCard");
|
||||
getWizardWindow().nextCard();
|
||||
|
||||
checkData();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -273,57 +138,60 @@ public class SDMXTableDetailCard extends WizardCard {
|
|||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* private HorizontalLayoutContainer selectAgencies(){
|
||||
*
|
||||
*
|
||||
*
|
||||
* HorizontalLayoutContainer documentSelectionPanel = new
|
||||
* HorizontalLayoutContainer();
|
||||
*
|
||||
* Radio radioAgenciesAlready = new Radio();
|
||||
*
|
||||
* radioAgenciesAlready.setBoxLabel("Present");
|
||||
* radioAgenciesAlready.setValue(true);
|
||||
* radioAgenciesAlready.setName("Agencies");
|
||||
*
|
||||
* Radio radioAgencyNew = new Radio(); radioAgencyNew.setBoxLabel("New");
|
||||
* radioAgencyNew.setName("AgencyNew");
|
||||
*
|
||||
*
|
||||
* documentSelectionPanel.add(radioAgenciesAlready);
|
||||
* documentSelectionPanel.add(radioAgencyNew);
|
||||
*
|
||||
*
|
||||
* ToggleGroup toggle = new ToggleGroup(); toggle.add(radioAgenciesAlready);
|
||||
* toggle.add(radioAgencyNew);
|
||||
*
|
||||
* toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>()
|
||||
* {
|
||||
*
|
||||
* @Override public void onValueChange(ValueChangeEvent<HasValue<Boolean>>
|
||||
* event) { try { ToggleGroup group = (ToggleGroup) event.getSource(); Radio
|
||||
* radio = (Radio) group.getValue(); Log.info("Document Selected:" +
|
||||
* radio.getName()); if (radio.getName().compareTo("AgencyNew") == 0) {
|
||||
* //agencyName.setVisible(true); //combo.setVisible(false); // } else { if
|
||||
* (radio.getName().compareTo("Agency") == 0) {
|
||||
* //agencyName.setVisible(false); //combo.setVisible(true); // } else {
|
||||
*
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*
|
||||
* } catch (Exception e) { Log.error("ToggleGroup: onValueChange " +
|
||||
* e.getLocalizedMessage()); }
|
||||
*
|
||||
* } });
|
||||
*
|
||||
* return documentSelectionPanel;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
protected void checkData() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
AlertMessageBox d;
|
||||
HideHandler hideHandler = new HideHandler() {
|
||||
|
||||
@Override
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
if (name.getValue() == null || name.getValue().isEmpty()
|
||||
|| !name.isValid() || description.getValue() == null
|
||||
|| description.getValue().isEmpty() || !description.isValid()
|
||||
|| rights.getValue() == null || rights.getValue().isEmpty()
|
||||
|| !rights.isValid() || agencyName.getValue() == null
|
||||
|| agencyName.getValue().isEmpty() || !agencyName.isValid()) {
|
||||
|
||||
d = new AlertMessageBox("Attention!", "Fill in all fields");
|
||||
d.addHideHandler(hideHandler);
|
||||
d.show();
|
||||
} else {
|
||||
name.setReadOnly(true);
|
||||
description.setReadOnly(true);
|
||||
rights.setReadOnly(true);
|
||||
agencyName.setReadOnly(true);
|
||||
goNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void goNext() {
|
||||
try {
|
||||
detail.setName(name.getCurrentValue());
|
||||
detail.setAgency(agencyName.getCurrentValue());
|
||||
detail.setDescription(description.getCurrentValue());
|
||||
detail.setRight(rights.getCurrentValue());
|
||||
|
||||
importSession.setTabResource(detail);
|
||||
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
||||
importSession);
|
||||
getWizardWindow().addCard(sdmxOperationInProgressCard);
|
||||
Log.info("NextCard SDMXOperationInProgressCard");
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue