use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent.
/**
* Response must not contain the selection event if the selection was triggered by the request
*/
@Test
public void testIgnorableSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
ITableRow row = table.getRow(2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTabBoxTest method handleUiTabSelected.
private void handleUiTabSelected(String selectedTabId) {
JSONObject data = new JSONObject();
data.put("selectedTab", selectedTabId);
m_tabBox.handleUiPropertyChange("selectedTab", new JsonEvent("?", "?", data).toJson());
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method testSelectionEvent.
/**
* Tests whether the model row gets correctly selected
*/
@Test
public void testSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
assertNull(table.getSelectedRow());
ITableRow row = table.getRow(2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
jsonTable.handleUiEvent(event);
assertTrue(row.isSelected());
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonFormTableControlTest method testLazyLoadingForm_onUiSelectionChanged.
@Test
public void testLazyLoadingForm_onUiSelectionChanged() throws Exception {
FormWithOneField form = new FormWithOneField();
FormTableControl control = new FormTableControl();
control.setTable(new Table());
control.setForm(form);
control.decorateForm();
JsonTableControl<ITableControl> jsonControl = UiSessionTestUtility.newJsonAdapter(m_uiSession, control, null);
assertNull(jsonControl.getAdapter(form));
JsonEvent event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
// Form needs to be created and sent if selection changes to true
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(form);
assertNotNull(formAdapter);
String formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertEquals(formAdapter.getId(), formId);
JsonTestUtility.endRequest(m_uiSession);
// Don't send form again on subsequent selection changes
event = createJsonSelectedEvent(jsonControl.getId(), false);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
JsonTestUtility.endRequest(m_uiSession);
event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonDesktop method addActionEventForEachDisplayParentAdapter.
protected List<JsonEvent> addActionEventForEachDisplayParentAdapter(String eventName, String propModelAdapterId, IJsonAdapter<?> modelAdapter, IDisplayParent displayParent, int position) {
List<JsonEvent> events = new ArrayList<>();
for (IJsonAdapter<IDisplayParent> displayParentAdapter : getUiSession().getJsonAdapters(displayParent)) {
JSONObject jsonEvent = new JSONObject();
jsonEvent.put(propModelAdapterId, modelAdapter.getId());
jsonEvent.put(PROP_DISPLAY_PARENT, displayParentAdapter.getId());
if (position >= 0) {
jsonEvent.put(PROP_POSITION, position);
}
// Add modelAdapter as "referenced adapter" to event (to remove event when
// modelAdapter is disposed but desktop is not)
events.add(addActionEvent(eventName, modelAdapter, jsonEvent));
}
return events;
}
Aggregations