Home | Games | Media | Programming | Raspberry Pi | Misc Content

Create a Plug-in for Eclipse Tutorial

The Eclipse IDE is highly extendable and can be customized through the creation of plug-ins. With all of its features, one thing it doesn’t have is a simple and quick way to change the font size in the editor without going through a complex preferences screen. This functionality is particularly useful when reviewing your code with others during a code review. Follow these tutorial steps, and you will be able to build such a plug-in allowing you to share your code with people sitting anywhere in the room.

Tutorial Steps

The following steps can be followed in order to build this feature into a plug-in that you can use in your projects.

Additional Features to Add

public void run(IAction action) { IPreferencesService srv = Platform.getPreferencesService(); String value = srv.getString("org.eclipse.ui.workbench","org.eclipse.jdt.ui.editors.textfont", null, null);

Preferences preference = srv.getRootNode().node("/instance/org.eclipse.ui.workbench");
try {
}catch(BackingStoreException e){ /* Do nothing */ } }

private int getFontSize(String info,int fontSize) { return PreferenceConverter.basicGetFontData(info)[0].getHeight(); }

private FontData getFontDataOfSize(String info, int size){ FontData fd = PreferenceConverter.basicGetFontData(info)[0]; fd.setHeight(size); return fd; } </code>


When running a new instance of Eclipse to test your plug-in from Eclipse, you may receive an MaxPermGen exception. This can be fixed by adding the following arguments to your run configuration.

vm args: -XX:MaxPermSize=512M program args: --launcher.XXMaxPermSize=512m