use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method treeNodeToJson.
protected JSONObject treeNodeToJson(ITreeNode node) {
JSONObject json = new JSONObject();
putProperty(json, "id", getOrCreateNodeId(node));
putProperty(json, "expanded", node.isExpanded());
putProperty(json, "expandedLazy", node.isExpandedLazy());
putProperty(json, "lazyExpandingEnabled", node.isLazyExpandingEnabled());
putProperty(json, "leaf", node.isLeaf());
putProperty(json, "checked", node.isChecked());
putProperty(json, "enabled", node.isEnabled());
putProperty(json, "iconId", BinaryResourceUrlUtility.createIconUrl(node.getCell().getIconId()));
putProperty(json, "initialExpanded", node.isInitialExpanded());
putChildNodeIndex(json, node);
putCellProperties(json, node.getCell());
JSONArray jsonChildNodes = new JSONArray();
if (node.getChildNodeCount() > 0) {
for (ITreeNode childNode : node.getChildNodes()) {
if (!isNodeAccepted(childNode)) {
continue;
}
jsonChildNodes.put(treeNodeToJson(childNode));
}
}
putProperty(json, "childNodes", jsonChildNodes);
JsonObjectUtility.filterDefaultValues(json, "TreeNode");
return json;
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method toJson.
@Override
public JSONObject toJson() {
JSONObject json = super.toJson();
JSONArray jsonNodes = new JSONArray();
for (ITreeNode childNode : getTopLevelNodes()) {
if (!isNodeAccepted(childNode)) {
continue;
}
jsonNodes.put(treeNodeToJson(childNode));
}
putProperty(json, PROP_NODES, jsonNodes);
putProperty(json, PROP_SELECTED_NODES, nodeIdsToJson(getModel().getSelectedNodes(), true, true));
putProperty(json, PROP_MENUS, getJsonContextMenu().childActionsToJson());
return json;
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method handleModelChildNodeOrderChanged.
protected void handleModelChildNodeOrderChanged(TreeEvent event) {
JSONObject jsonEvent = new JSONObject();
jsonEvent.put("parentNodeId", getNodeId(event.getCommonParentNode()));
boolean hasNodeIds = false;
for (ITreeNode childNode : event.getChildNodes()) {
if (!isNodeAccepted(childNode)) {
continue;
}
String childNodeId = optNodeId(childNode);
if (childNodeId == null) {
// Ignore nodes that are not yet sent to the UI (may happen due to asynchronous event processing)
continue;
}
jsonEvent.append("childNodeIds", childNodeId);
hasNodeIds = true;
}
if (hasNodeIds) {
addActionEvent(EVENT_CHILD_NODE_ORDER_CHANGED, jsonEvent);
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method jsonToCheckedInfo.
protected CheckedInfo jsonToCheckedInfo(JSONObject data) {
JSONArray jsonNodes = data.optJSONArray("nodes");
CheckedInfo checkInfo = new CheckedInfo();
for (int i = 0; i < jsonNodes.length(); i++) {
JSONObject jsonObject = jsonNodes.optJSONObject(i);
ITreeNode row = m_treeNodes.get(jsonObject.getString("nodeId"));
checkInfo.getAllNodes().add(row);
if (jsonObject.optBoolean("checked")) {
checkInfo.getCheckedNodes().add(row);
} else {
checkInfo.getUncheckedNodes().add(row);
}
}
return checkInfo;
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method handleUiNodeExpanded.
protected void handleUiNodeExpanded(JsonEvent event) {
String nodeId = event.getData().getString(PROP_NODE_ID);
ITreeNode node = optTreeNodeForNodeId(nodeId);
if (node == null) {
LOG.info("Requested tree-node with ID {} doesn't exist. Skip nodeExpanded event", nodeId);
return;
}
boolean expanded = event.getData().getBoolean(PROP_EXPANDED);
boolean lazy = event.getData().getBoolean(PROP_EXPANDED_LAZY);
int eventType = expanded ? TreeEvent.TYPE_NODE_EXPANDED : TreeEvent.TYPE_NODE_COLLAPSED;
addTreeEventFilterCondition(eventType).setNodes(CollectionUtility.arrayList(node));
getModel().getUIFacade().setNodeExpandedFromUI(node, expanded, lazy);
}
Aggregations