|
|
Re: Problem adding a vertical ruler listener [message #870569 is a reply to message #869757] |
Tue, 08 May 2012 19:13 |
Pedro Pires Messages: 3 Registered: April 2012 |
Junior Member |
|
|
I tested it again, and the code I pasted here isn't working. The editor.getAdapter(IVerticalRuler.class) returns null.
I extended the java editor, and overrided the createJavaSourceViewer() method. In this method I have access to the vertical ruler, which now is the editor's composite ruler for sure (not null). I added the listener to this ruler, and the problem remained the same.
The drawback of this implementation is that I had to extend the CompilationUnitEditor class, which is discouraged. Maybe the problem is because of this, and I don't want to file a bug while extending the java editor. If I find a suitable way to add the listener, and the problem still remains, I'll file the bug.
Is there a way to add a vertical ruler listener without extending the java editor?
OBS: right after registering the ruler listener, I called the CompositeRuler.fireAnnotationSelected() method, and my listener was called as expected. When executing the plugin in debug mode, I can see that the editor has 2 ruler listeners: [cideplus.ui.presentation.VerticalRulerListener@ 11c048e, org.eclipse.jdt.internal.ui.javaeditor.JavaSelectMarkerRulerAction2@ 77bcd5]
Pedro
[Updated on: Tue, 08 May 2012 19:13] Report message to a moderator
|
|
|
Re: Problem adding a vertical ruler listener [message #870740 is a reply to message #870569] |
Wed, 09 May 2012 13:54 |
Pedro Pires Messages: 3 Registered: April 2012 |
Junior Member |
|
|
Created a fresh plugin just to test this.
Listener code:
public class VerticalRulerListener implements IVerticalRulerListener {
public VerticalRulerListener() {
System.out.println("VerticalRulerListener.VerticalRulerListener()");
}
public void annotationSelected(VerticalRulerEvent event) {
System.out.println("VerticalRulerListener.annotationSelected()");
}
public void annotationDefaultSelected(VerticalRulerEvent event) {
System.out.println("VerticalRulerListener.annotationDefaultSelected()");
}
public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) {
System.out.println("VerticalRulerListener.annotationContextMenuAboutToShow()");
}
}
Editor code:
public class MyJavaEditor extends CompilationUnitEditor {
@Override
protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
ISourceViewer javaSourceViewer = super.createJavaSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
if (verticalRuler instanceof IVerticalRulerInfoExtension)
((IVerticalRulerInfoExtension) verticalRuler).addVerticalRulerListener(new VerticalRulerListener());
((CompositeRuler) verticalRuler).fireAnnotationSelected(null);
return javaSourceViewer;
}
}
When I call fireAnnotationSelected() the listener is called, but when I click on any annotation in the vertical ruler, it isn't called.
|
|
|
Powered by
FUDForum. Page generated in 0.02548 seconds