use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class JsonTree method consumeBinaryResource.
@Override
public void consumeBinaryResource(List<BinaryResource> binaryResources, Map<String, String> uploadProperties) {
if ((getModel().getDropType() & IDNDSupport.TYPE_FILE_TRANSFER) == IDNDSupport.TYPE_FILE_TRANSFER) {
ResourceListTransferObject transferObject = new ResourceListTransferObject(binaryResources);
ITreeNode node = null;
if (uploadProperties != null && uploadProperties.containsKey("nodeId")) {
String nodeId = uploadProperties.get("nodeId");
if (!StringUtility.isNullOrEmpty(nodeId)) {
node = getTreeNodeForNodeId(nodeId);
}
}
getModel().getUIFacade().fireNodeDropActionFromUI(node, transferObject);
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class TreeEventFilter method filter.
/**
* Computes whether the event should be returned to the GUI. There are three cases:
* <ul>
* <li>No filtering happens: The original event is returned. <br>
* This is the case if the conditions don't contain an event with the same type as the original event.</li>
* <li>Partial filtering happens (if condition.checkNodes is true): A new event with a subset of tree nodes is
* returned.<br>
* This is the case if the conditions contain a relevant event but has different nodes than the original event.
* <li>Complete filtering happens: Null is returned.<br>
* This is the case if the event should be filtered for every node in the original event
*/
@Override
public TreeEvent filter(TreeEvent event) {
for (TreeEventFilterCondition condition : getConditions()) {
if (condition.getType() == event.getType()) {
if (condition.checkNodes()) {
Collection<ITreeNode> nodes = new ArrayList<>(event.getNodes());
nodes.removeAll(condition.getNodes());
if (nodes.size() == 0) {
// Ignore event if no nodes remain (or if the event contained no nodes at all)
return null;
}
return new TreeEvent(m_jsonTree.getModel(), event.getType(), event.getCommonParentNode(), nodes);
}
if (condition.checkCheckedNodes()) {
List<ITreeNode> nodes = new ArrayList<>(event.getNodes());
List<ITreeNode> checkedNodes = new ArrayList<>();
List<ITreeNode> uncheckedNodes = new ArrayList<>();
for (ITreeNode node : nodes) {
if (node.isChecked()) {
checkedNodes.add(node);
} else {
uncheckedNodes.add(node);
}
}
if (CollectionUtility.equalsCollection(checkedNodes, condition.getCheckedNodes()) && CollectionUtility.equalsCollection(uncheckedNodes, condition.getUncheckedNodes())) {
// Ignore event if the checked and the unchecked nodes have not changes
return null;
}
// Otherwise, send nodes that have a different checked state than before
checkedNodes.removeAll(condition.getCheckedNodes());
uncheckedNodes.removeAll(condition.getUncheckedNodes());
nodes = CollectionUtility.combine(checkedNodes, uncheckedNodes);
TreeEvent newEvent = new TreeEvent(m_jsonTree.getModel(), event.getType(), event.getCommonParentNode(), nodes);
return newEvent;
}
// Ignore event if only type should be checked
return null;
}
}
return event;
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class AbstractAddAttributeMenu method execOwnerValueChanged.
@Override
protected void execOwnerValueChanged(Object newOwnerValue) {
EntityNode entityNode = null;
ITreeNode treeNode = m_parentNode;
while (treeNode != null) {
if (treeNode instanceof EntityNode) {
entityNode = (EntityNode) treeNode;
break;
}
treeNode = treeNode.getParentNode();
}
List<IDataModelAttribute> attributes;
if (entityNode != null) {
attributes = entityNode.getEntity().getAttributes();
} else {
attributes = m_field.getAttributes();
}
setVisible(attributes.size() > 0);
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.
the class AbstractComposerNode method attachAddEntityMenus.
protected void attachAddEntityMenus(Collection<IMenu> menus) {
EntityNode eNode = null;
ITreeNode n = this;
while (n != null) {
if (n instanceof EntityNode) {
eNode = (EntityNode) n;
break;
}
n = n.getParentNode();
}
List<IDataModelEntity> childEntitites;
if (eNode != null) {
childEntitites = eNode.getEntity().getEntities();
} else {
childEntitites = getComposerField().getEntities();
}
for (IDataModelEntity e : childEntitites) {
menus.add(createAddEntityMenu(e));
}
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode 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);
}
Aggregations