use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class MessageBox method show.
/**
* Displays the message box and waits for a response.
* <p>
* If {@link #getAutoCloseMillis()} is set, the message box will return with given response after the specific time.
*/
@Override
public int show(int defaultResult) {
m_answerSet = false;
m_answer = defaultResult;
if (ClientSessionProvider.currentSession() == null) {
LOG.warn("outside ScoutSessionThread, default answer is CANCEL");
m_answerSet = true;
m_answer = CANCEL_OPTION;
return m_answer;
}
m_blockingCondition.setBlocking(true);
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
try {
// check if the desktop is observing this process
if (desktop == null || !desktop.isOpened()) {
LOG.warn("there is no desktop or the desktop has not yet been opened in the ui, default answer is CANCEL");
m_answerSet = true;
m_answer = CANCEL_OPTION;
} else {
// request a gui
desktop.showMessageBox(this);
// attach auto-cancel timer
IFuture<Void> autoCloseFuture = null;
if (getAutoCloseMillis() > 0) {
final long closeDelay = getAutoCloseMillis();
autoCloseFuture = Jobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
closeMessageBox();
}
}, Jobs.newInput().withName("Closing message box").withRunContext(ClientRunContexts.copyCurrent()).withExecutionTrigger(Jobs.newExecutionTrigger().withStartIn(closeDelay, TimeUnit.MILLISECONDS)));
}
// start sub event dispatch thread
waitFor();
if (autoCloseFuture != null && !autoCloseFuture.isDone()) {
autoCloseFuture.cancel(true);
}
}
} finally {
if (desktop != null) {
desktop.hideMessageBox(this);
}
fireClosed();
}
return m_answer;
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithNodesTest method testPageNodeText.
@Test
public void testPageNodeText() throws Exception {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
desktop.setOutline(PageWithNodeOutline.class);
desktop.activateFirstPage();
ITreeNode parentPageNode = desktop.getOutline().getSelectedNode();
assertEquals("Parent page", parentPageNode.getCell().getText());
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithNodesTest method testSetupOutlinePage.
@Test
public void testSetupOutlinePage() throws Exception {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
assertNotNull(desktop);
desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
desktop.setOutline(PageWithNodeOutline.class);
desktop.activateFirstPage();
IOutline outline = desktop.getOutline();
assertNotNull(outline);
assertSame(PageWithNodeOutline.class, outline.getClass());
IPage<?> page = outline.getActivePage();
assertNotNull(page);
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithNodesTest 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 PageWithNodeOutline()));
desktop.setOutline(PageWithNodeOutline.class);
desktop.activateFirstPage();
IOutline outline = desktop.getOutline();
assertNotNull(outline);
assertSame(PageWithNodeOutline.class, outline.getClass());
IPage<?> page = outline.getActivePage();
assertNotNull(page);
assertSame(ParentItemNodePage.class, page.getClass());
ParentItemNodePage nodePage = (ParentItemNodePage) page;
// init page
ModelContext initPageContext = nodePage.getInitPageContext();
assertNotNull(initPageContext);
assertSame(desktop, initPageContext.getDesktop());
assertSame(outline, initPageContext.getOutline());
// no context form must be set
assertNull(initPageContext.getForm());
// init table
ModelContext initTableContext = nodePage.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 OutlineTreeContextMenuTest 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());
assertEmptySpaceMenusExistOnTablePageParent(outline);
assertRowMenusExistOnTablePageNode(outline);
}
Aggregations