org.simantics.datatypes;bundle-version="1.0.0",
org.simantics.db;bundle-version="1.1.0",
org.simantics.ui;bundle-version="1.0.0",
- org.slf4j.api
+ org.slf4j.api,
+ org.eclipse.collections.eclipse-collections-api,
+ org.eclipse.collections.eclipse-collections
Export-Package: org.simantics.g2d.canvas,
org.simantics.g2d.canvas.impl,
org.simantics.g2d.chassis,
*******************************************************************************/
package org.simantics.g2d.diagram.impl;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import org.eclipse.collections.api.list.ImmutableList;
+import org.eclipse.collections.api.list.MutableList;
+import org.eclipse.collections.api.set.MutableSet;
+import org.eclipse.collections.impl.factory.Lists;
+import org.eclipse.collections.impl.factory.Sets;
import org.simantics.g2d.diagram.DiagramClass;
import org.simantics.g2d.diagram.IDiagram;
import org.simantics.g2d.diagram.handler.DiagramAdapter;
*/
public class AbstractDiagram implements IDiagram {
- ListenerList<CompositionVetoListener> compositionVetoListeners;
- ListenerList<CompositionListener> compositionListeners;
+ protected ListenerList<CompositionVetoListener> compositionVetoListeners;
+ protected ListenerList<CompositionListener> compositionListeners;
- Set<IElement> elements = new HashSet<IElement>();
- ArrayList<IElement> list = new ArrayList<IElement>();
- List<IElement> unmodifiableList = Collections.unmodifiableList(list);
- volatile List<IElement> snapshot = null;
- DiagramClass clazz;
- IHintContext hintCtx;
+ protected MutableList<IElement> list = Lists.mutable.empty();
+ protected MutableSet<IElement> elements = Sets.mutable.empty();
+ protected volatile ImmutableList<IElement> snapshot = null;
+ private DiagramClass clazz;
+ protected IHintContext hintCtx;
public AbstractDiagram(DiagramClass clazz, IHintContext hintCtx)
{
e.dispose();
}
- elements.clear();
list.clear();
snapshot = null;
}
snapshot = null;
- elements.add(e);
list.add(e);
+ elements.add(e);
e.addedToDiagram(this);
@Override
public List<IElement> getSnapshot() {
- List<IElement> snap = snapshot;
+ ImmutableList<IElement> snap = snapshot;
if (snap != null)
- return snap;
+ return snap.castToList();
synchronized (this) {
snap = snapshot;
if (snap == null)
- snapshot = snap = Collections.unmodifiableList( new ArrayList<IElement>(list) );
+ snapshot = snap = list.toImmutable();
}
- return snap;
+ return snap.castToList();
}
protected static void fireDestroyed(IDiagram e)
@Override
public List<IElement> getElements() {
- return unmodifiableList;
+ return getSnapshot();
}
@Override