Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem using GEF,ZEST GraphViewer in RCP views(Problem using GEF,ZEST GraphViewer in RCP views)
Problem using GEF,ZEST GraphViewer in RCP views [message #545991] Fri, 09 July 2010 19:59
syeed is currently offline syeedFriend
Messages: 19
Registered: June 2010
Junior Member

I have some problem managing the RCP Views and commands. In my application, I have a view (GraphView, its a ViewPart) which displays graphs using GraphViewer (ZEST graph viewer). Now different instance of the view(GraphView) displays different graphs. Graph contents are provided by the content providers.

Then in a command (TreeLayout command) I identity the current active instance of the GraphView, then get the GraphViewer in it and try to change the layout and node names. But the problem is, **If i change the layout or rename any node it automatically applied to all the instances of the GraphView. Also if I close the last instace of the GraphView, then the command did not work at all for the others.** How can i solve it? Its really a problem for me.. please help.

Follwoing is the code snippest.

First, i gave the GrahView class,which holds the GraphViewer. Then, the TreeLayout command that suppose to change the layout and node names in the current active instance of the GraphView.

**//view to create graphs.**
public class GraphView extends ViewPart implements IZoomableWorkbenchPart{

public static final String ID = "Views.GraphView";
static GraphViewer viewer = null;

public void createPartControl(Composite parent) {

//creates the GraphViewer
viewer = new GraphViewer(parent, SWT.NONE);

//setting the content provider for the graph.
viewer.setContentProvider( new GraphViewContentProvider());

//setting the lable provider for the graph
viewer.setLabelProvider(new GraphViewLabelProvider());

//setting the initial layout for the graph.
viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)) ;
viewer.setInput(new Object());

//creating the toolbar to hold the zoom menu.

*Returns the GraphViewer. this method is called from TreeLayout

public GraphViewer getGraphViewer()
return viewer;

* Passing the focus request to the viewer's control.
public void setFocus() {

private void fillToolBar() {
ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem(this);
IActionBars bars = getViewSite().getActionBars();

public AbstractZoomableViewer getZoomableViewer() {
return viewer;


**TreeLayout command:** Identify the current active instace of the GraphView and change the layout and node name in the GraphViewer of that instance. It has the following code:

//Get the current active instance of the GraphView
IWorkbenchPart view = org.eclipse.ui.handlers.HandlerUtil.getActivePart(event);
IViewPart part = (IViewPart)view;
GraphView gView = (GraphView)part;

//Get the GraphViewer on this GraphView.
GraphViewer viewer = gView.getGraphViewer();

**//Change the layout. But I applied to the last opened instance of the GraphView.. not on others.**
viewer.setLayoutAlgorithm(new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);

**//change the node name of the graph. But it changes node names in the current active instance as well as all the instance opende after it.**
List<GraphNode> nodeList = viewer.getGraphControl().getNodes();
for (Object c : nodeList) ((GraphNode) c).setText("rajit");

**OpenGraphView command:** Opens different instances of the GraphView with secondary id's.

page.showView("Views.GraphView", "secondaryId"+ Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE);

Many thanks in advance.

Previous Topic:distribute freehand drawing extension for GEF
Next Topic:Adapt FlowLayoutEditPolicy for ToolbarLayout
Goto Forum:

Current Time: Tue May 22 08:28:47 GMT 2018

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

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

Back to the top