Posts Tagged ‘compare’

Eclipse Bug #201116 update: Switch compare viewer for java files

Thursday, September 6th, 2007

I’ve submitted a patch (Attachment #77777 and a couple of screenshots ( Attachment #77774 y Attachment #77776) to Bug #201116. It’s only a preliminary work but it enables the user to select with contentMergeViewer to use with each FileType/ContentType. Now it’s only useful if you use my java formatting compare plugin. Currently the org.eclipse.compare subsystem will allow only one contentMergeViewer per fileType or contentType and you cannot tell which one it will be as Szymon Brandys comments. With this patch the user can select/switch which one he wants to use among all viewer registered for a given file extension/content type.

comparecontenttypeassociationspreferencepage.png

comparefileassociationspreferencepage1.png

Bug 201116 – Compare will silently discard additional contentMergeViewers associated with the same file extension

Friday, August 31st, 2007

I filled Bug 201116 – Compare will silently discard additional contentMergeViewers associated with the same file extension a couple of days ago. As Szymon Brandys says eclipse should allow the user to switch between the differente merge viewer available for a given extension. He proposes two solutions:

1) Having a mechanishm inside the compare view to do the switch 2) or having a preference page to do the same

I feel more inclined towards the second solution, as I’m used to change the defautl editor for .xml, etc though the preference page General -> Editors -> File Associations. Having a similar preference page would fit me. I’m trying to figure out how to integrate a preference page to org.eclipse.compare and send it back to eclipse.org to include it in the next release.

Eclipse Compare. Ignoring java formatting changes not only whitespace.

Saturday, August 18th, 2007

I met some difficulties dealing with the default eclipse java compare. I got involved on a project where everybody likes to commit code to CVS formatted their way, so comparing between CVS revisions is almost impossible.

So I decided to start investigating about Eclipse plugin development to make a Java Compare Viewer that not only ignores whitespace but also all java formatting changes. The result is the following

Before ignore java formatting plugin: comparebefore.png

After ignore java formatting plugin:

compareafter.png

The plugin honors the text font preferences set in General -> Appearance -> Colors and fonts -> Text Compare -> Java compare text font. Also honors the Java Formatter preferences in Java -> Code Style -> Formatter

You can download the plugin and source code tested in Eclipse 3.3 Europa release from here. (The source code is in src folder inside the .jar)

Or you can use Update Manager: http://rubenlaguna.com/javacompare/update-site.

findandinstall.png

To activate/deactivate the plugin all you have to do is press the new icon in the java compare view

comparebutton.png

UPDATE: Depending on your current set of plugins this plugin may or may not work. There is an issue in Eclipse when it comes to registering contentMergeViewers, It seems that when you register more that one contentMergeViewer for a particular file extension (in this case the Eclipse JDT registers org.eclipse.jdt.internal.ui.compare.JavaContentViewerCreator and my plugin registers com.rubenlaguna.eclipse.javacompare.JavaContentViewerCreator) then the CompareUIPlugin.registerExtensions() will only record the last one. I’m trying to figure out how can I force my plugin to register last because right now depending on your configuration my plugin can register before JDT and then JDT will override my contentMergeViewer with his own. I have filed a bug report on eclipse bugzilla about this issue