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/editor
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/editor')
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF3
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusPaletteSynchronizer.java57
2 files changed, 31 insertions, 29 deletions
diff --git a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
index 4995983e4c5..7e0bbf7ac34 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
@@ -6,7 +6,8 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
+ com.google.guava;bundle-version="11.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusPaletteSynchronizer.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusPaletteSynchronizer.java
index ad19bc2d895..f655bfc175a 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusPaletteSynchronizer.java
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusPaletteSynchronizer.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Montages AG, CEA, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Montages AG - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 437217
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.editor;
import org.eclipse.gef.ui.views.palette.PaletteView;
@@ -20,27 +33,15 @@ import org.eclipse.ui.IWorkbenchPage;
public PapyrusPaletteSynchronizer(PapyrusMultiDiagramEditor multiEditor) {
myMultiDiagramEditor = multiEditor;
+
+ // Handle the initial page selection
+ synchronizePaletteView(multiEditor.getISashWindowsContainer().getActiveSashWindowsPage());
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener
- * #activeEditorChanged(org.eclipse.papyrus.infra.core.sasheditor.internal.PagePart,
- * org.eclipse.papyrus.infra.core.sasheditor.internal.PagePart)
- */
public void activeEditorChanged(PagePart oldEditor, PagePart newEditor) {
synchronizePaletteView(newEditor);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener#pageChanged(org.eclipse
- * .papyrus.infra.core.sasheditor.editor.IPage)
- */
public void pageChanged(IPage newPage) {
synchronizePaletteView(newPage);
}
@@ -50,21 +51,21 @@ import org.eclipse.ui.IWorkbenchPage;
* inner page
*
* @param activePage
- * inner page to synchronize palette view with
+ * inner page to synchronize palette view with
*/
private void synchronizePaletteView(IPage activePage) {
PaletteView paletteView = findPaletteView();
- if (paletteView == null) {
+ if(paletteView == null) {
return;
}
// IEditorPage is not granted, it may be, e.g ErrorComponentPart
- IEditorPart activePart = activePage instanceof IEditorPage ? ((IEditorPage) activePage).getIEditorPart() : null;
- if (activePart == myLastActivePart) {
+ IEditorPart activePart = activePage instanceof IEditorPage ? ((IEditorPage)activePage).getIEditorPart() : null;
+ if(activePart == myLastActivePart) {
return;
}
-
- if (activePart == null) {
+
+ if(activePart == null) {
paletteView.partClosed(myLastActivePart);
} else {
// multi-editor may be activated outside of this code
@@ -80,15 +81,15 @@ import org.eclipse.ui.IWorkbenchPage;
* Called when host editor is disposed, cleans up
*/
public void dispose() {
- if (myLastActivePart == null) {
- // nothing to do
- return;
- }
PaletteView paletteView = findPaletteView();
- if (paletteView == null) {
+ if(paletteView == null) {
return;
}
- paletteView.partClosed(myLastActivePart);
+ if(myLastActivePart != null) {
+ paletteView.partClosed(myLastActivePart);
+ } else {
+ paletteView.partClosed(myMultiDiagramEditor);
+ }
}
/**
@@ -98,7 +99,7 @@ import org.eclipse.ui.IWorkbenchPage;
*/
private PaletteView findPaletteView() {
IWorkbenchPage samePage = myMultiDiagramEditor.getSite().getPage();
- return (PaletteView) samePage.findView(PaletteView.ID);
+ return (PaletteView)samePage.findView(PaletteView.ID);
}
}

Back to the top