comparison src/de/codedo/java/editor/CodedoJavaEditor.java @ 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 f7d908568cfc
children 778c251baa66
comparison
equal deleted inserted replaced
5:dd4ab3c8d143 6:6287f5e469f1
55 field.set(labelProvider, imageProvider); 55 field.set(labelProvider, imageProvider);
56 } 56 }
57 57
58 public void toggleTitleImage() 58 public void toggleTitleImage()
59 { 59 {
60 IEditorInput input = getEditorInput(); 60 IJavaElement javaElement = getJavaElement();
61
62 // this class is registered as Java editor so we should always have a java element here
63 IJavaElement javaElement = (IJavaElement)input.getAdapter(IJavaElement.class);
64 61
65 CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider(); 62 CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
66 Image newTitleImage = imageProvider.toggleTitleImage(javaElement); 63 Image newTitleImage = imageProvider.toggleTitleImage(javaElement);
67 setTitleImage(newTitleImage); 64 setTitleImage(newTitleImage);
68 } 65 }
66
67 @Override
68 public void dispose()
69 {
70 CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
71
72 IJavaElement javaElement = getJavaElement();
73 imageProvider.resetTitleImage(javaElement);
74
75 super.dispose();
76 }
77
78 private IJavaElement getJavaElement()
79 {
80 IEditorInput input = getEditorInput();
81
82 // this class is registered as Java editor so we should always have a java element here
83 return (IJavaElement)input.getAdapter(IJavaElement.class);
84 }
85
69 } 86 }