[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: graydon's swing and awt fixes

Kaffe CVS cvs-commits at kaffe.org
Fri Nov 12 18:22:09 PST 2004


PatchSet 5451 
Date: 2004/11/13 02:17:41
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: graydon's swing and awt fixes

2004-11-13  Dalibor Topic  <robilad at kaffe.org>

        * libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
        libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java,
        libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java,
        libraries/javalib/java/awt/print/PrinterJob.java,
        libraries/javalib/javax/swing/JComponent.java,
        libraries/javalib/javax/swing/JDesktopPane.java,
        libraries/javalib/javax/swing/JMenuItem.java,
        libraries/javalib/javax/swing/JTable.java,
        libraries/javalib/javax/swing/JTree.java,
        libraries/javalib/javax/swing/JViewport.java,
        libraries/javalib/javax/swing/RepaintManager.java,
        libraries/javalib/javax/swing/ScrollPaneLayout.java,
        libraries/javalib/javax/swing/ToolTipManager.java,
        libraries/javalib/javax/swing/TransferHandler.java,
        libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java,
        libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java,
        libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java,
        libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java,
        libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java,
        libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java,
        libraries/javalib/javax/swing/text/SimpleAttributeSet.java,
        libraries/javalib/javax/swing/tree/DefaultTreeCellRenderer.java,
        libraries/javalib/javax/swing/tree/DefaultTreeModel.java:
        Resynced with GNU Classpath.

        2004-11-11  Graydon Hoare  <graydon at redhat.com>

        * gnu/java/awt/peer/gtk/GdkGraphics2D.java
        (GdkGraphics2D): Set clip after transform.
        (drawImage): Protect against null image.
        * gnu/java/awt/peer/gtk/GtkFramePeer.java
        (setIconImage): Protect against non-GtkImage args.
        * gnu/java/awt/peer/gtk/GtkToolkit.java
        (checkImage): Protect against non-GtkImage args.
        * java/awt/print/PrinterJob.java:
        (print): Add variant taking PrintRequestAttributeSet.
        (printDialog): Likewise.
        * javax/swing/JComponent.java:
        (transferHandler): New field.
        (getComponentGraphics): Build new Graphics for each sub-paint.
        (getTransferHandler): New method.
        (setTransferHandler): New method.
        * javax/swing/JDesktopPane.java
        (setDragMode): Force LIVE_DRAG_MODE.
        * javax/swing/JMenuItem.java
        (menuSelectionChanged): Protect against null parent.
        * javax/swing/JTable.java (setDefaultRenderer): New method.
        * javax/swing/JTree.java: Get basic ctors and UI working.
        * javax/swing/JViewport.java (JViewport): Set scroll mode.
        * javax/swing/RepaintManager.java
        (addDirtyRegion): Skip empty regions.
        * javax/swing/ScrollPaneLayout.java (minimumLayoutSize): Do not
        bound scrollpane minimum by central view minimum.
        * javax/swing/ToolTipManager.java
        (showTip): Guard against null component.
        * javax/swing/TransferHandler.java: Stub out.
        * javax/swing/plaf/basic/BasicLookAndFeel.java:
        Add entry for TextPaneUI, change Tree icons to pngs.
        * javax/swing/plaf/basic/BasicMenuItemUI.java:
        (installDefaults): Set text position and alignment.

Members: 
	ChangeLog:1.2997->1.2998 
	libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.6->1.7 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.4->1.5 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java:1.5->1.6 
	libraries/javalib/java/awt/print/PrinterJob.java:1.3->1.4 
	libraries/javalib/javax/swing/JComponent.java:1.7->1.8 
	libraries/javalib/javax/swing/JDesktopPane.java:1.5->1.6 
	libraries/javalib/javax/swing/JMenuItem.java:1.5->1.6 
	libraries/javalib/javax/swing/JTable.java:1.7->1.8 
	libraries/javalib/javax/swing/JTree.java:1.5->1.6 
	libraries/javalib/javax/swing/JViewport.java:1.5->1.6 
	libraries/javalib/javax/swing/RepaintManager.java:1.5->1.6 
	libraries/javalib/javax/swing/ScrollPaneLayout.java:1.5->1.6 
	libraries/javalib/javax/swing/ToolTipManager.java:1.5->1.6 
	libraries/javalib/javax/swing/TransferHandler.java:1.1->1.2 
	libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.6->1.7 
	libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java:1.4->1.5 
	libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java:1.3->1.4 
	libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.6->1.7 
	libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java:1.2->1.3 
	libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java:1.3->1.4 
	libraries/javalib/javax/swing/text/SimpleAttributeSet.java:1.3->1.4 
	libraries/javalib/javax/swing/tree/DefaultTreeCellRenderer.java:1.2->1.3 
	libraries/javalib/javax/swing/tree/DefaultTreeModel.java:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2997 kaffe/ChangeLog:1.2998
--- kaffe/ChangeLog:1.2997	Sat Nov 13 00:56:23 2004
+++ kaffe/ChangeLog	Sat Nov 13 02:17:41 2004
@@ -1,3 +1,84 @@
+2004-11-13  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+	libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java,
+	libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java,
+	libraries/javalib/java/awt/print/PrinterJob.java,
+	libraries/javalib/javax/swing/JComponent.java,
+	libraries/javalib/javax/swing/JDesktopPane.java,
+	libraries/javalib/javax/swing/JMenuItem.java,
+	libraries/javalib/javax/swing/JTable.java,
+	libraries/javalib/javax/swing/JTree.java,
+	libraries/javalib/javax/swing/JViewport.java,
+	libraries/javalib/javax/swing/RepaintManager.java,
+	libraries/javalib/javax/swing/ScrollPaneLayout.java,
+	libraries/javalib/javax/swing/ToolTipManager.java,
+	libraries/javalib/javax/swing/TransferHandler.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java,
+	libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java,
+	libraries/javalib/javax/swing/text/SimpleAttributeSet.java,
+	libraries/javalib/javax/swing/tree/DefaultTreeCellRenderer.java,
+	libraries/javalib/javax/swing/tree/DefaultTreeModel.java:
+	Resynced with GNU Classpath.
+
+	2004-11-11  Graydon Hoare  <graydon at redhat.com>
+
+        * gnu/java/awt/peer/gtk/GdkGraphics2D.java
+        (GdkGraphics2D): Set clip after transform.
+        (drawImage): Protect against null image.
+        * gnu/java/awt/peer/gtk/GtkFramePeer.java
+        (setIconImage): Protect against non-GtkImage args.
+        * gnu/java/awt/peer/gtk/GtkToolkit.java
+        (checkImage): Protect against non-GtkImage args.
+        * java/awt/print/PrinterJob.java:
+        (print): Add variant taking PrintRequestAttributeSet.
+        (printDialog): Likewise.
+        * javax/swing/JComponent.java:
+        (transferHandler): New field.
+        (getComponentGraphics): Build new Graphics for each sub-paint.
+        (getTransferHandler): New method.
+        (setTransferHandler): New method.
+        * javax/swing/JDesktopPane.java
+        (setDragMode): Force LIVE_DRAG_MODE.
+        * javax/swing/JMenuItem.java
+        (menuSelectionChanged): Protect against null parent.
+        * javax/swing/JTable.java (setDefaultRenderer): New method.
+        * javax/swing/JTree.java: Get basic ctors and UI working.
+        * javax/swing/JViewport.java (JViewport): Set scroll mode.
+        * javax/swing/RepaintManager.java
+        (addDirtyRegion): Skip empty regions.
+        * javax/swing/ScrollPaneLayout.java (minimumLayoutSize): Do not
+        bound scrollpane minimum by central view minimum.
+        * javax/swing/ToolTipManager.java
+        (showTip): Guard against null component.
+        * javax/swing/TransferHandler.java: Stub out.
+        * javax/swing/plaf/basic/BasicLookAndFeel.java:
+        Add entry for TextPaneUI, change Tree icons to pngs.
+        * javax/swing/plaf/basic/BasicMenuItemUI.java:
+        (installDefaults): Set text position and alignment.
+        (paintMenuItem): Layout icon with normal compound function.
+        * javax/swing/plaf/basic/BasicTableHeaderUI.java:
+        (getMaximumSize): Delete.
+        (getMinimumSize): Delete.
+        (getPreferredSize): Use column model's total width.
+        * javax/swing/plaf/basic/BasicTextPaneUI.java: New file.
+        * javax/swing/plaf/basic/BasicTextUI.java
+        (modelChanged): Make resilient against nulls.
+        * javax/swing/plaf/basic/BasicTreeUI.java:
+        Add some simplistic config / painting functions.
+        * javax/swing/plaf/basic/BasicViewportUI.java
+        (paintSimple): Add new non-backingstore paint mode.
+        (paintBackingStore): Split out backing store code.
+        (paint): Switch on painting mode.
+        * javax/swing/text/SimpleAttributeSet.java
+        (SimpleAttributeSet): Resist nulls.
+        * javax/swing/tree/DefaultTreeCellRenderer.java: Implement.
+        * javax/swing/tree/DefaultTreeModel.java: Partially implement.
+
 2004-11-12  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/java/util/jar/JarFile.java:
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.6 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.7
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.6	Thu Oct 28 22:34:22 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java	Sat Nov 13 02:17:43 2004
@@ -187,8 +187,8 @@
     setBackground (bg);
     setPaint (paint);
     setStroke (stroke);
-    setClip (clip);
     setTransform (transform);
+    setClip (clip);
     stateStack = new Stack();
   }
 
@@ -502,6 +502,10 @@
                                   Color bgcolor,			    
                                   ImageObserver obs)
   {
+
+    if (img == null)
+      return false;
+
     if (img instanceof GtkOffScreenImage &&
         img.getGraphics () instanceof GdkGraphics2D &&            
         (xform == null 
@@ -1286,6 +1290,9 @@
                             Color bgcolor, ImageObserver observer)
   {
   
+    if (img == null)
+      return false;
+
     Image subImage;	
     
     int sourceWidth = sx2 - sx1;
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.4 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.5
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.4	Mon Sep 27 17:41:04 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java	Sat Nov 13 02:17:44 2004
@@ -170,7 +170,7 @@
   native void nativeSetIconImageFromData (int[] pixels, int width, int height);
   public void setIconImage (Image image) 
   {
-      if (image != null)
+      if (image != null && image instanceof GtkImage)
         {
           GtkImage img = (GtkImage) image;
           // FIXME: Image should be loaded, but if not, do image loading here.
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java:1.5 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java:1.6
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java:1.5	Sat Oct  9 22:18:50 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkToolkit.java	Sat Nov 13 02:17:44 2004
@@ -122,7 +122,14 @@
   public int checkImage (Image image, int width, int height, 
 			 ImageObserver observer) 
   {
-    int status = ((GtkImage) image).checkImage ();
+    int status = ImageObserver.ALLBITS 
+      | ImageObserver.WIDTH 
+      | ImageObserver.HEIGHT;
+
+    if (image instanceof GtkImage)
+      {        
+        status = ((GtkImage) image).checkImage ();
+      }
 
     if (observer != null)
       observer.imageUpdate (image, status,
Index: kaffe/libraries/javalib/java/awt/print/PrinterJob.java
diff -u kaffe/libraries/javalib/java/awt/print/PrinterJob.java:1.3 kaffe/libraries/javalib/java/awt/print/PrinterJob.java:1.4
--- kaffe/libraries/javalib/java/awt/print/PrinterJob.java:1.3	Sun Aug 10 18:47:51 2003
+++ kaffe/libraries/javalib/java/awt/print/PrinterJob.java	Sat Nov 13 02:17:44 2004
@@ -37,6 +37,7 @@
 
 
 package java.awt.print;
+import javax.print.attribute.PrintRequestAttributeSet;
 
 /**
   * This class controls printing.
@@ -194,6 +195,8 @@
   * Prints the pages.
   */
 public abstract void print () throws PrinterException;
+public abstract void print (PrintRequestAttributeSet attributes) throws PrinterException;
+
 
 /**
   * Displays a dialog box to the user which allows the print job
@@ -204,6 +207,9 @@
   */
 public abstract boolean
 printDialog();
+
+public abstract boolean 
+printDialog(PrintRequestAttributeSet attributes);
 
 /*************************************************************************/
 
Index: kaffe/libraries/javalib/javax/swing/JComponent.java
diff -u kaffe/libraries/javalib/javax/swing/JComponent.java:1.7 kaffe/libraries/javalib/javax/swing/JComponent.java:1.8
--- kaffe/libraries/javalib/javax/swing/JComponent.java:1.7	Mon Oct 25 19:12:11 2004
+++ kaffe/libraries/javalib/javax/swing/JComponent.java	Sat Nov 13 02:17:44 2004
@@ -325,6 +325,8 @@
   private ActionMap actionMap;
   private InputVerifier inputVerifier;
 
+  private TransferHandler transferHandler;
+
   /** 
    * A lock held during recursive painting; this is used to serialize
    * access to the double buffer, and also to select the "top level" 
@@ -862,9 +864,10 @@
    */
   protected Graphics getComponentGraphics(Graphics g)
   {    
-    g.setFont(this.getFont());
-    g.setColor(this.getForeground());
-    return g;
+    Graphics g2 = g.create();
+    g2.setFont(this.getFont());
+    g2.setColor(this.getForeground());
+    return g2;
   }
 
 
@@ -2066,6 +2069,32 @@
   public void setRequestFocusEnabled(boolean e)
   {
     requestFocusEnabled = e;
+  }
+
+  /**
+   * Get the value of the {@link #transferHandler} property.
+   *
+   * @return The current value of the property
+   *
+   * @see ComponentUI#setTransferHandler
+   */
+
+  public TransferHandler getTransferHandler()
+  {
+    return transferHandler;
+  }
+
+  /**
+   * Set the value of the {@link #transferHandler} property.
+   *
+   * @param newHandler The new value of the property
+   *
+   * @see ComponentUI#getTransferHandler
+   */
+
+  void setTransferHandler (TransferHandler newHandler)
+  {
+    transferHandler = newHandler;
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/JDesktopPane.java
diff -u kaffe/libraries/javalib/javax/swing/JDesktopPane.java:1.5 kaffe/libraries/javalib/javax/swing/JDesktopPane.java:1.6
--- kaffe/libraries/javalib/javax/swing/JDesktopPane.java:1.5	Sun Oct 24 13:08:51 2004
+++ kaffe/libraries/javalib/javax/swing/JDesktopPane.java	Sat Nov 13 02:17:44 2004
@@ -154,7 +154,10 @@
 
     // FIXME: Unsupported mode.
     if (mode == OUTLINE_DRAG_MODE)
-      throw new IllegalArgumentException("Outline drag modes are unsupported.");
+      {
+        // throw new IllegalArgumentException("Outline drag modes are unsupported.");
+        mode = LIVE_DRAG_MODE;
+      }
 
     dragMode = mode;
   }
Index: kaffe/libraries/javalib/javax/swing/JMenuItem.java
diff -u kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.5 kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.6
--- kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.5	Sun Oct 24 13:39:11 2004
+++ kaffe/libraries/javalib/javax/swing/JMenuItem.java	Sat Nov 13 02:17:44 2004
@@ -529,19 +529,20 @@
    */
   public void menuSelectionChanged(boolean changed)
   {
+    Component parent = this.getParent();
     if (changed)
       {
 	model.setArmed(true);
 
-	if (this.getParent() instanceof JPopupMenu)
-	  ((JPopupMenu) this.getParent()).setSelected(this);
+	if (parent != null && parent instanceof JPopupMenu)
+	  ((JPopupMenu) parent).setSelected(this);
       }
     else
       {
 	model.setArmed(false);
 
-	if (this.getParent() instanceof JPopupMenu)
-	  ((JPopupMenu) this.getParent()).getSelectionModel().clearSelection();
+	if (parent != null && parent instanceof JPopupMenu)
+	  ((JPopupMenu) parent).getSelectionModel().clearSelection();
       }
   }
 
Index: kaffe/libraries/javalib/javax/swing/JTable.java
diff -u kaffe/libraries/javalib/javax/swing/JTable.java:1.7 kaffe/libraries/javalib/javax/swing/JTable.java:1.8
--- kaffe/libraries/javalib/javax/swing/JTable.java:1.7	Sun Oct 24 13:39:12 2004
+++ kaffe/libraries/javalib/javax/swing/JTable.java	Sat Nov 13 02:17:44 2004
@@ -675,6 +675,11 @@
     return renderer;
   }
 
+  public void setDefaultRenderer(Class columnClass, TableCellRenderer rend)
+  {
+    defaultRenderersByColumnClass.put(columnClass, rend);
+  }
+
   public TableCellRenderer getDefaultRenderer(Class columnClass)
   {
     if (defaultRenderersByColumnClass.containsKey(columnClass))
Index: kaffe/libraries/javalib/javax/swing/JTree.java
diff -u kaffe/libraries/javalib/javax/swing/JTree.java:1.5 kaffe/libraries/javalib/javax/swing/JTree.java:1.6
--- kaffe/libraries/javalib/javax/swing/JTree.java:1.5	Sun Oct 24 13:39:12 2004
+++ kaffe/libraries/javalib/javax/swing/JTree.java	Sat Nov 13 02:17:44 2004
@@ -40,7 +40,9 @@
 
 import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.Vector;
 
 import javax.accessibility.Accessible;
@@ -52,6 +54,9 @@
 import javax.swing.event.TreeWillExpandListener;
 import javax.swing.plaf.TreeUI;
 import javax.swing.tree.ExpandVetoException;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeCellEditor;
 import javax.swing.tree.TreeCellRenderer;
 import javax.swing.tree.TreeModel;
@@ -59,6 +64,7 @@
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreeSelectionModel;
 
+
 public class JTree extends JComponent
   implements Scrollable, Accessible
 {
@@ -100,7 +106,7 @@
    */
   public JTree()
   {
-    treeModel = createTreeModel(null);
+    this(createTreeModel(null));
   }
 
   /**
@@ -110,7 +116,7 @@
    */
   public JTree(Hashtable value)
   {
-    treeModel = createTreeModel(value);
+    this(createTreeModel(value));
   }
 
   /**
@@ -120,7 +126,7 @@
    */
   public JTree(Object[] value)
   {
-    treeModel = createTreeModel(value);
+    this(createTreeModel(value));
   }
 
   /**
@@ -131,6 +137,8 @@
   public JTree(TreeModel model)
   {
     treeModel = model;
+    setCellRenderer(new DefaultTreeCellRenderer());
+    updateUI();
   }
 
   /**
@@ -152,6 +160,7 @@
    */
   public JTree(TreeNode root, boolean asksAllowChildren)
   {
+    this(new DefaultTreeModel(root, asksAllowChildren));
   }
 
   /**
@@ -161,7 +170,81 @@
    */
   public JTree(Vector value)
   {
-    treeModel = createTreeModel(value);
+    this(createTreeModel(value));
+  }
+
+  public static class DynamicUtilTreeNode 
+    extends DefaultMutableTreeNode
+  {
+    protected Object childValue;
+    protected boolean loadedChildren;
+    public DynamicUtilTreeNode(Object value,
+                               Object children) 
+    {
+      super(value);
+      childValue = children;
+      loadedChildren = false;
+    }
+
+    public int getChildCount()
+    {
+      loadChildren();
+      return super.getChildCount();
+    }
+
+    protected void loadChildren()
+    {
+      if (!loadedChildren)
+        {
+          createChildren(this, childValue);
+          loadedChildren = true;
+        }
+    }
+    
+    public Enumeration children()
+    {
+      loadChildren();
+      return super.children();
+    }
+
+    public boolean isLeaf() 
+    {
+      return (childValue == null || 
+              !(childValue instanceof Hashtable
+               || childValue instanceof Vector
+               || childValue.getClass().isArray()));
+    }
+
+    public static void createChildren(DefaultMutableTreeNode parent,
+                                      Object children)
+    {
+      if (children instanceof Hashtable)
+        {
+          Hashtable tab = (Hashtable) children;
+          Enumeration e = tab.keys();
+          while (e.hasMoreElements()) 
+            {
+              Object key = e.nextElement();
+              Object val = tab.get(key);
+              parent.add(new DynamicUtilTreeNode(key, val));
+            }
+        }
+      else if (children instanceof Vector)
+        {
+          Iterator i = ((Vector)children).iterator();
+          while (i.hasNext())
+            {
+              Object n = i.next();
+              parent.add(new DynamicUtilTreeNode(n,n));
+            }
+        }
+      else if (children.getClass().isArray())
+        {
+          Object[] arr = (Object[]) children;
+          for (int i = 0; i < arr.length; ++i)
+            parent.add(new DynamicUtilTreeNode(arr[i], arr[i]));
+      }
+    }
   }
 
   /**
@@ -171,8 +254,7 @@
    */
   protected static TreeModel createTreeModel(Object value)
   {
-    // FIXME: Implement this.
-    return null;
+    return new DefaultTreeModel(new DynamicUtilTreeNode(value, value));
   }
 
   /**
@@ -201,6 +283,8 @@
   public void updateUI()
   {
     setUI((TreeUI) UIManager.getUI(this));
+    revalidate();
+    repaint();
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/JViewport.java
diff -u kaffe/libraries/javalib/javax/swing/JViewport.java:1.5 kaffe/libraries/javalib/javax/swing/JViewport.java:1.6
--- kaffe/libraries/javalib/javax/swing/JViewport.java:1.5	Sun Oct 24 10:44:37 2004
+++ kaffe/libraries/javalib/javax/swing/JViewport.java	Sat Nov 13 02:17:45 2004
@@ -127,6 +127,7 @@
   public JViewport()
   {
     setOpaque(true);
+    setScrollMode(BLIT_SCROLL_MODE);
     updateUI();
   }
 
Index: kaffe/libraries/javalib/javax/swing/RepaintManager.java
diff -u kaffe/libraries/javalib/javax/swing/RepaintManager.java:1.5 kaffe/libraries/javalib/javax/swing/RepaintManager.java:1.6
--- kaffe/libraries/javalib/javax/swing/RepaintManager.java:1.5	Sun Oct 24 13:39:14 2004
+++ kaffe/libraries/javalib/javax/swing/RepaintManager.java	Sat Nov 13 02:17:45 2004
@@ -309,6 +309,9 @@
   public synchronized void addDirtyRegion(JComponent component, int x, int y,
                                           int w, int h)
   {
+    if (w == 0 || h == 0)
+      return;
+
     Rectangle r = new Rectangle(x, y, w, h);
     if (dirtyComponents.containsKey(component))
       r = r.union((Rectangle)dirtyComponents.get(component));
Index: kaffe/libraries/javalib/javax/swing/ScrollPaneLayout.java
diff -u kaffe/libraries/javalib/javax/swing/ScrollPaneLayout.java:1.5 kaffe/libraries/javalib/javax/swing/ScrollPaneLayout.java:1.6
--- kaffe/libraries/javalib/javax/swing/ScrollPaneLayout.java:1.5	Sun Oct 24 13:39:15 2004
+++ kaffe/libraries/javalib/javax/swing/ScrollPaneLayout.java	Sat Nov 13 02:17:45 2004
@@ -321,7 +321,6 @@
               insetsSize.setSize(insets.left + insets.right,
                                  insets.top + insets.bottom);
 
-            maybeSetMinimumSize(viewport, viewportSize);
             maybeSetMinimumSize(colHead, columnHeaderSize);
             maybeSetMinimumSize(rowHead, rowHeaderSize);
             
Index: kaffe/libraries/javalib/javax/swing/ToolTipManager.java
diff -u kaffe/libraries/javalib/javax/swing/ToolTipManager.java:1.5 kaffe/libraries/javalib/javax/swing/ToolTipManager.java:1.6
--- kaffe/libraries/javalib/javax/swing/ToolTipManager.java:1.5	Sun Oct 24 13:39:15 2004
+++ kaffe/libraries/javalib/javax/swing/ToolTipManager.java	Sat Nov 13 02:17:45 2004
@@ -464,7 +464,7 @@
    */
   private void showTip()
   {
-    if (! enabled)
+    if (! enabled || currentComponent == null)
       return;
 
     if (currentTip == null
Index: kaffe/libraries/javalib/javax/swing/TransferHandler.java
diff -u kaffe/libraries/javalib/javax/swing/TransferHandler.java:1.1 kaffe/libraries/javalib/javax/swing/TransferHandler.java:1.2
--- kaffe/libraries/javalib/javax/swing/TransferHandler.java:1.1	Sun Sep 12 15:11:07 2004
+++ kaffe/libraries/javalib/javax/swing/TransferHandler.java	Sat Nov 13 02:17:45 2004
@@ -38,6 +38,8 @@
 package javax.swing;
 
 import java.io.Serializable;
+import java.awt.event.InputEvent;
+import java.awt.datatransfer.*;
 
 public class TransferHandler implements Serializable
 {
@@ -48,8 +50,66 @@
   public static final int MOVE = 2;
   public static final int COPY_OR_MOVE = 3;
 
+  static Action getCopyAction ()
+  {
+    return null;
+  }
+
+  static Action getCutAction ()
+  {
+    return null;
+  }
+
+  static Action getPasteAction ()
+  {
+    return null;
+  }
+
+
   protected TransferHandler()
   {
     // Do nothing here.
   }
+
+  public TransferHandler(String property)
+  {
+  }
+
+  public boolean canImport (JComponent c, DataFlavor[] flavors)
+  {
+    return false;
+  }
+
+  public Transferable createTransferable(JComponent c) 
+  {
+    return null;
+  }
+
+  public void exportAsDrag (JComponent c, InputEvent e, int action) 
+  {    
+  }
+
+  protected void exportDone (JComponent c, Transferable data, int action) 
+  {
+  }
+
+  public void exportToClipboard(JComponent c, Clipboard clip, int action) 
+  {
+  } 
+
+  public int getSourceActions (JComponent c)
+  {
+    return 0;
+  }
+
+  public Icon getVisualRepresentation (Transferable t)
+  {
+    return null;
+  }
+
+  public boolean importData (JComponent c, Transferable t) 
+  {
+    return false;
+  }
+
 }
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.6 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.7
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.6	Sun Oct 24 13:39:19 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java	Sat Nov 13 02:17:45 2004
@@ -138,6 +138,7 @@
       "TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI",
       "TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI",
       "TableUI", "javax.swing.plaf.basic.BasicTableUI",
+      "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
       "TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI",
       "TextFieldUI", "javax.swing.plaf.basic.BasicTextFieldUI",
       "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
@@ -901,8 +902,8 @@
       }),
       "Tree.background", new ColorUIResource(Color.white),
       "Tree.changeSelectionWithFocus", Boolean.TRUE,
-      // XXX Don't use gif
-      "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.gif")),
+      "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
+      "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
       "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
       "Tree.editorBorder", new BorderUIResource.LineBorderUIResource(Color.lightGray),
       "Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
@@ -950,13 +951,12 @@
         "ctrl PAGE_DOWN", "scrollDownChangeLead"
       }),
       "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+      "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
       "Tree.foreground", new ColorUIResource(Color.black),
       "Tree.hash", new ColorUIResource(Color.gray),
-      // XXX Don't use gif
-      "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.gif")),
+      "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
       "Tree.leftChildIndent", new Integer(7),
-      // XXX Don't use gif
-      "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.gif")),
+      "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
       "Tree.rightChildIndent", new Integer(13),
       "Tree.rowHeight", new Integer(16),
       "Tree.scrollsOnExpand", Boolean.TRUE,
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java:1.4 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java:1.5
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java:1.4	Sun Oct 24 13:39:20 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicMenuItemUI.java	Sat Nov 13 02:17:45 2004
@@ -60,6 +60,7 @@
 import javax.swing.KeyStroke;
 import javax.swing.MenuElement;
 import javax.swing.MenuSelectionManager;
+import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 import javax.swing.UIDefaults;
 import javax.swing.UIManager;
@@ -392,6 +393,9 @@
     selectionBackground = defaults.getColor("MenuItem.selectionBackground");
     selectionForeground = defaults.getColor("MenuItem.selectionForeground");
     acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
+
+    menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
+    menuItem.setHorizontalAlignment(SwingConstants.LEADING);
   }
 
   /**
@@ -551,23 +555,14 @@
 	  }
       }
 
-    // paint icon
-    // FIXME: should paint different icon at different button state's.
-    // i.e disabled icon when button is disabled.. etc.
-    Icon i = m.getIcon();
-    if (i != null)
-      {
-	i.paintIcon(c, g, vr.x, vr.y);
-
-	// Adjust view rectangle, s.t text would be drawn after menu item's icon.
-	vr.x += i.getIconWidth() + defaultTextIconGap;
-      }
-
     // paint text and user menu icon if it exists	     
-    SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
+    Icon i = m.getIcon();
+    SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i,
                                        vertAlign, horAlign, vertTextPos,
                                        horTextPos, vr, ir, tr,
                                        defaultTextIconGap);
+    if (i != null)
+      i.paintIcon(c, g, ir.x, ir.y);
 
     paintText(g, m, tr, m.getText());
 
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java:1.3 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java:1.4
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java:1.3	Sun Oct 24 13:39:20 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTableHeaderUI.java	Sat Nov 13 02:17:46 2004
@@ -182,84 +182,6 @@
 
   }
 
-  public Dimension getMaximumSize(JComponent c)
-  {
-    TableColumnModel cmod = header.getColumnModel();
-    TableCellRenderer defaultRend = header.getDefaultRenderer();
-    int ncols = cmod.getColumnCount();    
-    int spacing = 0;
-    Dimension ret = getPreferredSize(c);
-    
-    if (header.getTable() != null 
-        && header.getTable().getInterCellSpacing() != null)
-      spacing = header.getTable().getInterCellSpacing().width;
-
-    ret.width = 0;
-    for (int i = 0; i < ncols; ++i)      
-      {
-        TableColumn col = cmod.getColumn(i);
-        TableCellRenderer rend = col.getHeaderRenderer();
-        if (rend == null)
-          rend = defaultRend;
-        Object val = col.getHeaderValue();
-        Component comp = rend.getTableCellRendererComponent(header.getTable(),
-                                                            val,
-                                                            false, // isSelected
-                                                            false, // isFocused
-                                                            -1, i);
-        comp.setFont(header.getFont());
-        comp.setBackground(header.getBackground());
-        comp.setForeground(header.getForeground());
-        if (comp instanceof JComponent)
-          ((JComponent)comp).setBorder(cellBorder);
-
-        Dimension d = comp.getMaximumSize();
-        ret.width += col.getMaxWidth();
-        ret.height = Math.max(ret.height, d.height);
-        ret.width += spacing;
-      }
-    return ret;
-  }
-
-  public Dimension getMinimumSize(JComponent c)
-  {
-    TableColumnModel cmod = header.getColumnModel();
-    TableCellRenderer defaultRend = header.getDefaultRenderer();
-    int ncols = cmod.getColumnCount();    
-    int spacing = 0;
-    Dimension ret = getPreferredSize(c);
-
-    if (header.getTable() != null 
-        && header.getTable().getInterCellSpacing() != null)
-      spacing = header.getTable().getInterCellSpacing().width;
-
-    ret.width = 0;
-    for (int i = 0; i < ncols; ++i)      
-      {
-        TableColumn col = cmod.getColumn(i);
-        TableCellRenderer rend = col.getHeaderRenderer();
-        if (rend == null)
-          rend = defaultRend;
-        Object val = col.getHeaderValue();
-        Component comp = rend.getTableCellRendererComponent(header.getTable(),
-                                                            val,
-                                                            false, // isSelected
-                                                            false, // isFocused
-                                                            -1, i);
-        comp.setFont(header.getFont());
-        comp.setBackground(header.getBackground());
-        comp.setForeground(header.getForeground());
-        if (comp instanceof JComponent)
-          ((JComponent)comp).setBorder(cellBorder);
-
-        Dimension d = comp.getMinimumSize();
-        ret.width += col.getMinWidth();
-        ret.width += spacing;
-        ret.height = Math.max(ret.height, d.height);
-      }
-    return ret;
-  }
-  
   public Dimension getPreferredSize(JComponent c)
   {
     TableColumnModel cmod = header.getColumnModel();
@@ -291,10 +213,10 @@
           ((JComponent)comp).setBorder(cellBorder);
 
         Dimension d = comp.getPreferredSize();
-        ret.width += d.width;
         ret.width += spacing;
         ret.height = Math.max(d.height, ret.height);        
       }
+    ret.width = cmod.getTotalColumnWidth();
     return ret;
   }
   
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.6 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.7
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.6	Sun Oct 24 13:39:20 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java	Sat Nov 13 02:17:46 2004
@@ -461,8 +461,17 @@
 
   protected void modelChanged()
   {
+    if (textComponent == null || rootView == null) 
+      return;
     ViewFactory factory = rootView.getViewFactory();
-    Element elem = textComponent.getDocument().getDefaultRootElement();
+    if (factory == null) 
+      return;
+    Document doc = textComponent.getDocument();
+    if (doc == null)
+      return;
+    Element elem = doc.getDefaultRootElement();
+    if (elem == null)
+      return;
     setView(factory.create(elem));
   }
 }
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java:1.2 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java:1.3
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java:1.2	Sun Oct 24 13:39:20 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTreeUI.java	Sat Nov 13 02:17:46 2004
@@ -38,11 +38,21 @@
 
 package javax.swing.plaf.basic;
 
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.Rectangle;
 
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
 import javax.swing.JTree;
 import javax.swing.plaf.TreeUI;
+import javax.swing.tree.DefaultTreeCellRenderer;
 import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeModel;
 
 /**
  * A delegate providing the user interface for <code>JTree</code>
@@ -57,6 +67,7 @@
 public class BasicTreeUI
   extends TreeUI
 {
+
   /**
    * Determines the geometric extent of the label that is
    * drawn for a path.
@@ -191,7 +202,6 @@
     return true;  // FIXME: not implemented
   }
 
-
   /**
    * Cancels editing a tree cell, discarding any entered value.
    * If no editing session is active, nothing happens. The cell
@@ -232,5 +242,158 @@
   public TreePath getEditingPath(JTree tree)
   {
     return null;  // FIXME: not implemented
+  }
+
+  public static ComponentUI createUI(JComponent c)
+  {
+    return new BasicTreeUI();
+  }
+
+  int rightChildIndent;
+  int leftChildIndent;
+  int rowHeight;
+  Color hashColor;
+
+  protected void installDefaults(JTree tree) 
+  {
+    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+    tree.setFont(defaults.getFont("Tree.font"));
+    tree.setForeground(defaults.getColor("Tree.foreground"));
+    tree.setBackground(defaults.getColor("Tree.background"));
+    tree.setOpaque(true);
+
+    hashColor = defaults.getColor("Tree.hash");
+    rightChildIndent = defaults.getInt("Tree.rightChildIndent");
+    leftChildIndent = defaults.getInt("Tree.leftChildIndent");
+    rowHeight = defaults.getInt("Tree.rowHeight");

*** Patch too long, truncated ***




More information about the kaffe mailing list