Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers')
-rw-r--r--extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/exprmatcher/ExpressionMatcher.java12
-rw-r--r--extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/LayersStackImpl.java4
-rw-r--r--extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/RegExpLayerImpl.java6
-rw-r--r--extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/ObservableListView.java (renamed from extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/NotyfyingList.java)38
4 files changed, 33 insertions, 27 deletions
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/exprmatcher/ExpressionMatcher.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/exprmatcher/ExpressionMatcher.java
index 8d33a4547c9..9280527e5ae 100644
--- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/exprmatcher/ExpressionMatcher.java
+++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/exprmatcher/ExpressionMatcher.java
@@ -34,7 +34,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.ecore.OCL;
import org.eclipse.papyrus.layers.stackmodel.LayersException;
-import org.eclipse.papyrus.layers.stackmodel.util.NotyfyingList;
+import org.eclipse.papyrus.layers.stackmodel.util.ObservableListView;
import com.google.common.collect.Lists;
@@ -57,7 +57,7 @@ public class ExpressionMatcher {
* List of element matching the expression.
* This class maintains the list.
*/
- protected NotyfyingList<View> matchingElements;
+ protected ObservableListView<View> matchingElements;
/**
* List of element used as starting point for search.
@@ -75,7 +75,7 @@ public class ExpressionMatcher {
this.expression = "";
this.searchRoots = Collections.emptyList();
// init matchingElements
- matchingElements = new NotyfyingList<View>(new ArrayList<View>());
+ matchingElements = new ObservableListView<View>(new ArrayList<View>());
}
/**
@@ -89,7 +89,7 @@ public class ExpressionMatcher {
this.expression = "";
this.searchRoots = searchRoots;
// init matchingElements
- matchingElements = new NotyfyingList<View>(new ArrayList<View>());
+ matchingElements = new ObservableListView<View>(new ArrayList<View>());
}
/**
@@ -112,7 +112,7 @@ public class ExpressionMatcher {
*/
public ExpressionMatcher(String expression, List<EObject> searchRoots) throws LayersException {
this.searchRoots = searchRoots;
- matchingElements = new NotyfyingList<View>(new ArrayList<View>());
+ matchingElements = new ObservableListView<View>(new ArrayList<View>());
// compute expr
setExpression(expression);
@@ -266,7 +266,7 @@ public class ExpressionMatcher {
/**
* @return the matchingElements
*/
- public NotyfyingList<View> getMatchingElements() {
+ public ObservableListView<View> getMatchingElements() {
return matchingElements;
}
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/LayersStackImpl.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/LayersStackImpl.java
index ce18474b5a5..e5dcf98361c 100644
--- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/LayersStackImpl.java
+++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/LayersStackImpl.java
@@ -527,6 +527,10 @@ MinimalEObjectImpl.Container implements LayersStack {
* @param addedLayer The added layer.
*/
protected void layerAdded(LayerExpression addedLayer) {
+ // Stop if there is no layer
+ if( addedLayer == null) {
+ return;
+ }
// init the layer
addedLayer.initLayer(this);
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/RegExpLayerImpl.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/RegExpLayerImpl.java
index 965885ead09..ede42349c03 100644
--- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/RegExpLayerImpl.java
+++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/RegExpLayerImpl.java
@@ -41,7 +41,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack;
import org.eclipse.papyrus.layers.stackmodel.layers.RegExpLayer;
import org.eclipse.papyrus.layers.stackmodel.notifier.DiagramViewEventNotifier;
import org.eclipse.papyrus.layers.stackmodel.notifier.IDiagramViewEventListener;
-import org.eclipse.papyrus.layers.stackmodel.util.NotyfyingList;
+import org.eclipse.papyrus.layers.stackmodel.util.ObservableListView;
import com.google.common.eventbus.Subscribe;
@@ -419,7 +419,7 @@ public class RegExpLayerImpl extends AbstractLayerImpl implements RegExpLayer {
}
/**
- * Listener on {@link NotyfyingList} eventBus. This method is called each time a change occurs in the
+ * Listener on {@link ObservableListView} eventBus. This method is called each time a change occurs in the
* result of the expression.
* When the result change, the list of attached views is updated accordingly.
*
@@ -427,7 +427,7 @@ public class RegExpLayerImpl extends AbstractLayerImpl implements RegExpLayer {
* @param event
*/
@Subscribe
- public void expressionResultChanged( NotyfyingList<View>.NotifyingListEvent event) {
+ public void expressionResultChanged( ObservableListView<View>.ObservableListEvent event) {
System.out.println( this.getClass().getSimpleName() + ".expressionResultChanged()");
if( ! event.getAddedElements().isEmpty()) {
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/NotyfyingList.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/ObservableListView.java
index a07fe21e082..a7b8631b5a0 100644
--- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/NotyfyingList.java
+++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/util/ObservableListView.java
@@ -24,7 +24,8 @@ import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
/**
- * A delegate list notifying of events on the delegated list.
+ * An observable list notifying of events on the delegated list.
+ * This view allows to observe a provided list.
* The following events are notified:
* <ul>
* <li>elements added</li>
@@ -35,18 +36,19 @@ import com.google.common.eventbus.EventBus;
* @author cedric dumoulin
*
*/
-public class NotyfyingList<E> extends ForwardingList<E>{
+public class ObservableListView<E> extends ForwardingList<E>{
protected List<E> delegate;
- protected EventBus eventBus = new EventBus(NotyfyingList.class.getName());
+ protected EventBus eventBus = new EventBus(ObservableListView.class.getName());
/**
* Constructor.
+ * Build an observable list based on the provided list.
*
* @param delegate
*/
- public NotyfyingList(List<E> delegate) {
+ public ObservableListView(List<E> delegate) {
this.delegate = delegate;
}
@@ -66,7 +68,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
public boolean add(E element) {
boolean isModified = delegate().add( element);
if( isModified) {
- eventBus.post(new NotifyingListEvent(element));
+ eventBus.post(new ObservableListEvent(element));
}
return isModified;
@@ -76,7 +78,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
public boolean addAll(Collection<? extends E> collection) {
boolean isModified = delegate().addAll(collection);
if( isModified) {
- eventBus.post(new NotifyingListEvent(collection));
+ eventBus.post(new ObservableListEvent(collection));
}
return isModified;
@@ -85,7 +87,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
@Override
public void add(int index, E element) {
delegate().add(index, element);
- eventBus.post(new NotifyingListEvent(element));
+ eventBus.post(new ObservableListEvent(element));
}
@Override
@@ -93,7 +95,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
// TODO Auto-generated method stub
boolean isModified = delegate().addAll(index, elements);
if( isModified) {
- eventBus.post(new NotifyingListEvent(elements));
+ eventBus.post(new ObservableListEvent(elements));
}
return isModified;
@@ -102,7 +104,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
@Override
public E remove(int index) {
E removed = super.remove(index);
- getEventBus().post( new NotifyingListEvent(null, removed));
+ getEventBus().post( new ObservableListEvent(null, removed));
return removed;
}
@@ -112,7 +114,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
public boolean remove(Object object) {
boolean isRemoved = super.remove(object);
if( isRemoved ) {
- getEventBus().post( new NotifyingListEvent(null, (E)object));
+ getEventBus().post( new ObservableListEvent(null, (E)object));
}
return isRemoved;
}
@@ -133,7 +135,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
// Do remove
boolean isRemoved = super.removeAll(collection);
if( isRemoved ) {
- getEventBus().post( new NotifyingListEvent(null, (Collection<? extends E>) removedElements));
+ getEventBus().post( new ObservableListEvent(null, (Collection<? extends E>) removedElements));
}
return isRemoved;
}
@@ -181,7 +183,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
// Fire event
boolean isModified = !(elementsToAdd.isEmpty() && elementsToRemove.isEmpty() );
if( isModified ) {
- getEventBus().post( new NotifyingListEvent(elementsToAdd, elementsToRemove));
+ getEventBus().post( new ObservableListEvent(elementsToAdd, elementsToRemove));
}
return isModified;
@@ -192,7 +194,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
* @author cedric dumoulin
*
*/
- public class NotifyingListEvent {
+ public class ObservableListEvent {
Collection<? extends E> addedElements = Collections.emptyList();
Collection<? extends E> removedElements = Collections.emptyList();
@@ -202,7 +204,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
* Constructor.
*
*/
- public NotifyingListEvent() {
+ public ObservableListEvent() {
this.addedElements = Collections.emptyList();
this.removedElements = Collections.emptyList();
}
@@ -212,7 +214,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
* Constructor.
*
*/
- public NotifyingListEvent(Collection<? extends E> addedElements) {
+ public ObservableListEvent(Collection<? extends E> addedElements) {
if( addedElements!=null ) {
this.addedElements = addedElements;
}
@@ -229,7 +231,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
* @param addedElements added elements or null
* @param removedElements removed elements or null
*/
- public NotifyingListEvent(Collection<? extends E> addedElements, Collection<? extends E> removedElements) {
+ public ObservableListEvent(Collection<? extends E> addedElements, Collection<? extends E> removedElements) {
if( addedElements!=null ) {
this.addedElements = addedElements;
}
@@ -252,7 +254,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
* @param addedElement An element added or null;
* @param removedElement An element added or null
*/
- public NotifyingListEvent( E addedElement, E removedElement) {
+ public ObservableListEvent( E addedElement, E removedElement) {
if( addedElement!=null ) {
addedElements = Collections.singletonList(addedElement);
@@ -275,7 +277,7 @@ public class NotyfyingList<E> extends ForwardingList<E>{
*
* @param addedElement An element added or null;
*/
- public NotifyingListEvent( E addedElement) {
+ public ObservableListEvent( E addedElement) {
if( addedElement!=null ) {
addedElements = Collections.singletonList(addedElement);

Back to the top