Search in sources :

Example 11 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor in project scout.rt by eclipse.

the class AbstractComposerField method execMarkSaved.

@Override
protected void execMarkSaved() {
    try {
        m_tree.setTreeChanging(true);
        // 
        ITreeVisitor v = new ITreeVisitor() {

            @Override
            public boolean visit(ITreeNode node) {
                if (!node.isStatusNonchanged()) {
                    node.setStatusInternal(ITreeNode.STATUS_NON_CHANGED);
                    m_tree.updateNode(node);
                }
                return true;
            }
        };
        m_tree.visitNode(m_tree.getRootNode(), v);
        m_tree.clearDeletedNodes();
        updateInitialValue();
    } finally {
        m_tree.setTreeChanging(false);
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 12 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor 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)

Example 13 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor in project scout.rt by eclipse.

the class AbstractTreeBox method syncValueToTree.

private void syncValueToTree() {
    if (m_valueTreeSyncActive) {
        return;
    }
    try {
        m_valueTreeSyncActive = true;
        getTree().setTreeChanging(true);
        // 
        Set<T> checkedKeys = getCheckedKeys();
        Collection<ITreeNode> checkedNodes = m_tree.findNodes(checkedKeys);
        getTree().visitTree(new ITreeVisitor() {

            @Override
            public boolean visit(ITreeNode node) {
                node.setChecked(false);
                return true;
            }
        });
        for (ITreeNode node : checkedNodes) {
            node.setChecked(true);
        }
        if (!getTree().isCheckable()) {
            getTree().selectNodes(checkedNodes, false);
        }
        getTree().applyNodeFilters();
    } finally {
        getTree().setTreeChanging(false);
        m_valueTreeSyncActive = false;
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 14 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor in project scout.rt by eclipse.

the class AbstractTreeField method execMarkSaved.

@Override
protected void execMarkSaved() {
    if (m_tree != null && !m_treeExternallyManaged) {
        try {
            m_tree.setTreeChanging(true);
            // 
            ITreeVisitor v = new ITreeVisitor() {

                @Override
                public boolean visit(ITreeNode node) {
                    if (!node.isStatusNonchanged()) {
                        node.setStatusInternal(ITreeNode.STATUS_NON_CHANGED);
                        m_tree.updateNode(node);
                    }
                    return true;
                }
            };
            m_tree.visitNode(m_tree.getRootNode(), v);
            m_tree.clearDeletedNodes();
        } finally {
            m_tree.setTreeChanging(false);
        }
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 15 with ITreeVisitor

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor in project scout.rt by eclipse.

the class TreeProposalChooser method getNode.

/**
 * Node with a given key. Assumes the node is already loaded at this point
 */
private ITreeNode getNode(final LOOKUP_KEY key) {
    final Holder<ITreeNode> holder = new Holder<>(ITreeNode.class);
    m_model.visitTree(new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            if (node.getCell().getValue() instanceof ILookupRow && ObjectUtility.equals(((ILookupRow) node.getCell().getValue()).getKey(), key)) {
                holder.setValue(node);
                return false;
            }
            return true;
        }
    });
    return holder.getValue();
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) Holder(org.eclipse.scout.rt.platform.holders.Holder) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Aggregations

ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)16 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)16 HashSet (java.util.HashSet)4 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)4 ArrayList (java.util.ArrayList)3 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)3 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 Order (org.eclipse.scout.rt.platform.Order)1 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)1 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)1 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)1 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)1