I have created two trees in gwt-ext one contains the values of nodes that can be dragged and other the nodes which can be dropped on. The problem being i am not able to set only a particular set of leaves mentioned in the array, from a tree to be dragged on other tree while the leaves which are not in the array cannot be dragged. I have enabled drag drop on the tree and then manually allow a leaf to disable drag but its not working. Tried it using the setallowdrag() method and also using setTreeAttribute("allowDrag",false) but don't know why it just doesn't work. Please help.
TreeNode n22=treePanel.getNodeById("ynode-121");
n22.setTreeAttribute("allowDrag","false");
n22.setAllowDrag(false);
Related
I'm developing a small GUI using JavaFX for an assignment. Having never used JavaFX before, most of what I've used or learned I've research myself. Most of my application runs smoothly, animations included.
I have a small user input section:
I'm trying to allow it to swipe left prior to loading the next scene, to give the user the impression of sequence. I achieved this using a ParallelTransition populated by TranslationTransitions in which I load all of these Nodes.
However, just slightly before it animates, it appears to align everything right.
I have a feeling this is something to do with the container (AnchorPane) in which I'm placing these objects, or some undefined attribute which I'm not setting. As I'm learning this all on the fly, it's a bit difficult to narrow down. Can anyone give me an idea as to what is causing this and how I can retain the alignment? Each Node moves in the following way:
translateTransition.setFromX(node.getLayoutX());
translateTransition.setToX(node.getLayoutX()-500.00);
If I've left out any pertinent information, please let me know!
So, my issue turned out to be the way I'm laying out my objects. Placing them in an arbitrary AnchorPane with only specific attributes to locate those items means that, upon animation, it will group those objects and animate them accordingly. It was the incorrect way to layout those nodes.
Instead, I've placed them in a VBox which has two advantages.
I can align the contents of that VBox centre, so I need not specify the exact layout attributes of the elements.
I can animate using the single VBox, as opposed to the all the elements in a ParallelTransition. As a result, a single TranslateTransition on the VBox node will suffice!
I am new to prefuse and don't understand several things regarding nodes.
How can I get an event raised whenever a node clicked?
How can I group similar nodes with the same color?
How can I keep an extra meta-data on every node?
Its important to say that I build the graph in real-time and not loading it from any file.
Thanks,
Ozrad.
Three answers to your three questions:
The best way to react on node clicks is to extend prefuse.controls.ControlAdapter and add it to the Display.
prefuse.action.assignment.DataColorAction assigns color based on a data field. For more advanced scenarios you can use ColorAction with predicates or extend the class DataColorAction.
You can add columns to the node table to store metadata. A column can also store objects if you need it:
vg.getNodeTable().addColumn("meta", MyMetaData.class);
I am making a program in Java and I have a SWT tree widget that the user is supposed to toy with via drag and drop.
Now the problem is that when the user drags and drops a branch, I want to change the branch item's parent to whichever treeItem it was dropped on, but there doesn't appear to be any way to do so. I could simply create a new treeItem, but there is no easy way to transfer the children, so I need to redefine all the children, and their grandchildren and so on recursively. It seems pretty klunky and inefficient to me that I need to remake the entire branch just to change the parent.
Is there any clean way to do this?
Well, the clean way is to separate view/widgets from model (as in MVC). In case of SWT, you should use TreeViewer and implement ITreeContentProvider. jFace will take care of creating tree nodes for you and you only need to update your model and refresh the viewer.
I am new to eclipse RCP, well as a matter of fact to java also. Have a very basic question.
I have a JFace TreeViewer. I want to expand a particular node in that. The catch is I only have the name of the node. and no information apart from that.
I tried using treeItem, compared its string with that of the node name that I have, thus I got the node. I tried expanding it in the contentprovider of the tree. But i am not getting the desired output. When I check it in the log i get that it is expanded but it doesnt show in the viewer. I am performing this in display.asyncExec method in the contentprovider.
I hope the question is clear.
JFace viewers were created so that developers wouldn't have to mess around with SWT widgets and could use higher level API instead. When using JFace's viewer/content provider/label provider you should be in control of what nodes are in your tree (thus when you say you only know the name, I assume you are using SWT Tree directly). You can read about JFace viewers from Eclipse help.
To expand a tree node use expandToLevel(Object elementOrTreePath, int level) method of TreeViewer (the level is relative to the node that is expanded, not the root of the tree).
I have a jtree and I only want the user to be able to select sibling nodes. If the user selects nodes that aren't siblings, I want the previously selected nodes to be deselected.
The user should also be able to select sibling nodes that aren't contiguous. I was hoping to extend defaulttreeselectionmodel.
Is there a simple way to do this?
Seems like you'll have to play with TreeSelectionModel (which will store current selection state) and TreeSelectionListener. An example algorithm could be the following : when your selection change, if your TreeSelectionListener is not in active mode, it enters into that mode (this is useful as your listener will update selection in some cases, and you don't want crazy cycles, want you ?). Then, it checks selected nodes using TreeSelectionModel#getSelectionPaths(). If this array size is one, only one node is selected and all is OK. If its size si greater than 1, then you'll have to write some code to ensure those nodes are siblings (as an example by ensuring their TreePath are identical except the last part.