Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-12-12 18:50:23 +0000
committerChristian W. Damus2014-12-12 20:14:41 +0000
commit8f951e53677c4fa6bec567337581c7fc27d85631 (patch)
tree9f78f40f2e368870e90b8c5c6d70cdc63d58c42a /plugins/views/properties
parent4c8c059d27f444d9ea8240535de853db81e8b158 (diff)
downloadorg.eclipse.papyrus-8f951e53677c4fa6bec567337581c7fc27d85631.tar.gz
org.eclipse.papyrus-8f951e53677c4fa6bec567337581c7fc27d85631.tar.xz
org.eclipse.papyrus-8f951e53677c4fa6bec567337581c7fc27d85631.zip
454536: [Properties View] Impossible to display the properties pages after reopening of a project
https://bugs.eclipse.org/bugs/show_bug.cgi?id=454536 Ensure that the current selection in the Property sheet is forgotten when closing the model if the selection is from that model. Also ensure that the property sheet always updates to show the current Model Explorer selection when the explorer view is activated (otherwise it may still be showing what was relevant for a previous model editor). Furthermore, when re-using a data source in the property sheet, if that data source contains unloaded objects, then don't reuse it, to ensure that widgets aren't re-used that remember the previous editor's resource-set and other context.
Diffstat (limited to 'plugins/views/properties')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
index f20e3add355..dc26c6eb599 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultDisplayEngine.java
@@ -12,6 +12,7 @@
* Christian W. Damus (CEA) - bug 417409
* Christian W. Damus (CEA) - bug 444227
* Christian W. Damus - bug 450478
+ * Christian W. Damus - bug 454536
*
*****************************************************************************/
package org.eclipse.papyrus.views.properties.runtime;
@@ -20,6 +21,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -29,6 +31,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.catalog.PropertiesURIHandler;
import org.eclipse.papyrus.views.properties.contexts.Context;
@@ -194,8 +197,11 @@ public class DefaultDisplayEngine implements DisplayEngine {
DataSource existing = getDataSource(section);
if (!allowDuplicate && (existing != null)) {
- if (conflictingArity(existing.getSelection(), source.getSelection())) {
- // Cannot reuse a multiple-selection data source for single-selection and vice-versa
+ if (isUnloaded(existing) || conflictingArity(existing.getSelection(), source.getSelection())) {
+ // If it's a left-over from an unloaded resource, then rebuild the properties UI because
+ // element-browser widgets and other things may remember the previous (now invalid)
+ // resource-set context. Also, cannot reuse a multiple-selection data source for
+ // single-selection and vice-versa
disposeControls(section);
} else {
// Update the data source and fire the bindings
@@ -220,6 +226,24 @@ public class DefaultDisplayEngine implements DisplayEngine {
return displayedSections.get(section);
}
+ /**
+ * Queries whether any object selected in a data source is unloaded (now an EMF proxy object).
+ *
+ * @param dataSource
+ * a data source
+ * @return whether it contains an unloaded model element
+ */
+ protected boolean isUnloaded(DataSource dataSource) {
+ boolean result = false;
+
+ for (Iterator<?> iter = dataSource.getSelection().iterator(); !result && iter.hasNext();) {
+ EObject next = EMFHelper.getEObject(iter.next());
+ result = (next != null) && ((EObject) next).eIsProxy();
+ }
+
+ return result;
+ }
+
protected boolean conflictingArity(IStructuredSelection selection1, IStructuredSelection selection2) {
return (selection1.size() <= 1) != (selection2.size() <= 1);
}

Back to the top