use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class TreeProposalChooser method dataFetchedDelegateImpl.
@Override
protected void dataFetchedDelegateImpl(IContentAssistFieldDataFetchResult<LOOKUP_KEY> result, int maxCount) {
if (result.getException() == null) {
List<ITreeNode> subTree = getSubtree(result);
ITreeNode parentNode = getParent(result);
try {
if (m_model != null) {
m_model.setTreeChanging(true);
updateSubTree(m_model, parentNode, subTree);
expand();
selectNode(result);
}
} finally {
if (m_model != null) {
m_model.setTreeChanging(false);
}
}
}
updateStatus(result);
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class TreeProposalChooser method execGetSingleMatch.
/**
* Override this method to change that behaviour of what is a single match. By default a single match is when there is
* a single enabled LEAF node in the tree
*/
@ConfigOperation
@Order(40)
@Override
protected ILookupRow<LOOKUP_KEY> execGetSingleMatch() {
final List<ILookupRow<LOOKUP_KEY>> foundLeafs = new ArrayList<>();
ITreeVisitor v = new ITreeVisitor() {
@Override
public boolean visit(ITreeNode node) {
if (node.isEnabled() && node.isLeaf()) {
@SuppressWarnings("unchecked") ILookupRow<LOOKUP_KEY> row = (ILookupRow<LOOKUP_KEY>) node.getCell().getValue();
if (row != null && row.isEnabled()) {
foundLeafs.add(row);
}
}
return foundLeafs.size() <= 2;
}
};
m_model.visitVisibleTree(v);
if (foundLeafs.size() == 1) {
return foundLeafs.get(0);
} else {
return null;
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class TreeProposalChooser method getSelectedLookupRow.
@Override
@SuppressWarnings("unchecked")
public ILookupRow<LOOKUP_KEY> getSelectedLookupRow() {
ILookupRow<LOOKUP_KEY> row = null;
ITreeNode node = null;
if (m_model.isCheckable()) {
Collection<ITreeNode> checkedNodes = m_model.getCheckedNodes();
if (CollectionUtility.hasElements(checkedNodes)) {
node = CollectionUtility.firstElement(checkedNodes);
}
} else {
node = m_model.getSelectedNode();
}
if (node != null && node.isFilterAccepted() && node.isEnabled()) {
row = (ILookupRow<LOOKUP_KEY>) node.getCell().getValue();
}
return row;
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class DefaultSearchFilterServiceTest method testComposerField.
@Test
public void testComposerField() {
MyComposerField composer = new MyComposerField();
composer.initField();
runBasicAsserts(composer);
CarEntity carEntity = composer.new CarEntity();
ITreeNode carNode = composer.addEntityNode(composer.getTree().getRootNode(), carEntity, true, Collections.emptyList(), new ArrayList<String>());
composer.addAttributeNode(carNode, carEntity.new ColorAttribute(), DataModelConstants.AGGREGATION_NONE, DataModelAttributeOp.create(DataModelConstants.OPERATOR_EQ), CollectionUtility.arrayList("blue key"), CollectionUtility.arrayList("blue value"));
m_searchFilterService.applySearchDelegate(composer, m_searchFilter, false);
StringBuilder result = new StringBuilder();
new ComposerDisplayTextBuilder().build(composer.getTree().getRootNode(), result, "");
Assert.assertEquals(result.toString().trim(), m_searchFilter.getDisplayTextsPlain());
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonOutlineTest method testPageDisposal.
@Test
public void testPageDisposal() {
TablePage tablePage = new TablePage(1, new TablePage.NodePageWithFormFactory());
NodePage nodePage = new NodePage();
List<IPage<?>> pages = new ArrayList<IPage<?>>();
pages.add(nodePage);
IOutline outline = new Outline(pages);
outline.addChildNode(nodePage, tablePage);
outline.selectNode(tablePage);
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
List<ITreeNode> allNodes = JsonTreeTest.getAllTreeNodes(outline);
List<String> allNodeIds = new LinkedList<String>();
for (ITreeNode node : allNodes) {
String nodeId = JsonTreeTest.getOrCreateNodeId(jsonOutline, node);
allNodeIds.add(nodeId);
assertNotNull(nodeId);
assertNotNull(JsonTreeTest.getNode(jsonOutline, nodeId));
}
outline.removeNode(nodePage);
JsonTestUtility.processBufferedEvents(m_uiSession);
// Verify nodes get unregistered
for (ITreeNode node : allNodes) {
assertNull(JsonTreeTest.optNodeId(jsonOutline, node));
}
for (String nodeId : allNodeIds) {
assertNull(JsonTreeTest.getNode(jsonOutline, nodeId));
}
// Verify table adapter gets unregistered
assertNull(m_uiSession.getJsonAdapter(tablePage.getTable(), m_uiSession.getRootJsonAdapter()));
}
Aggregations