Prevent drag and drop outside of branch - apache-flex

I have an AdvancedDataGrid that I populate with HierachialData from XML. I've enabled drag and drop of the children nodes, but want to prevent a child node from being dropped outside of a branch. A child must always be in a branch.
How can I test if the dropped node is outside of a branch?

I managed to solve this using the dragComplete event where I check for any nodes that should be in a branch and copy the node and append it to the last found branch node and delete the dragged one.
If the user drags the leaf to the top of the tree it appends it to the first branch node. This also works well with being able to drag and drop leafs to closed branches.
Is there a way to move/re-parent nodes or am I limited to append a copy/delete old node?

Related

Change a JavaFX node's parent in a single Add+Remove event, not two separate events

I want to move a child node from one parent's child list to another parent's child list without triggering a listener for the "null parent" case. I do so with only a single command:
newParent.getChildren().add(child)
But this triggers two separate change events on child.parentProperty:
oldParent -> null
null -> newParent
This causes problems in my user interface. I have a tab pane, where each tab allows selecting a node in the tab, such that when you navigate to another tab, then back to the first tab, the node is still selected. A listener deselects that node when the tab is no longer in the node's ancestry, that is, when the node is removed from the tab.
Naturally, the first of the two events is triggering the listener, removing the node from the tab, even if temporarily, and so deselecting the node.
What can I do to avoid this?

how to assign properties/explorer view to tree in Javafx?

I have a fall tree with output shown in picture below.In BorderPane "Center" a SplitPane is used to split the view. I want to assign the properties/explorer view to the tree branches & leafs, so that each branch and leaf should have its own properties/explorer view.
My question is this how can i assign this particular split's right side view shown in picture to branch "module" only, and what would be changes if user want this view to be assigned to any leaf. if user click on other branches or leaf this view/properties should not appear. if you need i can provide my sample code,its simple editable tree-view.
i tried but failed. Please
thank you

Prevent drag outside QTreeWidget

In a QTreeWidget I want to be able to reorder items using InternalMove AND receive drops from another tree in my application.
If I set dragDropMode to InternalMove I cannot drop items inside it. However, if I set it to DragDrop it lets the user drag items out of the my QTreeWidget.
Is there a way of preventing this? Is there another way around the problem?
If you are not worried about drags outside of your application, maybe setting the DragDropMode of the other QTreeWidget in your application (or anything that derives from QAbstractItemView for that matter) to:
treeWidget->setDragDropMode(QAbstractItemView::DragOnly);
is enough to get the desired behavior. This does not prevent the items of the QTreeWidget in question from being dragged, but they cannot be dropped in the other tree, while you can still drop them (and the items from the DragOnly tree) into the tree that accepts drops. Does this help? (Admittedly not the most intricate way to attack the problem but performing some local tests it seemed to work)

How do you make drag and drop always copy (never remove) in a Flex 4 Spark List?

Using the built in drag and drop features in Flex I can drag an item from one list and drop it into another list. But this removes the item from the first list. In my case I need to keep the items in the original list. So I need to always create a copy behavior for my users.
There is a property called, "dragMoveEnabled" that was set to "true".
From the documentation:
The description of this property is, "A flag that indicates whether items can be moved instead of just copied from the control as part of a drag-and-drop operation. If true, and the dragEnabled property is true, items can be moved. Often the data provider cannot or should not have items removed from it, so a MOVE operation should not be allowed during drag-and-drop."
When set to false or removed I'm getting the behavior that I want which is Copy always without having to also press the CTRL key for it to work.

Can I add a node to a tree without adding it to the dataProvider?

I've got a couple trees that I allow a user to drag and drop from one to another, works great except one apparent limitation. I'm picking up where they drop it in the list and adding it to the dataProvider manually. The user can drop it everywhere except after the last child of any particular node it seems, since it reads that position as being between the node and it's next sibling.
It seems the best way to deal with this is to add something like a dummy leaf so the user has something to drop the item in front of. I don't want this leaf in the dataProvider, so is it possible to add a leaf (or a folder) to the tree without adding it to the dataProvider? if so how?
Unfortunately, that is not possible.
Thanks Gabriel, I worked around the issue by adding the item when a node is opened, removing it when the node is closed, also loop through and remove it all before data is committed to the DB.

Resources