Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Delayed coloring of shapes throws exception
Delayed coloring of shapes throws exception [message #917931] Thu, 20 September 2012 15:17 Go to next message
Jens B is currently offline Jens BFriend
Messages: 2
Registered: September 2012
Junior Member

i am trying to color the shapes of my diagram with a delay of i.e. 1 sec programmaticly.

So what am i doing. First i start a new thread by clicking a menu button, then i iterate the outgoing connections of a container color them, wait a second, move to a target and start again iterating the connections and so on...

But sometimes i get a ConcurrentModificationException.

	at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
	at java.util.HashMap$ Source)
	at org.eclipse.graphiti.ui.internal.editor.DiagramRefreshJob.runInUIThread(
	at org.eclipse.ui.progress.UIJob$
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(
	at org.eclipse.swt.widgets.Display.runAsyncMessages(
	at org.eclipse.swt.widgets.Display.readAndDispatch(
	at org.eclipse.ui.internal.Workbench.runEventLoop(
	at org.eclipse.ui.internal.Workbench.runUI(
	at org.eclipse.ui.internal.Workbench.access$4(
	at org.eclipse.ui.internal.Workbench$
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(
	at org.eclipse.equinox.launcher.Main.basicRun(
	at org.eclipse.equinox.launcher.Main.main(

The menu button:
public class MenuStartSim implements IWorkbenchWindowActionDelegate {
    public void run(IAction action) {
        new Simulation();

public class Simulation implements Runnable{
    TransactionalEditingDomain editingDomain = null;
    IDiagramTypeProvider diagramTypeProvider = null;
    IFeatureProvider featureProvider = null;
    Diagram diagram = null;
    public Simulation {
        IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
        IWorkbenchPage page = win.getActivePage();
        IEditorPart editor = page.getActiveEditor();
        if(editor instanceof org.eclipse.graphiti.platform.IDiagramEditor) {
            IDiagramEditor graphitiEditor = (IDiagramEditor) editor;
            editingDomain = graphitiEditor.getEditingDomain();
            diagramTypeProvider = graphitiEditor.getDiagramTypeProvider(); 
            featureProvider = diagramTypeProvider.getFeatureProvider();
            diagram = diagramTypeProvider.getDiagram(); 
        new Thread(this).start();
    public void run(){
    void nextStep(EList<Connection> incoming){
        try {
            colorTargets(incoming); //color the shapes
            TimeUnit.SECONDS.sleep( TaskmodelSimulationConfig.configSpeed );
            findTargets(incoming); //find new connections + call nextStep with new connections
        } catch ( InterruptedException e ) { 

So what can i do? there has do be a problem with the given threads, but i dont know how to handle the exception.
I hope someone can help me.
Thanks in advance.
Re: Delayed coloring of shapes throws exception [message #918787 is a reply to message #917931] Fri, 21 September 2012 10:46 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1735
Registered: July 2009
Location: Walldorf, Germany
Senior Member

it seems that you modify a collection just while the editor loops over it
during the update. It's standard Java collection behavior to throw an
exception if that happens. Working on a copy of the collection might solve

Previous Topic:GraphicsAlgorithm coordinates: relative to....?
Next Topic:DirectEditing field position
Goto Forum:

Current Time: Mon Oct 05 12:53:25 GMT 2015

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

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