Adding connections with custom layers [message #194236] |
Wed, 31 August 2005 17:51 |
Nick Allen 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03757 seconds