Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to create GEF TreeViewer in a editor
How to create GEF TreeViewer in a editor [message #178403] Wed, 20 April 2005 08:04 Go to next message
zhang wei is currently offline zhang weiFriend
Messages: 84
Registered: July 2009
Member
Hi all,
I want to create a editor by using GEF.
My Editor is like this, it has two pages.
First page is a TreeViewer(create by org.eclipse.gef.ui.parts.TreeViewer),
second page is a text page.

Although I studyed org.eclipse.gef.examples.logicdesigner.LogicEditor,
I still not known clearly.
I don't know how to put a TreeViewer on GraphicalEditorWithFlyoutPalette
editor?

Here is some code:
-------------------------------------
protected void createGraphicalViewer(Composite parent) {
super.createGraphicalViewer(parent);
pageBook = new PageBook(parent, SWT.NONE);
outline = treeViewer.createControl(pageBook);
overview = new Canvas(pageBook, SWT.NONE);
pageBook.showPage(outline);
configureTreeViewer();
hookOutlineViewer();
initializeOutlineViewer();
}

private void initializeOutlineViewer() {
}

private void hookOutlineViewer() {
getSelectionSynchronizer().addViewer(treeViewer);
}

private void configureTreeViewer(){
treeViewer.setEditDomain(getEditDomain());
treeViewer.setEditPartFactory(new TreePartFactory());
treeViewer.addDropTargetListener(new
TreeDropTargetListener(treeViewer));
treeViewer.setContents(new TestModel());
}
---------------------------------------------
I am not sure it is right.

Where can I found some snippet or some hints ?

THX
Re: How to create GEF TreeViewer in a editor [message #178472 is a reply to message #178403] Wed, 20 April 2005 15:47 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
"wei zhang" <zhang-wei@sinocom.cn> wrote in message
news:e05f0a6611be488511628a31eb6278ce$1@www.eclipse.org...
> Hi all,
> I want to create a editor by using GEF.
> My Editor is like this, it has two pages.
> First page is a TreeViewer(create by org.eclipse.gef.ui.parts.TreeViewer),
> second page is a text page.
>
> Although I studyed org.eclipse.gef.examples.logicdesigner.LogicEditor,
> I still not known clearly.
> I don't know how to put a TreeViewer on GraphicalEditorWithFlyoutPalette
> editor?
>
> Here is some code:
> -------------------------------------
> protected void createGraphicalViewer(Composite parent) {
> super.createGraphicalViewer(parent);

Have you looked to see what this super method does?

> pageBook = new PageBook(parent, SWT.NONE);

Use a MultiPageEditorPart so that you don't have to create your own Tabbed
control (although MPE will bring its own share of grief). First, just try
and bring up your TreeViewer in a single editor. If you were just trying to
copy the logic example when you created the pagebook here, it's not needed
in your case. The logic example uses the pagebook for the outline tree and
the overview. The shapes example will better serve your purpose.

Your biggest problem is going to be that GraphicalEditor expects to be
working with a GraphicalViewer, and TreeViewer is not one. To keep the code
clean and simple, just copy whatever you need from the existing class and
use that as the superclass for your Editor. Replace GraphicalViewer with
EditPartViewer and then you can use some of the existing methods to create
your TreeViewer. createPartControl() (or createControl() or whatever that
method is called) is where it all starts. So you can compare that to the
outline's createPartControl() method.

> outline = treeViewer.createControl(pageBook);
> overview = new Canvas(pageBook, SWT.NONE);
> pageBook.showPage(outline);
> configureTreeViewer();
> hookOutlineViewer();
> initializeOutlineViewer();
> }
>
> private void initializeOutlineViewer() {
> }
>
> private void hookOutlineViewer() {
> getSelectionSynchronizer().addViewer(treeViewer);
> }
>
> private void configureTreeViewer(){
> treeViewer.setEditDomain(getEditDomain());
> treeViewer.setEditPartFactory(new TreePartFactory());
> treeViewer.addDropTargetListener(new
> TreeDropTargetListener(treeViewer));
> treeViewer.setContents(new TestModel());
> }
> ---------------------------------------------
> I am not sure it is right.
>
> Where can I found some snippet or some hints ?
>
> THX
>
Re: How to create GEF TreeViewer in a editor [message #178684 is a reply to message #178472] Thu, 21 April 2005 10:05 Go to previous message
zhang wei is currently offline zhang weiFriend
Messages: 84
Registered: July 2009
Member
Thanks a lot.

I have got a simple TreeViewer in my first page.
Previous Topic:Polygon Figure disappears when moved
Next Topic:Creating complex figures
Goto Forum:
  


Current Time: Mon Jan 30 12:54:40 GMT 2023

Powered by FUDForum. Page generated in 0.02312 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top