Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-06-18 15:57:18 +0000
committerChristian W. Damus2014-07-24 20:15:37 +0000
commitdfde88b139d345b628415dda0769aa87dd7733c6 (patch)
tree6eea3b88d5bbf1f5979a37770dd836407b68a50b /plugins/views/validation
parent660eb9df792ce11992342dfa712e659811d1da11 (diff)
downloadorg.eclipse.papyrus-dfde88b139d345b628415dda0769aa87dd7733c6.tar.gz
org.eclipse.papyrus-dfde88b139d345b628415dda0769aa87dd7733c6.tar.xz
org.eclipse.papyrus-dfde88b139d345b628415dda0769aa87dd7733c6.zip
437217: [Editors] In-place reloading of model resources in the editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=437217 In situ editor reloading. Introduces an IReloadableEditor adapter protocol with an implementation in the CoreMultiDiagramEditor that implements internal destruction of the ServicesRegistry and nested editors. Some refactoring of the initialization and disposal code in the editor class hierarchy and dependencies facilitates reuse of init/dispose code in the reload scenario. The re-loading of an editor is deferred until it is next activated, unless it is already the active editor (can happen when "Save All" is invoked). Editor re-load notifications to dependent views like Model Explorer and Outline. A new listener protocol informs dependents before and after reload so that they may properly dispose of obsolete state and re-initialize when the editor is reloaded. Also ensure that an editor is only reloaded once when some resource that it depends on has changed, not once for each resource. State restoration tokens. Re-load listeners can insert tokens into the re-load event that capture state to be restored after the re-load. Listeners retrieve and apply these tokens after the editor re-loads itself. Current state restoration includes: - tree node expansion and selection state in the Model Explorer view - diagram outline view: which presentation (tree or overview thumbnail) is active - which workbench part is active, such that the correct selection is reflected in views such as Model Explorer, Outline, and Properties - current active diagram in the re-loaded editor - edit-part selections in all diagrams - selection (columns and rows, not individual cells) in table editors - palettes in each diagram (or palette pages when the Palette View is open): * active tool * pinnable stack tool selection * drawer expansion state * drawer scroll position The Palette View support incidentally fixes loss of palette state when switching between Papyrus editors, caused by the PapyrusPaletteSynchronizer. JUnit regression tests for various aspects of editor re-load. Includes a fix for an NPE in the Validation View's content provider that occurs in several tests when an editor is closed or re-loaded. Also support for tests that need to load more than one test-fixture model and/or open more than one editor. Change-Id: Ic0f654ab138d3e091f81f1e9159bcca80d6bb0a5
Diffstat (limited to 'plugins/views/validation')
-rw-r--r--plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java95
1 files changed, 44 insertions, 51 deletions
diff --git a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java
index 23b5f5c347c..c47c5d83a33 100644
--- a/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java
+++ b/plugins/views/validation/org.eclipse.papyrus.views.validation/src/org/eclipse/papyrus/views/validation/internal/providers/ProblemsContentProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 437217
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.validation.internal.providers;
@@ -31,8 +33,7 @@ import com.google.common.collect.Iterables;
/**
* This is the ProblemsContentProvider type. Enjoy.
*/
-public class ProblemsContentProvider
- implements IStructuredContentProvider {
+public class ProblemsContentProvider implements IStructuredContentProvider {
private static final Object[] NONE = {};
@@ -53,31 +54,30 @@ public class ProblemsContentProvider
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = (AbstractTableViewer) viewer;
+ this.viewer = (AbstractTableViewer)viewer;
- if (oldInput instanceof ValidationMarkersService) {
- ValidationMarkersService service = (ValidationMarkersService) oldInput;
+ if(oldInput instanceof ValidationMarkersService) {
+ ValidationMarkersService service = (ValidationMarkersService)oldInput;
unhookMarkers(service);
- unhookResourceSet(service.getModelSet()
- .getTransactionalEditingDomain());
+
+ // The old service may have been disposed if its editor was closed
+ if(service.getModelSet() != null) {
+ unhookResourceSet(service.getModelSet().getTransactionalEditingDomain());
+ }
+
this.service = null;
}
- if (newInput instanceof ValidationMarkersService) {
- ValidationMarkersService service = (ValidationMarkersService) newInput;
+ if(newInput instanceof ValidationMarkersService) {
+ ValidationMarkersService service = (ValidationMarkersService)newInput;
this.service = service;
hookMarkers(service);
- hookResourceSet(service.getModelSet()
- .getTransactionalEditingDomain());
+ hookResourceSet(service.getModelSet().getTransactionalEditingDomain());
}
}
public Object[] getElements(Object inputElement) {
- return (inputElement instanceof ValidationMarkersService)
- ? Iterables.toArray(
- ((ValidationMarkersService) inputElement).getMarkers(),
- IPapyrusMarker.class)
- : NONE;
+ return (inputElement instanceof ValidationMarkersService) ? Iterables.toArray(((ValidationMarkersService)inputElement).getMarkers(), IPapyrusMarker.class) : NONE;
}
protected void hookMarkers(ValidationMarkersService service) {
@@ -89,19 +89,18 @@ public class ProblemsContentProvider
}
private IValidationMarkerListener getValidationMarkerListener() {
- if (listener == null) {
+ if(listener == null) {
listener = new IValidationMarkerListener() {
- public void notifyMarkerChange(IPapyrusMarker marker,
- MarkerChangeKind kind) {
- if (viewer != null) {
- switch (kind) {
- case ADDED :
- viewer.add(marker);
- break;
- case REMOVED :
- viewer.remove(marker);
- break;
+ public void notifyMarkerChange(IPapyrusMarker marker, MarkerChangeKind kind) {
+ if(viewer != null) {
+ switch(kind) {
+ case ADDED:
+ viewer.add(marker);
+ break;
+ case REMOVED:
+ viewer.remove(marker);
+ break;
}
}
}
@@ -120,42 +119,36 @@ public class ProblemsContentProvider
}
private ResourceSetListener getResourceSetListener() {
- if (resourceSetListener == null) {
+ if(resourceSetListener == null) {
resourceSetListener = new DemultiplexingListener() {
@Override
- protected void handleNotification(
- TransactionalEditingDomain domain,
- Notification notification) {
+ protected void handleNotification(TransactionalEditingDomain domain, Notification notification) {
// handle containment changes of problem elements to update
// labels
Object feature = notification.getFeature();
- if ((feature instanceof EReference)
- && ((EReference) feature).isContainment()) {
-
- switch (notification.getEventType()) {
- case Notification.ADD :
- handleContainment((EObject) notification
- .getNewValue());
- break;
- case Notification.ADD_MANY :
- for (Object next : (Collection<?>) notification
- .getNewValue()) {
- handleContainment((EObject) next);
- }
- break;
- case Notification.SET :
- handleContainment((EObject) notification
- .getNewValue());
- break;
+ if((feature instanceof EReference) && ((EReference)feature).isContainment()) {
+
+ switch(notification.getEventType()) {
+ case Notification.ADD:
+ handleContainment((EObject)notification.getNewValue());
+ break;
+ case Notification.ADD_MANY:
+ for(Object next : (Collection<?>)notification.getNewValue()) {
+ handleContainment((EObject)next);
+ }
+ break;
+ case Notification.SET:
+ handleContainment((EObject)notification.getNewValue());
+ break;
}
}
}
private void handleContainment(EObject object) {
Object[] markers = service.getMarkers(object).toArray();
- if (markers.length > 0) {
+ if(markers.length > 0) {
viewer.update(markers, null);
}
}

Back to the top