Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Using GEF inside a ViewPart

Hi All,

Apologies for sending this to a dev list, but I didn't see a user list for GEF.

So, I read most of the IBM redbook relating to GEF and the on-line documentation. I saw that the Viewers from GEF can be used in various places, other than editors, such as views. Unfortunately I have failed terribly in trying to get this to work.

I've created an Eclipse plug-in and created a new view extension within which I would like to use GEF to display a graph of my model. The class responsible for implementing the view extension is below.

So the view appears in the work bench as expected, I'm using a canvas as the graphical control for the ScrollingGraphicalViewer. I use a plug-in action to call the setContents of the ViewPart (see method definition below), which calls setContents on of the ScrollingGraphicalViewer.

The setContents adds all of the contents (via the CFGEditPartFactory) as expected.

Each EditPart that gets added only implements the createFigure and the refreshVisuals, no listeners.

Nothing is displayed in the View of the plug-in. It seems I am missing something quite fundamental here and if anyone has an example they could send on how to do what I'm trying I would very much appreciate it. I seriously cannot find any such examples anywhere. If I get a response then I'm willing to add documentation of this example to the GEF web site to help others who may have similar problems.

So, thanks in advance for any help offered.

Regards,
Jason Brown


public class CFGView extends ViewPart {
	private ScrollingGraphicalViewer mSGV;

	public CFGView() {
		ScalableRootEditPart srep = new ScalableRootEditPart();
		mSGV = new ScrollingGraphicalViewer();
		mSGV.setRootEditPart(srep);
		srep.setViewer(mSGV);
		mSGV.setEditPartFactory(new CFGEditPartFactory());
		CWorkspace.setCFGView(this);

	}

	public void addContent(Cfg cfg)
	{
		mSGV.setContents(cfg);
	}
	
	public void createPartControl(Composite parent) {
		Canvas c = new Canvas(parent, 0);
		mSGV.setControl(c);
	}

	private void showMessage(String message) {
	}

	public void setFocus() {
		mSGV.getControl().setFocus();
	}
}



Back to the top