use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline in project scout.rt by eclipse.
the class JsonOutlineTest method testTableNotSentIfInvisible.
/**
* Node.detailTable must not be sent if node.tableVisible is set to false to reduce response size.
*/
@Test
public void testTableNotSentIfInvisible() throws JSONException {
NodePageWithForm nodePage = new NodePageWithForm();
// trigger table creation
nodePage.getTable(true);
nodePage.setTableVisible(false);
List<IPage<?>> pages = new ArrayList<IPage<?>>();
pages.add(nodePage);
IOutline outline = new Outline(pages);
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
JSONObject jsonNode = jsonOutline.toJson().getJSONArray("nodes").getJSONObject(0);
Assert.assertNull(jsonNode.opt(IOutline.PROP_DETAIL_TABLE));
nodePage.setTableVisible(true);
JsonTestUtility.processBufferedEvents(m_uiSession);
jsonNode = jsonOutline.toJson().getJSONArray("nodes").getJSONObject(0);
Assert.assertNotNull(jsonNode.opt(IOutline.PROP_DETAIL_TABLE));
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline in project scout.rt by eclipse.
the class JsonOutlineTest method testPageDisposalOnRemoveAllNested.
@Test
public void testPageDisposalOnRemoveAllNested() throws JSONException {
NodePage nodePage = new NodePage();
nodePage.getCellForUpdate().setText("node");
// trigger table creation
nodePage.getTable(true);
NodePage childPage = new NodePage();
childPage.getCellForUpdate().setText("child");
// trigger table creation
childPage.getTable(true);
List<IPage<?>> pages = new ArrayList<IPage<?>>();
pages.add(nodePage);
IOutline outline = new Outline(pages);
outline.addChildNode(nodePage, childPage);
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
// Assert that pages have an id
String nodeId = JsonTreeTest.getOrCreateNodeId(jsonOutline, nodePage);
assertNotNull(nodeId);
assertNotNull(JsonTreeTest.getNode(jsonOutline, nodeId));
String childId = JsonTreeTest.getOrCreateNodeId(jsonOutline, childPage);
assertNotNull(childId);
assertNotNull(JsonTreeTest.getNode(jsonOutline, childId));
// Assert that adapters for table have been created
assertNotNull(m_uiSession.getJsonAdapter(nodePage.getTable(), m_uiSession.getRootJsonAdapter()));
assertNotNull(m_uiSession.getJsonAdapter(childPage.getTable(), m_uiSession.getRootJsonAdapter()));
outline.setTreeChanging(true);
// First remove all child nodes of the node page
outline.removeAllChildNodes(nodePage);
// Then remove all child nodes of the root page
outline.removeAllChildNodes(outline.getRootNode());
// Finally fire the events -> event buffer will remove the first event, but JsonOutline must dispose the children of nodePage anyway. That is why JsonTree keeps track of the child/parent link by itself.
outline.setTreeChanging(false);
JsonTestUtility.processBufferedEvents(m_uiSession);
// Assert that pages have been disposed
assertNull(JsonTreeTest.getNode(jsonOutline, nodeId));
assertNull(JsonTreeTest.getNode(jsonOutline, childId));
// Assert that tables have been disposed
assertNull(m_uiSession.getJsonAdapter(nodePage.getTable(), m_uiSession.getRootJsonAdapter()));
assertNull(m_uiSession.getJsonAdapter(childPage.getTable(), m_uiSession.getRootJsonAdapter()));
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline in project scout.rt by eclipse.
the class JsonTreeTest method testDeletionOfAllChildrenOfUnknownNode.
@Test
public void testDeletionOfAllChildrenOfUnknownNode() throws Exception {
IOutline outline = new Outline(new ArrayList<IPage<?>>());
ITreeNode parent = new TablePage(0);
ITreeNode node1 = new TablePage(0);
node1.setParentNodeInternal(parent);
ITreeNode node2 = new TablePage(0);
node2.setParentNodeInternal(parent);
ITreeNode node3 = new TablePage(0);
node3.setParentNodeInternal(parent);
outline.addChildNode(outline.getRootNode(), parent);
outline.addChildNode(parent, node1);
outline.addChildNode(parent, node2);
outline.addChildNode(parent, node3);
JsonOutline<IOutline> jsonOutline = m_uiSession.createJsonAdapter(outline, null);
List<ITreeNode> allChildren = CollectionUtility.arrayList(node1, node2, node3);
jsonOutline.bufferModelEvent(new TreeEvent(outline, TreeEvent.TYPE_ALL_CHILD_NODES_DELETED, parent, allChildren));
try {
jsonOutline.processBufferedEvents();
} catch (UiException e) {
fail("Regression of ticket 210096: Tree does not contain node whose children are to be deleted.");
}
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline in project scout.rt by eclipse.
the class JsonTableFieldTest method createTablePageAndSelectNode.
private IPageWithTable<?> createTablePageAndSelectNode() {
TablePage tablePage = new TablePage(1, new TablePage.NodePageWithFormFactory());
List<IPage<?>> pages = new ArrayList<IPage<?>>();
pages.add(tablePage);
IOutline outline = new Outline(pages);
outline.selectNode(tablePage);
return tablePage;
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline in project scout.rt by eclipse.
the class JsonOutlineTest method testDontSendNonDisplayableMenus.
/**
* Tests whether only header menus are sent.
* <p>
* Other menus are never displayed, no need to send them.
*/
@Test
public void testDontSendNonDisplayableMenus() throws Exception {
List<IPage<?>> pages = new ArrayList<IPage<?>>();
IOutline outline = new Outline(pages);
IMenu headerMenu = new HeaderMenu();
headerMenu.initAction();
IMenu nonHeaderMenu = new NonHeaderMenu();
nonHeaderMenu.initAction();
outline.getContextMenu().addChildAction(headerMenu);
outline.getContextMenu().addChildAction(nonHeaderMenu);
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
// ----------
JsonMenu<IMenu> jsonHeaderMenu = jsonOutline.getAdapter(headerMenu);
JsonMenu<IMenu> jsonNonHeaderMenu = jsonOutline.getAdapter(nonHeaderMenu);
// Adapter for NonHeaderMenu must not exist
assertNull(jsonNonHeaderMenu);
// Json response must not contain NonHeaderMenu
JSONObject json = jsonOutline.toJson();
JSONArray jsonMenus = json.getJSONArray("menus");
assertEquals(1, jsonMenus.length());
assertEquals(jsonHeaderMenu.getId(), jsonMenus.get(0));
}
Aggregations