1 package com.quantum.util.versioning;
3 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.graphics.FontData;
8 import org.eclipse.swt.widgets.FontDialog;
11 * This class provides backward compatibility between versions of Eclipse for
16 public class VersioningHelper {
18 public static final int ECLIPSE_VERSION_2_1_1 = 2135;
21 * Set the font in a FontDialog. In Eclipse 2.1.1, the
22 * <code>setFontData()</code> method was deprecated and an alternative
23 * method, <code>setFontList()</code> was suggested in its place.
28 public static void setFont(FontDialog fontDialog, FontData[] fontData) {
30 if (SWT.getVersion() >= ECLIPSE_VERSION_2_1_1) {
31 Method method = fontDialog.getClass().getMethod(
32 "setFontList", new Class[] { fontData.getClass()});
33 method.invoke(fontDialog, new Object[] {fontData});
34 } else if (fontData.length > 0) {
35 Method method = fontDialog.getClass().getMethod(
36 "setFontData", new Class[] { FontData.class });
37 method.invoke(fontDialog, new Object[] { fontData[0] });
39 } catch (NoSuchMethodException e) {
41 } catch (IllegalArgumentException e) {
43 } catch (IllegalAccessException e) {
45 } catch (InvocationTargetException e) {