use of org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor in project scout.rt by eclipse.
the class TableFieldTest method testErrorColumn_Visible.
/**
* Tests that an invisible displayable column is shown, if there is an error.
*/
@Test
public void testErrorColumn_Visible() {
P_TableField tableField = createTableField(false);
tableField.getTable().addRowByArray(TEST_ROW);
Cell cell = (Cell) tableField.getTable().getCell(0, 1);
cell.setEditable(true);
tableField.getTable().getStringColumn().setVisible(false);
cell.addErrorStatus("ErrorX");
IValidateContentDescriptor desc = tableField.validateContent();
assertTrue(tableField.getTable().getStringColumn().isVisible());
}
use of org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor in project scout.rt by eclipse.
the class AbstractForm method validateForm.
@Override
public void validateForm() {
if (!interceptCheckFields()) {
VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
veto.consume();
throw veto;
}
if (!getHandler().onCheckFields()) {
VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
veto.consume();
throw veto;
}
// check all fields that might be invalid
final ArrayList<String> invalidTexts = new ArrayList<String>();
final ArrayList<String> mandatoryTexts = new ArrayList<String>();
P_AbstractCollectingFieldVisitor<IValidateContentDescriptor> v = new P_AbstractCollectingFieldVisitor<IValidateContentDescriptor>() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
IValidateContentDescriptor desc = f.validateContent();
if (desc != null) {
if (desc.getErrorStatus() != null) {
invalidTexts.add(desc.getDisplayText() + ": " + desc.getErrorStatus().getMessage());
} else {
mandatoryTexts.add(desc.getDisplayText());
}
if (getCollectionCount() == 0) {
collect(desc);
}
}
return true;
}
};
visitFields(v);
if (v.getCollectionCount() > 0) {
IValidateContentDescriptor firstProblem = v.getCollection().get(0);
if (LOG.isInfoEnabled()) {
LOG.info("there are fields with errors");
}
if (firstProblem != null) {
firstProblem.activateProblemLocation();
}
throw new VetoException().withHtmlMessage(createValidationMessageBoxHtml(invalidTexts, mandatoryTexts));
}
if (!interceptValidate()) {
VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
veto.consume();
throw veto;
}
if (!getHandler().onValidate()) {
VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
veto.consume();
throw veto;
}
}
use of org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor in project scout.rt by eclipse.
the class TableFieldTest method testOkErrorStatus_ErrorText.
/**
* Tests that there is an error on the field, when a table field with errors is validated.
*/
@Test
public void testOkErrorStatus_ErrorText() {
P_TableField tableField = createTableField(false);
tableField.getTable().addRowByArray(TEST_ROW);
Cell cell = (Cell) tableField.getTable().getCell(0, 1);
cell.setEditable(true);
cell.addErrorStatus("ErrorX");
IValidateContentDescriptor desc = tableField.validateContent();
assertNotNull(desc);
assertTrue(desc.getDisplayText().contains(tableField.getTable().getStringColumn().getClass().getSimpleName()));
}
use of org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor in project scout.rt by eclipse.
the class TableFieldTest method testMandatory_ErrorText.
/**
* Tests that there is an error on the field, when a mandatory table is not filled.
*/
@Test
public void testMandatory_ErrorText() {
P_TableField tableField = createTableField(false);
tableField.getTable().addRowByArray(new Object[] { 1, null, false });
Cell cell = (Cell) tableField.getTable().getCell(0, 1);
cell.setEditable(true);
cell.setMandatory(true);
IValidateContentDescriptor desc = tableField.validateContent();
assertNotNull(desc);
assertNull(desc.getErrorStatus());
assertTrue(desc.getDisplayText().contains(tableField.getTable().getStringColumn().getClass().getSimpleName()));
}
use of org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor in project scout.rt by eclipse.
the class TableFieldTest method testOkErrorStatus_NoError.
/**
* Tests that there is no error when adding a {@link Status#OK_STATUS} to a cell.
*/
@Test
public void testOkErrorStatus_NoError() {
P_TableField tableField = createTableField(false);
tableField.getTable().addRowByArray(TEST_ROW);
Cell cell = (Cell) tableField.getTable().getCell(0, 1);
cell.setEditable(true);
cell.addErrorStatus(Status.OK_STATUS);
IValidateContentDescriptor desc = tableField.validateContent();
assertNull(desc);
}
Aggregations