|
Re: How to create GEF TreeViewer in a editor [message #178472 is a reply to message #178403] |
Wed, 20 April 2005 15:47 |
Pratik Shah 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
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03463 seconds