annotate src/de/codedo/java/editor/CodedoJavaEditor.java @ 5:dd4ab3c8d143

Use the same contributorClass as the JDT editor. This brings back the functionality of displaying the current line/column number in the status bar.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 16 Dec 2014 07:38:49 +0100
parents f7d908568cfc
children 6287f5e469f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 package de.codedo.java.editor;
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
3 import java.lang.reflect.Field;
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
5 import org.eclipse.jdt.core.IJavaElement;
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
7 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditorErrorTickUpdater;
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
8 import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 import org.eclipse.swt.graphics.Image;
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
10 import org.eclipse.ui.IEditorInput;
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 public class CodedoJavaEditor extends CompilationUnitEditor
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
14 public CodedoJavaEditor()
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
15 {
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
16 super();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
17 installJavaElementImageProvider();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
18 }
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
19
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
20 private void installJavaElementImageProvider()
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
22 try
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
24 JavaUILabelProvider labelProvider = getJavaUILabelProvider();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
25 setupJavaElementImageProvider(labelProvider);
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 }
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
27 catch (ReflectiveOperationException e)
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
29 throw new RuntimeException(e);
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
30 }
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
31 }
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
32
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
33 private JavaUILabelProvider getJavaUILabelProvider() throws ReflectiveOperationException
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
34 {
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
35 JavaEditorErrorTickUpdater tickUpdater = getJavaEditorErrorTickUpdater();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
36
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
37 Field field = tickUpdater.getClass().getDeclaredField("fLabelProvider");
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
38 field.setAccessible(true);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
39 return (JavaUILabelProvider)field.get(tickUpdater);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
40 }
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
41
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
42 private JavaEditorErrorTickUpdater getJavaEditorErrorTickUpdater() throws ReflectiveOperationException
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
43 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
44 Field field = getClass().getSuperclass().getDeclaredField("fJavaEditorErrorTickUpdater");
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
45 field.setAccessible(true);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
46 return (JavaEditorErrorTickUpdater)field.get(this);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
47 }
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
48
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
49 private void setupJavaElementImageProvider(JavaUILabelProvider labelProvider) throws ReflectiveOperationException
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
50 {
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
51 CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
52
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
53 Field field = labelProvider.getClass().getDeclaredField("fImageLabelProvider");
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
54 field.setAccessible(true);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
55 field.set(labelProvider, imageProvider);
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
56 }
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
57
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
58 public void toggleTitleImage()
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
59 {
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
60 IEditorInput input = getEditorInput();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
61
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
62 // this class is registered as Java editor so we should always have a java element here
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
63 IJavaElement javaElement = (IJavaElement)input.getAdapter(IJavaElement.class);
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
64
1
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
65 CodedoJavaElementImageProvider imageProvider = Activator.getDefault().getJavaElementImageProvider();
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
66 Image newTitleImage = imageProvider.toggleTitleImage(javaElement);
f7d908568cfc Install a custom JavaElementImageProvider subclass so that the custom title image stays in place even if the editor icon is decorated e.g. by error markers.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
67 setTitleImage(newTitleImage);
0
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
68 }
ca07a15b6cc8 created a plugin that allows to set a custom icon on a java editor
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
69 }