Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2012-02-10 22:02:12 +0000
committercdumoulin2012-02-10 22:02:12 +0000
commit953380086e7c91a9bca45c880ae15ddf2e62f31c (patch)
treefa9f672c42630903dd2116cc64ada14f0e53b9ac
parente535c5ea0fa50bf924ffcae513076e78d72a66a4 (diff)
downloadorg.eclipse.papyrus-953380086e7c91a9bca45c880ae15ddf2e62f31c.tar.gz
org.eclipse.papyrus-953380086e7c91a9bca45c880ae15ddf2e62f31c.tar.xz
org.eclipse.papyrus-953380086e7c91a9bca45c880ae15ddf2e62f31c.zip
ASSIGNED - bug 368704: [sasheditor] SashEditor does not invoke dispose() of nested IEditorPart
https://bugs.eclipse.org/bugs/show_bug.cgi?id=368704 NEW - bug 366943: [Performance] Editors Memory leaks https://bugs.eclipse.org/bugs/show_bug.cgi?id=366943 Allows disposal of the site associated to a nested editor.
-rw-r--r--org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java34
-rw-r--r--org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/IMultiPageEditorSite.java38
-rw-r--r--org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java2
-rw-r--r--org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite4x.java2
4 files changed, 73 insertions, 3 deletions
diff --git a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
index b084f2b00e6..ed5967e38aa 100644
--- a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
+++ b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
@@ -16,12 +16,15 @@ package org.eclipse.papyrus.infra.core.sasheditor.internal;
import java.io.PrintWriter;
import java.io.StringWriter;
+import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.core.sasheditor.Activator;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel;
import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage;
+import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.IMultiPageEditorSite;
import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageEditorSite;
import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageEditorSite4x;
import org.eclipse.swt.SWT;
@@ -36,6 +39,8 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.internal.ErrorEditorPart;
import org.eclipse.ui.internal.dnd.IDropTarget;
@@ -416,11 +421,38 @@ public class EditorPart extends PagePart implements IEditorPage {
*/
public void dispose() {
+ System.out.println("org.eclipse.papyrus.infra.core.sasheditor.internal.EditorPart.dispose()");
detachListeners(editorControl, true);
// dispose the SWT root control
editorControl.dispose();
// Dispose the editor.
- editorPart.dispose();
+// editorPart.dispose();
+ disposePart(editorPart);
+
+
+ }
+
+ /**
+ * Disposes the given part and its site.
+ *
+ * @param part
+ * The part to dispose; must not be <code>null</code>.
+ * @copy copied from org.eclipse.ui.part.MultiPageEditorPart.disposePart(IWorkbenchPart) v3.8
+ */
+ private void disposePart(final IWorkbenchPart part) {
+ SafeRunner.run(new ISafeRunnable() {
+ public void run() {
+ IWorkbenchPartSite partSite = part.getSite();
+ part.dispose();
+ if (partSite instanceof IMultiPageEditorSite) {
+ ((IMultiPageEditorSite) partSite).dispose();
+ }
+ }
+
+ public void handleException(Throwable e) {
+ // Exception has already being logged by Core. Do nothing.
+ }
+ });
}
diff --git a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/IMultiPageEditorSite.java b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/IMultiPageEditorSite.java
new file mode 100644
index 00000000000..931b12aced8
--- /dev/null
+++ b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/IMultiPageEditorSite.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Cedric Dumoulin.
+ *
+ *
+ * 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy;
+
+import org.eclipse.ui.IEditorSite;
+
+
+/**
+ * Interface implemented by site used by nested editors of MultiPageEditor.
+ * This interface add the dispose() method.
+ * This interface is added in order to allow different implementation of the site,
+ * mainly to have a version for 3.8 and 4.x.
+ *
+ * @since 0.9
+ *
+ * @author cedric dumoulin
+ *
+ */
+public interface IMultiPageEditorSite extends IEditorSite {
+
+ /**
+ * Method called when the Site should be disposed.
+ * After calling this method, the site is no longer available.
+ */
+ public void dispose();
+}
diff --git a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
index 3ef4aad2c3c..65b339d6200 100644
--- a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
+++ b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
@@ -56,7 +56,7 @@ import org.eclipse.ui.services.IServiceScopes;
*
* @see org.eclipse.ui.part.MultiPageEditorSite.class
*/
-public class MultiPageEditorSite implements IEditorSite, INestable {
+public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
org.eclipse.ui.part.MultiPageEditorSite e;
diff --git a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite4x.java b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite4x.java
index 1a20ef7cb15..b56ddcb1a4d 100644
--- a/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite4x.java
+++ b/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite4x.java
@@ -71,7 +71,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
*
* @see org.eclipse.ui.part.MultiPageEditorSite.class
*/
-public class MultiPageEditorSite4x implements IEditorSite, INestable {
+public class MultiPageEditorSite4x implements IMultiPageEditorSite, INestable {
org.eclipse.ui.part.MultiPageEditorSite e;

Back to the top