[cp-patches] FYI: Implemented LookAndFeel methods

2005-10-12 Thread Roman Kennke

I implemented 3 methods that were previously stubbed in
javax.swing.LookAndFeel.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/LookAndFeel.java
(installBorder): Implemented.
(installColors): Implemented.
(installColorsAndFont): Implemented.


/Roman


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: Implemented LookAndFeel methods

2005-10-12 Thread Roman Kennke
Here comes the actual patch.

Am 12.10.2005 schrieb Roman Kennke [EMAIL PROTECTED]:


I implemented 3 methods that were previously stubbed in
javax.swing.LookAndFeel.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/LookAndFeel.java
(installBorder): Implemented.
(installColors): Implemented.
(installColorsAndFont): Implemented.


/Roman


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/LookAndFeel.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/LookAndFeel.java,v
retrieving revision 1.11
diff -u -r1.11 LookAndFeel.java
--- javax/swing/LookAndFeel.java	13 Jul 2005 11:56:02 -	1.11
+++ javax/swing/LookAndFeel.java	12 Oct 2005 11:44:04 -
@@ -38,9 +38,13 @@
 
 package javax.swing;
 
+import java.awt.Color;
 import java.awt.Component;
+import java.awt.Font;
 import java.awt.Toolkit;
 
+import javax.swing.border.Border;
+import javax.swing.plaf.UIResource;
 import javax.swing.text.JTextComponent;
 
 public abstract class LookAndFeel
@@ -113,14 +117,27 @@
*/
   public static void installBorder(JComponent c, String defaultBorderName)
   {
+Border b = c.getBorder();
+if (b == null || b instanceof UIResource)
+  c.setBorder(UIManager.getBorder(defaultBorderName));
   }
 
   /**
* Convenience method for initializing a component's foreground and
* background color properties with values from the current defaults table.
*/
-  public static void installColors(JComponent c, String defaultBgName, String defaultFgName)
+  public static void installColors(JComponent c, String defaultBgName,
+   String defaultFgName)
   {
+// Install background.
+Color bg = c.getBackground();
+if (bg == null || bg instanceof UIResource)
+  c.setBackground(UIManager.getColor(defaultBgName));
+
+// Install foreground.
+Color fg = c.getForeground();
+if (fg == null || fg instanceof UIResource)
+  c.setForeground(UIManager.getColor(defaultFgName));
   }
 
   /**
@@ -128,10 +145,16 @@
* and font properties with values from the current defaults table. 
*/
   public static void installColorsAndFont(JComponent component,
-	  String defaultBgName,
-	  String defaultFgName,
-	  String defaultFontName)
-  {
+  String defaultBgName,
+  String defaultFgName,
+  String defaultFontName)
+  {
+// Install colors.
+installColors(component, defaultBgName, defaultFgName);
+// Install font.
+Font f = component.getFont();
+if (f == null || f instanceof UIResource)
+  component.setFont(UIManager.getFont(defaultFontName));
   }
 
   /**
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Some JViewport fixes

2005-10-12 Thread Roman Kennke
I investigated the JViewport stuff a little more and fixed the following
issues, which should bring JViewport a little closer to the reference
impl's behaviour:

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JViewport.java
(ViewListener.componentResized): Only call revalidate instead of
going through weird reverting code.
(JViewport): First call updateUI, then set layout.
(setViewPosition): Don't do anything if there is no real
change.
(setView): Don't remove the old component. This is handled by
addImpl. Call revalidate().
* javax/swing/ViewportLayout.java
(layoutContainer): Preferably set view size to it's preferredSize
instead of its minimumSize.

/Roman
Index: javax/swing/JViewport.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JViewport.java,v
retrieving revision 1.28
diff -u -r1.28 JViewport.java
--- javax/swing/JViewport.java	22 Sep 2005 14:35:30 -	1.28
+++ javax/swing/JViewport.java	12 Oct 2005 12:30:59 -
@@ -130,12 +130,10 @@
 
   /**
* A [EMAIL PROTECTED] java.awt.event.ComponentListener} that listens for
-   * changes of the view's size. This class forbids changes of the view
-   * component's size that would exceed the viewport's size.
+   * changes of the view's size. This triggers a revalidate() call on the
+   * viewport.
*/
-  protected class ViewListener
-extends ComponentAdapter
-implements Serializable
+  protected class ViewListener extends ComponentAdapter implements Serializable
   {
 private static final long serialVersionUID = -2812489404285958070L;
 
@@ -148,37 +146,14 @@
 
 /**
  * Receives notification when a component (in this case: the view
- * component) changes it's size.
+ * component) changes it's size. This simply triggers a revalidate() on the
+ * viewport.
  *
  * @param ev the ComponentEvent describing the change
  */
 public void componentResized(ComponentEvent ev)
 {
-  // According to some tests that I did with Sun's implementation
-  // this class is supposed to make sure that the view component
-  // is not resized to a larger size than the viewport.
-  // This is not documented anywhere. What I did is: I subclassed JViewport
-  // and ViewListener and 'disabled' the componentResized method by
-  // overriding it and not calling super.componentResized().
-  // When this method is disabled I can set the size on the view component
-  // normally, when it is enabled, it gets immediatly resized back,
-  // after a resize attempt that would exceed the Viewport's size.
-  Component comp = ev.getComponent();
-  Dimension newSize = comp.getSize();
-  Dimension viewportSize = getSize();
-  boolean revert = false;
-  if (newSize.width  viewportSize.width)
-{
-  newSize.width = viewportSize.width;
-  revert = true;
-}
-  if (newSize.height  viewportSize.height)
-{
-  newSize.height = viewportSize.height;
-  revert = true;
-}
-  if (revert == true)
-comp.setSize(newSize);
+  revalidate();
 }
   }
 
@@ -264,8 +239,8 @@
   {
 setOpaque(true);
 setScrollMode(BLIT_SCROLL_MODE);
-setLayout(createLayoutManager());
 updateUI();
+setLayout(createLayoutManager());
 lastPaintPosition = new Point();
 cachedBlitFrom = new Point();
 cachedBlitTo = new Point();
@@ -356,6 +331,8 @@
 
   public void setViewPosition(Point p)
   {
+if (getViewPosition().equals(p))
+  return;
 Component view = getView();
 if (view != null)
   {
@@ -418,7 +395,7 @@
   {
 if (viewListener != null)
   getView().removeComponentListener(viewListener);
-remove(0);
+//remove(0);
   }
 
 if (v != null)
@@ -429,6 +406,7 @@
 add(v);
 fireStateChanged();
   }
+revalidate();
   }
 
   public void revalidate()
Index: javax/swing/ViewportLayout.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/ViewportLayout.java,v
retrieving revision 1.15
diff -u -r1.15 ViewportLayout.java
--- javax/swing/ViewportLayout.java	13 Sep 2005 09:17:21 -	1.15
+++ javax/swing/ViewportLayout.java	12 Oct 2005 12:30:59 -
@@ -142,7 +142,7 @@
  portBounds.y + portBounds.height);
 
 // vertical implementation of the above rules
-if (portBounds.height = viewMinimum.height)
+if (portBounds.height = viewPref.height)
   {
 portBounds.y = 0;
 if ( !(view instanceof Scrollable) || ((Scrollable)view).getScrollableTracksViewportHeight())
@@ -150,14 +150,13 @@
   }
 else
   {
-viewPref.height = viewMinimum.height;
 int overextension = portLowerRight.y - viewPref.height;
 

[cp-patches] FYI: Some JComponent fixlets

2005-10-12 Thread Roman Kennke
Here come two fixlets for JComponent that I found while investigating the
revalidate stuff a little more:

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JComponent.java
(setFont): Only get active if the new font differs from the old
one.
Call revalidate when font changes.
(setUI): Call revalidate when UI changes.

/Roman
Index: javax/swing/JComponent.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.67
diff -u -r1.67 JComponent.java
--- javax/swing/JComponent.java	10 Oct 2005 12:22:37 -	1.67
+++ javax/swing/JComponent.java	12 Oct 2005 12:39:50 -
@@ -2200,7 +2200,14 @@
*/
   public void setFont(Font f)
   {
-super.setFont(f);
+if (f == null  getFont() == null)
+  return;
+
+if (f == null || !f.equals(getFont()))
+  {
+super.setFont(f);
+revalidate();
+  }
   }
 
   /**
@@ -2395,7 +2402,7 @@
   ui.installUI(this);
 
 firePropertyChange(UI, oldUI, newUI);
-
+revalidate();
   }
 
   /**
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Removed unneeded method in JComboBox

2005-10-12 Thread Roman Kennke
I removed a method in JComboBox that is unneeded and unspecified (and
deprecated).

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JComboBox.java
(isFocusTraversable): Removed unneeded and unspecified method.

/Roman
Index: javax/swing/JComboBox.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JComboBox.java,v
retrieving revision 1.20
diff -u -r1.20 JComboBox.java
--- javax/swing/JComboBox.java	27 Sep 2005 05:55:26 -	1.20
+++ javax/swing/JComboBox.java	12 Oct 2005 12:37:26 -
@@ -1029,19 +1029,6 @@
   }
 
   /**
-   * This method always returns false to indicate that JComboBox  itself is
-   * not focus traversable.
-   *
-   * @return false to indicate that JComboBox itself is not focus traversable.
-   *
-   * @deprecated
-   */
-  public boolean isFocusTraversable()
-  {
-return false;
-  }
-
-  /**
* setKeySelectionManager
*
* @param aManager
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: MetalIconFactory

2005-10-12 Thread David Gilbert
Some tests I am working on for the 
JFileChooser/BasicFileChooserUI/MetalFileChooserUI classes depend on some of the 
methods of MetalIconFactory returning the same icon reference each time they are 
called.  In many cases, Classpath is returning a new icon instance for each call.  I 
wrote Mauve tests for each method to confirm the correct behaviour, and updated 
MetalIconFactory with the patch below (committed).  I also fixed the getIconHeight() 
methods in FileIcon16 and FolderIcon16 which must add the value returned by 
getAdditionalHeight():


2005-10-12  David Gilbert  [EMAIL PROTECTED]

* javax/swing/plaf/metal/MetalIconFactory.java
(FileIcon16.getIconHeight): add result of getAdditionalHeight(),
(FolderIcon16.getIconHeight): add result of getAdditionalHeight(),
(checkBoxIcon): new private field,
(checkBoxMenuItemIcon): likewise,
(fileChooserDetailViewIcon): likewise,
(fileChooserHomeFolderIcon): likewise,
(fileChooserListViewIcon): likewise,
(fileChooserNewFolderIcon): likewise,
(fileChooserUpFolderIcon): likewise,
(radioButtonMenuItemIcon): likewise,
(internalFrameDefaultMenuIcon): likewise,
(treeComputerIcon): likewise,
(treeFloppyDriveIcon): likewise,
(treeHardDriveIcon): likewise,
(getCheckBoxIcon): return single instance,
(getCheckBoxMenuItemIcon): likewise,
(getFileChooserDetailViewIcon): likewise,
(getFileChooserHomeFolderIcon): likewise,
(getFileChooserListViewIcon): likewise,
(getFileChooserNewFolderIcon): likewise,
(getFileChooserUpFolderIcon): likewise,
(getRadioButtonMenuItemIcon): likewise,
(getInternalFrameDefaultMenuIcon): likewise,
(getTreeComputerIcon): likewise,
(getTreeFloppyDriveIcon): likewise,
(getTreeHardDriveIcon): likewise.

Regards,

Dave
Index: javax/swing/plaf/metal/MetalIconFactory.java
===
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalIconFactory.java,v
retrieving revision 1.16
diff -u -r1.16 MetalIconFactory.java
--- javax/swing/plaf/metal/MetalIconFactory.java28 Sep 2005 10:29:17 
-  1.16
+++ javax/swing/plaf/metal/MetalIconFactory.java12 Oct 2005 13:27:33 
-
@@ -531,13 +531,15 @@
 }
 
 /**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels.  The height returned is 
+ * code16/code plus the value returned by 
+ * [EMAIL PROTECTED] #getAdditionalHeight()}.
  * 
  * @return The height of the icon.
  */
 public int getIconHeight() 
 {
-  return 16;
+  return 16 + getAdditionalHeight();
 }
 
 /**
@@ -570,9 +572,11 @@
 }
 
 /**
- * Returns the additional height (???).
+ * Returns the additional height for the icon.  The 
+ * [EMAIL PROTECTED] #getIconHeight()} method adds this value to the icon 
height it
+ * returns.  Subclasses can override this method to adjust the icon height.
  * 
- * @return The additional height.
+ * @return The additional height (code0/code unless overridden).
  */
 public int getAdditionalHeight() 
 {
@@ -606,13 +610,15 @@
 }
 
 /**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels.  The height returned is 
+ * code16/code plus the value returned by 
+ * [EMAIL PROTECTED] #getAdditionalHeight()}.
  * 
  * @return The height of the icon.
  */
 public int getIconHeight() 
 {
-  return 16;
+  return 16 + getAdditionalHeight();
 }
 
 /**
@@ -643,9 +649,11 @@
 }
 
 /**
- * Returns the additional height (???).
+ * Returns the additional height for the icon.  The 
+ * [EMAIL PROTECTED] #getIconHeight()} method adds this value to the icon 
height it
+ * returns.  Subclasses can override this method to adjust the icon height.
  * 
- * @return The additional height.
+ * @return The additional height (code0/code unless overridden).
  */
 public int getAdditionalHeight() 
 {
@@ -1816,9 +1824,10 @@
 }
 
 /**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case code2/code
+ * pixels.
  * 
- * @return The additional height.
+ * @return code2/code.
  */
 public int getAdditionalHeight() 
 {
@@ -1849,9 +1858,10 @@
 }
 
 /**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case code4/code
+ * pixels.
  * 
- * @return The additional height.
+ * @return code4/code.
  */
 public int getAdditionalHeight() 
 {
@@ -2125,9 +2135,45 @@
 }
   }  
 
+  /** The icon returned by [EMAIL PROTECTED] #getCheckBoxIcon()}. */
+  private 

[cp-patches] FYI: Component fixlet

2005-10-12 Thread Roman Kennke
This fixes a small repaint problem in java.awt.Component. The rectangle
calculation in reshape() was wrong, it calculated rectangle relative to
the parent's parent, which should only be relative to the parent.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* java/awt/Component.java
(reshape): Fixed calculation of newBounds and oldBounds to create
rectangles relative to the parent, and not to the parent's
parent.
Solves a painting problem in an app here.


/Roman
Index: java/awt/Component.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.79
diff -u -r1.79 Component.java
--- java/awt/Component.java	4 Oct 2005 14:05:56 -	1.79
+++ java/awt/Component.java	12 Oct 2005 15:23:03 -
@@ -1402,17 +1402,14 @@
   peer.setBounds (x, y, width, height);
 
 // Erase old bounds and repaint new bounds for lightweights.
-if (isLightweight()  isShowing ())
+if (isLightweight()  isShowing())
   {
 if (parent != null)
   {
 Rectangle parentBounds = parent.getBounds();
-Rectangle oldBounds = new Rectangle(parent.getX() + oldx,
-parent.getY() + oldy,
-oldwidth, oldheight);
-Rectangle newBounds = new Rectangle(parent.getX() + x,
-parent.getY() + y,
-width, height);
+Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
+oldheight);
+Rectangle newBounds = new Rectangle(x, y, width, height);
 Rectangle destroyed = oldBounds.union(newBounds);
 if (!destroyed.isEmpty())
   parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: JViewport optimization

2005-10-12 Thread Roman Kennke
This optimizes JViewport. The backingstore drawing mechanism created
images far too often. Now it only creates a new image when the actual
size of the viewport changed.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JViewport.java
(sizeChanged): A new flag, indicating when the size of the
viewport has changed relative to the last painting operation.
(reshape): Set sizeChanged flag if size has changed.
(paintBackingStore): Only create new backingstore image when
the size has changed.


/Roman
Index: javax/swing/JViewport.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JViewport.java,v
retrieving revision 1.29
diff -u -r1.29 JViewport.java
--- javax/swing/JViewport.java	12 Oct 2005 12:31:34 -	1.29
+++ javax/swing/JViewport.java	12 Oct 2005 15:28:31 -
@@ -235,6 +235,13 @@
 
   boolean damaged = true;
 
+  /**
+   * A flag indicating if the size of the viewport has changed since the
+   * last repaint. This is used in double buffered painting to check if we
+   * need a new double buffer, or can reuse the old one.
+   */
+  boolean sizeChanged = true;
+
   public JViewport()
   {
 setOpaque(true);
@@ -418,15 +425,19 @@
 
   public void reshape(int x, int y, int w, int h)
   {
-damaged = true;
 boolean changed = 
   (x != getX()) 
   || (y != getY()) 
   || (w != getWidth())
   || (h != getHeight());
+if (w != getWidth() || h != getHeight())
+  sizeChanged = true;
 super.reshape(x, y, w, h);
 if (changed)
-  fireStateChanged();
+  {
+damaged = true;
+fireStateChanged();
+  }
   }
 
   public final Insets getInsets() 
@@ -750,7 +761,7 @@
 translated = true;
 view.paint(g);
   } 
-finally 
+finally
   {
 if (translated)
   g.translate (pos.x, pos.y);
@@ -771,9 +782,10 @@
   {
 // If we have no backing store image yet or the size of the component has
 // changed, we need to rebuild the backing store.
-if (backingStoreImage == null || damaged)
+if (backingStoreImage == null || sizeChanged)
   {
 backingStoreImage = createImage(getWidth(), getHeight());
+sizeChanged = false;
 Graphics g2 = backingStoreImage.getGraphics();
 paintSimple(g2);
 g2.dispose();
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] [PATCH] Fix PR classpath/24086, PR classpath/24091, PR classpath/24104 et al. ...

2005-10-12 Thread David Daney

Jeroen Frijters wrote:

David Daney wrote:


Jeroen Frijters wrote:


David Daney wrote:

LimitedLengthInputStream shouldn't have a finalize().


Let's consider the case where a client program did not read 
the entire body of the response:


As implemented in the patch, the finalize is indeed needed to 
clean up the mess and return the connection to the connection

pool.



I understand that was the motivation, but I just don't agree with it.
Even *if* you wanted to do this, you should use a PhantomReference to
keep track of the lifetime of the LimitedLengthInputStream instead of a
finalize method.



The LimitedLengthInputStream *is* the class that needs to do the 
cleanup.  Once a PhontomReference is enqueued the object is gone.  A 
finalizer is simple and gets the job done.


But this is all moot as I am going to kill it anyhow.

David Daney.


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] [PATCH] Fix PR classpath/24086, PR classpath/24091, PR classpath/24104 et al. ...

2005-10-12 Thread Tom Tromey
 Jeroen == Jeroen Frijters [EMAIL PROTECTED] writes:

 OK to commit?

Jeroen I vote yes.

Me too.  Please go ahead and check it in.
Thanks for doing this.

Tom


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: Fixed ScrollPaneLayout

2005-10-12 Thread Lillian Angel

 
 
 I don't know if this patch caused the problem, but something today has 
 made the Swing demo fail (on the List world tab):
 
 java.lang.NullPointerException
at javax.swing.ScrollPaneLayout.minimumLayoutSize 
 (ScrollPaneLayout.java:290)
at javax.swing.plaf.basic.BasicScrollPaneUI.getMinimumSize 
 (BasicScrollPaneUI.java:416)
at javax.swing.JComponent.getMinimumSize (JComponent.java:1053)
at 
 javax.swing.plaf.basic.BasicSplitPaneUI$BasicHorizontalLayoutManager.minimumSizeOfComponent
  
 (BasicSplitPaneUI.java:481)
at javax.swing.plaf.basic.BasicSplitPaneUI.getMinimumDividerLocation 
 (BasicSplitPaneUI.java:1362)
at javax.swing.plaf.basic.BasicSplitPaneUI.validLocation 
 (BasicSplitPaneUI.java:1570)
at javax.swing.plaf.basic.BasicSplitPaneUI.finishDraggingTo 
 (BasicSplitPaneUI.java:1537)
at javax.swing.plaf.basic.BasicSplitPaneDivider.finishDraggingTo 
 (BasicSplitPaneDivider.java:489)
at 
 javax.swing.plaf.basic.BasicSplitPaneDivider$DragController.completeDrag 
 (BasicSplitPaneDivider.java:719)
at 
 javax.swing.plaf.basic.BasicSplitPaneDivider$MouseHandler.mouseReleased 
 (BasicSplitPaneDivider.java:586)
at java.awt.Component.processMouseEvent (Component.java:3111)
at java.awt.Component.processEvent (Component.java:2972)
at java.awt.Container.processEvent (Container.java:905)
at java.awt.Component.dispatchEventImpl (Component.java:4840)
at java.awt.Container.dispatchEventImpl (Container.java:1644)
at java.awt.Component.dispatchEvent (Component.java:2339)
at java.awt.LightweightDispatcher.handleEvent (Container.java:2190)
at java.awt.Container.dispatchEventImpl (Container.java:1635)
at java.awt.Window.dispatchEventImpl (Window.java:623)
at java.awt.Component.dispatchEvent (Component.java:2339)
at java.awt.EventQueue.dispatchEvent (EventQueue.java:474)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:75)
 

Yes, I get this as well. It is because this patch. There is another
problem, when I fix the NPE, my program hangs or complains about Bad
Allocation when getMinimumSize is called. The exact error message is:
The error was 'BadAlloc (insufficient resources for operation)'. There
might be another loop somewhere.

Lillian





___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] RFA: Fix LineInputStream (PR classpath/24259)

2005-10-12 Thread Tom Tromey
 David == David Daney [EMAIL PROTECTED] writes:

David 2005-10-07  David Daney  [EMAIL PROTECTED]
David  PR classpath/24259
David  * gnu/java/net/LineInputStream.java: Import BufferedInputStream.
David  (Constructor): Don't do blockReads on BufferedInputStreams.
David  (readLine): Rename MIN_LENGTH to MAX_LENGTH.  Limit buffer size to
David  MAX_LENGTH.
David OK to commit?

I think so.  Please check it in.  Thanks.

Tom


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: AbstractDocument fixlet resolves PR24335

2005-10-12 Thread Anthony Balkissoon
Small fix to AbstractDocument's insertString and remove methods fixes
the bug I mentioned in my last post.  The DocumentEvents now don't
include ElementChanges unless Elements were added or removed.

I'll turn the testcase I worked on into a Mauve testcase and submit it.

2005-10-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/AbstractDocument.java:
(insertString): Don't include an ElementChange if no children were
added.
(remove): Don't include an ElementChange if no children were removed.

--Tony
Index: javax/swing/text/AbstractDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.33
diff -u -r1.33 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	6 Oct 2005 19:53:33 -	1.33
+++ javax/swing/text/AbstractDocument.java	12 Oct 2005 18:03:37 -
@@ -557,14 +557,20 @@
 int start = root.getElementIndex(changes.where);
 int end = root.getElementIndex(changes.where+changes.length);
 
-Element[] removed = new Element[1];
-removed[0] = root;
-Element[] added = new Element[end - start + 1];
-for (int i = start; i = end; i++)
-  added[i - start] = root.getElement(i);
-
-ElementEdit edit = new ElementEdit(root, root.getElementIndex(changes.where), removed, added);
-event.addEdit(edit);
+if (!(start == 0  end == 0))
+  {
+Element[] removed = new Element[1];
+removed[0] = root;
+Element[] added = new Element[end - start + 1];
+for (int i = start; i = end; i++)
+  added[i - start] = root.getElement(i);
+
+ElementEdit edit = new ElementEdit(
+   root,
+   root.getElementIndex(changes.where),
+   removed, added);
+event.addEdit(edit);
+  }
   }
 fireInsertUpdate(event);
   }
@@ -718,7 +724,7 @@
 if (content instanceof GapContent)
   changes = (GapContent.UndoRemove) temp;
 
-if (changes != null)
+if (changes != null  !(start == end))
   {
 // We need to add an ElementChange to our DocumentEvent
 ElementEdit edit = new ElementEdit (root, start, removed, added);
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: PlainView update improvements

2005-10-12 Thread Anthony Balkissoon
Didn't include the patch.  Here it is.

--Tony

On Wed, 2005-10-12 at 13:41 -0400, Anthony Balkissoon wrote:
 This patch fixes a number of issues with PlainView's updating
 facilities.  First, changedUpdate is implemented and made to call the
 same method as insertUpdate and removeUpdate (so this package private
 method was renamed from insertOrRemoveUpdate to updateDamage).
 
 Also, this method (updateDamage) is improved because if no children are
 added or removed, it calls repaint only on the area containing the line
 that was changed (this is specified in the docs but wasn't implemented
 before).  There was also a serious error in the bounds for the
 Document.getText call in this method that is now fixed.
 
 Finally, the protected method damageLineRange is implemented.
 
 Note that for the time being, the performance improvements from only
 painting the changed line are not seen because we are sending
 DocumentEvents with incorrect information, so when this method checks it
 finds that lines have been removed, even when they have not.  I'm
 writing a testcase ATM to demonstrate this and I will file a bug/mauve
 testcase and then fix the problem.
 
 
 2005-10-12  Anthony Balkissoon  [EMAIL PROTECTED]
 
   * javax/swing/text/PlainView.java:
   (insertOrRemoveUpdate): Renamed this method to udpateDamage because
   changedUpdate calls it as well.
   (updateDamage): This method used to be named insertOrRemoveDamage.
   Changes are: If no children were added or removed, repaint only the 
   area containing the line that was changed.  Also, if children were
   added or removed, call repaint on the entire container. Also fixed a 
   serious logic error in the bounds for Document.getText().
   (insertUpdate): Changed call from insertOrRemoveUpdate to updateDamage
   and removed repaint call (this is done in updateDamage).
   (removeUpdate): Likewise.
   (changedUpdate): Implemented.
   (damageLineRange): Implemented.
 
 --Tony
 
 
 
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/text/PlainView.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.19
diff -u -r1.19 PlainView.java
--- javax/swing/text/PlainView.java	11 Oct 2005 18:34:09 -	1.19
+++ javax/swing/text/PlainView.java	12 Oct 2005 17:27:20 -
@@ -320,7 +320,7 @@
 
 int pos = Utilities.getTabbedTextOffset(s, metrics, rec.x, (int)x, this, start);
 return Math.max (0, pos);
-  }
+  } 
   
   /**
* Since insertUpdate and removeUpdate each deal with children
@@ -330,16 +330,34 @@
* @param a the allocation of the View.
* @param f the ViewFactory to use for rebuilding.
*/
-  void insertOrRemoveUpdate(DocumentEvent changes, Shape a, ViewFactory f)
+  void updateDamage(DocumentEvent changes, Shape a, ViewFactory f)
   {
 Element el = getElement();
 ElementChange ec = changes.getChange(el);
+
+// If ec is null then no lines were added or removed, just 
+// repaint the changed line
 if (ec == null)
-  return;
+  {
+int line = getElement().getElementIndex(changes.getOffset());
+damageLineRange(line, line, a, getContainer());
+return;
+  }
 
+Element[] removed = ec.getChildrenRemoved();
+Element[] newElements = ec.getChildrenAdded();
+
+// If no Elements were added or removed, we just want to repaint
+// the area containing the line that was modified
+if (removed == null  newElements == null)
+  {
+int line = getElement().getElementIndex(changes.getOffset());
+damageLineRange(line, line, a, getContainer());
+return;
+  }
+
 // Check to see if we removed the longest line, if so we have to
 // search through all lines and find the longest one again
-Element[] removed = ec.getChildrenRemoved();
 if (removed != null)
   {
 for (int i = 0; i  removed.length; i++)
@@ -348,22 +366,30 @@
   // reset maxLineLength and search through all lines for longest one
   maxLineLength = -1;
   determineMaxLineLength();
+  ((JTextComponent)getContainer()).repaint();
   return;
 }
   }
 
+// If we've reached here, that means we haven't removed the longest line
+if (newElements == null)
+  {
+// No lines were added, just repaint the container and exit
+((JTextComponent)getContainer()).repaint();
+return;
+  }
+
 //  Make sure we have the metrics
 updateMetrics();
-
-// Since we didn't remove the longest line, we can just compare it to 
-// the new lines to see if any of them are longer
-Element[] newElements = ec.getChildrenAdded();
+   
+// If 

[cp-patches] FYI: Properly implement ObjectInputStream ObjectValidators

2005-10-12 Thread Mark Wielaard
Hi,

This fixes bug #22841 by rewriting the ObjectValidators support. It
seems this code has been wrong since 1998 when it was first added. But
it is not a feature that is often used.

2005-10-12  Mark Wielaard  [EMAIL PROTECTED]

Fixes bug #22841
* java/io/ObjectInputStream (validators): Removed field.
(isDeserializing): Removed field.
(currentObjectValidators): New field.
(ObjectInputStream): Remove validators and isDeserializing
initialization.
(readObject): Remove isDeserializing logic. Don't call
invokeValidators() here.
(parseContent): Call invokeValidators() after TC_OBJECT done.
(registerValidation): Create currentObjectValidators if needed.
(invokeValidators): Rewritten.

This fixes the gnu.testlet.java.io.ObjectInputStream.registerValidation
mauve tests and introduces no regressions.

Committed,

Mark
Index: java/io/ObjectInputStream.java
===
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.68
diff -u -r1.68 ObjectInputStream.java
--- java/io/ObjectInputStream.java	17 Sep 2005 15:46:22 -	1.68
+++ java/io/ObjectInputStream.java	12 Oct 2005 19:28:48 -
@@ -52,6 +52,8 @@
 import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.TreeSet;
 import java.util.Vector;
 
 public class ObjectInputStream extends InputStream
@@ -90,7 +92,6 @@
   }
 
 this.resolveEnabled = false;
-this.isDeserializing = false;
 this.blockDataPosition = 0;
 this.blockDataBytes = 0;
 this.blockData = new byte[BUFFER_SIZE];
@@ -98,7 +99,6 @@
 this.realInputStream = new DataInputStream(in);
 this.nextOID = baseWireHandle;
 this.objectLookupTable = new Hashtable();
-this.validators = new Vector();
 this.classLookupTable = new Hashtable();
 setBlockDataMode(true);
 readStreamHeader();
@@ -126,42 +126,28 @@
 if (this.useSubclassMethod)
   return readObjectOverride();
 
-boolean was_deserializing;
-
 Object ret_val;
-was_deserializing = this.isDeserializing;
-
 boolean old_mode = setBlockDataMode(false);
-
-this.isDeserializing = true;
-
 byte marker = this.realInputStream.readByte();
 
-depth += 2;
+if (DEBUG)
+  depth += 2;
 
 if(dump) dumpElement(MARKER: 0x + Integer.toHexString(marker) +  );
 
 try
   {
  	ret_val = parseContent(marker);
-   }
- finally
-   {
+  }
+finally
+  {
  	setBlockDataMode(old_mode);
- 	
- 	this.isDeserializing = was_deserializing;
- 	
- 	depth -= 2;
- 	
- 	if (! was_deserializing)
-	  {
- 	if (validators.size()  0)
- 	  invokeValidators();
- 	  }
-   }
- 
- return ret_val;
-   }
+ 	if (DEBUG)
+	  depth -= 2;
+  }
+
+return ret_val;
+  }
 
/**
 * Handles a content block within the stream, which begins with a marker
@@ -347,8 +333,10 @@
  	  int handle = assignNewHandle(obj);
  	  Object prevObject = this.currentObject;
  	  ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
+	  TreeSet prevObjectValidators = this.currentObjectValidators;
  	  
  	  this.currentObject = obj;
+	  this.currentObjectValidators = null;
  	  ObjectStreamClass[] hierarchy =
  	inputGetObjectStreamClasses(clazz);
  	  
@@ -400,7 +388,10 @@
  	  this.currentObject = prevObject;
  	  this.currentObjectStreamClass = prevObjectStreamClass;
  	  ret_val = processResolution(osc, obj, handle);
- 	  
+	  if (currentObjectValidators != null)
+	invokeValidators();
+	  this.currentObjectValidators = prevObjectValidators;
+
  	  break;
  	}
 	
@@ -732,8 +723,10 @@
   throw new InvalidObjectException(attempt to add a null 
    + ObjectInputValidation object);
 
-this.validators.addElement(new ValidatorAndPriority (validator,
-			 priority));
+if (currentObjectValidators == null)
+  currentObjectValidators = new TreeSet();
+
+currentObjectValidators.add(new ValidatorAndPriority(validator, priority));
   }
 
 
@@ -1837,18 +1830,19 @@
   // on OBJ
   private void invokeValidators() throws InvalidObjectException
   {
-Object[] validators = new Object[this.validators.size()];
-this.validators.copyInto (validators);
-Arrays.sort (validators);
-
 try
   {
-	for (int i=0; i  validators.length; i++)
-	  ((ObjectInputValidation)validators[i]).validateObject();
+	Iterator it = currentObjectValidators.iterator();
+	while(it.hasNext())
+	  {
+	ValidatorAndPriority vap = (ValidatorAndPriority) it.next();
+	ObjectInputValidation validator = vap.validator;
+	validator.validateObject();
+	  }
   }
 finally
   {
-	this.validators.removeAllElements();
+	currentObjectValidators = null;
   }
   }
 
@@ -1897,10 +1891,9 @@
   private Hashtable objectLookupTable;
   private Object currentObject;
   

[cp-patches] FYI: JTable doc and import fixes

2005-10-12 Thread Anthony Balkissoon
Just fixed some of those little yellow exclamation marks Eclipse was
showing.  A few links in API docs and 2 unused imports.

2005-10-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JTable.java: Fixed some API docs and unused imports.

--Tony
Index: javax/swing/JTable.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.51
diff -u -r1.51 JTable.java
--- javax/swing/JTable.java	7 Oct 2005 14:54:10 -	1.51
+++ javax/swing/JTable.java	12 Oct 2005 19:55:16 -
@@ -45,8 +45,6 @@
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.text.DateFormat;
@@ -86,7 +84,7 @@
* Handles property changes from the codeTableColumn/codes of this
* codeJTable/code.
*
-   * More specifically, this triggers a [EMAIL PROTECTED] #revalidate} call if the
+   * More specifically, this triggers a [EMAIL PROTECTED] #revalidate()} call if the
* preferredWidth of one of the observed columns changes.
*/
   class TableColumnPropertyChangeHandler implements PropertyChangeListener
@@ -393,7 +391,7 @@
* property when the [EMAIL PROTECTED] #dataModel} property is changed. 
*
* @see #setModel(TableModel)
-   * @see #createColumnsFromModel()
+   * @see #createDefaultColumnsFromModel()
* @see #setColumnModel(TableColumnModel)
* @see #setAutoCreateColumnsFromModel(boolean)
* @see #getAutoCreateColumnsFromModel()
@@ -516,7 +514,7 @@
   /**
* Whether or not drag-and-drop is enabled on this table.
*
-   * @see #setDragEnabled()
+   * @see #setDragEnabled(boolean)
* @see #getDragEnabled()
*/
   private boolean dragEnabled;
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Fix LineInputStream (PR classpath/24259)

2005-10-12 Thread David Daney
I just committed this patch which is the partner to my last patch.

This patch corrects the run-away buffering condition documented in the
PR by limiting the maximum buffer size.

In addition buffering is disabled if the underlying stream is a
BufferedInputStream.  Because in this case the redundant buffering
causes more memory and CPU resources to be used to allocate and move
data through all the buffers.

Tested with make -k check in GCJ libjava(HEAD) + mauve + jacks with no
regressions.


2005-10-12  David Daney  [EMAIL PROTECTED]

PR classpath/24259
* gnu/java/net/LineInputStream.java: Import BufferedInputStream.
(Constructor): Don't do blockReads on BufferedInputStreams.
(readLine): Rename MIN_LENGTH to MAX_LENGTH.  Limit buffer size to
MAX_LENGTH.

Index: gnu/java/net/LineInputStream.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/net/LineInputStream.java,v
retrieving revision 1.4
diff -u -p -r1.4 LineInputStream.java
--- gnu/java/net/LineInputStream.java   2 Jul 2005 20:32:13 -   1.4
+++ gnu/java/net/LineInputStream.java   12 Oct 2005 20:01:50 -
@@ -1,5 +1,5 @@
 /* LineInputStream.java --
-   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.

 This file is part of GNU Classpath.

@@ -38,6 +38,7 @@ exception statement from your version. *

 package gnu.java.net;

+import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FilterInputStream;
 import java.io.IOException;
@@ -91,7 +92,8 @@ public class LineInputStream
 buf = new ByteArrayOutputStream();
 this.encoding = encoding;
 eof = false;
-blockReads = in.markSupported();
+// If it is already buffered, additional buffering gains nothing.
+blockReads = !(in instanceof BufferedInputStream)  in.markSupported();
   }

   /**
@@ -109,11 +111,12 @@ public class LineInputStream
 if (blockReads)
   {
 // Use mark and reset to read chunks of bytes
-final int MIN_LENGTH = 1024;
+final int MAX_LENGTH = 1024;
 int len, pos;
-
+
 len = in.available();
-len = (len  MIN_LENGTH) ? MIN_LENGTH : len;
+if (len == 0 || len  MAX_LENGTH)
+  len = MAX_LENGTH;
 byte[] b = new byte[len];
 in.mark(len);
 // Read into buffer b


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: ScrollPaneLayout fixlet

2005-10-12 Thread Roman Kennke
In my latest patch to ScrollPaneLayout I obviously forgot some necessary
NPE checks. Here they come.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/ScrollPaneLayout.java
(minimumLayoutSize): Added checks to avoid NPEs.

/Roman
Index: javax/swing/ScrollPaneLayout.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/ScrollPaneLayout.java,v
retrieving revision 1.16
diff -u -r1.16 ScrollPaneLayout.java
--- javax/swing/ScrollPaneLayout.java	12 Oct 2005 14:36:11 -	1.16
+++ javax/swing/ScrollPaneLayout.java	12 Oct 2005 19:48:19 -
@@ -287,9 +287,9 @@
   height += hsb.getMinimumSize().height;
 if (vsb.isVisible())
   width += vsb.getMinimumSize().width;
-if (rowHead.isVisible())
+if (rowHead != null  rowHead.isVisible())
   width += rowHead.getMinimumSize().width;
-if (colHead.isVisible())
+if (colHead != null  colHead.isVisible())
   height += colHead.getMinimumSize().height;
 return new Dimension(width, height);
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] RFC: Swing painting overhaul

2005-10-12 Thread Roman Kennke
Hi,

I finally got my improved (I hope) Swing painting to work. The situation
before was, that we always went up to the root window and painted
everything and let the clipping sort out what is not repainted.

This new painting is more finegrained. It makes use of the opaque and
isOptimizedPainting properties in JComponent, to sensibly find a paint
root that is:
- opaque
- not overlapped by another component

Also I changed addDirtyRegion, so it collapses overlapping dirty regions
into bigger chunks to avoid painting the same stuff more than once
within one work request.

I would like you to test this stuff. My hope is that painting is faster
for most cases, but since I haven't benchmarked this yet, I cannot
guarantee that. Also I want to avoid introducing any bugs with that, so
I won't blindly commit it before it's tested. Also, if you feel that it
makes performance worse, I will have to look into it a little deeper.

2005-10-12  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JComponent.java
(paintImmediately): Find the paint root more cleverly, instead
of
going up to the root.
(findPaintRoot): New helper method.
(findOverlapFreeParent): New helper method.
(findOpaqueParent): New helper method.
* javax/swing/RepaintManager.java
(addDirtyRegion): Collapse overlapping dirty regions into single
regions.
(paintDirtyRegions): Simple iterator over dirty regions and
paint them. The optimizations are done in JComponent and
addDirtyRegion.

Kind regards,
Roman
Index: javax/swing/JComponent.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.68
diff -u -r1.68 JComponent.java
--- javax/swing/JComponent.java	12 Oct 2005 12:41:27 -	1.68
+++ javax/swing/JComponent.java	12 Oct 2005 20:05:45 -
@@ -1616,6 +1616,7 @@
   public void paintImmediately(Rectangle r)
   {
 // Try to find a root pane for this component.
+//Component root = findPaintRoot(r);
 Component root = SwingUtilities.getRootPane(this);
 // If no root pane can be found, then try to find the Window that contains
 // this component.
@@ -2935,5 +2936,76 @@
 JComponent jc = (JComponent) children[i];
 jc.fireAncestorEvent(ancestor, id);
   }
+  }
+
+  private Component findPaintRoot(Rectangle c)
+  {
+Component p = findOverlapFreeParent(c);
+Component root = findOpaqueParent(p);
+return root;
+  }
+
+  private Component findOverlapFreeParent(Rectangle clip)
+  {
+Rectangle currentClip = clip;
+Component found = this;
+Container parent = this; 
+while (parent != null)
+  {
+Container newParent = parent.getParent();
+if (newParent == null)
+  break;
+// If the parent is optimizedDrawingEnabled, then its children are
+// tiled and cannot have an overlapping child. Go directly to next
+// parent.
+if (newParent instanceof JComponent
+ ((JComponent) newParent).isOptimizedDrawingEnabled())
+  {
+parent = newParent;
+continue;
+  }
+
+// Otherwise we must check if one of the children of this parent
+// overlaps with the current component.
+Rectangle currentRect = SwingUtilities.convertRectangle(found,
+currentClip,
+newParent);
+Component[] children = newParent.getComponents();
+for (int i = 0; i  children.length; i++)
+  {
+if (children[i] == parent)
+  continue;
+Component c = children[i]; 
+if (currentRect.intersects(c.getX(), c.getY(), c.getWidth(),
+   c.getHeight()))
+  {
+// We found a parent whose children overlap with our current
+// component. Make this the current component.
+found = newParent;
+currentClip = currentRect;
+break;
+  }
+  }
+parent = newParent;
+  }
+return found;
+  }
+
+  private Component findOpaqueParent(Component c)
+  {
+Component found = c;
+while (true)
+  {
+if ((found instanceof JComponent)  ((JComponent) found).isOpaque())
+  break;
+else if (!(found instanceof JComponent))
+  break;
+Container p = found.getParent();
+if (p == null)
+  break;
+else
+  found = p;
+  }
+return found;
   }
 }
Index: javax/swing/RepaintManager.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/RepaintManager.java,v
retrieving revision 1.14
diff -u -r1.14 RepaintManager.java
--- javax/swing/RepaintManager.java	13 Sep 2005 

[cp-patches]: Patch: UIDefaults fix

2005-10-12 Thread Lillian Angel
When running applications that have their own UI's created, I was
getting exceptions all the time. Tom Tromey suggested this fix a while
back, and it has seemed to fix the problem every time. It has not had
any adverse side effects either.

2005-10-12  Lillian Angel  [EMAIL PROTECTED]

* javax/swing/UIDefaults.java
(getUIClass): Fixed to use the system class loader if
the loader is null.

Index: javax/swing/UIDefaults.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/UIDefaults.java,v
retrieving revision 1.23
diff -u -r1.23 UIDefaults.java
--- javax/swing/UIDefaults.java	28 Sep 2005 14:53:40 -	1.23
+++ javax/swing/UIDefaults.java	12 Oct 2005 20:19:20 -
@@ -674,9 +674,9 @@
   return null;
 try 
   {
-if (loader != null)
-  return loader.loadClass (className);
-return Class.forName (className);
+if (loader == null)
+  loader = ClassLoader.getSystemClassLoader();
+return loader.loadClass (className);
   }
 catch (Exception e)
   {
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches]: Patch: JTree fix

2005-10-12 Thread Mark Wielaard
Hi Lillian,

On Wed, 2005-10-05 at 17:28 -0400, Lillian Angel wrote:
 Fixed up BasicTreeUI because it was not efficent when painting.
 
 2005-10-05  Lillian Angel  [EMAIL PROTECTED]
 
 * javax/swing/plaf/metal/MetalTreeUI.java
 (installUI): Fixed to call toggleExpandState instead.
 * javax/swing/plaf/basic/BasicTreeUI.java
 (getPathForRow): Used currentVisiblePath to get Path.
 (getRowForPath): Used currentVisiblePath to get row.
 (getRowCount): Returned currentVisiblePath length.
 (updateLayoutCacheExpandedNodes): Took out unneeded code.
 (installUI): Fixed to call toggleExpandState instead.
 (getPreferredSize): Made more efficent by using 
   currentVisiblePath.
 (toggleExpandState): Called updateCurrentVisiblePath.
 (getCellLocation): Made more efficent.
 (paintNode): Removed.
 (paintRecursive): Made more efficent, changed paintNode calls to
 paintRow.
 (getNextVisibleNode): Reimplemented to use currentVisiblePath.
 (getPreviousVisibleNode): Likewise.
 (paintRow): Implemented.
 (updateCurrentVisiblePath): New helper used to cache the current
 visible path.

This broke junit for me (see stack trace below). The problem is that
newly introduces currentVisiblePath field can be NULL, but is used in
various places without checking whether or not it is NUll.

java.lang.NullPointerException
   at javax.swing.plaf.basic.BasicTreeUI.getPreferredSize 
(BasicTreeUI.java:1474)
   at javax.swing.plaf.basic.BasicTreeUI.getPreferredSize 
(BasicTreeUI.java:1457)
   at javax.swing.JComponent.getPreferredSize (JComponent.java:1083)
   at javax.swing.JViewport.getViewSize (JViewport.java:297)
   at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport 
(BasicScrollPaneUI.java:434)
   at 
javax.swing.plaf.basic.BasicScrollPaneUI$ViewportChangeHandler.stateChanged 
(BasicScrollPaneUI.java:160)
   at javax.swing.JViewport.fireStateChanged (JViewport.java:623)
   at javax.swing.JViewport.revalidate (JViewport.java:422)
   at javax.swing.JComponent$1.run (JComponent.java:2111)
   at java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:191)
   at java.awt.EventQueue.dispatchEvent (EventQueue.java:465)
   at java.awt.EventDispatchThread.run (EventDispatchThread.java:75)



signature.asc
Description: This is a digitally signed message part
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] [generics] Various miscellaneous fixes found by JAPI or ecj

2005-10-12 Thread Andrew John Hughes
I'm committing the attached patch to fix a few methods and fields that lack
generic information.

Changelog:

2005-10-12  Andrew John Hughes  [EMAIL PROTECTED]

* java/awt/datatransfer/DataFlavor.java:
(DataFlavor(Class?,String,String): Genericized.
* java/awt/dnd/DragGestureEvent.java:
(DragGestureEvent(DragGestureRecognizer,int,Point,
List? extends InputEvent)): Likewise.
(iterator()): Likewise.
* java/awt/dnd/DragSource.java:
(createDragGestureRecognizer(ClassT,Component,int,
DragGestureListener)): Likewise.
* java/awt/dnd/DropTargetContext.java:
(getCurrentDataFlavorsAsList()): Likewise.
* java/awt/dnd/DropTargetDragEvent.java:
(getCurrentDataFlavorsAsList()): Likewise.
* java/awt/dnd/DropTargetDropEvent.java:
(getCurrentDataFlavorsAsList()): Likewise.
* java/awt/font/TextLayout.java:
(TextLayout(String,Map? extends
AttributedCharacterIterator.Attribute, FontRenderContext)): Likewise.
* java/awt/image/BufferedImage.java:
(BufferedImage(ColorModel,WritableRaster,boolean,Hashtable?,?)):
Likewise.
* java/awt/image/ImageConsumer.java:
(setProperties(Hashtable?,?)): Likewise.
* java/awt/image/MemoryImageSource.java:
(MemoryImageSource(int,int,ColorModel,byte[],int,int,Hashtable?,?)):
Likewise.
(MemoryImageSource(int,int,ColorModel,int[],int,int,Hashtable?,?)):
Likewise.   
* java/awt/image/RenderedImage.java:
(getSources()): Likewise.
* java/awt/image/renderable/ParameterBlock.java:
(sources): Likewise.
(parameters): Likewise.
(ParameterBlock()): Likewise.
(ParameterBlock(VectorObject)): Likewise.
(ParameterBlock(VectorObject,VectorObject)): Likewise.
(clone()): Added casts to handle new Vector type.
(getSources()): Genericized.
(setSources(VectorObject)): Likewise.
(getParameters()): Likewise.
(setParameters(VectorObject)): Likewise.
* java/awt/image/renderable/RenderableImage.java:
(getSources()): Likewise.
* javax/swing/tree/DefaultMutableTreeNode.java:
(children): Likewise.
(getSharedAncestor(DefaultMutableTreeNode)): Likewise.
(getDepth()): Likewise.
(pathFromAncestorEnumeration(TreeNode)): Likewise.
(PostOrderEnumeration)): Likewise.
* javax/swing/undo/CompoundEdit.java:
(edits): Likewise.
(CompoundEdit()): Likewise.
(undo()): Likewise.
(redo()): Likewise.
(lastEdit()): Likewise.
(die()): Likewise.
(isSignificant()): Likewise.
* javax/swing/undo/UndoableEditSupport.java:
(listeners): Likewise.
(getUndoableEditListeners()): Likewise.
* lib/Makefile.am:
Turn off listing unused imports (at least for now).
* org/omg/CosNaming/_NamingContextExtImplBase.java:
(_methods): Likewise.
* org/omg/CosNaming/_NamingContextImplBase.java:
(methods): Likewise.
* vm/reference/java/lang/reflect/Method.java:
(getTypeParameters()): Corrected return type.

-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn. 
-- Richard Stallman

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: java/awt/datatransfer/DataFlavor.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/datatransfer/DataFlavor.java,v
retrieving revision 1.20.2.5
diff -u -3 -p -u -r1.20.2.5 DataFlavor.java
--- java/awt/datatransfer/DataFlavor.java   6 Oct 2005 00:59:30 -   
1.20.2.5
+++ java/awt/datatransfer/DataFlavor.java   12 Oct 2005 21:05:35 -
@@ -231,7 +231,7 @@ DataFlavor()
  * Private constructor.
  */
 private
-DataFlavor(Class representationClass,
+DataFlavor(Class? representationClass,
   String mimeType,
   String humanPresentableName)
 {
Index: java/awt/dnd/DragGestureEvent.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/dnd/DragGestureEvent.java,v
retrieving revision 1.2.2.1
diff -u -3 -p -u -r1.2.2.1 DragGestureEvent.java
--- java/awt/dnd/DragGestureEvent.java  2 Aug 2005 20:12:15 -   1.2.2.1
+++ java/awt/dnd/DragGestureEvent.java  12 Oct 2005 21:05:35 -
@@ -68,7 +68,7 @@ public class DragGestureEvent extends Ev
   private final int action;
 
   public DragGestureEvent(DragGestureRecognizer dgr, int action, Point origin,
-  List events)
+  List? extends