Bug 568720 - [Robotics] RoboticsContentProvider generates a NPE when built using a IStructuredContentProvider

 - Added a method in FilterStereotypes to get the value of protected attribute stereotypeFilter
 - In RoboticsContentProvider, when encapsulated is an instance of class FilterStereotypes, the stereotypeFilter is initialized using the method above

Change-Id: I0329bd16fd0d13bcfc2d77ba19e0385d2d8d979d
Signed-off-by: Matteo MORELLI <matteo.morelli@cea.fr>
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/FilterStereotypes.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/FilterStereotypes.java
index dd48855..6bfa301 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/FilterStereotypes.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/FilterStereotypes.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2017-2020 CEA LIST.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
  *
  * Contributors:
  *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr>       - Bug 568720
  *
  *****************************************************************************/
 
@@ -40,6 +41,16 @@
 		this.stereotypeFilter = stereotypeFilter;
 	}
 
+	/**
+	 * Read access to the filter condition.
+	 *
+	 * @return stereotypeFilter a filter condition
+	 */
+	public Class<? extends EObject> getStereotypeFilter() {
+		return stereotypeFilter;
+	}
+
+	@Override
 	public boolean isValid(final Object object) {
 		if (object instanceof Element) {
 			return StereotypeUtil.isApplied((Element) object, stereotypeFilter);
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/RoboticsContentProvider.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/RoboticsContentProvider.java
index d446030..bb85141 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/RoboticsContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/provider/RoboticsContentProvider.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST.
+ * Copyright (c) 2019, 2020 CEA LIST.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
  *
  * Contributors:
  *  Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr>       - Bug 568720
  *
  *****************************************************************************/
 
@@ -61,7 +62,7 @@
 	protected Class<? extends EObject> stereotypeFilter;
 
 	/**
-	 * 
+	 *
 	 * Constructor.
 	 *
 	 * @param context
@@ -79,7 +80,7 @@
 	}
 
 	/**
-	 * 
+	 *
 	 * Constructor.
 	 *
 	 * @param context
@@ -96,6 +97,11 @@
 			Activator.log.debug("RoboticsContentProvider: passed context is not contained in a resource (proxy?)"); //$NON-NLS-1$
 		}
 		this.encapsulated = encapsulated;
+		if (encapsulated instanceof FilterStereotypes) {
+			this.stereotypeFilter = ((FilterStereotypes) encapsulated).getStereotypeFilter();
+		} else {
+			Activator.log.debug("RoboticsContentProvider: passed encapsulated content provider does not specialize class org.eclipse.papyrus.robotics.core.provider.FilterStereotypes"); //$NON-NLS-1$
+		}
 		this.extension = extension;
 		tempRS = new ResourceSetImpl();
 	}