Search in sources :

Example 6 with IMultiStatus

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

the class FormFieldTest method testAddSameErrorStatus.

@Test
public void testAddSameErrorStatus() 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();
    // no event, because same status already exists
    testField.addErrorStatus(new Status("error"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status2 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertEquals(status1, status2);
    assertEquals(1, 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 7 with IMultiStatus

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

the class FormFieldTest method testAddRemoveAddErrorStatus.

@Test
public void testAddRemoveAddErrorStatus() 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.removeErrorStatus(Status.class);
    assertNull(testField.getErrorStatus());
    IMultiStatus status2 = testField.getErrorStatus();
    testField.addErrorStatus(new Status("error"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status3 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertNotEquals(status1, status2);
    assertNotEquals(status2, status3);
    // adding + removing + adding
    assertEquals(3, 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 8 with IMultiStatus

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

the class FormFieldTest method testRemoveErrorStatus.

@Test
public void testRemoveErrorStatus() 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.removeErrorStatus(Status.class);
    assertNull(testField.getErrorStatus());
    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 9 with IMultiStatus

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

the class FormFieldTest method testRemoveNonExistingErrorStatus.

@Test
public void testRemoveNonExistingErrorStatus() 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();
    // should not trigger an event
    testField.removeErrorStatus(ParsingFailedStatus.class);
    assertTrue(testField.getErrorStatus().containsStatus(InvalidSequenceStatus.class));
    assertFalse(testField.getErrorStatus().containsStatus(ParsingFailedStatus.class));
    IMultiStatus status2 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertEquals(status1, status2);
    assertEquals(1, 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 10 with IMultiStatus

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

the class JsonStatus method toJson.

@Override
public JSONObject toJson() {
    JSONObject json = new JSONObject();
    json.put("message", m_status.getMessage());
    json.put("severity", m_status.getSeverity());
    json.put("iconId", m_status.getIconId());
    json.put("code", m_status.getCode());
    if (m_status.isMultiStatus()) {
        for (IStatus cs : ((IMultiStatus) m_status).getChildren()) {
            json.append("children", new JsonStatus(cs).toJson());
        }
    }
    return json;
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) JSONObject(org.json.JSONObject) 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