harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r507467 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/ test/api/java/common/java/awt/
Date Wed, 14 Feb 2007 10:24:51 GMT
Author: apetrenko
Date: Wed Feb 14 02:24:50 2007
New Revision: 507467

URL: http://svn.apache.org/viewvc?view=rev&rev=507467
Log:
Patch for HARMONY-1605 "[classlib][awt]Compatibility: java.awt.Window has null default Font
on RI while it hasn't on Harmony"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
Wed Feb 14 02:24:50 2007
@@ -186,11 +186,6 @@
         }
     }
 
-    @Override
-    boolean hasDefaultFont() {
-        return true;
-    }
-
     public String getLabel() {
         toolkit.lockAWT();
         try {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
Wed Feb 14 02:24:50 2007
@@ -2960,17 +2960,12 @@
     public Font getFont() {
         toolkit.lockAWT();
         try {
-            if (font == null && hasDefaultFont()) {
-                return toolkit.getDefaultFont();
-            }
-            if (font == null && parent != null) {
-                return parent.getFont();
-            }
-            return font;
+            return (font == null) && (parent != null) ? parent.getFont() : font;
         } finally {
             toolkit.unlockAWT();
         }
     }
+    
 
     public void setFont(Font f) {
         Font oldFont;
@@ -2992,9 +2987,6 @@
         }
     }
 
-    boolean hasDefaultFont() {
-        return false;
-    }
 
     /**
      * Invalidate the component if it inherits the font from the parent. This

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Wed
Feb 14 02:24:50 2007
@@ -75,6 +75,8 @@
     public static final int LAYOUT_NO_START_CONTEXT = 2;
 
     public static final int LAYOUT_NO_LIMIT_CONTEXT = 4;
+    
+    static final Font DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 12); //$NON-NLS-1$
 
     protected String name;
 
@@ -353,17 +355,17 @@
         // as the delimiter to avoid unexpected parse results of font face names 
         // with spaces.
         
+        if (str == null) {
+            return DEFAULT_FONT;
+        }
+        
         StringTokenizer strTokens;
         String delim = "-"; //$NON-NLS-1$
         String substr;
 
-        int fontSize = 12;
-        int fontStyle = Font.PLAIN;
-        String fontName = "dialog"; //$NON-NLS-1$
-
-        if (str == null) {
-            return new Font(fontName, fontStyle, fontSize);
-        }
+        int fontSize = DEFAULT_FONT.size;
+        int fontStyle = DEFAULT_FONT.style;
+        String fontName = DEFAULT_FONT.name;
 
         strTokens = new StringTokenizer(str.trim(), delim);
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java Wed
Feb 14 02:24:50 2007
@@ -273,11 +273,6 @@
     }
 
     @Override
-    boolean hasDefaultFont() {
-        return true;
-    }
-
-    @Override
     AccessibleContext createAccessibleContext() {
         return new AccessibleAWTLabel();
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
Wed Feb 14 02:24:50 2007
@@ -539,6 +539,11 @@
             } else {
                 disposed = false;
             }
+            
+            if (getFont() == null) {
+                setFont(Font.DEFAULT_FONT);
+            }
+            
             super.show();
             toFront();
             if (!opened) {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java?view=diff&rev=507467&r1=507466&r2=507467
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
Wed Feb 14 02:24:50 2007
@@ -338,6 +338,37 @@
         assertTrue(tc.areFocusTraversalKeysSet(id));
 
     }
+    
+    public void testGetFont() {
+        // Regression for HARMONY-1605
+        final Font defaultFont = new Font("Dialog", Font.PLAIN, 12); //$NON-NLS-1$
+        final Window w = new Window(new Frame());
+        final Component c = tc;
+        final Button b = new Button();
+
+        assertNull(w.getFont());
+        assertNull(c.getFont());
+        w.add(c);
+        assertNull(c.getFont());
+        w.setVisible(true);
+        assertEquals(defaultFont, w.getFont());
+        assertEquals(defaultFont, c.getFont());
+
+        assertNull(b.getFont());
+        b.setVisible(true);
+        assertNull(b.getFont());
+        b.setVisible(false);
+        b.setVisible(true);
+        assertNull(b.getFont());
+        new Frame().add(b);
+        assertNull(b.getFont());
+        w.add(b);
+        assertEquals(defaultFont, b.getFont());
+
+        w.setVisible(false);
+        w.dispose();
+        // End of regression for HARMONY-1605
+    }
 
     private void createRobot() {
         try {



Mime
View raw message