XML Tree with GEF [message #214605] |
Wed, 19 April 2006 08:31 |
Eclipse User |
|
|
|
Originally posted by: kosteen.web.de
Hallo,
I am new to GEF and want to represent an xml-file as a tree with GEF. Should I create a model or is it possible to do it directly like, say, it is in swing?
Are there examples for it?
|
|
|
Re: XML Tree with GEF [message #214847 is a reply to message #214605] |
Mon, 24 April 2006 14:42 |
Eclipse User |
|
|
|
Originally posted by: guedes.bruno.gmail.com
Hi Shabaltas,
You can use a JFaces TreeViewer or a GEF TreeViewer.
To use the second one, you have to use the duo Model-EditPart, and
Policies to do action in the widget created !!
If you use the first one, you can do it without a model !!!
With GEF :
public class MyTreeEditor extends GraphicalEditorWithPalette {
public void createPartControl(Composite parent) {
gefTreeViewer = new TreeViewer();
gefTreeViewer.createControl(sf);
gefTreeViewer.setEditDomain(getEditDomain());
//The factory who create the edipart in relation of the model to
use !!
gefTreeViewer.setEditPartFactory(editPartFactory);
...
}
With JFaces :
viewer = new TreeViewer();
viewer.setUseHashlookup(true);
XmlEditorContentProvider xmlProvider = new
XmlEditorContentProvider();
viewer.setContentProvider(xmlProvider);
XmlEditorLabelProvider labelProvider = new XmlEditorLabelProvider();
viewer.setLabelProvider(labelProvider);
MyNode root = new MyNode("root");
MyNode fils = new MyNode("titi");
MyNode fils2 = new MyNode("tutu");
fils.addChild(new MyNode("test"));
fils.addChild(fils2);
root.addChild(fils);
viewer.setInput(root);
Have fun
Bruno
|
|
|
Powered by
FUDForum. Page generated in 0.02702 seconds