Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » org.eclipse.gef.ui.parts.TreeViewer in ViewPart
org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #538805] Tue, 08 June 2010 16:53 Go to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: June 2010
Junior Member
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());	
		}
	}
}
Re: org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #538913 is a reply to message #538805] Wed, 09 June 2010 05:30 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
treeviwer.createControl call is missing.....

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #539086 is a reply to message #538913] Wed, 09 June 2010 15:25 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: June 2010
Junior Member
thank you very much for your reply.

i add the call to the code, but it still doesn't work.

      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());
			this.treeViewer.createControl(parent);
		}
	}

Re: org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #539128 is a reply to message #539086] Wed, 09 June 2010 17:39 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
try adding it after constructing treeviewer....

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: org.eclipse.gef.ui.parts.TreeViewer in ViewPart [message #539903 is a reply to message #538805] Mon, 14 June 2010 09:02 Go to previous message
Madhu Samuel is currently offline Madhu SamuelFriend
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());
> }
> }
> }
>


Previous Topic:EditPart won't receive CreateRequest
Next Topic:[zest] View fails to update graph after subsequent calls to setInput [closed]
Goto Forum:
  


Current Time: Fri Apr 26 14:34:32 GMT 2024

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

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

Back to the top