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