Search in sources :

Example 41 with IDesktop

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;
}
Also used : IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 42 with IDesktop

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());
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 43 with IDesktop

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);
}
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 44 with IDesktop

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());
        }
    });
}
Also used : ModelContext(org.eclipse.scout.rt.client.ModelContextProxy.ModelContext) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IForm(org.eclipse.scout.rt.client.ui.form.IForm) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 45 with IDesktop

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);
}
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)

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