Search in sources :

Example 1 with NodePage

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage 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 2 with NodePage

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage in project scout.rt by eclipse.

the class JsonOutlineTest method testPageDisposal.

@Test
public void testPageDisposal() {
    TablePage tablePage = new TablePage(1, new TablePage.NodePageWithFormFactory());
    NodePage nodePage = new NodePage();
    List<IPage<?>> pages = new ArrayList<IPage<?>>();
    pages.add(nodePage);
    IOutline outline = new Outline(pages);
    outline.addChildNode(nodePage, tablePage);
    outline.selectNode(tablePage);
    JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
    List<ITreeNode> allNodes = JsonTreeTest.getAllTreeNodes(outline);
    List<String> allNodeIds = new LinkedList<String>();
    for (ITreeNode node : allNodes) {
        String nodeId = JsonTreeTest.getOrCreateNodeId(jsonOutline, node);
        allNodeIds.add(nodeId);
        assertNotNull(nodeId);
        assertNotNull(JsonTreeTest.getNode(jsonOutline, nodeId));
    }
    outline.removeNode(nodePage);
    JsonTestUtility.processBufferedEvents(m_uiSession);
    // Verify nodes get unregistered
    for (ITreeNode node : allNodes) {
        assertNull(JsonTreeTest.optNodeId(jsonOutline, node));
    }
    for (String nodeId : allNodeIds) {
        assertNull(JsonTreeTest.getNode(jsonOutline, nodeId));
    }
    // Verify table adapter gets unregistered
    assertNull(m_uiSession.getJsonAdapter(tablePage.getTable(), m_uiSession.getRootJsonAdapter()));
}
Also used : 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) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) LinkedList(java.util.LinkedList) 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) NodePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Example 3 with NodePage

use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage in project scout.rt by eclipse.

the class JsonOutlineTest method testPageDisposalOnRemoveAll.

@Test
public void testPageDisposalOnRemoveAll() throws JSONException {
    NodePage nodePage = new NodePage();
    // trigger table creation
    nodePage.getTable(true);
    NodePage childPage = new NodePage();
    // 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()));
    // Remove all child nodes of the root page
    outline.removeAllChildNodes(outline.getRootNode());
    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)

Aggregations

ArrayList (java.util.ArrayList)3 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)3 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)3 NodePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NodePage)3 Outline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline)3 JsonTreeTest (org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest)3 Test (org.junit.Test)3 LinkedList (java.util.LinkedList)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1 TablePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage)1