X-Git-Url: http://git.phpeclipse.com
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java
new file mode 100644
index 0000000..1f3bacf
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java
@@ -0,0 +1,49 @@
+package com.quantum.util.versioning;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.FontDialog;
+
+/**
+ * This class provides backward compatibility between versions of Eclipse for
+ * known differences.
+ *
+ * @author BC
+ */
+public class VersioningHelper {
+
+ public static final int ECLIPSE_VERSION_2_1_1 = 2135;
+
+ /**
+ * Set the font in a FontDialog. In Eclipse 2.1.1, the
+ * setFontData()
method was deprecated and an alternative
+ * method, setFontList()
was suggested in its place.
+ *
+ * @param fontDialog
+ * @param fontData
+ */
+ public static void setFont(FontDialog fontDialog, FontData[] fontData) {
+ try {
+ if (SWT.getVersion() >= ECLIPSE_VERSION_2_1_1) {
+ Method method = fontDialog.getClass().getMethod(
+ "setFontList", new Class[] { fontData.getClass()});
+ method.invoke(fontDialog, new Object[] {fontData});
+ } else if (fontData.length > 0) {
+ Method method = fontDialog.getClass().getMethod(
+ "setFontData", new Class[] { FontData.class });
+ method.invoke(fontDialog, new Object[] { fontData[0] });
+ }
+ } catch (NoSuchMethodException e) {
+ // should not happen
+ } catch (IllegalArgumentException e) {
+ // should not happen
+ } catch (IllegalAccessException e) {
+ // should not happen
+ } catch (InvocationTargetException e) {
+ // should not happen
+ }
+ }
+}