Search in sources :

Example 1 with IMultiStatus

use of org.eclipse.scout.rt.platform.status.IMultiStatus in project scout.rt by eclipse.

the class FormFieldTest method testRemoveWithRemainingErrorStatus.

@Test
public void testRemoveWithRemainingErrorStatus() throws Exception {
    SimpleTestFormField testField = new SimpleTestFormField();
    P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
    testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
    IMultiStatus status0 = testField.getErrorStatus();
    testField.addErrorStatus(new InvalidSequenceStatus("error"));
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertFalse(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status1 = testField.getErrorStatus();
    testField.addErrorStatus(new ParsingFailedStatus("error", "input"));
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertTrue(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status2 = testField.getErrorStatus();
    testField.removeErrorStatus(ParsingFailedStatus.class);
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertFalse(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status3 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertNotEquals(status1, status2);
    assertNotEquals(status2, status3);
    // add + add + remove
    assertEquals(3, counter.getCount());
}
Also used : IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) InvalidSequenceStatus(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus) Test(org.junit.Test)

Example 2 with IMultiStatus

use of org.eclipse.scout.rt.platform.status.IMultiStatus in project scout.rt by eclipse.

the class FormFieldTest method testAddDifferentErrorStatus.

@Test
public void testAddDifferentErrorStatus() throws Exception {
    SimpleTestFormField testField = new SimpleTestFormField();
    P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
    testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
    IMultiStatus status0 = testField.getErrorStatus();
    testField.addErrorStatus(new Status("error"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status1 = testField.getErrorStatus();
    testField.addErrorStatus(new Status("another message"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status2 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertNotEquals(status1, status2);
    assertEquals(2, counter.getCount());
}
Also used : InvalidSequenceStatus(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus) Status(org.eclipse.scout.rt.platform.status.Status) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) MultiStatus(org.eclipse.scout.rt.platform.status.MultiStatus) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) Test(org.junit.Test)

Example 3 with IMultiStatus

use of org.eclipse.scout.rt.platform.status.IMultiStatus in project scout.rt by eclipse.

the class FormFieldTest method testAddMultipleRemoveOneAddErrorStatus.

@Test
public void testAddMultipleRemoveOneAddErrorStatus() throws Exception {
    SimpleTestFormField testField = new SimpleTestFormField();
    P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
    testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
    IMultiStatus status0 = testField.getErrorStatus();
    testField.addErrorStatus(new InvalidSequenceStatus("error"));
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertFalse(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status1 = testField.getErrorStatus();
    testField.addErrorStatus(new ParsingFailedStatus("error", "input"));
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertTrue(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status2 = testField.getErrorStatus();
    testField.removeErrorStatus(ParsingFailedStatus.class);
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertFalse(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status3 = testField.getErrorStatus();
    testField.addErrorStatus(new ParsingFailedStatus("error", "input"));
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertTrue(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status4 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertNotEquals(status1, status2);
    assertNotEquals(status2, status3);
    assertNotEquals(status3, status4);
    // add + add + remove + add
    assertEquals(4, counter.getCount());
}
Also used : IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) InvalidSequenceStatus(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus) Test(org.junit.Test)

Example 4 with IMultiStatus

use of org.eclipse.scout.rt.platform.status.IMultiStatus in project scout.rt by eclipse.

the class AbstractColumn method cellValueToEditor.

/**
 * Map the values of a cell to the editing form field. The default implementation assumes a value field.
 *
 * @param row
 *          the row that is currently edited
 * @param editorField
 *          the field to edit the value
 * @throws ProcessingException
 *           if the field is not a value field
 */
@SuppressWarnings("unchecked")
protected void cellValueToEditor(ITableRow row, IFormField editorField) {
    final ICell cell = row.getCell(this);
    IMultiStatus status = cell.getErrorStatus();
    if (status == null || status.isOK()) {
        cellValueToEditField((VALUE) cell.getValue(), editorField);
    } else {
        cellTextToEditField(cell.getText(), editorField);
    }
}
Also used : IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell)

Example 5 with IMultiStatus

use of org.eclipse.scout.rt.platform.status.IMultiStatus in project scout.rt by eclipse.

the class Cell method removeErrorStatus.

/**
 * Remove IStatus of a specific type
 */
public void removeErrorStatus(Class<? extends IStatus> statusClazz) {
    final IMultiStatus ms = getErrorStatusInternal();
    if (ms != null) {
        ms.removeAll(statusClazz);
        if (ms.getChildren().isEmpty()) {
            clearErrorStatus();
        }
        notifyObserver(ERROR_STATUS_BIT);
    }
}
Also used : IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus)

Aggregations

IMultiStatus (org.eclipse.scout.rt.platform.status.IMultiStatus)10 InvalidSequenceStatus (org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus)7 Test (org.junit.Test)7 MultiStatus (org.eclipse.scout.rt.platform.status.MultiStatus)4 Status (org.eclipse.scout.rt.platform.status.Status)4 ICell (org.eclipse.scout.rt.client.ui.basic.cell.ICell)1 IStatus (org.eclipse.scout.rt.platform.status.IStatus)1 JSONObject (org.json.JSONObject)1