use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class JsonTree method initJsonProperties.
@Override
protected void initJsonProperties(TREE model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TITLE, model) {
@Override
protected String modelValue() {
return getModel().getTitle();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_ICON_ID, model) {
@Override
protected String modelValue() {
return getModel().getIconId();
}
@Override
public Object prepareValueForToJson(Object value) {
return BinaryResourceUrlUtility.createIconUrl((String) value);
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_CSS_CLASS, model) {
@Override
protected String modelValue() {
return getModel().getCssClass();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_CHECKABLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isCheckable();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_MULTI_CHECK, model) {
@Override
protected Boolean modelValue() {
return getModel().isMultiCheck();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isEnabled();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_LAZY_EXPANDING_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isLazyExpandingEnabled();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_AUTO_CHECK_CHILDREN, model) {
@Override
protected Boolean modelValue() {
return getModel().isAutoCheckChildNodes();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_SCROLL_TO_SELECTION, model) {
@Override
protected Boolean modelValue() {
return getModel().isScrollToSelection();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_TYPE, model) {
@Override
protected Integer modelValue() {
return getModel().getDropType();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_MAXIMUM_SIZE, model) {
@Override
protected Long modelValue() {
return getModel().getDropMaximumSize();
}
});
putJsonProperty(new JsonAdapterProperty<ITree>(ITree.PROP_KEY_STROKES, model, getUiSession()) {
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
}
@Override
protected List<IKeyStroke> modelValue() {
return getModel().getKeyStrokes();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_DISPLAY_STYLE, model) {
@Override
protected String modelValue() {
return getModel().getDisplayStyle();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TOGGLE_BREADCRUMB_STYLE_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isToggleBreadcrumbStyleEnabled();
}
});
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class JsonOutlineTest method testDispose.
@Test
public void testDispose() {
ITree tree = new OutlineWithOneNode();
JsonTree<ITree> object = UiSessionTestUtility.newJsonAdapter(m_uiSession, tree, null);
WeakReference<JsonTree> ref = new WeakReference<JsonTree>(object);
object.dispose();
m_uiSession = null;
object = null;
TestingUtility.assertGC(ref);
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class JsonTreeTest method testIgnorableSelectionEvent.
/**
* Response must not contain the selection event if the selection was triggered by the request
*/
@Test
public void testIgnorableSelectionEvent() throws JSONException {
ITree tree = createTreeWithOneNode();
ITreeNode node = tree.getRootNode().getChildNode(0);
JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
JsonEvent event = createJsonSelectedEvent(jsonTree.getOrCreateNodeId(node));
jsonTree.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTree.EVENT_NODES_SELECTED);
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class JsonTreeTest method testNodeFilter.
@Test
public void testNodeFilter() throws JSONException {
TreeNode nodeToFilter = new TreeNode();
nodeToFilter.setEnabled(false);
List<ITreeNode> nodes = new ArrayList<ITreeNode>();
nodes.add(nodeToFilter);
nodes.add(new TreeNode());
nodes.add(new TreeNode());
nodes.add(new TreeNode());
ITree tree = createTree(nodes);
JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
String node0Id = jsonTree.getOrCreateNodeId(nodes.get(0));
assertNotNull(node0Id);
assertNotNull(jsonTree.optTreeNodeForNodeId(node0Id));
tree.addNodeFilter(new ITreeNodeFilter() {
@Override
public boolean accept(ITreeNode node, int level) {
return node.isEnabled();
}
});
JsonTestUtility.processBufferedEvents(m_uiSession);
assertNull(jsonTree.optNodeId(nodes.get(0)));
assertNull(jsonTree.optTreeNodeForNodeId(node0Id));
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class JsonTreeTest method testWrongEventOrder.
/**
* Tests that events are ignored when nodes are not yet inserted.
*/
@Test
public void testWrongEventOrder() throws JSONException {
List<ITreeNode> nodes = new ArrayList<ITreeNode>();
nodes.add(new TreeNode());
nodes.add(new TreeNode());
nodes.add(new TreeNode());
ITree tree = createTree(nodes);
JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
TreeNode newNode = new TreeNode();
jsonTree.handleModelTreeEvent(new TreeEvent(tree, TreeEvent.TYPE_NODE_EXPANDED, newNode));
jsonTree.handleModelTreeEvent(new TreeEvent(tree, TreeEvent.TYPE_NODES_INSERTED, nodes.get(0), Collections.singletonList(newNode)));
JsonTestUtility.processBufferedEvents(m_uiSession);
List<JsonEvent> events = m_uiSession.currentJsonResponse().getEventList();
assertEquals(1, events.size());
assertEquals("nodesInserted", events.get(0).getType());
}
Aggregations