Search in sources :

Example 26 with IOutline

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

the class AbstractDesktop method setAvailableOutlines.

@Override
public void setAvailableOutlines(List<? extends IOutline> availableOutlines) {
    activateOutline((IOutline) null);
    if (m_availableOutlines != null) {
        for (IOutline o : m_availableOutlines) {
            ClientSessionProvider.currentSession().getMemoryPolicy().deregisterOutline(o);
        }
    }
    m_availableOutlines = CollectionUtility.arrayList(availableOutlines);
    for (IOutline o : m_availableOutlines) {
        ClientSessionProvider.currentSession().getMemoryPolicy().registerOutline(o);
    }
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 27 with IOutline

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

the class DisplayParentResolver method findClosestDisplayParent.

/**
 * Resolves to the closest {@link IDisplayParent} from the current calling context.
 */
protected IDisplayParent findClosestDisplayParent() {
    final ClientRunContext currentRunContext = ClientRunContexts.copyCurrent();
    // Check whether a Form is currently the 'displayParent'. If being a wrapped Form, return its outer Form.
    IForm currentForm = currentRunContext.getForm();
    if (currentForm != null) {
        while (currentForm.getOuterForm() != null) {
            currentForm = currentForm.getOuterForm();
        }
        // added to the desktop (e.g. forms managed by form tool buttons).
        if (currentForm.isFormStarted()) {
            return currentForm;
        }
    }
    // Check whether an Outline is currently the 'displayParent'.
    final IOutline currentOutline = currentRunContext.getOutline();
    if (currentOutline != null) {
        return currentOutline;
    }
    // Use the desktop as 'displayParent'.
    return currentRunContext.getDesktop();
}
Also used : ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 28 with IOutline

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

the class OutlineDeepLinkHandlerTest method testHandleImpl.

/**
 * Checks if the OutlineHandler activates the correct outline for a given deep-link path.
 */
@Test
public void testHandleImpl() throws Exception {
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    IOutline outlineFoo = new P_OutlineFoo();
    IOutline outlineBar = new P_OutlineBar();
    addOutlineToDesktop(desktop, outlineFoo);
    addOutlineToDesktop(desktop, outlineBar);
    desktop.activateOutline(outlineBar);
    assertSame(outlineBar, desktop.getOutline());
    OutlineDeepLinkHandler handler = new OutlineDeepLinkHandler();
    handler.handle("outline-04446");
    assertSame(outlineFoo, desktop.getOutline());
}
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 29 with IOutline

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

the class JsonOutlineTable method tableRowToJson.

@Override
protected JSONObject tableRowToJson(ITableRow row) {
    JSONObject json = super.tableRowToJson(row);
    ITreeNode treeNode = m_page.getTreeNodeFor(row);
    JsonOutline<IOutline> jsonOutline = getGlobalAdapter(m_page.getOutline());
    String nodeId = jsonOutline.getOrCreateNodeId(treeNode);
    putProperty(json, "nodeId", nodeId);
    return json;
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) JSONObject(org.json.JSONObject) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 30 with IOutline

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

the class MediumMemoryPolicy method afterOutlineSelectionChanged.

@Override
public void afterOutlineSelectionChanged(final IDesktop desktop) {
    try {
        final AtomicLong nodeCount = new AtomicLong();
        if (desktop.getOutline() != null && desktop.getOutline().getSelectedNode() != null) {
            final HashSet<IPage> preservationSet = new HashSet<IPage>();
            IPage<?> p = (IPage) desktop.getOutline().getSelectedNode();
            while (p != null) {
                // the tree in the selection is not the topic
                // of the analysis whether we should free up the memory
                // so we calculate only the other ones.
                preservationSet.add(p);
                p = p.getParentPage();
            }
            ITreeVisitor v = new ITreeVisitor() {

                @Override
                public boolean visit(ITreeNode node) {
                    IPage<?> page = (IPage) node;
                    if (preservationSet.contains(page)) {
                    // nop
                    } else if (page.getParentPage() == null) {
                    // nop, InvisibleRootPage
                    } else if (page.isChildrenLoaded()) {
                        nodeCount.getAndAdd(page.getChildNodeCount());
                    }
                    return true;
                }
            };
            for (IOutline outline : desktop.getAvailableOutlines()) {
                outline.visitNode(outline.getRootNode(), v);
            }
        }
        long memTotal = Runtime.getRuntime().totalMemory();
        long memUsed = (memTotal - Runtime.getRuntime().freeMemory());
        long memMax = Runtime.getRuntime().maxMemory();
        if (memUsed > memMax * 80L / 100L || nodeCount.get() > 10000) {
            m_release = true;
        }
    } catch (Exception e) {
        LOG.error("Unexpected Exception", e);
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) HashSet(java.util.HashSet) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Aggregations

IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)49 Test (org.junit.Test)24 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)18 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)12 ArrayList (java.util.ArrayList)11 Outline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline)9 JsonTreeTest (org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest)7 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)5 IForm (org.eclipse.scout.rt.client.ui.form.IForm)5 JSONObject (org.json.JSONObject)5 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)4 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)4 TablePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage)4 List (java.util.List)3 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)3 IViewButton (org.eclipse.scout.rt.client.ui.action.view.IViewButton)3 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)3 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)3 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)3 JsonOutline (org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline)3