|
|
|
|
Re: org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #539903 is a reply to message #538805] |
Mon, 14 June 2010 09:02 |
Madhu Samuel Messages: 199 Registered: July 2009 |
Senior Member |
|
|
Hello Simon,
You have not set the parent control for the treeViewer. You do not need
to explicitly set the rootTreeEditPart either.
Refer the below code. The below method is from the ViewPart subclass,
public void createPartControl(Composite parent) {
TreeViewer treeViewer = new TreeViewer();
//Set the parent control for the treeViewer
treeViewer.createControl(parent);
//Get the editor instance
MyGraphicalEditor editor =
(MyGraphicalEditor)PlatformUI.getWorkbench()
..getActiveWorkbenchWindow().getActivePage() .getActiveEditor();
treeViewer.setEditDomain(editor.getEditDomain());
treeViewer.setEditPartFactory(new AppTreeEditPartFactory());
treeViewer.setContents(editor.getModel());
//Synchronze the selection between editor and view
editor.getSelectionSynchronizer().addViewer(treeViewer);
}
Regards,
Madhu Samuel
EclipseBible.com
On 08-06-2010 22:23, simon@gooodguy.de wrote:
> Hi,
>
> first I must say, that I am new to GEF.
>
> I would like to show a TreeViewer in a ViewPart, similar to the
> ContentOutlinePage but as view.
>
> I set up the treeViewer, but nothing is painted in the view. What am i
> doing wrong?
>
> For the moment i'm doing a quickhack to get the model from the
> GraphicalEditor.
>
>
> public class ComponentTypeExplorer extends ViewPart implements
> ISelectionListener {
>
> [...]
>
> public void selectionChanged(IWorkbenchPart part, ISelection selection) {
>
>
> if (part instanceof MyEditor) {
> this.editor = (MyEditor) part;
> this.setEditDomain(((MyEditor) part).getDomain());
> this.setModel(((MyEditor) part).getModel());
> this.createPartControl(this.parent);
> }
>
> }
> public void createPartControl(Composite parent) {
>
> this.parent = parent;
> getViewSite().getPage().addSelectionListener(this);
> if (this.getModel() != null) {
> this.treeViewer = new TreeViewer();
> this.treeViewer.setRootEditPart(new RootTreeEditPart());
> this.treeViewer.setEditDomain(this.domain);
> this.treeViewer.setEditPartFactory(new MyEditPartsFactory());
> this.treeViewer.setContents(this.getModel());
> }
> }
> }
>
Regards,
Madhu
http://eclipsebible.com
|
|
|
Powered by
FUDForum. Page generated in 0.08370 seconds