[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[albireo-dev] 1.5 Linux initial display problem

Very consistently, on Linux under 1.5, in certain views (e.g. EmbeddedJTable), the SwingControl is not displayed at all for me on initial creation. As soon as any sort of user-initiated resize is done, the SwingControl will appear.

I noticed that SWT_AWT has the following resize listener code in new_Frame

	if (Library.JAVA_VERSION >= Library.JAVA_VERSION(1, 6, 0)) {
		final Rectangle clientArea = parent.getClientArea();
		EventQueue.invokeLater(new Runnable () {
			public void run () {
				frame.setSize (clientArea.width, clientArea.height);
			}
		});
	}

Whatever is meant to set the frame size in 1.5 and earlier is not compatible with our code at the moment. If I remove the if() statement above, the problem goes away.

For now, I've added a version check to hack around this problem in handleSetBounds(). I know its not the long-term solution. We need to revisit our use of the inhibit flag and the cachedSizesInitialized int.


### Eclipse Workspace Patch 1.0
#P org.eclipse.albireo.core
Index: src/org/eclipse/albireo/core/SwingControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/SwingControl.java,v
retrieving revision 1.32
diff -u -r1.32 SwingControl.java
--- src/org/eclipse/albireo/core/SwingControl.java	13 Feb 2008 21:14:48 -0000	1.32
+++ src/org/eclipse/albireo/core/SwingControl.java	14 Feb 2008 03:27:01 -0000
@@ -28,6 +28,7 @@
 import org.eclipse.albireo.internal.CleanResizeListener;
 import org.eclipse.albireo.internal.ComponentDebugging;
 import org.eclipse.albireo.internal.FocusDebugging;
+import org.eclipse.albireo.internal.JavaPlatform;
 import org.eclipse.albireo.internal.Platform;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.SWTException;
@@ -553,7 +554,8 @@
         // derived from the default size 64x64 of SWT Composites. Ignore these
         // values then! It is better than to use them.
         synchronized (this) {
-            if (cachedSizesInitialized >= 2) {
+            if ((cachedSizesInitialized >= 2) || 
+                    (Platform.isGtk() && JavaPlatform.VERSION < JavaPlatform.VERSION(1, 6, 0))) {
                 if (!inhibitSizePropagationToAWT) {
                     setAWTSize(width, height);
                 }
Index: src/org/eclipse/albireo/core/LookAndFeelHandler.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/LookAndFeelHandler.java,v
retrieving revision 1.5
diff -u -r1.5 LookAndFeelHandler.java
--- src/org/eclipse/albireo/core/LookAndFeelHandler.java	4 Feb 2008 23:49:09 -0000	1.5
+++ src/org/eclipse/albireo/core/LookAndFeelHandler.java	14 Feb 2008 03:27:01 -0000
@@ -17,6 +17,7 @@
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
 
+import org.eclipse.albireo.internal.JavaPlatform;
 import org.eclipse.albireo.internal.Platform;
 
 /**
@@ -76,10 +77,7 @@
     {
         // On JDK 1.6, we have to avoid the Swing Gtk look&feel, to work around
         // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126931
-        String javaVersion = System.getProperty("java.version");
-        if (!(javaVersion.startsWith("1.3")
-              || javaVersion.startsWith("1.4")
-              || javaVersion.startsWith("1.5"))) {
+        if (JavaPlatform.VERSION >= JavaPlatform.VERSION(1, 6, 0)) {
             lafChoice = LAFChoiceNativeSystemNoGtk;
         } else {
             // Set the default to LAFChoiceNativeSystemPreferGtk, so that on
Index: src/org/eclipse/albireo/internal/JavaPlatform.java
===================================================================
RCS file: src/org/eclipse/albireo/internal/JavaPlatform.java
diff -N src/org/eclipse/albireo/internal/JavaPlatform.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/albireo/internal/JavaPlatform.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation (org.eclipse.swt.internal.Library)
+ *     SAS Institute Inc. - adapted for Albireo
+ *     ILOG S.A. - adapted for Albireo
+ *******************************************************************************/
+package org.eclipse.albireo.internal;
+
+
+public class JavaPlatform {
+    /**
+     * The JAVA and SWT versions
+     */
+    public static final int VERSION;
+
+    static {
+        VERSION = parseVersion(System.getProperty("java.version")); //$NON-NLS-1$
+    }
+
+    static int parseVersion(String version) {
+        if (version == null) return 0;
+        int major = 0, minor = 0, micro = 0;
+        int length = version.length(), index = 0, start = 0;
+        while (index < length && Character.isDigit(version.charAt(index))) index++;
+        try {
+            if (start < length) major = Integer.parseInt(version.substring(start, index));
+        } catch (NumberFormatException e) {}
+        start = ++index;
+        while (index < length && Character.isDigit(version.charAt(index))) index++;
+        try {
+            if (start < length) minor = Integer.parseInt(version.substring(start, index));
+        } catch (NumberFormatException e) {}
+        start = ++index;
+        while (index < length && Character.isDigit(version.charAt(index))) index++;
+        try {
+            if (start < length) micro = Integer.parseInt(version.substring(start, index));
+        } catch (NumberFormatException e) {}
+        return VERSION(major, minor, micro);
+    }
+
+    /**
+     * Returns the Java version number as an integer.
+     * 
+     * @param major
+     * @param minor
+     * @param micro
+     * @return the version
+     */
+    public static int VERSION (int major, int minor, int micro) {
+        return (major << 16) + (minor << 8) + micro;
+    }
+
+}