diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java index b62276d..3eb68d9 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java @@ -3,22 +3,19 @@ */ package org.gcube.portlets.user.td.csvimportwidget.client; -import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; -import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +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.user.client.Command; import com.google.gwt.user.client.ui.VerticalPanel; import com.sencha.gxt.widget.core.client.FramedPanel; 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.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; @@ -46,11 +43,7 @@ public class CSVTableDetailCard extends WizardCard { protected TextArea description; protected TextArea rights; - protected TextButton checkButton; - - // protected ComboBox combo=null; - - TabResource detail = new TabResource(); + protected TabResource detail = new TabResource(); public CSVTableDetailCard(final CSVImportSession importSession) { super("Tabular Resource Detail", ""); @@ -96,47 +89,14 @@ public class CSVTableDetailCard extends WizardCard { rights.setAllowBlank(false); p.add(new FieldLabel(rights, "Rights"), 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() + protected void checkField() { - ) { - 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); - checkButton.disable(); - getWizardWindow().setEnableNextButton(true); - } } @Override @@ -145,18 +105,7 @@ public class CSVTableDetailCard extends WizardCard { @Override public void execute() { - detail.setName(name.getCurrentValue()); - detail.setDescription(description.getCurrentValue()); - detail.setRight(rights.getCurrentValue()); - - importSession.setTabResource(detail); - - CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard( - importSession); - getWizardWindow().addCard(csvOperationInProgressCard); - Log.info("NextCard CSVOperationInProgressCard"); - getWizardWindow().nextCard(); - + checkData(); } }; @@ -176,8 +125,58 @@ public class CSVTableDetailCard extends WizardCard { }; getWizardWindow().setPreviousButtonCommand(sayPreviousCard); - getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableNextButton(true); } + 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() + + ) { + d = new AlertMessageBox("Attention!", "Fill in all fields"); + d.addHideHandler(hideHandler); + d.show(); + } else { + name.setReadOnly(true); + description.setReadOnly(true); + rights.setReadOnly(true); + goNext(); + } + } + + protected void goNext() { + try { + detail.setName(name.getCurrentValue()); + detail.setDescription(description.getCurrentValue()); + detail.setRight(rights.getCurrentValue()); + + importSession.setTabResource(detail); + + CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard( + importSession); + getWizardWindow().addCard(csvOperationInProgressCard); + Log.info("NextCard CSVOperationInProgressCard"); + getWizardWindow().nextCard(); + } catch (Exception e) { + Log.error("sayNextCard :" + e.getLocalizedMessage()); + } + } + }