Skip to main content

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

Gordon Hirsch wrote:
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.

...

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.

I found the same problem under Windows and SWT3.3, no matter which JDK version I used. I've added another version check to handle this case, and have consolidated internal version query code.

### Eclipse Workspace Patch 1.0
#P org.eclipse.albireo.core
Index: src/org/eclipse/albireo/internal/Platform.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/internal/Platform.java,v
retrieving revision 1.1
diff -u -r1.1 Platform.java
--- src/org/eclipse/albireo/internal/Platform.java	7 Dec 2007 21:14:28 -0000	1.1
+++ src/org/eclipse/albireo/internal/Platform.java	16 Feb 2008 23:21:24 -0000
@@ -9,10 +9,12 @@
  * Contributors:
  *     SAS Institute Inc. - initial API and implementation
  *     ILOG S.A. - initial API and implementation
+ *     IBM Corporation - Java/SWT versioning code (from org.eclipse.swt.internal.Library)
  *******************************************************************************/
 package org.eclipse.albireo.internal;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.Library;
 
 public class Platform {
     private static String platformString = SWT.getPlatform();
@@ -21,6 +23,7 @@
         // prevent instantiation
     }
     
+    // Window System
     public static boolean isWin32() {
         return "win32".equals(platformString); //$NON-NLS-1$
     }
@@ -29,4 +32,56 @@
         return "gtk".equals(platformString); //$NON-NLS-1$
     }
     
+    //Java
+    /**
+     * The JAVA version
+     */
+    public static final int JAVA_VERSION;
+    static {
+        JAVA_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 javaVersion(major, minor, micro);
+    }
+
+    /**
+     * Returns the Java version number as an integer.
+     * 
+     * @param major
+     * @param minor
+     * @param micro
+     * @return the version
+     */
+    public static int javaVersion (int major, int minor, int micro) {
+        return (major << 16) + (minor << 8) + micro;
+    }
+
+    //SWT
+    // It seems necessary to use private API to get this value. Provide delegating methods here so that
+    // the internal dependency is localized. 
+    public static final int SWT_VERSION = Library.SWT_VERSION;
+    public static final int SWT_33 = swtVersion(3, 300);
+    public static final int SWT_34 = swtVersion(3, 400);
+    
+    private static int swtVersion(int major, int minor) {
+        return Library.SWT_VERSION(major, minor);
+    }
 }
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
--- src/org/eclipse/albireo/internal/JavaPlatform.java	14 Feb 2008 03:44:39 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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 version
-     */
-    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;
-    }
-
-}
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.34
diff -u -r1.34 SwingControl.java
--- src/org/eclipse/albireo/core/SwingControl.java	14 Feb 2008 05:29:53 -0000	1.34
+++ src/org/eclipse/albireo/core/SwingControl.java	16 Feb 2008 23:21:24 -0000
@@ -31,7 +31,6 @@
 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;
@@ -55,7 +54,7 @@
     static final boolean verboseSizeLayout = false;
 
     // Whether to print debugging information regarding focus events.
-    static final boolean verboseFocusEvents = false;
+    static final boolean verboseFocusEvents = true;
 
     private Listener settingsListener = new Listener() {
         public void handleEvent(Event event) {
@@ -557,9 +556,15 @@
         // computeSize did not take it into account, the values are always
         // derived from the default size 64x64 of SWT Composites. Ignore these
         // values then! It is better than to use them.
+        //
+        // Do not optimize with the cachedSizesInitialized flag on GTK/Java5 or 
+        // win32/SWT3.3 since this will prevent the initial contents of the control
+        // from being displayed. 
+        // TODO: research the initial content display problem further
         synchronized (this) {
             if ((cachedSizesInitialized >= 2) || 
-                    (Platform.isGtk() && JavaPlatform.VERSION < JavaPlatform.VERSION(1, 6, 0))) {
+                    (Platform.isGtk() && Platform.JAVA_VERSION < Platform.javaVersion(1, 6, 0)) ||
+                    (Platform.isWin32() && Platform.SWT_VERSION < Platform.SWT_34)) {
                 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.6
diff -u -r1.6 LookAndFeelHandler.java
--- src/org/eclipse/albireo/core/LookAndFeelHandler.java	14 Feb 2008 03:44:39 -0000	1.6
+++ src/org/eclipse/albireo/core/LookAndFeelHandler.java	16 Feb 2008 23:21:24 -0000
@@ -17,7 +17,6 @@
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
 
-import org.eclipse.albireo.internal.JavaPlatform;
 import org.eclipse.albireo.internal.Platform;
 
 /**
@@ -77,7 +76,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
-        if (JavaPlatform.VERSION >= JavaPlatform.VERSION(1, 6, 0)) {
+        if (Platform.JAVA_VERSION >= Platform.javaVersion(1, 6, 0)) {
             lafChoice = LAFChoiceNativeSystemNoGtk;
         } else {
             // Set the default to LAFChoiceNativeSystemPreferGtk, so that on

Back to the top