Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to extend Compare Editor
How to extend Compare Editor [message #1110133] Mon, 16 September 2013 08:18
Vinod Kumar is currently offline Vinod Kumar
Messages: 1
Registered: September 2013
Junior Member
I need to add a context menu on vertical ruler of a left pane of eclipse compare editor. Another requirement is to have an annotation column on left pane of compare editor vertical ruler to show my annotations. Now since compare editor does not vertical ruler, I tried contributing to the extension point org.eclipse.compare.contentMergeViewers and extend TextMergeViewer, but as it does not expose MergeSourceViewer, I'm trying to get it using reflection, so that I can get SourceViewer on the left pane (MergeSourceViewer) which will give me the vertical ruler object.
This way I can show vertical ruler on the left side of compare editor. Now this custom compare editor is available as one of the options but cannot be opened as default compare editor (as system default editor take precedence over custom editor and and custom editor can be attached as default editor for specific file type only which does not have any default editor).
What is want is to open 2 versions of my file when I double click on a view where file is listed in tree structure and this file can be any text file (java, txt, xml, properties etc).

Now to force the custom compare editor to open on double click I extended the findContentViewer() method of CompareEditorInput class. In this method I returned an instance of custom viewer irrespective of the file type (discarding the instantiated default viewer) and also removed the org.eclipse.compare.contentMergeViewers extension entry from plugin.xml. This way, I can open the custom compare editor on double click on file node of the tree structured view. Now the problem I'm facing is that when I close the custom editor, I get java.lang.NullPointerException
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$ContributorInfo.access$1(TextMergeViewer.java:787)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.handleDispose(TextMergeViewer.java:1832)
at org.eclipse.jdt.internal.ui.compare.JavaMergeViewer.handleDispose(JavaMergeViewer.java:119)
at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:123)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058)
at org.eclipse.swt.widgets.Widget.release(Widget.java:808)

Now the questions are:
1. Is this the right approach to implement the required functionality?
2. If not then what will be the right approach to implement this?
3. What is the reason of NullPointerException and how to resolve this?
Previous Topic:Binary not found
Next Topic:new to Eclipse
Goto Forum:
  


Current Time: Wed Apr 23 02:40:32 EDT 2014

Powered by FUDForum. Page generated in 0.02636 seconds