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