changeset 6:6287f5e469f1

Reset the title image when an editor is closed.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 07 Sep 2015 14:42:44 +0200
parents dd4ab3c8d143
children fe67b0af9b23
files src/de/codedo/java/editor/CodedoJavaEditor.java src/de/codedo/java/editor/CodedoJavaElementImageProvider.java
diffstat 2 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/de/codedo/java/editor/CodedoJavaEditor.java	Tue Dec 16 07:38:49 2014 +0100
+++ b/src/de/codedo/java/editor/CodedoJavaEditor.java	Mon Sep 07 14:42:44 2015 +0200
@@ -57,13 +57,30 @@
 
 	public void toggleTitleImage()
 	{
-		IEditorInput input = getEditorInput();
-		
-		// this class is registered as Java editor so we should always have a java element here
-		IJavaElement javaElement = (IJavaElement)input.getAdapter(IJavaElement.class);
+		IJavaElement javaElement = getJavaElement();
 
 		CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
 		Image newTitleImage =  imageProvider.toggleTitleImage(javaElement);
 		setTitleImage(newTitleImage);
 	}
+
+	@Override
+	public void dispose()
+	{
+		CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
+
+		IJavaElement javaElement = getJavaElement();
+		imageProvider.resetTitleImage(javaElement);
+		
+		super.dispose();
+	}
+	
+	private IJavaElement getJavaElement()
+	{
+		IEditorInput input = getEditorInput();
+		
+		// this class is registered as Java editor so we should always have a java element here
+		return (IJavaElement)input.getAdapter(IJavaElement.class);
+	}
+
 }
--- a/src/de/codedo/java/editor/CodedoJavaElementImageProvider.java	Tue Dec 16 07:38:49 2014 +0100
+++ b/src/de/codedo/java/editor/CodedoJavaElementImageProvider.java	Mon Sep 07 14:42:44 2015 +0200
@@ -63,4 +63,9 @@
 		}
 		return _customTitleImage;
 	}
+
+	public void resetTitleImage(IJavaElement element)
+	{
+		_editorsWithCustomTitleImage.remove(element);
+	}
 }