summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-29 22:49:21 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-29 22:49:21 +0000
commite36d2a50b5a1a677c7ecaf926e73a5dac386c1ef (patch)
tree9649a7997f35624c829eccad8c84c84e9c8e3fb9
parentbe24db70d4ff66302f560e12913f5b71acf3c12c (diff)
downloadclasspath-e36d2a50b5a1a677c7ecaf926e73a5dac386c1ef.tar.gz
2006-10-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics for 2006/10/04-2006/10/29.
-rw-r--r--ChangeLog1024
-rw-r--r--NEWS6
-rw-r--r--gnu/java/awt/ComponentReshapeEvent.java85
-rw-r--r--gnu/java/awt/peer/NativeEventLoopRunningEvent.java (renamed from tools/gnu/classpath/tools/appletviewer/AppletWarning.java)40
-rw-r--r--gnu/java/awt/peer/gtk/BufferedImageGraphics.java246
-rw-r--r--gnu/java/awt/peer/gtk/CairoGraphics2D.java97
-rw-r--r--gnu/java/awt/peer/gtk/CairoSurface.java30
-rw-r--r--gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java216
-rw-r--r--gnu/java/awt/peer/gtk/FreetypeGlyphVector.java20
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java22
-rw-r--r--gnu/java/awt/peer/gtk/GtkMainThread.java113
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java8
-rw-r--r--gnu/java/awt/peer/gtk/GtkVolatileImage.java45
-rw-r--r--gnu/java/awt/peer/gtk/GtkWindowPeer.java69
-rw-r--r--gnu/java/awt/peer/gtk/VolatileImageGraphics.java13
-rw-r--r--gnu/java/lang/InstrumentationImpl.java4
-rw-r--r--gnu/java/net/PlainDatagramSocketImpl.java57
-rw-r--r--gnu/java/net/PlainSocketImpl.java55
-rw-r--r--gnu/java/nio/KqueueSelectorImpl.java27
-rw-r--r--gnu/javax/crypto/jce/cipher/CipherAdapter.java39
-rw-r--r--gnu/javax/crypto/pad/PKCS7.java4
-rw-r--r--gnu/xml/transform/TransformerImpl.java3
-rw-r--r--include/Makefile.am3
-rw-r--r--include/gnu_java_awt_peer_gtk_CairoGraphics2D.h13
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkFramePeer.h4
-rw-r--r--include/gnu_java_net_VMPlainSocketImpl.h169
-rw-r--r--include/gnu_java_nio_EpollSelectorImpl.h94
-rw-r--r--include/gnu_java_nio_FileChannelImpl.h15
-rw-r--r--include/gnu_java_nio_KqueueSelectorImpl.h94
-rw-r--r--include/gnu_java_nio_VMChannel.h321
-rw-r--r--include/gnu_java_nio_VMPipe.h22
-rw-r--r--include/java_net_VMNetworkInterface.h29
-rw-r--r--java/awt/CardLayout.java7
-rw-r--r--java/awt/Component.java17
-rw-r--r--java/awt/Container.java62
-rw-r--r--java/awt/Dialog.java21
-rw-r--r--java/awt/EventQueue.java73
-rw-r--r--java/awt/FileDialog.java28
-rw-r--r--java/awt/Frame.java19
-rw-r--r--java/awt/LightweightDispatcher.java4
-rw-r--r--java/awt/ScrollPane.java34
-rw-r--r--java/awt/ScrollPaneAdjustable.java26
-rw-r--r--java/awt/Scrollbar.java70
-rw-r--r--java/awt/Toolkit.java2
-rw-r--r--java/awt/Window.java168
-rw-r--r--java/awt/datatransfer/DataFlavor.java3
-rw-r--r--java/awt/font/TextLayout.java13
-rw-r--r--java/awt/image/BufferedImage.java59
-rw-r--r--java/awt/image/ColorModel.java8
-rw-r--r--java/awt/image/Raster.java7
-rw-r--r--java/awt/image/WritableRaster.java5
-rw-r--r--java/net/Inet6Address.java2
-rw-r--r--java/net/MulticastSocket.java46
-rw-r--r--java/net/NetworkInterface.java20
-rw-r--r--java/net/ServerSocket.java28
-rw-r--r--java/net/Socket.java31
-rw-r--r--javax/crypto/CipherOutputStream.java180
-rw-r--r--javax/swing/AbstractButton.java137
-rw-r--r--javax/swing/DefaultComboBoxModel.java30
-rw-r--r--javax/swing/JComponent.java120
-rw-r--r--javax/swing/JDialog.java55
-rw-r--r--javax/swing/JEditorPane.java33
-rw-r--r--javax/swing/JFrame.java51
-rw-r--r--javax/swing/JLabel.java68
-rw-r--r--javax/swing/JMenuItem.java82
-rw-r--r--javax/swing/JScrollPane.java8
-rw-r--r--javax/swing/JSlider.java71
-rw-r--r--javax/swing/JSplitPane.java34
-rw-r--r--javax/swing/JTree.java21
-rw-r--r--javax/swing/JViewport.java31
-rw-r--r--javax/swing/JWindow.java5
-rw-r--r--javax/swing/RepaintManager.java36
-rw-r--r--javax/swing/ToolTipManager.java77
-rw-r--r--javax/swing/TransferHandler.java357
-rw-r--r--javax/swing/filechooser/FileSystemView.java3
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java7
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java34
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java106
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java78
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java108
-rw-r--r--javax/swing/plaf/basic/BasicSliderUI.java566
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java52
-rw-r--r--javax/swing/plaf/basic/BasicTabbedPaneUI.java107
-rw-r--r--javax/swing/plaf/metal/MetalRadioButtonUI.java2
-rw-r--r--javax/swing/plaf/metal/MetalSliderUI.java27
-rw-r--r--javax/swing/text/FlowView.java258
-rw-r--r--javax/swing/text/GlyphView.java37
-rw-r--r--javax/swing/text/ParagraphView.java32
-rw-r--r--javax/swing/text/html/BRView.java5
-rw-r--r--javax/swing/tree/AbstractLayoutCache.java25
-rw-r--r--javax/swing/tree/DefaultTreeSelectionModel.java778
-rw-r--r--javax/swing/tree/VariableHeightLayoutCache.java188
-rw-r--r--native/jawt/jawt.c2
-rw-r--r--native/jni/classpath/classpath_jawt.h1
-rw-r--r--native/jni/classpath/jcl.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c73
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c44
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c38
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c64
-rw-r--r--native/jni/gtk-peer/gtk_jawt.c35
-rw-r--r--native/jni/java-net/Makefile.am1
-rw-r--r--native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c170
-rw-r--r--native/jni/java-net/javanet.c2
-rw-r--r--native/jni/java-net/javanet.h1
-rw-r--r--native/jni/java-nio/gnu_java_nio_VMChannel.c104
-rw-r--r--native/jni/native-lib/cpio.c10
-rw-r--r--native/jni/native-lib/cpio.h1
-rw-r--r--resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties70
-rw-r--r--resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties75
-rw-r--r--resource/gnu/classpath/tools/appletviewer/messages.properties102
-rwxr-xr-xtools/Makefile.am36
-rw-r--r--tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java3
-rw-r--r--tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java175
-rw-r--r--tools/gnu/classpath/tools/appletviewer/Main.java109
-rw-r--r--tools/gnu/classpath/tools/appletviewer/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java4
-rw-r--r--tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java12
-rw-r--r--tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java4
-rw-r--r--tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java3
-rw-r--r--tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java10
-rw-r--r--tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java33
-rw-r--r--tools/gnu/classpath/tools/javah/ClassWrapper.java5
-rw-r--r--tools/gnu/classpath/tools/javah/CniPrintStream.java6
-rw-r--r--tools/gnu/classpath/tools/javah/JniIncludePrinter.java2
-rw-r--r--tools/gnu/classpath/tools/javah/JniStubPrinter.java4
-rw-r--r--tools/gnu/classpath/tools/rmic/RMICException.java51
-rw-r--r--tools/toolwrapper.c2
-rw-r--r--vm/reference/gnu/java/net/VMPlainSocketImpl.java119
-rw-r--r--vm/reference/gnu/java/nio/VMChannel.java38
-rw-r--r--vm/reference/java/lang/VMClassLoader.java3
-rw-r--r--vm/reference/java/net/VMNetworkInterface.java17
131 files changed, 5806 insertions, 3241 deletions
diff --git a/ChangeLog b/ChangeLog
index fe554bf01..97fd1ba36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,1037 @@
+2006-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (importData): Implemented stub method. Added API docs.
+
+2006-10-26 Christian Elias Naur <elias@oddlabs.com>
+
+ * native/jni/gtk-peer/gtk_jawt.c (classpath_jawt_get_depth): New
+ function.
+ * native/jni/classpath/classpath_jawt.h: Likewise.
+ * native/jawt/jawt.c (_Jv_GetDrawingSurfaceInfo): Added
+ initializer for surface_info_x11->depth.
+
+2006-10-26 Tania Bento <tbento@redhat.com>
+
+ * java/awt/FileDialog.java:
+ (setFile): Changed if-clause condition.
+
+2006-10-25 Francis Kung <fkung@redhat.com>
+
+ * include/gnu_java_nio_VMChannel.h,
+ * include/java_net_VMNetworkInterface.h,
+ * include/gnu_java_nio_EpollSelectorImpl.h,
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
+ * include/gnu_java_nio_FileChannelImpl.h,
+ * include/gnu_java_nio_KqueueSelectorImpl.h,
+ * include/gnu_java_nio_VMPipe.h,
+ * include/gnu_java_net_VMPlainSocketImpl.h: Regenerated.
+
+2006-10-25 Tania Bento <tbento@redhat.com>
+
+ * java/awt/Dialog.java: Created new private variable
+ next_dialog_number.
+ (Dialog(Frame, String, boolean, GraphicsConfiguration)):
+ Set cursor to default cursor.
+ (Dialog(Dialog, STring, boolean, GraphicsConfiguration)):
+ Same.
+ (generateName): New method.
+ (getUniqueLong): New private method.
+ * java/awt/FileDialog.java: Created new private variable
+ next_file_dialog_number.
+ (setFile): If file == "", set it to null.
+ (generateName): New method.
+ (getUniqueLong): New private method.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/net/MulticastSocket.java:
+ (setNetworkInterface): Rewritten.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * native/jni/java-net/javanet.h: Added declaration for
+ _javanet_create_inetaddress.
+ * native/jni/java-net/javanet.c:
+ (_javanet_create_inetaddress): Removed static keyword.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/java/net/PlainDatagramSocketImpl.java:
+ (connect): Use VMChannel instance for connect call.
+ (getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
+ (setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
+ (setOption): Handle multicast options.
+ (getOption): Handle multicast options.
+ * gnu/java/net/PlainSocketImpl.java:
+ (getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
+ (setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
+ (setOption): Filter unappropriate options.
+ (getOption): Filter unappropriate options.
+ (connect): Use given SocketAddress.
+ (close): Reset address and port.
+ (getInetAddress):
+ * include/Makefile.am: Removed all occurences of
+ gnu_java_net_VMPlainDatagramSocketImpl.h.
+ * include/gnu_java_net_VMPlainDatagramSocketImpl.h: Removed.
+ * native/jni/java-net/Makefile.am: Removed
+ gnu_java_net_VMPlainDatagramSocketImpl.c from sources.
+ * native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
+ Removed.
+ as SocketException, declare to throw SocketException.
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c: Added definitions
+ for SocketException and ConnectException.
+ (Java_gnu_java_nio_VMChannel_connect): Throw SocketException instead
+ of IOException.
+ (Java_gnu_java_nio_VMChannel_connect6): Throw SocketException instead
+ of IOException.
+ (Java_gnu_java_nio_VMChannel_accept): Rewritten.
+ (JCL_thread_interrupted): New function.
+ (initIDs): Added initialisation for isThreadInterrupted method id.
+ * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Added
+ CPNET_IP_TTL to java_sockopt enum.
+ (Java_gnu_java_net_VMPlainSocketImpl_setOption): Handle CPNET_IP_TTL
+ case, handle SO_LINGER case properly.
+ (Java_gnu_java_net_VMPlainSocketImpl_getOption): Handle CPNET_IP_TTL
+ case, handle SO_LINGER case properly.
+ (Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface): New
+ function.
+ (Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface): New
+ function.
+ (Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6): New
+ function.
+ (Java_gnu_java_net_VMPlainSocketImpl_leave6): Fixed constant to be
+ IPV6_LEAVE_GROUP.
+ * vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed.
+ * vm/reference/gnu/java/nio/VMChannel.java:
+ (connect(int, byte[], int, int)): Declare to throw SocketException.
+ (connect6): Declare to throw SocketException.
+ (connect(InetSocketAddress, int)): Catch IOException and rethrow
+ (isThreadInterrupted): New method.
+ * vm/reference/gnu/java/net/VMPlainSocketImpl.java: Added CP_IP_TTL
+ field.
+ (setTimeToLive): New method.
+ (getTimeToLive): New method.
+ (setMulticastInterface(int, InetAddress)): New method.
+ (setMulticastInterface(int, int, Inet4Address): New method.
+ (setMulticastInterface6(int, int, Inet6Address): New method.
+ (setOptions): Handle SO_LINGER case.
+ (getOptions): Add missing SO_REUSEADDR case.
+ * java/net/Socket.java:
+ (Socket(InetAddress, int, InetAddress, int, boolean)): Close socket
+ when exception was thrown out of connect().
+ (setSoLinger): Replaced instantiations with valueOf calls, replaced
+ Boolean.FALSE with Integer.valueOf(-1).
+ * native/jni/native-lib/cpio.h: Added cpio_closeOnExec declaration.
+ * native/jni/native-lib/cpio.c: Added cpio_closeOnExec implementation.
+ * NEWS: Documented VM interface changes.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/net/Inet6Address.java:
+ (isMulticastAddress): Fixed check.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR29576
+ * java/net/MulticastSocket.java:
+ (getNetworkInterface): Return a special NetworkInterface instance
+ if the socket's multicast interface is set to any.
+
+2006-10-25 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR29576
+ * java/net/NetworkInterface.java:
+ (createAnyInterface): New method.
+ (equals): Added if-statement to handle case where netif.name is null.
+ * vm/reference/java/net/VMNetworkInterface.java:
+ (hashCode): Rewritten.
+ (VMNetworkInterface): New constructor.
+
+2006-10-24 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * tools/Makefile.am: Add ASM_JAR define to each tool's CFLAGS.
+ * tools/toolwrapper.c (main): Set bootclasspath, not classpath.
+ Add ASM_JAR to bootclasspath.
+
+2006-10-24 Tania Bento <tbento@redhat.com>
+
+ * java/awt/Scrollbar.java:
+ (setLineIncrement): Removed unnecessary if-clause and if
+ lineIncrement == 0, then it should be set to 1, not 0.
+ (setPageIncrement): Removed unnecessary if-clause and if
+ pageIncrement == 0, then it should be set to 1, not 0.
+ (setValues): If visibleAmount <= 0, it should be set to 1, not 0.
+ If maximum <= minimum, maximum should be set to mininum + 1. The
+ actual value of maximum is maximum - visibleAmount, so I made
+ this change to the appropriate if-check. Remove the two unneccessary
+ if-clauses.
+
+2006-10-23 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (cairoSetFont): New method.
+ (copy): Set font using setFont method.
+ (setFont): Call cairoSetFont.
+ (setup): Set font using setFont method.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Added method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (install_font_peer): Removed.
+ (cairoDrawGlyphVector): Removed call to install_font_peer.
+ (cairoSetFont): New method.
+
+2006-10-23 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/NativeEventLoopRunningEvent.java: New file.
+ * gnu/java/awt/peer/gtk/GtkMainThread.java: Post
+ NativeEventLoopRunningEvent after GTK main loop start and stop.
+ * java/awt/EventQueue.java (isShutdown): Check nativeLoopRunning.
+ (getNextEvent): Set dispatchThread to null.
+ (postEventImpl): Set nativeLoopRunning.
+ (pop): Interrupt event dispatch thread.
+ * java/awt/Frame.java (noteFrame): Synchronize on weakFrames.
+
+2006-10-22 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c (config-int.h):
+ Added include.
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c (config-int.h):
+ Likewise.
+
+2006-10-23 Marco Trudel <mtrudel@gmx.ch>
+
+ * gnu/javax/crypto/pad/PKCS7.java (unpad): Removed an unnecessary test.
+ * javax/crypto/CipherOutputStream.java: Re-implemented.
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java
+ (engineUpdate(byte[], int, int)): Always keep data for unpadding in padded
+ decryption mode and check if it is a complete block.
+ (engineUpdate(byte[], int, int, byte[], int)): Likewise.
+ (engineDoFinal(byte[], int, int)): In padded decryption mode, take
+ partially processed data into account.
+
2006-10-21 Tom Tromey <tromey@redhat.com>
PR classpath/29086:
* java/util/AbstractCollection.java (toArray): Removed cast.
+2006-10-20 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/JniIncludePrinter.java (printClass):
+ Don't use mangled class name for .h file.
+ * tools/gnu/classpath/tools/javah/JniStubPrinter.java (printClass):
+ Don't use mangled class name for .c file.
+ * tools/gnu/classpath/tools/javah/CniPrintStream.java (writeClass):
+ Handle classes from the default package.
+
+2006-10-20 Francis Kung <fkung@redhat.com>
+
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Added missing constants.
+
+2006-10-19 Francis Kung <fkung@redhat.com>
+
+ PR 29510
+ * java/awt/image/BufferedImage.java
+ (constructor): Updated some properties of default image types.
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (argb32): Updated field to match default in BufferedImage.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ PR 29419
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (copyArea): Changed size comparison to return when size == 0
+ too.
+ * javax/swing/JViewport.java
+ (paintBackingStore): Check width and height of blitted area
+ and only do blit if its > 0.
+ (paintBlit): Check width and height of blitted area
+ and only do blit if its > 0.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ PR 27091
+ * gnu/java/awt/peer/gtk/GtkFramePeer.java
+ (maximize): New native method.
+ (unmaximize): New native method.
+ (iconify): New native method.
+ (deiconify): New native method.
+ (getState): Implemented.
+ (setState): Implemented.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (oldState): Rename to windowState and made protected, so that
+ the FramePeer can access it.
+ (postWindowEvent): Handle state change events more gently and
+ correctly.
+ * java/awt/Frame.java
+ (getState): Fetch state from getExtendedState().
+ (setExtendedState): Update the peer. Check if the state change
+ is actually supported.
+ (getExtendedState): Update the state from the peer.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+ (maximize): New method.
+ (unmaximize): New method.
+ (iconify): New method.
+ (deiconify): New method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+ (AWT_FRAME_NORMAL): New macro.
+ (AWT_FRAME_ICONIFIED): New macro.
+ (AWT_FRAME_MAXIMIZED_BOTH): New macro.
+ (window_window_state_cb): Rewritten to handle window state changes
+ more gently (mostly on the java side of the world).
+ * include/gnu_java_awt_peer_gtk_GtkFramePeer.h: Regenerated.
+
+2006-10-18 Tania Bento <tbento@redhat.com>
+
+ * java/awt/CardLayout.java:
+ (maximumLayoutSize): Return a new Dimension with Integer.MAX_VALUE as
+ its height and width if Container passed as argument is null.
+ (gotoComponent): Consider the case where the component is not visible.
+
+2006-10-18 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties:
+ Rename file...
+ * resource/gnu/classpath/tools/appletviewer/messages.properties:
+ New file.
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties:
+ Remove file.
+ * tools/gnu/classpath/tools/appletviewer/AppletWarning.java:
+ Remove file.
+ * tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/Messages.java: New file.
+ * tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java:
+ Retrieve user-visible strings through Messages.getString.
+ * tools/gnu/classpath/tools/appletviewer/Main.java: Likewise.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java:
+ Likewise.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java:
+ Likewise.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+ (AWT_WINDOW_OPENED): Remove unnecessary macro.
+ (window_show_cb): Removed unnecessary function.
+ (connect_signals): Don't connect signal for show. *
+ gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (hasBeenShown): Removed. This is handled in java.awt.Window.
+ (postWindowEvent): Removed handling of WINDOW_OPENED. This is done
+ in java.awt.Window. * java/awt/Window.java
+ (dispose): Post WINDOW_CLOSED here, not WINDOW_OPENED.
+
+2006-10-18 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ (drawRenderedImage): New method.
+ (drawImage): New method.
+ (CairoSurfaceGraphics): Set clip.
+ (createBuffer): New method.
+ (getBufferCM): New method.
+ (drawComposite): New method.
+ (fill): New method.
+ (getNativeCM): New method.
+ (drawGlyphVector): New method.
+ (draw): New method.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (getNativeCM): Reflect renamed field.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (cairoCM_pre): Renamed from cairoColorModel.
+ (cairoColorModel): Set premultiplication to false.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ PR 28769
+ * javax/swing/JScrollPane.java
+ (viewportBorder): Made field private.
+ (wheelScrollingEnabled): Made field private.
+ (JScrollPane): Enabled wheel scrolling by default.
+ * javax/swing/JTree.java
+ (TreeSelectionRedirector.valueChanged): Don't repaint anything
+ here.
+ (getScrollableUnitIncrement): Fixed thinko.
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (static scrollByBlock): New static method to avoid code duplication
+ for the BasicScrollPane wheel scrolling.
+ (static scrollByUnits): New static method to avoid code duplication
+ for the BasicScrollPane wheel scrolling.
+ (scrollByBlock): Delegate to static helper method.
+ (scrollByUnit): Delegate to static helper method.
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (MouseWheelHandler.mouseWheelMoved): Delegate to BasicScrollBarUI
+ static helper methods to avoid code duplication.
+ (MouseWheelHandler.bounds): Removed.
+ (MouseWheelHandler.getValue): Removed.
+ (MouseWheelHandler.scroll): Removed.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ PR 29502
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (updateComponent): Don't override this here.
+ * java/awt/Window.java
+ (addWindowListener): Ignore null listener. Set newEventsOnly flag.
+ (addWindowFocusListener): Ignore null listener. Set newEventsOnly
+ flag.
+ (addWindowStateListener): Ignore null listener. Set newEventsOnly
+ flag.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JEditorPane.java
+ (getStream): Try to detect and set the content type of the
+ connection stream.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/RepaintManager.java
+ (RepaintWorkerEvent): Pass full set of params to super.
+ (RepaintWorker.dispatch): Overridden to allow apps to call this
+ via reflection.
+ (addDirtyRegion): Synchronize a little more to protect the
+ dirtyComponents field and avoid NPEs.
+ (invokeLater): Pass full set of params to RepaintWorkerEvent
+ constructor.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JEditorPane.java
+ (page): Removed field. The page is now stored in the correct
+ document property.
+ (getPage): Fetch page URL from document property.
+ (read): Set the document for this JEditorPane. Use a Reader
+ for reading in the document.
+ (setPage): Call getStream() to get the stream from which we read.
+ Fire property change. Store page in document property.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/datatransfer/DataFlavor.java
+ (DataFlavor(String)): Removed check for space in mime string.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Container.java
+ (validateTree): Call ContainerPeer.begin|endLayout() rather than
+ begin|endValidate().
+ (validate): Call ContainerPeer.begin|endValidate() here.
+ Added some local vars to avoid NPEs.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ * native/target/.cvsignore
+ * native/target/Linux/.cvsignore
+ * native/target/generic/.cvsignore:
+ Added to let CVS ignore the generated Makefile and Makefile.in
+ files.
+
+2006-10-18 Roman Kennke <kennke@aicas.com>
+
+ PR 29448
+ * java/awt/Window.java
+ (eventTypeEnabled): Overridden to handle WindowEvents.
+ (processEvent): Switch between processWindowEvent(),
+ processWindowFocusEvent() and processWindowStateEvent() here,
+ rather than simply calling processWindowEvent().
+ (processWindowEvent): Only dispatch event to listener, do not
+ switch to processWindowFocusEvent() or processWindowStateEvent()
+ here.
+ * javax/swing/JFrame.java
+ (frameInit): Explicitly enable window and key events here.
+ (processWindowEvent): Throw out some unnecessary code.
+ * javax/swing/JWindow.java
+ (windowInit): Explicitly enable key events here.
+ * javax/swing/JDialog.java
+ (close_action): Renamed to closeAction.
+ (dialogInit): Explicitly enable window events here.
+ (getDefaultCloseOperation): Renamed close_action to closeAction.
+ (processWindowEvent): Throw out some unnecessary code.
+ Renamed close_action to closeAction.
+ (setDefaultCloseOperation): Renamed close_action to closeAction.
+
+2006-10-17 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkMainThread.java: Introduce running flag
+ to track native GTK event loop status.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Set and
+ clear running flag when native GTK event loop starts and stops.
+
+2006-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (exportToClipboard): Implemented.
+
+2006-10-17 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java (draw): Extend updated
+ region to account for pixel-shifting.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java (shiftDrawCalls): Made
+ proctected.
+
+2006-10-17 Francis Kung <fkung@redhat.com>
+
+ PR 29450
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (getLogicalBounds): Translate individual glyphs before appending bounds.
+ (getOutline): Translate individual glyphs before appending outline.
+
+2006-10-17 Cameron McCormack <cam@mcc.id.au>
+
+ PR 29014
+ * java/awt/font/TextLayout.java
+ (bidi): New field.
+ (constructor): Store bidi in field.
+ (getCharacterLevel): Implemented.
+
+2006-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (PropertyTransferable): New inner class. Handles transfers
+ from component properties.
+ (createTransferable): Implemented.
+
+2006-10-17 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (drawComposite): Ensure composite does not extend beyond buffer
+ bounds.
+ * java/awt/image/Raster.java
+ (createChild): Ensure child does not extend beyond parent's
+ bounds.
+ * java/awt/image/WritableRaster.java
+ (createWritableChild): Ensure child does not extend beyond
+ parent's bounds.
+
+2006-10-17 Jeroen Frijters <jeroen@frijters.net>
+
+ * native/jni/classpath/jcl.c
+ (JNI_OnLoad): Corrected calling convention.
+
+2006-10-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/TransferHandler.java
+ (propertyName): New field.
+ (TransferHandler(String)): Store property name in field.
+ (canImport): Implemented stub method.
+ (exportDone): This is a no-op. Removed not-implemented mark.
+ (getPropertyDataFlavor): New helper method.
+ (getPropertyDescriptor): New helper method.
+
+2006-10-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ (AccessibleJButton.getAfterIndex): Implemented.
+ (AccessibleJButton.getAtIndex): Implemented.
+ (AccessibleJButton.getBeforeIndex): Implemented.
+ (AccessibleJButton.getCharacterAttribute): Completed incomplete
+ method implementation.
+
+2006-10-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getIndexAtPoint): Implemented.
+ (AccessibleJLabel.getCharacterBounds): Implemented.
+ (AccessibleJLabel.getTextRectangle): New helper method.
+
+2006-10-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/filechooser/FileSystemView.java
+ (getFileSystemView): Mark as implemented.
+
+2006-10-14 Roman Kennke <kennke@aicas.com>
+
+ PR 27957
+ * javax/swing/JComponent.java
+ (toolTipText): Removed field.
+ (createToolTip): Don't set tooltip text here. This is done
+ in the ToolTipManager.
+ (setToolTipText): Set tooltip text as client property.
+ (getToolTipText): Get tooltip text from client property.
+ * javax/swing/ToolTipManager.java
+ (currentComponent): Made field non-static and of type JComponent.
+ (currentPoint): Made field non-static.
+ (currentTip): Made field non-static.
+ (popup): Made field non-static.
+ (toolTipText): New field. Stores the current tooltip text.
+ (checkTipUpdate): New helper method. Checks for updates of
+ the tooltip text and triggers the appropriate actions.
+ (getContentPaneDeepestComponent): Removed unneeded casts.
+ (mouseEntered): Removed unneeded cast. Initially fetch tooltip
+ text from component.
+ (mouseMoved): Check for tooltip text updates.
+ (showTip): Set tooltip text from current setting.
+
+2006-10-14 Roman Kennke <kennke@aicas.com>
+
+ PR 27956
+ * javax/swing/JSlider.java
+ (setPaintLabels): Call setLabelTable() instead of setting
+ the field directly. This also updates the label's size.
+
+2006-10-13 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/ClassWrapper.java (toString): New
+ method.
+
+2006-10-13 Tania Bento <tbento@redhat.com>
+
+ * java/awt/ScrollPane.java
+ (setLayout): Should throw AWTError whenever called.
+
+2006-10-13 Roman Kennke <kennke@aicas.com>
+
+ PR 29448
+ * java/awt/Component.java
+ (dispatchEventImpl): Special handle ComponentReshapeEvents to
+ update the AWT's knowledge about a component's size.
+ * gnu/java/awt/ComponentReshapeEvent.java: New class.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (postConfigureEvent): Directly dispatch a ComponentReshapeEvent
+ to update the AWT's knowledge about the component bounds.
+
+2006-10-13 Tania Bento <tbento@redhat.com>
+
+ * java/awt/ScrollPaneAdjustable.java
+ (setMaximum): Should throw AWTError whenever called.
+ (setMinimum): Same.
+ (setVisibleAmount): Same.
+
+2006-10-13 Tania Bento <tbento@redhat.com>
+
+ * java/awt/ScrollPane.java
+ (addImpl): When calling super, index should be value passed,
+ not -1.
+ (getIsValidString): New helper method for paramString().
+ (getScrollbarDisplayString): New helper method for paramString().
+ (paramString): Changed format of outputted string.
+
+2006-10-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/tree/DefaultTreeSelectionModel.java
+ (clone): Added cast to TreePath[].
+
+2006-10-13 Roman Kennke <kennke@aicas.com>
+
+ PR 27780
+ * javax/swing/JMenuItem.java
+ (isDragging): New field. Indicates if we are inside a mouse
+ drag.
+ (createMenuDragMouseEvent): Removed unneeded method.
+ (processMenuDragMouseEvent): Track if we are dragging.
+ (processMouseEvent): Simply forward to processMenuDragMouseEvent().
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (MenuDragMouseHandler.menuDragMouseDragged): Fetch
+ MenuSelectionManager from event.
+ (MenuDragMouseHandler.menuDragMouseEntered): Fetch
+ MenuSelectionManager from event.
+ (MenuDragMouseHandler.menuDragMouseExited): Fetch
+ MenuSelectionManager from event.
+ (MenuDragMouseHandler.menuDragMouseReleased): Click on mouse
+ release inside menu item, otherwise clear selection.
+ (MenuInputHandler.mouseReleased): Avoid multiple calls to getX()
+ and getY(). Call doClick() rather than the doClick() of JMenuItem.
+ (doClick): Perform an immediate click.
+
+2006-10-13 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/swing/DefaultComboBoxModel.java (setSelectedItem): Simply
+ return if object is not in the list.
+
2006-10-12 Andrew Haley <aph@redhat.com>
* java/lang/InheritableThreadLocal.java: Rename NULL to sentinel.
* java/lang/ThreadLocal.java: Likewise.
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ PR 27956
+ * javax/swing/JSlider.java
+ (LabelUIResource): New inner class. A JLabel as UIResource.
+ (createStandardLabels): Don't set label bounds here.
+ Create LabelUIResource instances.
+ (setInverted): Repaint.
+ (setLabelTable): Update the label UIs. Revalidate and repaint.
+ (setMajorTickSpacing): Update the label table. Repaint if
+ necessary.
+ (setMinorTickSpacing): Repaint if necessary.
+ (setOrientation): Revalidate.
+ (setPaintLabels): Revalidate and repaint.
+ (setPaintTicks): Revalidate and repaint.
+ (setPaintTrack): Repaint.
+ (updateLabelUIs): Set the label sizes here.
+ (updateUI): Also update the label UIs.
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (ComponentHandler.componentResized): Don't revalidate.
+ (FocusHandler.focusGained): Don't set field.
+ (FocusHandler.focusLost): Don't set field.
+ (PropertyChangeHandler.propertyChange): Calculate geometry
+ and repaint for a couple more properties.
+ (TrackListener.mouseReleased): Repaint.
+ (hasFocus): Removed unneeded field.
+ (calculateContentRect): No need to check for content size < 0.
+ (calculateFocusRect): Use insets from insetCache.
+ (calculateLabelRect): Fixed calculation of label rectangle.
+ It is relative to the tick rectangle, rather than the content
+ rectangle.
+ (calculateTickRect): Small restructuring to avoid unnecessary
+ comparisons.
+ (calculateTrackRect): Fixed calculation of track rectangle.
+ (getMaximumSize): Fixed. Fetch preferred size and set
+ the height of width to Short.MAX_VALUE.
+ (getMinimumHorizontalSize): Fixed to return UIManager value.
+ (getMinimumVerticalSize): Fixed to return UIManager value.
+ (getPreferredHorizontalSize): Fixed to return UIManager value.
+ (getPreferredVerticalSize): Fixed to return UIManager value.
+ (getMinimumSize): Fixed to return the UIManager value plus
+ insets added.
+ (getPreferredSize): Fixed to return the UIManager value plus
+ insets added.
+ (getWidthOfWidestLabel): Restructured for more cleanness and
+ efficiency.
+ (hitClip): New helper method.
+ (paintHorizontalLabel): Replaced by more efficient and clean
+ implementation.
+ (paintVerticalLabel): Replaced by more efficient and clean
+ implementation.
+ (paintLabels): Replaced by more efficient and clean
+ implementation.
+ (paint): Check if rectangles intersect with clip for maximum
+ efficiency.
+ (recalculateIfInsetsChanged): Fixed. This method should
+ recalculate only when the insets changed.
+ (setThumbLocation): Repaint with a reasonable clip.
+ (xPositionForValue): Made more clean and efficient.
+ (yPositionForValue): Made more clean and efficient.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponenDefaults): Added Slider.horizontalSize,
+ Slider.verticalSize, Slider.minimumHorizontalSize and
+ Slider.minimumVerticalSize properties.
+ * javax/swing/plaf/metal/MetalSliderUI.java
+ (getTickLength): Add 1 for horizontal sliders and 3 for
+ vertical sliders.
+ (paintMajorTickForHorizSlider): Fix colors. Fix line locations.
+ (paintMinorTickForHorizSlider): Fix colors. Fix line locations.
+ (paintMajorTickForVertSlider): Fix colors. Fix line locations.
+ (paintMinorTickForVertSlider): Fix colors. Fix line locations.
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ PR 28696
+ * javax/swing/text/FlowView.java
+ (FlowStrategy.layout): Preserve logical views from getting lost.
+ (FlowStrategy.layoutRow): Fix line breaking.
+ (FlowStrategy.adjustRow): Fix line breaking.
+ (FlowStrategy.changedUpdate): Mark layout invalid, or repaint.
+ (FlowStrategy.insertUpdate): Mark layout invalid, or repaint.
+ (FlowStrategy.removeUpdate): Mark layout invalid, or repaint.
+ (createView): Don't check index.
+ (contains): New helper method.
+ (reparent): New helper method.
+ (layoutDirty): Removed unneeded field.
+ (FlowView): Removed layoutDirty field init.
+ (changedUpdate): Removed layoutDirty handling.
+ (insertUpdate): Removed layoutDirty handling.
+ (removeUpdate): Removed layoutDirty handling.
+ (layout): Use isLayoutValid() rather than the layoutDirty field.
+ * javax/swing/text/GlyphView.java
+ (startOffset): Removed.
+ (endOffset): Removed.
+ (offset): New field.
+ (length): New field.
+ (GlyphView): Initialize new fields. Removed old fields.
+ (createFragment): Create fragment with new relative offsets.
+ (getEndOffset): Work with new relative offsets.
+ (getStartOffset): Work with new relative offsets.
+ * javax/swing/text/ParagraphView.java
+ (Row.getStartOffset): Overidden to determine the minimum start
+ offset from the children.
+ (Row.getEndOffset): Overidden to determine the maximum end
+ offset from the children.
+ * javax/swing/text/html/BRView.java
+ Make subclass of InlineView.
+ (getBreakWeight): Fall back to super for Y_AXIS.
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ PR 28733
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (TabPaneLayout.normalizeTabRuns): Replaced algorithm with
+ one that avoids faulty state that could cause division by zero
+ error.
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ PR 28057
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Determine correct icon. Added support for HTML label.
+ Added small optimizations.
+ (getPreferredSize): Only consider the buttons iconTextGap, and
+ only when the text is not null.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Fetch border for RadioButton from
+ BasicButtons.getRadioButtonBorder().
+ * javax/swing/plaf/metal/MetalRadioButtonUI.java
+ (paintFocus): Paint focus rectangle one pixel smaller.
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ PR 29418
+ * javax/swing/tree/AbstractLayoutCache.java
+ (getNodeDimensions): Don't throw InternalError, but instead
+ return null.
+ (getRowsForPaths): Check for null here.
+ (isFixedRowHeight): Returns true when rowHeight > 0.
+ (setSelectionModel): Set this as the row mapper for the selection
+ model.
+ * javax/swing/tree/VariableHeightLayoutCache.java
+ (NodeRecord.NodeRecord): Initialize bounds field.
+ (getBounds): Simply return the bounds field.
+ (row2Node): Changed to be an ArrayList.
+ (RECT_CACHE): New field. Caches a Rectangle instance.
+ (countRows): Added y parameter and return value. The method
+ now takes the current y position as parameter, and returns
+ the updated y position.
+ (getBounds): Fixed to return the correct bounds.
+ (getPathForRow): Replaced by fixed implementation.
+ (getPreferredHeight): Replaced by more efficient implementation.
+ This simply fetches the last node record and returns its lower
+ bounds.
+ (getPreferredWidth): Added null check.
+ (getVisibleChildCount): Added null check.
+ (getVisiblePathsFrom): Added null check.
+ (setExpandedState): Also expand the ancestors of the node
+ to be expanded.
+ (setModel): Set dirty flag rather than updating for real.
+ (setNodeDimensions): Overridden to set the dirty flag.
+ (setRowHeight): Overridden to set the dirty flag.
+ (update): Don't special case the root here, this is done now
+ in countRows().
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintImmediately2): Added support for components which need
+ to force themselves as paint root.
+ (isPaintRoot): New method. This should be overridden by components
+ which need to force themselves as paint root.
+ * javax/swing/JViewport.java
+ (isPaintRoot): Overridden to force the viewport as paint root
+ when running in backingstore mode.
+
+2006-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/tree/DefaultTreeSelectionModel.java
+ (PathPlaceHolder): New inner class. Wraps a path and its status
+ wrt to its newness.
+ (selectedPaths): New field. A supporting datastructure.
+ (tmpPaths): New field. A supporting datastructure.
+ (DefaultTreeSelectionModel): Initialize the list selection model,
+ the leadIndex and the supporting datastructures.
+ (addPropertyChangeListener): Create changeSupport object lazily.
+ (addSelectionPaths): Mostly rewritten to handle the different
+ selection modes correctly.
+ (addSelectionPath): Delegate to addSelectionPaths().
+ (arePathsContiguous): Replaced with more efficient implementation
+ using BitSet
+ (canPathBeAdded): Removed unneeded method.
+ (canPathsBeAdded): Replaced with more efficient implementation.
+ (clearSelection): Create correct event. Clear the fields correctly,
+ including the supporting datastructures.
+ (clone): Also clone the supporting datastructures and nullify
+ changeSupport field.
+ (getMaxSelectionRow): Delegate to list selection model.
+ (getMinSelectionRow): Delegate to list selection model.
+ (getPath): Removed unneeded method.
+ (getPropertyChangeListeners): Handle null changeSupport field
+ correctly.
+ (getRow): Handle null rowMapper field correctly.
+ (getSelectionRows): Handle invisible rows correctly.
+ (insureRowContinuity): Replaced by more efficient and correct
+ implementation.
+ (isRowSelected): Delegate to list selection model.
+ (notifyPathChange): Made more efficient by use of PathPlaceHolder
+ class.
+ (removePropertyChangeListener): Handle null changeSupport field.
+ (removeSelectionPaths): Mostly rewritten to handle the different
+ selection modes correctly.
+ (removeSelectionPath): Delegate to removeSelectionPaths().
+ (resetRowSelection): Handle list selection model.
+ (selectOne): Removed unneeded field.
+ (setRowMapper): Reset the row selection.
+ (setSelectionMode): Check for invalid mode and set to
+ DISCONTINUOUS_TREE_SELECTION in this case. Fire property change.
+ (setSelectionPaths): Mostly rewritten to handle the different
+ selection modes correctly.
+ (setSelectionPath): Delegate to setSelectionPaths().
+ (updateLeadIndex): Made more efficient.
+
+2006-10-11 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (buffer, locked): New fields.
+ (constructors): Initialize new variables.
+ (createBuffer): New method.
+ (draw): Implement custom composites.
+ (drawComposite): New method.
+ (drawGlyphVector): Implement custom composites.
+ (drawImage): Implement custom composites.
+ (drawRenderedImage): Implement custom composites.
+ (fill): Implement custom composites.
+ (getBufferCM): New method.
+ (getNativeCM): New method.
+ (updateBufferedImage): Fix premultiplication.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (copy): Copy composite.
+ (drawImage): Set background properly.
+ (getBufferCM): New method.
+ (setComposite): Reset alpha composite when using custom composite.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (cairoColorModel): New field.
+ (nativeColorModel): Renamed.
+ (constructor): Use renamed createCairoSampleModel method.
+ (createCairoSampleModel): New method.
+ (createNativeSampleModel): Renamed.
+ (getBufferedImage): Use renamed cairoColorModel field.
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ (gdkColorModel): New field.
+ (createGdkSampleModel): New method.
+ (getPixels): Added comments.
+ (getSnapshot): Use GDK colour and sample models.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (createBuffer): Use GDK colour and sample models.
+ (getNativeCM): Added comments.
+ * java/awt/image/BufferedImage.java
+ (constructor): Set premultiplied flag properly.
+
+2006-10-11 Edwin Steiner <edwin.steiner@gmx.net>
+
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c
+ (Java_gnu_java_nio_VMChannel_lock): Special case Long.MAX_VALUE.
+
+2006-10-10 Francis Kung <fkung@redhat.com>
+
+ PR 29372
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (createPath): Added isDraw parameter.
+ (draw): Updated createPath call.
+ (fill): Updated createPath call.
+
+2006-10-10 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/29362:
+ * gnu/xml/transform/TransformerImpl.java (transform): Only strip if
+ there is a stylesheet.
+
+2006-10-10 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Toolkit.java
+ (getDefaultTookit): Make method synchronized to avoid
+ accidentally creating more than one toolkits from different
+ threads.
+
+2006-10-10 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (handleMouseEvent): Redispatch MOUSE_WHEEL events too.
+ (redispatch): Transfer the button to the redispatched event.
+
+2006-10-10 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/ColorModel.java (coerceData): Implemented.
+
+2006-10-09 Christian Elias Naur <elias@oddlabs.com>
+
+ * vm/reference/java/lang/VMClassLoader.java:
+ (defineClassWithTransformers): Use proper class name format.
+
+2006-10-09 Gary Benson <gbenson@redhat.com>
+
+ * java/net/ServerSocket.java
+ (implAccept): Add security check.
+ (accept): Close socket if security check fails.
+ (setSocketFactory): Add security check and already-set check.
+
+2006-10-09 Roman Kennke <kennke@aicas.com>
+
+ PR 29325
+ * javax/swing/JSplitPane.java
+ (dividerLocation): New field. Stores the divider location.
+ (JSplitPane): Initialize dividerLocation with -1.
+ (addImpl): Removed unneeded local variables.
+ (getDividerLocation): Manage dividerLocation in the JSplitPane
+ class, not in the UI.
+ (setDividerLocation): Manage dividerLocation in the JSplitPane
+ class, not in the UI. Only call the UI method for notification.
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (BasicHorizontalLayoutManager.layoutContainer): Fetch divider
+ location from the JSplitPane. Honour the minimumSize, but only
+ if the divider location hasn't been set explicitly.
+ (BasicHorizontalLayoutManager.minimumLayoutSize): Removed unneeded
+ statement.
+ (BasicHorizontalLayoutManager.preferredLayoutSize): Removed unneeded
+ statement.
+ (BasicHorizontalLayoutManager.resetToPreferredSizes): Don't touch
+ the divider location.
+ (dividerLocationSet): New field.
+ (dividerLocation): Removed field.
+ (createActionMap): Fetch and set divider location on the JSplitPane.
+ (getDividerLocation): Return the actual real divider location.
+ (getMaximumSize): Removed unneeded cast.
+ (getPreferredSize): Removed unneeded cast.
+ (getMinimumSize): Removed unneeded cast.
+ (installUI): Initialize dividerLocationSet with false.
+ (uninstallUI): Initialize dividerLocationSet with false.
+ (setDividerLocation): Set dividerLocationSet to true.
+
+2006-10-09 Robert Schuster <robertschuster@fsfe.org>
+
+ * native/jni/java-net/gnu_java_net/VMPlainSocketImpl.c:
+ (Java_gnu_java_net_VMPlainSocketImpl_joinGroup): Properly
+ convert jstring into char *.
+ (Java_gnu_java_net_VMPlainSocketImpl_joinGroup6): Dito.
+ (Java_gnu_java_net_VMPlainSocketImpl_leaveGroup): Dito.
+ (Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6): Dito.
+ (getif_address): Added const modifier to second argument.
+ (getif_index): Dito.
+
+2006-10-09 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTree.java
+ (isSelected): Added API docs.
+
+2006-10-09 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTree.java
+ (isSelected): Delegate to the selection model directly.
+
+2006-10-09 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/java/nio/KqueueSelectorImpl.java: Renamed field
+ sizeof_struct_kevent to _sizeof_struct_kevent.
+
+2006-10-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * tools/gnu/classpath/tools/rmic/RMICException.java:
+ javadoc corrections, reformatted.
+
+2006-10-07 Christian Elias Naur <elias@oddlabs.com>
+
+ * gnu/java/lang/InstrumentationImpl.java:
+ Made constructor package visible.
+
+2006-10-05 Gary Benson <gbenson@redhat.com>
+
+ * java/net/Socket.java
+ (Socket): Perform security check on address not hostname.
+
2006-10-04 Roman Kennke <kennke@aicas.com>
* javax/swing/tree/VariableHeightLayoutCache.java
diff --git a/NEWS b/NEWS
index e1714e032..bf31d9c6a 100644
--- a/NEWS
+++ b/NEWS
@@ -39,11 +39,13 @@ Runtime interface changes:
* gnu.java.nio.VMPipe has been similarly changed.
* gnu.java.net.VMPlainSocketImpl has been changed to remove some
functionality now provided by VMChannel; datagram socket-specific
- methods have also been moved here, deprecating
- VMPlainDatagramSocketImpl.
+ methods have also been moved here, deprecating VMPlainDatagramSocketImpl.
+* gnu.java.net.VMPlainDatagramSocketImpl removed.
New in release 0.92 (Aug 9, 2006)
+* GConf is used as a backend for java.util.prefs. GNU Classpath
+ thanks to Mario Torre for this contribution!
* libjawtgnu.so has been renamed libjawt.so for binary compatibility.
libjawt.so should be installed in a VM-specific directory rather
than directly in /usr/lib. Proprietary VMs put their libjawt.so
diff --git a/gnu/java/awt/ComponentReshapeEvent.java b/gnu/java/awt/ComponentReshapeEvent.java
new file mode 100644
index 000000000..8f15c8519
--- /dev/null
+++ b/gnu/java/awt/ComponentReshapeEvent.java
@@ -0,0 +1,85 @@
+/* WindowResizeEvent.java -- Used to synchronize the AWT and peer sizes
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt;
+
+import java.awt.AWTEvent;
+import java.awt.Component;
+
+/**
+ * This is used to update the AWT's knowledge about a Window's size when
+ * the user changes the window bounds.
+ *
+ * This event is _not_ posted to the eventqueue, but rather dispatched directly
+ * via Window.dispatchEvent(). It is the cleanest way we could find to update
+ * the AWT's knowledge of the window size. Small testprograms showed the
+ * following:
+ * - Component.reshape() and its derivatives are _not_ called. This makes sense
+ * as it could end up in loops,because this calls back into the peers.
+ * - Intercepting event dispatching for any events in
+ * EventQueue.dispatchEvent() showed that the size is still updated. So it
+ * is not done via an event dispatched over the eventqueue.
+ *
+ * Possible other candidates for implementation would have been:
+ * - Call a (private) callback method in Window/Component from the native
+ * side.
+ * - Call a (private) callback method in Window/Component via reflection.
+ *
+ * Both is uglier than sending this event directly. Note however that this
+ * is impossible to test, as Component.dispatchEvent() is final and can't be
+ * intercepted from outside code. But this impossibility to test the issue from
+ * outside code also means that this shouldn't raise any compatibility issues.
+ */
+public class ComponentReshapeEvent
+ extends AWTEvent
+{
+
+ public int x;
+ public int y;
+ public int width;
+ public int height;
+
+ public ComponentReshapeEvent(Component c, int x, int y, int width, int height)
+ {
+ super(c, 1999);
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+}
diff --git a/tools/gnu/classpath/tools/appletviewer/AppletWarning.java b/gnu/java/awt/peer/NativeEventLoopRunningEvent.java
index b2376a4cb..962ecd990 100644
--- a/tools/gnu/classpath/tools/appletviewer/AppletWarning.java
+++ b/gnu/java/awt/peer/NativeEventLoopRunningEvent.java
@@ -1,5 +1,6 @@
-/* AppletWarning -- a security warning message display dialog
- Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+/* NativeEventLoopRunningEvent.java -- communicates to EventQueue the
+ state of the native event loop
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,32 +36,23 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.appletviewer;
+package gnu.java.awt.peer;
-import javax.swing.JOptionPane;
+import java.awt.AWTEvent;
-/**
- * @author Michael Koch (konqueror@gmx.de)
- */
-public class AppletWarning
+public class NativeEventLoopRunningEvent
+ extends AWTEvent
{
- private static String TITLE = "WARNING";
- private static boolean showWarning = false;
+ private boolean running;
- private static String MESSAGE =
- "The current version of this applet plugin does not provide\n" +
- "a security manager capable of handling Java (tm) applets. Applets\n" +
- "have UNRESTRICTED access to your computer. This means they can do\n" +
- "anything you can do, like deleting all your important data.\n\n" +
- "Continue ?";
-
- public static int show()
+ public NativeEventLoopRunningEvent(Object source)
{
- if (showWarning)
- return JOptionPane.showConfirmDialog(null, MESSAGE, TITLE,
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
- else
- return JOptionPane.YES_OPTION;
+ super(source, 2999);
+ running = ((Boolean) source).booleanValue();
+ }
+
+ public boolean isRunning()
+ {
+ return running;
}
}
diff --git a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
index e188d3fd0..341fa2a4e 100644
--- a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -38,23 +38,27 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
+import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
+import java.awt.Toolkit;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferInt;
import java.awt.image.ColorModel;
+import java.awt.image.DataBufferInt;
import java.awt.image.DirectColorModel;
-import java.awt.image.RenderedImage;
import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
import java.util.WeakHashMap;
/**
@@ -68,7 +72,13 @@ public class BufferedImageGraphics extends CairoGraphics2D
/**
* the buffered Image.
*/
- private BufferedImage image;
+ private BufferedImage image, buffer;
+
+ /**
+ * Allows us to lock the image from updates (if we want to perform a few
+ * intermediary operations on the cairo surface, then update it all at once)
+ */
+ private boolean locked;
/**
* Image size.
@@ -93,7 +103,7 @@ public class BufferedImageGraphics extends CairoGraphics2D
/**
* Colormodels we recognize for fast copying.
*/
- static ColorModel rgb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF);
+ static ColorModel rgb32 = new DirectColorModel(24, 0xFF0000, 0xFF00, 0xFF);
static ColorModel argb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF,
0xFF000000);
private boolean hasFastCM;
@@ -105,6 +115,8 @@ public class BufferedImageGraphics extends CairoGraphics2D
this.image = bi;
imageWidth = bi.getWidth();
imageHeight = bi.getHeight();
+ locked = false;
+
if(bi.getColorModel().equals(rgb32))
{
hasFastCM = true;
@@ -113,7 +125,7 @@ public class BufferedImageGraphics extends CairoGraphics2D
else if(bi.getColorModel().equals(argb32))
{
hasFastCM = true;
- hasAlpha = false;
+ hasAlpha = true;
}
else
hasFastCM = false;
@@ -163,6 +175,7 @@ public class BufferedImageGraphics extends CairoGraphics2D
cairo_t = surface.newCairoContext();
imageWidth = copyFrom.imageWidth;
imageHeight = copyFrom.imageHeight;
+ locked = false;
copy( copyFrom, cairo_t );
setClip(0, 0, surface.width, surface.height);
}
@@ -172,6 +185,9 @@ public class BufferedImageGraphics extends CairoGraphics2D
*/
private void updateBufferedImage(int x, int y, int width, int height)
{
+ if (locked)
+ return;
+
int[] pixels = surface.getPixels(imageWidth * imageHeight);
if( x > imageWidth || y > imageHeight )
@@ -184,18 +200,18 @@ public class BufferedImageGraphics extends CairoGraphics2D
if( y + height > imageHeight )
height = imageHeight - y;
- boolean wasPremultiplied = image.isAlphaPremultiplied();
- image.coerceData(true);
-
- if( !hasFastCM )
+ // The setRGB method assumes (or should assume) that pixels are NOT
+ // alpha-premultiplied, but Cairo stores data with premultiplication
+ // (thus the pixels returned in getPixels are premultiplied).
+ // This is ignored for consistency, however, since in
+ // CairoGrahpics2D.drawImage we also use non-premultiplied data
+ if(!hasFastCM)
image.setRGB(x, y, width, height, pixels,
x + y * imageWidth, imageWidth);
else
System.arraycopy(pixels, y * imageWidth,
((DataBufferInt)image.getRaster().getDataBuffer()).
getData(), y * imageWidth, height * imageWidth);
-
- image.coerceData(wasPremultiplied);
}
/**
@@ -228,36 +244,214 @@ public class BufferedImageGraphics extends CairoGraphics2D
*/
public void draw(Shape s)
{
- super.draw(s);
- Rectangle r = s.getBounds();
- updateBufferedImage(r.x, r.y, r.width, r.height);
+ if (comp == null || comp instanceof AlphaComposite)
+ {
+ super.draw(s);
+ Rectangle r = s.getBounds();
+
+ if (shiftDrawCalls)
+ updateBufferedImage(r.x, r.y, r.width+1, r.height+1);
+ else
+ updateBufferedImage(r.x, r.y, r.width, r.height);
+ }
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setStroke(this.getStroke());
+ g2d.setColor(this.getColor());
+ g2d.draw(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
}
public void fill(Shape s)
{
- super.fill(s);
- Rectangle r = s.getBounds();
- updateBufferedImage(r.x, r.y, r.width, r.height);
+ if (comp == null || comp instanceof AlphaComposite)
+ {
+ super.fill(s);
+ Rectangle r = s.getBounds();
+ updateBufferedImage(r.x, r.y, r.width, r.height);
+ }
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setPaint(this.getPaint());
+ g2d.setColor(this.getColor());
+ g2d.fill(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
}
public void drawRenderedImage(RenderedImage image, AffineTransform xform)
{
- super.drawRenderedImage(image, xform);
- updateBufferedImage(0, 0, imageWidth, imageHeight);
+ if (comp == null || comp instanceof AlphaComposite)
+ {
+ super.drawRenderedImage(image, xform);
+ updateBufferedImage(0, 0, imageWidth, imageHeight);
+ }
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setRenderingHints(this.getRenderingHints());
+ g2d.drawRenderedImage(image, xform);
+
+ drawComposite(buffer.getRaster().getBounds(), null);
+ }
+
}
protected boolean drawImage(Image img, AffineTransform xform,
Color bgcolor, ImageObserver obs)
{
- boolean rv = super.drawImage(img, xform, bgcolor, obs);
- updateBufferedImage(0, 0, imageWidth, imageHeight);
- return rv;
+ if (comp == null || comp instanceof AlphaComposite)
+ {
+ boolean rv = super.drawImage(img, xform, bgcolor, obs);
+ updateBufferedImage(0, 0, imageWidth, imageHeight);
+ return rv;
+ }
+ else
+ {
+ // Get buffered image of source
+ if( !(img instanceof BufferedImage) )
+ {
+ ImageProducer source = img.getSource();
+ if (source == null)
+ return false;
+ img = Toolkit.getDefaultToolkit().createImage(source);
+ }
+ BufferedImage bImg = (BufferedImage) img;
+
+ // Find translated bounds
+ Point2D origin = new Point2D.Double(bImg.getMinX(), bImg.getMinY());
+ Point2D pt = new Point2D.Double(bImg.getWidth() + bImg.getMinX(),
+ bImg.getHeight() + bImg.getMinY());
+ if (xform != null)
+ {
+ origin = xform.transform(origin, origin);
+ pt = xform.transform(pt, pt);
+ }
+
+ // Create buffer and draw image
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setRenderingHints(this.getRenderingHints());
+ g2d.drawImage(img, xform, obs);
+
+ // Perform compositing
+ return drawComposite(new Rectangle2D.Double(origin.getX(),
+ origin.getY(),
+ pt.getX(), pt.getY()),
+ obs);
+ }
}
public void drawGlyphVector(GlyphVector gv, float x, float y)
{
- super.drawGlyphVector(gv, x, y);
- updateBufferedImage(0, 0, imageWidth, imageHeight);
+ if (comp == null || comp instanceof AlphaComposite)
+ {
+ super.drawGlyphVector(gv, x, y);
+ updateBufferedImage(0, 0, imageWidth, imageHeight);
+ }
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setPaint(this.getPaint());
+ g2d.setStroke(this.getStroke());
+ g2d.drawGlyphVector(gv, x, y);
+
+ Rectangle2D bounds = gv.getLogicalBounds();
+ bounds = new Rectangle2D.Double(x + bounds.getX(), y + bounds.getY(),
+ bounds.getWidth(), bounds.getHeight());
+ drawComposite(bounds, null);
+ }
+ }
+
+ private boolean drawComposite(Rectangle2D bounds, ImageObserver observer)
+ {
+ // Clip source to visible areas that need updating
+ Rectangle2D clip = this.getClipBounds();
+ Rectangle2D.intersect(bounds, clip, bounds);
+ clip = new Rectangle(buffer.getMinX(), buffer.getMinY(),
+ buffer.getWidth(), buffer.getHeight());
+ Rectangle2D.intersect(bounds, clip, bounds);
+
+ BufferedImage buffer2 = buffer;
+ if (!bounds.equals(buffer2.getRaster().getBounds()))
+ buffer2 = buffer2.getSubimage((int)bounds.getX(), (int)bounds.getY(),
+ (int)bounds.getWidth(),
+ (int)bounds.getHeight());
+
+ // Get destination clip to bounds
+ double[] points = new double[] {bounds.getX(), bounds.getY(),
+ bounds.getMaxX(), bounds.getMaxY()};
+ transform.transform(points, 0, points, 0, 2);
+
+ Rectangle2D deviceBounds = new Rectangle2D.Double(points[0], points[1],
+ points[2] - points[0],
+ points[3] - points[1]);
+
+ Rectangle2D.intersect(deviceBounds, this.getClipInDevSpace(), deviceBounds);
+
+ BufferedImage current = image;
+ current = current.getSubimage((int)deviceBounds.getX(),
+ (int)deviceBounds.getY(),
+ (int)deviceBounds.getWidth(),
+ (int)deviceBounds.getHeight());
+
+ // Perform actual composite operation
+ compCtx.compose(buffer2.getRaster(), current.getRaster(),
+ current.getRaster());
+
+ // Prevent the clearRect in CairoGraphics2D.drawImage from clearing
+ // our composited image
+ locked = true;
+
+ // This MUST call directly into the "action" method in CairoGraphics2D,
+ // not one of the wrappers, to ensure that the composite isn't processed
+ // more than once!
+ boolean rv = super.drawImage(current,
+ AffineTransform.getTranslateInstance(bounds.getX(),
+ bounds.getY()),
+ new Color(0,0,0,0), null);
+ locked = false;
+ return rv;
+ }
+
+ private void createBuffer()
+ {
+ if (buffer == null)
+ {
+ buffer = new BufferedImage(image.getWidth(), image.getHeight(),
+ BufferedImage.TYPE_INT_ARGB);
+ }
+ else
+ {
+ Graphics2D g2d = ((Graphics2D)buffer.getGraphics());
+
+ g2d.setBackground(new Color(0,0,0,0));
+ g2d.clearRect(0, 0, buffer.getWidth(), buffer.getHeight());
+ }
+ }
+
+ protected ColorModel getNativeCM()
+ {
+ return image.getColorModel();
+ }
+
+ protected ColorModel getBufferCM()
+ {
+ return ColorModel.getRGBdefault();
}
}
diff --git a/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
index fd69c9b48..4c60336a3 100644
--- a/gnu/java/awt/peer/gtk/CairoGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
@@ -176,7 +176,7 @@ public abstract class CairoGraphics2D extends Graphics2D
* coords be shifted to land on 0.5-pixel boundaries, in order to land on
* "middle of pixel" coordinates and light up complete pixels.
*/
- private boolean shiftDrawCalls = false;
+ protected boolean shiftDrawCalls = false;
/**
* Keep track if the first clip to be set, which is restored on setClip(null);
@@ -220,7 +220,7 @@ public abstract class CairoGraphics2D extends Graphics2D
{
nativePointer = init(cairo_t_pointer);
setRenderingHints(new RenderingHints(getDefaultHints()));
- font = new Font("SansSerif", Font.PLAIN, 12);
+ setFont(new Font("SansSerif", Font.PLAIN, 12));
setColor(Color.black);
setBackground(Color.white);
setPaint(Color.black);
@@ -236,7 +236,6 @@ public abstract class CairoGraphics2D extends Graphics2D
nativePointer = init(cairo_t_pointer);
paint = g.paint;
stroke = g.stroke;
- comp = g.comp;
setRenderingHints(g.hints);
Color foreground;
@@ -263,8 +262,7 @@ public abstract class CairoGraphics2D extends Graphics2D
else
transform = new AffineTransform(g.transform);
- font = g.font;
-
+ setFont(g.font);
setColor(foreground);
setBackground(bg);
setPaint(paint);
@@ -386,6 +384,10 @@ public abstract class CairoGraphics2D extends Graphics2D
float x, float y, int n,
int[] codes, float[] positions);
+ /**
+ * Set the font in cairo.
+ */
+ private native void cairoSetFont(long pointer, GdkFontPeer font);
private native void cairoRelCurveTo(long pointer, double dx1, double dy1,
double dx2, double dy2, double dx3,
@@ -965,27 +967,30 @@ public abstract class CairoGraphics2D extends Graphics2D
compCtx.dispose();
compCtx = null;
- if (comp == null)
- comp = AlphaComposite.SrcOver;
-
if (comp instanceof AlphaComposite)
{
AlphaComposite a = (AlphaComposite) comp;
- cairoSetOperator(nativePointer, a.getRule());
+ cairoSetOperator(nativePointer, a.getRule());
}
else
{
- // FIXME: this check is only required "if this Graphics2D
- // context is drawing to a Component on the display screen".
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new AWTPermission("readDisplayPixels"));
-
- // FIXME: implement general Composite support
- //throw new java.lang.UnsupportedOperationException();
- // this is in progress! yay!
- compCtx = comp.createContext(getNativeCM(), getNativeCM(), hints);
+ cairoSetOperator(nativePointer, AlphaComposite.SRC_OVER);
+
+ if (comp != null)
+ {
+ // FIXME: this check is only required "if this Graphics2D
+ // context is drawing to a Component on the display screen".
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new AWTPermission("readDisplayPixels"));
+
+ // FIXME: implement general Composite support
+ //throw new java.lang.UnsupportedOperationException();
+ // this is in progress! yay!
+ //compCtx = comp.createContext(getNativeCM(), getNativeCM(), hints);
+ compCtx = comp.createContext(getBufferCM(), getNativeCM(), hints);
+ }
}
}
@@ -1003,6 +1008,12 @@ public abstract class CairoGraphics2D extends Graphics2D
// for now, so that the build doesn't break.
return null;
}
+
+ // This may be overridden by some subclasses
+ protected ColorModel getBufferCM()
+ {
+ return getNativeCM();
+ }
///////////////////////// DRAWING PRIMITIVES ///////////////////////////////////
@@ -1017,13 +1028,13 @@ public abstract class CairoGraphics2D extends Graphics2D
return;
}
- createPath(s);
+ createPath(s, true);
cairoStroke(nativePointer);
}
public void fill(Shape s)
{
- createPath(s);
+ createPath(s, false);
double alpha = 1.0;
if (comp instanceof AlphaComposite)
@@ -1031,7 +1042,7 @@ public abstract class CairoGraphics2D extends Graphics2D
cairoFill(nativePointer, alpha);
}
- private void createPath(Shape s)
+ private void createPath(Shape s, boolean isDraw)
{
cairoNewPath(nativePointer);
@@ -1039,8 +1050,8 @@ public abstract class CairoGraphics2D extends Graphics2D
if (s instanceof Rectangle2D)
{
Rectangle2D r = (Rectangle2D) s;
- cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls),
- shifted(r.getY(), shiftDrawCalls), r.getWidth(),
+ cairoRectangle(nativePointer, shifted(r.getX(),shiftDrawCalls && isDraw),
+ shifted(r.getY(), shiftDrawCalls && isDraw), r.getWidth(),
r.getHeight());
}
@@ -1070,9 +1081,9 @@ public abstract class CairoGraphics2D extends Graphics2D
}
cairoArc(nativePointer,
- shifted(e.getCenterX() / xscale, shiftDrawCalls),
- shifted(e.getCenterY() / yscale, shiftDrawCalls), radius, 0,
- Math.PI * 2);
+ shifted(e.getCenterX() / xscale, shiftDrawCalls && isDraw),
+ shifted(e.getCenterY() / yscale, shiftDrawCalls && isDraw),
+ radius, 0, Math.PI * 2);
if (xscale != 1 || yscale != 1)
cairoRestore(nativePointer);
@@ -1081,7 +1092,7 @@ public abstract class CairoGraphics2D extends Graphics2D
// All other shapes are broken down and drawn in steps using the
// PathIterator
else
- walkPath(s.getPathIterator(null), shiftDrawCalls);
+ walkPath(s.getPathIterator(null), shiftDrawCalls && isDraw);
}
/**
@@ -1214,7 +1225,7 @@ public abstract class CairoGraphics2D extends Graphics2D
Rectangle2D r = getRealBounds();
- if( width < 0 || height < 0 )
+ if( width <= 0 || height <= 0 )
return;
// Return if outside the surface
if( x + dx > r.getWidth() || y + dy > r.getHeight() )
@@ -1358,9 +1369,6 @@ public abstract class CairoGraphics2D extends Graphics2D
int width = b.getWidth();
int height = b.getHeight();
- boolean wasPremultplied = b.isAlphaPremultiplied();
- b.coerceData(true);
-
// If this BufferedImage has a BufferedImageGraphics object,
// use the cached CairoSurface that BIG is drawing onto
@@ -1380,31 +1388,32 @@ public abstract class CairoGraphics2D extends Graphics2D
((CairoSurface)raster).drawSurface(nativePointer, i2u, alpha,
getInterpolation());
updateColor();
- b.coerceData(wasPremultplied);
return true;
}
if( bgcolor != null )
{
- // Fill a rectangle with the background color
- // to composite the image onto.
- Paint oldPaint = paint;
- AffineTransform oldTransform = transform;
- setPaint( bgcolor );
- setTransform( invertedXform );
- fillRect(0, 0, width, height);
- setTransform( oldTransform );
- setPaint( oldPaint );
+ Color oldColor = bg;
+ setBackground(bgcolor);
+
+ double[] origin = new double[] {0,0};
+ xform.transform(origin, 0, origin, 0, 1);
+ clearRect((int)origin[0], (int)origin[1], width, height);
+
+ setBackground(oldColor);
}
int[] pixels = b.getRGB(0, 0, width, height, null, 0, width);
+
+ // FIXME: The above method returns data in the standard ARGB colorspace,
+ // meaning data should NOT be alpha pre-multiplied; however Cairo expects
+ // data to be premultiplied.
drawPixels(nativePointer, pixels, width, height, width, i2u, alpha,
getInterpolation());
// Cairo seems to lose the current color which must be restored.
updateColor();
- b.coerceData(wasPremultplied);
return true;
}
@@ -1607,6 +1616,8 @@ public abstract class CairoGraphics2D extends Graphics2D
font =
((ClasspathToolkit)(Toolkit.getDefaultToolkit()))
.getFont(f.getName(), f.getAttributes());
+
+ cairoSetFont(nativePointer, (GdkFontPeer)getFont().getPeer());
}
public Font getFont()
diff --git a/gnu/java/awt/peer/gtk/CairoSurface.java b/gnu/java/awt/peer/gtk/CairoSurface.java
index 91b10369d..d3b3d4504 100644
--- a/gnu/java/awt/peer/gtk/CairoSurface.java
+++ b/gnu/java/awt/peer/gtk/CairoSurface.java
@@ -72,16 +72,22 @@ public class CairoSurface extends WritableRaster
*/
long bufferPointer;
- // nativeGetPixels will return [0]=red, [1]=green, [2]=blue, [3]=alpha
- static ColorModel nativeColorModel = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
- 32,
- 0x000000FF,
+ // FIXME: use only the cairoCM_pre colormodel
+ // since that's what Cairo really uses (is there a way to do this cheaply?
+ // we use a non-multiplied model most of the time to avoid costly coercion
+ // operations...)
+ static ColorModel cairoColorModel = new DirectColorModel(32, 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+
+ static ColorModel cairoCM_pre = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ 32, 0x00FF0000,
0x0000FF00,
- 0x00FF0000,
+ 0x000000FF,
0xFF000000,
true,
Buffers.smallestAppropriateTransferType(32));
-
/**
* Allocates and clears the buffer and creates the cairo surface.
* @param width, height - the image size
@@ -147,7 +153,7 @@ public class CairoSurface extends WritableRaster
*/
public CairoSurface(int width, int height)
{
- super(createNativeSampleModel(width, height),
+ super(createCairoSampleModel(width, height),
null, new Point(0, 0));
if(width <= 0 || height <= 0)
@@ -260,7 +266,9 @@ public class CairoSurface extends WritableRaster
*/
public static BufferedImage getBufferedImage(CairoSurface surface)
{
- return new BufferedImage(nativeColorModel, surface, true, new Hashtable());
+ return new BufferedImage(cairoColorModel, surface,
+ cairoColorModel.isAlphaPremultiplied(),
+ new Hashtable());
}
private class CairoDataBuffer extends DataBuffer
@@ -326,10 +334,10 @@ public class CairoSurface extends WritableRaster
/**
* Creates a SampleModel that matches Cairo's native format
*/
- protected static SampleModel createNativeSampleModel(int w, int h)
+ protected static SampleModel createCairoSampleModel(int w, int h)
{
return new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h,
- new int[]{0x000000FF, 0x0000FF00,
- 0x00FF0000, 0xFF000000});
+ new int[]{0x00FF0000, 0x0000FF00,
+ 0x000000FF, 0xFF000000});
}
}
diff --git a/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java b/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
index 7bd136c38..36743b9c2 100644
--- a/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+++ b/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
@@ -38,10 +38,26 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.AlphaComposite;
+import java.awt.Color;
import java.awt.Graphics;
-import java.awt.GraphicsEnvironment;
+import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.RenderedImage;
+import java.util.Hashtable;
/**
* Implementation of Graphics2D on a Cairo surface.
@@ -49,6 +65,7 @@ import java.awt.geom.Rectangle2D;
public class CairoSurfaceGraphics extends CairoGraphics2D
{
protected CairoSurface surface;
+ private BufferedImage buffer;
private long cairo_t;
/**
@@ -59,6 +76,7 @@ public class CairoSurfaceGraphics extends CairoGraphics2D
this.surface = surface;
cairo_t = surface.newCairoContext();
setup( cairo_t );
+ setClip(0, 0, surface.width, surface.height);
}
/**
@@ -91,4 +109,200 @@ public class CairoSurfaceGraphics extends CairoGraphics2D
{
surface.copyAreaNative(x, y, width, height, dx, dy, surface.width);
}
+
+ /**
+ * Overloaded methods that do actual drawing need to account for custom
+ * composites
+ */
+ public void draw(Shape s)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.draw(s);
+
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setStroke(this.getStroke());
+ g2d.setColor(this.getColor());
+ g2d.draw(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
+ }
+
+ public void fill(Shape s)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.fill(s);
+
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setPaint(this.getPaint());
+ g2d.setColor(this.getColor());
+ g2d.fill(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.drawRenderedImage(image, xform);
+
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setRenderingHints(this.getRenderingHints());
+ g2d.drawRenderedImage(image, xform);
+
+ drawComposite(buffer.getRaster().getBounds(), null);
+ }
+
+ }
+
+ protected boolean drawImage(Image img, AffineTransform xform,
+ Color bgcolor, ImageObserver obs)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ return super.drawImage(img, xform, bgcolor, obs);
+
+ else
+ {
+ // Get buffered image of source
+ if( !(img instanceof BufferedImage) )
+ {
+ ImageProducer source = img.getSource();
+ if (source == null)
+ return false;
+ img = Toolkit.getDefaultToolkit().createImage(source);
+ }
+ BufferedImage bImg = (BufferedImage) img;
+
+ // Find translated bounds
+ Point2D origin = new Point2D.Double(bImg.getMinX(), bImg.getMinY());
+ Point2D pt = new Point2D.Double(bImg.getWidth() + bImg.getMinX(),
+ bImg.getHeight() + bImg.getMinY());
+ if (xform != null)
+ {
+ origin = xform.transform(origin, origin);
+ pt = xform.transform(pt, pt);
+ }
+
+ // Create buffer and draw image
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setRenderingHints(this.getRenderingHints());
+ g2d.drawImage(img, xform, obs);
+
+ // Perform compositing
+ return drawComposite(new Rectangle2D.Double(origin.getX(),
+ origin.getY(),
+ pt.getX(), pt.getY()),
+ obs);
+ }
+ }
+
+ public void drawGlyphVector(GlyphVector gv, float x, float y)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.drawGlyphVector(gv, x, y);
+
+ else
+ {
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setPaint(this.getPaint());
+ g2d.setStroke(this.getStroke());
+ g2d.drawGlyphVector(gv, x, y);
+
+ Rectangle2D bounds = gv.getLogicalBounds();
+ bounds = new Rectangle2D.Double(x + bounds.getX(), y + bounds.getY(),
+ bounds.getWidth(), bounds.getHeight());
+ drawComposite(bounds, null);
+ }
+ }
+
+ private boolean drawComposite(Rectangle2D bounds, ImageObserver observer)
+ {
+ // Clip source to visible areas that need updating
+ Rectangle2D clip = this.getClipBounds();
+ Rectangle2D.intersect(bounds, clip, bounds);
+ clip = new Rectangle(buffer.getMinX(), buffer.getMinY(),
+ buffer.getWidth(), buffer.getHeight());
+ Rectangle2D.intersect(bounds, clip, bounds);
+
+ BufferedImage buffer2 = buffer;
+ if (!bounds.equals(buffer2.getRaster().getBounds()))
+ buffer2 = buffer2.getSubimage((int)bounds.getX(), (int)bounds.getY(),
+ (int)bounds.getWidth(),
+ (int)bounds.getHeight());
+
+ // Get destination clip to bounds
+ double[] points = new double[] {bounds.getX(), bounds.getY(),
+ bounds.getMaxX(), bounds.getMaxY()};
+ transform.transform(points, 0, points, 0, 2);
+
+ Rectangle2D deviceBounds = new Rectangle2D.Double(points[0], points[1],
+ points[2] - points[0],
+ points[3] - points[1]);
+
+ Rectangle2D.intersect(deviceBounds, this.getClipInDevSpace(), deviceBounds);
+
+ BufferedImage current = CairoSurface.getBufferedImage(surface);
+ current = current.getSubimage((int)deviceBounds.getX(),
+ (int)deviceBounds.getY(),
+ (int)deviceBounds.getWidth(),
+ (int)deviceBounds.getHeight());
+
+ // Perform actual composite operation
+ compCtx.compose(buffer2.getRaster(), current.getRaster(),
+ buffer2.getRaster());
+
+ // This MUST call directly into the "action" method in CairoGraphics2D,
+ // not one of the wrappers, to ensure that the composite isn't processed
+ // more than once!
+ boolean rv = super.drawImage(buffer2,
+ AffineTransform.getTranslateInstance(bounds.getX(),
+ bounds.getY()),
+ new Color(0,0,0,0), null);
+ return rv;
+ }
+
+ private void createBuffer()
+ {
+ if (buffer == null)
+ {
+ buffer = new BufferedImage(getBufferCM(),
+ surface.createCompatibleWritableRaster(),
+ getBufferCM().isAlphaPremultiplied(),
+ new Hashtable());
+ }
+ else
+ {
+ Graphics2D g2d = ((Graphics2D)buffer.getGraphics());
+
+ g2d.setBackground(new Color(0,0,0,0));
+ g2d.clearRect(0, 0, buffer.getWidth(), buffer.getHeight());
+ }
+ }
+
+ protected ColorModel getNativeCM()
+ {
+ return CairoSurface.cairoCM_pre;
+ }
+
+ protected ColorModel getBufferCM()
+ {
+ return CairoSurface.cairoColorModel;
+ }
}
diff --git a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
index 44c1ad926..1449cdf61 100644
--- a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+++ b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
@@ -424,10 +424,18 @@ public class FreetypeGlyphVector extends GlyphVector
return logicalBounds;
Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
+ AffineTransform tx = new AffineTransform();
for( int i = 1; i < nGlyphs; i++ )
{
- Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
- rect = rect.createUnion( r2 );
+ Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
+
+ // Translate to the glyph's position
+ tx.setToTranslation(glyphPositions[i*2], glyphPositions[i*2+1]);
+ Point2D pt = new Point2D.Double(r2.getMinX(), r2.getMinY());
+ tx.transform(pt, pt);
+ r2.setRect(pt.getX(), pt.getY(), r2.getWidth(), r2.getHeight());
+
+ rect = rect.createUnion( r2 );
}
logicalBounds = rect;
@@ -448,8 +456,14 @@ public class FreetypeGlyphVector extends GlyphVector
public Shape getOutline()
{
GeneralPath path = new GeneralPath();
+ AffineTransform tx = new AffineTransform();
for( int i = 0; i < getNumGlyphs(); i++ )
- path.append( getGlyphOutline( i ), false );
+ {
+ Shape outline = getGlyphOutline(i);
+ tx.setToTranslation(glyphPositions[i*2], glyphPositions[i*2 +1]);
+ outline = tx.createTransformedShape(outline);
+ path.append(outline, false);
+ }
return path;
}
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index bb6f8b3bb..d113e92f5 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -57,6 +57,11 @@ public class GtkFramePeer extends GtkWindowPeer
native void removeMenuBarPeer ();
native void gtkFixedSetVisible (boolean visible);
+ private native void maximize();
+ private native void unmaximize();
+ private native void iconify();
+ private native void deiconify();
+
int getMenuBarHeight ()
{
return menuBar == null ? 0 : getMenuBarHeight (menuBar);
@@ -199,12 +204,25 @@ public class GtkFramePeer extends GtkWindowPeer
public int getState ()
{
- return 0;
+ return windowState;
}
public void setState (int state)
{
-
+ switch (state)
+ {
+ case Frame.NORMAL:
+ if ((windowState & Frame.ICONIFIED) != 0)
+ deiconify();
+ if ((windowState & Frame.MAXIMIZED_BOTH) != 0)
+ unmaximize();
+ break;
+ case Frame.ICONIFIED:
+ iconify();
+ break;
+ case Frame.MAXIMIZED_BOTH:
+ maximize();
+ }
}
public void setMaximizedBounds (Rectangle r)
diff --git a/gnu/java/awt/peer/gtk/GtkMainThread.java b/gnu/java/awt/peer/gtk/GtkMainThread.java
index 19d3f1d0b..a4e280fe4 100644
--- a/gnu/java/awt/peer/gtk/GtkMainThread.java
+++ b/gnu/java/awt/peer/gtk/GtkMainThread.java
@@ -38,6 +38,44 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import gnu.java.awt.peer.NativeEventLoopRunningEvent;
+
+import java.awt.AWTEvent;
+
+/**
+ * The Java thread representing the native GTK main loop, that is,
+ * GtkMainThread.mainThread, terminates when GtkToolkit.gtkMain()
+ * returns. That happens in response to the last window peer being
+ * disposed (see GtkWindowPeer.dispose).
+ *
+ * When GtkMainThread.destroyWindow is called for the last window, it
+ * in turn calls GtkMainThread.endMainThread, which calls gtk_quit.
+ * gtk_quit signals gtk_main to return, which causes GtkMainThread.run
+ * to return.
+ *
+ * There should only be one native GTK main loop running at any given
+ * time. In order to safely start and stop the GTK main loop, we use
+ * a running flag and corresponding runningLock. startMainThread will
+ * not return until the native GTK main loop has started, as confirmed
+ * by the native set_running_flag callback setting the running flag to
+ * true. Without this protection, gtk_quit could be called before the
+ * main loop has actually started, which causes GTK assertion
+ * failures. Likewise endMainThread will not return until the native
+ * GTK main loop has ended.
+ *
+ * post_running_flag_callback is called during gtk_main initialization
+ * and no window can be created before startMainThread returns. This
+ * ensures that calling post_running_flag_callback is the first action
+ * taken by the native GTK main loop.
+ *
+ * GtkMainThread.mainThread is started when the window count goes from
+ * zero to one.
+ *
+ * GtkMainThread keeps the AWT event queue informed of its status by
+ * posting NativeEventLoopRunningEvents. The AWT event queue uses
+ * this status to determine whether or not the AWT exit conditions
+ * have been met (see EventQueue.isShutdown).
+ */
public class GtkMainThread extends Thread
{
/** Count of the number of open windows */
@@ -46,6 +84,12 @@ public class GtkMainThread extends Thread
/** Lock for the above */
private static Object nWindowsLock = new Object();
+ /** Indicates whether or not the GTK main loop is running. */
+ private static boolean running = false;
+
+ /** Lock for the above. */
+ private static Object runningLock = new Object();
+
/** The main thread instance (singleton) */
public static GtkMainThread mainThread;
@@ -60,26 +104,75 @@ public class GtkMainThread extends Thread
GtkToolkit.gtkMain ();
}
+ private static void setRunning(boolean running)
+ {
+ synchronized (runningLock)
+ {
+ GtkMainThread.running = running;
+ runningLock.notifyAll();
+ }
+ }
+
private static void startMainThread()
{
- if( mainThread == null )
+ synchronized (runningLock)
{
- mainThread = new GtkMainThread();
- mainThread.start();
+ if (!running)
+ {
+ mainThread = new GtkMainThread();
+ mainThread.start();
+
+ while (!running)
+ {
+ try
+ {
+ runningLock.wait();
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println ("GtkMainThread.startMainThread:"
+ + " interrupted while waiting "
+ + " for GTK main loop to start");
+ }
+ }
+ GtkGenericPeer.q()
+ .postEvent(new NativeEventLoopRunningEvent(new Boolean(true)));
+ }
}
}
private static void endMainThread()
{
- if( mainThread != null )
- GtkToolkit.gtkQuit();
+ synchronized (runningLock)
+ {
+ if (running)
+ {
+ GtkToolkit.gtkQuit();
+
+ while (running)
+ {
+ try
+ {
+ runningLock.wait();
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println ("GtkMainThread.endMainThread:"
+ + " interrupted while waiting "
+ + " for GTK main loop to stop");
+ }
+ }
+ GtkGenericPeer.q()
+ .postEvent(new NativeEventLoopRunningEvent(new Boolean(false)));
+ }
+ }
}
public static void createWindow()
{
- synchronized( nWindowsLock )
+ synchronized (nWindowsLock)
{
- if( numberOfWindows == 0 )
+ if (numberOfWindows == 0)
startMainThread();
numberOfWindows++;
}
@@ -87,11 +180,11 @@ public class GtkMainThread extends Thread
public static void destroyWindow()
{
- synchronized( nWindowsLock )
+ synchronized (nWindowsLock)
{
numberOfWindows--;
- if( numberOfWindows == 0 )
+ if (numberOfWindows == 0)
endMainThread();
}
}
-} \ No newline at end of file
+}
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 3f87ca6e6..d2721b43f 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -664,6 +664,14 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return new GtkMouseInfoPeer();
}
+ public boolean isFrameStateSupported(int state)
+ {
+ // GTK supports ICONFIED, NORMAL and MAXIMIZE_BOTH, but
+ // not (yet?) MAXIMIZE_VERT and MAXIMIZE_HORIZ.
+ return state == Frame.NORMAL || state == Frame.ICONIFIED
+ || state == Frame.MAXIMIZED_BOTH;
+ }
+
public native int getMouseNumberOfButtons();
} // class GtkToolkit
diff --git a/gnu/java/awt/peer/gtk/GtkVolatileImage.java b/gnu/java/awt/peer/gtk/GtkVolatileImage.java
index 44e7b027b..8660ced8e 100644
--- a/gnu/java/awt/peer/gtk/GtkVolatileImage.java
+++ b/gnu/java/awt/peer/gtk/GtkVolatileImage.java
@@ -37,13 +37,21 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.ImageCapabilities;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
+import java.awt.ImageCapabilities;
+import java.awt.Point;
import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DirectColorModel;
import java.awt.image.ImageObserver;
+import java.awt.image.Raster;
+import java.awt.image.SampleModel;
+import java.awt.image.SinglePixelPackedSampleModel;
import java.awt.image.VolatileImage;
+import java.awt.image.WritableRaster;
public class GtkVolatileImage extends VolatileImage
{
@@ -52,6 +60,12 @@ public class GtkVolatileImage extends VolatileImage
final GtkComponentPeer component;
+ static ColorModel gdkColorModel = new DirectColorModel(32,
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000);
+
/**
* Don't touch, accessed from native code.
*/
@@ -62,6 +76,17 @@ public class GtkVolatileImage extends VolatileImage
native void destroy(long pointer);
native int[] nativeGetPixels(long pointer);
+
+ /**
+ * Gets the pixels in the current image from GDK.
+ *
+ * Note that pixels are in 32-bit RGBA, non-premultiplied, which is different
+ * from Cairo's premultiplied ARGB, which is different from Java's standard
+ * non-premultiplied ARGB. Caution is advised when using this method, to
+ * ensure that the data format remains consistent with what you expect.
+ *
+ * @return the current pixels, as reported by GDK.
+ */
public int[] getPixels()
{
return nativeGetPixels(nativePointer);
@@ -113,9 +138,11 @@ public class GtkVolatileImage extends VolatileImage
public BufferedImage getSnapshot()
{
- CairoSurface cs = new CairoSurface( width, height );
- cs.setPixels( getPixels() );
- return CairoSurface.getBufferedImage( cs );
+ WritableRaster raster = Raster.createWritableRaster(createGdkSampleModel(width, height),
+ new Point(0, 0));
+ raster.setDataElements(0, 0, getPixels());
+ return new BufferedImage(gdkColorModel, raster,
+ gdkColorModel.isAlphaPremultiplied(), null);
}
public Graphics getGraphics()
@@ -167,4 +194,14 @@ public class GtkVolatileImage extends VolatileImage
{
return null;
}
+
+ /**
+ * Creates a SampleModel that matches GDK's native format
+ */
+ protected static SampleModel createGdkSampleModel(int w, int h)
+ {
+ return new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h,
+ new int[]{0x000000FF, 0x0000FF00,
+ 0x00FF0000, 0xFF000000});
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
index 1f340611e..1abc5ca84 100644
--- a/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import gnu.java.awt.ComponentReshapeEvent;
+
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
@@ -62,8 +64,7 @@ public class GtkWindowPeer extends GtkContainerPeer
protected static final int GDK_WINDOW_TYPE_HINT_DOCK = 6;
protected static final int GDK_WINDOW_TYPE_HINT_DESKTOP = 7;
- private boolean hasBeenShown = false;
- private int oldState = Frame.NORMAL;
+ protected int windowState = Frame.NORMAL;
// Cached awt window component location, width and height.
private int x, y, width, height;
@@ -224,9 +225,31 @@ public class GtkWindowPeer extends GtkContainerPeer
// only called from GTK thread
protected void postConfigureEvent (int x, int y, int width, int height)
{
+ int frame_x = x - insets.left;
+ int frame_y = y - insets.top;
int frame_width = width + insets.left + insets.right;
int frame_height = height + insets.top + insets.bottom;
+ // Update the component's knowledge about the size.
+ // Important: Please look at the big comment in ComponentReshapeEvent
+ // to learn why we did it this way. If you change this code, make
+ // sure that the peer->AWT bounds update still works.
+ // (for instance: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29448 )
+
+ // We do this befor we post the ComponentEvent, because (in Window)
+ // we invalidate() / revalidate() when a ComponentEvent is seen,
+ // and the AWT must already know about the new size then.
+ if (frame_x != this.x || frame_y != this.y || frame_width != this.width
+ || frame_height != this.height)
+ {
+ ComponentReshapeEvent ev = new ComponentReshapeEvent(awtComponent,
+ frame_x,
+ frame_y,
+ frame_width,
+ frame_height);
+ awtComponent.dispatchEvent(ev);
+ }
+
if (frame_width != getWidth()
|| frame_height != getHeight())
{
@@ -236,9 +259,6 @@ public class GtkWindowPeer extends GtkContainerPeer
ComponentEvent.COMPONENT_RESIZED));
}
- int frame_x = x - insets.left;
- int frame_y = y - insets.top;
-
if (frame_x != getX()
|| frame_y != getY())
{
@@ -247,6 +267,7 @@ public class GtkWindowPeer extends GtkContainerPeer
q().postEvent(new ComponentEvent(awtComponent,
ComponentEvent.COMPONENT_MOVED));
}
+
}
public void show ()
@@ -261,23 +282,26 @@ public class GtkWindowPeer extends GtkContainerPeer
void postWindowEvent (int id, Window opposite, int newState)
{
- if (id == WindowEvent.WINDOW_OPENED)
+ if (id == WindowEvent.WINDOW_STATE_CHANGED)
{
- // Post a WINDOW_OPENED event the first time this window is shown.
- if (!hasBeenShown)
+ if (windowState != newState)
{
+ // Post old styleWindowEvent with WINDOW_ICONIFIED or
+ // WINDOW_DEICONIFIED if appropriate.
+ if ((windowState & Frame.ICONIFIED) != 0
+ && (newState & Frame.ICONIFIED) == 0)
+ q().postEvent(new WindowEvent((Window) awtComponent,
+ WindowEvent.WINDOW_DEICONIFIED,
+ opposite, 0, 0));
+ else if ((windowState & Frame.ICONIFIED) == 0
+ && (newState & Frame.ICONIFIED) != 0)
+ q().postEvent(new WindowEvent((Window) awtComponent,
+ WindowEvent.WINDOW_ICONIFIED,
+ opposite, 0, 0));
+ // Post new-style WindowStateEvent.
q().postEvent (new WindowEvent ((Window) awtComponent, id,
- opposite));
- hasBeenShown = true;
- }
- }
- else if (id == WindowEvent.WINDOW_STATE_CHANGED)
- {
- if (oldState != newState)
- {
- q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite,
- oldState, newState));
- oldState = newState;
+ opposite, windowState, newState));
+ windowState = newState;
}
}
else
@@ -356,13 +380,6 @@ public class GtkWindowPeer extends GtkContainerPeer
return g;
}
- protected void updateComponent (PaintEvent event)
- {
- // Do not clear anything before painting. Sun never calls
- // Window.update, only Window.paint.
- paintComponent(event);
- }
-
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
{
diff --git a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
index 560d31750..3a9f9d693 100644
--- a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
@@ -282,12 +282,12 @@ public class VolatileImageGraphics extends ComponentGraphics
if (buffer == null)
{
WritableRaster rst;
- rst = Raster.createWritableRaster(CairoSurface.
- createNativeSampleModel(owner.width,
+ rst = Raster.createWritableRaster(GtkVolatileImage.createGdkSampleModel(owner.width,
owner.height),
new Point(0,0));
- buffer = new BufferedImage(CairoSurface.nativeColorModel, rst, true,
+ buffer = new BufferedImage(GtkVolatileImage.gdkColorModel, rst,
+ GtkVolatileImage.gdkColorModel.isAlphaPremultiplied(),
new Hashtable());
}
else
@@ -301,7 +301,12 @@ public class VolatileImageGraphics extends ComponentGraphics
protected ColorModel getNativeCM()
{
- return CairoSurface.nativeColorModel;
+ // We should really return GtkVolatileImage.gdkColorModel ,
+ // but CairoGraphics2D doesn't handle alpha premultiplication properly (see
+ // the fixme in drawImage) so we use the naive Cairo model instead to trick
+ // the compositing context.
+ // Because getNativeCM() == getBufferCM() for this peer, it doesn't break.
+ return CairoSurface.cairoCM_pre;
}
}
diff --git a/gnu/java/lang/InstrumentationImpl.java b/gnu/java/lang/InstrumentationImpl.java
index 3192683ef..2425b35c8 100644
--- a/gnu/java/lang/InstrumentationImpl.java
+++ b/gnu/java/lang/InstrumentationImpl.java
@@ -1,6 +1,6 @@
/* InstrumentationImpl.java -- GNU implementation of
java.lang.instrument.Instrumentation
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -67,7 +67,7 @@ public final class InstrumentationImpl implements Instrumentation
new ArrayList<ClassFileTransformer>();
- private InstrumentationImpl()
+ InstrumentationImpl()
{
}
diff --git a/gnu/java/net/PlainDatagramSocketImpl.java b/gnu/java/net/PlainDatagramSocketImpl.java
index be2fc796b..a84525e18 100644
--- a/gnu/java/net/PlainDatagramSocketImpl.java
+++ b/gnu/java/net/PlainDatagramSocketImpl.java
@@ -1,5 +1,5 @@
/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
- Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import gnu.java.nio.VMChannel;
import java.io.IOException;
import java.io.InterruptedIOException;
-import java.lang.reflect.Field;
import java.net.DatagramPacket;
import java.net.DatagramSocketImpl;
import java.net.InetAddress;
@@ -69,7 +68,6 @@ import java.nio.ByteBuffer;
*/
public final class PlainDatagramSocketImpl extends DatagramSocketImpl
{
-
private final VMChannel channel;
/**
@@ -171,7 +169,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected void connect(InetAddress addr, int port) throws SocketException
{
- VMPlainDatagramSocketImpl.connect(this, addr, port);
+ channel.connect(new InetSocketAddress(addr, port), 0);
}
/**
@@ -203,7 +201,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected synchronized void setTimeToLive(int ttl) throws IOException
{
- setOption(VMPlainDatagramSocketImpl.IP_TTL, new Integer(ttl));
+ impl.setTimeToLive(ttl);
}
/**
@@ -215,12 +213,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected synchronized int getTimeToLive() throws IOException
{
- Object obj = getOption(VMPlainDatagramSocketImpl.IP_TTL);
-
- if (! (obj instanceof Integer))
- throw new IOException("Internal Error");
-
- return ((Integer) obj).intValue();
+ return impl.getTimeToLive();
}
protected int getLocalPort()
@@ -318,30 +311,53 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
/**
* Sets the value of an option on the socket
*
- * @param option_id The identifier of the option to set
- * @param val The value of the option to set
+ * @param optionId The identifier of the option to set
+ * @param value The value of the option to set
*
* @exception SocketException If an error occurs
*/
- public synchronized void setOption(int option_id, Object val)
+ public synchronized void setOption(int optionId, Object value)
throws SocketException
{
- impl.setOption(option_id, val);
+ switch (optionId)
+ {
+ case IP_MULTICAST_IF:
+ case IP_MULTICAST_IF2:
+ impl.setMulticastInterface(optionId, (InetAddress) value);
+ break;
+
+ case IP_MULTICAST_LOOP:
+ case SO_BROADCAST:
+ case SO_KEEPALIVE:
+ case SO_OOBINLINE:
+ case TCP_NODELAY:
+ case IP_TOS:
+ case SO_LINGER:
+ case SO_RCVBUF:
+ case SO_SNDBUF:
+ case SO_TIMEOUT:
+ case SO_REUSEADDR:
+ impl.setOption(optionId, value);
+ return;
+
+ default:
+ throw new SocketException("cannot set option " + optionId);
+ }
}
/**
* Retrieves the value of an option on the socket
*
- * @param option_id The identifier of the option to retrieve
+ * @param optionId The identifier of the option to retrieve
*
* @return The value of the option
*
* @exception SocketException If an error occurs
*/
- public synchronized Object getOption(int option_id)
+ public synchronized Object getOption(int optionId)
throws SocketException
{
- if (option_id == SO_BINDADDR)
+ if (optionId == SO_BINDADDR)
{
try
{
@@ -361,7 +377,10 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
throw se;
}
}
- return impl.getOption(option_id);
+ if (optionId == IP_MULTICAST_IF || optionId == IP_MULTICAST_IF2)
+ return impl.getMulticastInterface(optionId);
+
+ return impl.getOption(optionId);
}
/**
diff --git a/gnu/java/net/PlainSocketImpl.java b/gnu/java/net/PlainSocketImpl.java
index 750243d5d..64e498746 100644
--- a/gnu/java/net/PlainSocketImpl.java
+++ b/gnu/java/net/PlainSocketImpl.java
@@ -39,12 +39,9 @@ exception statement from your version. */
package gnu.java.net;
-import gnu.java.nio.SelectorProviderImpl;
import gnu.java.nio.SocketChannelImpl;
import gnu.java.nio.VMChannel;
-import gnu.java.security.action.GetSecurityPropertyAction;
-import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import java.io.InterruptedIOException;
@@ -56,7 +53,6 @@ import java.net.SocketException;
import java.net.SocketImpl;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
@@ -148,26 +144,21 @@ public class PlainSocketImpl extends SocketImpl
{
switch (optionId)
{
- case IP_MULTICAST_IF:
- case IP_MULTICAST_IF2:
- throw new UnsupportedOperationException("FIXME");
-
+ case SO_LINGER:
case IP_MULTICAST_LOOP:
case SO_BROADCAST:
case SO_KEEPALIVE:
case SO_OOBINLINE:
case TCP_NODELAY:
case IP_TOS:
- case SO_LINGER:
case SO_RCVBUF:
case SO_SNDBUF:
case SO_TIMEOUT:
case SO_REUSEADDR:
impl.setOption(optionId, value);
return;
-
- default:
- throw new SocketException("cannot set option " + optionId);
+ default:
+ throw new SocketException("Unrecognized TCP option: " + optionId);
}
}
@@ -197,10 +188,26 @@ public class PlainSocketImpl extends SocketImpl
throw se;
}
}
- if (optionId == IP_MULTICAST_IF || optionId == IP_MULTICAST_IF2)
- throw new UnsupportedOperationException ("can't get option " +
- optionId + " yet");
- return impl.getOption(optionId);
+
+ // This filters options which are invalid for TCP.
+ switch (optionId)
+ {
+ case SO_LINGER:
+ case IP_MULTICAST_LOOP:
+ case SO_BROADCAST:
+ case SO_KEEPALIVE:
+ case SO_OOBINLINE:
+ case TCP_NODELAY:
+ case IP_TOS:
+ case SO_RCVBUF:
+ case SO_SNDBUF:
+ case SO_TIMEOUT:
+ case SO_REUSEADDR:
+ return impl.getOption(optionId);
+ default:
+ throw new SocketException("Unrecognized TCP option: " + optionId);
+ }
+
}
public void shutdownInput() throws IOException
@@ -274,7 +281,10 @@ public class PlainSocketImpl extends SocketImpl
boolean connected = channel.connect(address, timeout);
if (!connected)
throw new SocketTimeoutException("connect timed out");
- InetSocketAddress addr = channel.getVMChannel().getPeerAddress();
+
+ // Using the given SocketAddress is important to preserve
+ // hostnames given by the caller.
+ InetSocketAddress addr = (InetSocketAddress) address;
this.address = addr.getAddress();
this.port = addr.getPort();
}
@@ -364,6 +374,9 @@ public class PlainSocketImpl extends SocketImpl
{
if (impl.getState().isValid())
impl.close();
+
+ address = null;
+ port = -1;
}
public void sendUrgentData(int data) throws IOException
@@ -417,11 +430,18 @@ public class PlainSocketImpl extends SocketImpl
{
if (channel == null)
return null;
+
try
{
InetSocketAddress remote = channel.getVMChannel().getPeerAddress();
if (remote == null)
return null;
+ // To mimic behavior of the RI the InetAddress instance which was
+ // used to establish the connection is returned instead of one that
+ // was created by the native layer (this preserves exact hostnames).
+ if (address != null)
+ return address;
+
return remote.getAddress();
}
catch (IOException ioe)
@@ -471,6 +491,7 @@ public class PlainSocketImpl extends SocketImpl
{
if (channel == null)
return -1;
+
try
{
InetSocketAddress remote = channel.getVMChannel().getPeerAddress();
diff --git a/gnu/java/nio/KqueueSelectorImpl.java b/gnu/java/nio/KqueueSelectorImpl.java
index eed86119c..34ca1dc59 100644
--- a/gnu/java/nio/KqueueSelectorImpl.java
+++ b/gnu/java/nio/KqueueSelectorImpl.java
@@ -63,7 +63,10 @@ import java.util.Set;
*/
public class KqueueSelectorImpl extends AbstractSelector
{
- private static final int sizeof_struct_kevent;
+ // Prepended underscore to field name to make it distinct
+ // from the method with the similar name.
+ private static final int _sizeof_struct_kevent;
+
private static final int MAX_DOUBLING_CAPACITY = 16384;
private static final int CAP_INCREMENT = 1024;
private static final int INITIAL_CAPACITY;
@@ -80,10 +83,10 @@ public class KqueueSelectorImpl extends AbstractSelector
}
if (kqueue_supported ())
- sizeof_struct_kevent = sizeof_struct_kevent();
+ _sizeof_struct_kevent = sizeof_struct_kevent();
else
- sizeof_struct_kevent = -1;
- INITIAL_CAPACITY = 16 * sizeof_struct_kevent;
+ _sizeof_struct_kevent = -1;
+ INITIAL_CAPACITY = 16 * _sizeof_struct_kevent;
}
/**
@@ -205,7 +208,7 @@ public class KqueueSelectorImpl extends AbstractSelector
key.interestOps = 0;
}
- int events_size = (2 * sizeof_struct_kevent) * keys.size();
+ int events_size = (2 * _sizeof_struct_kevent) * keys.size();
int num_events = 0;
for (Iterator it = keys.entrySet().iterator(); it.hasNext(); )
@@ -256,7 +259,7 @@ public class KqueueSelectorImpl extends AbstractSelector
if (blockedThread.isInterrupted())
timeout = 0;
n = kevent(kq, events, num_events,
- events.capacity() / sizeof_struct_kevent, timeout);
+ events.capacity() / _sizeof_struct_kevent, timeout);
}
finally
{
@@ -267,7 +270,7 @@ public class KqueueSelectorImpl extends AbstractSelector
}
//System.out.println("dump of keys selected:");
- //dump_selection_keys((ByteBuffer) events.duplicate().limit(n * sizeof_struct_kevent));
+ //dump_selection_keys((ByteBuffer) events.duplicate().limit(n * _sizeof_struct_kevent));
// Commit the operations we've just added in the call to kevent.
for (Iterator it = keys.values().iterator(); it.hasNext(); )
@@ -280,8 +283,8 @@ public class KqueueSelectorImpl extends AbstractSelector
int x = 0;
for (int i = 0; i < n; i++)
{
- events.position(x).limit(x + sizeof_struct_kevent);
- x += sizeof_struct_kevent;
+ events.position(x).limit(x + _sizeof_struct_kevent);
+ x += _sizeof_struct_kevent;
int y = fetch_key(events.slice());
KqueueSelectionKeyImpl key =
(KqueueSelectionKeyImpl) keys.get(new Integer(y));
@@ -370,7 +373,7 @@ public class KqueueSelectorImpl extends AbstractSelector
{
synchronized (keys)
{
- if (events.capacity() < (2 * sizeof_struct_kevent) * keys.size())
+ if (events.capacity() < (2 * _sizeof_struct_kevent) * keys.size())
{
int cap = events.capacity();
if (cap >= MAX_DOUBLING_CAPACITY)
@@ -380,7 +383,7 @@ public class KqueueSelectorImpl extends AbstractSelector
events = ByteBuffer.allocateDirect(cap);
}
- else if (events.capacity() > 4 * (sizeof_struct_kevent) * keys.size() + 1
+ else if (events.capacity() > 4 * (_sizeof_struct_kevent) * keys.size() + 1
&& events.capacity() > INITIAL_CAPACITY)
{
int cap = events.capacity();
@@ -437,7 +440,7 @@ public class KqueueSelectorImpl extends AbstractSelector
/**
* Return the size of a <code>struct kevent</code> on this system.
- *
+ *
* @return The size of <code>struct kevent</code>.
*/
private static native int sizeof_struct_kevent();
diff --git a/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
index b7cd755f5..0863b1f1c 100644
--- a/gnu/javax/crypto/jce/cipher/CipherAdapter.java
+++ b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
@@ -373,14 +373,24 @@ class CipherAdapter
engineInit(opmode, key, spec, random);
}
- protected byte[] engineUpdate(byte[] input, int off, int len)
+ protected byte[] engineUpdate(byte[] input, int inOff, int inLen)
{
+ if (inLen == 0) // nothing to process
+ return new byte[0];
final int blockSize = mode.currentBlockSize();
- final int count = (partLen + len) / blockSize;
- final byte[] out = new byte[count * blockSize];
+ int blockCount = (partLen + inLen) / blockSize;
+
+ // always keep data for unpadding in padded decryption mode;
+ // might even be a complete block
+ if (pad != null
+ && ((Integer) attributes.get(IMode.STATE)).intValue() == IMode.DECRYPTION
+ && (partLen + inLen) % blockSize == 0)
+ blockCount--;
+
+ final byte[] out = new byte[blockCount * blockSize];
try
{
- engineUpdate(input, off, len, out, 0);
+ engineUpdate(input, inOff, inLen, out, 0);
}
catch (ShortBufferException x) // should not happen
{
@@ -395,7 +405,15 @@ class CipherAdapter
if (inLen == 0) // nothing to process
return 0;
final int blockSize = mode.currentBlockSize();
- final int blockCount = (partLen + inLen) / blockSize;
+ int blockCount = (partLen + inLen) / blockSize;
+
+ // always keep data for unpadding in padded decryption mode;
+ // might even be a complete block
+ if (pad != null
+ && ((Integer) attributes.get(IMode.STATE)).intValue() == IMode.DECRYPTION
+ && (partLen + inLen) % blockSize == 0)
+ blockCount--;
+
final int result = blockCount * blockSize;
if (result > out.length - outOff)
throw new ShortBufferException();
@@ -447,16 +465,21 @@ class CipherAdapter
break;
case IMode.DECRYPTION:
int padLen;
+ byte[] buf3 = new byte[buf.length + partLen];
try
{
- padLen = pad.unpad(buf, 0, buf.length);
+ if (partLen != mode.currentBlockSize())
+ throw new WrongPaddingException();
+ System.arraycopy(buf, 0, buf3, 0, buf.length);
+ mode.update(partBlock, 0, buf3, buf.length);
+ padLen = pad.unpad(buf3, 0, buf3.length);
}
catch (WrongPaddingException wpe)
{
throw new BadPaddingException(wpe.getMessage());
}
- result = new byte[buf.length - padLen];
- System.arraycopy(buf, 0, result, 0, result.length);
+ result = new byte[buf3.length - padLen];
+ System.arraycopy(buf3, 0, result, 0, result.length);
break;
default:
throw new IllegalStateException();
diff --git a/gnu/javax/crypto/pad/PKCS7.java b/gnu/javax/crypto/pad/PKCS7.java
index bef1784ee..8fce5b8b0 100644
--- a/gnu/javax/crypto/pad/PKCS7.java
+++ b/gnu/javax/crypto/pad/PKCS7.java
@@ -100,8 +100,8 @@ public final class PKCS7
throws WrongPaddingException
{
int limit = offset + length;
- int result = in[limit - 1] & 0xFF;
- for (int i = 0; i < result; i++)
+ int result = in[--limit] & 0xFF;
+ for (int i = 0; i < result - 1; i++)
if (result != (in[--limit] & 0xFF))
throw new WrongPaddingException();
if (Configuration.DEBUG)
diff --git a/gnu/xml/transform/TransformerImpl.java b/gnu/xml/transform/TransformerImpl.java
index 732a911bd..f43b6602f 100644
--- a/gnu/xml/transform/TransformerImpl.java
+++ b/gnu/xml/transform/TransformerImpl.java
@@ -327,7 +327,8 @@ class TransformerImpl
domDoc.setCheckWellformedness(false);
}
parent.normalize();
- strip(stylesheet, parent);
+ if (stylesheet != null)
+ strip(stylesheet, parent);
Document resultDoc = (parent instanceof Document) ?
(Document) parent :
parent.getOwnerDocument();
diff --git a/include/Makefile.am b/include/Makefile.am
index baa6fc0bd..b69b0ef73 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -125,7 +125,6 @@ $(XMLJ_H_FILES) \
$(GTKPEER_H_FILES) \
$(QTPEER_H_FILES) \
$(GCONF_PREFS_FILES) \
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
$(top_srcdir)/include/gnu_java_nio_EpollSelectorImpl.h \
@@ -180,8 +179,6 @@ $(top_srcdir)/include/gnu_javax_sound_midi_dssi_%.h: $(top_builddir)/$(CLASSDIR)
$(top_srcdir)/include/gnu_java_util_prefs_gconf_%.h: $(top_builddir)/$(CLASSDIR)/gnu/java/util/prefs/gconf/%.class
$(JAVAH) -o $@ gnu.java.util.prefs.gconf.$*
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
- $(JAVAH) -o $@ gnu.java.net.VMPlainDatagramSocketImpl
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainSocketImpl.java
$(JAVAH) -o $@ gnu.java.net.VMPlainSocketImpl
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h: $(top_srcdir)/gnu/java/net/local/LocalSocketImpl.java
diff --git a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
index 50912e8b5..f32b9381b 100644
--- a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
@@ -23,6 +23,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFillRu
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetLine (JNIEnv *env, jobject, jlong, jdouble, jint, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash (JNIEnv *env, jobject, jlong, jdoubleArray, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector (JNIEnv *env, jobject, jlong, jobject, jfloat, jfloat, jint, jintArray, jfloatArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFont (JNIEnv *env, jobject, jlong, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelCurveTo (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoArc (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jdouble);
@@ -43,6 +44,18 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoResetClip
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawLine (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFillRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_NEAREST
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_NEAREST 0L
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_BILINEAR
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_BILINEAR 1L
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_BICUBIC
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_INTERPOLATION_BICUBIC 5L
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_SPEED
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_SPEED 2L
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_QUALITY
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_QUALITY 3L
+#undef gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_DEFAULT
+#define gnu_java_awt_peer_gtk_CairoGraphics2D_ALPHA_INTERPOLATION_DEFAULT 4L
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
index 2095d421c..63b881d2f 100644
--- a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
@@ -16,6 +16,10 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth (
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkFixedSetVisible (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_maximize (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_unmaximize (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_iconify (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_deiconify (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage (JNIEnv *env, jobject, jobject);
#ifdef __cplusplus
diff --git a/include/gnu_java_net_VMPlainSocketImpl.h b/include/gnu_java_net_VMPlainSocketImpl.h
index b274ce0fb..ef3c3a467 100644
--- a/include/gnu_java_net_VMPlainSocketImpl.h
+++ b/include/gnu_java_net_VMPlainSocketImpl.h
@@ -1,152 +1,39 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_net_VMPlainSocketImpl__
+#define __gnu_java_net_VMPlainSocketImpl__
+
#include <jni.h>
-/* Header for class gnu_java_net_VMPlainSocketImpl */
-#ifndef _Included_gnu_java_net_VMPlainSocketImpl
-#define _Included_gnu_java_net_VMPlainSocketImpl
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: setOption
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setOption
- (JNIEnv *, jclass, jint, jint, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: getOption
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_net_VMPlainSocketImpl_getOption
- (JNIEnv *, jclass, jint, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: bind
- * Signature: (I[BI)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind
- (JNIEnv *, jclass, jint, jbyteArray, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: bind6
- * Signature: (I[BI)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind6
- (JNIEnv *, jclass, jint, jbyteArray, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: listen
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_listen
- (JNIEnv *, jclass, jint, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: join
- * Signature: (I[B)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join
- (JNIEnv *, jclass, jint, jbyteArray);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: join6
- * Signature: (I[B)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join6
- (JNIEnv *, jclass, jint, jbyteArray);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: leave
- * Signature: (I[B)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave
- (JNIEnv *, jclass, jint, jbyteArray);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: leave6
- * Signature: (I[B)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave6
- (JNIEnv *, jclass, jint, jbyteArray);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: joinGroup
- * Signature: (I[BLjava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup
- (JNIEnv *, jclass, jint, jbyteArray, jstring);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: joinGroup6
- * Signature: (I[BLjava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup6
- (JNIEnv *, jclass, jint, jbyteArray, jstring);
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: leaveGroup
- * Signature: (I[BLjava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup
- (JNIEnv *, jclass, jint, jbyteArray, jstring);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: leaveGroup6
- * Signature: (I[BLjava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6
- (JNIEnv *, jclass, jint, jbyteArray, jstring);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: shutdownInput
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownInput
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: shutdownOutput
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_net_VMPlainSocketImpl
- * Method: sendUrgentData
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_sendUrgentData
- (JNIEnv *, jclass, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env, jclass, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface (JNIEnv *env, jclass, jint, jint, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6 (JNIEnv *env, jclass, jint, jint, jstring);
+JNIEXPORT jint JNICALL Java_gnu_java_net_VMPlainSocketImpl_getOption (JNIEnv *env, jclass, jint, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface (JNIEnv *env, jclass, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind (JNIEnv *env, jclass, jint, jbyteArray, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind6 (JNIEnv *env, jclass, jint, jbyteArray, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_listen (JNIEnv *env, jclass, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join (JNIEnv *env, jclass, jint, jbyteArray);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join6 (JNIEnv *env, jclass, jint, jbyteArray);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave (JNIEnv *env, jclass, jint, jbyteArray);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave6 (JNIEnv *env, jclass, jint, jbyteArray);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup (JNIEnv *env, jclass, jint, jbyteArray, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup6 (JNIEnv *env, jclass, jint, jbyteArray, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup (JNIEnv *env, jclass, jint, jbyteArray, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6 (JNIEnv *env, jclass, jint, jbyteArray, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownInput (JNIEnv *env, jclass, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput (JNIEnv *env, jclass, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_sendUrgentData (JNIEnv *env, jclass, jint, jint);
+#undef gnu_java_net_VMPlainSocketImpl_CP_IP_TTL
+#define gnu_java_net_VMPlainSocketImpl_CP_IP_TTL 7777L
#ifdef __cplusplus
}
#endif
-#endif
-/* Header for class gnu_java_net_VMPlainSocketImpl_State */
-#ifndef _Included_gnu_java_net_VMPlainSocketImpl_State
-#define _Included_gnu_java_net_VMPlainSocketImpl_State
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
+#endif /* __gnu_java_net_VMPlainSocketImpl__ */
diff --git a/include/gnu_java_nio_EpollSelectorImpl.h b/include/gnu_java_nio_EpollSelectorImpl.h
index 188cdf9d5..0e43d1ce9 100644
--- a/include/gnu_java_nio_EpollSelectorImpl.h
+++ b/include/gnu_java_nio_EpollSelectorImpl.h
@@ -1,12 +1,24 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_nio_EpollSelectorImpl__
+#define __gnu_java_nio_EpollSelectorImpl__
+
#include <jni.h>
-/* Header for class gnu_java_nio_EpollSelectorImpl */
-#ifndef _Included_gnu_java_nio_EpollSelectorImpl
-#define _Included_gnu_java_nio_EpollSelectorImpl
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
+
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1supported (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_sizeof_1struct (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1create (JNIEnv *env, jclass, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1add (JNIEnv *env, jclass, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1modify (JNIEnv *env, jclass, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete (JNIEnv *env, jclass, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1wait (JNIEnv *env, jclass, jint, jobject, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1fd (JNIEnv *env, jclass, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1ops (JNIEnv *env, jclass, jobject);
#undef gnu_java_nio_EpollSelectorImpl_DEFAULT_EPOLL_SIZE
#define gnu_java_nio_EpollSelectorImpl_DEFAULT_EPOLL_SIZE 128L
#undef gnu_java_nio_EpollSelectorImpl_OP_ACCEPT
@@ -17,79 +29,9 @@ extern "C" {
#define gnu_java_nio_EpollSelectorImpl_OP_READ 1L
#undef gnu_java_nio_EpollSelectorImpl_OP_WRITE
#define gnu_java_nio_EpollSelectorImpl_OP_WRITE 4L
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_supported
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1supported
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: sizeof_struct
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_sizeof_1struct
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_create
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1create
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_add
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1add
- (JNIEnv *, jclass, jint, jint, jint);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_modify
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1modify
- (JNIEnv *, jclass, jint, jint, jint);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_delete
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete
- (JNIEnv *, jclass, jint, jint);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: epoll_wait
- * Signature: (ILjava/nio/ByteBuffer;II)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1wait
- (JNIEnv *, jclass, jint, jobject, jint, jint);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: selected_fd
- * Signature: (Ljava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1fd
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: gnu_java_nio_EpollSelectorImpl
- * Method: selected_ops
- * Signature: (Ljava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1ops
- (JNIEnv *, jclass, jobject);
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* __gnu_java_nio_EpollSelectorImpl__ */
diff --git a/include/gnu_java_nio_FileChannelImpl.h b/include/gnu_java_nio_FileChannelImpl.h
index ebf466ccc..43000114c 100644
--- a/include/gnu_java_nio_FileChannelImpl.h
+++ b/include/gnu_java_nio_FileChannelImpl.h
@@ -1,12 +1,15 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_nio_FileChannelImpl__
+#define __gnu_java_nio_FileChannelImpl__
+
#include <jni.h>
-/* Header for class gnu_java_nio_FileChannelImpl */
-#ifndef _Included_gnu_java_nio_FileChannelImpl
-#define _Included_gnu_java_nio_FileChannelImpl
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
+
#undef gnu_java_nio_FileChannelImpl_READ
#define gnu_java_nio_FileChannelImpl_READ 1L
#undef gnu_java_nio_FileChannelImpl_WRITE
@@ -19,7 +22,9 @@ extern "C" {
#define gnu_java_nio_FileChannelImpl_SYNC 16L
#undef gnu_java_nio_FileChannelImpl_DSYNC
#define gnu_java_nio_FileChannelImpl_DSYNC 32L
+
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* __gnu_java_nio_FileChannelImpl__ */
diff --git a/include/gnu_java_nio_KqueueSelectorImpl.h b/include/gnu_java_nio_KqueueSelectorImpl.h
index f9716f38c..acfdeaae7 100644
--- a/include/gnu_java_nio_KqueueSelectorImpl.h
+++ b/include/gnu_java_nio_KqueueSelectorImpl.h
@@ -1,12 +1,24 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_nio_KqueueSelectorImpl__
+#define __gnu_java_nio_KqueueSelectorImpl__
+
#include <jni.h>
-/* Header for class gnu_java_nio_KqueueSelectorImpl */
-#ifndef _Included_gnu_java_nio_KqueueSelectorImpl
-#define _Included_gnu_java_nio_KqueueSelectorImpl
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
+
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kqueue_1supported (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implOpen (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implClose (JNIEnv *env, jclass, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent_1set (JNIEnv *env, jclass, jobject, jint, jint, jint, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent (JNIEnv *env, jclass, jint, jobject, jint, jint, jlong);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_fetch_1key (JNIEnv *env, jclass, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_ready_1ops (JNIEnv *env, jclass, jobject, jint);
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_check_1eof (JNIEnv *env, jclass, jobject);
#undef gnu_java_nio_KqueueSelectorImpl_MAX_DOUBLING_CAPACITY
#define gnu_java_nio_KqueueSelectorImpl_MAX_DOUBLING_CAPACITY 16384L
#undef gnu_java_nio_KqueueSelectorImpl_CAP_INCREMENT
@@ -19,79 +31,9 @@ extern "C" {
#define gnu_java_nio_KqueueSelectorImpl_OP_READ 1L
#undef gnu_java_nio_KqueueSelectorImpl_OP_WRITE
#define gnu_java_nio_KqueueSelectorImpl_OP_WRITE 4L
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: kqueue_supported
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kqueue_1supported
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: sizeof_struct_kevent
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: implOpen
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implOpen
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: implClose
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implClose
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: kevent_set
- * Signature: (Ljava/nio/ByteBuffer;IIIII)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent_1set
- (JNIEnv *, jclass, jobject, jint, jint, jint, jint, jint);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: kevent
- * Signature: (ILjava/nio/ByteBuffer;IIJ)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent
- (JNIEnv *, jclass, jint, jobject, jint, jint, jlong);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: fetch_key
- * Signature: (Ljava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_fetch_1key
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: ready_ops
- * Signature: (Ljava/nio/ByteBuffer;I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_ready_1ops
- (JNIEnv *, jclass, jobject, jint);
-
-/*
- * Class: gnu_java_nio_KqueueSelectorImpl
- * Method: check_eof
- * Signature: (Ljava/nio/ByteBuffer;)Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_check_1eof
- (JNIEnv *, jclass, jobject);
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* __gnu_java_nio_KqueueSelectorImpl__ */
diff --git a/include/gnu_java_nio_VMChannel.h b/include/gnu_java_nio_VMChannel.h
index 969e3298a..dd023816c 100644
--- a/include/gnu_java_nio_VMChannel.h
+++ b/include/gnu_java_nio_VMChannel.h
@@ -1,291 +1,50 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class gnu_java_nio_VMChannel */
-
-#ifndef _Included_gnu_java_nio_VMChannel
-#define _Included_gnu_java_nio_VMChannel
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: stdin_fd
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdin_1fd
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: stdout_fd
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdout_1fd
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: stderr_fd
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stderr_1fd
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: setBlocking
- * Signature: (IZ)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_setBlocking
- (JNIEnv *, jclass, jint, jboolean);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: available
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_available
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: read
- * Signature: (ILjava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__ILjava_nio_ByteBuffer_2
- (JNIEnv *, jclass, jint, jobject);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: read
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__I
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: readScattering
- * Signature: (I[Ljava/nio/ByteBuffer;II)J
- */
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_readScattering
- (JNIEnv *, jclass, jint, jobjectArray, jint, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: receive
- * Signature: (ILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_receive
- (JNIEnv *, jclass, jint, jobject, jobject);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: write
- * Signature: (ILjava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_write__ILjava_nio_ByteBuffer_2
- (JNIEnv *, jobject, jint, jobject);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: writeGathering
- * Signature: (I[Ljava/nio/ByteBuffer;II)J
- */
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_writeGathering
- (JNIEnv *, jobject, jint, jobjectArray, jint, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: send
- * Signature: (ILjava/nio/ByteBuffer;[BI)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send
- (JNIEnv *, jclass, jint, jobject, jbyteArray, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: send6
- * Signature: (ILjava/nio/ByteBuffer;[BI)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send6
- (JNIEnv *, jclass, jint, jobject, jbyteArray, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: write
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_write__II
- (JNIEnv *, jclass, jint, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: initIDs
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_initIDs
- (JNIEnv *, jclass);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: socket
- * Signature: (Z)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_socket
- (JNIEnv *, jclass, jboolean);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: connect
- * Signature: (I[BII)Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect
- (JNIEnv *, jclass, jint, jbyteArray, jint, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: connect6
- * Signature: (I[BII)Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect6
- (JNIEnv *, jclass, jint, jbyteArray, jint, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: disconnect
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_disconnect
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: getsockname
- * Signature: (ILjava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getsockname
- (JNIEnv *, jclass, jint, jobject);
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: getpeername
- * Signature: (ILjava/nio/ByteBuffer;)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getpeername
- (JNIEnv *, jclass, jint, jobject);
+#ifndef __gnu_java_nio_VMChannel__
+#define __gnu_java_nio_VMChannel__
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: accept
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_accept
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: open
- * Signature: (Ljava/lang/String;I)I
- */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_open
- (JNIEnv *, jclass, jstring, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: position
- * Signature: (I)J
- */
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_position
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: seek
- * Signature: (IJ)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_seek
- (JNIEnv *, jclass, jint, jlong);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: truncate
- * Signature: (IJ)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_truncate
- (JNIEnv *, jclass, jint, jlong);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: lock
- * Signature: (IJJZZ)Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_lock
- (JNIEnv *, jclass, jint, jlong, jlong, jboolean, jboolean);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: unlock
- * Signature: (IJJ)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_unlock
- (JNIEnv *, jclass, jint, jlong, jlong);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: size
- * Signature: (I)J
- */
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_size
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: map
- * Signature: (ICJI)Ljava/nio/MappedByteBuffer;
- */
-JNIEXPORT jobject JNICALL Java_gnu_java_nio_VMChannel_map
- (JNIEnv *, jclass, jint, jchar, jlong, jint);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: flush
- * Signature: (IZ)Z
- */
-JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_flush
- (JNIEnv *, jclass, jint, jboolean);
-
-/*
- * Class: gnu_java_nio_VMChannel
- * Method: close
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_close
- (JNIEnv *, jclass, jint);
+#include <jni.h>
#ifdef __cplusplus
-}
-#endif
-#endif
-/* Header for class gnu_java_nio_VMChannel_State */
+extern "C"
+{
+#endif
+
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdin_1fd (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdout_1fd (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stderr_1fd (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env, jclass, jint, jboolean);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_available (JNIEnv *env, jclass, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__ILjava_nio_ByteBuffer_2 (JNIEnv *env, jclass, jint, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__I (JNIEnv *env, jclass, jint);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env, jclass, jint, jobjectArray, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_receive (JNIEnv *env, jclass, jint, jobject, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_write__ILjava_nio_ByteBuffer_2 (JNIEnv *env, jobject, jint, jobject);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env, jobject, jint, jobjectArray, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send (JNIEnv *env, jclass, jint, jobject, jbyteArray, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send6 (JNIEnv *env, jclass, jint, jobject, jbyteArray, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_write__II (JNIEnv *env, jclass, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_socket (JNIEnv *env, jclass, jboolean);
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass, jint, jbyteArray, jint, jint);
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass, jint, jbyteArray, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_disconnect (JNIEnv *env, jclass, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getsockname (JNIEnv *env, jclass, jint, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getpeername (JNIEnv *env, jclass, jint, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_accept (JNIEnv *env, jclass, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_open (JNIEnv *env, jclass, jstring, jint);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_position (JNIEnv *env, jclass, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_seek (JNIEnv *env, jclass, jint, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_truncate (JNIEnv *env, jclass, jint, jlong);
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_lock (JNIEnv *env, jclass, jint, jlong, jlong, jboolean, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_unlock (JNIEnv *env, jclass, jint, jlong, jlong);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_size (JNIEnv *env, jclass, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_nio_VMChannel_map (JNIEnv *env, jclass, jint, jchar, jlong, jint);
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_flush (JNIEnv *env, jclass, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_close (JNIEnv *env, jclass, jint);
-#ifndef _Included_gnu_java_nio_VMChannel_State
-#define _Included_gnu_java_nio_VMChannel_State
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifdef __cplusplus
}
#endif
-#endif
-/* Header for class gnu_java_nio_VMChannel_Kind */
-#ifndef _Included_gnu_java_nio_VMChannel_Kind
-#define _Included_gnu_java_nio_VMChannel_Kind
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
+#endif /* __gnu_java_nio_VMChannel__ */
diff --git a/include/gnu_java_nio_VMPipe.h b/include/gnu_java_nio_VMPipe.h
index 06d8001b7..2088e55dc 100644
--- a/include/gnu_java_nio_VMPipe.h
+++ b/include/gnu_java_nio_VMPipe.h
@@ -1,21 +1,19 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_nio_VMPipe__
+#define __gnu_java_nio_VMPipe__
+
#include <jni.h>
-/* Header for class gnu_java_nio_VMPipe */
-#ifndef _Included_gnu_java_nio_VMPipe
-#define _Included_gnu_java_nio_VMPipe
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/*
- * Class: gnu_java_nio_VMPipe
- * Method: pipe0
- * Signature: ()[I
- */
-JNIEXPORT jintArray JNICALL Java_gnu_java_nio_VMPipe_pipe0
- (JNIEnv *, jclass);
+
+JNIEXPORT jintArray JNICALL Java_gnu_java_nio_VMPipe_pipe0 (JNIEnv *env, jclass);
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* __gnu_java_nio_VMPipe__ */
diff --git a/include/java_net_VMNetworkInterface.h b/include/java_net_VMNetworkInterface.h
index 4d5192d28..b53bda565 100644
--- a/include/java_net_VMNetworkInterface.h
+++ b/include/java_net_VMNetworkInterface.h
@@ -1,29 +1,20 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __java_net_VMNetworkInterface__
+#define __java_net_VMNetworkInterface__
+
#include <jni.h>
-/* Header for class java_net_VMNetworkInterface */
-#ifndef _Included_java_net_VMNetworkInterface
-#define _Included_java_net_VMNetworkInterface
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/*
- * Class: java_net_VMNetworkInterface
- * Method: initIds
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_net_VMNetworkInterface_initIds
- (JNIEnv *, jclass);
-/*
- * Class: java_net_VMNetworkInterface
- * Method: getVMInterfaces
- * Signature: ()[Ljava/net/VMNetworkInterface;
- */
-JNIEXPORT jobjectArray JNICALL Java_java_net_VMNetworkInterface_getVMInterfaces
- (JNIEnv *, jclass);
+JNIEXPORT void JNICALL Java_java_net_VMNetworkInterface_initIds (JNIEnv *env, jclass);
+JNIEXPORT jobjectArray JNICALL Java_java_net_VMNetworkInterface_getVMInterfaces (JNIEnv *env, jclass);
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* __java_net_VMNetworkInterface__ */
diff --git a/java/awt/CardLayout.java b/java/awt/CardLayout.java
index 7b733c821..2e3feece8 100644
--- a/java/awt/CardLayout.java
+++ b/java/awt/CardLayout.java
@@ -225,6 +225,8 @@ public class CardLayout implements LayoutManager2, Serializable
*/
public Dimension maximumLayoutSize (Container target)
{
+ if (target == null)
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
// The JCL says that this returns Integer.MAX_VALUE for both
// dimensions. But that just seems wrong to me.
return getSize (target, MAX);
@@ -423,7 +425,10 @@ public class CardLayout implements LayoutManager2, Serializable
if (choice >= 0)
break;
- }
+ } else
+ {
+ comps[i].setVisible(true);
+ }
}
if (choice >= 0 && choice < num)
diff --git a/java/awt/Component.java b/java/awt/Component.java
index 7688e2618..82c81c7a0 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -41,6 +41,8 @@ package java.awt;
//import gnu.java.awt.dnd.peer.gtk.GtkDropTargetContextPeer;
+import gnu.java.awt.ComponentReshapeEvent;
+
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.AdjustmentEvent;
@@ -5699,6 +5701,21 @@ p * <li>the set of backward traversal keys
*/
void dispatchEventImpl(AWTEvent e)
{
+ // Update the component's knowledge about the size.
+ // Important: Please look at the big comment in ComponentReshapeEvent
+ // to learn why we did it this way. If you change this code, make
+ // sure that the peer->AWT bounds update still works.
+ // (for instance: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29448 )
+ if (e instanceof ComponentReshapeEvent)
+ {
+ ComponentReshapeEvent reshape = (ComponentReshapeEvent) e;
+ x = reshape.x;
+ y = reshape.y;
+ width = reshape.width;
+ height = reshape.height;
+ return;
+ }
+
// Retarget focus events before dispatching it to the KeyboardFocusManager
// in order to handle lightweight components properly.
boolean dispatched = false;
diff --git a/java/awt/Container.java b/java/awt/Container.java
index 3d460baaf..83d9f7b78 100644
--- a/java/awt/Container.java
+++ b/java/awt/Container.java
@@ -43,6 +43,7 @@ import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
@@ -606,11 +607,20 @@ public class Container extends Component
*/
public void validate()
{
- synchronized (getTreeLock ())
+ ComponentPeer p = peer;
+ if (! valid && p != null)
{
- if (! isValid() && peer != null)
+ ContainerPeer cPeer = null;
+ if (p instanceof ContainerPeer)
+ cPeer = (ContainerPeer) peer;
+ synchronized (getTreeLock ())
{
+ if (cPeer != null)
+ cPeer.beginValidate();
validateTree();
+ valid = true;
+ if (cPeer != null)
+ cPeer.endValidate();
}
}
}
@@ -641,36 +651,36 @@ public class Container extends Component
*/
protected void validateTree()
{
- if (valid)
- return;
-
- ContainerPeer cPeer = null;
- if (peer instanceof ContainerPeer)
- {
- cPeer = (ContainerPeer) peer;
- cPeer.beginValidate();
- }
-
- doLayout ();
- for (int i = 0; i < ncomponents; ++i)
+ if (!valid)
{
- Component comp = component[i];
-
- if (comp instanceof Container && ! (comp instanceof Window)
- && ! comp.valid)
+ ContainerPeer cPeer = null;
+ if (peer instanceof ContainerPeer)
{
- ((Container) comp).validateTree();
+ cPeer = (ContainerPeer) peer;
+ cPeer.beginLayout();
}
- else
+
+ doLayout ();
+ for (int i = 0; i < ncomponents; ++i)
{
- comp.validate();
+ Component comp = component[i];
+
+ if (comp instanceof Container && ! (comp instanceof Window)
+ && ! comp.valid)
+ {
+ ((Container) comp).validateTree();
+ }
+ else
+ {
+ comp.validate();
+ }
}
- }
- if (peer instanceof ContainerPeer)
- {
- cPeer = (ContainerPeer) peer;
- cPeer.endValidate();
+ if (cPeer != null)
+ {
+ cPeer = (ContainerPeer) peer;
+ cPeer.endLayout();
+ }
}
/* children will call invalidate() when they are layed out. It
diff --git a/java/awt/Dialog.java b/java/awt/Dialog.java
index 55c3371e6..7df2f523c 100644
--- a/java/awt/Dialog.java
+++ b/java/awt/Dialog.java
@@ -97,6 +97,11 @@ public class Dialog extends Window
private EventQueue eq2 = null;
/**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_dialog_number;
+
+ /**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is resizable and not modal, and which has no title.
*
@@ -190,6 +195,7 @@ public class Dialog extends Window
visible = false;
setLayout(new BorderLayout());
+ setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
/**
@@ -273,6 +279,7 @@ public class Dialog extends Window
visible = false;
setLayout(new BorderLayout());
+ setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
/**
@@ -530,5 +537,19 @@ public class Dialog extends Window
accessibleContext = new AccessibleAWTDialog();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>Dialog</code>.
+ *
+ * @return A unique name for this <code>Dialog</code>.
+ */
+ String generateName()
+ {
+ return "dialog" + getUniqueLong();
+ }
+ private static synchronized long getUniqueLong()
+ {
+ return next_dialog_number++;
+ }
}
diff --git a/java/awt/EventQueue.java b/java/awt/EventQueue.java
index e1f109098..0b6e03efa 100644
--- a/java/awt/EventQueue.java
+++ b/java/awt/EventQueue.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import gnu.java.awt.LowPriorityEvent;
+import gnu.java.awt.peer.NativeEventLoopRunningEvent;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
@@ -114,31 +115,25 @@ public class EventQueue
private long lastWhen = System.currentTimeMillis();
private EventDispatchThread dispatchThread = new EventDispatchThread(this);
- private boolean shutdown = false;
+ private boolean nativeLoopRunning = false;
- synchronized private void setShutdown (boolean b)
+ private boolean isShutdown ()
{
- shutdown = b;
- }
-
- synchronized boolean isShutdown ()
- {
- if (shutdown)
- return true;
-
// This is the exact self-shutdown condition specified in J2SE:
// http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html
-
- // FIXME: check somewhere that the native queue is empty
- if (peekEvent() == null)
- {
- Frame[] frames = Frame.getFrames();
- for (int i = 0; i < frames.length; ++i)
- if (frames[i].isDisplayable())
- return false;
- return true;
- }
- return false;
+
+ if (nativeLoopRunning)
+ return false;
+
+ if (peekEvent() != null)
+ return false;
+
+ Frame[] frames = Frame.getFrames();
+ for (int i = 0; i < frames.length; ++i)
+ if (frames[i].isDisplayable())
+ return false;
+
+ return true;
}
/**
@@ -167,19 +162,23 @@ public class EventQueue
return next.getNextEvent();
AWTEvent res = getNextEventImpl(true);
+
while (res == null)
{
- // We are not allowed to return null from this method, yet it
- // is possible that we actually have run out of native events
- // in the enclosing while() loop, and none of the native events
- // happened to cause AWT events. We therefore ought to check
- // the isShutdown() condition here, before risking a "native
- // wait". If we check it before entering this function we may
- // wait forever for events after the shutdown condition has
- // arisen.
-
if (isShutdown())
- throw new InterruptedException();
+ {
+ // Explicitly set dispathThread to null. If we don't do
+ // this, there is a race condition where dispatchThread
+ // can be != null even after the event dispatch thread has
+ // stopped running. If that happens, then the
+ // dispatchThread == null check in postEventImpl will
+ // fail, and a new event dispatch thread will not be
+ // created, leaving invokeAndWaits waiting indefinitely.
+ dispatchThread = null;
+
+ // Interrupt the event dispatch thread.
+ throw new InterruptedException();
+ }
wait();
res = getNextEventImpl(true);
@@ -296,6 +295,12 @@ public class EventQueue
priority = LOW_PRIORITY;
// TODO: Maybe let Swing RepaintManager events also be processed with
// low priority.
+ if (evt instanceof NativeEventLoopRunningEvent)
+ {
+ nativeLoopRunning = ((NativeEventLoopRunningEvent) evt).isRunning();
+ notify();
+ return;
+ }
postEventImpl(evt, priority);
}
@@ -576,11 +581,11 @@ public class EventQueue
ex.printStackTrace();
}
}
-
prev = null;
- setShutdown(true);
+ // Tell our EventDispatchThread that it can end
+ // execution.
+ dispatchThread.interrupt();
dispatchThread = null;
- this.notifyAll();
}
}
}
diff --git a/java/awt/FileDialog.java b/java/awt/FileDialog.java
index f02d06be2..21117700d 100644
--- a/java/awt/FileDialog.java
+++ b/java/awt/FileDialog.java
@@ -95,6 +95,11 @@ private FilenameFilter filter;
*/
private int mode;
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_file_dialog_number;
+
/*************************************************************************/
/*
@@ -300,7 +305,11 @@ getFile()
public synchronized void
setFile(String file)
{
- this.file = file;
+ if ("".equals(file))
+ this.file = null;
+ else
+ this.file = file;
+
if (peer != null)
{
FileDialogPeer f = (FileDialogPeer) peer;
@@ -366,5 +375,22 @@ paramString()
",mode=" + mode + "," + super.paramString());
}
+/**
+ * Generate a unique name for this <code>FileDialog</code>.
+ *
+ * @return A unique name for this <code>FileDialog</code>.
+ */
+String
+generateName()
+{
+ return "filedlg" + getUniqueLong();
+}
+
+private static synchronized long
+getUniqueLong()
+{
+ return next_file_dialog_number++;
+}
+
} // class FileDialog
diff --git a/java/awt/Frame.java b/java/awt/Frame.java
index e0c0d1ff3..d5cc7f531 100644
--- a/java/awt/Frame.java
+++ b/java/awt/Frame.java
@@ -488,7 +488,10 @@ public class Frame extends Window implements MenuContainer
private static void noteFrame(Frame f)
{
- weakFrames.add(new WeakReference(f));
+ synchronized (weakFrames)
+ {
+ weakFrames.add(new WeakReference(f));
+ }
}
public static Frame[] getFrames()
@@ -536,8 +539,7 @@ public class Frame extends Window implements MenuContainer
public int getState()
{
- // FIXME: State might have changed in the peer... Must check.
- return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
+ return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
}
/**
@@ -545,7 +547,13 @@ public class Frame extends Window implements MenuContainer
*/
public void setExtendedState(int state)
{
- this.state = state;
+ if (getToolkit().isFrameStateSupported(state))
+ {
+ this.state = state;
+ FramePeer p = (FramePeer) peer;
+ if (p != null)
+ p.setState(state);
+ }
}
/**
@@ -553,6 +561,9 @@ public class Frame extends Window implements MenuContainer
*/
public int getExtendedState()
{
+ FramePeer p = (FramePeer) peer;
+ if (p != null)
+ state = p.getState();
return state;
}
diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java
index 4360f592d..04196bd77 100644
--- a/java/awt/LightweightDispatcher.java
+++ b/java/awt/LightweightDispatcher.java
@@ -160,6 +160,8 @@ final class LightweightDispatcher
if (isDragging(ev))
redispatch(ev, mouseEventTarget, id);
break;
+ case MouseEvent.MOUSE_WHEEL:
+ redispatch(ev, mouseEventTarget, id);
}
ev.consume();
}
@@ -314,7 +316,7 @@ final class LightweightDispatcher
retargeted = new MouseEvent(target, id, ev.getWhen(),
ev.getModifiers() | ev.getModifiersEx(),
x, y, ev.getClickCount(),
- ev.isPopupTrigger());
+ ev.isPopupTrigger(), ev.getButton());
}
if (target == source)
diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java
index 65ce484b8..6d7994dab 100644
--- a/java/awt/ScrollPane.java
+++ b/java/awt/ScrollPane.java
@@ -393,7 +393,7 @@ setScrollPosition(int x, int y)
h.setValue(x);
if (v != null)
v.setValue(y);
-
+
ScrollPanePeer spp = (ScrollPanePeer)getPeer();
if (spp != null)
spp.setScrollPosition(x, y);
@@ -453,7 +453,7 @@ removeNotify()
if ((list != null) && (list.length > 0))
remove(list[0]);
- super.addImpl(component, constraints, -1);
+ super.addImpl(component, constraints, index);
doLayout();
}
@@ -518,11 +518,12 @@ layout()
* not have layout managers.
*
* @param layoutManager Ignored
+ * @throws AWTError Always throws this error when called.
*/
public final void
setLayout(LayoutManager layoutManager)
{
- return;
+ throw new AWTError("ScrollPane controls layout");
}
/*************************************************************************/
@@ -553,16 +554,37 @@ paramString()
+ getX() + ","
+ getY() + ","
+ getWidth() + "x" + getHeight() + ","
- + "ScrollPosition=(" + scrollPosition.getX() + ","
- + scrollPosition.getY() + "),"
+ + getIsValidString() + ","
+ + "ScrollPosition=(" + scrollPosition.x + ","
+ + scrollPosition.y + "),"
+ "Insets=(" + insets.top + ","
+ insets.left + ","
+ insets.bottom + ","
+ insets.right + "),"
- + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + ","
+ + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicyString() + ","
+ "wheelScrollingEnabled=" + isWheelScrollingEnabled();
}
+private String
+getScrollbarDisplayPolicyString()
+{
+ if (getScrollbarDisplayPolicy() == 0)
+ return "as-needed";
+ else if (getScrollbarDisplayPolicy() == 1)
+ return "always";
+ else
+ return "never";
+}
+
+private String
+getIsValidString()
+{
+ if (isValid())
+ return "valid";
+ else
+ return "invalid";
+}
+
/**
* Tells whether or not an event is enabled.
*
diff --git a/java/awt/ScrollPaneAdjustable.java b/java/awt/ScrollPaneAdjustable.java
index 21b58c36e..6ce79b1f6 100644
--- a/java/awt/ScrollPaneAdjustable.java
+++ b/java/awt/ScrollPaneAdjustable.java
@@ -145,14 +145,26 @@ public class ScrollPaneAdjustable
this.blockIncrement = blockIncrement;
}
- public void setMaximum (int maximum)
+ /**
+ * This method should never be called.
+ *
+ * @param maximum The maximum value to be set.
+ * @throws AWTError Always throws this error when called.
+ */
+ public void setMaximum (int maximum) throws AWTError
{
- this.maximum = maximum;
+ throw new AWTError("Can be set by scrollpane only");
}
+ /**
+ * This method should never be called.
+ *
+ * @param minimum The minimum value to be set.
+ * @throws AWTError Always throws this error when called.
+ */
public void setMinimum (int minimum)
{
- this.minimum = minimum;
+ throw new AWTError("Can be set by scrollpane only");
}
public void setUnitIncrement (int unitIncrement)
@@ -171,9 +183,15 @@ public class ScrollPaneAdjustable
maximum = value;
}
+ /**
+ * This method should never be called.
+ *
+ * @param visibleAmount The visible amount to be set.
+ * @throws AWTError Always throws this error when called.
+ */
public void setVisibleAmount (int visibleAmount)
{
- this.visibleAmount = visibleAmount;
+ throw new AWTError("Can be set by scrollpane only");
}
public String paramString ()
diff --git a/java/awt/Scrollbar.java b/java/awt/Scrollbar.java
index ef8d6d59e..0cba512f6 100644
--- a/java/awt/Scrollbar.java
+++ b/java/awt/Scrollbar.java
@@ -341,17 +341,22 @@ public class Scrollbar extends Component implements Accessible, Adjustable
public synchronized void setValues(int value, int visibleAmount,
int minimum, int maximum)
{
- if (maximum < minimum)
- maximum = minimum;
+ if (visibleAmount <= 0)
+ visibleAmount = 1;
+
+ if (maximum <= minimum)
+ maximum = minimum + 1;
if (value < minimum)
value = minimum;
- if (value > maximum)
- value = maximum;
-
if (visibleAmount > maximum - minimum)
visibleAmount = maximum - minimum;
+
+ // According to documentation, the actual maximum
+ // value is (maximum - visibleAmount)
+ if (value > maximum - visibleAmount)
+ value = maximum - visibleAmount;
ScrollbarPeer peer = (ScrollbarPeer) getPeer();
if (peer != null
@@ -362,30 +367,7 @@ public class Scrollbar extends Component implements Accessible, Adjustable
this.value = value;
this.visibleAmount = visibleAmount;
this.minimum = minimum;
- this.maximum = maximum;
-
- int range = maximum - minimum;
- if (lineIncrement > range)
- {
- if (range == 0)
- lineIncrement = 1;
- else
- lineIncrement = range;
-
- if (peer != null)
- peer.setLineIncrement(lineIncrement);
- }
-
- if (pageIncrement > range)
- {
- if (range == 0)
- pageIncrement = 1;
- else
- pageIncrement = range;
-
- if (peer != null)
- peer.setPageIncrement(pageIncrement);
- }
+ this.maximum = maximum;
}
/**
@@ -437,19 +419,13 @@ public class Scrollbar extends Component implements Accessible, Adjustable
{
if (lineIncrement < 0)
throw new IllegalArgumentException("Unit increment less than zero.");
-
- int range = maximum - minimum;
- if (lineIncrement > range)
- {
- if (range == 0)
- lineIncrement = 1;
- else
- lineIncrement = range;
- }
-
- if (lineIncrement == this.lineIncrement)
+
+ if (lineIncrement == 0)
+ lineIncrement = 1;
+
+ if (lineIncrement == this.lineIncrement)
return;
-
+
this.lineIncrement = lineIncrement;
ScrollbarPeer peer = (ScrollbarPeer) getPeer();
@@ -507,15 +483,9 @@ public class Scrollbar extends Component implements Accessible, Adjustable
if (pageIncrement < 0)
throw new IllegalArgumentException("Block increment less than zero.");
- int range = maximum - minimum;
- if (pageIncrement > range)
- {
- if (range == 0)
- pageIncrement = 1;
- else
- pageIncrement = range;
- }
-
+ if (pageIncrement == 0)
+ pageIncrement = 1;
+
if (pageIncrement == this.pageIncrement)
return;
diff --git a/java/awt/Toolkit.java b/java/awt/Toolkit.java
index d2c5f390e..9eb4da216 100644
--- a/java/awt/Toolkit.java
+++ b/java/awt/Toolkit.java
@@ -550,7 +550,7 @@ public abstract class Toolkit
*
* @throws AWTError If the toolkit cannot be loaded.
*/
- public static Toolkit getDefaultToolkit()
+ public static synchronized Toolkit getDefaultToolkit()
{
if (toolkit != null)
return toolkit;
diff --git a/java/awt/Window.java b/java/awt/Window.java
index 7a3092f81..41dff5577 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -362,15 +362,15 @@ public class Window extends Container implements Accessible
component[i].removeNotify();
this.removeNotify();
- // Post WINDOW_CLOSED from here.
- if (windowListener != null
- || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
- {
- WindowEvent ev = new WindowEvent(this,
- WindowEvent.WINDOW_OPENED);
- Toolkit tk = Toolkit.getDefaultToolkit();
- tk.getSystemEventQueue().postEvent(ev);
- }
+ // Post WINDOW_CLOSED from here.
+ if (windowListener != null
+ || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ {
+ WindowEvent ev = new WindowEvent(this,
+ WindowEvent.WINDOW_CLOSED);
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ tk.getSystemEventQueue().postEvent(ev);
+ }
}
}
@@ -498,7 +498,11 @@ public class Window extends Container implements Accessible
*/
public synchronized void addWindowListener(WindowListener listener)
{
- windowListener = AWTEventMulticaster.add(windowListener, listener);
+ if (listener != null)
+ {
+ newEventsOnly = true;
+ windowListener = AWTEventMulticaster.add(windowListener, listener);
+ }
}
/**
@@ -555,7 +559,12 @@ public class Window extends Container implements Accessible
*/
public void addWindowFocusListener (WindowFocusListener wfl)
{
- windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
+ if (wfl != null)
+ {
+ newEventsOnly = true;
+ windowFocusListener = AWTEventMulticaster.add (windowFocusListener,
+ wfl);
+ }
}
/**
@@ -565,7 +574,12 @@ public class Window extends Container implements Accessible
*/
public void addWindowStateListener (WindowStateListener wsl)
{
- windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
+ if (wsl != null)
+ {
+ newEventsOnly = true;
+ windowStateListener = AWTEventMulticaster.add (windowStateListener,
+ wsl);
+ }
}
/**
@@ -624,7 +638,28 @@ public class Window extends Container implements Accessible
protected void processEvent(AWTEvent evt)
{
if (evt instanceof WindowEvent)
- processWindowEvent((WindowEvent) evt);
+ {
+ WindowEvent we = (WindowEvent) evt;
+ switch (evt.getID())
+ {
+ case WindowEvent.WINDOW_OPENED:
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_CLOSING:
+ case WindowEvent.WINDOW_ICONIFIED:
+ case WindowEvent.WINDOW_DEICONIFIED:
+ case WindowEvent.WINDOW_ACTIVATED:
+ case WindowEvent.WINDOW_DEACTIVATED:
+ processWindowEvent(we);
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ processWindowFocusEvent(we);
+ break;
+ case WindowEvent.WINDOW_STATE_CHANGED:
+ processWindowStateEvent(we);
+ break;
+ }
+ }
else
super.processEvent(evt);
}
@@ -639,54 +674,35 @@ public class Window extends Container implements Accessible
*/
protected void processWindowEvent(WindowEvent evt)
{
- int id = evt.getID();
-
- if (id == WindowEvent.WINDOW_GAINED_FOCUS
- || id == WindowEvent.WINDOW_LOST_FOCUS)
- processWindowFocusEvent (evt);
- else if (id == WindowEvent.WINDOW_STATE_CHANGED)
- processWindowStateEvent (evt);
- else
+ if (windowListener != null)
{
- if (windowListener != null)
- {
- switch (evt.getID())
- {
- case WindowEvent.WINDOW_ACTIVATED:
- windowListener.windowActivated(evt);
- break;
-
- case WindowEvent.WINDOW_CLOSED:
- windowListener.windowClosed(evt);
- break;
-
- case WindowEvent.WINDOW_CLOSING:
- windowListener.windowClosing(evt);
- break;
-
- case WindowEvent.WINDOW_DEACTIVATED:
- windowListener.windowDeactivated(evt);
- break;
-
- case WindowEvent.WINDOW_DEICONIFIED:
- windowListener.windowDeiconified(evt);
- break;
-
- case WindowEvent.WINDOW_ICONIFIED:
- windowListener.windowIconified(evt);
- break;
-
- case WindowEvent.WINDOW_OPENED:
- windowListener.windowOpened(evt);
- break;
-
- default:
- break;
- }
- }
+ switch (evt.getID())
+ {
+ case WindowEvent.WINDOW_ACTIVATED:
+ windowListener.windowActivated(evt);
+ break;
+ case WindowEvent.WINDOW_CLOSED:
+ windowListener.windowClosed(evt);
+ break;
+ case WindowEvent.WINDOW_CLOSING:
+ windowListener.windowClosing(evt);
+ break;
+ case WindowEvent.WINDOW_DEACTIVATED:
+ windowListener.windowDeactivated(evt);
+ break;
+ case WindowEvent.WINDOW_DEICONIFIED:
+ windowListener.windowDeiconified(evt);
+ break;
+ case WindowEvent.WINDOW_ICONIFIED:
+ windowListener.windowIconified(evt);
+ break;
+ case WindowEvent.WINDOW_OPENED:
+ windowListener.windowOpened(evt);
+ break;
+ }
}
}
-
+
/**
* Identifies if this window is active. The active window is a Frame or
* Dialog that has focus or owns the active window.
@@ -1231,6 +1247,42 @@ public class Window extends Container implements Accessible
return "win" + getUniqueLong();
}
+ /**
+ * Overridden to handle WindowEvents.
+ *
+ * @return <code>true</code> when the specified event type is enabled,
+ * <code>false</code> otherwise
+ */
+ boolean eventTypeEnabled(int type)
+ {
+ boolean enabled = false;
+ switch (type)
+ {
+ case WindowEvent.WINDOW_OPENED:
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_CLOSING:
+ case WindowEvent.WINDOW_ICONIFIED:
+ case WindowEvent.WINDOW_DEICONIFIED:
+ case WindowEvent.WINDOW_ACTIVATED:
+ case WindowEvent.WINDOW_DEACTIVATED:
+ enabled = ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ || windowListener != null;
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ enabled = ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0)
+ || windowFocusListener != null;
+ break;
+ case WindowEvent.WINDOW_STATE_CHANGED:
+ enabled = ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0)
+ || windowStateListener != null;
+ break;
+ default:
+ enabled = super.eventTypeEnabled(type);
+ }
+ return enabled;
+ }
+
private static synchronized long getUniqueLong()
{
return next_window_number++;
diff --git a/java/awt/datatransfer/DataFlavor.java b/java/awt/datatransfer/DataFlavor.java
index 63a00db13..d31c7065f 100644
--- a/java/awt/datatransfer/DataFlavor.java
+++ b/java/awt/datatransfer/DataFlavor.java
@@ -338,8 +338,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
// Do some simple validity checks
String type = getPrimaryType() + "/" + getSubType();
- if (type.indexOf(' ') != -1
- || type.indexOf('=') != -1
+ if (type.indexOf('=') != -1
|| type.indexOf(';') != -1)
throw new IllegalArgumentException(mimeType);
diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java
index 435e21f30..0fe4c0f73 100644
--- a/java/awt/font/TextLayout.java
+++ b/java/awt/font/TextLayout.java
@@ -88,6 +88,12 @@ public final class TextLayout implements Cloneable
private boolean hasWhitespace = false;
/**
+ * The {@link Bidi} object that is used for reordering and by
+ * {@link #getCharacterLevel(int)}.
+ */
+ private Bidi bidi;
+
+ /**
* The default caret policy.
*/
public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy();
@@ -107,7 +113,7 @@ public final class TextLayout implements Cloneable
if( Bidi.requiresBidi( string.toCharArray(), 0, string.length() ) )
{
- Bidi bidi = new Bidi( string, leftToRight ?
+ bidi = new Bidi( string, leftToRight ?
Bidi.DIRECTION_LEFT_TO_RIGHT :
Bidi.DIRECTION_RIGHT_TO_LEFT );
int rc = bidi.getRunCount();
@@ -436,9 +442,10 @@ public final class TextLayout implements Cloneable
}
public byte getCharacterLevel (int index)
- throws NotImplementedException
{
- throw new Error ("not implemented");
+ if( bidi == null )
+ return (byte)( leftToRight ? 0 : 1 );
+ return (byte)bidi.getLevelAt( index );
}
public float getDescent ()
diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java
index 0a78bf223..ef3141d0e 100644
--- a/java/awt/image/BufferedImage.java
+++ b/java/awt/image/BufferedImage.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt.image;
+import gnu.java.awt.Buffers;
import gnu.java.awt.ComponentDataBlitOp;
import java.awt.Graphics;
@@ -129,12 +130,12 @@ public class BufferedImage extends Image
* <li>{@link #TYPE_BYTE_INDEXED}</li>
* </ul>
*
- * @param w the width (must be > 0).
- * @param h the height (must be > 0).
+ * @param width the width (must be > 0).
+ * @param height the height (must be > 0).
* @param type the image type (see the list of valid types above).
*
- * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is
- * less than or equal to zero.
+ * @throws IllegalArgumentException if <code>width</code> or
+ * <code>height</code> is less than or equal to zero.
* @throws IllegalArgumentException if <code>type</code> is not one of the
* specified values.
*/
@@ -161,8 +162,11 @@ public class BufferedImage extends Image
width, height,
3, width * 3,
new int[]{ 2, 1, 0 } );
- cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 );
- break;
+ cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ false, false,
+ BufferedImage.OPAQUE,
+ DataBuffer.TYPE_BYTE);
+ break;
case BufferedImage.TYPE_INT_ARGB:
case BufferedImage.TYPE_INT_ARGB_PRE:
@@ -172,18 +176,25 @@ public class BufferedImage extends Image
0x0000FF00,
0x000000FF,
0xFF000000 } );
- cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 );
+ if (premultiplied)
+ cm = new DirectColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ 32, 0xff0000, 0xff00, 0xff, 0xff000000,
+ true,
+ Buffers.smallestAppropriateTransferType(32));
+ else
+ cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 );
break;
case BufferedImage.TYPE_4BYTE_ABGR:
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
- sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT,
- width, height,
- new int[]{ 0x000000FF,
- 0xFF000000,
- 0x00FF0000,
- 0x0000FF00 } );
- cm = new DirectColorModel( 32, 0xff, 0xff00, 0xff0000, 0xff000000 );
+ sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height,
+ 4, 4*width,
+ new int[]{3, 2, 1, 0});
+ cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ true, premultiplied,
+ BufferedImage.TRANSLUCENT,
+ DataBuffer.TYPE_BYTE);
break;
case BufferedImage.TYPE_INT_BGR:
@@ -192,24 +203,24 @@ public class BufferedImage extends Image
new int[]{ 0x000000FF,
0x0000FF00,
0x00FF0000 } ) ;
- cm = new DirectColorModel( 32, 0xff, 0xff00, 0xff0000 );
- break;
+ cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 );
+ break;
case BufferedImage.TYPE_USHORT_565_RGB:
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
width, height,
- new int[]{ 0x0000001F,
- 0x000007E0,
- 0x0000F800 } ) ;
- cm = new DirectColorModel( 16, 0x1F, 0x7E0, 0xf800 );
+ new int[]{ 0xF800,
+ 0x7E0,
+ 0x1F } ) ;
+ cm = new DirectColorModel( 16, 0xF800, 0x7E0, 0x1F );
break;
case BufferedImage.TYPE_USHORT_555_RGB:
sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT,
width, height,
- new int[]{ 0x0000001F,
- 0x000003E0,
- 0x00007C00 } ) ;
- cm = new DirectColorModel( 15, 0x1F, 0x3E0, 0x7c00 );
+ new int[]{ 0x7C00,
+ 0x3E0,
+ 0x1F } ) ;
+ cm = new DirectColorModel( 15, 0x7C00, 0x3E0, 0x1F );
break;
case BufferedImage.TYPE_BYTE_INDEXED:
diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java
index ea3d1b64c..e2873c5d7 100644
--- a/java/awt/image/ColorModel.java
+++ b/java/awt/image/ColorModel.java
@@ -624,8 +624,12 @@ public abstract class ColorModel implements Transparency
return cspace;
}
- public abstract ColorModel coerceData(WritableRaster raster,
- boolean isAlphaPremultiplied);
+ public ColorModel coerceData(WritableRaster raster,
+ boolean isAlphaPremultiplied)
+ {
+ // This method should always be overridden, but is not abstract.
+ throw new UnsupportedOperationException();
+ }
protected void coerceDataWorker(WritableRaster raster,
boolean isAlphaPremultiplied)
diff --git a/java/awt/image/Raster.java b/java/awt/image/Raster.java
index 160f8be8b..d63e156f6 100644
--- a/java/awt/image/Raster.java
+++ b/java/awt/image/Raster.java
@@ -511,9 +511,10 @@ public class Raster
int height, int childMinX, int childMinY,
int[] bandList)
{
- /* FIXME: Throw RasterFormatException if child bounds extends
- beyond the bounds of this raster. */
-
+ if (parentX < minX || parentX + width > minX + this.width
+ || parentY < minY || parentY + height > minY + this.height)
+ throw new RasterFormatException("Child raster extends beyond parent");
+
SampleModel sm = (bandList == null) ?
sampleModel :
sampleModel.createSubsetSampleModel(bandList);
diff --git a/java/awt/image/WritableRaster.java b/java/awt/image/WritableRaster.java
index 473c6fe41..d2ea4a8aa 100644
--- a/java/awt/image/WritableRaster.java
+++ b/java/awt/image/WritableRaster.java
@@ -136,8 +136,9 @@ public class WritableRaster extends Raster
{
// This mirrors the code from the super class
- // FIXME: Throw RasterFormatException if child bounds extends
- // beyond the bounds of this raster.
+ if (parentX < minX || parentX + w > minX + width
+ || parentY < minY || parentY + h > minY + height)
+ throw new RasterFormatException("Child raster extends beyond parent");
SampleModel sm = (bandList == null) ?
sampleModel :
diff --git a/java/net/Inet6Address.java b/java/net/Inet6Address.java
index ef3c4431a..f4893eb09 100644
--- a/java/net/Inet6Address.java
+++ b/java/net/Inet6Address.java
@@ -121,7 +121,7 @@ public final class Inet6Address extends InetAddress
*/
public boolean isMulticastAddress()
{
- return ipaddress[0] == 0xFF;
+ return ipaddress[0] == (byte) 0xFF;
}
/**
diff --git a/java/net/MulticastSocket.java b/java/net/MulticastSocket.java
index 03bdf1e77..2841192db 100644
--- a/java/net/MulticastSocket.java
+++ b/java/net/MulticastSocket.java
@@ -202,13 +202,41 @@ public class MulticastSocket extends DatagramSocket
{
if (isClosed())
throw new SocketException("socket is closed");
-
- Enumeration e = netIf.getInetAddresses();
-
- if (! e.hasMoreElements())
- throw new SocketException("no network devices found");
-
- InetAddress address = (InetAddress) e.nextElement();
+
+ InetAddress address;
+ if (netIf != null)
+ out:
+ {
+ Enumeration e = netIf.getInetAddresses();
+ if (getLocalAddress() instanceof Inet4Address)
+ {
+ // Search for a IPv4 address.
+ while (e.hasMoreElements())
+ {
+ address = (InetAddress) e.nextElement();
+ if (address instanceof Inet4Address)
+ break out;
+ }
+ throw new SocketException("interface " + netIf.getName() + " has no IPv6 address");
+ }
+ else if (getLocalAddress() instanceof Inet6Address)
+ {
+ // Search for a IPv6 address.
+ while (e.hasMoreElements())
+ {
+ address = (InetAddress) e.nextElement();
+ if (address instanceof Inet6Address)
+ break out;
+ }
+ throw new SocketException("interface " + netIf.getName() + " has no IPv6 address");
+ }
+ else
+ throw new SocketException("interface " + netIf.getName() + " has no suitable IP address");
+ }
+ else
+ address = InetAddress.ANY_IF;
+
+
getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address);
}
@@ -230,6 +258,10 @@ public class MulticastSocket extends DatagramSocket
InetAddress address =
(InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
+
+ if (address.isAnyLocalAddress())
+ return NetworkInterface.createAnyInterface();
+
NetworkInterface netIf = NetworkInterface.getByInetAddress(address);
return netIf;
diff --git a/java/net/NetworkInterface.java b/java/net/NetworkInterface.java
index af595a1ee..6c78ead5b 100644
--- a/java/net/NetworkInterface.java
+++ b/java/net/NetworkInterface.java
@@ -67,6 +67,16 @@ public final class NetworkInterface
this.netif = netif;
}
+ /** Creates an NetworkInterface instance which
+ * represents any interface in the system. Its only
+ * address is <code>0.0.0.0/0.0.0.0</code>. This
+ * method is needed by {@link MulticastSocket#getNetworkInterface}
+ */
+ static NetworkInterface createAnyInterface()
+ {
+ return new NetworkInterface(new VMNetworkInterface());
+ }
+
/**
* Returns the name of the network interface
*
@@ -208,6 +218,9 @@ public final class NetworkInterface
return false;
NetworkInterface tmp = (NetworkInterface) obj;
+
+ if (netif.name == null)
+ return tmp.netif.name == null;
return (netif.name.equals(tmp.netif.name)
&& (netif.addresses.equals(tmp.netif.addresses)));
@@ -221,7 +234,12 @@ public final class NetworkInterface
public int hashCode()
{
// FIXME: hash correctly
- return netif.name.hashCode() + netif.addresses.hashCode();
+ int hc = netif.addresses.hashCode();
+
+ if (netif.name != null)
+ hc += netif.name.hashCode();
+
+ return hc;
}
/**
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java
index 533626e0b..d5f2a176b 100644
--- a/java/net/ServerSocket.java
+++ b/java/net/ServerSocket.java
@@ -345,6 +345,19 @@ public class ServerSocket
throw e;
}
+ catch (SecurityException e)
+ {
+ try
+ {
+ socket.close();
+ }
+ catch (IOException e2)
+ {
+ // Ignore.
+ }
+
+ throw e;
+ }
return socket;
}
@@ -367,9 +380,6 @@ public class ServerSocket
if (isClosed())
throw new SocketException("ServerSocket is closed");
- // FIXME: Add a security check to make sure we're allowed to
- // connect to the remote host.
-
// The Sun spec says that if we have an associated channel and
// it is in non-blocking mode, we throw an IllegalBlockingModeException.
// However, in our implementation if the channel itself initiated this
@@ -380,6 +390,11 @@ public class ServerSocket
impl.accept(socket.impl);
socket.bound = true;
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkAccept(socket.getInetAddress().getHostAddress(),
+ socket.getPort());
}
/**
@@ -603,6 +618,13 @@ public class ServerSocket
public static synchronized void setSocketFactory(SocketImplFactory fac)
throws IOException
{
+ if (factory != null)
+ throw new SocketException("SocketFactory already defined");
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSetFactory();
+
factory = fac;
}
}
diff --git a/java/net/Socket.java b/java/net/Socket.java
index 63ba43727..f4f25fe1c 100644
--- a/java/net/Socket.java
+++ b/java/net/Socket.java
@@ -291,15 +291,33 @@ public class Socket
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkConnect(raddr.getHostName(), rport);
+ sm.checkConnect(raddr.getHostAddress(), rport);
// bind socket
SocketAddress bindaddr =
laddr == null ? null : new InetSocketAddress(laddr, lport);
bind(bindaddr);
- // connect socket
- connect(new InetSocketAddress(raddr, rport));
+ // Connect socket in case of Exceptions we must close the socket
+ // because an exception in the constructor means that the caller will
+ // not have a reference to this instance.
+ // Note: You may have the idea that the exception treatment
+ // should be moved into connect() but there is a Mauve test which
+ // shows that a failed connect should not close the socket.
+ try
+ {
+ connect(new InetSocketAddress(raddr, rport));
+ }
+ catch (IOException ioe)
+ {
+ impl.close();
+ throw ioe;
+ }
+ catch (RuntimeException re)
+ {
+ impl.close();
+ throw re;
+ }
// FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
// i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
@@ -692,10 +710,10 @@ public class Socket
if (linger > 65535)
linger = 65535;
- getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger));
+ getImpl().setOption(SocketOptions.SO_LINGER, Integer.valueOf(linger));
}
else
- getImpl().setOption(SocketOptions.SO_LINGER, Boolean.valueOf(false));
+ getImpl().setOption(SocketOptions.SO_LINGER, Integer.valueOf(-1));
}
/**
@@ -1190,7 +1208,7 @@ public class Socket
{
if (impl == null)
return false;
-
+
return impl.getInetAddress() != null;
}
@@ -1223,6 +1241,7 @@ public class Socket
public boolean isClosed()
{
SocketChannel channel = getChannel();
+
return impl == null || (channel != null && ! channel.isOpen());
}
diff --git a/javax/crypto/CipherOutputStream.java b/javax/crypto/CipherOutputStream.java
index adeb6e5ed..5d1e57a16 100644
--- a/javax/crypto/CipherOutputStream.java
+++ b/javax/crypto/CipherOutputStream.java
@@ -45,59 +45,25 @@ import java.io.OutputStream;
/**
* A filtered output stream that transforms data written to it with a
* {@link Cipher} before sending it to the underlying output stream.
- *
+ *
* @author Casey Marshall (csm@gnu.org)
*/
public class CipherOutputStream extends FilterOutputStream
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
/** The underlying cipher. */
private Cipher cipher;
- private byte[][] inBuffer;
-
- private int inLength;
-
- private byte[] outBuffer;
-
- private static final int FIRST_TIME = 0;
- private static final int SECOND_TIME = 1;
- private static final int SEASONED = 2;
- private int state;
-
- /** True if the cipher is a stream cipher (blockSize == 1) */
- private boolean isStream;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
/**
- * Create a new cipher output stream. The cipher argument must have
- * already been initialized.
- *
- * @param out The sink for transformed data.
+ * Create a new cipher output stream. The cipher argument must have already
+ * been initialized.
+ *
+ * @param out The sink for transformed data.
* @param cipher The cipher to transform data with.
*/
public CipherOutputStream(OutputStream out, Cipher cipher)
{
super(out);
- if (cipher != null)
- {
- this.cipher = cipher;
- if (!(isStream = cipher.getBlockSize() == 1))
- {
- inBuffer = new byte[2][];
- inBuffer[0] = new byte[cipher.getBlockSize()];
- inBuffer[1] = new byte[cipher.getBlockSize()];
- inLength = 0;
- state = FIRST_TIME;
- }
- }
- else
- this.cipher = new NullCipher();
+ this.cipher = (cipher != null) ? cipher : new NullCipher();
}
/**
@@ -110,52 +76,36 @@ public class CipherOutputStream extends FilterOutputStream
super(out);
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Close this output stream, and the sink output stream.
- *
- * <p>This method will first invoke the {@link Cipher#doFinal()}
- * method of the underlying {@link Cipher}, and writes the output of
- * that method to the sink output stream.
- *
- * @throws java.io.IOException If an I/O error occurs, or if an error
- * is caused by finalizing the transformation.
+ * <p>
+ * This method will first invoke the {@link Cipher#doFinal()} method of the
+ * underlying {@link Cipher}, and writes the output of that method to the
+ * sink output stream.
+ *
+ * @throws IOException If an I/O error occurs, or if an error is caused by
+ * finalizing the transformation.
*/
public void close() throws IOException
{
try
{
- int len;
- if (state != FIRST_TIME)
- {
- len = cipher.update(inBuffer[0], 0, inBuffer[0].length, outBuffer);
- out.write(outBuffer, 0, len);
- }
- len = cipher.doFinal(inBuffer[0], 0, inLength, outBuffer);
- out.write(outBuffer, 0, len);
- }
- catch (javax.crypto.IllegalBlockSizeException ibse)
- {
- throw new IOException(ibse.toString());
+ out.write(cipher.doFinal());
+ out.flush();
+ out.close();
}
- catch (javax.crypto.BadPaddingException bpe)
+ catch (Exception cause)
{
- throw new IOException(bpe.toString());
+ IOException ioex = new IOException(String.valueOf(cause));
+ ioex.initCause(cause);
+ throw ioex;
}
- catch (ShortBufferException sbe)
- {
- throw new IOException(sbe.toString());
- }
- out.flush();
- out.close();
}
/**
* Flush any pending output.
*
- * @throws java.io.IOException If an I/O error occurs.
+ * @throws IOException If an I/O error occurs.
*/
public void flush() throws IOException
{
@@ -164,40 +114,22 @@ public class CipherOutputStream extends FilterOutputStream
/**
* Write a single byte to the output stream.
- *
+ *
* @param b The next byte.
- * @throws java.io.IOException If an I/O error occurs, or if the
- * underlying cipher is not in the correct state to transform
- * data.
+ * @throws IOException If an I/O error occurs, or if the underlying cipher is
+ * not in the correct state to transform data.
*/
public void write(int b) throws IOException
{
- if (isStream)
- {
- byte[] buf = new byte[] { (byte) b };
- try
- {
- cipher.update(buf, 0, 1, buf, 0);
- }
- catch (ShortBufferException sbe)
- {
- throw new IOException(sbe.toString());
- }
- out.write(buf);
- return;
- }
- inBuffer[1][inLength++] = (byte) b;
- if (inLength == inBuffer[1].length)
- process();
+ write(new byte[] { (byte) b }, 0, 1);
}
/**
* Write a byte array to the output stream.
- *
+ *
* @param buf The next bytes.
- * @throws java.io.IOException If an I/O error occurs, or if the
- * underlying cipher is not in the correct state to transform
- * data.
+ * @throws IOException If an I/O error occurs, or if the underlying cipher is
+ * not in the correct state to transform data.
*/
public void write(byte[] buf) throws IOException
{
@@ -206,63 +138,15 @@ public class CipherOutputStream extends FilterOutputStream
/**
* Write a portion of a byte array to the output stream.
- *
+ *
* @param buf The next bytes.
* @param off The offset in the byte array to start.
* @param len The number of bytes to write.
- * @throws java.io.IOException If an I/O error occurs, or if the
- * underlying cipher is not in the correct state to transform
- * data.
+ * @throws IOException If an I/O error occurs, or if the underlying cipher is
+ * not in the correct state to transform data.
*/
public void write(byte[] buf, int off, int len) throws IOException
{
- if (isStream)
- {
- out.write(cipher.update(buf, off, len));
- return;
- }
- int count = 0;
- while (count < len)
- {
- int l = Math.min(inBuffer[1].length - inLength, len - count);
- System.arraycopy(buf, off+count, inBuffer[1], inLength, l);
- count += l;
- inLength += l;
- if (inLength == inBuffer[1].length)
- process();
- }
- }
-
- // Own method.
- // -------------------------------------------------------------------------
-
- private void process() throws IOException
- {
- if (state == SECOND_TIME)
- {
- state = SEASONED;
- }
- else
- {
- byte[] temp = inBuffer[0];
- inBuffer[0] = inBuffer[1];
- inBuffer[1] = temp;
- }
- if (state == FIRST_TIME)
- {
- inLength = 0;
- state = SECOND_TIME;
- return;
- }
- try
- {
- cipher.update(inBuffer[0], 0, inBuffer[0].length, outBuffer);
- }
- catch (ShortBufferException sbe)
- {
- throw new IOException(sbe.toString());
- }
- out.write(outBuffer);
- inLength = 0;
+ out.write(cipher.update(buf, off, len));
}
}
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index c2c894c06..cb0f458b8 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -37,8 +37,6 @@ exception statement from your version. */
package javax.swing;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
@@ -74,7 +72,10 @@ import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
import javax.swing.text.Position;
+import javax.swing.text.StyledDocument;
import javax.swing.text.View;
@@ -804,22 +805,127 @@ public abstract class AbstractButton extends JComponent
return -1;
}
- public String getAtIndex(int value0, int value1)
- throws NotImplementedException
+ /**
+ * Returns the character, word or sentence at the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence after the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence after <code>index</code>
+ */
+ public String getAtIndex(int part, int index)
{
- return null; // TODO
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index));
+ break;
+ case AccessibleText.WORD:
+ startIndex = text.lastIndexOf(' ', index);
+ endIndex = text.indexOf(' ', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ startIndex = text.lastIndexOf('.', index);
+ endIndex = text.indexOf('.', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
}
- public String getAfterIndex(int value0, int value1)
- throws NotImplementedException
+ /**
+ * Returns the character, word or sentence after the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence after the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence after <code>index</code>
+ */
+ public String getAfterIndex(int part, int index)
{
- return null; // TODO
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index + 1));
+ break;
+ case AccessibleText.WORD:
+ startIndex = text.indexOf(' ', index);
+ endIndex = text.indexOf(' ', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ startIndex = text.indexOf('.', index);
+ endIndex = text.indexOf('.', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
}
- public String getBeforeIndex(int value0, int value1)
- throws NotImplementedException
+ /**
+ * Returns the character, word or sentence before the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence before the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence before <code>index</code>
+ */
+ public String getBeforeIndex(int part, int index)
{
- return null; // TODO
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index - 1));
+ break;
+ case AccessibleText.WORD:
+ endIndex = text.lastIndexOf(' ', index);
+ if (endIndex == -1)
+ endIndex = 0;
+ startIndex = text.lastIndexOf(' ', endIndex - 1);
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ endIndex = text.lastIndexOf('.', index);
+ if (endIndex == -1)
+ endIndex = 0;
+ startIndex = text.lastIndexOf('.', endIndex - 1);
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
}
/**
@@ -837,7 +943,14 @@ public abstract class AbstractButton extends JComponent
View view = (View) getClientProperty(BasicHTML.propertyKey);
if (view != null)
{
-
+ Document doc = view.getDocument();
+ if (doc instanceof StyledDocument)
+ {
+ StyledDocument sDoc = (StyledDocument) doc;
+ Element charEl = sDoc.getCharacterElement(i);
+ if (charEl != null)
+ atts = charEl.getAttributes();
+ }
}
return atts;
}
diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java
index 34af3db87..9b5bdb60d 100644
--- a/javax/swing/DefaultComboBoxModel.java
+++ b/javax/swing/DefaultComboBoxModel.java
@@ -224,18 +224,26 @@ public class DefaultComboBoxModel extends AbstractListModel
*/
public void setSelectedItem(Object object)
{
- if (selectedItem == null)
- {
- if (object == null)
- return;
- }
- else
- {
- if (selectedItem.equals(object))
- return;
- }
+ // No item is selected and object is null, so no change required.
+ if (selectedItem == null && object == null)
+ return;
+
+ // object is already selected so no change required.
+ if (selectedItem != null && selectedItem.equals(object))
+ return;
+
+ // Simply return if object is not in the list.
+ if (object != null && getIndexOf(object) == -1)
+ return;
+
+ // Here we know that object is either an item in the list or null.
+
+ // Handle the three change cases: selectedItem is null, object is
+ // non-null; selectedItem is non-null, object is null;
+ // selectedItem is non-null, object is non-null and they're not
+ // equal.
selectedItem = object;
- fireContentsChanged(this, -1, -1);
+ fireContentsChanged(this, -1, -1);
}
/**
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 0b4631f6c..3b8f1f68c 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -541,14 +541,6 @@ public abstract class JComponent extends Container implements Serializable
*/
Border border;
- /**
- * The text to show in the tooltip associated with this component.
- *
- * @see #setToolTipText
- * @see #getToolTipText()
- */
- String toolTipText;
-
/**
* The popup menu for the component.
*
@@ -1439,14 +1431,12 @@ public abstract class JComponent extends Container implements Serializable
{
JToolTip toolTip = new JToolTip();
toolTip.setComponent(this);
- toolTip.setTipText(toolTipText);
-
return toolTip;
}
/**
- * Return the location at which the {@link #toolTipText} property should be
- * displayed, when triggered by a particular mouse event.
+ * Return the location at which the <code>toolTipText</code> property should
+ * be displayed, when triggered by a particular mouse event.
*
* @param event The event the tooltip is being presented in response to
*
@@ -1459,53 +1449,56 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Set the value of the {@link #toolTipText} property.
+ * Set the tooltip text for this component. If a non-<code>null</code>
+ * value is set, this component is registered in the
+ * <code>ToolTipManager</code> in order to turn on tooltips for this
+ * component. If a <code>null</code> value is set, tooltips are turne off
+ * for this component.
*
- * @param text The new property value
+ * @param text the tooltip text for this component
*
* @see #getToolTipText()
+ * @see #getToolTipText(MouseEvent)
*/
public void setToolTipText(String text)
{
+ String old = getToolTipText();
+ putClientProperty(TOOL_TIP_TEXT_KEY, text);
+ ToolTipManager ttm = ToolTipManager.sharedInstance();
if (text == null)
- {
- ToolTipManager.sharedInstance().unregisterComponent(this);
- toolTipText = null;
- return;
- }
-
- // XXX: The tip text doesn't get updated unless you set it to null
- // and then to something not-null. This is consistent with the behaviour
- // of Sun's ToolTipManager.
-
- String oldText = toolTipText;
- toolTipText = text;
-
- if (oldText == null)
- ToolTipManager.sharedInstance().registerComponent(this);
+ ttm.unregisterComponent(this);
+ else if (old == null)
+ ttm.registerComponent(this);
}
/**
- * Get the value of the {@link #toolTipText} property.
+ * Returns the current tooltip text for this component, or <code>null</code>
+ * if none has been set.
*
- * @return The current property value
+ * @return the current tooltip text for this component, or <code>null</code>
+ * if none has been set
*
* @see #setToolTipText
+ * @see #getToolTipText(MouseEvent)
*/
public String getToolTipText()
{
- return toolTipText;
+ return (String) getClientProperty(TOOL_TIP_TEXT_KEY);
}
/**
- * Get the value of the {@link #toolTipText} property, in response to a
- * particular mouse event.
+ * Returns the tooltip text for this component for a particular mouse
+ * event. This can be used to support context sensitive tooltips that can
+ * change with the mouse location. By default this returns the static
+ * tooltip text returned by {@link #getToolTipText()}.
*
- * @param event The mouse event which triggered the tooltip
+ * @param event the mouse event which triggered the tooltip
*
- * @return The current property value
+ * @return the tooltip text for this component for a particular mouse
+ * event
*
* @see #setToolTipText
+ * @see #getToolTipText()
*/
public String getToolTipText(MouseEvent event)
{
@@ -2188,6 +2181,10 @@ public abstract class JComponent extends Container implements Serializable
components.add(c);
if (! onTop && jc != null && ! jc.isOptimizedDrawingEnabled())
{
+ // Indicates whether we reset the paint root to be the current
+ // component.
+ boolean updatePaintRoot = false;
+
// Check obscured state of the child.
// Generally, we have 3 cases here:
// 1. Not obscured. No need to paint from the parent.
@@ -2195,23 +2192,32 @@ public abstract class JComponent extends Container implements Serializable
// 3. Completely obscured. No need to paint anything.
if (c != this)
{
- int count = c.getComponentCount();
- int i = 0;
- for (; i < count && c.getComponent(i) != child; i++);
+ if (jc.isPaintRoot())
+ updatePaintRoot = true;
+ else
+ {
+ int count = c.getComponentCount();
+ int i = 0;
+ for (; i < count && c.getComponent(i) != child; i++);
- if (jc.isCompletelyObscured(i, paintX, paintY, paintW, paintH))
- return; // No need to paint anything.
- else if (jc.isPartiallyObscured(i, paintX, paintY, paintW,
+ if (jc.isCompletelyObscured(i, paintX, paintY, paintW,
paintH))
- {
- // Paint from parent.
- paintRoot = jc;
- pIndex = pCount;
- offsX = 0;
- offsY = 0;
- haveBuffer = false;
+ return; // No need to paint anything.
+ else if (jc.isPartiallyObscured(i, paintX, paintY, paintW,
+ paintH))
+ updatePaintRoot = true;
+
}
}
+ if (updatePaintRoot)
+ {
+ // Paint from parent.
+ paintRoot = jc;
+ pIndex = pCount;
+ offsX = 0;
+ offsY = 0;
+ haveBuffer = false;
+ }
}
pCount++;
// Check if component is double buffered.
@@ -2257,8 +2263,7 @@ public abstract class JComponent extends Container implements Serializable
// Actually trigger painting.
if (haveBuffer)
- paintRoot.paintDoubleBuffered(paintX, paintY, paintW,
- paintH);
+ paintRoot.paintDoubleBuffered(paintX, paintY, paintW, paintH);
else
{
Graphics g = paintRoot.getGraphics();
@@ -2303,6 +2308,19 @@ public abstract class JComponent extends Container implements Serializable
}
/**
+ * This returns true when a component needs to force itself as a paint
+ * origin. This is used for example in JViewport to make sure that it
+ * gets to update its backbuffer.
+ *
+ * @return true when a component needs to force itself as a paint
+ * origin
+ */
+ boolean isPaintRoot()
+ {
+ return false;
+ }
+
+ /**
* Performs double buffered repainting.
*/
private void paintDoubleBuffered(int x, int y, int w, int h)
diff --git a/javax/swing/JDialog.java b/javax/swing/JDialog.java
index 08dada2fd..495c9c791 100644
--- a/javax/swing/JDialog.java
+++ b/javax/swing/JDialog.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
+import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
@@ -97,7 +98,7 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
protected boolean rootPaneCheckingEnabled = false;
/** The default action taken when closed. */
- private int close_action = HIDE_ON_CLOSE;
+ private int closeAction = HIDE_ON_CLOSE;
/** Whether JDialogs are decorated by the Look and Feel. */
private static boolean decorated;
@@ -245,6 +246,10 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
protected void dialogInit()
{
+ // We need to explicitly enable events here so that our processKeyEvent()
+ // and processWindowEvent() gets called.
+ enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+
// FIXME: Do a check on GraphicsEnvironment.isHeadless()
setLocale(JComponent.getDefaultLocale());
getRootPane(); // Will do set/create.
@@ -507,37 +512,23 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
protected void processWindowEvent(WindowEvent e)
{
- // System.out.println("PROCESS_WIN_EV-1: " + e);
super.processWindowEvent(e);
- // System.out.println("PROCESS_WIN_EV-2: " + e);
- switch (e.getID())
+ if (e.getID() == WindowEvent.WINDOW_CLOSING)
{
- case WindowEvent.WINDOW_CLOSING:
- {
- switch (getDefaultCloseOperation())
- {
- case DISPOSE_ON_CLOSE:
- {
- dispose();
- break;
- }
- case HIDE_ON_CLOSE:
- {
- setVisible(false);
- break;
- }
- case DO_NOTHING_ON_CLOSE:
- break;
- }
- break;
- }
- case WindowEvent.WINDOW_CLOSED:
- case WindowEvent.WINDOW_OPENED:
- case WindowEvent.WINDOW_ICONIFIED:
- case WindowEvent.WINDOW_DEICONIFIED:
- case WindowEvent.WINDOW_ACTIVATED:
- case WindowEvent.WINDOW_DEACTIVATED:
- break;
+ switch (closeAction)
+ {
+ case EXIT_ON_CLOSE:
+ System.exit(0);
+ break;
+ case DISPOSE_ON_CLOSE:
+ dispose();
+ break;
+ case HIDE_ON_CLOSE:
+ setVisible(false);
+ break;
+ case DO_NOTHING_ON_CLOSE:
+ break;
+ }
}
}
@@ -554,7 +545,7 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
must return the invalid code, and the behaviour
defaults to DO_NOTHING_ON_CLOSE. processWindowEvent
above handles this */
- close_action = operation;
+ closeAction = operation;
}
/**
@@ -565,7 +556,7 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
public int getDefaultCloseOperation()
{
- return close_action;
+ return closeAction;
}
/**
diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java
index a5efa07df..06844355a 100644
--- a/javax/swing/JEditorPane.java
+++ b/javax/swing/JEditorPane.java
@@ -47,6 +47,7 @@ import java.io.Reader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.util.HashMap;
import javax.accessibility.AccessibleContext;
@@ -508,7 +509,6 @@ public class JEditorPane extends JTextComponent
private static final long serialVersionUID = 3140472492599046285L;
- private URL page;
private EditorKit editorKit;
boolean focus_root;
@@ -762,13 +762,19 @@ public class JEditorPane extends JTextComponent
public URL getPage()
{
- return page;
+ return (URL) getDocument().getProperty(Document.StreamDescriptionProperty);
}
protected InputStream getStream(URL page)
throws IOException
{
- return page.openStream();
+ URLConnection conn = page.openConnection();
+ // Try to detect the content type of the stream data.
+ String type = conn.getContentType();
+ if (type != null)
+ setContentType(type);
+ InputStream stream = conn.getInputStream();
+ return stream;
}
public String getText()
@@ -799,10 +805,12 @@ public class JEditorPane extends JTextComponent
EditorKit kit = getEditorKit();
if (kit instanceof HTMLEditorKit && desc instanceof HTMLDocument)
{
- Document doc = (Document) desc;
+ HTMLDocument doc = (HTMLDocument) desc;
+ setDocument(doc);
try
{
- kit.read(in, doc, 0);
+ InputStreamReader reader = new InputStreamReader(in);
+ kit.read(reader, doc, 0);
}
catch (BadLocationException ex)
{
@@ -921,15 +929,16 @@ public class JEditorPane extends JTextComponent
if (page == null)
throw new IOException("invalid url");
- try
- {
- this.page = page;
- getEditorKit().read(page.openStream(), getDocument(), 0);
- }
- catch (BadLocationException e)
+ URL old = getPage();;
+ InputStream in = getStream(page);
+ if (editorKit != null)
{
- // Ignored. '0' is always a valid offset.
+ Document doc = editorKit.createDefaultDocument();
+ doc.putProperty(Document.StreamDescriptionProperty, page);
+ read(in, doc);
+ setDocument(doc);
}
+ firePropertyChange("page", old, page);
}
/**
diff --git a/javax/swing/JFrame.java b/javax/swing/JFrame.java
index 1371525dd..0ae23f101 100644
--- a/javax/swing/JFrame.java
+++ b/javax/swing/JFrame.java
@@ -157,6 +157,10 @@ public class JFrame extends Frame
protected void frameInit()
{
+ // We need to explicitly enable events here so that our processKeyEvent()
+ // and processWindowEvent() gets called.
+ enableEvents(AWTEvent.WINDOW_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
+
super.setLayout(new BorderLayout());
setBackground(UIManager.getDefaults().getColor("control"));
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
@@ -351,39 +355,22 @@ public class JFrame extends Frame
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
- switch (e.getID())
+ if (e.getID() == WindowEvent.WINDOW_CLOSING)
{
- case WindowEvent.WINDOW_CLOSING:
- {
- switch (closeAction)
- {
- case EXIT_ON_CLOSE:
- {
- System.exit(0);
- break;
- }
- case DISPOSE_ON_CLOSE:
- {
- dispose();
- break;
- }
- case HIDE_ON_CLOSE:
- {
- setVisible(false);
- break;
- }
- case DO_NOTHING_ON_CLOSE:
- break;
- }
- break;
- }
- case WindowEvent.WINDOW_CLOSED:
- case WindowEvent.WINDOW_OPENED:
- case WindowEvent.WINDOW_ICONIFIED:
- case WindowEvent.WINDOW_DEICONIFIED:
- case WindowEvent.WINDOW_ACTIVATED:
- case WindowEvent.WINDOW_DEACTIVATED:
- break;
+ switch (closeAction)
+ {
+ case EXIT_ON_CLOSE:
+ System.exit(0);
+ break;
+ case DISPOSE_ON_CLOSE:
+ dispose();
+ break;
+ case HIDE_ON_CLOSE:
+ setVisible(false);
+ break;
+ case DO_NOTHING_ON_CLOSE:
+ break;
+ }
}
}
diff --git a/javax/swing/JLabel.java b/javax/swing/JLabel.java
index fcf0fd7cb..3e0f28ed7 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -38,13 +38,14 @@ exception statement from your version. */
package javax.swing;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Component;
import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Image;
+import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.Shape;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
@@ -54,8 +55,12 @@ import javax.accessibility.AccessibleExtendedComponent;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleText;
import javax.swing.plaf.LabelUI;
+import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Position;
import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.View;
/**
* A component that displays a static text message and/or an icon.
@@ -303,10 +308,52 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* @return the bounding box of the character at the specified index
*/
public Rectangle getCharacterBounds(int index)
- throws NotImplementedException
{
- // FIXME: Implement this correctly.
- return new Rectangle();
+ Rectangle bounds = null;
+ View view = (View) getClientProperty(BasicHTML.propertyKey);
+ if (view != null)
+ {
+ Rectangle textR = getTextRectangle();
+ try
+ {
+ Shape s = view.modelToView(index, textR, Position.Bias.Forward);
+ bounds = s.getBounds();
+ }
+ catch (BadLocationException ex)
+ {
+ // Can't return something reasonable in this case.
+ }
+ }
+ return bounds;
+ }
+
+ /**
+ * Returns the rectangle inside the JLabel, in which the actual text is
+ * rendered. This method has been adopted from the Mauve testcase
+ * gnu.testlet.javax.swing.JLabel.AccessibleJLabel.getCharacterBounds.
+ *
+ * @return the rectangle inside the JLabel, in which the actual text is
+ * rendered
+ */
+ private Rectangle getTextRectangle()
+ {
+ JLabel l = JLabel.this;
+ Rectangle textR = new Rectangle();
+ Rectangle iconR = new Rectangle();
+ Insets i = l.getInsets();
+ int w = l.getWidth();
+ int h = l.getHeight();
+ Rectangle viewR = new Rectangle(i.left, i.top, w - i.left - i.right,
+ h - i.top - i.bottom);
+ FontMetrics fm = l.getFontMetrics(l.getFont());
+ SwingUtilities.layoutCompoundLabel(l, fm, l.getText(), l.getIcon(),
+ l.getVerticalAlignment(),
+ l.getHorizontalAlignment(),
+ l.getVerticalTextPosition(),
+ l.getHorizontalTextPosition(),
+ viewR, iconR, textR,
+ l.getIconTextGap());
+ return textR;
}
/**
@@ -319,10 +366,15 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* point
*/
public int getIndexAtPoint(Point point)
- throws NotImplementedException
{
- // FIXME: Implement this correctly.
- return 0;
+ int index = -1;
+ View view = (View) getClientProperty(BasicHTML.propertyKey);
+ if (view != null)
+ {
+ Rectangle r = getTextRectangle();
+ index = view.viewToModel(point.x, point.y, r, new Position.Bias[0]);
+ }
+ return index;
}
}
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index 4231e4fa6..ffdccdcef 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
-import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
@@ -77,6 +76,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
private KeyStroke accelerator;
/**
+ * Indicates if we are currently dragging the mouse.
+ */
+ private boolean isDragging;
+
+ /**
* Creates a new JMenuItem object.
*/
public JMenuItem()
@@ -319,71 +323,21 @@ public class JMenuItem extends AbstractButton implements Accessible,
/**
* Process mouse events forwarded from MenuSelectionManager.
*
- * @param event event forwarded from MenuSelectionManager
+ * @param ev event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*/
- public void processMouseEvent(MouseEvent event, MenuElement[] path,
+ public void processMouseEvent(MouseEvent ev, MenuElement[] path,
MenuSelectionManager manager)
{
- // Fire MenuDragMouseEvents if mouse is being dragged.
- boolean dragged
- = (event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0;
- if (dragged)
- processMenuDragMouseEvent(createMenuDragMouseEvent(event, path, manager));
-
- switch (event.getID())
- {
- case MouseEvent.MOUSE_CLICKED:
- break;
- case MouseEvent.MOUSE_ENTERED:
- if (isRolloverEnabled())
- model.setRollover(true);
- break;
- case MouseEvent.MOUSE_EXITED:
- if (isRolloverEnabled())
- model.setRollover(false);
-
- // for JMenu last element on the path is its popupMenu.
- // JMenu shouldn't me disarmed.
- if (! (path[path.length - 1] instanceof JPopupMenu) && ! dragged)
- setArmed(false);
- break;
- case MouseEvent.MOUSE_PRESSED:
- if ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
- {
- model.setArmed(true);
- model.setPressed(true);
- }
- break;
- case MouseEvent.MOUSE_RELEASED:
- break;
- case MouseEvent.MOUSE_MOVED:
- break;
- case MouseEvent.MOUSE_DRAGGED:
- break;
- }
- }
-
- /**
- * Creates MenuDragMouseEvent.
- *
- * @param event MouseEvent that occured while mouse was pressed.
- * @param path Path the the menu element where the dragging event was
- * originated
- * @param manager MenuSelectionManager for the current menu hierarchy.
- *
- * @return new MenuDragMouseEvent
- */
- private MenuDragMouseEvent createMenuDragMouseEvent(MouseEvent event,
- MenuElement[] path,
- MenuSelectionManager manager)
- {
- return new MenuDragMouseEvent((Component) event.getSource(),
- event.getID(), event.getWhen(),
- event.getModifiers(), event.getX(),
- event.getY(), event.getClickCount(),
- event.isPopupTrigger(), path, manager);
+ MenuDragMouseEvent e = new MenuDragMouseEvent(ev.getComponent(),
+ ev.getID(), ev.getWhen(),
+ ev.getModifiers(), ev.getX(),
+ ev.getY(),
+ ev.getClickCount(),
+ ev.isPopupTrigger(), path,
+ manager);
+ processMenuDragMouseEvent(e);
}
/**
@@ -419,16 +373,20 @@ public class JMenuItem extends AbstractButton implements Accessible,
switch (event.getID())
{
case MouseEvent.MOUSE_ENTERED:
+ isDragging = false;
fireMenuDragMouseEntered(event);
break;
case MouseEvent.MOUSE_EXITED:
+ isDragging = false;
fireMenuDragMouseExited(event);
break;
case MouseEvent.MOUSE_DRAGGED:
+ isDragging = true;
fireMenuDragMouseDragged(event);
break;
case MouseEvent.MOUSE_RELEASED:
- fireMenuDragMouseReleased(event);
+ if (isDragging)
+ fireMenuDragMouseReleased(event);
break;
}
}
diff --git a/javax/swing/JScrollPane.java b/javax/swing/JScrollPane.java
index 45df1d919..f6d37c7b4 100644
--- a/javax/swing/JScrollPane.java
+++ b/javax/swing/JScrollPane.java
@@ -161,9 +161,10 @@ public class JScrollPane extends JComponent
protected int verticalScrollBarPolicy;
protected JViewport viewport;
-
- Border viewportBorder;
- boolean wheelScrollingEnabled;
+
+ private Border viewportBorder;
+
+ private boolean wheelScrollingEnabled;
public JViewport getColumnHeader()
{
@@ -595,6 +596,7 @@ public class JScrollPane extends JComponent
*/
public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
{
+ wheelScrollingEnabled = true;
setVerticalScrollBarPolicy(vsbPolicy);
setVerticalScrollBar(createVerticalScrollBar());
setHorizontalScrollBarPolicy(hsbPolicy);
diff --git a/javax/swing/JSlider.java b/javax/swing/JSlider.java
index 8a06d4f01..91eec4751 100644
--- a/javax/swing/JSlider.java
+++ b/javax/swing/JSlider.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing;
-import java.awt.Dimension;
import java.awt.MenuContainer;
import java.awt.image.ImageObserver;
import java.beans.PropertyChangeEvent;
@@ -56,6 +55,7 @@ import javax.accessibility.AccessibleValue;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.SliderUI;
+import javax.swing.plaf.UIResource;
/**
* A visual component that allows selection of a value within a
@@ -112,6 +112,22 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
ImageObserver,
MenuContainer, Serializable
{
+
+ /**
+ * A little testing shows that the reference implementation creates
+ * labels from a class named LabelUIResource.
+ */
+ private class LabelUIResource
+ extends JLabel
+ implements UIResource
+ {
+ LabelUIResource(String text, int align)
+ {
+ super(text, align);
+ setName("Slider.label");
+ }
+ }
+
private static final long serialVersionUID = -1441275936141218479L;
/**
@@ -425,6 +441,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
public void updateUI()
{
+ updateLabelUIs();
setUI((SliderUI) UIManager.getUI(this));
}
@@ -721,6 +738,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
int oldOrientation = this.orientation;
this.orientation = orientation;
firePropertyChange("orientation", oldOrientation, this.orientation);
+ revalidate();
}
}
@@ -751,7 +769,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
{
Dictionary oldTable = labelTable;
labelTable = table;
+ updateLabelUIs();
firePropertyChange("labelTable", oldTable, labelTable);
+ revalidate();
+ repaint();
}
}
@@ -761,12 +782,18 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
protected void updateLabelUIs()
{
- if (labelTable == null)
- return;
- for (Enumeration list = labelTable.elements(); list.hasMoreElements();)
+ if (labelTable != null)
{
- JLabel label = (JLabel) list.nextElement();
- label.updateUI();
+ for (Enumeration list = labelTable.elements(); list.hasMoreElements();)
+ {
+ Object o = (JLabel) list.nextElement();
+ if (o instanceof JComponent)
+ {
+ JComponent jc = (JComponent) o;
+ jc.updateUI();
+ jc.setSize(jc.getPreferredSize());
+ }
+ }
}
}
@@ -810,23 +837,11 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
if (start < getMinimum() || start > getMaximum())
throw new IllegalArgumentException("The 'start' value is out of range.");
Hashtable table = new Hashtable();
- JLabel label;
- Dimension dim;
-
- int max = sliderModel.getMaximum();
-
+ int max = getMaximum();
for (int i = start; i <= max; i += increment)
{
- label = new JLabel(String.valueOf(i));
- label.setVerticalAlignment(CENTER);
- label.setHorizontalAlignment(CENTER);
-
- // Make sure these labels have the width and height
- // they want.
- dim = label.getPreferredSize();
- label.setBounds(label.getX(), label.getY(),
- (int) dim.getWidth(),
- (int) dim.getHeight());
+ LabelUIResource label = new LabelUIResource(String.valueOf(i),
+ JLabel.CENTER);
table.put(new Integer(i), label);
}
return table;
@@ -867,6 +882,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
boolean oldInverted = isInverted;
isInverted = inverted;
firePropertyChange("inverted", oldInverted, isInverted);
+ repaint();
}
}
@@ -898,7 +914,11 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
{
int oldSpacing = majorTickSpacing;
majorTickSpacing = spacing;
+ if (labelTable == null && majorTickSpacing > 0 && getPaintLabels())
+ setLabelTable(createStandardLabels(majorTickSpacing));
firePropertyChange("majorTickSpacing", oldSpacing, majorTickSpacing);
+ if (getPaintTicks())
+ repaint();
}
}
@@ -932,6 +952,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
int oldSpacing = minorTickSpacing;
minorTickSpacing = spacing;
firePropertyChange("minorTickSpacing", oldSpacing, minorTickSpacing);
+ if (getPaintTicks())
+ repaint();
}
}
@@ -1001,6 +1023,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
boolean oldPaintTicks = paintTicks;
paintTicks = paint;
firePropertyChange("paintTicks", oldPaintTicks, paintTicks);
+ revalidate();
+ repaint();
}
}
@@ -1031,6 +1055,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
{
paintTrack = paint;
firePropertyChange("paintTrack", !paint, paint);
+ repaint();
}
}
@@ -1062,8 +1087,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
{
paintLabels = paint;
if (paint && majorTickSpacing > 0 && labelTable == null)
- labelTable = createStandardLabels(majorTickSpacing);
+ setLabelTable(createStandardLabels(majorTickSpacing));
firePropertyChange("paintLabels", !paint, paint);
+ revalidate();
+ repaint();
}
}
diff --git a/javax/swing/JSplitPane.java b/javax/swing/JSplitPane.java
index 5b77f5176..fcdc1c041 100644
--- a/javax/swing/JSplitPane.java
+++ b/javax/swing/JSplitPane.java
@@ -247,6 +247,11 @@ public class JSplitPane extends JComponent implements Accessible
/** The component on the right or bottom. */
protected Component rightComponent;
+ /**
+ * The divider location.
+ */
+ private int dividerLocation;
+
/** Determines how extra space should be allocated. */
private transient double resizeWeight;
@@ -288,7 +293,7 @@ public class JSplitPane extends JComponent implements Accessible
continuousLayout = newContinuousLayout;
setLeftComponent(newLeftComponent);
setRightComponent(newRightComponent);
-
+ dividerLocation = -1;
updateUI();
}
@@ -355,10 +360,6 @@ public class JSplitPane extends JComponent implements Accessible
*/
protected void addImpl(Component comp, Object constraints, int index)
{
- int left = 0;
- int right = 1;
- int div = 2;
- int place;
if (constraints == null)
{
if (leftComponent == null)
@@ -431,10 +432,7 @@ public class JSplitPane extends JComponent implements Accessible
*/
public int getDividerLocation()
{
- if (ui != null)
- return ((SplitPaneUI) ui).getDividerLocation(this);
- else
- return -1;
+ return dividerLocation;
}
/**
@@ -722,17 +720,13 @@ public class JSplitPane extends JComponent implements Accessible
*/
public void setDividerLocation(int location)
{
- if (ui != null && location != getDividerLocation())
- {
- int oldLocation = getDividerLocation();
- if (location < 0)
- ((SplitPaneUI) ui).resetToPreferredSizes(this);
- else
- ((SplitPaneUI) ui).setDividerLocation(this, location);
-
- firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation,
- getDividerLocation());
- }
+ int oldLocation = dividerLocation;
+ dividerLocation = location;
+ SplitPaneUI ui = getUI();
+ if (ui != null)
+ ui.setDividerLocation(this, location);
+ firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation,
+ location);
}
/**
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 7d093e3d0..c6f08b49c 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -1279,13 +1279,6 @@ public class JTree extends JComponent implements Scrollable, Accessible
TreeSelectionEvent rewritten =
(TreeSelectionEvent) ev.cloneWithSource(JTree.this);
fireValueChanged(rewritten);
-
- // Only repaint the changed nodes.
- TreePath[] changed = ev.getPaths();
- for (int i = 0; i < changed.length; i++)
- {
- repaint(getPathBounds(changed[i]));
- }
}
}
@@ -1698,7 +1691,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (direction < 0)
delta = Math.max(0, visibleRect.y - b.y);
else
- delta = b.y + b.height - visibleRect.height;
+ delta = b.y + b.height - visibleRect.y;
}
else
{
@@ -2433,9 +2426,19 @@ public class JTree extends JComponent implements Scrollable, Accessible
return selectionModel.isPathSelected(path);
}
+ /**
+ * Returns <code>true</code> when the specified row is selected,
+ * <code>false</code> otherwise. This call is delegated to the
+ * {@link TreeSelectionModel#isRowSelected(int)} method.
+ *
+ * @param row the row to check
+ *
+ * @return <code>true</code> when the specified row is selected,
+ * <code>false</code> otherwise
+ */
public boolean isRowSelected(int row)
{
- return selectionModel.isPathSelected(getPathForRow(row));
+ return selectionModel.isRowSelected(row);
}
public boolean isSelectionEmpty()
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index 9fd14e80a..d90da1d15 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -837,10 +837,13 @@ public class JViewport extends JComponent implements Accessible
if (canBlit)
{
// Copy the part that remains visible during scrolling.
- g2.copyArea(cachedBlitFrom.x, cachedBlitFrom.y,
- cachedBlitSize.width, cachedBlitSize.height,
- cachedBlitTo.x - cachedBlitFrom.x,
- cachedBlitTo.y - cachedBlitFrom.y);
+ if (cachedBlitSize.width > 0 && cachedBlitSize.height > 0)
+ {
+ g2.copyArea(cachedBlitFrom.x, cachedBlitFrom.y,
+ cachedBlitSize.width, cachedBlitSize.height,
+ cachedBlitTo.x - cachedBlitFrom.x,
+ cachedBlitTo.y - cachedBlitFrom.y);
+ }
// Now paint the part that becomes newly visible.
g2.setClip(cachedBlitPaint.x, cachedBlitPaint.y,
cachedBlitPaint.width, cachedBlitPaint.height);
@@ -888,10 +891,13 @@ public class JViewport extends JComponent implements Accessible
if (canBlit && isPaintRoot)
{
// Copy the part that remains visible during scrolling.
- g.copyArea(cachedBlitFrom.x, cachedBlitFrom.y,
- cachedBlitSize.width, cachedBlitSize.height,
- cachedBlitTo.x - cachedBlitFrom.x,
- cachedBlitTo.y - cachedBlitFrom.y);
+ if (cachedBlitSize.width > 0 && cachedBlitSize.width > 0)
+ {
+ g.copyArea(cachedBlitFrom.x, cachedBlitFrom.y,
+ cachedBlitSize.width, cachedBlitSize.height,
+ cachedBlitTo.x - cachedBlitFrom.x,
+ cachedBlitTo.y - cachedBlitFrom.y);
+ }
// Now paint the part that becomes newly visible.
Shape oldClip = g.getClip();
g.clipRect(cachedBlitPaint.x, cachedBlitPaint.y,
@@ -926,4 +932,13 @@ public class JViewport extends JComponent implements Accessible
super.paintImmediately2(x, y, w, h);
isPaintRoot = false;
}
+
+ /**
+ * Returns true when the JViewport is using a backbuffer, so that we
+ * can update our backbuffer correctly.
+ */
+ boolean isPaintRoot()
+ {
+ return scrollMode == BACKINGSTORE_SCROLL_MODE;
+ }
}
diff --git a/javax/swing/JWindow.java b/javax/swing/JWindow.java
index 19d830ed1..b36b8cf2a 100644
--- a/javax/swing/JWindow.java
+++ b/javax/swing/JWindow.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
+import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
@@ -158,6 +159,10 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
protected void windowInit()
{
+ // We need to explicitly enable events here so that our processKeyEvent()
+ // and processWindowEvent() gets called.
+ enableEvents(AWTEvent.KEY_EVENT_MASK);
+
super.setLayout(new BorderLayout(1, 1));
getRootPane(); // will do set/create
// Now we're done init stage, adds and layouts go to content pane.
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index fa374a34f..afed7ec8e 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -69,6 +69,7 @@ import java.util.WeakHashMap;
* <p>See <a
* href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
* document</a> for more details.</p>
+ * document</a> for more details.</p>
*
* @author Roman Kennke (kennke@aicas.com)
* @author Graydon Hoare (graydon@redhat.com)
@@ -96,9 +97,21 @@ public class RepaintManager
* @param source the source
* @param runnable the runnable to execute
*/
- public RepaintWorkerEvent(Object source, Runnable runnable)
+ public RepaintWorkerEvent(Object source, Runnable runnable,
+ Object notifier, boolean catchEx)
+ {
+ super(source, runnable, notifier, catchEx);
+ }
+
+ /**
+ * An application that I met implements its own event dispatching and
+ * calls dispatch() via reflection, and only checks declared methods,
+ * that is, it expects this method to be in the event's class, not
+ * in a superclass. So I put this in here... sigh.
+ */
+ public void dispatch()
{
- super(source, runnable);
+ super.dispatch();
}
}
@@ -419,15 +432,16 @@ public class RepaintManager
if (! rectCache.isEmpty())
{
- if (dirtyComponents.containsKey(component))
- {
- SwingUtilities.computeUnion(rectCache.x, rectCache.y,
- rectCache.width, rectCache.height,
- (Rectangle) dirtyComponents.get(component));
- }
- else
+ synchronized (dirtyComponents)
{
- synchronized (dirtyComponents)
+ Rectangle dirtyRect = (Rectangle)dirtyComponents.get(component);
+ if (dirtyRect != null)
+ {
+ SwingUtilities.computeUnion(rectCache.x, rectCache.y,
+ rectCache.width, rectCache.height,
+ dirtyRect);
+ }
+ else
{
dirtyComponents.put(component, rectCache.getBounds());
}
@@ -838,7 +852,7 @@ public class RepaintManager
{
Toolkit tk = Toolkit.getDefaultToolkit();
EventQueue evQueue = tk.getSystemEventQueue();
- InvocationEvent ev = new RepaintWorkerEvent(this, runnable);
+ InvocationEvent ev = new RepaintWorkerEvent(evQueue, runnable, null, false);
evQueue.postEvent(ev);
}
}
diff --git a/javax/swing/ToolTipManager.java b/javax/swing/ToolTipManager.java
index 963ccf881..152fc0343 100644
--- a/javax/swing/ToolTipManager.java
+++ b/javax/swing/ToolTipManager.java
@@ -163,16 +163,21 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
private static ToolTipManager shared;
/** The current component the tooltip is being displayed for. */
- private static Component currentComponent;
+ private JComponent currentComponent;
/** The current tooltip. */
- private static JToolTip currentTip;
+ private JToolTip currentTip;
+
+ /**
+ * The tooltip text.
+ */
+ private String toolTipText;
/** The last known position of the mouse cursor. */
- private static Point currentPoint;
-
+ private Point currentPoint;
+
/** */
- private static Popup popup;
+ private Popup popup;
/**
* Creates a new ToolTipManager and sets up the timers.
@@ -364,8 +369,8 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
return;
currentPoint = event.getPoint();
- currentComponent = (Component) event.getSource();
-
+ currentComponent = (JComponent) event.getSource();
+ toolTipText = currentComponent.getToolTipText(event);
if (exitTimer.isRunning())
{
exitTimer.stop();
@@ -443,8 +448,52 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
public void mouseMoved(MouseEvent event)
{
currentPoint = event.getPoint();
- if (enterTimer.isRunning())
- enterTimer.restart();
+ if (currentTip != null && currentTip.isShowing())
+ checkTipUpdate(event);
+ else
+ {
+ if (enterTimer.isRunning())
+ enterTimer.restart();
+ }
+ }
+
+ /**
+ * Checks if the tooltip's text or location changes when the mouse is moved
+ * over the component.
+ */
+ private void checkTipUpdate(MouseEvent ev)
+ {
+ JComponent comp = (JComponent) ev.getSource();
+ String newText = comp.getToolTipText(ev);
+ String oldText = toolTipText;
+ if (newText != null)
+ {
+ if (((newText != null && newText.equals(oldText)) || newText == null))
+ {
+ // No change at all. Restart timers.
+ if (popup == null)
+ enterTimer.restart();
+ else
+ insideTimer.restart();
+ }
+ else
+ {
+ // Update the tooltip.
+ toolTipText = newText;
+ hideTip();
+ showTip();
+ exitTimer.stop();
+ }
+ }
+ else
+ {
+ // Hide tooltip.
+ currentTip = null;
+ currentPoint = null;
+ hideTip();
+ enterTimer.stop();
+ exitTimer.stop();
+ }
}
/**
@@ -461,9 +510,9 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
return;
}
- if (currentTip == null || currentTip.getComponent() != currentComponent
- && currentComponent instanceof JComponent)
- currentTip = ((JComponent) currentComponent).createToolTip();
+ if (currentTip == null || currentTip.getComponent() != currentComponent)
+ currentTip = currentComponent.createToolTip();
+ currentTip.setTipText(toolTipText);
Point p = currentPoint;
Point cP = currentComponent.getLocationOnScreen();
@@ -531,8 +580,8 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
private Component getContentPaneDeepestComponent(MouseEvent e)
{
Component source = (Component) e.getSource();
- Container parent = (Container) SwingUtilities.getAncestorOfClass(JRootPane.class,
- currentComponent);
+ Container parent = SwingUtilities.getAncestorOfClass(JRootPane.class,
+ currentComponent);
if (parent == null)
return null;
parent = ((JRootPane) parent).getContentPane();
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index 40a36b27d..d594a8244 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -44,12 +44,117 @@ import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
import java.io.Serializable;
+import java.lang.reflect.Method;
public class TransferHandler implements Serializable
{
+
+ /**
+ * An implementation of {@link Transferable} that can be used to export
+ * data from a component's property.
+ */
+ private static class PropertyTransferable
+ implements Transferable
+ {
+ /**
+ * The component from which we export.
+ */
+ private JComponent component;
+
+ /**
+ * The property descriptor of the property that we handle.
+ */
+ private PropertyDescriptor property;
+
+ /**
+ * Creates a new PropertyTransferable.
+ *
+ * @param c the component from which we export
+ * @param prop the property from which we export
+ */
+ PropertyTransferable(JComponent c, PropertyDescriptor prop)
+ {
+ component = c;
+ property = prop;
+ }
+
+ /**
+ * Returns the data flavors supported by the Transferable.
+ *
+ * @return the data flavors supported by the Transferable
+ */
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ DataFlavor[] flavors;
+ Class propClass = property.getPropertyType();
+ String mime = DataFlavor.javaJVMLocalObjectMimeType + "; class="
+ + propClass.getName();
+ try
+ {
+ DataFlavor flavor = new DataFlavor(mime);
+ flavors = new DataFlavor[]{ flavor };
+ }
+ catch (ClassNotFoundException ex)
+ {
+ flavors = new DataFlavor[0];
+ }
+ return flavors;
+ }
+
+ /**
+ * Returns <code>true</code> when the specified data flavor is supported,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> when the specified data flavor is supported,
+ * <code>false</code> otherwise
+ */
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ Class propClass = property.getPropertyType();
+ return flavor.getPrimaryType().equals("application")
+ && flavor.getSubType().equals("x-java-jvm-local-objectref")
+ && propClass.isAssignableFrom(flavor.getRepresentationClass());
+ }
+
+ /**
+ * Returns the actual transfer data.
+ *
+ * @param flavor the data flavor
+ *
+ * @return the actual transfer data
+ */
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException
+ {
+ if (isDataFlavorSupported(flavor))
+ {
+ Method getter = property.getReadMethod();
+ Object o;
+ try
+ {
+ o = getter.invoke(component, null);
+ return o;
+ }
+ catch (Exception ex)
+ {
+ throw new IOException("Property read failed: "
+ + property.getName());
+ }
+ }
+ else
+ throw new UnsupportedFlavorException(flavor);
+ }
+ }
+
static class TransferAction extends AbstractAction
{
private String command;
@@ -123,7 +228,13 @@ public class TransferHandler implements Serializable
private int sourceActions;
private Icon visualRepresentation;
-
+
+ /**
+ * The name of the property into/from which this TransferHandler
+ * imports/exports.
+ */
+ private String propertyName;
+
public static Action getCopyAction()
{
return copyAction;
@@ -146,19 +257,78 @@ public class TransferHandler implements Serializable
public TransferHandler(String property)
{
+ propertyName = property;
this.sourceActions = property != null ? COPY : NONE;
}
+ /**
+ * Returns <code>true</code> if the data in this TransferHandler can be
+ * imported into the specified component. This will be the case when:
+ * <ul>
+ * <li>The component has a readable and writable property with the property
+ * name specified in the TransferHandler constructor.</li>
+ * <li>There is a dataflavor with a mime type of
+ * <code>application/x-java-jvm-local-object-ref</code>.</li>
+ * <li>The dataflavor's representation class matches the class of the
+ * property in the component.</li>
+ * </li>
+ *
+ * @param c the component to check
+ * @param flavors the possible data flavors
+ *
+ * @return <code>true</code> if the data in this TransferHandler can be
+ * imported into the specified component, <code>false</code>
+ * otherwise
+ */
public boolean canImport(JComponent c, DataFlavor[] flavors)
- throws NotImplementedException
{
- return false;
+ PropertyDescriptor propDesc = getPropertyDescriptor(c);
+ boolean canImport = false;
+ if (propDesc != null)
+ {
+ // Check if the property is writable. The readable check is already
+ // done in getPropertyDescriptor().
+ Method writer = propDesc.getWriteMethod();
+ if (writer != null)
+ {
+ Class[] params = writer.getParameterTypes();
+ if (params.length == 1)
+ {
+ // Number of parameters ok, now check mime type and
+ // representation class.
+ DataFlavor flavor = getPropertyDataFlavor(params[0], flavors);
+ if (flavor != null)
+ canImport = true;
+ }
+ }
+ }
+ return canImport;
}
+ /**
+ * Creates a {@link Transferable} that can be used to export data
+ * from the specified component.
+ *
+ * This method returns <code>null</code> when the specified component
+ * doesn't have a readable property that matches the property name
+ * specified in the <code>TransferHandler</code> constructor.
+ *
+ * @param c the component to create a transferable for
+ *
+ * @return a {@link Transferable} that can be used to export data
+ * from the specified component, or null if the component doesn't
+ * have a readable property like the transfer handler
+ */
protected Transferable createTransferable(JComponent c)
- throws NotImplementedException
{
- return null;
+ Transferable transferable = null;
+ if (propertyName != null)
+ {
+ PropertyDescriptor prop = getPropertyDescriptor(c);
+ if (prop != null)
+ transferable = new PropertyTransferable(c, prop);
+ }
+ return transferable;
}
public void exportAsDrag(JComponent c, InputEvent e, int action)
@@ -167,16 +337,64 @@ public class TransferHandler implements Serializable
// TODO: Implement this properly
}
- protected void exportDone(JComponent c, Transferable data, int action)
- throws NotImplementedException
+ /**
+ * This method is invoked after data has been exported.
+ * Subclasses should implement this method to remove the data that has been
+ * transferred when the action was <code>MOVE</code>.
+ *
+ * The default implementation does nothing because MOVE is not supported.
+ *
+ * @param c the source component
+ * @param data the data that has been transferred or <code>null</code>
+ * when the action is NONE
+ * @param action the action that has been performed
+ */
+ protected void exportDone(JComponent c, Transferable data, int action)
{
- // TODO: Implement this properly
+ // Nothing to do in the default implementation.
}
+ /**
+ * Exports the property of the component <code>c</code> that was
+ * specified for this TransferHandler to the clipboard, performing
+ * the specified action.
+ *
+ * This will check if the action is allowed by calling
+ * {@link #getSourceActions(JComponent)}. If the action is not allowed,
+ * then no export is performed.
+ *
+ * In either case the method {@link #exportDone} will be called with
+ * the action that has been performed, or {@link #NONE} if the action
+ * was not allowed or could otherwise not be completed.
+ * Any IllegalStateException that is thrown by the Clipboard due to
+ * beeing unavailable will be propagated through this method.
+ *
+ * @param c the component from which to export
+ * @param clip the clipboard to which the data will be exported
+ * @param action the action to perform
+ *
+ * @throws IllegalStateException when the clipboard is not available
+ */
public void exportToClipboard(JComponent c, Clipboard clip, int action)
- throws NotImplementedException
+ throws IllegalStateException
{
- // TODO: Implement this properly
+ action &= getSourceActions(c);
+ Transferable transferable = createTransferable(c);
+ if (transferable != null && action != NONE)
+ {
+ try
+ {
+ clip.setContents(transferable, null);
+ exportDone(c, transferable, action);
+ }
+ catch (IllegalStateException ex)
+ {
+ exportDone(c, transferable, NONE);
+ throw ex;
+ }
+ }
+ else
+ exportDone(c, null, NONE);
}
public int getSourceActions(JComponent c)
@@ -189,9 +407,124 @@ public class TransferHandler implements Serializable
return visualRepresentation;
}
+ /**
+ * Imports the transfer data represented by <code>t</code> into the specified
+ * component <code>c</code> by setting the property of this TransferHandler
+ * on that component. If this succeeds, this method returns
+ * <code>true</code>, otherwise <code>false</code>.
+ *
+ *
+ * @param c the component to import into
+ * @param t the transfer data to import
+ *
+ * @return <code>true</code> if the transfer succeeds, <code>false</code>
+ * otherwise
+ */
public boolean importData(JComponent c, Transferable t)
- throws NotImplementedException
{
- return false;
+ boolean ok = false;
+ PropertyDescriptor prop = getPropertyDescriptor(c);
+ if (prop != null)
+ {
+ Method writer = prop.getWriteMethod();
+ if (writer != null)
+ {
+ Class[] params = writer.getParameterTypes();
+ if (params.length == 1)
+ {
+ DataFlavor flavor = getPropertyDataFlavor(params[0],
+ t.getTransferDataFlavors());
+ if (flavor != null)
+ {
+ try
+ {
+ Object value = t.getTransferData(flavor);
+ writer.invoke(c, new Object[]{ value });
+ ok = true;
+ }
+ catch (Exception ex)
+ {
+ // If anything goes wrong here, do nothing and return
+ // false;
+ }
+ }
+ }
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * Returns the property descriptor for the property of this TransferHandler
+ * in the specified component, or <code>null</code> if no such property
+ * exists in the component. This method only returns properties that are
+ * at least readable (that is, it has a public no-arg getter method).
+ *
+ * @param c the component to check
+ *
+ * @return the property descriptor for the property of this TransferHandler
+ * in the specified component, or <code>null</code> if no such
+ * property exists in the component
+ */
+ private PropertyDescriptor getPropertyDescriptor(JComponent c)
+ {
+ PropertyDescriptor prop = null;
+ if (propertyName != null)
+ {
+ Class clazz = c.getClass();
+ BeanInfo beanInfo;
+ try
+ {
+ beanInfo = Introspector.getBeanInfo(clazz);
+ }
+ catch (IntrospectionException ex)
+ {
+ beanInfo = null;
+ }
+ if (beanInfo != null)
+ {
+ PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
+ for (int i = 0; i < props.length && prop == null; i++)
+ {
+ PropertyDescriptor desc = props[i];
+ if (desc.getName().equals(propertyName))
+ {
+ Method reader = desc.getReadMethod();
+ if (reader != null)
+ {
+ Class[] params = reader.getParameterTypes();
+ if (params == null || params.length == 0)
+ prop = desc;
+ }
+ }
+ }
+ }
+ }
+ return prop;
+ }
+
+ /**
+ * Searches <code>flavors</code> to find a suitable data flavor that
+ * has the mime type application/x-java-jvm-local-objectref and a
+ * representation class that is the same as the specified <code>clazz</code>.
+ * When no such data flavor is found, this returns <code>null</code>.
+ *
+ * @param clazz the representation class required for the data flavor
+ * @param flavors the possible data flavors
+ *
+ * @return the suitable data flavor or null if none is found
+ */
+ private DataFlavor getPropertyDataFlavor(Class clazz, DataFlavor[] flavors)
+ {
+ DataFlavor found = null;
+ for (int i = 0; i < flavors.length && found == null; i++)
+ {
+ DataFlavor flavor = flavors[i];
+ if (flavor.getPrimaryType().equals("application")
+ && flavor.getSubType().equals("x-java-jvm-local-objectref")
+ && clazz.isAssignableFrom(flavor.getRepresentationClass()))
+ found = flavor;
+ }
+ return found;
}
}
diff --git a/javax/swing/filechooser/FileSystemView.java b/javax/swing/filechooser/FileSystemView.java
index 26ca4860c..41d865a96 100644
--- a/javax/swing/filechooser/FileSystemView.java
+++ b/javax/swing/filechooser/FileSystemView.java
@@ -37,8 +37,6 @@ exception statement from your version. */
package javax.swing.filechooser;
-import gnu.classpath.NotImplementedException;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -171,7 +169,6 @@ public abstract class FileSystemView
* @return A default {@link FileSystemView} appropriate for the platform.
*/
public static FileSystemView getFileSystemView()
- throws NotImplementedException
{
if (defaultFileSystemView == null)
{
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 76d67b002..154309454 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -1062,8 +1062,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ProgressBar.repaintInterval", new Integer(50),
"ProgressBar.cycleTime", new Integer(3000),
"RadioButton.background", new ColorUIResource(light),
- "RadioButton.border", new BorderUIResource.CompoundBorderUIResource(null,
- null),
+ "RadioButton.border", BasicBorders.getRadioButtonBorder(),
"RadioButton.darkShadow", new ColorUIResource(shadow),
"RadioButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
KeyStroke.getKeyStroke("SPACE"), "pressed",
@@ -1183,6 +1182,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Slider.thumbHeight", new Integer(20),
"Slider.thumbWidth", new Integer(11),
"Slider.tickHeight", new Integer(12),
+ "Slider.horizontalSize", new Dimension(200, 21),
+ "Slider.verticalSize", new Dimension(21, 200),
+ "Slider.minimumHorizontalSize", new Dimension(36, 21),
+ "Slider.minimumVerticalSize", new Dimension(21, 36),
"Spinner.background", new ColorUIResource(light),
"Spinner.foreground", new ColorUIResource(light),
"Spinner.arrowButtonSize", new DimensionUIResource(16, 5),
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index 87dce2ef4..5fafb4108 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -364,7 +364,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected void doClick(MenuSelectionManager msm)
{
- menuItem.doClick();
+ menuItem.doClick(0);
msm.clearSelectedPath();
}
@@ -1058,15 +1058,14 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void mouseReleased(MouseEvent e)
{
- Rectangle size = menuItem.getBounds();
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
- && e.getY() < size.height)
+ int x = e.getX();
+ int y = e.getY();
+ if (x > 0 && x < menuItem.getWidth() && y > 0
+ && y < menuItem.getHeight())
{
- manager.clearSelectedPath();
- menuItem.doClick();
+ doClick(manager);
}
-
else
manager.processMouseEvent(e);
}
@@ -1085,7 +1084,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ MenuSelectionManager manager = e.getMenuSelectionManager();
manager.setSelectedPath(e.getPath());
}
@@ -1098,7 +1097,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ MenuSelectionManager manager = e.getMenuSelectionManager();
manager.setSelectedPath(e.getPath());
}
@@ -1110,7 +1109,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here yet.
}
/**
@@ -1122,13 +1121,14 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
- MenuElement[] path = e.getPath();
-
- if (path[path.length - 1] instanceof JMenuItem)
- ((JMenuItem) path[path.length - 1]).doClick();
-
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- manager.clearSelectedPath();
+ MenuSelectionManager manager = e.getMenuSelectionManager();
+ int x = e.getX();
+ int y = e.getY();
+ if (x >= 0 && x < menuItem.getWidth() && y >= 0
+ && y < menuItem.getHeight())
+ doClick(manager);
+ else
+ manager.clearSelectedPath();
}
}
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index fb84cf443..bfb9e98db 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -52,6 +52,7 @@ import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+import javax.swing.text.View;
/**
* The BasicLookAndFeel UI implementation for
@@ -129,52 +130,92 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
public void paint(Graphics g, JComponent c)
{
AbstractButton b = (AbstractButton) c;
-
+ Dimension size = c.getSize();
Insets i = b.getInsets();
- Rectangle tr = textR;
textR.x = 0;
textR.y = 0;
textR.width = 0;
textR.height = 0;
- Rectangle ir = iconR;
iconR.x = 0;
iconR.y = 0;
iconR.width = 0;
iconR.height = 0;
- Rectangle vr = viewR;
viewR.x = i.left;
viewR.y = i.right;
- viewR.width = b.getWidth() - i.left - i.right;
- viewR.height = b.getHeight() - i.top - i.bottom;
+ viewR.width = size.width - i.left - i.right;
+ viewR.height = size.height - i.top - i.bottom;
Font f = c.getFont();
g.setFont(f);
ButtonModel m = b.getModel();
- // FIXME: Do a filtering on any customized icon if the following property
- // is set.
- boolean enabled = b.isEnabled();
-
- Icon currentIcon = b.getIcon();
- if (currentIcon == null)
- {
- currentIcon = getDefaultIcon();
- }
-
+ // This is the icon that we use for layout.
+ Icon icon = b.getIcon();
+ if (icon == null)
+ icon = getDefaultIcon();
+
+ // Do the layout.
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
- b.getText(), currentIcon,
+ b.getText(), icon,
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
- vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
+ viewR, iconR, textR, b.getIconTextGap());
- currentIcon.paintIcon(c, g, ir.x, ir.y);
-
+ // Figure out the correct icon.
+ icon = b.getIcon();
+ if (icon == null)
+ icon = getDefaultIcon();
+ else
+ {
+ if (! m.isEnabled())
+ {
+ if (m.isSelected())
+ icon = b.getDisabledSelectedIcon();
+ else
+ icon = b.getDisabledIcon();
+ }
+ else if (m.isArmed() && m.isPressed())
+ {
+ icon = b.getPressedIcon();
+ if (icon == null)
+ icon = b.getSelectedIcon();
+ }
+ else if (m.isSelected())
+ {
+ if (b.isRolloverEnabled() && m.isRollover())
+ {
+ icon = b.getRolloverSelectedIcon();
+ if (icon == null)
+ icon = b.getSelectedIcon();
+ }
+ else
+ icon = b.getSelectedIcon();
+ }
+ else if (b.isRolloverEnabled() && m.isRollover())
+ icon = b.getRolloverIcon();
+ if (icon == null)
+ icon = b.getIcon();
+ }
+ // .. and paint it.
+ icon.paintIcon(c, g, iconR.x, iconR.y);
+
+ // Paint text and focus indicator.
if (text != null)
- paintText(g, b, tr, text);
- if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
- paintFocus(g, tr, c.getSize());
+ {
+ // Maybe render HTML in the radio button.
+ View v = (View) c.getClientProperty(BasicHTML.propertyKey);
+ if (v != null)
+ v.paint(g, textR);
+ else
+ paintText(g, b, textR, text);
+
+ // Paint focus indicator if necessary.
+ if (b.hasFocus() && b.isFocusPainted()
+ && textR.width > 0 && textR.height > 0)
+ paintFocus(g, textR, size);
+ }
}
public Dimension getPreferredSize(JComponent c)
@@ -207,17 +248,14 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
viewR.width = Short.MAX_VALUE;
viewR.height = Short.MAX_VALUE;
- SwingUtilities.layoutCompoundLabel(
- b, // for the component orientation
- b.getFontMetrics(b.getFont()),
- b.getText(),
- i,
- b.getVerticalAlignment(),
- b.getHorizontalAlignment(),
- b.getVerticalTextPosition(),
- b.getHorizontalTextPosition(),
- viewR, iconR, textR,
- defaultTextIconGap + defaultTextShiftOffset);
+ SwingUtilities.layoutCompoundLabel(b, // for the component orientation
+ b.getFontMetrics(b.getFont()),
+ text, i, b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ viewR, iconR, textR,
+ text == null ? 0 : b.getIconTextGap());
Rectangle r = SwingUtilities.computeUnion(textR.x, textR.y, textR.width,
textR.height, iconR);
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index 5205724b5..400ede03c 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -1225,12 +1225,36 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void scrollByBlock(int direction)
{
+ scrollByBlock(scrollbar, direction);
+ }
+
+ /**
+ * Scrolls the specified <code>scrollBar</code> by one block (according
+ * to the scrollable protocol) in the specified <code>direction</code>.
+ *
+ * This method is here statically to support wheel scrolling from the
+ * BasicScrollPaneUI without code duplication.
+ *
+ * @param scrollBar the scrollbar to scroll
+ * @param direction the scroll direction
+ */
+ static final void scrollByBlock(JScrollBar scrollBar, int direction)
+ {
+ int delta;
if (direction > 0)
- scrollbar.setValue(scrollbar.getValue()
- + scrollbar.getBlockIncrement(direction));
+ delta = scrollBar.getBlockIncrement(direction);
else
- scrollbar.setValue(scrollbar.getValue()
- - scrollbar.getBlockIncrement(direction));
+ delta = - scrollBar.getBlockIncrement(direction);
+ int oldValue = scrollBar.getValue();
+ int newValue = oldValue + delta;
+
+ // Overflow check.
+ if (delta > 0 && newValue < oldValue)
+ newValue = scrollBar.getMaximum();
+ else if (delta < 0 && newValue > oldValue)
+ newValue = scrollBar.getMinimum();
+
+ scrollBar.setValue(newValue);
}
/**
@@ -1240,12 +1264,46 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void scrollByUnit(int direction)
{
- if (direction > 0)
- scrollbar.setValue(scrollbar.getValue()
- + scrollbar.getUnitIncrement(direction));
- else
- scrollbar.setValue(scrollbar.getValue()
- - scrollbar.getUnitIncrement(direction));
+ scrollByUnits(scrollbar, direction, 1);
+ }
+
+ /**
+ * Scrolls the specified <code>scrollbac/code> by <code>units</code> units
+ * in the specified <code>direction</code>.
+ *
+ * This method is here statically to support wheel scrolling from the
+ * BasicScrollPaneUI without code duplication.
+ *
+ * @param scrollBar the scrollbar to scroll
+ * @param direction the direction
+ * @param units the number of units to scroll
+ */
+ static final void scrollByUnits(JScrollBar scrollBar, int direction,
+ int units)
+ {
+ // Do this inside a loop so that we don't clash with the scrollable
+ // interface, which can return different units at times. For instance,
+ // a Scrollable could return a unit of 2 pixels only to adjust the
+ // visibility of an item. If we would simply multiply this by units,
+ // then we would only get 6 pixels, which is complete crap.
+ for (int i = 0; i < units; i++)
+ {
+ int delta;
+ if (direction > 0)
+ delta = scrollBar.getUnitIncrement(direction);
+ else
+ delta = - scrollBar.getUnitIncrement(direction);
+ int oldValue = scrollBar.getValue();
+ int newValue = oldValue + delta;
+
+ // Overflow check.
+ if (delta > 0 && newValue < oldValue)
+ newValue = scrollBar.getMaximum();
+ else if (delta < 0 && newValue > oldValue)
+ newValue = scrollBar.getMinimum();
+
+ scrollBar.setValue(newValue);
+ }
}
/**
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
index 236eac073..a71942840 100644
--- a/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
@@ -62,8 +61,6 @@ import javax.swing.JViewport;
import javax.swing.LookAndFeel;
import javax.swing.ScrollPaneConstants;
import javax.swing.ScrollPaneLayout;
-import javax.swing.Scrollable;
-import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
@@ -229,103 +226,24 @@ public class BasicScrollPaneUI extends ScrollPaneUI
*/
public void mouseWheelMoved(MouseWheelEvent e)
{
- if (scrollpane.getViewport().getComponentCount() == 0)
- return;
-
- Component target = scrollpane.getViewport().getComponent(0);
- JScrollBar bar = scrollpane.getVerticalScrollBar();
- Scrollable scrollable = (target instanceof Scrollable) ? (Scrollable) target
- : null;
-
- boolean tracksHeight = scrollable != null
- && scrollable.getScrollableTracksViewportHeight();
- int wheel = e.getWheelRotation() * ROWS_PER_WHEEL_CLICK;
- int delta;
-
- // If possible, scroll vertically.
- if (bar != null && ! tracksHeight)
- {
- if (scrollable != null)
- {
- bounds(target);
- delta = scrollable.getScrollableUnitIncrement(
- rect, SwingConstants.VERTICAL, wheel);
- }
- else
- {
- // Scroll non scrollables.
- delta = wheel * SCROLL_NON_SCROLLABLES;
- }
- scroll(bar, wheel > 0 ? delta : -delta);
- }
- // If not, try to scroll horizontally
- else
+ if (scrollpane.isWheelScrollingEnabled() && e.getScrollAmount() != 0)
{
- bar = scrollpane.getHorizontalScrollBar();
- boolean tracksWidth = scrollable != null
- && scrollable.getScrollableTracksViewportWidth();
-
- if (bar != null && ! tracksWidth)
+ // Try to scroll vertically first.
+ JScrollBar scrollBar = scrollpane.getVerticalScrollBar();
+ if (scrollBar == null || ! scrollBar.isVisible())
+ scrollBar = scrollpane.getHorizontalScrollBar();
+ if (scrollBar != null && scrollBar.isVisible())
{
- if (scrollable != null)
- {
- bounds(target);
- delta = scrollable.getScrollableUnitIncrement(
- rect, SwingConstants.HORIZONTAL, wheel);
- }
- else
- {
- // Scroll non scrollables.
- delta = wheel * SCROLL_NON_SCROLLABLES;
- }
- scroll(bar, delta);
+ int direction = e.getWheelRotation() < 0 ? -1 : 1;
+ int scrollType = e.getScrollType();
+ if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL)
+ BasicScrollBarUI.scrollByUnits(scrollBar, direction,
+ e.getScrollAmount());
+ else if (scrollType == MouseWheelEvent.WHEEL_BLOCK_SCROLL)
+ BasicScrollBarUI.scrollByBlock(scrollBar, direction);
}
}
}
-
- /**
- * Place the component bounds into rect. The x and y values
- * need to be reversed.
- *
- * @param target the target being scrolled
- */
- final void bounds(Component target)
- {
- // Viewport bounds, translated by the scroll bar positions.
- target.getParent().getBounds(rect);
- rect.x = getValue(scrollpane.getHorizontalScrollBar());
- rect.y = getValue(scrollpane.getVerticalScrollBar());
- }
-
- /**
- * Get the scroll bar value or 0 if there is no such scroll bar.
- *
- * @param bar the scroll bar (<code>null</code> permitted).
- *
- * @return The scroll bar value, or 0.
- */
- final int getValue(JScrollBar bar)
- {
- return bar != null ? bar.getValue() : 0;
- }
-
- /**
- * Scroll the given distance.
- *
- * @param bar the scrollbar to scroll
- * @param delta the distance
- */
- final void scroll(JScrollBar bar, int delta)
- {
- int y = bar.getValue() + delta;
-
- if (y < bar.getMinimum())
- y = bar.getMinimum();
- if (y > bar.getMaximum())
- y = bar.getMaximum();
-
- bar.setValue(y);
- }
}
/**
diff --git a/javax/swing/plaf/basic/BasicSliderUI.java b/javax/swing/plaf/basic/BasicSliderUI.java
index 3811eebdf..474a42256 100644
--- a/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/javax/swing/plaf/basic/BasicSliderUI.java
@@ -40,7 +40,6 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Component;
-import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
@@ -65,7 +64,6 @@ import javax.swing.ActionMap;
import javax.swing.BoundedRangeModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
-import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
@@ -185,8 +183,6 @@ public class BasicSliderUI extends SliderUI
public void componentResized(ComponentEvent e)
{
calculateGeometry();
-
- slider.revalidate();
slider.repaint();
}
}
@@ -209,7 +205,6 @@ public class BasicSliderUI extends SliderUI
public void focusGained(FocusEvent e)
{
slider.repaint();
- hasFocus = true;
}
/**
@@ -221,7 +216,6 @@ public class BasicSliderUI extends SliderUI
public void focusLost(FocusEvent e)
{
slider.repaint();
- hasFocus = false;
}
}
@@ -240,25 +234,27 @@ public class BasicSliderUI extends SliderUI
public void propertyChange(PropertyChangeEvent e)
{
// Check for orientation changes.
- if (e.getPropertyName().equals("orientation"))
- recalculateIfOrientationChanged();
+ String prop = e.getPropertyName();
+ if (prop.equals("orientation")
+ || prop.equals("inverted")
+ || prop.equals("labelTable")
+ || prop.equals("majorTickSpacing")
+ || prop.equals("minorTickSpacing")
+ || prop.equals("paintTicks")
+ || prop.equals("paintTrack")
+ || prop.equals("paintLabels"))
+ {
+ calculateGeometry();
+ slider.repaint();
+ }
else if (e.getPropertyName().equals("model"))
{
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue();
oldModel.removeChangeListener(changeListener);
slider.getModel().addChangeListener(changeListener);
calculateThumbLocation();
+ slider.repaint();
}
- else if (e.getPropertyName().equals("paintTicks"))
- calculateGeometry();
-
- // elif the componentOrientation changes (this is a bound property,
- // just undocumented) we change leftToRightCache. In Sun's
- // implementation, the LTR cache changes on a repaint. This is strange
- // since there is no need to do so. We could events here and
- // update the cache.
- // elif the border/insets change, we recalculateInsets.
- slider.repaint();
}
}
@@ -466,6 +462,7 @@ public class BasicSliderUI extends SliderUI
if (scrollTimer != null)
scrollTimer.stop();
}
+ slider.repaint();
}
/**
@@ -592,10 +589,7 @@ public class BasicSliderUI extends SliderUI
/** The focus color. */
private transient Color focusColor;
-
- /** True if the slider has focus. */
- private transient boolean hasFocus;
-
+
/** True if the user is dragging the slider. */
boolean dragging;
@@ -935,36 +929,10 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getPreferredHorizontalSize()
{
- Insets insets = slider.getInsets();
-
- // The width should cover all the labels (which are usually the
- // deciding factor of the width)
- int width = getWidthOfWidestLabel() * (slider.getLabelTable() == null ? 0
- : slider.getLabelTable().size());
-
- // If there are not enough labels.
- // This number is pretty much arbitrary, but it looks nice.
- if (width < 200)
- width = 200;
-
- // We can only draw inside of the focusRectangle, so we have to
- // pad it with insets.
- width += insets.left + insets.right + focusInsets.left + focusInsets.right;
-
- // Height is determined by the thumb, the ticks and the labels.
- int height = getThumbSize().height;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- height += getTickLength();
-
- if (slider.getPaintLabels())
- height += getHeightOfTallestLabel();
-
- height += insets.top + insets.bottom + focusInsets.top
- + focusInsets.bottom;
-
- return new Dimension(width, height);
+ Dimension dim = UIManager.getDimension("Slider.horizontalSize");
+ if (dim == null) // Just to be sure we mirror the default.
+ dim = new Dimension(200, 21);
+ return dim;
}
/**
@@ -975,30 +943,10 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getPreferredVerticalSize()
{
- Insets insets = slider.getInsets();
-
- int height = getHeightOfTallestLabel() * (slider.getLabelTable() == null
- ? 0 : slider.getLabelTable()
- .size());
-
- if (height < 200)
- height = 200;
-
- height += insets.top + insets.bottom + focusInsets.top
- + focusInsets.bottom;
-
- int width = getThumbSize().width;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- width += getTickLength();
-
- if (slider.getPaintLabels())
- width += getWidthOfWidestLabel();
-
- width += insets.left + insets.right + focusInsets.left + focusInsets.right;
-
- return new Dimension(width, height);
+ Dimension dim = UIManager.getDimension("Slider.verticalSize");
+ if (dim == null) // Just to be sure we mirror the default.
+ dim = new Dimension(21, 200);
+ return dim;
}
/**
@@ -1009,21 +957,10 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMinimumHorizontalSize()
{
- Insets insets = slider.getInsets();
- // Height is determined by the thumb, the ticks and the labels.
- int height = getThumbSize().height;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- height += getTickLength();
-
- if (slider.getPaintLabels())
- height += getHeightOfTallestLabel();
-
- height += insets.top + insets.bottom + focusInsets.top
- + focusInsets.bottom;
-
- return new Dimension(36, height);
+ Dimension dim = UIManager.getDimension("Slider.minimumHorizontalSize");
+ if (dim == null) // Just to be sure we mirror the default.
+ dim = new Dimension(36, 21);
+ return dim;
}
/**
@@ -1034,19 +971,10 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMinimumVerticalSize()
{
- Insets insets = slider.getInsets();
- int width = getThumbSize().width;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- width += getTickLength();
-
- if (slider.getPaintLabels())
- width += getWidthOfWidestLabel();
-
- width += insets.left + insets.right + focusInsets.left + focusInsets.right;
-
- return new Dimension(width, 36);
+ Dimension dim = UIManager.getDimension("Slider.minimumVerticalSize");
+ if (dim == null) // Just to be sure we mirror the default.
+ dim = new Dimension(21, 36);
+ return dim;
}
/**
@@ -1060,10 +988,25 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getPreferredSize(JComponent c)
{
+ recalculateIfInsetsChanged();
+ Dimension dim;
if (slider.getOrientation() == JSlider.HORIZONTAL)
- return getPreferredHorizontalSize();
+ {
+ // Create copy here to protect the UIManager value.
+ dim = new Dimension(getPreferredHorizontalSize());
+ dim.height = insetCache.top + insetCache.bottom;
+ dim.height += focusInsets.top + focusInsets.bottom;
+ dim.height += trackRect.height + tickRect.height + labelRect.height;
+ }
else
- return getPreferredVerticalSize();
+ {
+ // Create copy here to protect the UIManager value.
+ dim = new Dimension(getPreferredVerticalSize());
+ dim.width = insetCache.left + insetCache.right;
+ dim.width += focusInsets.left + focusInsets.right;
+ dim.width += trackRect.width + tickRect.width + labelRect.width;
+ }
+ return dim;
}
/**
@@ -1077,10 +1020,25 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMinimumSize(JComponent c)
{
+ recalculateIfInsetsChanged();
+ Dimension dim;
if (slider.getOrientation() == JSlider.HORIZONTAL)
- return getMinimumHorizontalSize();
+ {
+ // Create copy here to protect the UIManager value.
+ dim = new Dimension(getMinimumHorizontalSize());
+ dim.height = insetCache.top + insetCache.bottom;
+ dim.height += focusInsets.top + focusInsets.bottom;
+ dim.height += trackRect.height + tickRect.height + labelRect.height;
+ }
else
- return getMinimumVerticalSize();
+ {
+ // Create copy here to protect the UIManager value.
+ dim = new Dimension(getMinimumVerticalSize());
+ dim.width = insetCache.left + insetCache.right;
+ dim.width += focusInsets.left + focusInsets.right;
+ dim.width += trackRect.width + tickRect.width + labelRect.width;
+ }
+ return dim;
}
/**
@@ -1093,40 +1051,12 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMaximumSize(JComponent c)
{
- Insets insets = slider.getInsets();
+ Dimension dim = getPreferredSize(c);
if (slider.getOrientation() == JSlider.HORIZONTAL)
- {
- // Height is determined by the thumb, the ticks and the labels.
- int height = getThumbSize().height;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- height += getTickLength();
-
- if (slider.getPaintLabels())
- height += getHeightOfTallestLabel();
-
- height += insets.top + insets.bottom + focusInsets.top
- + focusInsets.bottom;
-
- return new Dimension(32767, height);
- }
+ dim.width = Short.MAX_VALUE;
else
- {
- int width = getThumbSize().width;
-
- if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0)
- width += getTickLength();
-
- if (slider.getPaintLabels())
- width += getWidthOfWidestLabel();
-
- width += insets.left + insets.right + focusInsets.left
- + focusInsets.right;
-
- return new Dimension(width, 32767);
- }
+ dim.height = Short.MAX_VALUE;
+ return dim;
}
/**
@@ -1151,12 +1081,10 @@ public class BasicSliderUI extends SliderUI
*/
protected void calculateFocusRect()
{
- insetCache = slider.getInsets();
- focusRect = SwingUtilities.calculateInnerArea(slider, focusRect);
- if (focusRect.width < 0)
- focusRect.width = 0;
- if (focusRect.height < 0)
- focusRect.height = 0;
+ focusRect.x = insetCache.left;
+ focusRect.y = insetCache.top;
+ focusRect.width = slider.getWidth() - insetCache.left - insetCache.right;
+ focusRect.height = slider.getHeight() - insetCache.top - insetCache.bottom;
}
/**
@@ -1181,13 +1109,8 @@ public class BasicSliderUI extends SliderUI
contentRect.y = focusRect.y + focusInsets.top;
contentRect.width = focusRect.width - focusInsets.left - focusInsets.right;
- contentRect.height = focusRect.height - focusInsets.top
- - focusInsets.bottom;
-
- if (contentRect.width < 0)
- contentRect.width = 0;
- if (contentRect.height < 0)
- contentRect.height = 0;
+ contentRect.height = focusRect.height - focusInsets.top
+ - focusInsets.bottom;
}
/**
@@ -1258,26 +1181,24 @@ public class BasicSliderUI extends SliderUI
{
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
- trackRect.x = contentRect.x + trackBuffer;
- int h = getThumbSize().height;
- if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0))
- h += getTickLength();
+ int center = thumbRect.height;
+ if (slider.getPaintTicks())
+ center += getTickLength();
if (slider.getPaintLabels())
- h += getHeightOfTallestLabel();
- trackRect.y = contentRect.y + (contentRect.height - h) / 2 - 1;
+ center += getHeightOfTallestLabel();
+ trackRect.x = contentRect.x + trackBuffer;
+ trackRect.y = contentRect.y + (contentRect.height - center - 1) / 2;
trackRect.width = contentRect.width - 2 * trackBuffer;
trackRect.height = thumbRect.height;
}
else
{
- int w = getThumbSize().width;
- if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
- || slider.getMinorTickSpacing() > 0))
- w += getTickLength();
+ int center = thumbRect.width;
+ if (slider.getPaintTicks())
+ center += getTickLength();
if (slider.getPaintLabels())
- w += getWidthOfWidestLabel();
- trackRect.x = contentRect.x + (contentRect.width - w) / 2 - 1;
+ center += getWidthOfWidestLabel();
+ trackRect.x = contentRect.x + (contentRect.width - center - 1) / 2;
trackRect.y = contentRect.y + trackBuffer;
trackRect.width = thumbRect.width;
trackRect.height = contentRect.height - 2 * trackBuffer;
@@ -1310,28 +1231,28 @@ public class BasicSliderUI extends SliderUI
tickRect.x = trackRect.x;
tickRect.y = trackRect.y + trackRect.height;
tickRect.width = trackRect.width;
- tickRect.height = slider.getPaintTicks() ? getTickLength() : 0;
+ tickRect.height = getTickLength();
// this makes our Mauve tests pass...can't explain it!
if (!slider.getPaintTicks())
- tickRect.y--;
-
- if (tickRect.y + tickRect.height > contentRect.y + contentRect.height)
- tickRect.height = contentRect.y + contentRect.height - tickRect.y;
+ {
+ tickRect.y--;
+ tickRect.height = 0;
+ }
}
else
{
tickRect.x = trackRect.x + trackRect.width;
tickRect.y = trackRect.y;
- tickRect.width = slider.getPaintTicks() ? getTickLength() : 0;
+ tickRect.width = getTickLength();
tickRect.height = trackRect.height;
// this makes our Mauve tests pass...can't explain it!
if (!slider.getPaintTicks())
- tickRect.x--;
-
- if (tickRect.x + tickRect.width > contentRect.x + contentRect.width)
- tickRect.width = contentRect.x + contentRect.width - tickRect.x;
+ {
+ tickRect.x--;
+ tickRect.width = 0;
+ }
}
}
@@ -1345,33 +1266,35 @@ public class BasicSliderUI extends SliderUI
{
if (slider.getPaintLabels())
{
- labelRect.x = contentRect.x;
- labelRect.y = tickRect.y + tickRect.height - 1;
- labelRect.width = contentRect.width;
+ labelRect.x = tickRect.x - trackBuffer;
+ labelRect.y = tickRect.y + tickRect.height;
+ labelRect.width = tickRect.width + trackBuffer * 2;
+ labelRect.height = getHeightOfTallestLabel();
}
else
{
- labelRect.x = trackRect.x;
+ labelRect.x = tickRect.x;
labelRect.y = tickRect.y + tickRect.height;
- labelRect.width = trackRect.width;
+ labelRect.width = tickRect.width;
+ labelRect.height = 0;
}
- labelRect.height = getHeightOfTallestLabel();
}
else
{
if (slider.getPaintLabels())
{
- labelRect.x = tickRect.x + tickRect.width - 1;
- labelRect.y = contentRect.y;
- labelRect.height = contentRect.height;
+ labelRect.x = tickRect.x + tickRect.width;
+ labelRect.y = tickRect.y - trackBuffer;
+ labelRect.width = getWidthOfWidestLabel();
+ labelRect.height = tickRect.height + trackBuffer * 2;
}
else
{
labelRect.x = tickRect.x + tickRect.width;
- labelRect.y = trackRect.y;
- labelRect.height = trackRect.height;
+ labelRect.y = tickRect.y;
+ labelRect.width = 0;
+ labelRect.height = tickRect.height;
}
- labelRect.width = getWidthOfWidestLabel();
}
}
@@ -1384,22 +1307,15 @@ public class BasicSliderUI extends SliderUI
protected int getWidthOfWidestLabel()
{
int widest = 0;
- Component label;
-
- if (slider.getLabelTable() == null)
- return 0;
-
- Dimension pref;
- for (Enumeration list = slider.getLabelTable().elements();
- list.hasMoreElements();)
+ Dictionary table = slider.getLabelTable();
+ if (table != null)
{
- Object comp = list.nextElement();
- if (! (comp instanceof Component))
- continue;
- label = (Component) comp;
- pref = label.getPreferredSize();
- if (pref != null && pref.width > widest)
- widest = pref.width;
+ for (Enumeration list = slider.getLabelTable().elements();
+ list.hasMoreElements();)
+ {
+ Component label = (Component) list.nextElement();
+ widest = Math.max(label.getPreferredSize().width, widest);
+ }
}
return widest;
}
@@ -1576,23 +1492,18 @@ public class BasicSliderUI extends SliderUI
*/
public void paint(Graphics g, JComponent c)
{
- // FIXME: Move this to propertyChangeEvent handler, when we get those.
- leftToRightCache = slider.getComponentOrientation()
- != ComponentOrientation.RIGHT_TO_LEFT;
- // FIXME: This next line is only here because the above line is here.
- calculateGeometry();
-
- if (slider.getPaintTrack())
+ recalculateIfInsetsChanged();
+ recalculateIfOrientationChanged();
+ if (slider.getPaintTrack() && hitClip(g, trackRect))
paintTrack(g);
- if (slider.getPaintTicks())
+ if (slider.getPaintTicks() && hitClip(g, tickRect))
paintTicks(g);
- if (slider.getPaintLabels())
+ if (slider.getPaintLabels() && hitClip(g, labelRect))
paintLabels(g);
-
- paintThumb(g);
-
- if (hasFocus)
+ if (slider.hasFocus() && hitClip(g, focusRect))
paintFocus(g);
+ if (hitClip(g, thumbRect))
+ paintThumb(g);
}
/**
@@ -1601,18 +1512,12 @@ public class BasicSliderUI extends SliderUI
*/
protected void recalculateIfInsetsChanged()
{
- // Examining a test program shows that either Sun calls private
- // methods that we don't know about, or these don't do anything.
- calculateFocusRect();
-
- calculateContentRect();
- calculateThumbSize();
- calculateTrackBuffer();
- calculateTrackRect();
- calculateThumbLocation();
-
- calculateTickRect();
- calculateLabelRect();
+ Insets insets = slider.getInsets();
+ if (! insets.equals(insetCache))
+ {
+ insetCache = insets;
+ calculateGeometry();
+ }
}
/**
@@ -1863,45 +1768,30 @@ public class BasicSliderUI extends SliderUI
*/
public void paintLabels(Graphics g)
{
- if (slider.getLabelTable() != null)
+ Dictionary table = slider.getLabelTable();
+ if (table != null)
{
- Dictionary table = slider.getLabelTable();
- Integer tmpKey;
- Object key;
- Object element;
- Component label;
- if (slider.getOrientation() == JSlider.HORIZONTAL)
- {
- for (Enumeration list = table.keys(); list.hasMoreElements();)
- {
- key = list.nextElement();
- if (! (key instanceof Integer))
- continue;
- tmpKey = (Integer) key;
- element = table.get(tmpKey);
- // We won't paint them if they're not
- // JLabels so continue anyway
- if (! (element instanceof JLabel))
- continue;
- label = (Component) element;
- paintHorizontalLabel(g, tmpKey.intValue(), label);
- }
- }
- else
+ int min = slider.getMinimum();
+ int max = slider.getMaximum();
+ for (Enumeration list = table.keys(); list.hasMoreElements();)
{
- for (Enumeration list = table.keys(); list.hasMoreElements();)
+ Integer key = (Integer) list.nextElement();
+ int value = key.intValue();
+ if (value >= min && value <= max)
{
- key = list.nextElement();
- if (! (key instanceof Integer))
- continue;
- tmpKey = (Integer) key;
- element = table.get(tmpKey);
- // We won't paint them if they're not
- // JLabels so continue anyway
- if (! (element instanceof JLabel))
- continue;
- label = (Component) element;
- paintVerticalLabel(g, tmpKey.intValue(), label);
+ Component label = (Component) table.get(key);
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ {
+ g.translate(0, labelRect.y);
+ paintHorizontalLabel(g, value, label);
+ g.translate(0, -labelRect.y);
+ }
+ else
+ {
+ g.translate(labelRect.x, 0);
+ paintVerticalLabel(g, value, label);
+ g.translate(-labelRect.x, 0);
+ }
}
}
}
@@ -1920,51 +1810,11 @@ public class BasicSliderUI extends SliderUI
*/
protected void paintHorizontalLabel(Graphics g, int value, Component label)
{
- // This relies on clipping working properly or we'll end up
- // painting all over the place. If our preferred size is ignored, then
- // the labels may not fit inside the slider's bounds. Rather than mucking
- // with font sizes and possible icon sizes, we'll set the bounds for
- // the label and let it get clipped.
- Dimension dim = label.getPreferredSize();
- int w = (int) dim.getWidth();
- int h = (int) dim.getHeight();
-
- int max = slider.getMaximum();
- int min = slider.getMinimum();
-
- if (value > max || value < min)
- return;
-
- // value
- // |
- // ------------
- // | |
- // | |
- // | |
- // The label must move w/2 to the right to fit directly under the value.
- int xpos = xPositionForValue(value) - w / 2;
- int ypos = labelRect.y;
-
- // We want to center the label around the xPositionForValue
- // So we use xpos - w / 2. However, if value is min and the label
- // is large, we run the risk of going out of bounds. So we bring it back
- // to 0 if it becomes negative.
- if (xpos < 0)
- xpos = 0;
-
- // If the label + starting x position is greater than
- // the x space in the label rectangle, we reset it to the largest
- // amount possible in the rectangle. This means ugliness.
- if (xpos + w > labelRect.x + labelRect.width)
- w = labelRect.x + labelRect.width - xpos;
-
- // If the label is too tall. We reset it to the height of the label
- // rectangle.
- if (h > labelRect.height)
- h = labelRect.height;
-
- label.setBounds(xpos, ypos, w, h);
- SwingUtilities.paintComponent(g, label, null, label.getBounds());
+ int center = xPositionForValue(value);
+ int left = center - label.getPreferredSize().width / 2;
+ g.translate(left, 0);
+ label.paint(g);
+ g.translate(-left, 0);
}
/**
@@ -1980,30 +1830,11 @@ public class BasicSliderUI extends SliderUI
*/
protected void paintVerticalLabel(Graphics g, int value, Component label)
{
- Dimension dim = label.getPreferredSize();
- int w = (int) dim.getWidth();
- int h = (int) dim.getHeight();
-
- int max = slider.getMaximum();
- int min = slider.getMinimum();
-
- if (value > max || value < min)
- return;
-
- int xpos = labelRect.x;
- int ypos = yPositionForValue(value) - h / 2;
-
- if (ypos < 0)
- ypos = 0;
-
- if (ypos + h > labelRect.y + labelRect.height)
- h = labelRect.y + labelRect.height - ypos;
-
- if (w > labelRect.width)
- w = labelRect.width;
-
- label.setBounds(xpos, ypos, w, h);
- SwingUtilities.paintComponent(g, label, null, label.getBounds());
+ int center = yPositionForValue(value);
+ int top = center - label.getPreferredSize().height / 2;
+ g.translate(0, top);
+ label.paint(g);
+ g.translate(0, -top);
}
/**
@@ -2118,8 +1949,11 @@ public class BasicSliderUI extends SliderUI
*/
public void setThumbLocation(int x, int y)
{
- thumbRect.x = x;
- thumbRect.y = y;
+ Rectangle union = new Rectangle(thumbRect);
+ thumbRect.setLocation(x, y);
+ SwingUtilities.computeUnion(thumbRect.x, thumbRect.y, thumbRect.width,
+ thumbRect.height, union);
+ slider.repaint(union);
}
/**
@@ -2197,21 +2031,21 @@ public class BasicSliderUI extends SliderUI
*/
protected int xPositionForValue(int value)
{
- double min = slider.getMinimum();
- if (value < min)
- value = (int) min;
- double max = slider.getMaximum();
- if (value > max)
- value = (int) max;
- double len = trackRect.width;
- if ((max - min) <= 0.0)
- return 0;
- int xPos = (int) ((value - min) / (max - min) * len + 0.5);
-
- if (drawInverted())
- return trackRect.x + Math.max(trackRect.width - xPos - 1, 0);
+ int min = slider.getMinimum();
+ int max = slider.getMaximum();
+ int len = trackRect.width;
+ double range = max - min;
+ double pixPerVal = len / range;
+ int left = trackRect.x;
+ int right = left + trackRect.width - 1;
+ int xpos;
+ if (! drawInverted())
+ xpos = left + (int) Math.round(pixPerVal * ((double) value - min));
else
- return trackRect.x + Math.min(xPos, trackRect.width - 1);
+ xpos = right - (int) Math.round(pixPerVal * ((double) value - min));
+ xpos = Math.max(left, xpos);
+ xpos = Math.min(right, xpos);
+ return xpos;
}
/**
@@ -2225,22 +2059,21 @@ public class BasicSliderUI extends SliderUI
*/
protected int yPositionForValue(int value)
{
- double min = slider.getMinimum();
- if (value < min)
- value = (int) min;
- double max = slider.getMaximum();
- if (value > max)
- value = (int) max;
+ int min = slider.getMinimum();
+ int max = slider.getMaximum();
int len = trackRect.height;
- if ((max - min) <= 0.0)
- return 0;
-
- int yPos = (int) ((value - min) / (max - min) * len + 0.5);
-
+ double range = max - min;
+ double pixPerVal = len / range;
+ int top = trackRect.y;
+ int bottom = top + trackRect.height - 1;
+ int ypos;
if (! drawInverted())
- return trackRect.y + trackRect.height - Math.max(yPos, 1);
+ ypos = top + (int) Math.round(pixPerVal * ((double) max - value));
else
- return trackRect.y + Math.min(yPos, trackRect.height - 1);
+ ypos = top + (int) Math.round(pixPerVal * ((double) value - min));
+ ypos = Math.max(top, ypos);
+ ypos = Math.min(bottom, ypos);
+ return ypos;
}
/**
@@ -2494,4 +2327,13 @@ public class BasicSliderUI extends SliderUI
);
return map;
}
+
+ /**
+ * Small utility method to save me from typing the hell out of myself in
+ * paint().
+ */
+ private boolean hitClip(Graphics g, Rectangle r)
+ {
+ return g.hitClip(r.x, r.y, r.width, r.height);
+ }
}
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index 6ef4c08ce..b7cc42548 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -320,8 +320,17 @@ public class BasicSplitPaneUI extends SplitPaneUI
Dimension dims = split.getSize();
int loc = getInitialLocation(insets);
int available = getAvailableSize(dims, insets);
- sizes[0] = getDividerLocation(split) - loc;
+ sizes[0] = split.getDividerLocation();
sizes[1] = available - sizes[0] - sizes[2];
+
+ // According to a Mauve test we only honour the minimum
+ // size of the components, when the dividerLocation hasn't
+ // been excplicitly set.
+ if (! dividerLocationSet)
+ {
+ sizes[0] = Math.max(sizes[0], minimumSizeOfComponent(0));
+ sizes[1] = Math.max(sizes[1], minimumSizeOfComponent(1));
+ }
// The size of the divider won't change.
// Layout component#1.
@@ -363,7 +372,6 @@ public class BasicSplitPaneUI extends SplitPaneUI
Dimension dim = new Dimension();
if (target instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) target;
int primary = 0;
int secondary = 0;
for (int i = 0; i < components.length; i++)
@@ -401,7 +409,6 @@ public class BasicSplitPaneUI extends SplitPaneUI
Dimension dim = new Dimension();
if (target instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) target;
int primary = 0;
int secondary = 0;
for (int i = 0; i < components.length; i++)
@@ -460,8 +467,6 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
for (int i = 0; i < components.length; i++)
resetSizeAt(i);
- setDividerLocation(splitPane,
- getInitialLocation(splitPane.getInsets()) + sizes[0]);
}
/**
@@ -857,7 +862,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** The JSplitPane that this UI draws. */
protected JSplitPane splitPane;
- private int dividerLocation;
+ /**
+ * True, when setDividerLocation() has been called at least
+ * once on the JSplitPane, false otherwise.
+ *
+ * This is package private to avoid a synthetic accessor method.
+ */
+ boolean dividerLocationSet;
/**
* Creates a new BasicSplitPaneUI object.
@@ -889,6 +900,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
if (c instanceof JSplitPane)
{
splitPane = (JSplitPane) c;
+ dividerLocationSet = false;
installDefaults();
installListeners();
installKeyboardActions();
@@ -906,6 +918,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
uninstallListeners();
uninstallDefaults();
+ dividerLocationSet = false;
splitPane = null;
}
@@ -1054,8 +1067,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
new AbstractAction("negativeIncrement") {
public void actionPerformed(ActionEvent event)
{
- setDividerLocation(splitPane, Math.max(dividerLocation
- - KEYBOARD_DIVIDER_MOVE_OFFSET, 0));
+ int oldLoc = splitPane.getDividerLocation();
+ int newLoc =
+ Math.max(oldLoc - KEYBOARD_DIVIDER_MOVE_OFFSET, 0);
+ splitPane.setDividerLocation(newLoc);
}
}
);
@@ -1063,8 +1078,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
new AbstractAction("positiveIncrement") {
public void actionPerformed(ActionEvent event)
{
- setDividerLocation(splitPane, dividerLocation
- + KEYBOARD_DIVIDER_MOVE_OFFSET);
+ int oldLoc = splitPane.getDividerLocation();
+ int newLoc =
+ Math.max(oldLoc + KEYBOARD_DIVIDER_MOVE_OFFSET, 0);
+ splitPane.setDividerLocation(newLoc);
}
}
);
@@ -1354,7 +1371,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public void setDividerLocation(JSplitPane jc, int location)
{
- dividerLocation = location;
+ dividerLocationSet = true;
splitPane.revalidate();
splitPane.repaint();
}
@@ -1368,7 +1385,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public int getDividerLocation(JSplitPane jc)
{
- return dividerLocation;
+ int loc;
+ if (jc.getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
+ loc = divider.getX();
+ else
+ loc = divider.getY();
+ return loc;
}
/**
@@ -1441,7 +1463,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public Dimension getPreferredSize(JComponent jc)
{
- return layoutManager.preferredLayoutSize((Container) jc);
+ return layoutManager.preferredLayoutSize(jc);
}
/**
@@ -1453,7 +1475,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public Dimension getMinimumSize(JComponent jc)
{
- return layoutManager.minimumLayoutSize((Container) jc);
+ return layoutManager.minimumLayoutSize(jc);
}
/**
@@ -1465,7 +1487,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public Dimension getMaximumSize(JComponent jc)
{
- return layoutManager.maximumLayoutSize((Container) jc);
+ return layoutManager.maximumLayoutSize(jc);
}
/**
diff --git a/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 21dcf0d29..0d1fa1eed 100644
--- a/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -957,82 +957,51 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
protected void normalizeTabRuns(int tabPlacement, int tabCount, int start,
int max)
{
- if (tabPlacement == SwingUtilities.TOP
- || tabPlacement == SwingUtilities.BOTTOM)
+ boolean horizontal = tabPlacement == TOP || tabPlacement == BOTTOM;
+ int currentRun = runCount - 1;
+ double weight = 1.25;
+ for (boolean adjust = true; adjust == true;)
{
- // We should only do this for runCount - 1, cause we can
- // only shift that many times between runs.
- for (int i = 1; i < runCount; i++)
+ int last = lastTabInRun(tabCount, currentRun);
+ int prevLast = lastTabInRun(tabCount, currentRun - 1);
+ int end;
+ int prevLength;
+ if (horizontal)
{
- Rectangle currRun = rects[lastTabInRun(tabCount, i)];
- Rectangle nextRun = rects[lastTabInRun(tabCount,
- getNextTabRun(i))];
- int spaceInCurr = currRun.x + currRun.width;
- int spaceInNext = nextRun.x + nextRun.width;
-
- int diffNow = spaceInCurr - spaceInNext;
- int diffLater = (spaceInCurr - currRun.width)
- - (spaceInNext + currRun.width);
-
- while (Math.abs(diffLater) < Math.abs(diffNow)
- && spaceInNext + currRun.width < max)
- {
- tabRuns[i]--;
- spaceInNext += currRun.width;
- spaceInCurr -= currRun.width;
- currRun = rects[lastTabInRun(tabCount, i)];
- diffNow = spaceInCurr - spaceInNext;
- diffLater = (spaceInCurr - currRun.width)
- - (spaceInNext + currRun.width);
- }
-
- // Fixes the bounds of all tabs in the current
- // run.
- int first = tabRuns[i];
- int last = lastTabInRun(tabCount, i);
- int currX = start;
- for (int j = first; j <= last; j++)
- {
- rects[j].x = currX;
- currX += rects[j].width;
- }
+ end = rects[last].x + rects[last].width;
+ prevLength = (int) (maxTabWidth * weight);
}
- }
- else
- {
- for (int i = 1; i < runCount; i++)
+ else
{
- Rectangle currRun = rects[lastTabInRun(tabCount, i)];
- Rectangle nextRun = rects[lastTabInRun(tabCount,
- getNextTabRun(i))];
- int spaceInCurr = currRun.y + currRun.height;
- int spaceInNext = nextRun.y + nextRun.height;
-
- int diffNow = spaceInCurr - spaceInNext;
- int diffLater = (spaceInCurr - currRun.height)
- - (spaceInNext + currRun.height);
- while (Math.abs(diffLater) < Math.abs(diffNow)
- && spaceInNext + currRun.height < max)
- {
- tabRuns[i]--;
- spaceInNext += currRun.height;
- spaceInCurr -= currRun.height;
- currRun = rects[lastTabInRun(tabCount, i)];
- diffNow = spaceInCurr - spaceInNext;
- diffLater = (spaceInCurr - currRun.height)
- - (spaceInNext + currRun.height);
- }
-
- // Fixes the bounds of tabs in the current run.
- int first = tabRuns[i];
- int last = lastTabInRun(tabCount, i);
- int currY = start;
- for (int j = first; j <= last; j++)
+ end = rects[last].y + rects[last].height;
+ prevLength = (int) (maxTabWidth * weight * 2);
+ }
+ if (max - end > prevLength)
+ {
+ tabRuns[currentRun] = prevLast;
+ if (horizontal)
+ rects[prevLast].x = start;
+ else
+ rects[prevLast].y = start;
+ for (int i = prevLast + 1; i <= last; i++)
{
- rects[j].y = currY;
- currY += rects[j].height;
+ if (horizontal)
+ rects[i].x = rects[i - 1].x + rects[i - 1].width;
+ else
+ rects[i].y = rects[i - 1].y + rects[i - 1].height;
}
}
+ else if (currentRun == runCount - 1)
+ adjust = false;
+ if (currentRun - 1 > 0)
+ currentRun -= 1;
+ else
+ {
+ // Check again, but with higher ratio to avoid
+ // clogging up the last run.
+ currentRun = runCount - 1;
+ weight += 0.25;
+ }
}
}
diff --git a/javax/swing/plaf/metal/MetalRadioButtonUI.java b/javax/swing/plaf/metal/MetalRadioButtonUI.java
index 046e4942e..57f5bbe3e 100644
--- a/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -177,7 +177,7 @@ public class MetalRadioButtonUI
protected void paintFocus(Graphics g, Rectangle t, Dimension d)
{
g.setColor(focusColor);
- g.drawRect(t.x - 1, t.y - 1, t.width + 2, t.height + 2);
+ g.drawRect(t.x - 1, t.y - 1, t.width + 1, t.height + 1);
}
}
diff --git a/javax/swing/plaf/metal/MetalSliderUI.java b/javax/swing/plaf/metal/MetalSliderUI.java
index 0f824418c..b3e8707c9 100644
--- a/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/javax/swing/plaf/metal/MetalSliderUI.java
@@ -352,7 +352,10 @@ public class MetalSliderUI extends BasicSliderUI
*/
public int getTickLength()
{
- return tickLength + TICK_BUFFER;
+ int len = tickLength + TICK_BUFFER + 1;
+ if (slider.getOrientation() == JSlider.VERTICAL)
+ len += 2;
+ return len;
}
/**
@@ -406,9 +409,9 @@ public class MetalSliderUI extends BasicSliderUI
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.setColor(MetalLookAndFeel.getControlShadow());
g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2);
}
@@ -425,10 +428,10 @@ public class MetalSliderUI extends BasicSliderUI
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength - 1);
}
/**
@@ -444,10 +447,10 @@ public class MetalSliderUI extends BasicSliderUI
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(TICK_BUFFER, y, TICK_BUFFER + tickLength / 2, y);
}
/**
@@ -463,10 +466,10 @@ public class MetalSliderUI extends BasicSliderUI
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
if (slider.isEnabled())
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.setColor(slider.getForeground());
else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(TICK_BUFFER, y, TICK_BUFFER + tickLength, y);
}
}
diff --git a/javax/swing/text/FlowView.java b/javax/swing/text/FlowView.java
index 085b0ac45..c4625fc62 100644
--- a/javax/swing/text/FlowView.java
+++ b/javax/swing/text/FlowView.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.text;
+import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Shape;
@@ -85,7 +86,17 @@ public abstract class FlowView extends BoxView
*/
public void insertUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
{
- // The default implementation does nothing.
+ if (alloc != null)
+ {
+ fv.layoutChanged(X_AXIS);
+ fv.layoutChanged(Y_AXIS);
+ }
+ else
+ {
+ Component host = fv.getContainer();
+ if (host != null)
+ host.repaint();
+ }
}
/**
@@ -101,7 +112,17 @@ public abstract class FlowView extends BoxView
*/
public void removeUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
{
- // The default implementation does nothing.
+ if (alloc != null)
+ {
+ fv.layoutChanged(X_AXIS);
+ fv.layoutChanged(Y_AXIS);
+ }
+ else
+ {
+ Component host = fv.getContainer();
+ if (host != null)
+ host.repaint();
+ }
}
/**
@@ -117,7 +138,17 @@ public abstract class FlowView extends BoxView
*/
public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
{
- // The default implementation does nothing.
+ if (alloc != null)
+ {
+ fv.layoutChanged(X_AXIS);
+ fv.layoutChanged(Y_AXIS);
+ }
+ else
+ {
+ Component host = fv.getContainer();
+ if (host != null)
+ host.repaint();
+ }
}
/**
@@ -143,18 +174,35 @@ public abstract class FlowView extends BoxView
*/
public void layout(FlowView fv)
{
- fv.removeAll();
- Element el = fv.getElement();
+ int start = fv.getStartOffset();
+ int end = fv.getEndOffset();
+
+ // Preserve the views from the logical view from beeing removed.
+ View lv = getLogicalView(fv);
+ int viewCount = lv.getViewCount();
+ for (int i = 0; i < viewCount; i++)
+ {
+ View v = lv.getView(i);
+ v.setParent(lv);
+ }
- int rowStart = el.getStartOffset();
- int end = el.getEndOffset();
- int rowIndex = 0;
- while (rowStart >= 0 && rowStart < end)
+ // Then remove all views from the flow view.
+ fv.removeAll();
+
+ for (int rowIndex = 0; start < end; rowIndex++)
{
View row = fv.createRow();
fv.append(row);
- rowStart = layoutRow(fv, rowIndex, rowStart);
- rowIndex++;
+ int next = layoutRow(fv, rowIndex, start);
+ if (row.getViewCount() == 0)
+ {
+ row.append(createView(fv, start, Integer.MAX_VALUE, rowIndex));
+ next = row.getEndOffset();
+ }
+ if (start < next)
+ start = next;
+ else
+ assert false: "May not happen";
}
}
@@ -179,46 +227,69 @@ public abstract class FlowView extends BoxView
int axis = fv.getFlowAxis();
int span = fv.getFlowSpan(rowIndex);
int x = fv.getFlowStart(rowIndex);
- int offset = pos;
- View logicalView = getLogicalView(fv);
- // Special case when span == 0. We need to layout the row as if it had
- // a span of Integer.MAX_VALUE.
- if (span == 0)
- span = Integer.MAX_VALUE;
-
- Row: while (span > 0)
+ int end = fv.getEndOffset();
+
+ // Needed for adjusting indentation in adjustRow().
+ int preX = x;
+ int availableSpan = span;
+
+ TabExpander tabExp = fv instanceof TabExpander ? (TabExpander) fv : null;
+
+ boolean forcedBreak = false;
+ while (pos < end && span >= 0)
{
- if (logicalView.getViewIndex(offset, Position.Bias.Forward) == - 1)
- break;
- View view = createView(fv, offset, span, rowIndex);
- if (view == null)
+ View view = createView(fv, pos, span, rowIndex);
+ if (view == null
+ || (span == 0 && view.getPreferredSpan(axis) > 0))
break;
- int viewSpan = (int) view.getPreferredSpan(axis);
- int breakWeight = view.getBreakWeight(axis, x, span);
-
- row.append(view);
- offset += (view.getEndOffset() - view.getStartOffset());
- x += viewSpan;
- span -= viewSpan;
+ int viewSpan;
+ if (axis == X_AXIS && view instanceof TabableView)
+ viewSpan = (int) ((TabableView) view).getTabbedSpan(x, tabExp);
+ else
+ viewSpan = (int) view.getPreferredSpan(axis);
// Break if the line if the view does not fit in this row or the
// line just must be broken.
- if (span < 0 || breakWeight >= View.ForcedBreakWeight)
+ int breakWeight = view.getBreakWeight(axis, pos, span);
+ if (breakWeight >= ForcedBreakWeight)
{
- int flowStart = fv.getFlowStart(axis);
- int flowSpan = fv.getFlowSpan(axis);
- adjustRow(fv, rowIndex, flowSpan, flowStart);
int rowViewCount = row.getViewCount();
if (rowViewCount > 0)
- offset = row.getView(rowViewCount - 1).getEndOffset();
- else
- offset = - 1;
- break Row;
+ {
+ view = view.breakView(axis, pos, x, span);
+ if (view != null)
+ {
+ if (axis == X_AXIS && view instanceof TabableView)
+ viewSpan =
+ (int) ((TabableView) view).getTabbedSpan(x, tabExp);
+ else
+ viewSpan = (int) view.getPreferredSpan(axis);
+ }
+ else
+ viewSpan = 0;
+ }
+ forcedBreak = true;
+ }
+ span -= viewSpan;
+ x += viewSpan;
+ if (view != null)
+ {
+ row.append(view);
+ pos = view.getEndOffset();
}
+ if (forcedBreak)
+ break;
}
- return offset != pos ? offset : - 1;
+ if (span < 0)
+ adjustRow(fv, rowIndex, availableSpan, preX);
+ else if (row.getViewCount() == 0)
+ {
+ View view = createView(fv, pos, Integer.MAX_VALUE, rowIndex);
+ row.append(view);
+ }
+ return row.getEndOffset();
}
/**
@@ -248,13 +319,9 @@ public abstract class FlowView extends BoxView
View logicalView = getLogicalView(fv);
// FIXME: Handle the bias thing correctly.
int index = logicalView.getViewIndex(startOffset, Position.Bias.Forward);
- View retVal = null;
- if (index >= 0)
- {
- retVal = logicalView.getView(index);
- if (retVal.getStartOffset() != startOffset)
- retVal = retVal.createFragment(startOffset, retVal.getEndOffset());
- }
+ View retVal = logicalView.getView(index);
+ if (retVal.getStartOffset() != startOffset)
+ retVal = retVal.createFragment(startOffset, retVal.getEndOffset());
return retVal;
}
@@ -279,37 +346,82 @@ public abstract class FlowView extends BoxView
View row = fv.getView(rowIndex);
int count = row.getViewCount();
int breakIndex = -1;
- int maxBreakWeight = View.BadBreakWeight;
- int breakX = x;
- int breakSpan = desiredSpan;
- int currentX = x;
- int currentSpan = desiredSpan;
+ int breakWeight = BadBreakWeight;
+ int breakSpan = 0;
+ int currentSpan = 0;
for (int i = 0; i < count; ++i)
{
View view = row.getView(i);
- int weight = view.getBreakWeight(axis, currentX, currentSpan);
- if (weight >= maxBreakWeight)
+ int spanLeft = desiredSpan - currentSpan;
+ int weight = view.getBreakWeight(axis, x + currentSpan, spanLeft);
+ if (weight >= breakWeight && weight > BadBreakWeight)
{
breakIndex = i;
- breakX = currentX;
breakSpan = currentSpan;
- maxBreakWeight = weight;
+ breakWeight = weight;
+ if (weight >= ForcedBreakWeight)
+ // Don't search further.
+ break;
}
- int size = (int) view.getPreferredSpan(axis);
- currentX += size;
- currentSpan -= size;
+ currentSpan += view.getPreferredSpan(axis);
}
// If there is a potential break location found, break the row at
// this location.
- if (breakIndex > -1)
+ if (breakIndex >= 0)
{
+ int spanLeft = desiredSpan - breakSpan;
View toBeBroken = row.getView(breakIndex);
View brokenView = toBeBroken.breakView(axis,
toBeBroken.getStartOffset(),
- breakX, breakSpan);
+ x + breakSpan, spanLeft);
+ View lv = getLogicalView(fv);
+ for (int i = breakIndex; i < count; i++)
+ {
+ View tmp = row.getView(i);
+ if (contains(lv, tmp))
+ tmp.setParent(lv);
+ else if (tmp.getViewCount() > 0)
+ reparent(tmp, lv);
+ }
row.replace(breakIndex, count - breakIndex,
- new View[]{brokenView});
+ new View[]{ brokenView });
+ }
+
+ }
+
+ /**
+ * Helper method to determine if one view contains another as child.
+ */
+ private boolean contains(View view, View child)
+ {
+ boolean ret = false;
+ int n = view.getViewCount();
+ for (int i = 0; i < n && ret == false; i++)
+ {
+ if (view.getView(i) == child)
+ ret = true;
+ }
+ return ret;
+ }
+
+ /**
+ * Helper method that reparents the <code>view</code> and all of its
+ * decendents to the <code>parent</code> (the logical view).
+ *
+ * @param view the view to reparent
+ * @param parent the new parent
+ */
+ private void reparent(View view, View parent)
+ {
+ int n = view.getViewCount();
+ for (int i = 0; i < n; i++)
+ {
+ View tmp = view.getView(i);
+ if (contains(parent, tmp))
+ tmp.setParent(parent);
+ else
+ reparent(tmp, parent);
}
}
}
@@ -367,11 +479,6 @@ public abstract class FlowView extends BoxView
protected FlowStrategy strategy;
/**
- * Indicates if the flow should be rebuild during the next layout.
- */
- private boolean layoutDirty;
-
- /**
* Creates a new <code>FlowView</code> for the given
* <code>Element</code> and <code>axis</code>.
*
@@ -384,7 +491,6 @@ public abstract class FlowView extends BoxView
{
super(element, axis);
strategy = sharedStrategy;
- layoutDirty = true;
}
/**
@@ -493,15 +599,20 @@ public abstract class FlowView extends BoxView
}
}
- if (layoutDirty)
+ if (! isLayoutValid(flowAxis))
{
+ int axis = getAxis();
+ int oldSpan = axis == X_AXIS ? getWidth() : getHeight();
strategy.layout(this);
- layoutDirty = false;
+ int newSpan = (int) getPreferredSpan(axis);
+ if (oldSpan != newSpan)
+ {
+ View parent = getParent();
+ if (parent != null)
+ parent.preferenceChanged(this, axis == X_AXIS, axis == Y_AXIS);
+ }
}
- if (getPreferredSpan(getAxis()) != height)
- preferenceChanged(this, false, true);
-
super.layout(width, height);
}
@@ -520,7 +631,6 @@ public abstract class FlowView extends BoxView
// be updated accordingly.
layoutPool.insertUpdate(changes, a, vf);
strategy.insertUpdate(this, changes, getInsideAllocation(a));
- layoutDirty = true;
}
/**
@@ -536,7 +646,6 @@ public abstract class FlowView extends BoxView
{
layoutPool.removeUpdate(changes, a, vf);
strategy.removeUpdate(this, changes, getInsideAllocation(a));
- layoutDirty = true;
}
/**
@@ -552,7 +661,6 @@ public abstract class FlowView extends BoxView
{
layoutPool.changedUpdate(changes, a, vf);
strategy.changedUpdate(this, changes, getInsideAllocation(a));
- layoutDirty = true;
}
/**
diff --git a/javax/swing/text/GlyphView.java b/javax/swing/text/GlyphView.java
index 385f50bf6..e177d927d 100644
--- a/javax/swing/text/GlyphView.java
+++ b/javax/swing/text/GlyphView.java
@@ -467,12 +467,12 @@ public class GlyphView extends View implements TabableView, Cloneable
/**
* The start offset within the document for this view.
*/
- private int startOffset;
+ private int offset;
/**
* The end offset within the document for this view.
*/
- private int endOffset;
+ private int length;
/**
* Creates a new <code>GlyphView</code> for the given <code>Element</code>.
@@ -482,8 +482,8 @@ public class GlyphView extends View implements TabableView, Cloneable
public GlyphView(Element element)
{
super(element);
- startOffset = -1;
- endOffset = -1;
+ offset = 0;
+ length = 0;
}
/**
@@ -699,10 +699,11 @@ public class GlyphView extends View implements TabableView, Cloneable
*/
public int getStartOffset()
{
- int start = startOffset;
- if (start < 0)
- start = super.getStartOffset();
- return start;
+ Element el = getElement();
+ int offs = el.getStartOffset();
+ if (length > 0)
+ offs += offset;
+ return offs;
}
/**
@@ -714,10 +715,13 @@ public class GlyphView extends View implements TabableView, Cloneable
*/
public int getEndOffset()
{
- int end = endOffset;
- if (end < 0)
- end = super.getEndOffset();
- return end;
+ Element el = getElement();
+ int offs;
+ if (length > 0)
+ offs = el.getStartOffset() + offset + length;
+ else
+ offs = el.getEndOffset();
+ return offs;
}
/**
@@ -1029,11 +1033,12 @@ public class GlyphView extends View implements TabableView, Cloneable
*/
public View createFragment(int p0, int p1)
{
+ checkPainter();
+ Element el = getElement();
GlyphView fragment = (GlyphView) clone();
- if (p0 != getStartOffset())
- fragment.startOffset = p0;
- if (p1 != getEndOffset())
- fragment.endOffset = p1;
+ fragment.offset = p0 - el.getStartOffset();
+ fragment.length = p1 - p0;
+ fragment.glyphPainter = glyphPainter.getPainter(fragment, p0, p1);
return fragment;
}
diff --git a/javax/swing/text/ParagraphView.java b/javax/swing/text/ParagraphView.java
index b0b4b246e..6a13b2a3e 100644
--- a/javax/swing/text/ParagraphView.java
+++ b/javax/swing/text/ParagraphView.java
@@ -161,6 +161,38 @@ public class ParagraphView extends FlowView implements TabExpander
{
// Do nothing here. The children are added while layouting.
}
+
+ /**
+ * Overridden to determine the minimum start offset of the row's children.
+ */
+ public int getStartOffset()
+ {
+ // Determine minimum start offset of the children.
+ int offset = Integer.MAX_VALUE;
+ int n = getViewCount();
+ for (int i = 0; i < n; i++)
+ {
+ View v = getView(i);
+ offset = Math.min(offset, v.getStartOffset());
+ }
+ return offset;
+ }
+
+ /**
+ * Overridden to determine the maximum end offset of the row's children.
+ */
+ public int getEndOffset()
+ {
+ // Determine minimum start offset of the children.
+ int offset = 0;
+ int n = getViewCount();
+ for (int i = 0; i < n; i++)
+ {
+ View v = getView(i);
+ offset = Math.max(offset, v.getEndOffset());
+ }
+ return offset;
+ }
}
/**
diff --git a/javax/swing/text/html/BRView.java b/javax/swing/text/html/BRView.java
index 5521fed8e..7d0d5164d 100644
--- a/javax/swing/text/html/BRView.java
+++ b/javax/swing/text/html/BRView.java
@@ -44,8 +44,7 @@ import javax.swing.text.Element;
* Handled the HTML BR tag.
*/
class BRView
- extends NullView
-
+ extends InlineView
{
/**
* Creates the new BR view.
@@ -66,6 +65,6 @@ class BRView
if (axis == X_AXIS)
return ForcedBreakWeight;
else
- return BadBreakWeight;
+ return super.getBreakWeight(axis, pos, len);
}
}
diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java
index 772c0c96c..4a6899fbe 100644
--- a/javax/swing/tree/AbstractLayoutCache.java
+++ b/javax/swing/tree/AbstractLayoutCache.java
@@ -149,9 +149,11 @@ public abstract class AbstractLayoutCache
protected Rectangle getNodeDimensions(Object value, int row, int depth,
boolean expanded, Rectangle bounds)
{
- if (nodeDimensions == null)
- throw new InternalError("The NodeDimensions are not set");
- return nodeDimensions.getNodeDimensions(value, row, depth, expanded, bounds);
+ Rectangle d = null;
+ if (nodeDimensions != null)
+ d = nodeDimensions.getNodeDimensions(value, row, depth, expanded,
+ bounds);
+ return d;
}
/**
@@ -224,7 +226,12 @@ public abstract class AbstractLayoutCache
*/
public void setSelectionModel(TreeSelectionModel model)
{
+ if (treeSelectionModel != null)
+ treeSelectionModel.setRowMapper(null);
treeSelectionModel = model;
+ if (treeSelectionModel != null)
+ treeSelectionModel.setRowMapper(this);
+
}
/**
@@ -425,9 +432,13 @@ public abstract class AbstractLayoutCache
*/
public int[] getRowsForPaths(TreePath[] paths)
{
- int[] rows = new int[paths.length];
- for (int i = 0; i < rows.length; i++)
- rows[i] = getRowForPath(paths[i]);
+ int[] rows = null;
+ if (paths != null)
+ {
+ rows = new int[paths.length];
+ for (int i = 0; i < rows.length; i++)
+ rows[i] = getRowForPath(paths[i]);
+ }
return rows;
}
@@ -440,6 +451,6 @@ public abstract class AbstractLayoutCache
*/
protected boolean isFixedRowHeight()
{
- return false;
+ return rowHeight > 0;
}
}
diff --git a/javax/swing/tree/DefaultTreeSelectionModel.java b/javax/swing/tree/DefaultTreeSelectionModel.java
index db16a1a60..3d9c67728 100644
--- a/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -44,6 +44,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.EventListener;
import java.util.HashSet;
import java.util.Iterator;
@@ -67,7 +68,39 @@ import javax.swing.event.TreeSelectionListener;
public class DefaultTreeSelectionModel
implements Cloneable, Serializable, TreeSelectionModel
{
-
+
+ /**
+ * According to the API docs, the method
+ * {@link DefaultTreeSelectionModel#notifyPathChange} should
+ * expect instances of a class PathPlaceHolder in the Vector parameter.
+ * This seems to be a non-public class, so I can only make guesses about the
+ * use of it.
+ */
+ private static class PathPlaceHolder
+ {
+ /**
+ * The path that we wrap.
+ */
+ TreePath path;
+
+ /**
+ * Indicates if the path is new or already in the selection.
+ */
+ boolean isNew;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param p the path to wrap
+ * @param n if the path is new or already in the selection
+ */
+ PathPlaceHolder(TreePath p, boolean n)
+ {
+ path = p;
+ isNew = n;
+ }
+ }
+
/**
* Use serialVersionUID for interoperability.
*/
@@ -124,12 +157,36 @@ public class DefaultTreeSelectionModel
protected int leadRow = -1;
/**
+ * A supporting datastructure that is used in addSelectionPaths() and
+ * removeSelectionPaths(). It contains currently selected paths.
+ *
+ * @see #addSelectionPaths(TreePath[])
+ * @see #removeSelectionPaths(TreePath[])
+ * @see #setSelectionPaths(TreePath[])
+ */
+ private transient HashSet selectedPaths;
+
+ /**
+ * A supporting datastructure that is used in addSelectionPaths() and
+ * removeSelectionPaths(). It contains the paths that are added or removed.
+ *
+ * @see #addSelectionPaths(TreePath[])
+ * @see #removeSelectionPaths(TreePath[])
+ * @see #setSelectionPaths(TreePath[])
+ */
+ private transient HashSet tmpPaths;
+
+ /**
* Constructs a new DefaultTreeSelectionModel.
*/
public DefaultTreeSelectionModel()
{
setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
+ listSelectionModel = new DefaultListSelectionModel();
listenerList = new EventListenerList();
+ leadIndex = -1;
+ tmpPaths = new HashSet();
+ selectedPaths = new HashSet();
}
/**
@@ -144,12 +201,14 @@ public class DefaultTreeSelectionModel
{
DefaultTreeSelectionModel cloned =
(DefaultTreeSelectionModel) super.clone();
-
- // Clone the selection and the list selection model.
+ cloned.changeSupport = null;
cloned.selection = (TreePath[]) selection.clone();
- if (listSelectionModel != null)
- cloned.listSelectionModel
- = (DefaultListSelectionModel) listSelectionModel.clone();
+ cloned.listenerList = new EventListenerList();
+ cloned.listSelectionModel =
+ (DefaultListSelectionModel) listSelectionModel.clone();
+ cloned.selectedPaths = new HashSet();
+ cloned.tmpPaths = new HashSet();
+
return cloned;
}
@@ -209,6 +268,7 @@ public class DefaultTreeSelectionModel
public void setRowMapper(RowMapper mapper)
{
rowMapper = mapper;
+ resetRowSelection();
}
/**
@@ -236,8 +296,18 @@ public class DefaultTreeSelectionModel
*/
public void setSelectionMode(int mode)
{
+ int oldMode = selectionMode;
selectionMode = mode;
- insureRowContinuity();
+ // Make sure we have a valid selection mode.
+ if (selectionMode != SINGLE_TREE_SELECTION
+ && selectionMode != CONTIGUOUS_TREE_SELECTION
+ && selectionMode != DISCONTIGUOUS_TREE_SELECTION)
+ selectionMode = DISCONTIGUOUS_TREE_SELECTION;
+
+ // Fire property change event.
+ if (oldMode != selectionMode && changeSupport != null)
+ changeSupport.firePropertyChange(SELECTION_MODE_PROPERTY, oldMode,
+ selectionMode);
}
/**
@@ -262,32 +332,10 @@ public class DefaultTreeSelectionModel
*/
public void setSelectionPath(TreePath path)
{
- // The most frequently only one cell in the tree is selected.
- TreePath[] ose = selection;
- selection = new TreePath[] { path };
- TreePath oldLead = leadPath;
- leadIndex = 0;
- leadRow = getRow(path);
- leadPath = path;
-
- TreeSelectionEvent event;
-
- if (ose != null && ose.length > 0)
- {
- // The first item in the path list is the selected path.
- // The remaining items are unselected pathes.
- TreePath[] changed = new TreePath[ose.length + 1];
- boolean[] news = new boolean[changed.length];
- news[0] = true;
- changed[0] = path;
- System.arraycopy(ose, 0, changed, 1, ose.length);
- event = new TreeSelectionEvent(this, changed, news, oldLead, path);
- }
- else
- {
- event = new TreeSelectionEvent(this, path, true, oldLead, path);
- }
- fireValueChanged(event);
+ TreePath[] paths = null;
+ if (path != null)
+ paths = new TreePath[]{ path };
+ setSelectionPaths(paths);
}
/**
@@ -307,7 +355,7 @@ public class DefaultTreeSelectionModel
AbstractLayoutCache ama = (AbstractLayoutCache) mapper;
return ama.getRowForPath(path);
}
- else
+ else if (mapper != null)
{
// Generic non optimized implementation.
int[] rows = mapper.getRowsForPaths(new TreePath[] { path });
@@ -316,6 +364,7 @@ public class DefaultTreeSelectionModel
else
return rows[0];
}
+ return -1;
}
/**
@@ -327,10 +376,90 @@ public class DefaultTreeSelectionModel
*/
public void setSelectionPaths(TreePath[] paths)
{
- // Must be called, as defined in JDK API 1.4.
- insureUniqueness();
- clearSelection();
- addSelectionPaths(paths);
+ int oldLength = 0;
+ if (selection != null)
+ oldLength = selection.length;
+ int newLength = 0;
+ if (paths != null)
+ newLength = paths.length;
+ if (newLength > 0 || oldLength > 0)
+ {
+ // For SINGLE_TREE_SELECTION and for CONTIGUOUS_TREE_SELECTION with
+ // a non-contiguous path, we only allow the first path element.
+ if ((selectionMode == SINGLE_TREE_SELECTION && newLength > 1)
+ || (selectionMode == CONTIGUOUS_TREE_SELECTION && newLength > 0
+ && ! arePathsContiguous(paths)))
+ {
+ paths = new TreePath[] { paths[0] };
+ newLength = 1;
+ }
+ // Find new paths.
+ Vector changedPaths = null;
+ tmpPaths.clear();
+ int validPaths = 0;
+ TreePath oldLeadPath = leadPath;
+ for (int i = 0; i < newLength; i++)
+ {
+ if (paths[i] != null && ! tmpPaths.contains(paths[i]))
+ {
+ validPaths++;
+ tmpPaths.add(paths[i]);
+ if (! selectedPaths.contains(paths[i]))
+ {
+ if (changedPaths == null)
+ changedPaths = new Vector();
+ changedPaths.add(new PathPlaceHolder(paths[i], true));
+ }
+ leadPath = paths[i];
+ }
+ }
+ // Put together the new selection.
+ TreePath[] newSelection = null;
+ if (validPaths != 0)
+ {
+ if (validPaths != newLength)
+ {
+ // Some of the paths are already selected, put together
+ // the new selection carefully.
+ newSelection = new TreePath[validPaths];
+ Iterator newPaths = tmpPaths.iterator();
+ validPaths = 0;
+ for (int i = 0; newPaths.hasNext(); i++)
+ newSelection[i] = (TreePath) newPaths.next();
+ }
+ else
+ {
+ newSelection = new TreePath[paths.length];
+ System.arraycopy(paths, 0, newSelection, 0, paths.length);
+ }
+ }
+
+ // Find paths that have been selected, but are no more.
+ for (int i = 0; i < oldLength; i++)
+ {
+ if (selection[i] != null && ! tmpPaths.contains(selection[i]))
+ {
+ if (changedPaths == null)
+ changedPaths = new Vector();
+ changedPaths.add(new PathPlaceHolder(selection[i], false));
+ }
+ }
+
+ // Perform changes and notification.
+ selection = newSelection;
+ HashSet tmp = selectedPaths;
+ selectedPaths = tmpPaths;
+ tmpPaths = tmp;
+ tmpPaths.clear();
+
+ // Not necessary, but required according to the specs and to tests.
+ if (selection != null)
+ insureUniqueness();
+ updateLeadIndex();
+ resetRowSelection();
+ if (changedPaths != null && changedPaths.size() > 0)
+ notifyPathChange(changedPaths, oldLeadPath);
+ }
}
/**
@@ -345,29 +474,10 @@ public class DefaultTreeSelectionModel
*/
public void addSelectionPath(TreePath path)
{
- if (! isPathSelected(path))
+ if (path != null)
{
- if (selectionMode == SINGLE_TREE_SELECTION || isSelectionEmpty()
- || ! canPathBeAdded(path))
- setSelectionPath(path);
- else
- {
- TreePath[] temp = new TreePath[selection.length + 1];
- System.arraycopy(selection, 0, temp, 0, selection.length);
- temp[temp.length - 1] = path;
- selection = new TreePath[temp.length];
- System.arraycopy(temp, 0, selection, 0, temp.length);
- }
- }
-
- if (path != leadPath)
- {
- TreePath oldLead = leadPath;
- leadPath = path;
- leadRow = getRow(path);
- leadIndex = selection.length - 1;
- fireValueChanged(new TreeSelectionEvent(this, path, true, oldLead,
- leadPath));
+ TreePath[] add = new TreePath[]{ path };
+ addSelectionPaths(add);
}
}
@@ -380,37 +490,76 @@ public class DefaultTreeSelectionModel
*/
public void addSelectionPaths(TreePath[] paths)
{
- // Must be called, as defined in JDK API 1.4.
- insureUniqueness();
-
- if (paths != null)
+ int length = paths != null ? paths.length : 0;
+ if (length > 0)
{
- TreePath v0 = null;
- for (int i = 0; i < paths.length; i++)
+ if (selectionMode == SINGLE_TREE_SELECTION)
+ setSelectionPaths(paths);
+ else if (selectionMode == CONTIGUOUS_TREE_SELECTION
+ && ! canPathsBeAdded(paths))
+ {
+ if (arePathsContiguous(paths))
+ setSelectionPaths(paths);
+ else
+ setSelectionPaths(new TreePath[] { paths[0] });
+ }
+ else
{
- v0 = paths[i];
- if (! isPathSelected(v0))
+ Vector changedPaths = null;
+ tmpPaths.clear();
+ int validPaths = 0;
+ TreePath oldLeadPath = leadPath;
+ int oldPaths = 0;
+ if (selection != null)
+ oldPaths = selection.length;
+ int i;
+ for (i = 0; i < length; i++)
{
- if (isSelectionEmpty())
- setSelectionPath(v0);
- else
+ if (paths[i] != null)
{
- TreePath[] temp = new TreePath[selection.length + 1];
- System.arraycopy(selection, 0, temp, 0, selection.length);
- temp[temp.length - 1] = v0;
- selection = new TreePath[temp.length];
- System.arraycopy(temp, 0, selection, 0, temp.length);
+ if (! selectedPaths.contains(paths[i]))
+ {
+ validPaths++;
+ if (changedPaths == null)
+ changedPaths = new Vector();
+ changedPaths.add(new PathPlaceHolder(paths[i], true));
+ selectedPaths.add(paths[i]);
+ tmpPaths.add(paths[i]);
+ }
+ leadPath = paths[i];
}
- TreePath oldLead = leadPath;
- leadPath = paths[paths.length - 1];
- leadRow = getRow(leadPath);
- leadIndex = selection.length - 1;
-
- fireValueChanged(new TreeSelectionEvent(this, v0, true,
- oldLead, leadPath));
}
+ if (validPaths > 0)
+ {
+ TreePath[] newSelection = new TreePath[oldPaths + validPaths];
+ if (oldPaths > 0)
+ System.arraycopy(selection, 0, newSelection, 0, oldPaths);
+ if (validPaths != paths.length)
+ {
+ // Some of the paths are already selected, put together
+ // the new selection carefully.
+ Iterator newPaths = tmpPaths.iterator();
+ i = oldPaths;
+ while (newPaths.hasNext())
+ {
+ newSelection[i] = (TreePath) newPaths.next();
+ i++;
+ }
+ }
+ else
+ System.arraycopy(paths, 0, newSelection, oldPaths,
+ validPaths);
+ selection = newSelection;
+ insureUniqueness();
+ updateLeadIndex();
+ resetRowSelection();
+ if (changedPaths != null && changedPaths.size() > 0)
+ notifyPathChange(changedPaths, oldLeadPath);
+ }
+ else
+ leadPath = oldLeadPath;
+ tmpPaths.clear();
}
- insureRowContinuity();
}
}
@@ -422,36 +571,8 @@ public class DefaultTreeSelectionModel
*/
public void removeSelectionPath(TreePath path)
{
- if (isSelectionEmpty())
- return;
-
- int index = - 1;
- if (isPathSelected(path))
- {
- for (int i = 0; i < selection.length; i++)
- {
- if (selection[i].equals(path))
- {
- index = i;
- break;
- }
- }
- TreePath[] temp = new TreePath[selection.length - 1];
- System.arraycopy(selection, 0, temp, 0, index);
- System.arraycopy(selection, index + 1, temp, index, selection.length
- - index - 1);
- selection = new TreePath[temp.length];
- System.arraycopy(temp, 0, selection, 0, temp.length);
-
- // If the removed path was the lead path, set the lead path to null.
- TreePath oldLead = leadPath;
- if (path != null && leadPath != null && path.equals(leadPath))
- leadPath = null;
-
- fireValueChanged(new TreeSelectionEvent(this, path, false, oldLead,
- leadPath));
- insureRowContinuity();
- }
+ if (path != null)
+ removeSelectionPaths(new TreePath[]{ path });
}
/**
@@ -462,40 +583,54 @@ public class DefaultTreeSelectionModel
*/
public void removeSelectionPaths(TreePath[] paths)
{
- if (isSelectionEmpty())
- return;
- if (paths != null)
+ if (paths != null && selection != null && paths.length > 0)
{
- int index = - 1;
- TreePath v0 = null;
- TreePath oldLead = leadPath;
- for (int i = 0; i < paths.length; i++)
+ if (! canPathsBeRemoved(paths))
+ clearSelection();
+ else
{
- v0 = paths[i];
- if (isPathSelected(v0))
+ Vector pathsToRemove = null;
+ for (int i = paths.length - 1; i >= 0; i--)
{
- for (int x = 0; x < selection.length; x++)
+ if (paths[i] != null && selectedPaths.contains(paths[i]))
{
- if (selection[i].equals(v0))
- {
- index = x;
- break;
- }
- if (leadPath != null && leadPath.equals(v0))
+ if (pathsToRemove == null)
+ pathsToRemove = new Vector();
+ selectedPaths.remove(paths[i]);
+ pathsToRemove.add(new PathPlaceHolder(paths[i],
+ false));
+ }
+ }
+ if (pathsToRemove != null)
+ {
+ int numRemove = pathsToRemove.size();
+ TreePath oldLead = leadPath;
+ if (numRemove == selection.length)
+ selection = null;
+ else
+ {
+ selection = new TreePath[selection.length - numRemove];
+ Iterator keep = selectedPaths.iterator();
+ for (int valid = 0; keep.hasNext(); valid++)
+ selection[valid] = (TreePath) keep.next();
+ }
+ // Update lead path.
+ if (leadPath != null && ! selectedPaths.contains(leadPath))
+ {
+ if (selection != null)
+ leadPath = selection[selection.length - 1];
+ else
leadPath = null;
}
- TreePath[] temp = new TreePath[selection.length - 1];
- System.arraycopy(selection, 0, temp, 0, index);
- System.arraycopy(selection, index + 1, temp, index,
- selection.length - index - 1);
- selection = new TreePath[temp.length];
- System.arraycopy(temp, 0, selection, 0, temp.length);
-
- fireValueChanged(new TreeSelectionEvent(this, v0, false,
- oldLead, leadPath));
+ else if (selection != null)
+ leadPath = selection[selection.length - 1];
+ else
+ leadPath = null;
+ updateLeadIndex();
+ resetRowSelection();
+ notifyPathChange(pathsToRemove, oldLead);
}
}
- insureRowContinuity();
}
}
@@ -572,19 +707,22 @@ public class DefaultTreeSelectionModel
*/
public void clearSelection()
{
- if (! isSelectionEmpty())
+ if (selection != null)
{
- TreeSelectionEvent event = new TreeSelectionEvent(
- this, selection, new boolean[selection.length], leadPath, null);
+ int selectionLength = selection.length;
+ boolean[] news = new boolean[selectionLength];
+ Arrays.fill(news, false);
+ TreeSelectionEvent event = new TreeSelectionEvent(this, selection,
+ news, leadPath,
+ null);
leadPath = null;
+ leadIndex = 0;
+ leadRow = 0;
+ selectedPaths.clear();
selection = null;
+ resetRowSelection();
fireValueChanged(event);
}
- else
- {
- leadPath = null;
- selection = null;
- }
}
/**
@@ -650,10 +788,43 @@ public class DefaultTreeSelectionModel
*/
public int[] getSelectionRows()
{
- if (rowMapper == null)
- return null;
- else
- return rowMapper.getRowsForPaths(selection);
+ int[] rows = null;
+ if (rowMapper != null && selection != null)
+ {
+ rows = rowMapper.getRowsForPaths(selection);
+ if (rows != null)
+ {
+ // Find invisible rows.
+ int invisible = 0;
+ for (int i = rows.length - 1; i >= 0; i--)
+ {
+ if (rows[i] == -1)
+ invisible++;
+
+ }
+ // Clean up invisible rows.
+ if (invisible > 0)
+ {
+ if (invisible == rows.length)
+ rows = null;
+ else
+ {
+ int[] newRows = new int[rows.length - invisible];
+ int visCount = 0;
+ for (int i = rows.length - 1; i >= 0; i--)
+ {
+ if (rows[i] != -1)
+ {
+ newRows[visCount] = rows[i];
+ visCount++;
+ }
+ }
+ rows = newRows;
+ }
+ }
+ }
+ }
+ return rows;
}
/**
@@ -663,16 +834,7 @@ public class DefaultTreeSelectionModel
*/
public int getMinSelectionRow()
{
- if ((rowMapper == null) || (selection == null) || (selection.length == 0))
- return - 1;
- else
- {
- int[] rows = rowMapper.getRowsForPaths(selection);
- int minRow = Integer.MAX_VALUE;
- for (int index = 0; index < rows.length; index++)
- minRow = Math.min(minRow, rows[index]);
- return minRow;
- }
+ return listSelectionModel.getMinSelectionIndex();
}
/**
@@ -682,16 +844,7 @@ public class DefaultTreeSelectionModel
*/
public int getMaxSelectionRow()
{
- if ((rowMapper == null) || (selection == null) || (selection.length == 0))
- return - 1;
- else
- {
- int[] rows = rowMapper.getRowsForPaths(selection);
- int maxRow = - 1;
- for (int index = 0; index < rows.length; index++)
- maxRow = Math.max(maxRow, rows[index]);
- return maxRow;
- }
+ return listSelectionModel.getMaxSelectionIndex();
}
/**
@@ -706,29 +859,7 @@ public class DefaultTreeSelectionModel
*/
public boolean isRowSelected(int row)
{
- // Return false if nothing is selected.
- if (isSelectionEmpty())
- return false;
-
- RowMapper mapper = getRowMapper();
-
- if (mapper instanceof AbstractLayoutCache)
- {
- // The absolute majority of cases, unless the TreeUI is very
- // seriously rewritten
- AbstractLayoutCache ama = (AbstractLayoutCache) mapper;
- TreePath path = ama.getPathForRow(row);
- return isPathSelected(path);
- }
- else
- {
- // Generic non optimized implementation.
- int[] rows = mapper.getRowsForPaths(selection);
- for (int i = 0; i < rows.length; i++)
- if (rows[i] == row)
- return true;
- return false;
- }
+ return listSelectionModel.isSelectedIndex(row);
}
/**
@@ -736,7 +867,32 @@ public class DefaultTreeSelectionModel
*/
public void resetRowSelection()
{
- // Nothing to do here.
+ listSelectionModel.clearSelection();
+ if (selection != null && rowMapper != null)
+ {
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ // Update list selection model.
+ for (int i = 0; i < rows.length; i++)
+ {
+ int row = rows[i];
+ if (row != -1)
+ listSelectionModel.addSelectionInterval(row, row);
+ }
+ // Update lead selection.
+ if (leadIndex != -1 && rows != null)
+ leadRow = rows[leadIndex];
+ else if (leadPath != null)
+ {
+ TreePath[] tmp = new TreePath[]{ leadPath };
+ rows = rowMapper.getRowsForPaths(tmp);
+ leadRow = rows != null ? rows[0] : -1;
+ }
+ else
+ leadRow = -1;
+ insureRowContinuity();
+ }
+ else
+ leadRow = -1;
}
/**
@@ -766,6 +922,8 @@ public class DefaultTreeSelectionModel
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
+ if (changeSupport == null)
+ changeSupport = new SwingPropertyChangeSupport(this);
changeSupport.addPropertyChangeListener(listener);
}
@@ -776,7 +934,8 @@ public class DefaultTreeSelectionModel
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
{
- changeSupport.removePropertyChangeListener(listener);
+ if (changeSupport != null)
+ changeSupport.removePropertyChangeListener(listener);
}
/**
@@ -787,7 +946,12 @@ public class DefaultTreeSelectionModel
*/
public PropertyChangeListener[] getPropertyChangeListeners()
{
- return changeSupport.getPropertyChangeListeners();
+ PropertyChangeListener[] listeners = null;
+ if (changeSupport != null)
+ listeners = changeSupport.getPropertyChangeListeners();
+ else
+ listeners = new PropertyChangeListener[0];
+ return listeners;
}
/**
@@ -801,67 +965,41 @@ public class DefaultTreeSelectionModel
*/
protected void insureRowContinuity()
{
- if (selection == null || selection.length < 2)
- return;
- else if (selectionMode == CONTIGUOUS_TREE_SELECTION)
+ if (selectionMode == CONTIGUOUS_TREE_SELECTION && selection != null
+ && rowMapper != null)
{
- if (rowMapper == null)
- // This is the best we can do without the row mapper:
- selectOne();
- else
+ int min = listSelectionModel.getMinSelectionIndex();
+ if (min != -1)
{
- int[] rows = rowMapper.getRowsForPaths(selection);
- Arrays.sort(rows);
- int i;
- for (i = 1; i < rows.length; i++)
- {
- if (rows[i - 1] != rows[i] - 1)
- // Break if no longer continuous.
- break;
- }
-
- if (i < rows.length)
+ int max = listSelectionModel.getMaxSelectionIndex();
+ for (int i = min; i <= max; i++)
{
- TreePath[] ns = new TreePath[i];
- for (int j = 0; j < ns.length; j++)
- ns[i] = getPath(j);
- setSelectionPaths(ns);
+ if (! listSelectionModel.isSelectedIndex(i))
+ {
+ if (i == min)
+ clearSelection();
+ else
+ {
+ TreePath[] newSelection = new TreePath[i - min];
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ for (int j = 0; j < rows.length; j++)
+ {
+ if (rows[j] < i)
+ newSelection[rows[j] - min] = selection[j];
+ }
+ setSelectionPaths(newSelection);
+ break;
+ }
+ }
}
}
}
- else if (selectionMode == SINGLE_TREE_SELECTION)
- selectOne();
+ else if (selectionMode == SINGLE_TREE_SELECTION && selection != null
+ && selection.length > 1)
+ setSelectionPath(selection[0]);
}
/**
- * Keep only one (normally last or leading) path in the selection.
- */
- private void selectOne()
- {
- if (leadIndex > 0 && leadIndex < selection.length)
- setSelectionPath(selection[leadIndex]);
- else
- setSelectionPath(selection[selection.length - 1]);
- }
-
- /**
- * Get path for the given row that must be in the current selection.
- */
- private TreePath getPath(int row)
- {
- if (rowMapper instanceof AbstractLayoutCache)
- return ((AbstractLayoutCache) rowMapper).getPathForRow(row);
- else
- {
- int[] rows = rowMapper.getRowsForPaths(selection);
- for (int i = 0; i < rows.length; i++)
- if (rows[i] == row)
- return selection[i];
- }
- throw new InternalError(row + " not in selection");
- }
-
- /**
* Returns <code>true</code> if the paths are contiguous (take subsequent
* rows in the diplayed tree view. The method returns <code>true</code> if
* we have no RowMapper assigned.
@@ -875,16 +1013,36 @@ public class DefaultTreeSelectionModel
if (rowMapper == null || paths.length < 2)
return true;
- int[] rows = rowMapper.getRowsForPaths(paths);
-
- // The patches may not be sorted.
- Arrays.sort(rows);
-
- for (int i = 1; i < rows.length; i++)
+ int length = paths.length;
+ TreePath[] tmp = new TreePath[1];
+ tmp[0] = paths[0];
+ int min = rowMapper.getRowsForPaths(tmp)[0];
+ BitSet selected = new BitSet();
+ int valid = 0;
+ for (int i = 0; i < length; i++)
{
- if (rows[i - 1] != rows[i] - 1)
- return false;
+ if (paths[i] != null)
+ {
+ tmp[0] = paths[i];
+ int[] rows = rowMapper.getRowsForPaths(tmp);
+ if (rows == null)
+ return false; // No row mapping yet, can't be selected.
+ int row = rows[0];
+ if (row == -1 || row < (min - length) || row > (min + length))
+ return false; // Not contiguous.
+ min = Math.min(min, row);
+ if (! selected.get(row))
+ {
+ selected.set(row);
+ valid++;
+ }
+
+ }
}
+ int max = valid + min;
+ for (int i = min; i < max; i++)
+ if (! selected.get(i))
+ return false; // Not contiguous.
return true;
}
@@ -904,34 +1062,51 @@ public class DefaultTreeSelectionModel
*/
protected boolean canPathsBeAdded(TreePath[] paths)
{
- if (rowMapper == null || isSelectionEmpty()
- || selectionMode == DISCONTIGUOUS_TREE_SELECTION)
+ if (paths == null || paths.length == 0 || rowMapper == null
+ || selection == null || selectionMode == DISCONTIGUOUS_TREE_SELECTION)
return true;
-
- TreePath [] all = new TreePath[paths.length + selection.length];
- System.arraycopy(paths, 0, all, 0, paths.length);
- System.arraycopy(selection, 0, all, paths.length, selection.length);
- return arePathsContiguous(all);
+ BitSet selected = new BitSet();
+ int min = listSelectionModel.getMinSelectionIndex();
+ int max = listSelectionModel.getMaxSelectionIndex();
+ TreePath[] tmp = new TreePath[1];
+ if (min != -1)
+ {
+ // Set the bitmask of selected elements.
+ for (int i = min; i <= max; i++)
+ selected.set(i);
+ }
+ else
+ {
+ tmp[0] = paths[0];
+ min = rowMapper.getRowsForPaths(tmp)[0];
+ max = min;
+ }
+ // Mark new paths as selected.
+ for (int i = paths.length - 1; i >= 0; i--)
+ {
+ if (paths[i] != null)
+ {
+ tmp[0] = paths[i];
+ int[] rows = rowMapper.getRowsForPaths(tmp);
+ if (rows == null)
+ return false; // Now row mapping yet, can't be selected.
+ int row = rows[0];
+ if (row == -1)
+ return false; // Now row mapping yet, can't be selected.
+ min = Math.min(min, row);
+ max = Math.max(max, row);
+ selected.set(row);
+ }
+ }
+ // Now look if the new selection would be contiguous.
+ for (int i = min; i <= max; i++)
+ if (! selected.get(i))
+ return false;
+ return true;
}
/**
- * Checks if the single path can be added to selection.
- */
- private boolean canPathBeAdded(TreePath path)
- {
- if (rowMapper == null || isSelectionEmpty()
- || selectionMode == DISCONTIGUOUS_TREE_SELECTION)
- return true;
-
- TreePath[] all = new TreePath[selection.length + 1];
- System.arraycopy(selection, 0, all, 0, selection.length);
- all[all.length - 1] = path;
-
- return arePathsContiguous(all);
- }
-
- /**
* Checks if the paths can be removed without breaking the continuity of the
* selection according to selectionMode.
*
@@ -966,20 +1141,23 @@ public class DefaultTreeSelectionModel
* method will call listeners if invoked, but it is not called from the
* implementation of this class.
*
- * @param vPathes the vector of the changed patches
+ * @param vPaths the vector of the changed patches
* @param oldLeadSelection the old selection index
*/
- protected void notifyPathChange(Vector vPathes, TreePath oldLeadSelection)
+ protected void notifyPathChange(Vector vPaths, TreePath oldLeadSelection)
{
- TreePath[] pathes = new TreePath[vPathes.size()];
- for (int i = 0; i < pathes.length; i++)
- pathes[i] = (TreePath) vPathes.get(i);
- boolean[] news = new boolean[pathes.length];
- for (int i = 0; i < news.length; i++)
- news[i] = isPathSelected(pathes[i]);
+ int numChangedPaths = vPaths.size();
+ boolean[] news = new boolean[numChangedPaths];
+ TreePath[] paths = new TreePath[numChangedPaths];
+ for (int i = 0; i < numChangedPaths; i++)
+ {
+ PathPlaceHolder p = (PathPlaceHolder) vPaths.get(i);
+ news[i] = p.isNew;
+ paths[i] = p.path;
+ }
- TreeSelectionEvent event = new TreeSelectionEvent(this, pathes, news,
+ TreeSelectionEvent event = new TreeSelectionEvent(this, paths, news,
oldLeadSelection,
leadPath);
fireValueChanged(event);
@@ -991,22 +1169,20 @@ public class DefaultTreeSelectionModel
*/
protected void updateLeadIndex()
{
- if (isSelectionEmpty())
+ leadIndex = -1;
+ if (leadPath != null)
{
- leadRow = leadIndex = - 1;
- }
- else
- {
- leadRow = getRow(leadPath);
- for (int i = 0; i < selection.length; i++)
+ leadRow = -1;
+ if (selection == null)
+ leadPath = null;
+ else
{
- if (selection[i].equals(leadPath))
+ for (int i = selection.length - 1; i >= 0 && leadIndex == -1; i--)
{
- leadIndex = i;
- break;
+ if (selection[i] == leadPath)
+ leadIndex = i;
}
}
- leadIndex = leadRow;
}
}
diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java
index b256f1fe9..8c70c13af 100644
--- a/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/javax/swing/tree/VariableHeightLayoutCache.java
@@ -40,6 +40,7 @@ package javax.swing.tree;
import gnu.javax.swing.tree.GnuPath;
import java.awt.Rectangle;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
@@ -60,8 +61,11 @@ import javax.swing.event.TreeModelEvent;
* @author Audrius Meskauskas
*/
public class VariableHeightLayoutCache
- extends AbstractLayoutCache
+ extends AbstractLayoutCache
{
+
+ private static final Rectangle RECT_CACHE = new Rectangle();
+
/**
* The cached node record.
*/
@@ -73,8 +77,8 @@ public class VariableHeightLayoutCache
depth = aDepth;
parent = aParent;
node = aNode;
-
- isExpanded = expanded.contains(aNode);
+ isExpanded = expanded.contains(aNode);
+ bounds = new Rectangle(0, -1, 0, 0);
}
/**
@@ -102,7 +106,7 @@ public class VariableHeightLayoutCache
* Using this field saves one hashtable access operation.
*/
final boolean isExpanded;
-
+
/**
* The cached bounds of the tree row.
*/
@@ -160,11 +164,6 @@ public class VariableHeightLayoutCache
*/
Rectangle getBounds()
{
- // This method may be called in the context when the tree rectangle is
- // not known. To work around this, it is assumed near infinitely large.
- if (bounds == null)
- bounds = getNodeDimensions(node, row, depth, isExpanded,
- new Rectangle());
return bounds;
}
}
@@ -182,7 +181,7 @@ public class VariableHeightLayoutCache
/**
* Maps row numbers to nodes.
*/
- Hashtable row2node = new Hashtable();
+ ArrayList row2node = new ArrayList();
/**
* If true, the row map must be recomputed before using.
@@ -236,45 +235,54 @@ public class VariableHeightLayoutCache
return;
Object root = treeModel.getRoot();
-
- if (rootVisible)
- {
- countRows(root, null, 0);
- }
- else
- {
- int sc = treeModel.getChildCount(root);
- for (int i = 0; i < sc; i++)
- {
- Object child = treeModel.getChild(root, i);
- countRows(child, root, 0);
- }
- }
+ countRows(root, null, 0, 0);
dirty = false;
}
/**
* Recursively counts all rows in the tree.
*/
- private final void countRows(Object node, Object parent, int depth)
+ private final int countRows(Object node, Object parent, int depth, int y)
{
- Integer n = new Integer(row2node.size());
- row2node.put(n, node);
-
- NodeRecord nr = new NodeRecord(n.intValue(), depth, node, parent);
+ boolean visible = node != treeModel.getRoot() || rootVisible;
+ int row = row2node.size();
+ if (visible)
+ {
+ row2node.add(node);
+ }
+ NodeRecord nr = new NodeRecord(row, depth, node, parent);
+ NodeDimensions d = getNodeDimensions();
+ Rectangle r = RECT_CACHE;
+ if (d != null)
+ r = d.getNodeDimensions(node, row, depth, nr.isExpanded, r);
+ else
+ r.setBounds(0, 0, 0, 0);
+
+ if (! visible)
+ r.y = -1;
+ else
+ r.y = Math.max(0, y);
+
+ if (isFixedRowHeight())
+ r.height = getRowHeight();
+
+ nr.bounds.setBounds(r);
nodes.put(node, nr);
-
- // For expanded nodes
+
+ if (visible)
+ y += r.height;
+
+ int sc = treeModel.getChildCount(node);
+ int deeper = depth + 1;
if (expanded.contains(node))
{
- int sc = treeModel.getChildCount(node);
- int deeper = depth + 1;
for (int i = 0; i < sc; i++)
{
Object child = treeModel.getChild(node, i);
- countRows(child, node, deeper);
+ y = countRows(child, node, deeper, y);
}
}
+ return y;
}
/**
@@ -309,10 +317,14 @@ public class VariableHeightLayoutCache
public void setExpandedState(TreePath path, boolean isExpanded)
{
if (isExpanded)
- expanded.add(path.getLastPathComponent());
+ {
+ int length = path.getPathCount();
+ for (int i = 0; i < length; i++)
+ expanded.add(path.getPathComponent(i));
+ }
else
expanded.remove(path.getLastPathComponent());
-
+
dirty = true;
}
@@ -340,30 +352,20 @@ public class VariableHeightLayoutCache
if (dirty)
update();
- // The RI allows null arguments for rect, in which case a new Rectangle
- // is created.
- if (rect == null)
- rect = new Rectangle();
-
Object last = path.getLastPathComponent();
+ Rectangle result = null;
NodeRecord r = (NodeRecord) nodes.get(last);
- if (r == null)
- // This node is not visible.
- {
- rect.x = rect.y = rect.width = rect.height = 0;
- }
- else
+ if (r != null)
{
- if (r.bounds == null)
- {
- Rectangle dim = getNodeDimensions(last, r.row, r.depth,
- r.isExpanded, rect);
- r.bounds = dim;
- }
-
- rect.setRect(r.bounds);
+ // The RI allows null arguments for rect, in which case a new Rectangle
+ // is created.
+ result = rect;
+ if (result == null)
+ result = new Rectangle(r.bounds);
+ else
+ result.setBounds(r.bounds);
}
- return rect;
+ return result;
}
/**
@@ -376,14 +378,17 @@ public class VariableHeightLayoutCache
{
if (dirty)
update();
- Object last = row2node.get(new Integer(row));
- if (last == null)
- return null;
- else
+
+ TreePath path = null;
+ // Search row in the nodes map. TODO: This is inefficient, optimize this.
+ Enumeration nodesEnum = nodes.elements();
+ while (nodesEnum.hasMoreElements() && path == null)
{
- NodeRecord r = (NodeRecord) nodes.get(last);
- return r.getPath();
+ NodeRecord record = (NodeRecord) nodesEnum.nextElement();
+ if (record.row == row)
+ path = record.getPath();
}
+ return path;
}
/**
@@ -396,7 +401,9 @@ public class VariableHeightLayoutCache
{
if (path == null)
return -1;
- if (dirty) update();
+
+ if (dirty)
+ update();
NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
if (r == null)
@@ -474,7 +481,7 @@ public class VariableHeightLayoutCache
*/
public int getVisibleChildCount(TreePath path)
{
- if (isExpanded(path))
+ if (! isExpanded(path) || treeModel == null)
return 0;
else
return treeModel.getChildCount(path.getLastPathComponent());
@@ -499,7 +506,7 @@ public class VariableHeightLayoutCache
{
node = parentPath.getPathComponent(i);
nr = (NodeRecord) nodes.get(node);
- if (nr.row >= 0)
+ if (nr != null && nr.row >= 0)
p.add(node);
}
return p.elements();
@@ -564,15 +571,11 @@ public class VariableHeightLayoutCache
public void setModel(TreeModel newModel)
{
treeModel = newModel;
- // We need to clear the table and update the layout,
- // so that we don't end up with wrong data in the tables.
- expanded.clear();
- update();
+ dirty = true;
if (treeModel != null)
{
// The root node is expanded by default.
expanded.add(treeModel.getRoot());
- dirty = true;
}
}
@@ -596,15 +599,14 @@ public class VariableHeightLayoutCache
{
if (dirty)
update();
- totalHeight = 0;
- Enumeration en = nodes.elements();
- while (en.hasMoreElements())
+ int height = 0;
+ int rowCount = getRowCount();
+ if (rowCount > 0)
{
- NodeRecord nr = (NodeRecord) en.nextElement();
- Rectangle r = nr.getBounds();
- totalHeight += r.height;
+ NodeRecord last = (NodeRecord) nodes.get(row2node.get(rowCount - 1));
+ height = last.bounds.y + last.bounds.height;
}
- return totalHeight;
+ return height;
}
/**
@@ -620,10 +622,36 @@ public class VariableHeightLayoutCache
while (en.hasMoreElements())
{
NodeRecord nr = (NodeRecord) en.nextElement();
- Rectangle r = nr.getBounds();
- if (r.x + r.width > maximalWidth)
- maximalWidth = r.x + r.width;
+ if (nr != null)
+ {
+ Rectangle r = nr.getBounds();
+ int width = r.x + r.width;
+ if (width > maximalWidth)
+ maximalWidth = width;
+ }
}
return maximalWidth;
}
+
+ /**
+ * Sets the node dimensions and invalidates the cached layout.
+ *
+ * @param dim the dimensions to set
+ */
+ public void setNodeDimensions(NodeDimensions dim)
+ {
+ super.setNodeDimensions(dim);
+ dirty = true;
+ }
+
+ /**
+ * Sets the row height and marks the layout as invalid.
+ *
+ * @param height the row height to set
+ */
+ public void setRowHeight(int height)
+ {
+ super.setRowHeight(height);
+ dirty = true;
+ }
}
diff --git a/native/jawt/jawt.c b/native/jawt/jawt.c
index a41786850..4ebb105d7 100644
--- a/native/jawt/jawt.c
+++ b/native/jawt/jawt.c
@@ -116,6 +116,8 @@ static JAWT_DrawingSurfaceInfo*
surface->target);
surface_info_x11->visualID = classpath_jawt_get_visualID (surface->env,
surface->target);
+ surface_info_x11->depth = classpath_jawt_get_depth (surface->env,
+ surface->target);
/* FIXME: also include bounding rectangle of drawing surface */
/* FIXME: also include current clipping region */
diff --git a/native/jni/classpath/classpath_jawt.h b/native/jni/classpath/classpath_jawt.h
index 32a04dc5c..35c734a57 100644
--- a/native/jni/classpath/classpath_jawt.h
+++ b/native/jni/classpath/classpath_jawt.h
@@ -54,6 +54,7 @@ jint classpath_jawt_get_awt_version (void);
Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas);
Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas);
VisualID classpath_jawt_get_visualID (JNIEnv* env, jobject canvas);
+int classpath_jawt_get_depth (JNIEnv* env, jobject canvas);
jint classpath_jawt_lock (void);
void classpath_jawt_unlock (void);
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c
index 607b54d57..cd3f5161d 100644
--- a/native/jni/classpath/jcl.c
+++ b/native/jni/classpath/jcl.c
@@ -58,7 +58,7 @@ static jmethodID rawData_mid = NULL;
/*
* JNI OnLoad constructor.
*/
-jint
+JNIEXPORT jint JNICALL
JNI_OnLoad (JavaVM *vm, void *reserved __attribute__((unused)))
{
JNIEnv *env;
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
index 0a35a3f18..11b0426c6 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
@@ -49,7 +49,6 @@ exception statement from your version. */
#include <stdio.h>
#include <stdlib.h>
-static void install_font_peer(cairo_t *cr, struct peerfont *pfont);
static void update_pattern_transform (struct cairographics2d *gr);
/**
@@ -327,8 +326,6 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
g_assert (pfont != NULL);
- install_font_peer(gr->cr, pfont);
-
glyphs = g_malloc( sizeof(cairo_glyph_t) * n);
g_assert (glyphs != NULL);
@@ -354,6 +351,37 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFont
+(JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
+ jlong pointer, jobject font)
+{
+ struct cairographics2d *gr = NULL;
+ struct peerfont *pfont = NULL;
+ FT_Face face = NULL;
+ cairo_font_face_t *ft = NULL;
+
+ gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
+ g_assert (pfont != NULL);
+
+ face = pango_fc_font_lock_face( (PangoFcFont *)pfont->font );
+ g_assert (face != NULL);
+
+ ft = cairo_ft_font_face_create_for_ft_face (face, 0);
+ g_assert (ft != NULL);
+
+ cairo_set_font_face (gr->cr, ft);
+ cairo_set_font_size (gr->cr,
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
+
+ cairo_font_face_destroy (ft);
+ pango_fc_font_unlock_face((PangoFcFont *)pfont->font);
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetOperator
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer, jint op)
@@ -748,45 +776,6 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFillRect
cairo_fill(gr->cr);
}
-
-/************************** FONT STUFF ****************************/
-static void
-install_font_peer(cairo_t *cr,
- struct peerfont *pfont)
-{
- cairo_font_face_t *ft;
- FT_Face face = NULL;
-
- g_assert(cr != NULL);
- g_assert(pfont != NULL);
-
- if (pfont->graphics_resource == NULL)
- {
- face = pango_fc_font_lock_face( (PangoFcFont *)pfont->font );
- g_assert (face != NULL);
-
- ft = cairo_ft_font_face_create_for_ft_face (face, 0);
- g_assert (ft != NULL);
-
- cairo_set_font_face (cr, ft);
- /* cairo_font_face_destroy (ft);*/
- cairo_set_font_size (cr,
- (pango_font_description_get_size (pfont->desc) /
- (double)PANGO_SCALE));
- ft = cairo_get_font_face (cr);
- pango_fc_font_unlock_face( (PangoFcFont *)pfont->font );
- pfont->graphics_resource = ft;
- }
- else
- {
- ft = (cairo_font_face_t *) pfont->graphics_resource;
- cairo_set_font_face (cr, ft);
- cairo_set_font_size (cr,
- (pango_font_description_get_size (pfont->desc) /
- (double)PANGO_SCALE));
- }
-}
-
static void
update_pattern_transform (struct cairographics2d *gr)
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
index 766964314..144ca0e8a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
@@ -188,3 +188,47 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage
gdk_threads_leave ();
}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_maximize
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gtk_window_maximize (GTK_WINDOW (ptr));
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_unmaximize
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gtk_window_unmaximize (GTK_WINDOW (ptr));
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_iconify
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gtk_window_iconify (GTK_WINDOW (ptr));
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_deiconify
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ gdk_threads_enter ();
+ ptr = NSA_GET_PTR (env, obj);
+ gtk_window_deiconify (GTK_WINDOW (ptr));
+ gdk_threads_leave ();
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index 969b7bc5c..0f868eaed 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -77,8 +77,10 @@ struct state_table *cp_gtk_native_state_table;
struct state_table *cp_gtk_native_global_ref_table;
static jclass gtkgenericpeer;
+static jclass gtktoolkit;
static JavaVM *java_vm;
static jmethodID printCurrentThreadID;
+static jmethodID setRunningID;
union env_union
{
@@ -99,7 +101,9 @@ GtkWindowGroup *cp_gtk_global_window_group;
double cp_gtk_dpi_conversion_factor;
static void init_glib_threads(JNIEnv *, jint);
-
+static gboolean post_set_running_flag (gpointer);
+static gboolean set_running_flag (gpointer);
+static gboolean clear_running_flag (gpointer);
static void init_dpi_conversion_factor (void);
static void dpi_changed_cb (GtkSettings *settings,
GParamSpec *pspec);
@@ -199,6 +203,10 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
cp_gtk_global_window_group = gtk_window_group_new ();
init_dpi_conversion_factor ();
+
+ gtktoolkit = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GtkMainThread");
+ setRunningID = (*env)->GetStaticMethodID (env, gtktoolkit,
+ "setRunning", "(Z)V");
}
@@ -324,6 +332,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkMain
{
gdk_threads_enter ();
+ gtk_init_add (post_set_running_flag, NULL);
+ gtk_quit_add (gtk_main_level (), clear_running_flag, NULL);
+
gtk_main ();
gdk_threads_leave ();
@@ -502,3 +513,28 @@ gdk_color_to_java_color (GdkColor gdk_color)
return (jint) (0xff000000 | (red << 16) | (green << 8) | blue);
}
+
+static gboolean
+post_set_running_flag (gpointer data __attribute__((unused)))
+{
+ g_idle_add (set_running_flag, NULL);
+ return FALSE;
+}
+
+static gboolean
+set_running_flag (gpointer data __attribute__((unused)))
+{
+ (*cp_gtk_gdk_env ())->CallStaticVoidMethod (cp_gtk_gdk_env (),
+ gtktoolkit,
+ setRunningID, TRUE);
+ return FALSE;
+}
+
+static gboolean
+clear_running_flag (gpointer data __attribute__((unused)))
+{
+ (*cp_gtk_gdk_env ())->CallStaticVoidMethod (cp_gtk_gdk_env (),
+ gtktoolkit,
+ setRunningID, FALSE);
+ return FALSE;
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index 3f288af5c..aa70b9d2d 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -44,7 +44,6 @@ exception statement from your version. */
#include <X11/Xatom.h>
#include <gdk/gdkkeysyms.h>
-#define AWT_WINDOW_OPENED 200
#define AWT_WINDOW_CLOSING 201
#define AWT_WINDOW_CLOSED 202
#define AWT_WINDOW_ICONIFIED 203
@@ -55,6 +54,10 @@ exception statement from your version. */
#define AWT_WINDOW_LOST_FOCUS 208
#define AWT_WINDOW_STATE_CHANGED 209
+#define AWT_FRAME_NORMAL 0
+#define AWT_FRAME_ICONIFIED 1
+#define AWT_FRAME_MAXIMIZED_BOTH 6
+
/* Virtual Keys */
/* This list should be kept in the same order as the VK_ field
declarations in KeyEvent.java. */
@@ -1046,7 +1049,6 @@ static gboolean window_delete_cb (GtkWidget *widget, GdkEvent *event,
jobject peer);
static void window_destroy_cb (GtkWidget *widget, GdkEvent *event,
jobject peer);
-static void window_show_cb (GtkWidget *widget, jobject peer);
static void window_focus_state_change_cb (GtkWidget *widget,
GParamSpec *pspec,
jobject peer);
@@ -1322,9 +1324,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals
g_signal_connect (G_OBJECT (ptr), "destroy-event",
G_CALLBACK (window_destroy_cb), *gref);
- g_signal_connect (G_OBJECT (ptr), "show",
- G_CALLBACK (window_show_cb), *gref);
-
g_signal_connect (G_OBJECT (ptr), "notify::has-toplevel-focus",
G_CALLBACK (window_focus_state_change_cb), *gref);
@@ -1661,16 +1660,6 @@ window_destroy_cb (GtkWidget *widget __attribute__((unused)),
}
static void
-window_show_cb (GtkWidget *widget __attribute__((unused)),
- jobject peer)
-{
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
- postWindowEventID,
- (jint) AWT_WINDOW_OPENED,
- (jobject) NULL, (jint) 0);
-}
-
-static void
window_focus_state_change_cb (GtkWidget *widget,
GParamSpec *pspec __attribute__((unused)),
jobject peer)
@@ -1718,41 +1707,24 @@ window_window_state_cb (GtkWidget *widget __attribute__((unused)),
GdkEvent *event,
jobject peer)
{
- jint new_state;
-
- /* Handle WINDOW_ICONIFIED and WINDOW_DEICONIFIED events. */
- if (event->window_state.changed_mask & GDK_WINDOW_STATE_ICONIFIED)
- {
- /* We've either been iconified or deiconified. */
- if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED)
- {
- /* We've been iconified. */
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
- postWindowEventID,
- (jint) AWT_WINDOW_ICONIFIED,
- (jobject) NULL, (jint) 0);
- }
- else
- {
- /* We've been deiconified. */
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
- postWindowEventID,
- (jint) AWT_WINDOW_DEICONIFIED,
- (jobject) NULL, (jint) 0);
- }
- }
-
- /* Post a WINDOW_STATE_CHANGED event, passing the new frame state to
- GtkWindowPeer. */
- new_state = AWT_FRAME_STATE_NORMAL;
-
- if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED)
- new_state |= AWT_FRAME_STATE_ICONIFIED;
+ jint new_java_state = 0;
+ /* Put together the new state and let the java side figure out what
+ * to post */
+ GdkWindowState new_state = event->window_state.new_window_state;
+ /* The window can be either iconfified, maximized, iconified + maximized
+ * or normal. */
+ if ((new_state & GDK_WINDOW_STATE_ICONIFIED) != 0)
+ new_java_state |= AWT_FRAME_ICONIFIED;
+ if ((new_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+ new_java_state |= AWT_FRAME_MAXIMIZED_BOTH;
+ if ((new_state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_ICONIFIED))
+ == 0)
+ new_java_state = AWT_FRAME_NORMAL;
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_STATE_CHANGED,
- (jobject) NULL, new_state);
+ (jobject) NULL, new_java_state);
return TRUE;
}
diff --git a/native/jni/gtk-peer/gtk_jawt.c b/native/jni/gtk-peer/gtk_jawt.c
index 763db8d1e..2348a63fb 100644
--- a/native/jni/gtk-peer/gtk_jawt.c
+++ b/native/jni/gtk-peer/gtk_jawt.c
@@ -122,6 +122,41 @@ classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
/* Does not require locking: meant to be called after the drawing
surface is locked. */
+int
+classpath_jawt_get_depth (JNIEnv* env, jobject canvas)
+{
+ GtkWidget *widget;
+ GdkVisual *visual;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ widget = GTK_WIDGET (ptr);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ visual = gtk_widget_get_visual (widget);
+ g_assert (visual != NULL);
+
+ return visual->depth;
+ }
+ else
+ return (VisualID) NULL;
+}
+
+/* Does not require locking: meant to be called after the drawing
+ surface is locked. */
Drawable
classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
{
diff --git a/native/jni/java-net/Makefile.am b/native/jni/java-net/Makefile.am
index b743f2ffe..1278b946c 100644
--- a/native/jni/java-net/Makefile.am
+++ b/native/jni/java-net/Makefile.am
@@ -13,7 +13,6 @@ libjavanet_la_SOURCES = javanet.c \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
java_net_VMURLConnection.c \
- gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
diff --git a/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c b/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
index 6ebb64fa5..53ef04d47 100644
--- a/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
@@ -40,6 +40,8 @@ exception statement from your version. */
#include <config.h>
#endif /* HAVE_CONFIG_H */
+#include <config-int.h>
+
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -47,6 +49,7 @@ exception statement from your version. */
#include <ifaddrs.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <net/if.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
@@ -56,16 +59,14 @@ exception statement from your version. */
#include <jni.h>
#include <jcl.h>
-/* #include "javanet.h" */
+#include "cpnative.h"
+#include "cpnet.h"
+#include "cpio.h"
+#include "javanet.h"
#include "gnu_java_net_VMPlainSocketImpl.h"
-#define IO_EXCEPTION "java/io/IOException"
-#define SOCKET_EXCEPTION "java/net/SocketException"
-#define BIND_EXCEPTION "java/net/BindException"
-
-#define THROW_NO_NETWORK(env) JCL_ThrowException (env, "java/lang/InternalError", "this platform not configured for network support")
-
+#define THROW_NO_NETWORK(env) JCL_ThrowException (env, "java/lang/InternalError", "this platform not configured for network support")
/*
* Class: gnu_java_net_VMPlainSocketImpl
@@ -102,6 +103,8 @@ Java_gnu_java_net_VMPlainSocketImpl_bind (JNIEnv *env,
if (-1 == ret)
JCL_ThrowException (env, BIND_EXCEPTION, strerror (errno));
+
+ cpio_closeOnExec(ret);
}
@@ -158,7 +161,10 @@ Java_gnu_java_net_VMPlainSocketImpl_listen (JNIEnv *env,
}
-/* These constants are also defined in java/net/SocketOptions.java */
+/* These constants are also defined in java/net/SocketOptions.java.
+ * Except for CPNET_IP_TTL which is defined in
+ * vm/reference/gnu/java/net/VMPlainSocketImpl.java .
+ */
enum java_sockopt {
CPNET_SO_KEEPALIVE = 0x8,
CPNET_SO_LINGER = 0x80,
@@ -173,7 +179,8 @@ enum java_sockopt {
CPNET_IP_MULTICAST_IF = 0x10,
CPNET_IP_MULTICAST_IF2 = 0x1F,
CPNET_IP_MULTICAST_LOOP = 0x12,
- CPNET_IP_TOS = 0x03
+ CPNET_IP_TOS = 0x03,
+ CPNET_IP_TTL = 0x1E61
};
@@ -195,7 +202,7 @@ Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env,
struct timeval _timeo;
void *optval = (void *) &_value;
socklen_t optlen = sizeof (int);
-
+
switch (joption)
{
case CPNET_IP_MULTICAST_LOOP:
@@ -209,7 +216,7 @@ Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env,
case CPNET_SO_LINGER:
optname = SO_LINGER;
- if (_value == 0)
+ if (_value == -1)
_linger.l_onoff = 0;
else
_linger.l_onoff = 1;
@@ -256,6 +263,11 @@ Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env,
optname = IP_TOS;
break;
+ case CPNET_IP_TTL:
+ level = IPPROTO_IP;
+ optname = IP_TTL;
+ break;
+
case CPNET_SO_BINDADDR:
case CPNET_IP_MULTICAST_IF:
case CPNET_IP_MULTICAST_IF2:
@@ -339,6 +351,11 @@ Java_gnu_java_net_VMPlainSocketImpl_getOption (JNIEnv *env,
optname = IP_TOS;
break;
+ case CPNET_IP_TTL:
+ level = IPPROTO_IP;
+ optname = IP_TTL;
+ break;
+
case CPNET_SO_BINDADDR:
case CPNET_IP_MULTICAST_IF:
case CPNET_IP_MULTICAST_IF2:
@@ -349,14 +366,108 @@ Java_gnu_java_net_VMPlainSocketImpl_getOption (JNIEnv *env,
if (getsockopt (fd, level, optname, optval, &optlen) == -1)
JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ /* Returns the linger value if it is enabled or -1 in case
+ * it is disabled. This is how the Java API expects it.
+ */
if (joption == CPNET_SO_LINGER)
- return linger.l_linger;
+ return (linger.l_onoff) ? linger.l_linger : -1;
if (joption == CPNET_SO_TIMEOUT)
return (timeo.tv_sec * 1000) + (timeo.tv_usec / 1000);
return value;
}
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd,
+ jint optionId __attribute__((unused)),
+ jobject addr)
+{
+ int result;
+ cpnet_address *cpaddr = _javanet_get_ip_netaddr (env, addr);
+
+ if ((*env)->ExceptionOccurred (env))
+ return;
+
+ result = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+ (struct sockaddr *) cpaddr->data, cpaddr->len);
+
+ cpnet_freeAddress (env, cpaddr);
+
+ if (result == -1)
+ JCL_ThrowException (env, SOCKET_EXCEPTION, cpnative_getErrorString (errno));
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd,
+ jint optionId __attribute__((unused)),
+ jstring ifname)
+{
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6
+ int result;
+ const char *str_ifname = JCL_jstring_to_cstring (env, ifname);
+ u_int if_index;
+
+ if ((*env)->ExceptionOccurred (env))
+ {
+ JCL_free_cstring(env, ifname, str_ifname);
+ return;
+ }
+
+ if_index = if_nametoindex(str_ifname);
+ if (!if_index)
+ {
+ JCL_free_cstring(env, ifname, str_ifname);
+ JCL_ThrowException (env, SOCKET_EXCEPTION, "interface does not exist");
+ return;
+ }
+
+ result = setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+ (u_int *) &if_index, sizeof(if_index));
+
+ JCL_free_cstring(env, ifname, str_ifname);
+
+ if (result == -1)
+ JCL_ThrowException (env, SOCKET_EXCEPTION, cpnative_getErrorString (errno));
+#else
+ (void) fd;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+ (void) fd;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
+}
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd,
+ jint optionId __attribute__((unused)))
+{
+ jobject obj;
+ cpnet_address *cpaddr;
+ int result = cpnet_getMulticastIF (env, fd, &cpaddr);
+
+ if (result != CPNATIVE_OK)
+ {
+ JCL_ThrowException (env, SOCKET_EXCEPTION,
+ cpnative_getErrorString (result));
+ return (0);
+ }
+
+ obj = _javanet_create_inetaddress (env, cpaddr);
+ cpnet_freeAddress (env, cpaddr);
+
+ return obj;
+}
+
/*
* Class: gnu_java_net_VMPlainSocketImpl
@@ -538,7 +649,7 @@ Java_gnu_java_net_VMPlainSocketImpl_leave6 (JNIEnv *env,
(*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
- if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
&maddr, sizeof (struct ipv6_mreq)))
JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
#else
@@ -555,8 +666,8 @@ Java_gnu_java_net_VMPlainSocketImpl_leave6 (JNIEnv *env,
#endif /* HAVE_SETSOCKOPT */
}
-static uint32_t getif_address (JNIEnv *env, char *ifname);
-static int getif_index (JNIEnv *env, char *ifname);
+static uint32_t getif_address (JNIEnv *env, const char *ifname);
+static int getif_index (JNIEnv *env, const char *ifname);
/*
* Class: gnu_java_net_VMPlainSocketImpl
@@ -572,10 +683,14 @@ Java_gnu_java_net_VMPlainSocketImpl_joinGroup (JNIEnv *env,
#ifdef HAVE_SETSOCKOPT
struct ip_mreq maddr;
jbyte *addr_elems;
+ const char *str_ifname;
if (ifname != NULL)
{
- maddr.imr_interface.s_addr = getif_address (env, ifname);
+ str_ifname = JCL_jstring_to_cstring(env, ifname);
+ maddr.imr_interface.s_addr = getif_address (env, str_ifname);
+ JCL_free_cstring(env, ifname, str_ifname);
+
if ((*env)->ExceptionCheck (env))
return;
}
@@ -593,6 +708,7 @@ Java_gnu_java_net_VMPlainSocketImpl_joinGroup (JNIEnv *env,
if (-1 == setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&maddr, sizeof (struct ip_mreq)))
JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+
#else
(void) fd;
(void) addr;
@@ -617,10 +733,14 @@ Java_gnu_java_net_VMPlainSocketImpl_joinGroup6 (JNIEnv *env,
#ifdef HAVE_INET6
struct ipv6_mreq maddr;
jbyte *addr_elems;
+ const char *str_ifname;
if (ifname == NULL)
{
- maddr.ipv6mr_interface = getif_index (env, ifname);
+ str_ifname = JCL_jstring_to_cstring(env, ifname);
+ maddr.ipv6mr_interface = getif_index (env, str_ifname);
+ JCL_free_cstring(env, ifname, str_ifname);
+
if ((*env)->ExceptionCheck (env))
return;
}
@@ -666,10 +786,14 @@ Java_gnu_java_net_VMPlainSocketImpl_leaveGroup (JNIEnv *env,
#ifdef HAVE_SETSOCKOPT
struct ip_mreq maddr;
jbyte *addr_elems;
+ const char *str_ifname;
if (ifname != NULL)
{
- maddr.imr_interface.s_addr = getif_address (env, ifname);
+ str_ifname = JCL_jstring_to_cstring(env, ifname);
+ maddr.imr_interface.s_addr = getif_address (env, str_ifname);
+ JCL_free_cstring(env, ifname, str_ifname);
+
if ((*env)->ExceptionCheck (env))
return;
}
@@ -711,10 +835,14 @@ Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6 (JNIEnv *env,
#ifdef HAVE_INET6
struct ipv6_mreq maddr;
jbyte *addr_elems;
+ const char *str_ifname;
if (ifname == NULL)
{
- maddr.ipv6mr_interface = getif_index (env, ifname);
+ str_ifname = JCL_jstring_to_cstring(env, ifname);
+ maddr.ipv6mr_interface = getif_index (env, str_ifname);
+ JCL_free_cstring(env, ifname, str_ifname);
+
if ((*env)->ExceptionCheck (env))
return;
}
@@ -747,7 +875,7 @@ Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6 (JNIEnv *env,
}
static uint32_t
-getif_address (JNIEnv *env, char *ifname)
+getif_address (JNIEnv *env, const char *ifname)
{
#ifdef HAVE_GETIFADDRS
struct ifaddrs *ifaddrs, *i;
@@ -789,7 +917,7 @@ getif_address (JNIEnv *env, char *ifname)
}
static int
-getif_index (JNIEnv *env, char *ifname)
+getif_index (JNIEnv *env, const char *ifname)
{
#ifdef HAVE_GETIFADDRS
struct ifaddrs *ifaddrs, *i;
diff --git a/native/jni/java-net/javanet.c b/native/jni/java-net/javanet.c
index a8213044f..1d2f7202a 100644
--- a/native/jni/java-net/javanet.c
+++ b/native/jni/java-net/javanet.c
@@ -232,7 +232,7 @@ _javanet_create_integer (JNIEnv * env, jint val)
/*
* Builds an InetAddress object from a 32 bit address in host byte order
*/
-static jobject
+jobject
_javanet_create_inetaddress (JNIEnv * env, cpnet_address *netaddr)
{
#ifndef WITHOUT_NETWORK
diff --git a/native/jni/java-net/javanet.h b/native/jni/java-net/javanet.h
index 411c6c651..96dba881b 100644
--- a/native/jni/java-net/javanet.h
+++ b/native/jni/java-net/javanet.h
@@ -81,6 +81,7 @@ exception statement from your version. */
extern int _javanet_get_int_field(JNIEnv *, jobject, const char *);
extern cpnet_address *_javanet_get_ip_netaddr(JNIEnv *, jobject);
+extern jobject _javanet_create_inetaddress (JNIEnv *, cpnet_address *);
extern void _javanet_create(JNIEnv *, jobject, jboolean);
extern void _javanet_close(JNIEnv *, jobject, int);
extern void _javanet_connect(JNIEnv *, jobject, jobject, jint, jboolean);
diff --git a/native/jni/java-nio/gnu_java_nio_VMChannel.c b/native/jni/java-nio/gnu_java_nio_VMChannel.c
index b4f444361..33a4f66de 100644
--- a/native/jni/java-nio/gnu_java_nio_VMChannel.c
+++ b/native/jni/java-nio/gnu_java_nio_VMChannel.c
@@ -40,6 +40,8 @@ exception statement from your version. */
#include <config.h>
#endif
+#include <config-int.h>
+
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -57,6 +59,7 @@ exception statement from your version. */
#include <jni.h>
#include <jcl.h>
+#include "cpio.h"
#include "gnu_java_nio_VMChannel.h"
#include "javanio.h"
@@ -64,7 +67,9 @@ exception statement from your version. */
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
+#define CONNECT_EXCEPTION "java/net/ConnectException"
#define IO_EXCEPTION "java/io/IOException"
+#define SOCKET_EXCEPTION "java/net/SocketException"
#define INTERRUPTED_IO_EXCEPTION "java/io/InterruptedIOException"
#define NON_READABLE_CHANNEL_EXCEPTION "java/nio/channels/NonReadableChannelException"
#define NON_WRITABLE_CHANNEL_EXCEPTION "java/nio/channels/NonWritableChannelException"
@@ -101,6 +106,7 @@ void JCL_print_buffer(JNIEnv *, struct JCL_buffer *);
int JCL_init_buffer(JNIEnv *, struct JCL_buffer *, jobject);
void JCL_release_buffer(JNIEnv *, struct JCL_buffer *, jobject, jint);
void JCL_cleanup_buffers(JNIEnv *, struct JCL_buffer *, jint, jobjectArray, jint, jlong);
+int JCL_thread_interrupted(JNIEnv *, jclass);
static jfieldID address_fid;
static jmethodID get_position_mid;
@@ -110,6 +116,7 @@ static jmethodID set_limit_mid;
static jmethodID has_array_mid;
static jmethodID array_mid;
static jmethodID array_offset_mid;
+static jmethodID thread_interrupted_mid;
jmethodID
get_method_id(JNIEnv *env, jclass clazz, const char *name,
@@ -119,7 +126,7 @@ get_method_id(JNIEnv *env, jclass clazz, const char *name,
/* NIODBG("name: %s; sig: %s", name, sig); */
if (mid == NULL)
{
- JCL_ThrowException(env, "java/lang/InternalError", name);
+ JCL_ThrowException(env, "java/lang/InternalError", name);
return NULL;
}
@@ -247,6 +254,13 @@ JCL_cleanup_buffers(JNIEnv *env,
}
+int
+JCL_thread_interrupted(JNIEnv *env, jclass c)
+{
+ return (int) (*env)->CallBooleanMethod(env, c, thread_interrupted_mid);
+}
+
+
/*
* Class: gnu_java_nio_VMChannel
* Method: stdin_fd
@@ -291,7 +305,7 @@ Java_gnu_java_nio_VMChannel_stderr_1fd (JNIEnv *env __attribute__((unused)),
JNIEXPORT void JNICALL
Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env,
- jclass clazz __attribute__ ((__unused__)))
+ jclass clazz)
{
jclass bufferClass = JCL_FindClass(env, "java/nio/Buffer");
jclass byteBufferClass = JCL_FindClass(env, "java/nio/ByteBuffer");
@@ -316,6 +330,8 @@ Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env,
has_array_mid = get_method_id(env, byteBufferClass, "hasArray", "()Z");
array_mid = get_method_id(env, byteBufferClass, "array", "()[B");
array_offset_mid = get_method_id(env, byteBufferClass, "arrayOffset", "()I");
+
+ thread_interrupted_mid = get_method_id(env, clazz, "isThreadInterrupted", "()Z");
}
JNIEXPORT void JNICALL
@@ -973,7 +989,8 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
if ((*env)->GetArrayLength (env, addr) != 4)
{
- JCL_ThrowException (env, "java/io/IOException", "expecting 4-byte address");
+ JCL_ThrowException (env, SOCKET_EXCEPTION,
+ "expecting 4-byte address");
return JNI_FALSE;
}
@@ -984,7 +1001,7 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
origflags = fcntl (fd, F_GETFL, 0);
if (origflags == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
/* Set nonblocking mode, if not already set. */
@@ -993,7 +1010,7 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
flags = origflags | O_NONBLOCK;
if (fcntl (fd, F_SETFL, flags) == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1022,7 +1039,7 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
if (fcntl (fd, F_SETFL, origflags) == -1)
{
/* oops */
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1033,7 +1050,7 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
if (ret == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
if (ret == 0) /* connect timed out */
@@ -1046,13 +1063,13 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
}
else if (ECONNREFUSED == errno)
{
- JCL_ThrowException (env, "java/net/ConnectException",
+ JCL_ThrowException (env, CONNECT_EXCEPTION,
strerror (errno));
return JNI_FALSE;
}
else
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1063,13 +1080,13 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
return JNI_FALSE;
else if (ECONNREFUSED == errno)
{
- JCL_ThrowException (env, "java/net/ConnectException",
+ JCL_ThrowException (env, CONNECT_EXCEPTION,
strerror (errno));
return JNI_FALSE;
}
else
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1080,7 +1097,7 @@ Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((un
(void) addr;
(void) port;
(void) timeout;
- JCL_ThrowException (env, IO_EXCEPTION, "connect not supported");
+ JCL_ThrowException (env, SOCKET_EXCEPTION, "connect not supported");
return JNI_FALSE;
#endif /* HAVE_CONNECT */
}
@@ -1109,7 +1126,7 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
origflags = fcntl (fd, F_GETFL, 0);
if (origflags == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
/* Set nonblocking mode, if not already set. */
@@ -1118,7 +1135,7 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
flags = origflags | O_NONBLOCK;
if (fcntl (fd, F_SETFL, flags) == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1146,7 +1163,7 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
if (fcntl (fd, F_SETFL, origflags) == -1)
{
/* oops */
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1157,7 +1174,7 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
if (ret == -1)
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
if (ret == 0) /* connect timed out */
@@ -1170,13 +1187,13 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
}
else if (ECONNREFUSED == errno)
{
- JCL_ThrowException (env, "java/net/ConnectException",
+ JCL_ThrowException (env, CONNECT_EXCEPTION,
strerror (errno));
return JNI_FALSE;
}
else
{
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1187,13 +1204,13 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
return JNI_FALSE;
else if (ECONNREFUSED == errno)
{
- JCL_ThrowException (env, "java/net/ConnectException",
+ JCL_ThrowException (env, CONNECT_EXCEPTION,
strerror (errno));
return JNI_FALSE;
}
else
{
- JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
return JNI_FALSE;
}
}
@@ -1204,7 +1221,7 @@ Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((u
(void) addr;
(void) port;
(void) timeout;
- JCL_ThrowException (env, IO_EXCEPTION, "IPv6 connect not supported");
+ JCL_ThrowException (env, SOCKET_EXCEPTION, "IPv6 connect not supported");
return JNI_FALSE;
#endif /* HAVE_CONNECT && HAVE_INET6 */
}
@@ -1338,11 +1355,12 @@ Java_gnu_java_nio_VMChannel_getpeername (JNIEnv *env, jclass clazz __attribute__
*/
JNIEXPORT jint JNICALL
Java_gnu_java_nio_VMChannel_accept (JNIEnv *env,
- jclass clazz __attribute__((unused)),
+ jclass clazz,
jint fd)
{
#ifdef HAVE_ACCEPT
int ret;
+ int tmp_errno = 0;
#ifdef HAVE_INET6
struct sockaddr_in6 addr;
@@ -1355,14 +1373,38 @@ Java_gnu_java_nio_VMChannel_accept (JNIEnv *env,
do
{
ret = cpnio_accept (fd, (struct sockaddr *) &addr, &alen);
+ tmp_errno = errno;
+
+ if (ret == -1)
+ switch (tmp_errno)
+ {
+ case EINTR:
+ /* Check if interrupted by Thread.interrupt(). If not then some
+ * other unrelated signal interrupted the system function and
+ * we should start over again.
+ */
+ if (JCL_thread_interrupted(env, clazz))
+ {
+ JCL_ThrowException (env, "java/net/SocketException", strerror (tmp_errno));
+ return -1;
+ }
+ break;
+#if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ case EAGAIN:
+ /* Socket in non-blocking mode and no pending connection. */
+ return -1;
+ default:
+ JCL_ThrowException (env, "java/net/SocketException", strerror (tmp_errno));
+ return -1;
+ }
+ else
+ break;
}
- while (ret == -1 && EINTR == errno);
+ while (1);
- if (ret == -1)
- {
- if (EWOULDBLOCK != ret && EAGAIN != ret)
- JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
- }
+ cpio_closeOnExec(ret);
return ret;
#else
@@ -1582,7 +1624,11 @@ Java_gnu_java_nio_VMChannel_lock (JNIEnv *env,
struct flock fl;
fl.l_start = (off_t) pos;
- fl.l_len = (off_t) len;
+ /* Long.MAX_VALUE means lock everything possible starting at pos. */
+ if (len == 9223372036854775807LL)
+ fl.l_len = 0;
+ else
+ fl.l_len = (off_t) len;
fl.l_pid = getpid ();
fl.l_type = (shared ? F_RDLCK : F_WRLCK);
fl.l_whence = SEEK_SET;
diff --git a/native/jni/native-lib/cpio.c b/native/jni/native-lib/cpio.c
index 4d23b7a1f..2777a31b2 100644
--- a/native/jni/native-lib/cpio.c
+++ b/native/jni/native-lib/cpio.c
@@ -473,3 +473,13 @@ int cpio_readDir (void *handle, char *filename)
strncpy (filename, dBuf->d_name, FILENAME_MAX);
return 0;
}
+
+
+int
+cpio_closeOnExec(int fd)
+{
+ if (fcntl (fd, F_SETFD, FD_CLOEXEC) == -1)
+ return errno;
+
+ return 0;
+}
diff --git a/native/jni/native-lib/cpio.h b/native/jni/native-lib/cpio.h
index 97483d294..b388b5b50 100644
--- a/native/jni/native-lib/cpio.h
+++ b/native/jni/native-lib/cpio.h
@@ -64,6 +64,7 @@ JNIEXPORT int cpio_read (int fd, void *data, jint len, jint *bytes_read);
JNIEXPORT int cpio_write (int fd, const void *data, jint len, jint *bytes_written);
JNIEXPORT int cpio_fsync (int fd);
JNIEXPORT int cpio_truncate (int fd, jlong size);
+JNIEXPORT int cpio_closeOnExec(int fd);
#define CPFILE_FILE 0
#define CPFILE_DIRECTORY 1
diff --git a/resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties b/resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties
deleted file mode 100644
index bbd7618a6..000000000
--- a/resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties
+++ /dev/null
@@ -1,70 +0,0 @@
-# MessagesBundle.properties -- English language messages
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-#
-# This file is part of GNU Classpath.
-#
-# GNU Classpath is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU Classpath is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Classpath; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA.
-#
-# Linking this library statically or dynamically with other modules is
-# making a combined work based on this library. Thus, the terms and
-# conditions of the GNU General Public License cover the whole
-# combination.
-#
-# As a special exception, the copyright holders of this library give you
-# permission to link this library with independent modules to produce an
-# executable, regardless of the license terms of these independent
-# modules, and to copy and distribute the resulting executable under
-# terms of your choice, provided that you also meet, for each linked
-# independent module, the terms and conditions of the license of that
-# module. An independent module is a module which is not derived from
-# or based on this library. If you modify this library, you may extend
-# this exception to your version of the library, but you are not
-# obligated to do so. If you do not wish to do so, delete this
-# exception statement from your version.
-
-gcjwebplugin.code_description=specify the code attribute
-gcjwebplugin.codebase_description=specify the codebase attribute
-gcjwebplugin.archive_description=specify the archive attribute
-gcjwebplugin.width_description=specify the width attribute
-gcjwebplugin.height_description=specify the height attribute
-gcjwebplugin.param_description=specify the parameter arguments
-gcjwebplugin.plugin_description=enable plugin mode
-gcjwebplugin.verbose_description=enable verbose mode
-gcjwebplugin.debug_description=enable debugging mode (not implemented)
-gcjwebplugin.encoding_description=specify the HTML character encoding
-
-gcjwebplugin.no_input_files=appletviewer: no input files
-
-gcjwebplugin.menu_title=Applet
-gcjwebplugin.menu_reload=Reload
-gcjwebplugin.menu_restart=Restart
-gcjwebplugin.menu_start=Start
-gcjwebplugin.menu_stop=Stop
-gcjwebplugin.menu_clone=Clone ...
-gcjwebplugin.menu_quit=Quit
-gcjwebplugin.menu_close=Close
-gcjwebplugin.menu_tag=Tag ...
-gcjwebplugin.menu_info=Info ...
-gcjwebplugin.menu_edit=Edit
-gcjwebplugin.menu_encoding=Character Encoding
-gcjwebplugin.menu_print=Print ...
-gcjwebplugin.menu_properties=Properties ...
-gcjwebplugin.menu_cancel=Cancel
-gcjwebplugin.menu_save=Save ...
-
-gcjwebplugin.console_title=GCJ web plugin console
-gcjwebplugin.console_clear=Clear
-gcjwebplugin.console_hide=Hide
diff --git a/resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties b/resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties
deleted file mode 100644
index 036b86f30..000000000
--- a/resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-# MessagesBundle_de.properties -- German language messages
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-#
-# This file is part of GNU Classpath.
-#
-# GNU Classpath is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU Classpath is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Classpath; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 USA.
-#
-# Linking this library statically or dynamically with other modules is
-# making a combined work based on this library. Thus, the terms and
-# conditions of the GNU General Public License cover the whole
-# combination.
-#
-# As a special exception, the copyright holders of this library give you
-# permission to link this library with independent modules to produce an
-# executable, regardless of the license terms of these independent
-# modules, and to copy and distribute the resulting executable under
-# terms of your choice, provided that you also meet, for each linked
-# independent module, the terms and conditions of the license of that
-# module. An independent module is a module which is not derived from
-# or based on this library. If you modify this library, you may extend
-# this exception to your version of the library, but you are not
-# obligated to do so. If you do not wish to do so, delete this
-# exception statement from your version.
-
-# FIXME: rewrite this:
-gcjwebplugin.help.0=Syntax: appletviewer [Optionen] <Dateiname>.class | <Dateiname>.html... | URL...
-gcjwebplugin.help.1=Optionen:
-gcjwebplugin.help.2= --help Diese Hilfe anzeigen and beenden
-gcjwebplugin.help.3= --version Version anzeigen und beenden
-gcjwebplugin.help.4= --code=<Klassenname>[.class] Applet mit Klassen- oder Dateiname ausführen
-gcjwebplugin.help.5= --codebase=<Verzeichnis> Applet-Codebasis setzen
-gcjwebplugin.help.6= --archive=<Dateiname>.jar[,...] Archive zum Klassenlader hinzufügen
-gcjwebplugin.help.7= --param=<Name>,<Wert> Parameter an Applet übergeben
-gcjwebplugin.help.8= --width=<Breite> Setze Breite des Appletfensters
-gcjwebplugin.help.9= --height=<Höhe> Setze Höhe des Appletfensters
-gcjwebplugin.help.10= --plugin=<Eingabepipe>,<Ausgabepipe> Pluginmodus einschalten
-gcjwebplugin.help.11= -debug Starten des Applet-Viewers im Java-Debugger (nicht implementiert)
-gcjwebplugin.help.12= -encoding <Codierung> Angabe der von HTML-Dateien verwendeten Zeichencodierung
-gcjwebplugin.help.13= -J<Laufzeit-Flag> Übergeben des Arguments an den Java-Interpreter
-
-gcjwebplugin.no_input_files=appletviewer: keine Dateien angegeben
-
-gcjwebplugin.menu_title=Applet
-gcjwebplugin.menu_reload=Neu laden
-gcjwebplugin.menu_restart=Neu starten
-gcjwebplugin.menu_start=Start
-gcjwebplugin.menu_stop=Stop
-gcjwebplugin.menu_clone=Klonen ...
-gcjwebplugin.menu_quit=Beenden
-gcjwebplugin.menu_tag=Tag ...
-gcjwebplugin.menu_info=Informationen ...
-gcjwebplugin.menu_edit=Bearbeiten
-gcjwebplugin.menu_encoding=Zeichenkodierung
-gcjwebplugin.menu_print=Drucken ...
-gcjwebplugin.menu_properties=Eigenschaften ...
-gcjwebplugin.menu_close=Schließen
-gcjwebplugin.menu_cancel=Abbrechen
-gcjwebplugin.menu_save=Speichern unter ...
-
-gcjwebplugin.console_title=GCJ web plugin Konsole
-gcjwebplugin.console_clear=Löschen
-gcjwebplugin.console_hide=Schließen
diff --git a/resource/gnu/classpath/tools/appletviewer/messages.properties b/resource/gnu/classpath/tools/appletviewer/messages.properties
new file mode 100644
index 000000000..c826afa21
--- /dev/null
+++ b/resource/gnu/classpath/tools/appletviewer/messages.properties
@@ -0,0 +1,102 @@
+# messages.properties -- English language messages
+# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.ErrorApplet=An error occurred while loading this applet.
+Main.Usage=Usage: appletviewer [OPTION] -code CODE | URL...
+Main.AppletTagOptions=Applet tag options
+Main.CodeDescription=specify the code attribute
+Main.CodeArgument=CODE
+Main.CodebaseDescription=specify the codebase attribute
+Main.CodebaseArgument=CODEBASE
+Main.ArchiveDescription=specify the archive attribute
+Main.ArchiveArgument=ARCHIVE
+Main.WidthDescription=specify the width attribute
+Main.WidthArgument=WIDTH
+Main.HeightDescription=specify the height attribute
+Main.HeightArgument=HEIGHT
+Main.ParamDescription=specify the parameter arguments
+Main.ParamArgument=NAME,VALUE
+Main.PluginOption=Plugin option
+Main.PluginDescription=enable plugin mode
+Main.PluginArgument=INPUT,OUTPUT
+Main.DebuggingOption=Debugging option
+Main.VerboseDescription=enable verbose mode
+Main.CompatibilityOptions=Compatibility options
+Main.DebugDescription=enable debugging mode (not implemented)
+Main.EncodingDescription=specify the HTML character encoding
+Main.EncodingArgument=CHARSET
+Main.SecurityWarning=WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NO\
+ SECURITY MANAGER.\n\
+THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION\n\
+THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.\n\
+DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANT\
+ DATA.\n\
+THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.
+Main.ContinuationPrompt=[press 'c' or 'C' to continue or anything else to quit]
+Main.NoInputFiles=appletviewer: no input files
+Main.RawArguments=Raw arguments:
+
+PluginAppletViewer.AppletViewerWrote=PIPE: applet viewer wrote:
+PluginAppletViewer.AppletViewerRead=PIPE: applet viewer read:
+PluginAppletViewer.AppletViewerExiting=appletviewer: exiting plugin applet\
+ viewer
+
+StandaloneAppletContext.ShowDocumentError=showDocument is not implemented in\
+ standalone mode
+
+StandaloneAppletViewer.ParsedAppletTags=Parsed applet tags:
+StandaloneAppletViewer.Tag=tag
+StandaloneAppletViewer.CodeOptionError=appletviewer: option '--code' requires\
+ a class filename
+
+StandaloneAppletWindow.MenuTitle=Applet
+StandaloneAppletWindow.MenuReload=Reload
+StandaloneAppletWindow.MenuRestart=Restart
+StandaloneAppletWindow.MenuStart=Start
+StandaloneAppletWindow.MenuStop=Stop
+StandaloneAppletWindow.MenuClone=Clone ...
+StandaloneAppletWindow.MenuQuit=Quit
+StandaloneAppletWindow.MenuClose=Close
+StandaloneAppletWindow.MenuTag=Tag ...
+StandaloneAppletWindow.MenuInfo=Info ...
+StandaloneAppletWindow.MenuEdit=Edit
+StandaloneAppletWindow.MenuEncoding=Character Encoding
+StandaloneAppletWindow.MenuPrint=Print ...
+StandaloneAppletWindow.MenuProperties=Properties ...
+StandaloneAppletWindow.MenuCancel=Cancel
+StandaloneAppletWindow.MenuSave=Save ...
+StandaloneAppletWindow.WindowTitle=GNU Classpath Applet Viewer:
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 04c2f2bbf..7c666dcd5 100755
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -33,63 +33,75 @@ AM_CPPFLAGS = -Wall \
gappletviewer_SOURCES = toolwrapper.c
gappletviewer_CFLAGS = \
-DTOOLPACKAGE="\"appletviewer\"" \
- -DTOOLNAME="\"gappletviewer\""
+ -DTOOLNAME="\"gappletviewer\"" \
+ -DASM_JAR=""
gjarsigner_SOURCES = toolwrapper.c
gjarsigner_CFLAGS = \
-DTOOLPACKAGE="\"jarsigner\"" \
- -DTOOLNAME="\"gjarsigner\""
+ -DTOOLNAME="\"gjarsigner\"" \
+ -DASM_JAR=""
gkeytool_SOURCES = toolwrapper.c
gkeytool_CFLAGS = \
-DTOOLPACKAGE="\"keytool\"" \
- -DTOOLNAME="\"gkeytool\""
+ -DTOOLNAME="\"gkeytool\"" \
+ -DASM_JAR=""
gjar_SOURCES = toolwrapper.c
gjar_CFLAGS = \
-DTOOLPACKAGE="\"jar\"" \
- -DTOOLNAME="\"gjar\""
+ -DTOOLNAME="\"gjar\"" \
+ -DASM_JAR=""
gnative2ascii_SOURCES = toolwrapper.c
gnative2ascii_CFLAGS = \
-DTOOLPACKAGE="\"native2ascii\"" \
- -DTOOLNAME="\"gnative2ascii\""
+ -DTOOLNAME="\"gnative2ascii\"" \
+ -DASM_JAR=""
gserialver_SOURCES = toolwrapper.c
gserialver_CFLAGS = \
-DTOOLPACKAGE="\"serialver\"" \
- -DTOOLNAME="\"gserialver\""
+ -DTOOLNAME="\"gserialver\"" \
+ -DASM_JAR=""
grmiregistry_SOURCES = toolwrapper.c
grmiregistry_CFLAGS = \
-DTOOLPACKAGE="\"rmiregistry\"" \
- -DTOOLNAME="\"grmiregistry\""
+ -DTOOLNAME="\"grmiregistry\"" \
+ -DASM_JAR=""
gtnameserv_SOURCES = toolwrapper.c
gtnameserv_CFLAGS = \
-DTOOLPACKAGE="\"tnameserv\"" \
- -DTOOLNAME="\"gtnameserv\""
+ -DTOOLNAME="\"gtnameserv\"" \
+ -DASM_JAR=""
gorbd_SOURCES = toolwrapper.c
gorbd_CFLAGS = \
-DTOOLPACKAGE="\"orbd\"" \
- -DTOOLNAME="\"gorbd\""
+ -DTOOLNAME="\"gorbd\"" \
+ -DASM_JAR=""
grmid_SOURCES = toolwrapper.c
grmid_CFLAGS = \
-DTOOLPACKAGE="\"rmid\"" \
- -DTOOLNAME="\"grmid\""
+ -DTOOLNAME="\"grmid\"" \
+ -DASM_JAR=""
if USE_ASM
gjavah_SOURCES = toolwrapper.c
gjavah_CFLAGS = \
-DTOOLPACKAGE="\"javah\"" \
- -DTOOLNAME="\"gjavah\""
+ -DTOOLNAME="\"gjavah\"" \
+ -DASM_JAR="\":$(PATH_TO_ASM)\""
grmic_SOURCES = toolwrapper.c
grmic_CFLAGS = \
-DTOOLPACKAGE="\"rmic\"" \
- -DTOOLNAME="\"grmic\""
+ -DTOOLNAME="\"grmic\"" \
+ -DASM_JAR="\":$(PATH_TO_ASM)\""
endif
else
diff --git a/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java b/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
index bc0cc45e1..c41ac1d7c 100644
--- a/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
+++ b/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
@@ -98,7 +98,8 @@ class CommonAppletStub
}
catch (MalformedURLException e)
{
- throw new RuntimeException("unknown codebase");
+ throw new RuntimeException("Attempted to create"
+ + " invalid codebase URL.", e);
}
}
diff --git a/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java b/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
deleted file mode 100644
index 9c937cc77..000000000
--- a/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/* ConsoleDialog -- a console dialog for applets
- Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.appletviewer;
-
-import java.awt.BorderLayout;
-import java.awt.Button;
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.Panel;
-import java.awt.TextArea;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-
-/**
- * This class is a little dialog showing standard output and standard error output.
- *
- * @author Michael Koch (konqueror@gmx.de)
- */
-public class ConsoleDialog extends Frame
- implements ActionListener
-{
- static class InternalOutputStream extends OutputStream
- {
- private ConsoleDialog console;
-
- public InternalOutputStream(ConsoleDialog console)
- {
- super();
- this.console = console;
- }
-
- public void write(int data) throws IOException
- {
- console.print(String.valueOf((char) data));
- }
- }
-
- private TextArea textArea;
- private Button buttonClear;
- private Button buttonHide;
- private PrintStream printStream;
-
- /**
- * Creates a console dialog object.
- */
- public ConsoleDialog()
- {
- super(Main.messages.getString("gcjwebplugin.console_title"));
-
- setSize(400, 200);
- setLayout(new BorderLayout());
- addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent event)
- {
- hide();
- }
- });
-
- textArea = new TextArea();
- textArea.setEditable(false);
- add(textArea);
-
- Panel panel = new Panel();
- panel.setLayout(new FlowLayout());
- add(panel, BorderLayout.SOUTH);
-
- buttonClear = new Button(Main.messages.getString("gcjwebplugin.console_clear"));
- buttonClear.addActionListener(this);
- panel.add(buttonClear);
-
- buttonHide = new Button(Main.messages.getString("gcjwebplugin.console_hide"));
- buttonHide.addActionListener(this);
- panel.add(buttonHide);
-
- printStream = new PrintStream(new InternalOutputStream(this));
- clearTextArea();
- }
-
- /**
- * Clears the content of the textarea and inserts the initial text.
- */
- public void clearTextArea()
- {
- textArea.setText("");
-
- println("java.vm.version: " + System.getProperty("java.vm.version"));
- println("java.vm.vendor: " + System.getProperty("java.vm.vendor"));
- }
-
- /**
- * Print a message into the console dialog.
- *
- * @param message the message to print.
- */
- public void print(String message)
- {
- textArea.append(message);
- }
-
- /**
- * Print a line into the console dialog.
- *
- * @param message the line to print.
- */
- public void println(String message)
- {
- print(message + "\n");
- }
-
- /**
- * Perform actions on button clicks inside the console dialog.
- *
- * @param event the event.
- */
- public void actionPerformed(ActionEvent event)
- {
- if (event.getSource() == buttonHide)
- hide(); // Hide console window.
- else if (event.getSource() == buttonClear)
- clearTextArea(); // Clear text area and insert standard messages.
- }
-
- /**
- * Returns a <code>PrintStream</code> object that prints into the
- * console dialog.
- *
- * @return the <code>PrintStream</code> object.
- */
- public PrintStream getPrintStream()
- {
- return printStream;
- }
-}
diff --git a/tools/gnu/classpath/tools/appletviewer/Main.java b/tools/gnu/classpath/tools/appletviewer/Main.java
index b22368003..a10b889bc 100644
--- a/tools/gnu/classpath/tools/appletviewer/Main.java
+++ b/tools/gnu/classpath/tools/appletviewer/Main.java
@@ -60,12 +60,6 @@ import java.util.ResourceBundle;
class Main
{
- /**
- * The localized strings are kept in a separate file.
- */
- public static final ResourceBundle messages = ResourceBundle.getBundle
- ("gnu.classpath.tools.appletviewer.MessagesBundle");
-
private static HashMap classLoaderCache = new HashMap();
private static ClassLoader getClassLoader(URL codebase, ArrayList archives)
@@ -110,7 +104,7 @@ class Main
}
if (applet == null)
- applet = new ErrorApplet("Error loading applet");
+ applet = new ErrorApplet(Messages.getString ("Main.ErrorApplet"));
return applet;
}
@@ -127,68 +121,72 @@ class Main
public static void main(String[] args) throws IOException
{
parser = new ClasspathToolParser("appletviewer", true);
- parser.setHeader("usage: appletviewer [OPTION] -code CODE | URL...");
+ parser.setHeader(Messages.getString("Main.Usage"));
- OptionGroup attributeGroup = new OptionGroup("Applet tag options");
+ OptionGroup attributeGroup
+ = new OptionGroup(Messages.getString("Main.AppletTagOptions"));
- attributeGroup.add(new Option("code", Main.messages.getString
- ("gcjwebplugin.code_description"),
- "CODE")
+ attributeGroup.add(new Option("code",
+ Messages.getString("Main.CodeDescription"),
+ Messages.getString("Main.CodeArgument"))
{
public void parsed(String argument) throws OptionException
{
code = argument;
}
});
- attributeGroup.add(new Option("codebase", Main.messages.getString
- ("gcjwebplugin.codebase_description"),
- "CODEBASE")
+ attributeGroup.add
+ (new Option("codebase",
+ Messages.getString("Main.CodebaseDescription"),
+ Messages.getString("Main.CodebaseArgument"))
{
public void parsed(String argument) throws OptionException
{
codebase = argument;
}
});
- attributeGroup.add(new Option("archive", Main.messages.getString
- ("gcjwebplugin.archive_description"),
- "ARCHIVE")
+ attributeGroup.add
+ (new Option("archive",
+ Messages.getString("Main.ArchiveDescription"),
+ Messages.getString("Main.ArchiveArgument"))
{
public void parsed(String argument) throws OptionException
{
archive = argument;
}
});
- attributeGroup.add(new Option("width", Main.messages.getString
- ("gcjwebplugin.width_description"),
- "WIDTH")
+ attributeGroup.add(new Option("width",
+ Messages.getString("Main.WidthDescription"),
+ Messages.getString("Main.WidthArgument"))
{
public void parsed(String argument) throws OptionException
{
dimensions.width = Integer.parseInt(argument);
}
});
- attributeGroup.add(new Option("height", Main.messages.getString
- ("gcjwebplugin.height_description"),
- "HEIGHT")
+ attributeGroup.add(new Option("height",
+ Messages.getString("Main.HeightDescription"),
+ Messages.getString("Main.HeightArgument"))
{
public void parsed(String argument) throws OptionException
{
dimensions.height = Integer.parseInt(argument);
}
});
- attributeGroup.add(new Option("param", Main.messages.getString
- ("gcjwebplugin.param_description"),
- "NAME,VALUE")
+ attributeGroup.add(new Option("param",
+ Messages.getString("Main.ParamDescription"),
+ Messages.getString("Main.ParamArgument"))
{
public void parsed(String argument) throws OptionException
{
parameters.add(argument);
}
});
- OptionGroup pluginGroup = new OptionGroup("Plugin option");
- pluginGroup.add(new Option("plugin", Main.messages.getString
- ("gcjwebplugin.plugin_description"),
- "INPUT,OUTPUT")
+ OptionGroup pluginGroup
+ = new OptionGroup(Messages.getString("Main.PluginOption"));
+ pluginGroup.add(new Option("plugin",
+ Messages.getString("Main.PluginDescription"),
+ Messages.getString("Main.PluginArgument"))
{
public void parsed(String argument) throws OptionException
{
@@ -198,29 +196,34 @@ class Main
pipeOutName = argument.substring(comma + 1);
}
});
- OptionGroup debuggingGroup = new OptionGroup("Debugging option");
- debuggingGroup.add(new Option("verbose", Main.messages.getString
- ("gcjwebplugin.verbose_description"),
- (String) null)
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebuggingOption"));
+ debuggingGroup.add
+ (new Option("verbose",
+ Messages.getString("Main.VerboseDescription"),
+ (String) null)
{
public void parsed(String argument) throws OptionException
{
verbose = true;
}
});
- OptionGroup compatibilityGroup = new OptionGroup("Compatibility options");
- compatibilityGroup.add(new Option("debug", Main.messages.getString
- ("gcjwebplugin.debug_description"),
- (String) null)
+ OptionGroup compatibilityGroup
+ = new OptionGroup(Messages.getString("Main.CompatibilityOptions"));
+ compatibilityGroup.add
+ (new Option("debug",
+ Messages.getString("Main.DebugDescription"),
+ (String) null)
{
public void parsed(String argument) throws OptionException
{
// Currently ignored.
}
});
- compatibilityGroup.add(new Option("encoding", Main.messages.getString
- ("gcjwebplugin.encoding_description"),
- "CHARSET")
+ compatibilityGroup.add
+ (new Option("encoding",
+ Messages.getString("Main.EncodingDescription"),
+ Messages.getString("Main.EncodingArgument"))
{
public void parsed(String argument) throws OptionException
{
@@ -263,15 +266,12 @@ class Main
else
{
// Warn user about missing security manager.
- System.err.println("WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NO SECURITY MANAGER.\n\n"
- + "THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION\n"
- + "THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.\n"
- + "DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANT DATA.\n"
- + "THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.\n");
+ System.err.println(Messages.getString("Main.SecurityWarning") + "\n");
- System.err.println("[press 'c' or 'C' to continue or anything else to quit]");
+ System.err.println(Messages.getString("Main.ContinuationPrompt"));
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ BufferedReader stdin
+ = new BufferedReader(new InputStreamReader(System.in));
String response = null;
try
@@ -280,8 +280,8 @@ class Main
}
catch (IOException e)
{
- System.err.println("failed to read response to warning message: " + e);
- System.exit(1);
+ throw new RuntimeException("Failed to read response"
+ + " to continuation prompt.", e);
}
if (!(response.equals("c") || response.equals("C")))
@@ -295,7 +295,7 @@ class Main
// arguments so we have nothing to work with.
if (args.length == 0)
{
- System.err.println(Main.messages.getString("gcjwebplugin.no_input_files"));
+ System.err.println(Messages.getString("Main.NoInputFiles"));
System.exit(1);
}
// Create a standalone appletviewer from a list of URLs.
@@ -305,7 +305,8 @@ class Main
{
// Create a standalone appletviewer from the --code
// option.
- new StandaloneAppletViewer(code, codebase, archive, parameters, dimensions);
+ new StandaloneAppletViewer(code, codebase, archive,
+ parameters, dimensions);
}
}
}
@@ -314,7 +315,7 @@ class Main
{
if (verbose)
{
- System.out.println("raw arguments:");
+ System.out.println(Messages.getString("Main.RawArguments"));
for (int i = 0; i < args.length; i++)
System.out.println(" " + args[i]);
diff --git a/tools/gnu/classpath/tools/appletviewer/Messages.java b/tools/gnu/classpath/tools/appletviewer/Messages.java
new file mode 100644
index 000000000..614a509fd
--- /dev/null
+++ b/tools/gnu/classpath/tools/appletviewer/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for appletviewer
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.appletviewer;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.appletviewer.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java b/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
index a0e6acd12..bc445a6b3 100644
--- a/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
+++ b/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
@@ -54,7 +54,7 @@ class PluginAppletContext extends CommonAppletContext
}
catch(IOException e)
{
- System.err.println("showDocument failed: " + e);
+ throw new RuntimeException("showDocument failed.", e);
}
}
@@ -66,7 +66,7 @@ class PluginAppletContext extends CommonAppletContext
}
catch(IOException e)
{
- System.err.println("showDocument failed: " + e);
+ throw new RuntimeException("showStatus failed.", e);
}
}
}
diff --git a/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java b/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
index fdb8097b4..d77aad392 100644
--- a/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
+++ b/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
@@ -141,7 +141,9 @@ class PluginAppletViewer
pluginOutputStream.newLine();
pluginOutputStream.flush();
- System.err.println(" PIPE: applet viewer wrote: " + message);
+ System.err.println
+ (" " + Messages.getString("PluginAppletViewer.AppletViewerWrote")
+ + message);
}
/**
@@ -155,7 +157,9 @@ class PluginAppletViewer
{
String message = pluginInputStream.readLine();
- System.err.println(" PIPE: applet viewer read: " + message);
+ System.err.println
+ (" " + Messages.getString("PluginAppletViewer.AppletViewerRead")
+ + message);
if (message == null || message.equals("shutdown"))
{
@@ -163,7 +167,9 @@ class PluginAppletViewer
pluginInputStream.close();
pluginOutputStream.close();
- System.err.println("appletviewer: exiting plugin applet viewer");
+ System.err.println
+ (Messages.getString("PluginAppletViewer.AppletViewerExiting"));
+
System.exit(0);
}
diff --git a/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java b/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
index 6d36e1cf0..283d547b8 100644
--- a/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
+++ b/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
@@ -428,10 +428,6 @@ class PluginAppletWindow
if (contexts.get(tag.getCodeBase()) == null)
contexts.put(tag.getCodeBase(), new PluginAppletContext());
- int result = AppletWarning.show();
- if (result == JOptionPane.NO_OPTION)
- return;
-
add(applet);
AppletContext context = (AppletContext) contexts.get(tag.getCodeBase());
diff --git a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
index a779f068a..48468f84d 100644
--- a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
+++ b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
@@ -58,7 +58,8 @@ class StandaloneAppletContext extends CommonAppletContext
public void showDocument(URL url, String target)
{
- System.err.println("showDocument is not implemented in standalone mode");
+ System.err.println
+ (Messages.getString("StandaloneAppletContext.ShowDocumentError"));
}
// In standalone mode, there are potentially several windows, each
diff --git a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
index 2b58f4b87..cc3a65cd7 100644
--- a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
+++ b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
@@ -79,7 +79,8 @@ class StandaloneAppletViewer extends Main
{
if (!(code.equals("") || code.endsWith(".class")))
{
- System.err.println("appletviewer: option '--code' requires a class filename");
+ System.err.println
+ (Messages.getString("StandaloneAppletViewer.CodeOptionError"));
System.exit(1);
}
@@ -118,13 +119,16 @@ class StandaloneAppletViewer extends Main
{
if (verbose)
{
- System.out.println("parsed applet tags:");
+ System.out.println
+ (Messages.getString("StandaloneAppletViewer.ParsedAppletTags"));
for (int i = 0; i < appletTags.size(); i++)
{
AppletTag tag = (AppletTag) appletTags.get(i);
- System.out.println(" tag " + i + ":");
+ System.out.println
+ (" " + Messages.getString("StandaloneAppletViewer.Tag")
+ + " " + i + ":");
System.out.println(tag);
}
}
diff --git a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
index fd2a7c0d8..3a0a44282 100644
--- a/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
+++ b/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
@@ -128,57 +128,57 @@ class StandaloneAppletWindow
addHierarchyListener(this);
addHierarchyBoundsListener(this);
- restartItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_restart"));
+ restartItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuRestart"));
restartItem.setEnabled(false);
restartItem.addActionListener(this);
- reloadItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_reload"));
+ reloadItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuReload"));
reloadItem.setEnabled(false);
reloadItem.addActionListener(this);
- cancelItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_cancel"));
+ cancelItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuCancel"));
cancelItem.setEnabled(false);
cancelItem.addActionListener(this);
- saveItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_save"));
+ saveItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuSave"));
saveItem.setEnabled(false);
saveItem.addActionListener(this);
- startItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_start"));
+ startItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuStart"));
startItem.setEnabled(false);
startItem.addActionListener(this);
- cloneItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_clone"));
+ cloneItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuClone"));
cloneItem.setEnabled(false);
cloneItem.addActionListener(this);
- closeItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_close"));
+ closeItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuClose"));
closeItem.setEnabled(false);
closeItem.addActionListener(this);
tagItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_tag"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuTag"));
tagItem.setEnabled(false);
tagItem.addActionListener(this);
infoItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_info"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuInfo"));
infoItem.setEnabled(false);
infoItem.addActionListener(this);
editItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_edit"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuEdit"));
editItem.setEnabled(false);
editItem.addActionListener(this);
editItem.setEnabled(false);
encodingItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_encoding"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuEncoding"));
encodingItem.setEnabled(false);
encodingItem.addActionListener(this);
printItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_print"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuPrint"));
printItem.setEnabled(false);
printItem.addActionListener(this);
propertiesItem =
- new MenuItem(Main.messages.getString("gcjwebplugin.menu_properties"));
+ new MenuItem(Messages.getString("StandaloneAppletWindow.MenuProperties"));
propertiesItem.setEnabled(false);
propertiesItem.addActionListener(this);
- quitItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_quit"));
+ quitItem = new MenuItem(Messages.getString("StandaloneAppletWindow.MenuQuit"));
quitItem.addActionListener(this);
MenuBar menuBar = new MenuBar();
- Menu menuApplet = new Menu(Main.messages.getString("gcjwebplugin.menu_title"));
+ Menu menuApplet = new Menu(Messages.getString("StandaloneAppletWindow.MenuTitle"));
menuBar.add(menuApplet);
menuApplet.add(restartItem);
menuApplet.add(reloadItem);
@@ -199,7 +199,8 @@ class StandaloneAppletWindow
menuApplet.add(closeItem);
menuApplet.add(quitItem);
setMenuBar(menuBar);
- setTitle("GNU Classpath Applet Viewer: " + tag.code);
+ setTitle(Messages.getString("StandaloneAppletWindow.WindowTitle")
+ + " " + tag.code);
AppletContext context = (AppletContext) contexts.get(tag.codebase);
((StandaloneAppletContext) context).addApplet(applet);
diff --git a/tools/gnu/classpath/tools/javah/ClassWrapper.java b/tools/gnu/classpath/tools/javah/ClassWrapper.java
index 778896395..e238065c2 100644
--- a/tools/gnu/classpath/tools/javah/ClassWrapper.java
+++ b/tools/gnu/classpath/tools/javah/ClassWrapper.java
@@ -338,4 +338,9 @@ public class ClassWrapper
out.println();
out.println("#endif // " + xname);
}
+
+ public String toString()
+ {
+ return name;
+ }
}
diff --git a/tools/gnu/classpath/tools/javah/CniPrintStream.java b/tools/gnu/classpath/tools/javah/CniPrintStream.java
index 574d7fd5f..64ba537d4 100644
--- a/tools/gnu/classpath/tools/javah/CniPrintStream.java
+++ b/tools/gnu/classpath/tools/javah/CniPrintStream.java
@@ -196,9 +196,9 @@ public class CniPrintStream
private void writeClass(PrintStream out, String klass)
{
int index = klass.lastIndexOf('/');
- String pkg = klass.substring(0, index);
- String[] pkgParts = pkg.split("/");
- String className = klass.substring(index + 1);
+ String pkg = index == -1 ? "" : klass.substring(0, index);
+ String[] pkgParts = index == -1 ? new String[0] : pkg.split("/");
+ String className = index == -1 ? klass : klass.substring(index + 1);
moveToPackage(out, pkgParts);
indent(out, pkgParts.length + 2);
out.print("class ");
diff --git a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
index 3d88650c1..f29bfc300 100644
--- a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
@@ -112,7 +112,7 @@ public class JniIncludePrinter
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".h", klass);
+ JniPrintStream out = (JniPrintStream) getPrintStream(klass.name + ".h", klass);
if (out == null)
return;
out.println();
diff --git a/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
index 0bc11873f..4e7871008 100644
--- a/tools/gnu/classpath/tools/javah/JniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
@@ -76,12 +76,12 @@ public class JniStubPrinter
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".c", klass);
+ JniPrintStream out = (JniPrintStream) getPrintStream(klass.name + ".c", klass);
if (out == null)
return;
out.println();
out.print("#include <");
- out.print(xname);
+ out.print(klass.name);
out.println(".h>");
Iterator i = klass.methods.iterator();
diff --git a/tools/gnu/classpath/tools/rmic/RMICException.java b/tools/gnu/classpath/tools/rmic/RMICException.java
index 8d6e5f766..300d60947 100644
--- a/tools/gnu/classpath/tools/rmic/RMICException.java
+++ b/tools/gnu/classpath/tools/rmic/RMICException.java
@@ -1,5 +1,5 @@
/* RMICException.java --
- Copyright (c) 2003 Free Software Foundation, Inc.
+ Copyright (c) 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -18,32 +18,37 @@ along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+
package gnu.classpath.tools.rmic;
/**
- * Thrown by the underlying compiler used by RMIC when it fails to compile a file.
- *
+ * Thrown by the underlying compiler used by RMIC when it fails to compile a
+ * file.
+ *
* @author Dalibor Topic <robilad@kaffe.org>
*/
+public class RMICException
+ extends Exception
+{
+ /**
+ * Create an exception with a message. The cause remains uninitialized.
+ *
+ * @param message the message string
+ * @see #initCause(Throwable)
+ */
+ public RMICException(String message)
+ {
+ super(message);
+ }
-public class RMICException extends Exception {
- /**
- * Create an exception with a message. The cause remains uninitialized.
- *
- * @param s the message string
- * @see #initCause(Throwable)
- */
- public RMICException(String message) {
- super(message);
- }
-
- /**
- * Create an exception with a message and a cause.
- *
- * @param s the message string
- * @param cause the cause of this exception
- */
- public RMICException(String message, Throwable cause) {
- super(message, cause);
- }
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param message the message string
+ * @param cause the cause of this exception
+ */
+ public RMICException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
}
diff --git a/tools/toolwrapper.c b/tools/toolwrapper.c
index 9f4720ab9..dd23286c3 100644
--- a/tools/toolwrapper.c
+++ b/tools/toolwrapper.c
@@ -136,7 +136,7 @@ main (int argc, const char** argv)
goto destroy;
}
- vm_args.options[vm_args.nOptions++].optionString = "-Djava.class.path=" TOOLS_ZIP;
+ vm_args.options[vm_args.nOptions++].optionString = "-Xbootclasspath/p:" TOOLS_ZIP ASM_JAR;
}
/* Terminate vm_args.options with a NULL element. */
diff --git a/vm/reference/gnu/java/net/VMPlainSocketImpl.java b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
index 126294c7f..916f95930 100644
--- a/vm/reference/gnu/java/net/VMPlainSocketImpl.java
+++ b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
@@ -43,15 +43,11 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
-import java.net.SocketAddress;
import java.net.SocketException;
-import java.net.SocketImpl;
import java.net.SocketOptions;
-import java.net.UnknownHostException;
import gnu.classpath.Configuration;
import gnu.java.nio.VMChannel;
-import gnu.java.nio.VMChannel.State;
/**
* The VM interface for {@link gnu.java.net.PlainSocketImpl}.
@@ -61,6 +57,10 @@ import gnu.java.nio.VMChannel.State;
*/
public final class VMPlainSocketImpl
{
+ /** Option id for time to live
+ */
+ private static final int CP_IP_TTL = 0x1E61;
+
private final State nfd;
/**
@@ -91,6 +91,41 @@ public final class VMPlainSocketImpl
return nfd;
}
+ /** This method exists to hide the CP_IP_TTL value from
+ * higher levels.
+ *
+ * Always think of JNode ... :)
+ */
+ public void setTimeToLive(int ttl)
+ throws SocketException
+ {
+ try
+ {
+ setOption(nfd.getNativeFD(), CP_IP_TTL, ttl);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
+ public int getTimeToLive()
+ throws SocketException
+ {
+ try
+ {
+ return getOption(nfd.getNativeFD(), CP_IP_TTL);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
public void setOption(int optionId, Object optionValue)
throws SocketException
{
@@ -98,7 +133,14 @@ public final class VMPlainSocketImpl
if (optionValue instanceof Integer)
value = ((Integer) optionValue).intValue();
else if (optionValue instanceof Boolean)
- value = ((Boolean) optionValue).booleanValue() ? 1 : 0;
+ // Switching off the linger behavior is done by setting
+ // the value to -1. This is how the Java API interprets
+ // it.
+ value = ((Boolean) optionValue).booleanValue()
+ ? 1
+ : (optionId == SocketOptions.SO_LINGER)
+ ? -1
+ : 0;
else
throw new IllegalArgumentException("option value type "
+ optionValue.getClass().getName());
@@ -118,6 +160,41 @@ public final class VMPlainSocketImpl
private static native void setOption(int fd, int id, int value)
throws SocketException;
+ public void setMulticastInterface(int optionId, InetAddress addr)
+ throws SocketException
+ {
+ try
+ {
+ if (addr instanceof Inet4Address)
+ setMulticastInterface(nfd.getNativeFD(), optionId, (Inet4Address) addr);
+ else if (addr instanceof Inet6Address)
+ {
+ NetworkInterface iface = NetworkInterface.getByInetAddress(addr);
+ setMulticastInterface6(nfd.getNativeFD(), optionId, iface.getName());
+ }
+ else
+ throw new SocketException("Unknown address format: " + addr);
+ }
+ catch (SocketException se)
+ {
+ throw se;
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
+ private static native void setMulticastInterface(int fd,
+ int optionId,
+ Inet4Address addr);
+
+ private static native void setMulticastInterface6(int fd,
+ int optionId,
+ String ifName);
+
/**
* Get a socket option. This implementation is only required to support
* socket options that are boolean values, which include:
@@ -126,6 +203,7 @@ public final class VMPlainSocketImpl
* SocketOptions.SO_BROADCAST
* SocketOptions.SO_KEEPALIVE
* SocketOptions.SO_OOBINLINE
+ * SocketOptions.SO_REUSEADDR
* SocketOptions.TCP_NODELAY
*
* and socket options that are integer values, which include:
@@ -161,6 +239,7 @@ public final class VMPlainSocketImpl
case SocketOptions.SO_BROADCAST:
case SocketOptions.SO_KEEPALIVE:
case SocketOptions.SO_OOBINLINE:
+ case SocketOptions.SO_REUSEADDR:
case SocketOptions.TCP_NODELAY:
return Boolean.valueOf(value != 0);
@@ -178,6 +257,33 @@ public final class VMPlainSocketImpl
}
private static native int getOption(int fd, int id) throws SocketException;
+
+ /**
+ * Returns an Inet4Address or Inet6Address instance belonging to the
+ * interface which is set as the multicast interface.
+ *
+ * The optionId is provided to make it possible that the native
+ * implementation may do something different depending on whether
+ * the value is SocketOptions.IP_MULTICAST_IF or
+ * SocketOptions.IP_MULTICAST_IF2.
+ */
+ public InetAddress getMulticastInterface(int optionId)
+ throws SocketException
+ {
+ try
+ {
+ return getMulticastInterface(nfd.getNativeFD(), optionId);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
+ private static native InetAddress getMulticastInterface(int fd,
+ int optionId);
/**
* Binds this socket to the given local address and port.
@@ -402,4 +508,5 @@ public final class VMPlainSocketImpl
}
}
}
-} \ No newline at end of file
+}
+
diff --git a/vm/reference/gnu/java/nio/VMChannel.java b/vm/reference/gnu/java/nio/VMChannel.java
index 688a94ac4..39ee4edb6 100644
--- a/vm/reference/gnu/java/nio/VMChannel.java
+++ b/vm/reference/gnu/java/nio/VMChannel.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package gnu.java.nio;
import gnu.classpath.Configuration;
-import gnu.classpath.jdwp.exception.NotImplementedException;
import java.io.IOException;
import java.net.Inet4Address;
@@ -379,23 +378,37 @@ public final class VMChannel
* @throws IOException If an error occurs while connecting.
*/
public boolean connect(InetSocketAddress saddr, int timeout)
- throws IOException
+ throws SocketException
{
+ int fd;
+
InetAddress addr = saddr.getAddress();
+
+ // Translates an IOException into a SocketException to conform
+ // to the throws clause.
+ try
+ {
+ fd = nfd.getNativeFD();
+ }
+ catch (IOException ioe)
+ {
+ throw new SocketException(ioe.getMessage());
+ }
+
if (addr instanceof Inet4Address)
- return connect(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ return connect(fd, addr.getAddress(), saddr.getPort(),
timeout);
if (addr instanceof Inet6Address)
- return connect6(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ return connect6(fd, addr.getAddress(), saddr.getPort(),
timeout);
- throw new IOException("unsupported internet address");
+ throw new SocketException("unsupported internet address");
}
private static native boolean connect(int fd, byte[] addr, int port, int timeout)
- throws IOException;
+ throws SocketException;
private static native boolean connect6(int fd, byte[] addr, int port, int timeout)
- throws IOException;
+ throws SocketException;
/**
* Disconnect this channel, if it is a datagram socket. Disconnecting
@@ -614,6 +627,17 @@ public final class VMChannel
}
static native void close(int native_fd) throws IOException;
+
+ /**
+ * <p>Provides a simple mean for the JNI code to find out whether the
+ * current thread was interrupted by a call to Thread.interrupt().</p>
+ *
+ * @return
+ */
+ final boolean isThreadInterrupted()
+ {
+ return Thread.currentThread().isInterrupted();
+ }
// Inner classes.
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index 897df5186..e56152d01 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -415,8 +415,9 @@ final class VMClassLoader
{
byte[] modifiedData = new byte[len];
System.arraycopy(data, offset, modifiedData, 0, len);
+ String jvmName = name.replace('.', '/');
modifiedData =
- ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
+ ((InstrumentationImpl)instrumenter).callTransformers(loader, jvmName,
null, pd, modifiedData);
return defineClass(loader, name, modifiedData, 0, modifiedData.length,
diff --git a/vm/reference/java/net/VMNetworkInterface.java b/vm/reference/java/net/VMNetworkInterface.java
index 7a29f4ee3..7f1e3ad98 100644
--- a/vm/reference/java/net/VMNetworkInterface.java
+++ b/vm/reference/java/net/VMNetworkInterface.java
@@ -66,6 +66,23 @@ final class VMNetworkInterface
addresses = new HashSet();
}
+ /**
+ * Creates a dummy instance which represents any network
+ * interface.
+ */
+ public VMNetworkInterface()
+ {
+ addresses = new HashSet();
+ try
+ {
+ addresses.add(InetAddress.getByName("0.0.0.0"));
+ }
+ catch (UnknownHostException _)
+ {
+ // Cannot happen.
+ }
+ }
+
static
{
if (Configuration.INIT_LOAD_LIBRARY)