From 2a2b91f336fe4f6c2a314db2bc4cdffff6cf5a61 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Mon, 13 Nov 2006 00:29:48 +0000 Subject: 2006-11-13 Andrew John Hughes * Merge of HEAD-->generics from 2006/11/04-2006/11/12. --- java/awt/FlowLayout.java | 5 +- java/awt/TextComponent.java | 4 +- java/awt/TextField.java | 12 +++-- java/awt/Toolkit.java | 9 ++++ java/beans/SimpleBeanInfo.java | 15 ++++-- java/beans/beancontext/BeanContextSupport.java | 75 ++++++++++++++++++++------ java/io/OutputStreamWriter.java | 6 +++ java/util/Collections.java | 15 +++--- java/util/regex/Matcher.java | 1 + 9 files changed, 111 insertions(+), 31 deletions(-) (limited to 'java') diff --git a/java/awt/FlowLayout.java b/java/awt/FlowLayout.java index 8c9919528..70c98a29a 100644 --- a/java/awt/FlowLayout.java +++ b/java/awt/FlowLayout.java @@ -337,7 +337,10 @@ public class FlowLayout implements LayoutManager, Serializable Insets ins = parent.getInsets (); - w += (num + 1) * hgap + ins.left + ins.right; + if (num == 0) + w += 2 * hgap + ins.left + ins.right; + else + w += (num + 1) * hgap + ins.left + ins.right; h += 2 * vgap + ins.top + ins.bottom; return new Dimension (w, h); diff --git a/java/awt/TextComponent.java b/java/awt/TextComponent.java index 4fc62a951..8fdd94139 100644 --- a/java/awt/TextComponent.java +++ b/java/awt/TextComponent.java @@ -391,7 +391,9 @@ public class TextComponent extends Component */ public synchronized void setSelectionStart(int selectionStart) { - select(selectionStart, getSelectionEnd()); + select(selectionStart, + (getSelectionEnd() < selectionStart) + ? selectionStart : getSelectionEnd()); } /** diff --git a/java/awt/TextField.java b/java/awt/TextField.java index 2aff0ca64..b1df66f7c 100644 --- a/java/awt/TextField.java +++ b/java/awt/TextField.java @@ -264,9 +264,12 @@ public class TextField extends TextComponent */ public Dimension minimumSize(int columns) { + if (isMinimumSizeSet()) + return new Dimension(minSize); + TextFieldPeer peer = (TextFieldPeer) getPeer (); if (peer == null) - return null; // FIXME: What do we do if there is no peer? + return new Dimension(getWidth(), getHeight()); return peer.getMinimumSize (columns); } @@ -316,10 +319,13 @@ public class TextField extends TextComponent */ public Dimension preferredSize(int columns) { + if (isPreferredSizeSet()) + return new Dimension(prefSize); + TextFieldPeer peer = (TextFieldPeer) getPeer (); if (peer == null) - return new Dimension (0, 0); - + return new Dimension (getWidth(), getHeight()); + return peer.getPreferredSize (columns); } diff --git a/java/awt/Toolkit.java b/java/awt/Toolkit.java index 9eb4da216..5ac9e2766 100644 --- a/java/awt/Toolkit.java +++ b/java/awt/Toolkit.java @@ -41,6 +41,7 @@ package java.awt; import gnu.classpath.SystemProperties; import gnu.java.awt.peer.GLightweightPeer; +import gnu.java.awt.peer.headless.HeadlessToolkit; import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragGestureEvent; @@ -554,6 +555,14 @@ public abstract class Toolkit { if (toolkit != null) return toolkit; + + // Check for the headless property. + if (GraphicsEnvironment.isHeadless()) + { + toolkit = new HeadlessToolkit(); + return toolkit; + } + String toolkit_name = SystemProperties.getProperty("awt.toolkit", default_toolkit_name); try diff --git a/java/beans/SimpleBeanInfo.java b/java/beans/SimpleBeanInfo.java index cfb960484..56b1f7aa7 100644 --- a/java/beans/SimpleBeanInfo.java +++ b/java/beans/SimpleBeanInfo.java @@ -1,5 +1,5 @@ /* java.beans.SimpleBeanInfo - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package java.beans; import java.awt.Image; import java.awt.Toolkit; +import java.net.URL; /** ** SimpleBeanInfo is a class you may extend to more easily @@ -130,10 +131,16 @@ public class SimpleBeanInfo implements BeanInfo { ** and its BeanInfo are both loaded by the same ** ClassLoader, generally a reasonable assumption. ** @param location the URL relative - ** @return the Image in question. + ** @return the Image in question (possibly null). **/ - public Image loadImage(String location) { - return Toolkit.getDefaultToolkit().getImage(getClass().getResource(location)); + public Image loadImage(String location) + { + if (location == null) + return null; + URL url = getClass().getResource(location); + if (url == null) + return null; + return Toolkit.getDefaultToolkit().getImage(url); } } diff --git a/java/beans/beancontext/BeanContextSupport.java b/java/beans/beancontext/BeanContextSupport.java index a12c078df..2dc2a4e4a 100644 --- a/java/beans/beancontext/BeanContextSupport.java +++ b/java/beans/beancontext/BeanContextSupport.java @@ -144,42 +144,61 @@ public class BeanContextSupport extends BeanContextChildSupport */ public BeanContextSupport () { - this (null, null, true, true); + this (null, null, false, true); } /** * Construct a BeanContextSupport instance. + * + * @param peer the bean context peer (null permitted). */ - public BeanContextSupport (BeanContext peer) + public BeanContextSupport(BeanContext peer) { - this (peer, null, true, true); + this (peer, null, false, true); } /** * Construct a BeanContextSupport instance. + * + * @param peer the bean context peer (null permitted). + * @param locale the locale (null permitted, equivalent to + * the default locale). */ - public BeanContextSupport (BeanContext peer, Locale lcle) + public BeanContextSupport (BeanContext peer, Locale locale) { - this (peer, lcle, true, true); + this (peer, locale, false, true); } /** * Construct a BeanContextSupport instance. + * + * @param peer the bean context peer (null permitted). + * @param locale the locale (null permitted, equivalent to + * the default locale). + * @param dtime a flag indicating whether or not the bean context is in + * design time mode. */ - public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime) + public BeanContextSupport (BeanContext peer, Locale locale, boolean dtime) { - this (peer, lcle, dtime, true); + this (peer, locale, dtime, true); } /** * Construct a BeanContextSupport instance. + * + * @param peer the bean context peer (null permitted). + * @param locale the locale (null permitted, equivalent to + * the default locale). + * @param dtime a flag indicating whether or not the bean context is in + * design time mode. + * @param visible initial value of the okToUseGui flag. */ - public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime, + public BeanContextSupport (BeanContext peer, Locale locale, boolean dtime, boolean visible) { super(peer); - locale = lcle == null ? Locale.getDefault() : lcle; + this.locale = locale == null ? Locale.getDefault() : locale; designTime = dtime; okToUseGui = visible; @@ -447,16 +466,40 @@ public class BeanContextSupport extends BeanContextChildSupport } } - public BeanContext getBeanContextPeer () - throws NotImplementedException + /** + * Returns the bean context peer. + * + * @return The bean context peer. + * + * @see BeanContextChildSupport#beanContextChildPeer + */ + public BeanContext getBeanContextPeer() { - throw new Error ("Not implemented"); + return (BeanContext) beanContextChildPeer; } - protected static final BeanContextChild getChildBeanContextChild (Object child) - throws NotImplementedException - { - throw new Error ("Not implemented"); + /** + * Returns the {@link BeanContextChild} implementation for the given child. + * + * @param child the child (null permitted). + * + * @return The bean context child. + * + * @throws IllegalArgumentException if child implements both + * the {@link BeanContextChild} and {@link BeanContextProxy} interfaces. + */ + protected static final BeanContextChild getChildBeanContextChild(Object child) + { + if (child == null) + return null; + if (child instanceof BeanContextChild && child instanceof BeanContextProxy) + throw new IllegalArgumentException("Child cannot implement " + + "BeanContextChild and BeanContextProxy simultaneously."); + if (child instanceof BeanContextChild) + return (BeanContextChild) child; + if (child instanceof BeanContextProxy) + return ((BeanContextProxy) child).getBeanContextProxy(); + return null; } protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child) diff --git a/java/io/OutputStreamWriter.java b/java/io/OutputStreamWriter.java index 572683834..26363401f 100644 --- a/java/io/OutputStreamWriter.java +++ b/java/io/OutputStreamWriter.java @@ -223,6 +223,7 @@ public class OutputStreamWriter extends Writer encoder.onMalformedInput(CodingErrorAction.REPLACE); encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); outputBuffer = CharBuffer.allocate(BUFFER_SIZE); + encodingName = EncodingHelper.getOldCanonical(cs.name()); } /** @@ -240,6 +241,11 @@ public class OutputStreamWriter extends Writer this.out = out; encoder = enc; outputBuffer = CharBuffer.allocate(BUFFER_SIZE); + Charset cs = enc.charset(); + if (cs == null) + encodingName = "US-ASCII"; + else + encodingName = EncodingHelper.getOldCanonical(cs.name()); } /** diff --git a/java/util/Collections.java b/java/util/Collections.java index cd4a6fb40..c15fa092b 100644 --- a/java/util/Collections.java +++ b/java/util/Collections.java @@ -2068,10 +2068,11 @@ public class Collections * sorts the array, and then iterates over the list setting each element from * the array. * - * @param l the List to sort + * @param l the List to sort (null not permitted) * @throws ClassCastException if some items are not mutually comparable * @throws UnsupportedOperationException if the List is not modifiable - * @throws NullPointerException if some element is null + * @throws NullPointerException if the list is null, or contains + * some element that is null. * @see Arrays#sort(Object[]) */ public static > void sort(List l) @@ -2087,13 +2088,15 @@ public class Collections * sorts the array, and then iterates over the list setting each element from * the array. * - * @param l the List to sort + * @param l the List to sort (null not permitted) * @param c the Comparator specifying the ordering for the elements, or - * null for natural ordering + * null for natural ordering * @throws ClassCastException if c will not compare some pair of items * @throws UnsupportedOperationException if the List is not modifiable - * @throws NullPointerException if null is compared by natural ordering - * (only possible when c is null) + * @throws NullPointerException if the List is null or + * null is compared by natural ordering (only possible + * when c is null) + * * @see Arrays#sort(Object[], Comparator) */ public static void sort(List l, Comparator c) diff --git a/java/util/regex/Matcher.java b/java/util/regex/Matcher.java index 3ddd42547..bf833673b 100644 --- a/java/util/regex/Matcher.java +++ b/java/util/regex/Matcher.java @@ -278,6 +278,7 @@ public final class Matcher implements MatchResult public Matcher reset (CharSequence input) { this.input = input; + this.inputCharIndexed = RE.makeCharIndexed(input, 0); return reset(); } -- cgit v1.2.1