Search in sources :

Example 16 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class PageWithTable1Test method testReloadPage_multipleSummaryColumns.

@Test
public void testReloadPage_multipleSummaryColumns() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    assertNotNull(desktop);
    desktop.setAvailableOutlines(Collections.singletonList(new PageWithTableOutline()));
    desktop.setOutline(PageWithTableOutline.class);
    desktop.activateFirstPage();
    IOutline outline = desktop.getOutline();
    assertNotNull(outline);
    assertSame(PageWithTableOutline.class, outline.getClass());
    IPage<?> page = outline.getActivePage();
    assertNotNull(page);
    assertSame(PageWithTable.class, page.getClass());
    page.reloadPage();
    page.reloadPage();
    page.reloadPage();
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 17 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class PageWithTable1Test method testLazyLoading.

@Test
public void testLazyLoading() {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    PageWithTableOutline o = new PageWithTableOutline();
    desktop.setAvailableOutlines(Collections.singletonList(o));
    desktop.setOutline(PageWithTableOutline.class);
    desktop.activateFirstPage();
    Assert.assertTrue(o.getActivePage() instanceof PageWithTable);
    PageWithTable pageWithNodes = (PageWithTable) o.getActivePage();
    Assert.assertEquals(1, pageWithNodes.m_execPageDataLoadedCalled);
    Assert.assertEquals(1, pageWithNodes.m_execCreateChildPage);
    for (IPage<?> p : pageWithNodes.getChildPages()) {
        Assert.assertEquals(0, ((PageWithNode) p).m_execCreateChildPages);
        Assert.assertEquals(0, ((PageWithNode) p).m_execInitDetailForm);
        Assert.assertEquals(0, ((PageWithNode) p).m_firePageChanged);
    }
    IPage<?> firstChildPage = pageWithNodes.getChildPage(0);
    firstChildPage.getTree().getUIFacade().setNodesSelectedFromUI(Collections.<ITreeNode>singletonList(firstChildPage));
    Assert.assertEquals(1, ((PageWithNode) firstChildPage).m_execCreateChildPages);
    Assert.assertEquals(1, ((PageWithNode) firstChildPage).m_execInitDetailForm);
    Assert.assertTrue(((PageWithNode) firstChildPage).m_firePageChanged > 0);
}
Also used : IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 18 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class ColumnAutoResizeTest method testReloadPage_multipleSummaryColumns.

@Test
public void testReloadPage_multipleSummaryColumns() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    desktop.setAvailableOutlines(Collections.singletonList(new PageWithTableOutline()));
    desktop.setOutline(PageWithTableOutline.class);
    desktop.activateFirstPage();
    IOutline outline = desktop.getOutline();
    IPage<?> page = outline.getActivePage();
    assertNotNull(page);
    assertTrue(page instanceof AbstractPageWithTable);
    ITable table = ((AbstractPageWithTable) page).getTable();
    assertTrue(table instanceof ColumnAutoResizeTest.PageWithTable.TestTable);
    ColumnAutoResizeTest.PageWithTable.TestTable testTable = (ColumnAutoResizeTest.PageWithTable.TestTable) table;
    IColumn col1 = CollectionUtility.firstElement(testTable.getColumns());
    int width1 = col1.getWidth();
    // when page is reloaded, the column width shall not be different afterwards
    page.reloadPage();
    int width2 = col1.getWidth();
    assertTrue(width1 == width2);
}
Also used : AbstractPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) AbstractPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 19 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class PageWithTable3Test method testSorting.

@Test
public void testSorting() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    PageWithTableOutline outline = new PageWithTableOutline();
    desktop.setAvailableOutlines(Collections.singletonList(outline));
    desktop.activateOutline(outline);
    desktop.activateFirstPage();
    PageWithTable page = (PageWithTable) desktop.getOutline().getActivePage();
    PageWithTable.Table table = page.getTable();
    table.resetColumns();
    // 
    // load table with configured sort columns
    assertTrue(CollectionUtility.equalsCollection(CollectionUtility.arrayList(7, 6, 5, 4, 3, 2, 1, 0), table.getValueColumn().getValues()));
    // user sorts value column asc (all other columns lost their sort index resp. their sort is now explicit=false)
    table.getUIFacade().fireHeaderSortFromUI(table.getValueColumn(), false, true);
    assertSortState(table, CollectionUtility.arrayList(0, 1, 2, 3, 4, 5, 6, 7), CollectionUtility.arrayList(0));
    // 
    // reset desktop and re-create new outline
    desktop.activateOutline((IOutline) null);
    outline = new PageWithTableOutline();
    desktop.setAvailableOutlines(Collections.singletonList(outline));
    desktop.activateOutline(outline);
    desktop.activateFirstPage();
    page = (PageWithTable) desktop.getOutline().getActivePage();
    table = page.getTable();
    assertSortState(table, CollectionUtility.arrayList(0, 1, 2, 3, 4, 5, 6, 7), CollectionUtility.arrayList(0));
}
Also used : IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 20 with IDesktop

use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.

the class PageWithTable6Test method testMenus.

@Test
public void testMenus() throws Exception {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    Outline outline = new Outline();
    desktop.setAvailableOutlines(Collections.singletonList(outline));
    desktop.activateOutline(outline);
    desktop.activateFirstPage();
    PageWithTable page = (PageWithTable) desktop.getOutline().getActivePage();
    PageWithTable.Table table = page.getTable();
    // 
    table.selectRow(null);
    assertMenus(table, new String[] { "New Account" });
    // 
    table.selectRow(0);
    assertMenus(table, new String[] { "Edit Account" });
    // 
    table.selectRow(1);
    assertMenus(table, new String[] {});
    // 
    table.selectAllRows();
    assertMenus(table, new String[] {});
    // 
    table.selectRow(1);
    assertMenus(table, new String[] {});
    table.selectRow(0);
    assertMenus(table, new String[] { "Edit Account" });
    // 
    table.deselectAllRows();
    assertMenus(table, new String[] { "New Account" });
}
Also used : AbstractOutline(org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Aggregations

IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)61 Test (org.junit.Test)36 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)18 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)7 JsonAdapterRegistryTest (org.eclipse.scout.rt.ui.html.json.JsonAdapterRegistryTest)7 IOutlineViewButton (org.eclipse.scout.rt.client.ui.desktop.outline.IOutlineViewButton)5 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)5 JsonForm (org.eclipse.scout.rt.ui.html.json.form.JsonForm)5 JSONObject (org.json.JSONObject)5 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)4 IClientSession (org.eclipse.scout.rt.client.IClientSession)3 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)3 IForm (org.eclipse.scout.rt.client.ui.form.IForm)3 DesktopWithOneOutline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithOneOutline)3 OutlineViewButton (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineViewButton)3 OutlineWithOneNode (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.OutlineWithOneNode)3 FormWithOneField (org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 Locale (java.util.Locale)2