Ruben Laguna’s blog

Updating the Java Compare Plugin

I received some comments about my java compare plugin about my plugin ignoring preferences for text font and formatter settings. I didn’t address those at the beginning because I didn’t notice so as soon as I realized that was missing I put my hands at work.

The java formatter settings was easy just modifying the old

final Properties options = new Properties();
final CodeFormatter codeFormatter = ToolFactory	.createCodeFormatter(options);


final Map options = JavaCore.getOptions();
final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);

That’s easy. The font issue was also easy, just adding the following snippet to the plugin.xml did the trick:

            label="Java compare text font (ignore formatting changes)">
            The Java compare text font is used by Java compare/merge tools when the ignore formatting changes plugin is loaded.

Because JavaFormattingMergeViewer extends JavaMergeViewer whick in turns extends TextMergeViewer the code to manager fonts, etc is already in place it’s just a matter of setting it properly in the plugin.xml.