Fixed TR Description fields

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@86496 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-03 15:02:58 +00:00
parent 6fb3d595d6
commit b3df0fdb3e
1 changed files with 56 additions and 57 deletions

View File

@ -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<Agencies> 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());
}
}
}