Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Adding connections with custom layers
Adding connections with custom layers [message #194236] Wed, 31 August 2005 17:51 Go to next message
Nick Allen is currently offline Nick AllenFriend
Messages: 23
Registered: July 2009
Junior Member
I am trying to simply add connections between figures which exist in my
diagram. I know I have implemented the connection code correctly
because it works in the case when my diagram edit part's figure is a
simple Freeformlayer like most of the GEF examples.

The problem comes when I have added custom layers to my diagram. What
follows is the code I have added to my diagram's editpart to allow for
these custom layers.

Each EditPart for my model elements decide which layer they want to be
added to through their getLayer() method. In addChildVisual, I use this
method to add the figure to one of my custom layers.

The problem is that after I click on the first figure to start the
connection and then start to move the mouse toward the target figure,
the entire platform locks up in an infinite loop. It seems to occur
when I drag the connection to a point which is an inch or so away from
the source figure. The editor's scrollbars rapidly move side-to-side
and up-to-down. It seems that for some reason a call to
readjustScrollbars keeps being made. I have included the stack trace below.

Any thoughts woulds be greatly appreciated.

--Nick


-------------------------

protected void addChildVisual(EditPart childEditPart, int index)
{

if(childEditPart instanceof ElementEditPart) {
String layerID = ((ElementEditPart)childEditPart).getLayer();
if(layerID == null)
super.addChildVisual(childEditPart, index);

Layer layer = findLayer(layerID);
if(layer == null)
throw new IllegalArgumentException("Invalid layer: " + layerID);
IFigure child = ((GraphicalEditPart)childEditPart).getFigure();

// in adding multiple layers we need to ignore the index??
//layer.add(child, index);
layer.add(child);
}
else
super.addChildVisual(childEditPart, index);
}


protected void removeChildVisual(EditPart childEditPart)
{
if(childEditPart instanceof ElementEditPart) {
String layerID = ((ElementEditPart)childEditPart).getLayer();
Layer layer = findLayer(layerID);
if(layer == null)
throw new IllegalArgumentException("Invalid layer: " + layerID);

IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
layer.remove(child);
}
else
super.removeChildVisual(childEditPart);
}

protected final IFigure createFigure()
{
container = new LayerContainer();
container.setLayoutManager(new FreeformLayout());
addLayer(new Layer(), BACKGROUND_LAYER); // background objects
addLayer(new Layer(), FOREGROUND_LAYER); // most object will reside here
addLayer(new Layer(), LABEL_LAYER); // labels overlay most everything
addLayer(new Layer(), SPECIAL_LAYER);

ConnectionLayer connLayer =
(ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER);
connLayer.setConnectionRouter(newShortestPathConnectionRoute r(container));
return container;
}


-----------------------------------------


Thread [main] (Suspended)
owns: DeferredUpdateManager (id=92)
owns: RunnableLock (id=93)
OS._gtk_main_do_event(int) line: not available [native method]
OS.gtk_main_do_event(int) line: 4777
Display.eventProc(int, int) line: 1067
OS._gtk_adjustment_value_changed(int) line: not available [native method]
OS.gtk_adjustment_value_changed(int) line: 3274
ScrollBar.setValues(int, int, int, int, int, int) line: 646
FigureCanvas$1.propertyChange(PropertyChangeEvent) line: 57
PropertyChangeSupport.firePropertyChange(PropertyChangeEvent ) line: 333
PropertyChangeSupport.firePropertyChange(String, Object, Object) line: 270
PropertyChangeSupport.firePropertyChange(String, int, int) line: 291
DefaultRangeModel.firePropertyChange(String, int, int) line: 60
DefaultRangeModel.setAll(int, int, int) line: 118
FreeformViewport.readjustScrollBars() line: 81
FreeformViewport(Viewport).validate() line: 364
LightweightSystem$RootFigure(Figure).validate() line: 1738
DeferredUpdateManager.validateFigures() line: 271
DeferredUpdateManager.performUpdate() line: 143
DeferredUpdateManager$UpdateRequest.run() line: 40
RunnableLock.run() line: 35
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123
Display.runAsyncMessages(boolean) line: 2844
Display.readAndDispatch() line: 2575
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1699
Workbench.runUI() line: 1663
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 367
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
IDEApplication.run(Object) line: 103
PlatformActivator$1.run(Object) line: 226
EclipseStarter.run(Object) line: 376
EclipseStarter.run(String[], Runnable) line: 163
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
Main.invokeFramework(String[], URL[]) line: 334
Main.basicRun(String[]) line: 278
Main.run(String[]) line: 973
Main.main(String[]) line: 948
Re: Adding connections with custom layers [message #194247 is a reply to message #194236] Wed, 31 August 2005 18:03 Go to previous messageGo to next message
Nick Allen is currently offline Nick AllenFriend
Messages: 23
Registered: July 2009
Junior Member
> protected final IFigure createFigure()
> {
> container = new LayerContainer();
> container.setLayoutManager(new FreeformLayout());
> addLayer(new Layer(), BACKGROUND_LAYER); // background objects
> addLayer(new Layer(), FOREGROUND_LAYER); // most object will reside here
> addLayer(new Layer(), LABEL_LAYER); // labels overlay most everything
> addLayer(new Layer(), SPECIAL_LAYER);
>
> ConnectionLayer connLayer =
> (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER);
> connLayer.setConnectionRouter(newShortestPathConnectionRoute r(container));
> return container;
> }

Also Layer and LayerContainer are just stand-ins for FreeformLayer and
FreeformLayeredPane, respectively. Here are their definitions along
with addLayer.

private class Layer extends FreeformLayer {
public Layer() {
setBorder(new MarginBorder(3));
setLayoutManager(new FreeformLayout());
}
}

private class LayerContainer extends FreeformLayeredPane {}

private void addLayer(Layer layer, String layerId) {
layerMap.put(layerId, layer);
container.add(layer, layerId);
}

Thanks
Nick
Re: Adding connections with custom layers [message #194309 is a reply to message #194236] Thu, 01 September 2005 01:44 Go to previous message
Nick Allen is currently offline Nick AllenFriend
Messages: 23
Registered: July 2009
Junior Member
Update: I removed the code that adds the connection router and the
problem does not occur anymore. I need to figure out exactly why this is.

There are other odd problems occurring now that I need to figure out.
Perhaps there are other methods that I need to implement besides
addChildVisual and removeChildVisual to make my custom layers work.
Previous Topic:Coordinate system
Next Topic:GEF & EMF representing AbsoluteBendpoint in EMF
Goto Forum:
  


Current Time: Mon Jan 20 17:12:36 GMT 2025

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

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

Back to the top