use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline 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.client.ui.desktop.outline.IOutline 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.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class ActionTest method testOutlineButton.
@Test
public void testOutlineButton() {
IDesktop desktopMock = Mockito.mock(IDesktop.class);
IOutline outlineMock = Mockito.mock(IOutline.class);
Mockito.when(desktopMock.getAvailableOutlines()).thenReturn(CollectionUtility.arrayList(outlineMock));
final IntegerHolder execActionHolder = new IntegerHolder(0);
final IntegerHolder execToggleHolder = new IntegerHolder(0);
AbstractOutlineViewButton b = new AbstractOutlineViewButton(desktopMock, outlineMock.getClass()) {
@Override
protected void execAction() {
execActionHolder.setValue(execActionHolder.getValue() + 1);
}
@Override
protected void execSelectionChanged(boolean selection) {
execToggleHolder.setValue(execToggleHolder.getValue() + 1);
}
};
b.getUIFacade().setSelectedFromUI(true);
b.getUIFacade().fireActionFromUI();
assertEquals(1, execActionHolder.getValue().intValue());
assertEquals(1, execToggleHolder.getValue().intValue());
assertTrue(b.isSelected());
b.getUIFacade().fireActionFromUI();
assertEquals(2, execActionHolder.getValue().intValue());
assertEquals(1, execToggleHolder.getValue().intValue());
assertTrue(b.isSelected());
b.getUIFacade().setSelectedFromUI(false);
b.getUIFacade().fireActionFromUI();
assertEquals(3, execActionHolder.getValue().intValue());
assertEquals(2, execToggleHolder.getValue().intValue());
assertFalse(b.isSelected());
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class JsonTableFieldTest method testPreventTableDisposal2.
@Test
public void testPreventTableDisposal2() {
// Create tablePage
IPageWithTable<?> tablePage = createTablePageAndSelectNode();
ITable tablePageTable = tablePage.getTable();
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, tablePage.getOutline(), null);
Assert.assertNotNull(jsonOutline.getAdapter(tablePageTable));
// Create table field which uses the table from the table page
ITableField<ITable> tableField = new TableField<ITable>();
JsonTableField<ITableField<?>> jsonTableField = UiSessionTestUtility.newJsonAdapter(m_uiSession, tableField, null);
tableField.setTable(tablePageTable, true);
// Switch table -> table must not be disposed because table page still needs it
ITable table2 = new Table();
tableField.setTable(table2, true);
assertNotNull(jsonTableField.getAdapter(table2));
assertTrue(jsonTableField.getAdapter(table2).isInitialized());
assertNotNull(jsonOutline.getAdapter(tablePageTable));
assertTrue(jsonOutline.getAdapter(tablePageTable).isInitialized());
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class DesktopWithOutlineForms method execOpened.
@Override
protected void execOpened() {
IOutline firstOutline = CollectionUtility.firstElement(getAvailableOutlines());
activateOutline(firstOutline);
}
Aggregations