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 index 1f3bacf..fcf6188 100644 --- 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 @@ -6,6 +6,8 @@ import java.lang.reflect.Method; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.part.WorkbenchPart; /** * This class provides backward compatibility between versions of Eclipse for @@ -16,6 +18,8 @@ import org.eclipse.swt.widgets.FontDialog; public class VersioningHelper { public static final int ECLIPSE_VERSION_2_1_1 = 2135; + public static final int ECLIPSE_VERSION_3_0_RC1 = 3054; + public static final int ECLIPSE_VERSION_3_0_RC3 = 3061; /** * Set the font in a FontDialog. In Eclipse 2.1.1, the @@ -46,4 +50,30 @@ public class VersioningHelper { // should not happen } } + + public static void setPartName(ViewPart viewPart, String partName) { + try { + if (SWT.getVersion() >= ECLIPSE_VERSION_3_0_RC1) { + Method method = WorkbenchPart.class.getDeclaredMethod( + "setPartName", new Class[] { String.class }); + method.invoke(viewPart, new Object[] {partName}); + } else { + Method method = WorkbenchPart.class.getDeclaredMethod( + "setTitle", new Class[] { FontData.class }); + method.invoke(method, new Object[] { partName }); + } + } catch (NoSuchMethodException e) { + // should not happen + } catch (IllegalArgumentException e) { + // should not happen + } catch (IllegalAccessException e) { + // should not happen + } catch (InvocationTargetException e) { + // should not happen + } + } + + public static void main(String[] args) { + System.out.println(SWT.getVersion()); + } }