use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class AbstractPage method reloadPage.
@Override
public final void reloadPage() {
ITree tree = getTree();
if (tree == null) {
return;
}
try {
tree.setTreeChanging(true);
loadChildren();
} finally {
tree.setTreeChanging(false);
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class AbstractPage method disposeInternal.
@Override
public void disposeInternal() {
super.disposeInternal();
try {
interceptDisposePage();
disposeDetailForm();
disposeTable();
fireAfterPageDispose();
} catch (RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
// automatically remove all data change listeners
ITree tree = getTree();
if (tree != null) {
tree.removeTreeListener(m_treeListener);
}
if (m_internalDataChangeListener != null) {
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
if (desktop != null) {
desktop.removeDataChangeListener(m_internalDataChangeListener);
}
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class AbstractPageWithTable method loadChildrenImpl.
/**
* load tree children<br>
* this method delegates to the table reload<br>
* when the table is loaded and this node is not a leaf node then the table rows are mirrored in child nodes
*/
@Override
protected final void loadChildrenImpl() {
ITree tree = getTree();
try {
if (tree != null) {
tree.setTreeChanging(true);
}
//
// backup currently selected tree node and its path to root
boolean oldSelectionOwned = false;
int oldSelectionDirectChildIndex = -1;
ITreeNode oldSelectedNode = null;
if (tree != null) {
oldSelectedNode = tree.getSelectedNode();
}
List<Object> oldSelectedRowKeys = null;
if (oldSelectedNode != null) {
ITreeNode t = oldSelectedNode;
while (t != null && t.getParentNode() != null) {
if (t.getParentNode() == this) {
oldSelectionOwned = true;
oldSelectedRowKeys = getTableRowFor(t).getKeyValues();
oldSelectionDirectChildIndex = t.getChildNodeIndex();
break;
}
t = t.getParentNode();
}
}
//
setChildrenLoaded(false);
fireBeforeDataLoaded();
try {
loadTableDataImpl();
} catch (ThreadInterruptedError | FutureCancelledError e) {
// NOSONAR
// NOOP
} finally {
fireAfterDataLoaded();
}
setChildrenLoaded(true);
setChildrenDirty(false);
// table events will handle automatic tree changes in case table is mirrored in tree.
// restore currently selected tree node when it was owned by our table rows.
// in case selection was lost, try to select similar index as before
T table = getTable();
if (tree != null && table != null && oldSelectionOwned && tree.getSelectedNode() == null) {
ITreeNode newSelectedNode = null;
ITableRow row = table.getSelectedRow();
if (row != null) {
newSelectedNode = getTreeNodeFor(row);
} else {
row = table.findRowByKey(oldSelectedRowKeys);
if (row != null) {
newSelectedNode = getTreeNodeFor(row);
} else if (oldSelectedNode != null && oldSelectedNode.getTree() == tree) {
// NOSONAR
newSelectedNode = oldSelectedNode;
} else {
int index = Math.max(-1, Math.min(oldSelectionDirectChildIndex, getChildNodeCount() - 1));
if (index >= 0 && index < getChildNodeCount()) {
newSelectedNode = getChildNode(index);
} else {
newSelectedNode = this;
}
}
}
if (newSelectedNode != null) {
tree.selectNode(newSelectedNode);
}
}
} finally {
if (tree != null) {
tree.setTreeChanging(false);
}
}
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
if (desktop != null) {
desktop.afterTablePageLoaded(this);
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class TreeContextMenu method handleOwnerEnabledChanged.
protected void handleOwnerEnabledChanged() {
ITree container = getContainer();
if (container != null) {
final boolean enabled = container.isEnabled();
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
menu.setEnabledInheritAccessibility(enabled);
}
}
return CONTINUE;
}
});
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class SmartFieldTest method testHierarchyNoResult.
@Test
public void testHierarchyNoResult() {
StyleField f = m_styleField;
f.setBrowseHierarchy(true);
m_styleField.getUIFacade().openProposalChooserFromUI("unknown", false, false);
waitForProposalResult(IProposalChooser.PROP_STATUS);
// single result
assertTrue(m_styleField.isProposalChooserRegistered());
assertEquals("unknown", m_styleField.getDisplayText());
// verifies tree is loaded containing a single node
@SuppressWarnings("unchecked") TreeProposalChooser<Long> treeProposalChooser = (TreeProposalChooser<Long>) f.getProposalChooser();
ITree tree = treeProposalChooser.getModel();
ITreeNode rootNode = tree.getRootNode();
assertEquals(0, rootNode.getChildNodes().size());
}
Aggregations