Sorry... Wrong patch. Attached is the good one.
On Fri, 2006-07-07 at 16:09 -0400, Tania Bento wrote:
> Hey,
>
> This patch generates the default name the same way as Sun as does. If
> someone could please comment on or approve this patch, that would be
> great.
>
> Thanks,
> Tania
>
> 2006-07-07 Tania Bento
>
> * gnu/java/awt/peer/ClasspathFontPeer.java
> (isLogicalFontName): Return true if name == default.
> (logicalFontNameToFaceName): Check if name == default,
> and if so, return "Dialog.plain".
> (setStandardAttributes(String, Map)): If name == null,
> it should be set to "Default", not "SansSerif".
> * java/awt/Canvas.java
> (generateName): Fixed documentation.
> * java/awt/CheckboxMenuItem.java
> Added static variable "next_chkmenuitem_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/Choice.java
> Added static variable "next_choice_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/Cursor.java
> (Cursor(int)): Set name depending on the type passed.
> * java/awt/List.java
> Added static variable "next_list_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/Menu.java
> Added static variable "next_menu_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/MenuBar.java
> Added static variable "next_menubar_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/MenuComponent.java
> (getName): Before returning name, check if name == null
> and name is not explicity set. If this is the case,
> name will be generated.
> (generateName): Added and implemented method.
> * java/awt/MenuItem.java
> Added static variable "next_menuitem_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/PopupMenu.java
> Added static variable "next_popup_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/ScrollPane.java
> Added static variable "next_scrollpane_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
> * java/awt/TextField.java
> Added static variable "next_textfield_number".
> (generateName): Added and implemented method.
> (getUniqueLong): Likewise.
>
>
Index: gnu/java/awt/peer/ClasspathFontPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/ClasspathFontPeer.java,v
retrieving revision 1.8
diff -u -r1.8 ClasspathFontPeer.java
--- gnu/java/awt/peer/ClasspathFontPeer.java 2 Jul 2005 20:32:11 -0000 1.8
+++ gnu/java/awt/peer/ClasspathFontPeer.java 7 Jul 2006 20:18:40 -0000
@@ -145,7 +145,8 @@
uname.equals ("SERIF") ||
uname.equals ("MONOSPACED") ||
uname.equals ("DIALOG") ||
- uname.equals ("DIALOGINPUT"));
+ uname.equals ("DIALOGINPUT") ||
+ uname.equals ("DEFAULT"));
}
protected static String logicalFontNameToFaceName (String name)
@@ -161,6 +162,8 @@
return "Helvetica";
else if (uname.equals ("DIALOGINPUT"))
return "Helvetica";
+ else if (uname.equals ("DEFAULT"))
+ return "Dialog.plain";
else
return "Helvetica";
}
@@ -233,7 +236,7 @@
family = (String) attribs.get (TextAttribute.FAMILY);
if (name == null)
- name = "SansSerif";
+ name = "Default";
if (attribs.containsKey (TextAttribute.WEIGHT))
{
Index: java/awt/Canvas.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Canvas.java,v
retrieving revision 1.17
diff -u -r1.17 Canvas.java
--- java/awt/Canvas.java 6 Jul 2006 17:32:52 -0000 1.17
+++ java/awt/Canvas.java 7 Jul 2006 20:18:40 -0000
@@ -350,9 +350,9 @@
}
/**
- * Generate a unique name for this canvas.
+ * Generate a unique name for this <code>Canvas</code>.
*
- * @return A unique name for this canvas.
+ * @return A unique name for this <code>Canvas</code>.
*/
String generateName()
{
Index: java/awt/CheckboxMenuItem.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/CheckboxMenuItem.java,v
retrieving revision 1.21
diff -u -r1.21 CheckboxMenuItem.java
--- java/awt/CheckboxMenuItem.java 20 Sep 2005 01:05:28 -0000 1.21
+++ java/awt/CheckboxMenuItem.java 7 Jul 2006 20:18:40 -0000
@@ -63,6 +63,11 @@
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_chkmenuitem_number;
+
// Serialization constant
private static final long serialVersionUID = 6190621106981774043L;
@@ -352,6 +357,21 @@
accessibleContext = new AccessibleAWTCheckboxMenuItem();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>CheckboxMenuItem</code>.
+ *
+ * @return A unique name for this <code>CheckboxMenuItem</code>.
+ */
+ String generateName()
+ {
+ return "chkmenuitem" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_chkmenuitem_number++;
+ }
} // class CheckboxMenuItem
Index: java/awt/Choice.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Choice.java,v
retrieving revision 1.25
diff -u -r1.25 Choice.java
--- java/awt/Choice.java 30 Mar 2006 18:55:13 -0000 1.25
+++ java/awt/Choice.java 7 Jul 2006 20:18:40 -0000
@@ -63,6 +63,11 @@
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_choice_number;
+
// Serialization constant
private static final long serialVersionUID = -4075310674757313071L;
@@ -639,4 +644,19 @@
accessibleContext = new AccessibleAWTChoice();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>Choice</code>.
+ *
+ * @return A unique name for this <code>Choice</code>.
+ */
+ String generateName()
+ {
+ return "choice" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_choice_number++;
+ }
} // class Choice
Index: java/awt/Cursor.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Cursor.java,v
retrieving revision 1.9
diff -u -r1.9 Cursor.java
--- java/awt/Cursor.java 30 Jan 2006 12:23:26 -0000 1.9
+++ java/awt/Cursor.java 7 Jul 2006 20:18:40 -0000
@@ -142,7 +142,37 @@
throw new IllegalArgumentException ("invalid cursor " + type);
this.type = type;
- // FIXME: lookup and set name?
+
+ if (type == 0)
+ name = "Default Cursor";
+ else if (type == 1)
+ name = "Crosshair Cursor";
+ else if (type == 2)
+ name = "Text Cursor";
+ else if (type == 3)
+ name = "Wait Cursor";
+ else if (type == 4)
+ name = "Southwest Resize Cursor";
+ else if (type == 5)
+ name = "Southeast Resize Cursor";
+ else if (type == 6)
+ name = "Northwest Resize Cursor";
+ else if (type == 7)
+ name = "Northeast Resize Cursor";
+ else if (type == 8)
+ name = "North Resize Cursor";
+ else if (type == 9)
+ name = "South Resize Cursor";
+ else if (type == 10)
+ name = "West Resize Cursor";
+ else if (type == 11)
+ name = "East Resize Cursor";
+ else if (type == 12)
+ name = "Hand Cursor";
+ else if (type == 13)
+ name = "Move Cursor";
+
+ // FIXME: lookup?
}
/** This constructor is used internally only.
Index: java/awt/List.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/List.java,v
retrieving revision 1.27
diff -u -r1.27 List.java
--- java/awt/List.java 26 Jun 2006 18:47:17 -0000 1.27
+++ java/awt/List.java 7 Jul 2006 20:18:40 -0000
@@ -66,6 +66,11 @@
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_list_number;
+
// Serialization constant
private static final long serialVersionUID = -3304312411574666869L;
@@ -1266,4 +1271,19 @@
accessibleContext = new AccessibleAWTList();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>List</code>.
+ *
+ * @return A unique name for this <code>List</code>.
+ */
+ String generateName()
+ {
+ return "list" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_list_number++;
+ }
} // class List
Index: java/awt/Menu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Menu.java,v
retrieving revision 1.23
diff -u -r1.23 Menu.java
--- java/awt/Menu.java 20 Feb 2006 09:15:02 -0000 1.23
+++ java/awt/Menu.java 7 Jul 2006 20:18:40 -0000
@@ -58,6 +58,11 @@
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_menu_number;
+
// Serialization Constant
private static final long serialVersionUID = -8809584163345499784L;
@@ -485,5 +490,20 @@
accessibleContext = new AccessibleAWTMenu();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>Menu</code>.
+ *
+ * @return A unique name for this <code>Menu</code>.
+ */
+ String generateName()
+ {
+ return "menu" + getUniqueLong();
+ }
+ private static synchronized long getUniqueLong()
+ {
+ return next_menu_number++;
+ }
+
} // class Menu
Index: java/awt/MenuBar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/MenuBar.java,v
retrieving revision 1.22
diff -u -r1.22 MenuBar.java
--- java/awt/MenuBar.java 20 Feb 2006 09:15:02 -0000 1.22
+++ java/awt/MenuBar.java 7 Jul 2006 20:18:40 -0000
@@ -60,10 +60,15 @@
implements MenuContainer, Serializable, Accessible
{
-//Serialization Constant
+ // Serialization Constant
private static final long serialVersionUID = -4930327919388951260L;
/**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menubar_number;
+
+ /**
* @serial The menu used for providing help information
*/
private Menu helpMenu;
@@ -331,6 +336,21 @@
accessibleContext = new AccessibleAWTMenuBar();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>MenuBar</code>.
+ *
+ * @return A unique name for this <code>MenuBar</code>.
+ */
+ String generateName()
+ {
+ return "menubar" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_menubar_number++;
+ }
/**
* This class provides accessibility support for AWT menu bars.
Index: java/awt/MenuComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/MenuComponent.java,v
retrieving revision 1.26
diff -u -r1.26 MenuComponent.java
--- java/awt/MenuComponent.java 14 Feb 2006 16:26:19 -0000 1.26
+++ java/awt/MenuComponent.java 7 Jul 2006 20:18:41 -0000
@@ -200,8 +200,22 @@
*/
public String getName()
{
+ if (name == null && ! nameExplicitlySet)
+ name = generateName();
return name;
}
+
+ /**
+ * Subclasses should override this to return unique component names like
+ * "menuitem0".
+ *
+ * @return the generated name for this menu component
+ */
+ String generateName()
+ {
+ // MenuComponent is abstract.
+ return null;
+ }
/**
* Sets the name of this component to the specified name.
Index: java/awt/MenuItem.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/MenuItem.java,v
retrieving revision 1.27
diff -u -r1.27 MenuItem.java
--- java/awt/MenuItem.java 16 Mar 2006 00:50:23 -0000 1.27
+++ java/awt/MenuItem.java 7 Jul 2006 20:18:41 -0000
@@ -63,9 +63,15 @@
/*
* Static Variables
*/
+
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menuitem_number;
-// Serialization Constant
-private static final long serialVersionUID = -21757335363267194L;
+ // Serialization Constant
+ private static final long serialVersionUID = - 21757335363267194L;
/*************************************************************************/
@@ -599,4 +605,19 @@
return accessibleContext;
}
+/**
+ * Generate a unique name for this <code>MenuItem</code>.
+ *
+ * @return A unique name for this <code>MenuItem</code>.
+ */
+String generateName()
+{
+ return "menuitem" + getUniqueLong();
+}
+
+private static synchronized long getUniqueLong()
+{
+ return next_menuitem_number++;
+}
+
} // class MenuItem
Index: java/awt/PopupMenu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/PopupMenu.java,v
retrieving revision 1.17
diff -u -r1.17 PopupMenu.java
--- java/awt/PopupMenu.java 20 Sep 2005 01:05:28 -0000 1.17
+++ java/awt/PopupMenu.java 7 Jul 2006 20:18:41 -0000
@@ -55,8 +55,13 @@
* Static Variables
*/
-// Serialization Constant
-private static final long serialVersionUID = -4620452533522760060L;
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_popup_number;
+
+ // Serialization Constant
+ private static final long serialVersionUID = - 4620452533522760060L;
/*************************************************************************/
@@ -166,6 +171,21 @@
accessibleContext = new AccessibleAWTPopupMenu();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>PopupMenu</code>.
+ *
+ * @return A unique name for this <code>PopupMenu</code>.
+ */
+ String generateName()
+ {
+ return "popup" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_popup_number++;
+ }
} // class PopupMenu
Index: java/awt/ScrollPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/ScrollPane.java,v
retrieving revision 1.26
diff -u -r1.26 ScrollPane.java
--- java/awt/ScrollPane.java 10 Nov 2005 17:42:01 -0000 1.26
+++ java/awt/ScrollPane.java 7 Jul 2006 20:18:41 -0000
@@ -76,6 +76,11 @@
*/
public static final int SCROLLBARS_NEVER = 2;
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_scrollpane_number;
+
// Serialization constant
private static final long serialVersionUID = 7956609840827222915L;
@@ -613,5 +618,21 @@
accessibleContext = new AccessibleAWTScrollPane();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>ScrollPane</code>.
+ *
+ * @return A unique name for this <code>ScrollPane</code>.
+ */
+ String generateName()
+ {
+ return "scrollpane" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_scrollpane_number++;
+ }
+
} // class ScrollPane
Index: java/awt/TextField.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/TextField.java,v
retrieving revision 1.19
diff -u -r1.19 TextField.java
--- java/awt/TextField.java 30 Jun 2006 09:32:21 -0000 1.19
+++ java/awt/TextField.java 7 Jul 2006 20:18:42 -0000
@@ -54,7 +54,13 @@
*/
public class TextField extends TextComponent
{
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_textfield_number;
+
private static final long serialVersionUID = -2966288784432217853L;
@@ -434,6 +440,21 @@
{
return (ActionListener[]) getListeners (ActionListener.class);
}
+
+ /**
+ * Generate a unique name for this <code>TextField</code>.
+ *
+ * @return A unique name for this <code>TextField</code>.
+ */
+ String generateName()
+ {
+ return "textfield" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_textfield_number++;
+ }
protected class AccessibleAWTTextField extends AccessibleAWTTextComponent
{