use of org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu in project scout.rt by eclipse.
the class P_BadVisitorCompositeField method testAddField.
@Test
public void testAddField() {
P_TestCompositeField compositeField = new P_TestCompositeField();
compositeField.setEnabled(false, false, false);
IStringField add = new AbstractStringField() {
};
AbstractMenu menu = new AbstractMenu() {
};
add.getContextMenu().addChildAction(menu);
compositeField.addField(add);
assertFalse(add.isEnabledIncludingParents());
assertTrue(add.isEnabled());
assertFalse(menu.isEnabled());
}
use of org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu in project scout.rt by eclipse.
the class JsonMenuTest method testDontSendNonDisplayableMenusSpecialCaseWithEvent.
/**
* Even more special case: Menus that are set to visibleGranted=false may already be referred in an event for another
* (still available) adapter.
*/
@Test
public void testDontSendNonDisplayableMenusSpecialCaseWithEvent() throws Exception {
// skip startup response
JsonTestUtility.endRequest(m_uiSession);
IForm form = new FormWithOneField();
IMenu menu = new AbstractMenu() {
@Override
protected void execInitAction() {
setVisibleGranted(false);
}
};
IJsonAdapter<?> jsonForm = m_uiSession.createJsonAdapter(form, null);
IJsonAdapter<?> jsonRootGroupBox = jsonForm.getAdapter(form.getRootGroupBox());
// Test:
// 3 adapters in response: Form, MainBox, StringField
// 0 events in response
assertEquals(3, JsonResponseTestUtility.adapterMap(m_uiSession.currentJsonResponse()).size());
assertEquals(0, JsonResponseTestUtility.eventList(m_uiSession.currentJsonResponse()).size());
// ------------------
// End request and simulate context menu change event on form
JsonTestUtility.endRequest(m_uiSession);
form.getRootGroupBox().getContextMenu().addChildAction(menu);
// Test:
// 1 adapters in response: Menu
// 1 events in response: PROP_MENU
assertEquals(1, JsonResponseTestUtility.adapterMap(m_uiSession.currentJsonResponse()).size());
assertEquals(1, JsonResponseTestUtility.eventList(m_uiSession.currentJsonResponse()).size());
// ------------------
// After attachment of adapter!
ActionUtility.initActions(CollectionUtility.arrayList(menu));
// Test:
// - 0 adapters in response (-1 menu)
// - 1 events in response: PROP_MENU <-- this would be wrong! But when the JSON string is generated, the adapter is removed from the list
assertEquals(0, JsonResponseTestUtility.adapterMap(m_uiSession.currentJsonResponse()).size());
assertEquals(1, JsonResponseTestUtility.eventList(m_uiSession.currentJsonResponse()).size());
// Check that the event's properties are empty after toJson()
JSONObject json = m_uiSession.currentJsonResponse().toJson();
assertFalse(json.has("adapterData"));
JSONArray events = json.getJSONArray("events");
assertEquals(1, events.length());
assertEquals(jsonRootGroupBox.getId(), events.getJSONObject(0).get("target"));
assertEquals("property", events.getJSONObject(0).get("type"));
assertEquals(0, events.getJSONObject(0).getJSONObject("properties").getJSONArray("menus").length());
}
Aggregations