509684: EMF Parsley Editor problem with Properties view in Oxygen

Change-Id: I6d58ba9a7b49bb1a33a74fd848e427473e058308
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=509684
diff --git a/plugins/org.eclipse.emf.parsley.editors.common/src/org/eclipse/emf/parsley/editors/EmfAbstractEditor.java b/plugins/org.eclipse.emf.parsley.editors.common/src/org/eclipse/emf/parsley/editors/EmfAbstractEditor.java
index beea7a7..534ab85 100644
--- a/plugins/org.eclipse.emf.parsley.editors.common/src/org/eclipse/emf/parsley/editors/EmfAbstractEditor.java
+++ b/plugins/org.eclipse.emf.parsley.editors.common/src/org/eclipse/emf/parsley/editors/EmfAbstractEditor.java
@@ -23,6 +23,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -139,7 +140,7 @@
 	 * 
 	 * @generated
 	 */
-	protected PropertySheetPage propertySheetPage;
+	protected List<PropertySheetPage> propertySheetPages = new ArrayList<PropertySheetPage>();
 
 	/**
 	 * This is the viewer that shadows the selection in the content outline. The
@@ -190,7 +191,7 @@
 					getActionBarContributor().setActiveEditor(EmfAbstractEditor.this);
 				}
 			} else if (p instanceof PropertySheet) {
-				if (((PropertySheet) p).getCurrentPage() == propertySheetPage) {
+				if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
 					getActionBarContributor().setActiveEditor(EmfAbstractEditor.this);
 					handleActivate();
 				}
@@ -498,8 +499,13 @@
 		if (mostRecentCommand != null) {
 			setSelectionToViewer(mostRecentCommand.getAffectedObjects());
 		}
-		if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
-			propertySheetPage.refresh();
+		for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();) {
+			PropertySheetPage propertySheetPage = i.next();
+			if (propertySheetPage.getControl().isDisposed()) {
+				i.remove();
+			} else {
+				propertySheetPage.refresh();
+			}
 		}
 	}
 
@@ -702,25 +708,21 @@
 	 * @generated
 	 */
 	public IPropertySheetPage getPropertySheetPage() {
-		if (propertySheetPage == null) {
-			propertySheetPage = new ExtendedPropertySheetPage(editingDomain) {
-				@Override
-				public void setSelectionToViewer(List<?> selection) {
-					EmfAbstractEditor.this.setSelectionToViewer(selection);
-					EmfAbstractEditor.this.setFocus();
-				}
+		PropertySheetPage propertySheetPage = new ExtendedPropertySheetPage(editingDomain) {
+			@Override
+			public void setSelectionToViewer(List<?> selection) {
+				EmfAbstractEditor.this.setSelectionToViewer(selection);
+				EmfAbstractEditor.this.setFocus();
+			}
 
-				@Override
-				public void setActionBars(IActionBars actionBars) {
-					super.setActionBars(actionBars);
-					getActionBarContributor().shareGlobalActions(this,
-							actionBars);
-				}
-			};
-			propertySheetPage
-					.setPropertySourceProvider(new AdapterFactoryContentProvider(
-							adapterFactory));
-		}
+			@Override
+			public void setActionBars(IActionBars actionBars) {
+				super.setActionBars(actionBars);
+				getActionBarContributor().shareGlobalActions(this, actionBars);
+			}
+		};
+		propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+		propertySheetPages.add(propertySheetPage);
 
 		return propertySheetPage;
 	}
@@ -1079,7 +1081,7 @@
 			getActionBarContributor().setActiveEditor(null);
 		}
 
-		if (propertySheetPage != null) {
+		for (PropertySheetPage propertySheetPage : propertySheetPages) {
 			propertySheetPage.dispose();
 		}