Ruben Laguna's blog

Aug 23, 2007 - 1 minute read - Comments - eclipse font fontdefinition formatter java plugin

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);

with

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:

   <extension
         point="org.eclipse.ui.themes">
      <fontDefinition
            categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
            defaultsTo="org.eclipse.jdt.internal.ui.compare.JavaMergeViewer"
            id="com.rubenlaguna.eclipse.javacompare.JavaFormattingMergeViewer"
            label="Java compare text font (ignore formatting changes)">
         <description>
            The Java compare text font is used by Java compare/merge tools when the ignore formatting changes plugin is loaded.
         </description>
      </fontDefinition>     
   </extension>

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.

avahi and .local domain troubleshooting Stockholm photos