Search in sources :

Example 1 with Outline

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));
}
Also used : IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) JSONObject(org.json.JSONObject) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) NodePageWithForm(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePageWithForm) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Example 2 with Outline

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()));
}
Also used : IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) NodePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage) ArrayList(java.util.ArrayList) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Example 3 with Outline

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.");
    }
}
Also used : TreeEvent(org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) TablePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) JsonOutline(org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) UiException(org.eclipse.scout.rt.ui.html.UiException) Test(org.junit.Test)

Example 4 with Outline

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;
}
Also used : IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) TablePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) JsonOutline(org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 5 with Outline

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));
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) JSONObject(org.json.JSONObject) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Aggregations

IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)9 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)9 Outline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 JsonTreeTest (org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest)7 TablePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage)4 NodePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage)3 LinkedList (java.util.LinkedList)2 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 JsonOutline (org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline)2 NodePageWithForm (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePageWithForm)2 JSONObject (org.json.JSONObject)2 List (java.util.List)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)1 AbstractPageWithNodes (org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithNodes)1 Holder (org.eclipse.scout.rt.platform.holders.Holder)1 UiException (org.eclipse.scout.rt.ui.html.UiException)1 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1