use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPage method execDataChanged.
/**
* Called by the data change listener registered with this page (and the current desktop) through
* {@link #registerDataChangeListener(Object...)}. Use this callback method to react to data change events by
* reloading current data, or throwing away cached data etc.
* <p>
* Subclasses can override this method.<br/>
* This default implementation does the following:
* <ol>
* <li>if this page is an ancestor of the selected page (or is selected itself) and this page is in the active
* outline, a full re-load of the page is performed
* <li>else the children of this page are marked dirty and the page itself is unloaded
* </ol>
*
* @see IDesktop#dataChanged(Object...)
*/
@ConfigOperation
@Order(55)
protected void execDataChanged(Object... dataTypes) {
if (getTree() == null) {
return;
}
//
HashSet<ITreeNode> pathsToSelections = new HashSet<ITreeNode>();
for (ITreeNode node : getTree().getSelectedNodes()) {
ITreeNode tmp = node;
while (tmp != null) {
pathsToSelections.add(tmp);
tmp = tmp.getParentNode();
}
}
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
final boolean isActiveOutline = (desktop != null ? desktop.getOutline() == this.getOutline() : false);
final boolean isRootNode = pathsToSelections.isEmpty() && getTree() != null && getTree().getRootNode() == this;
if (isActiveOutline && (pathsToSelections.contains(this) || isRootNode)) {
try {
// TODO [7.0] fko: maybe remove when bookmarks can be done on outline level? (currently only pages)
if (isRootNode) {
this.reloadPage();
} else /*
* Ticket 77332 (deleting a node in the tree) also requires a reload So
* the selected and its ancestor nodes require same processing
*/
if (desktop != null) {
// NOSONAR
Bookmark bm = desktop.createBookmark();
setChildrenDirty(true);
// activate bookmark without activating the outline, since this would hide active tabs.
desktop.activateBookmark(bm, false);
}
} catch (RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
} else {
// not active outline OR not on selection path
setChildrenDirty(true);
if (isExpanded()) {
setExpanded(false);
}
try {
if (isChildrenLoaded()) {
getTree().unloadNode(this);
}
} catch (RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
}
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class BookmarkToInvisibleOutlineTest method testBookmarkToInvisibleOutline.
@Test
public void testBookmarkToInvisibleOutline() throws Exception {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
desktop.setAvailableOutlines(CollectionUtility.arrayList(new CockpitOutline(), new AdminOutline()));
desktop.setOutline(CockpitOutline.class);
Bookmark bm = desktop.createBookmark();
//
desktop.setOutline(AdminOutline.class);
desktop.findOutline(CockpitOutline.class).setVisible(false);
Thread.sleep(400);
Exception err = null;
try {
desktop.activateBookmark(bm);
} catch (Exception e) {
err = e;
}
assertNotNull(err);
assertEquals(desktop.findOutline(AdminOutline.class), desktop.getOutline());
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithNodesTest method testRenameChildPages.
@Test
public void testRenameChildPages() throws Exception {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
desktop.setOutline(PageWithNodeOutline.class);
desktop.activateFirstPage();
AbstractPageWithNodes parentPage = (AbstractPageWithNodes) desktop.getOutline().getActivePage();
ITreeNode parentPageNode = desktop.getOutline().getSelectedNode();
ITreeNode childPageNode = parentPageNode.getChildNode(0);
assertEquals("Parent page", parentPageNode.getCell().getText());
assertEquals("Child page", childPageNode.getCell().getText());
// this is the childPages name in the table
assertEquals("Child page", parentPage.getTable().getRow(0).getCell(0).getText());
// update the child node's cell text
childPageNode.getCellForUpdate().setText("my new long text");
assertEquals("my new long text", childPageNode.getCell().getText());
// text must also be changed in the parent's table
assertEquals("my new long text", parentPage.getTable().getRow(0).getCell(0).getText());
// rename again
childPageNode.getCellForUpdate().setText("Child page");
assertEquals("Parent page", parentPageNode.getCell().getText());
assertEquals("Child page", childPageNode.getCell().getText());
assertEquals("Child page", parentPage.getTable().getRow(0).getCell(0).getText());
// rename on table, must be reflected to the tree
parentPage.getTable().getRow(0).getCellForUpdate(0).setText("my new long text");
assertEquals("my new long text", parentPage.getTable().getRow(0).getCell(0).getText());
assertEquals("Parent page", parentPageNode.getCell().getText());
assertEquals("my new long text", childPageNode.getCell().getText());
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithTableTest method testModelContextOfInitPageAndInitTable.
@Test
public void testModelContextOfInitPageAndInitTable() {
IForm mockForm = Mockito.mock(IForm.class);
IOutline mockOutline = Mockito.mock(IOutline.class);
ClientRunContexts.copyCurrent().withOutline(mockOutline, true).withForm(mockForm).run(new IRunnable() {
@Override
public void run() throws Exception {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
assertNotNull(desktop);
desktop.setAvailableOutlines(CollectionUtility.arrayList(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(ParentItemTablePage.class, page.getClass());
ParentItemTablePage tablePage = (ParentItemTablePage) page;
// init page
ModelContext initPageContext = tablePage.getInitPageContext();
assertNotNull(initPageContext);
assertSame(desktop, initPageContext.getDesktop());
assertSame(outline, initPageContext.getOutline());
// no context form must be set
assertNull(initPageContext.getForm());
// init table
ModelContext initTableContext = tablePage.getInitTableContext();
assertNotNull(initTableContext);
assertSame(desktop, initTableContext.getDesktop());
assertSame(outline, initTableContext.getOutline());
// no context form must be set
assertNull(initTableContext.getForm());
}
});
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class OutlineTreeContextMenuNestedPageWithTablesTest method testEmptySpaceAndRowMenus.
@Test
public void testEmptySpaceAndRowMenus() 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());
assertRowMenusExistOnTablePageNode(outline);
}
Aggregations