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