Imported GNU Classpath gcj-import-20051117.
authorMark Wielaard <mark@gcc.gnu.org>
Fri, 18 Nov 2005 00:59:33 +0000 (00:59 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Fri, 18 Nov 2005 00:59:33 +0000 (00:59 +0000)
       * gnu/java/net/protocol/file/Connection.java: Removed, fully merged.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r107153

102 files changed:
libjava/ChangeLog
libjava/Makefile.in
libjava/classpath/AUTHORS
libjava/classpath/ChangeLog
libjava/classpath/examples/Makefile.am
libjava/classpath/examples/Makefile.in
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java [new file with mode: 0644]
libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java [new file with mode: 0644]
libjava/classpath/gnu/CORBA/OrbFunctional.java
libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java
libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
libjava/classpath/gnu/java/net/protocol/file/Connection.java
libjava/classpath/gnu/java/net/protocol/jar/Connection.java
libjava/classpath/java/awt/Component.java
libjava/classpath/java/awt/Container.java
libjava/classpath/java/awt/image/MemoryImageSource.java
libjava/classpath/java/io/FilePermission.java
libjava/classpath/java/net/URL.java
libjava/classpath/java/net/URLClassLoader.java
libjava/classpath/java/security/ProtectionDomain.java
libjava/classpath/javax/swing/JApplet.java
libjava/classpath/javax/swing/JComponent.java
libjava/classpath/javax/swing/JEditorPane.java
libjava/classpath/javax/swing/JList.java
libjava/classpath/javax/swing/JMenu.java
libjava/classpath/javax/swing/JPanel.java
libjava/classpath/javax/swing/JSplitPane.java
libjava/classpath/javax/swing/JTextPane.java
libjava/classpath/javax/swing/KeyboardManager.java
libjava/classpath/javax/swing/ToolTipManager.java
libjava/classpath/javax/swing/UIManager.java
libjava/classpath/javax/swing/plaf/basic/BasicBorders.java
libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java
libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java
libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java
libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java
libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java [new file with mode: 0644]
libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java
libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java
libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
libjava/classpath/javax/swing/text/AbstractDocument.java
libjava/classpath/javax/swing/text/BoxView.java
libjava/classpath/javax/swing/text/ComponentView.java
libjava/classpath/javax/swing/text/CompositeView.java
libjava/classpath/javax/swing/text/DefaultCaret.java
libjava/classpath/javax/swing/text/FlowView.java
libjava/classpath/javax/swing/text/GlyphView.java
libjava/classpath/javax/swing/text/IconView.java
libjava/classpath/javax/swing/text/ParagraphView.java
libjava/classpath/javax/swing/text/PlainDocument.java
libjava/classpath/javax/swing/text/WrappedPlainView.java
libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
libjava/classpath/native/jni/java-lang/java_lang_VMDouble.c
libjava/gnu/java/net/protocol/file/Connection.java [deleted file]
libjava/sources.am

index 512b4f1..9219f19 100644 (file)
@@ -1,5 +1,12 @@
 2005-11-17  Mark Wielaard  <mark@klomp.org>
 
+       Imported GNU Classpath gcj-import-20051117.
+       * gnu/java/net/protocol/file/Connection.java: Removed, fully merged.
+       * sources.am: Regenerated.
+       * Makefile.in: Likewise.
+
+2005-11-17  Mark Wielaard  <mark@klomp.org>
+
        * gnu/java/net/protocol/file/Handler.java: Removed, fully merged now.
        * java/net/ServerSocket.java: Likewise.
        * sources.am: Regenerated.
index ac07ecf..e1bff42 100644 (file)
@@ -1425,7 +1425,7 @@ gnu/java/net/protocol/gcjlib/Handler.java
 
 gnu_java_net_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_source_files)))
 gnu_java_net_protocol_file_source_files = \
-gnu/java/net/protocol/file/Connection.java \
+classpath/gnu/java/net/protocol/file/Connection.java \
 classpath/gnu/java/net/protocol/file/Handler.java
 
 gnu_java_net_protocol_file_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files)))
@@ -4224,6 +4224,7 @@ classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java \
 classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java \
 classpath/javax/swing/plaf/metal/MetalLabelUI.java \
 classpath/javax/swing/plaf/metal/MetalLookAndFeel.java \
+classpath/javax/swing/plaf/metal/MetalMenuBarUI.java \
 classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java \
 classpath/javax/swing/plaf/metal/MetalProgressBarUI.java \
 classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java \
index 339138a..2ef1cb7 100644 (file)
@@ -5,6 +5,7 @@ on either list, but should, let us know. Please keep this list in
 alphabetic order.
 
 Lillian Angel (langel@redhat.com)
+Anthony Balkissoon (abalkiss@redhat.com)
 Stuart Ballard (stuart.a.ballard@gmail.com)
 Mark Benvenuto (mcb54@columbia.edu)
 Geoff Berry (gcb@gnu.org)
index d40cc1a..125388f 100644 (file)
@@ -1,3 +1,644 @@
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/JEditorPane.java
+       (PlainEditorKit): New inner class.
+       (createDefaultEditorKit): Return an instance of PlainEditorKit.
+       * javax/swing/JTextPane.java
+       (insertComponent): Implemented previously stubbed method.
+       (insertIcon): Implemented previously stubbed method.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicEditorPaneUI.java
+       (create): Removed unneeded method.
+       * javax/swing/plaf/basic/BasicTextPaneUI.java
+       (create): Removed unneeded method.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * java/awt/Container.java
+       (Container): Added comment.
+       (remove): Only call removeNotify if removed component is still
+       showing.
+       (paintComponents): Call paint() instead of super.paint().
+       (AccessibleContainerHandler.AccessibleContainerHandler): Added
+       comment.
+       (LightweightDispatcher.acquireComponentForMouseEvent):
+       Don't special case MOUSE_RELEASED events. They should be
+       dispatched unmodified just as MOUSE_PRESSED.
+       (LightweightDispatcher.handleEvent): Also clean up the pressCount
+       after a MOUSE_RELEASE.
+
+2005-11-17  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/text/BoxView.java:
+       (modelToView): New API method.
+
+2005-11-17  Lillian Angel  <langel@redhat.com>
+
+       Fixes PR classpath/PR24721
+       * javax/swing/text/BoxView.java
+       (getViewAtPoint): Added check in to return the last view, if one exists and
+       the point was not contained in the rectangle. This is what the JDK does.
+       * javax/swing/text/CompositeView.java
+       (viewToModel): Fixed API documentation. Added check to make sure
+       x and y are greater than 0. Otherwise, 0 is returned.
+       * javax/swing/text/DefaultCaret.java
+       (moveDot): Added check to match API specs.
+       (setDot): Likewise.
+       * javax/swing/text/GlyphView.java
+       (viewToModel): Removed assert. This is not needed here. The point does not
+       need to be in the rectangle.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       Reported by Roman Schnider <schnider@aicas.com>:
+       * java/awt/Component.java
+       (reshape): Removed unused statement.
+       (repaint()): Don't forward to parent when not showing.
+       (repaint(int)): Don't forward to parent when not showing.
+       (repaint(int,int,int,int)): Don't forward to parent when not showing.
+       (repaint(float,int,int,int,int)): Don't forward to parent when not
+       showing.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/text/AbstractDocument.java
+       (LeafElement.getName): If super.getName() returns something
+       non-null, then return that instead of ContentElementName.
+       * javax/swing/text/ComponentView.java
+       (comp): New field.
+       (getAlignment): Implemented previously stubbed method.
+       (getComponent): Implemented previously stubbed method.
+       (getMaximumSpan): Implemented previously stubbed method.
+       (getMinimumSpan): Implemented previously stubbed method.
+       (getPreferredSpan): Implemented previously stubbed method.
+       (modelToView): Implemented previously stubbed method.
+       (paint): Implemented previously stubbed method.
+       (setParent): Implemented previously stubbed method.
+       (setSize): Removed unneeded method.
+       (viewToModel): Implemented previously stubbed method.
+       * javax/swing/text/FlowView.java
+       (insertUpdate): Forward this event to the logical view.
+       * javax/swing/text/IconView.java
+       (paint): Implemented previously stubbed method.
+       (getPreferredSpan): Implemented previously stubbed method.
+       (modelToView): Implemented previously stubbed method.
+       (viewToModel): Implemented previously stubbed method.
+       * javax/swing/text/ParagraphView.java
+       (firstLineIndent): New field.
+       (justification): New field.
+       (lineSpacing): New field.
+       (tabSet): New field.
+       (changedUpdate): New method.
+       (setPropertiesFromAttributes): New method.
+       (setFirstLineIndent): New method.
+       (setJustification): New method.
+       (setLineSpacing): New method.
+       (getLayoutView): New method.
+       (getLayoutViewCount): New method.
+       (getTabSet): New method.
+
+2005-11-17  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/plaf/basic/BasicEditorPaneUI.java:
+       (create): Create new WrappedPlainView instance instead of PlainView.
+
+2005-11-17  Audrius Meskauskas  <AudriusA@Bioinformatics.org>
+        
+       PR 24911
+       * classpath/examples/Makefile.am
+       (EXAMPLE_JAVA_FILES): Extended by /*/*/*.java and /*/*/*/*.java.
+       (READMES): New category.
+       (ALL_EXAMPLE_FILES): Extended by READMES category. 
+
+2004-11-17  Bryce McKinlay  <mckinlay@redhat.com>
+
+       * gnu/java/net/protocol/jar/Connection.java (getHeaderField):
+       Implemented.
+       (getLastModified): Implemented.
+
+2005-11-17  Mark Wielaard  <mark@klomp.org>
+
+       * java/net/URLClassLoader.java: Reindented.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/JApplet.java
+       (paramString): Returns super.paramString() instead of a meaningless
+       'JFrame'.
+       * javax/swing/JPanel.java
+       (paramString): Returns super.paramString() instead of a meaningless
+       'JPanel'.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicButtonUI.java
+       (installDefaults): Don't handle the Button.rollover property here,
+       this is Metal specific and is handled in MetalButtonUI.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/JList.java
+       (locationToIndex): Clarified API comment.
+
+2005-11-17  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/tree/DefaultTreeCellEditor.java
+       (DefaultTreeCellEditor): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       (createTreeCellEditor): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       * javax/swing/tree/DefaultTreeCellRenderer.java
+       (DefaultTreeCellRenderer): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       (getDefaultOpenIcon): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       (getDefaultClosedIcon): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       (getDefaultLeafIcon): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().
+       (getTreeCellRendererComponent): Replaced
+       UIManager.getLookAndFeelDefaults().getXXX() with UIManager.getXXX().w
+       (paint): Replaced UIManager.getLookAndFeelDefaults().getXXX()
+       with UIManager.getXXX().
+
+2005-11-17  Andrew Haley  <aph@redhat.com>
+
+       * gnu/java/net/protocol/file/Connection.java (unquote): New
+       method.
+       (connect): Unquote filename.
+       * gnu/java/net/protocol/jar/Connection.java (get): Likewise.
+
+       * java/net/URL.java (URL): If the file part of a spec is absolute,
+       ignore the file part of its context.
+
+2005-11-17  Audrius Meskauskas  <AudriusA@Bioinformatics.org>
+
+       * examples/gnu/classpath/examples/CORBA/swing/README.html:
+       Added note about the build.
+       
+2005-11-16  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/JSplitPane.java: Reformatted file.
+       * javax/swing/plaf/basic/BasicSplitPaneUI.java: Reformatted file.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/ToolTipManager.java
+       (mouseEntered): No need to start the insideTimer here,
+       already called showTip.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       Fixes PR classpath/PR24763
+       * javax/swing/ToolTipManager.java
+       (mouseEntered): showTip should be called if exitTimer is running.
+       This means that the mouse has exited and re-entered a component
+       in less than 500ms.
+       (mouseExited): If enterTimer is not running, the exitTimer should
+       be started no matter what.
+       (showTip): Should not show tool tip if the currentComponent is
+       not showing.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+       
+       Fixes PR classpath/PR23557 and PR classpath/PR24099
+       * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+       (Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable):
+       Added check to determine if dst->drawable or src->drawable
+       are actually drawable. If not, return.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/metal/MetalBorders.java
+       (ButtonBorder.paintBorder): Special case the OceanTheme.
+       (ButtonBorder.paintOceanThemeBorder): New method.
+       * javax/swing/plaf/metal/MetalButtonUI.java
+       (installDefaults): Set the rollover flag here. Don't set a special
+       border for rollover buttons.
+       (uninstallDefaults): Reset the rollover flag.
+       (update): Only paint gradient when button is enabled and not pressed.
+       * javax/swing/plaf/metal/MetalButtonUI.java
+       (getCurrentTheme): New method.
+
+2005-11-16  Gary Benson  <gbenson@redhat.com>
+
+       * java/io/FilePermission.java (implies): Correct the sense
+       in which action checks are applied.
+
+2005-11-16  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * AUTHORS: Added myself.
+       * javax/swing/KeyboardManager.java: Changed @author tag to match the 
+       other ones I have.
+       * javax/swing/text/WrappedPlainView.java: Likewise.
+
+2005-11-16  Gary Benson  <gbenson@redhat.com>
+       * java/security/ProtectionDomain.java (toString): Use
+       gnu.classpath.SystemProperties to read line.separator
+       without security manager check.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       * java/awt/image/MemoryImageSource.java
+       (startProduction): If animated, imageComplete should
+       be called with the SINGLEFRAMEDONE flag, meaning the
+       single frame is complete, but there are more frames 
+       to follow.
+
+2005-11-16  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/text/PlainDocument.java:
+       (insertString): Null check fixes PR 24890.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/plaf/basic/BasicTreeUI.java
+       (paintVerticalPartOfLeg): Added a check to prevent
+       ArrayOutOfBoundsException.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+       (paintTitleBackground): Only paint background if component is
+       opaque.
+       * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+       (paintPalette): Added gradient painting.
+       (paintComponent): Added gradient painting.
+       * javax/swing/plaf/metal/OceanTheme.java
+       (addCustomEntriesToTable): Added gradient for
+       InternalFrama.activeTitleGradient.
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/ToolTipManager.java:
+       Removed unneeded fields.
+       (showTip): Re-implemented to use PopupFactory.
+       (hideTip): Likewise.
+       (adjustLocation): Fixed location.
+
+2005-11-16  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/text/PlainDocument.java:
+       (insertUpdate): The very first new element added doesn't start at the 
+       start of the event, it starts at the start offset of the Element that
+       contains the start of the event.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicMenuItemUI.java
+       (paintMenuItem): Always call paintBackground().
+
+2005-11-16  Lillian Angel  <langel@redhat.com>
+
+       * gnu/java/awt/peer/gtk/GtkDialogPeer.java
+       (create): Since popups were changed to be JWindowPopups,
+       this code should be done in GtkWindowPeer. Code is not
+       needed.
+       * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+       (create): If window is not focusable, it should not take
+       the focus away from any other window. Therefore, its
+       type should be set to GDK_WINDOW_TYPE_HINT_MENU.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/metal/MetalButtonUI.java
+       (update): New method. Paints the gradient.
+       * javax/swing/plaf/metal/MetalCheckBoxIcon.java
+       (paintIcon): Paint gradient.
+       * javax/swing/plaf/metal/MetalIconFactory.java
+       (RadioButtonIcon.paintIcon): Paint gradient.
+       * javax/swing/plaf/metal/MetalLookAndFeel.java
+       (initClassDefaults): Added MetalMenuBarUI.
+       * javax/swing/plaf/metal/MetalMenuBarUI.java: New file.
+       * javax/swing/plaf/metal/MetalToggleButtonUI.java
+       (update): New method. Paints the gradient.
+       * javax/swing/plaf/metal/OceanTheme.java
+       (addCustomEntriesToTable): Added all the gradients.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/JMenu.java
+       (JMenu()): Set opaque flag to false.
+       (JMenu(String)): Likewise.
+       (JMenu(Action)): Likewise.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicListUI.java
+       (getRowHeight): Adjusted to deal correctly with fixed cell heights.
+       (convertYRoRow): Likewise.
+       * javax/swing/plaf/basic/BasicMenuItemUI.java
+       (installDefaults): Don't make the menu item opaque here.
+       (paintBackground): Moved background painting code from
+       paintMenuItem() to this method.
+       (paintMenuItem): Moved background painting to paintBackground().
+       (installDefaults): Don't set opaque flag here.
+
+2005-11-16  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/metal/MetalUtils.java
+       (paintGradient): New utility method(s).
+       (paintHorizontalGradient): New utility method.
+       (paintVerticalGradient): New utility method.
+
+2005-11-15  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/JComponent.java
+       (paintDoubleBuffered): Put paint() call inside a try-finally
+       block to correctly recover the double-buffering flag when
+       an exception is thrown inside the paint() call.
+
+2005-11-15  Lillian Angel  <langel@redhat.com>
+
+       * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+       (Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable):
+       Needed to set allow_shrink to the same value as resizable. Other-
+       wise, it is always set to false.
+
+2005-11-15  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/plaf/basic/BasicTreeUI.java
+       (paint): Added check to prevent NPE.
+
+2005-11-15  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/JComponent.java:
+       (removeNotify): Unregister WHEN_IN_FOCUSED_WINDOW bindings from the 
+       KeyboardManager.
+
+2005-11-15  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/plaf/basic/BasicLookAndFeel.java
+       (initComponentDefaults): Default rowHeight for tree's should
+       be 0. This is Sun and IBM's default.
+       * javax/swing/plaf/metal/MetalLookAndFeel.java
+       (initComponentDefaults): Default rowHeight for tree's should
+       e 0. This is Sun and IBM's default.
+       * javax/swing/plaf/basic/BasicTreeUI.java:
+       Added a default rowHeight field.
+       (setRowHeight): Set the rowHeight to the class default if parameter
+       is 0. Tree row height should never be set to 0. 20 is the minimum.
+       (installDefaults): fixed call to tree.setRowHeight
+       (shouldPaintExpandControl): Added to check to prevent NPE.
+
+2005-11-15  Audrius Meskauskas  <AudriusA@Bioinformatics.org>
+
+       * examples/gnu/classpath/examples/CORBA/swing/README.html,
+       examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/Player.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/State.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java,
+       examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java: 
+       New files.
+
+2005-11-15  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/UIManager.java
+       (userUIDefaults): New field.
+       (get(Object)): Respect the user UI settings.
+       (get(Object,Locale)): Respect the user UI settings.
+       (getBoolean(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getBoolean(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getBorder(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getBorder(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getColor(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getColor(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getDimension(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getDimension(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getFont(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getFont(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getIcon(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getIcon(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getInsets(Object)): Call get() instead of
+       getLookAndFeelDefaults().getInsets() in order to respect the user UI
+       settings.
+       (getInsets(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().getInsets() in order to respect the user UI
+       settings.
+       (getInt(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getInt(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getString(Object)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getString(Object,Locale)): Call get() instead of
+       getLookAndFeelDefaults().get() in order to respect the user UI
+       settings.
+       (getUI(JComponent)): Respect the user UI settings.
+       (put): Put key/value into user UI settings.
+
+2005-11-15  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/metal/MetalBorders.java
+       (OptionDialogBorder.paintBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/metal/MetalButtonUI.java
+       (MetalButtonUI): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+       (installDefaults): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalLabelUI.java
+       (paintDisabledText): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalRadioButtonUI.java
+       (installDefaults): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalScrollBarUI.java
+       (createDecreaseButton): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (createIncreaseButton): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (paintThumbHorizontal): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (paintThumbVertical): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/metal/MetalSplitPaneUI.java
+       (createDefaultDivider): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/metal/MetalToggleButtonUI.java
+       (installDefaults): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalToolTipUI.java
+       (MetalToolTipUI): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/metal/MetalTreeUI.java
+       Removed all listener fields.
+       (installUI): Removed initialization and call super.installUI()
+       instead.
+       (uninstallUI): Removed initialization and call super.uninstallUI()
+       instead.
+
+2005-11-15  Audrius Meskauskas  <AudriusA@Bioinformatics.org>
+
+       * gnu/CORBA/OrbFunctional.java (serveStep):
+       Returning ensure that the socket is closed.
+
+2005-11-15  Roman Kennke  <kennke@aicas.com>
+
+       * javax/swing/plaf/basic/BasicBorders.java
+       (getButtonBorder): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       (getRadioButtonBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getToggleButtonBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getMenuBarBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getSplitPaneBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getSplitPaneDividerBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getTextFieldBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getInternalFrameBorder): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/basic/BasicButtonUI.java
+       (paintText): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicCheckBoxUI.java
+       (getDefaultIcon): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicComboBoxUI.java
+       (paintCurrentValue): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicFileChooserUI.java
+       (installStrings): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+       (installDefaults): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicListUI.java
+       (installKeyboardActions): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/basic/BasicProgressBarUI.java
+       (boxRect): Added @since tag to the API comment.
+       * javax/swing/plaf/basic/BasicRadioButtonUI.java
+       (getDefaultIcon): Replaced UIManager.getLookAndFeelDefaults().get()
+       with UIManager.get().
+       * javax/swing/plaf/basic/BasicScrollBarUI.java
+       (configureScrollBarColors): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (calculatePreferredSize): Fetch preferred width or height from
+       UI defaults.
+       * javax/swing/plaf/basic/BasicTableUI.java
+       (installKeyboardActions): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/basic/BasicTextUI.java
+       (createKeymap): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getInputMap): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (getActionMap): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       * javax/swing/plaf/basic/BasicToolBarUI.java
+       (dragTo): Don't use cached* fields.
+       (installComponents): Don't use cached* fields.
+       * javax/swing/plaf/basic/BasicTreeUI.java
+       (getHashColor): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       (setHashColor): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+       Added FIXME comment.
+       (installKeyboardActions): Replaced
+       UIManager.getLookAndFeelDefaults().get() with UIManager.get().
+
+2005-11-15  Christian Thalinger  <twisti@complang.tuwien.ac.at>
+
+       * native/jni/java-lang/java_lang_VMDouble.c (initIDs): Register 
+       clsDouble as global ref.
+       * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c 
+       (gtkInit): Register gtkgenericpeer as global ref.
+
+2005-11-15  Lillian Angel  <langel@redhat.com>
+
+       * javax/swing/plaf/basic/BasicTreeUI.java:
+       Removed unneeded field.
+       (getPathBounds): Reimplemented to use getNodeDimensions.
+       (getRowCount): Removed call to updateCurrentVisiblePath.
+       (uninstallKeyboardActions): Implemented.
+       (paint): Reimplemented to only paint rows contained in clip.
+       No longer uses recursion.
+       (mousePressed): If control icon is clicked, should scroll to that
+       path.
+       (getNodeDimensions): Implemented.
+       (getRowX): Implemented.
+       (getCellBounds): Removed.
+       (getCellLocation): Removed.
+       (paintRecursive): Removed.
+       (paintControlIcons): Removed.
+       (getPreviousVisibleNode): Removed call to updateCurrentVisiblePath.
+       (getLevel): Added check for invisible root.
+       (paintVerticalLine): Set graphics color.
+       (paintHorizontalLine): Likewise.
+       (drawCentered): Added negative check.
+       (drawDashedHorizontalLine): Set graphics color.
+       (drawDashedVerticalLine): Likewise.
+       (paintExpandControl): Implemented.
+       (paintHorizontalPartOfLeg): Likewise.
+       (paintVerticalPartOfLeg): Likewise.
+       (paintRow): Added call to paint the control icons.
+       (updateCurrentVisiblePath): Cleaned up function.        
+
+2005-11-15  Anthony Balkissoon  <abalkiss@redhat.com>
+
+       * javax/swing/text/AbstractDocument.java:
+       (remove): Do not set up an ElementEdit here, this is done in the 
+       Document implementation's removeUpdate method.
+       * javax/swing/text/PlainDocument.java:
+       (insertUpdate): Do not call reindex, instead, reindex the lines here
+       directly but only starting from the offset of the newly inserted text.
+       Also, if entire lines have been added or removed, set up an ElementEdit
+       and add it to the DocumentEvent.  Chain BadLocationException to an 
+       AssertionError and throw it in the unexpected case.
+       (removeUpdate): If entire lines have been added or removed, set up an 
+       ElementEdit and add it to the DocumentEvent.  Chain 
+       BadLocationException to an AssertionError and throw it in the 
+       unexpected case.
+       (reindex): Removed unnecessary method.
+
 2005-11-15  Wolfgang Baer  <WBaer@gmx.de>
 
        * javax/print/attribute/DateTimeSyntax.java,
@@ -8,7 +649,8 @@
 
 2005-11-15  Lillian Angel  <langel@redhat.com>
 
-       * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+       * gnu/java/awt/peer/gtk/GtkComponentPeer.java:
+       Code written by Sven de Marothy.
        (gtkWindowGetLocationOnScreen): Added declaration
        for native function.
        (getLocationOnScreen): Changed to handle 2 different cases.
index b7eeacb..341fc5e 100644 (file)
@@ -20,7 +20,7 @@ endif
 endif
 
 # All our example java source files
-EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java
+EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java
 
 # The example C source files
 EXAMPLE_C_FILES = $(srcdir)/gnu/classpath/examples/*/*.c
@@ -34,8 +34,11 @@ BUILT_SOURCES = $(EXAMPLE_ZIP)
 # the png icons we use in some of the examples.
 EXAMPLE_ICONS = $(srcdir)/gnu/classpath/examples/icons/*.png
 
+# The example specific README files.
+READMES = $(srcdir)/gnu/classpath/examples/CORBA/swing/README.html
+
 # All the files we find "interesting"
-ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS)
+ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS) $(READMES)
 
 # Some architecture independent data to be installed.
 example_DATA = $(EXAMPLE_ZIP) README
index f688ab7..5ba479c 100644 (file)
@@ -263,7 +263,7 @@ vm_classes = @vm_classes@
 @FOUND_GCJ_TRUE@JCOMPILER = $(GCJ) --bootclasspath '$(top_builddir)/lib' --classpath . -C
 
 # All our example java source files
-EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java
+EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java
 
 # The example C source files
 EXAMPLE_C_FILES = $(srcdir)/gnu/classpath/examples/*/*.c
@@ -277,8 +277,11 @@ BUILT_SOURCES = $(EXAMPLE_ZIP)
 # the png icons we use in some of the examples.
 EXAMPLE_ICONS = $(srcdir)/gnu/classpath/examples/icons/*.png
 
+# The example specific README files.
+READMES = $(srcdir)/gnu/classpath/examples/CORBA/swing/README.html
+
 # All the files we find "interesting"
-ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS)
+ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS) $(READMES)
 
 # Some architecture independent data to be installed.
 example_DATA = $(EXAMPLE_ZIP) README
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html
new file mode 100644 (file)
index 0000000..a3a9e62
--- /dev/null
@@ -0,0 +1,493 @@
+<html>
+  <head>
+    <title>Five-in-a-row v 0.0</title>
+  </head>
+  <body LANG="en-US">
+    <h1>
+      <i>Five-in-a-row
+      </i> 0.0 supplementary documentation
+    </h1>
+    <h3>Introduction and rules
+    </h3>
+    <p>
+      <i>Five-in-a-row
+      </i> is a two player strategy game. The players
+      are connected via network using CORBA-based RMI/IIOP protocol and
+      make they moves with the help of the Swing-based
+      interface. While playing, the users can also chat.
+    </p>
+    <p>The system consists of the single server and any number of
+      interconnected players. The person, willing to play, starts the
+      client and connects the server. The server redirects call to the
+      partner that has previously connected the same server, also willing
+      to play.
+    </p>
+    <p>The game desk is a field where it is possible to set O's
+      and X'es, one per move. The goal is to get five O's in a row while
+      preventing your partner from getting five X's in a row. Vertical,
+      horizontal and diagonal rows are allowed. The system detects the
+      loss-victory situation on the desk, but currently does not serve as a
+      playing partner, requiring at least two human players for this game.
+    </p>
+    <p>Both players can at any time reset the game (restarting it with
+      the same player) or leave the game (disconnecting). The disconnected
+      player can contact the game manager again, requesting to find another
+      partner.
+    </p>
+    <p>Simple as it is, the application has some features of the typical
+      role playing game that frequently just has more states, actions,
+      possible moves and also provides far richer graphics environment. The
+      game manger serves as a World-Wide-Pub where you can always find a
+      partner to play.
+
+      The players can made both unsynchronized (chatting, game reset and
+      leaving) and synchronized (moves) actions. The game state changes
+      while playing, and the set of the available actions depends on the
+      current state. Finally, the mouse and canvas are involved. However
+      using RMI/IIOP machinery allowed to implement all this functionality
+      with just 13 classes (plus 4 generated), all of them being rather
+      simple.
+      
+      This example refers to the standard classes only and must be buildable
+      from your IDE as long as it has any java 1.4 compiler.       
+    </p>
+    <p>
+      The used IIOP protocol must ensure interoperability, allowing players
+      to use different java virtual machines and operating systems.
+      The processors may have the opposite byte order.
+    </p>
+    <h3>Configuration and run
+    </h3>
+    <p>The game manager server executable class is
+      <i>gnu.classpath.examples.CORBA.swing.x5.X5Server
+      </i>. After start,
+      it will print to console the Internet address that must be entered to
+      the client to reach the manager.
+    </p>
+    <p>The client executable class it
+      <i>gnu.classpath.examples.CORBA.swing.x5.Demo
+      </i>.
+    </p>
+    <p>The game should run with GNU Classpath
+      0.19 and Sun Microsystems java 1.5.0_04. Due later fixed bugs it will
+      not run with the older versions of these two implementations.
+    </p>
+    <p>The game manager HTTP server uses port
+      1500. Hence all firewalls between the server and the player must be
+      configured to allow HTTP on 1500. The ports, used by the RMI/IIOP are
+      not persistent. GNU Classpath is configured to take ports 1501, 1502
+      and 1503 (the firewalls must allow to use them for RMI/IIOP). The
+      CORBA implementation other than Classpath may use different port
+      values. Unfortunately, there is no standard method to configure the
+      used port range in a vendor-independent way.
+    </p>
+    <h3>The game server
+    </h3>
+    <p>The game manager is first reachable via http:// protocol (for
+      instance http://123.456.7.89:1500). The simple server at this port
+      always serves much longer string, representing the CORBA stringified
+      object reference (IOR). The
+      <i>Five-in-a-row&nbsp;
+      </i>client uses
+      this reference to find and access the remote game server object.
+    </p>
+    <p>If the server player queue is empty, it simply queues this player.
+      If the queue is not empty, the server introduces the arrived player
+      and queued player to each other as leaves the them alone. When
+      playing, the two clients communicate with each other directly, so the
+      server is just a &ldquo;meeting point&rdquo; where the players can
+      find each other. The game server is a console-only application.
+    </p>
+    <p>The initial server http:// address must be transferred to players
+      by some other means of communication (web chat, E-mail, link in a web
+      site and so on). The server writes this address to the specified
+      file, and the client can also take the default value from the same
+      file. This is convenient when all applications run on a single
+      machine, but also may be used to transfer the address via shared
+      filesystem.
+    </p>
+    <h3>The game client
+    </h3>
+    <p>The clients are Swing-based GUI applications, capable for remote
+      communication with each other and with the game manager. They have a
+      set of predefined states and switch between these states in
+      accordance to the preprogrammed logic. The client states are defined
+      in the
+      <i>State
+      </i> interface. They are displayed in the bottom left
+      corner of the window and are summarized in the following table:
+    </p>
+    <table BORDER=1 CELLPADDING=4 CELLSPACING=0 WIDTH="100%">
+      <thead>
+        <tr BGCOLOR="#ccccff">
+          <th BGCOLOR="#e6e6ff">
+            Our state
+          </th>
+          <th BGCOLOR="#e6e6ff">
+            Partner state
+          </th>
+          <th BGCOLOR="#e6e6ff">
+            Possible actions
+          </th>
+          <th BGCOLOR="#e6e6ff">
+            Comment
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            Disconnected
+          </td>
+          <td>
+            Partner not accessible
+          </td>
+          <td>
+            Connect
+          </td>
+          <td>
+            Initial state.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            Queued
+          </td>
+          <td>
+            Partner not accessible
+          </td>
+          <td>
+            Leave
+          </td>
+          <td>
+            Queued by the game manager.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            I think.
+          </td>
+          <td>
+            I wait for your move
+          </td>
+          <td>
+            Make move, reset game, leave, chat.
+          </td>
+          <td>
+            The person who waited for another player to come starts
+            the game first.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            I wait for your move
+          </td>
+          <td>
+            I think
+          </td>
+          <td>
+            Chat, reset game, leave.
+          </td>
+          <td>
+            After the partner makes the move, the state changes to
+            <i>I think
+            </i>, unless the end of game situation is detected by
+            the desk analyzer.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            I have lost
+          </td>
+          <td>
+            I have won
+          </td>
+          <td>
+            Chat, reset game, leave.
+          </td>
+          <td>
+            Can be entered with the help of the desk analyzer only.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            I have won
+          </td>
+          <td>
+            I have lost
+          </td>
+          <td>
+            Chat, reset game, leave
+          </td>
+          <td>
+            Can be entered with the help of the desk analyzer only.
+          </td>
+        </tr>
+        <tr>
+          <td>
+            Error
+          </td>
+          <td>
+            Any
+          </td>
+          <td>
+            Chat, leave
+          </td>
+          <td>
+            This should never happen under normal work, but the demo
+            program may be modified by the user.
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <br>
+    <br>
+    As it is seen, being in one of the states, the client expects to
+    be the partner client in a certain defined state, and both clients
+    change they states in a synchronized manner. Each state has its own
+    set of the available actions and each action either preserves the
+    current state (chat, reset) or changes it following the rules. For
+    this simple example, the state change rules are obvious.
+    <h3>The used RMI-IIOP architecture
+    </h3>
+    Both player and game manager servants are derived from the
+    <i>org.omg.PortableServer.Servant
+    </i> and, being servants, are simply
+    connected to the
+    <i>POA
+    </i>with
+    <i>POA.servant_to_reference
+    </i>. The
+    first remote object (game manager) is found using the stringified
+    object reference. No naming service is involved.
+</p>
+Where required, the CORBA objects are narrowed into required
+player and game manager interfaces using method
+<i>PortableRemoteObject.narrow(org.omg.CORBA.Object object, Class
+  interface_class)
+</i>, passing the actual interface of the object as
+the second parameter. After narrowing, the remote side obtains
+possibility to invoke remote methods, defined in the interface of
+this object. After the first remote object is found, other objects
+can be simply passed as the method parameters. For instance, the game
+manager introduces another player by passing its reference as a
+parameter to the method
+<i>Player.start_game.
+</i>
+<h3>Class and interface summary
+</h3>
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+  <col>
+  <col>
+  <tr>
+    <th COLSPAN=2 BGCOLOR="#e6e6ff">
+      Executables classes
+    </th>
+  </tr>
+  <tr>
+    <td>
+      Demo
+    </td>
+    <td>
+      The main executable class of the game client.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      X5Server
+    </td>
+    <td>
+      The main executable class of the game manager server.
+    </td>
+  </tr>
+</table>
+<p></p>
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+  <tr BGCOLOR="#ccccff">
+    <th COLSPAN=2 BGCOLOR="#e6e6ff">
+      Interface Summary
+    </th>
+  </tr>
+  <tr>
+    <td>
+      GameManager
+    </td>
+    <td>
+      The game manager interface.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      Player
+    </td>
+    <td>
+      Defines remote methods that are invoked by another player or by
+      the challenge server.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      State
+    </td>
+    <td>
+      Defines the states in that the player can be.
+    </td>
+  </tr>
+</table>
+&nbsp;
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+  <col>
+  <col>
+  <tr BGCOLOR="#ccccff">
+    <th COLSPAN=2 BGCOLOR="#e6e6ff">
+      Class Summary
+    </th>
+  </tr>
+  <tr>
+    <td>
+      _GameManager_Stub
+    </td>
+    <td>
+      Normally generated with rmic compiler, this class represents
+      the GameManager Stub on the client side.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      _GameManagerImpl_Tie
+    </td>
+    <td>
+      Normally generated with rmic compiler, this class represents
+      the GameManager Tie on the client side.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      _Player_Stub
+    </td>
+    <td>
+      Generate with rmic, command line rmic -iiop -poa -keep
+      gnu.classpath.examples.CORBA.swing.x5.PlayerImpl (the compiled
+      package must be present in the current folder).
+    </td>
+  </tr>
+  <tr>
+    <td>
+      _PlayerImpl_Tie
+    </td>
+    <td>
+      Generate with rmic, command line rmic -iiop -poa -keep
+      gnu.classpath.examples.CORBA.swing.x5.PlayerImpl (the compiled
+      package must be present in the current folder).
+    </td>
+  </tr>
+  <tr>
+    <td>
+      ChatConstants
+    </td>
+    <td>
+      The chat color code constants, used to indicate who is talking.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      ClientFrame
+    </td>
+    <td>
+      The JFrame of the GUI client.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      GameManagerImpl
+    </td>
+    <td>
+      The manager connects two players into the game.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      IorReader
+    </td>
+    <td>
+      Reads the remote URL.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      OrbStarter
+    </td>
+    <td>
+      Starts the ORBs, involved into this application.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      PlayerImpl
+    </td>
+    <td>
+      The implementation of the PlayerCommunicator, providing the
+      local functionality.
+    </td>
+  </tr>
+  <tr>
+    <td>
+      PlayingDesk
+    </td>
+    <td>
+      Manages actions, related to the game rules and also does all
+      painting.
+    </td>
+  </tr>
+</table>
+<h3>See also
+</h3>
+<p>
+  <a HREF="http://www.javascripter.net/games/xo/xo.htm">http://www.javascripter.net/games/xo/xo.htm
+  </a>
+</p>
+<p>
+  <a HREF="http://www.leepoint.net/notes-java/45examples/55games/five/five.html">http://www.leepoint.net/notes-java/45examples/55games/five/five.html
+  </a>
+</p>
+<p>Copyright
+</p>
+<p>
+  <font COLOR="#b3b3b3">Copyright (C) 2005 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.
+  </font>
+</p>
+<p>
+  <br>
+  <br>
+</p>
+<p>
+First version written by <a href="http://savannah.gnu.org/users/audriusa">
+Audrius Me&scaron;kauskas</a>
+</p>
+</body>
+</html>
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java
new file mode 100644 (file)
index 0000000..9e1a70f
--- /dev/null
@@ -0,0 +1,307 @@
+/* CanvasWorld.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+
+/**
+ * The purpose of this simple example is to check if the mouse events are
+ * correctly received in a scrollable canvas and also if the canvas are
+ * correctly repainted. The similar canvas are used in various games and
+ * interactive demonstrations. 
+ * 
+ * The user can set one of the three possible figures with the different
+ * mouse buttons. The figure must be set where the user have clicked the
+ * mouse.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class CanvasWorld
+  extends JComponent
+  implements MouseListener, State
+{
+  /**
+   * Use serialVersionUID for interoperability.
+   */
+  private static final long serialVersionUID = 1;
+
+  /**
+   * Red oval, set by the left mouse button.
+   */
+  public static final int RED = 0;
+
+  /**
+   * Black cross, set by the right mouse button.
+   */
+  public static final int BLACK = 1;
+  
+  /**
+   * Blue and smaller oval, set by the middle mouse button.
+   */
+  public static final int HINT = 2;
+  
+  /**
+   * The message string is displayed at the top of the window.
+   */
+  String message = "Click left, right or middle button in to set the figure";
+  
+  /**
+   * The additinal message, related to the mouse events.
+   */
+  String mouse = "No mouse event so far";
+
+  /**
+   * The grid spacing.
+   */
+  static int W = 16;
+
+  /**
+   * The radius of the dots being painted.
+   */
+  static int R = W / 3;
+
+  /**
+   * The collection of the red dots.
+   */
+  ArrayList reds = new ArrayList();
+
+  /**
+   * The collection of the black crosses.
+   */
+  ArrayList blacks = new ArrayList();
+  
+  /**
+   * The collection of the smaller blue crosses.
+   */
+  ArrayList hints = new ArrayList();
+
+  public CanvasWorld()
+  {
+    try
+      {
+        addMouseListener(this);
+      }
+    catch (Exception e)
+      {
+        throw new AssertionError(e);
+      }
+  }
+
+  /**
+   * Paint this component.
+   */
+  public void paintComponent(Graphics g)
+  {
+    int w = getWidth();
+    int h = getHeight();
+
+    g.setColor(Color.white);
+    g.fillRect(0, 0, w, h);
+
+    drawGrid(w, h, g);
+    
+    g.setColor(Color.black);
+    
+    g.drawString(message, W, W);
+    g.drawString(mouse, W, 2*W);
+    
+    drawFigures(g);
+  }
+
+  /**
+   * Check for the presence of the given point in the collection.
+   */
+  public final boolean pointPresent(int x, int y, Collection in)
+  {
+    Iterator iter = in.iterator();
+    Point p;
+    while (iter.hasNext())
+      {
+        p = (Point) iter.next();
+        if (p.x == x && p.y == y)
+          return true;
+      }
+    return false;
+  }
+
+  public void drawGrid(int w, int h, Graphics g)
+  {
+    g.setColor(Color.lightGray);
+
+    int xs = 2*W+W/2;
+    
+    // Draw vertical lines:
+    for (int x = 0; x < w; x += W)
+      {
+        g.drawLine(x, xs, x, h);
+      }
+
+    // Draw horizontal lines:
+    for (int y = 3*W; y < h; y += W)
+      {
+        g.drawLine(0, y, w, y);
+      }
+      
+    g.setColor(Color.gray);
+  }
+
+  public void drawFigures(Graphics g)
+  {
+    g.setColor(Color.red);
+    drawDots(reds, g, RED);
+
+    g.setColor(Color.black);
+    drawDots(blacks, g, BLACK);
+    
+    g.setColor(Color.blue);
+    drawDots(hints, g, HINT);
+  }
+
+  public Point makePoint(int x, int y)
+  {
+    return new Point(x / W, y / W);
+  }
+
+  /**
+   * Draw a collection of dots (the collor must be set before calling the
+   * method).
+   */
+  public void drawDots(Collection dots, Graphics g, int mode)
+  {
+    Iterator iter = dots.iterator();
+    int x;
+    int y;
+
+    int hW = W / 2;
+    int RR = R * 2;
+    int hR = R / 2;
+    Point p;
+    while (iter.hasNext())
+      {
+        p = (Point) iter.next();
+        x = p.x * W + hW;
+        y = p.y * W + hW;
+
+        if (mode == RED)
+          g.drawOval(x - R, y - R, RR, RR);
+        else if (mode == BLACK)
+          {
+            g.drawLine(x - R, y - R, x + R, y + R);
+            g.drawLine(x - R, y + R, x + R, y - R);
+          }
+        else
+          {
+            // Hint.
+            g.drawOval(x - hR, y - hR, R, R);
+          }
+      }
+  }
+
+  public void mouseClicked(MouseEvent e)
+  {
+    int x = e.getX();
+    int y = e.getY();
+
+    Point p = makePoint(x, y);
+
+    // Ignore clicks on the occupied cells.
+    if (pointPresent(p.x, p.y, reds) || (pointPresent(p.x, p.y, blacks)))
+      {
+        message = "Clicked on the occupied cell.";
+        return;
+      }
+    else
+      message = "Figure set at ["+p.x+","+p.y+"]";
+
+    if (e.getButton() == MouseEvent.BUTTON1)
+      reds.add(p);
+    else if (e.getButton() == MouseEvent.BUTTON3)
+      blacks.add(p);
+    else if (e.getButton() == MouseEvent.BUTTON2)
+      hints.add(p);
+    repaint();
+  }
+
+  public void mouseEntered(MouseEvent m)
+  {
+    mouse = "Mouse entered.";
+    repaint();  
+  }
+
+  public void mousePressed(MouseEvent m)
+  {
+    mouse = "Mouse pressed at "+m.getX()+","+m.getY();
+    repaint();
+  }
+
+  public void mouseReleased(MouseEvent m)
+  {
+    mouse = "Mouse released at "+m.getX()+","+m.getY();    
+    repaint();
+  }
+
+  public void mouseExited(MouseEvent m)
+  {
+    mouse = "Mouse exited";
+    repaint();
+  }
+  
+  public static void main(String[] args)
+  {
+    JFrame frame = new JFrame();
+    CanvasWorld world = new CanvasWorld();
+    world.setPreferredSize(new Dimension(1000,1000));
+    frame.add(new JScrollPane(world));
+    frame.setSize(400, 200);
+    frame.setVisible(true);
+  }
+
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java
new file mode 100644 (file)
index 0000000..b0552b4
--- /dev/null
@@ -0,0 +1,80 @@
+/* ChatConstants.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Color;
+
+/**
+ * The chat color code constants, used to indicate who is talking.
+ * Additionally, the red color is reseved for the most important messages,
+ * related to the start and end of the game.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class ChatConstants
+{
+  /**
+   * Messages from the local system.
+   */
+  public static byte SYSTEM = 0;
+
+  /**
+   * Mirrored messsages from the local player.
+   */
+  public static byte SELF = 1;
+
+  /**
+   * Messages from the remote player.
+   */
+  public static byte REMOTE_PLAYER = 2;
+
+  /**
+   * Messages from the game server/
+   */
+  public static byte GAME_SERVER = 3;
+  
+  /**
+   * The array of the used colors.
+   */
+  public static Color[] colors =
+    new Color[]
+    {
+      Color.black, new Color(0, 80, 0), new Color(0, 0, 128), Color.blue
+    };
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java
new file mode 100644 (file)
index 0000000..c3d8300
--- /dev/null
@@ -0,0 +1,417 @@
+/* ClientFrame.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.event.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+import java.rmi.RemoteException;
+
+import javax.rmi.PortableRemoteObject;
+
+import javax.swing.*;
+import java.awt.Dimension;
+
+/**
+ * The JFrame of the GUI client.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ClientFrame
+  extends JFrame
+{
+  /**
+   * The size of the playing field.
+   */
+  public final Dimension DESK_SIZE = 
+       new Dimension(624, 352-PlayingDesk.W);
+
+  /**
+   * Use serialVersionUID for interoperability.
+   */
+  private static final long serialVersionUID = 1;
+
+  // Define the application components:
+
+  /**
+   * Central panel where the main action takes place.
+   */
+  PlayingDesk desk = new PlayingDesk();
+
+  /**
+   * The scroll pane for canvas.
+   */
+  JScrollPane scroll = new JScrollPane();
+
+  /**
+   * Will remember the manager IOR.
+   */
+  String mior = "";
+
+  // The bottom panel contains the area that is used both to enter URL and
+  // for chatting.
+  JPanel pnBottom = new JPanel();
+
+  BorderLayout layBottom = new BorderLayout();
+
+  JTextField taUrl = new JTextField();
+
+  // The top primitive chatting panel, composed from labels.
+  JPanel pnChat = new JPanel();
+
+  GridLayout layChat = new GridLayout();
+
+  JLabel lbC3 = new JLabel();
+
+  JLabel lbC2 = new JLabel();
+
+  JLabel lbC1 = new JLabel();
+
+  // The button panel.
+  JPanel pnButtons = new JPanel();
+
+  GridLayout layButtons = new GridLayout();
+
+  JButton bLeave = new JButton();
+
+  JButton bConnect = new JButton();
+
+  JButton bExit = new JButton();
+
+  JButton bReset = new JButton();
+
+  JLabel lbState = new JLabel();
+
+  JButton bChat = new JButton();
+  
+  JButton bPaste = new JButton();
+
+  public ClientFrame()
+  {
+    try
+      {
+        jbInit();
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+  }
+
+  private void jbInit()
+    throws Exception
+  {
+    desk.frame = this;
+
+    pnBottom.setLayout(layBottom);
+
+    pnChat.setLayout(layChat);
+    layChat.setColumns(1);
+    layChat.setRows(3);
+
+    lbC1.setText("This program needs the game server (see README on how to start it).");
+    lbC2.setText("Enter the game server address (host:port)");
+    lbC3.setText("Pressing \'Connect\' with the empty address will start the server on "
+      + "the local machine.");
+    bLeave.setEnabled(true);
+    bLeave.setToolTipText("Leave if either you have lost or do not want longer to play with "
+      + "this partner.");
+    bLeave.setText("Leave game");
+    bLeave.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bLeave_actionPerformed(e);
+      }
+    });
+    bConnect.setToolTipText("Connect your playing partner");
+    bConnect.setText("Connect");
+    bConnect.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bConnect_actionPerformed(e);
+      }
+    });
+    pnButtons.setLayout(layButtons);
+    bExit.setToolTipText("Exit this program");
+    bExit.setText("Exit");
+    bExit.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bExit_actionPerformed(e);
+      }
+    });
+    layButtons.setHgap(2);
+    bReset.setToolTipText("Restart the game. The partner may choose to exit!");
+    bReset.setText("Reset game");
+    bReset.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bReset_actionPerformed(e);
+      }
+    });
+    lbState.setText("Disconnected");
+    bChat.setToolTipText("Send message to player. Reuse the address "+
+                         "field to enter the message.");
+    bChat.setText("Chat");
+    bChat.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bChat_actionPerformed(e);
+      }
+    });
+    
+    bPaste.setText("Paste");
+    bPaste.setToolTipText("Paste, same as Ctrl-V");
+    bPaste.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        bPaste_actionPerformed(e);
+      }
+    });
+    
+    desk.setMaximumSize(DESK_SIZE);
+    desk.setPreferredSize(DESK_SIZE);
+    
+    scroll.getViewport().add(desk, null);
+    getContentPane().add(scroll, BorderLayout.CENTER);
+    getContentPane().add(pnBottom, BorderLayout.SOUTH);
+
+    pnBottom.add(taUrl, BorderLayout.CENTER);
+    pnBottom.add(pnChat, BorderLayout.NORTH);
+
+    pnChat.add(lbC1, null);
+    pnChat.add(lbC2, null);
+    pnChat.add(lbC3, null);
+    pnBottom.add(pnButtons, BorderLayout.SOUTH);
+    pnButtons.add(lbState, null);
+    pnButtons.add(bConnect, null);
+    pnButtons.add(bChat, null);
+    pnButtons.add(bLeave, null);
+    pnButtons.add(bReset, null);
+    pnButtons.add(bExit, null);
+    pnButtons.add(bPaste, null);    
+
+    desk.player.set_current_state(State.DISCONNECTED);
+  }
+
+  /**
+   * Handles exit procedure.
+   */
+  protected void processWindowEvent(WindowEvent e)
+  {
+    super.processWindowEvent(e);
+    if (e.getID() == WindowEvent.WINDOW_CLOSING)
+      {
+        bExit_actionPerformed(null);
+      }
+  }
+
+  /**
+   * Handles the connection procedure.
+   */
+  void bConnect_actionPerformed(ActionEvent e)
+  {
+    try
+      {
+        int state = desk.player.get_current_state();
+
+        if (state == State.DISCONNECTED || state == State.ERROR)
+          {
+            talk(ChatConstants.colors[0], "Connecting...");
+
+            if (desk.manager == null)
+              {
+                mior = taUrl.getText().trim();
+
+                // Obtain the manager object:
+                org.omg.CORBA.Object object = null;
+
+                try
+                  {
+                    object = desk.orb.string_to_object(mior);
+                  }
+                catch (Exception exc)
+                  {
+                    // Maybe CORBA 3.0.3 is not completely implemented?
+                    if (mior.startsWith("http://") || mior.startsWith("ftp://")
+                      || mior.startsWith("file://"))
+                      object = desk.orb.string_to_object(IorReader.readUrl(mior));
+                    else
+                      throw exc;
+                  }
+
+                desk.manager = (GameManager) PortableRemoteObject.narrow(
+                  object, GameManager.class);
+
+                // Export the desk.player as a remote object.
+                PortableRemoteObject.exportObject(desk.player);
+              }
+
+            desk.player.set_current_state(State.QUEUED);
+            desk.manager.requestTheGame(desk.player);
+          }
+
+        // Save the specified IOR for the future use:
+        File gmf = new File(OrbStarter.WRITE_URL_TO_FILE);
+        FileWriter f = new FileWriter(gmf);
+        BufferedWriter b = new BufferedWriter(f);
+
+        b.write(mior);
+        b.close();
+      }
+    catch (Exception ex)
+      {
+        talk(Color.red, "The manager is not reachable by this address.");
+        talk(Color.red, ex.getMessage());
+        desk.player.set_current_state(State.DISCONNECTED);
+      }
+  }
+
+  /**
+   * Display the new message with the given color. Shift the other messages over
+   * the labels.
+   */
+  public void talk(Color color, String text)
+  {
+    lbC1.setText(lbC2.getText());
+    lbC1.setForeground(lbC2.getForeground());
+
+    lbC2.setText(lbC3.getText());
+    lbC2.setForeground(lbC3.getForeground());
+
+    lbC3.setText(text);
+    lbC3.setForeground(color);
+  }
+
+  /**
+   * Exit this program.
+   */
+  void bExit_actionPerformed(ActionEvent e)
+  {
+    try
+      {
+        if (desk.player.get_current_state() != State.DISCONNECTED
+          && desk.player.partner != null)
+          {
+            desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+              "I close the program!");
+            desk.player.partner.disconnect();
+          }
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application that
+        // may be modified for learning purposes.
+        ex.printStackTrace();
+      }
+    System.exit(0);
+  }
+
+  void bReset_actionPerformed(ActionEvent e)
+  {
+    if (desk.player.partner != null)
+      {
+        try
+          {
+            desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+              "Your partner restarted the game.");
+
+            desk.player.start_game(desk.player.partner, false);
+            desk.player.partner.start_game(desk.player, true);
+          }
+        catch (RemoteException ex)
+          {
+            // We will print the exception because this is a demo application
+            // that
+            // may be modified for learning purposes.
+            ex.printStackTrace();
+          }
+      }
+    else
+      talk(Color.black, "You have not started the game yet.");
+  }
+
+  void bLeave_actionPerformed(ActionEvent e)
+  {
+    desk.player.leave();
+  }
+
+  void bChat_actionPerformed(ActionEvent e)
+  {
+    try
+      {
+        if (desk.player.partner != null)
+          {
+            String message = taUrl.getText();
+            desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER, message);
+            talk(ChatConstants.colors[ChatConstants.SELF], message);
+            taUrl.setText("");
+          }
+        else
+          {
+            talk(Color.black, "Sorry, not connected to anybody");
+          }
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application that
+        // may be modified for learning purposes.
+        ex.printStackTrace();
+      }
+  }
+  
+  /**
+   * Work around our keyboard shortcut handling that is still not working
+   * properly.
+   */
+  void bPaste_actionPerformed(ActionEvent e)
+  {
+    taUrl.paste();
+  }  
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java
new file mode 100644 (file)
index 0000000..b832178
--- /dev/null
@@ -0,0 +1,99 @@
+/* Demo.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+/**
+ * The main executable class of the game client.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class Demo
+{
+
+  public static void main(String[] args)
+  {
+    ClientFrame frame = new ClientFrame();
+    frame.setSize(new Dimension(640, 480));
+    frame.setTitle("Make vertical, horizontal or diagonal line of 5 dots. "
+      + "Click mouse to set the dot.");
+    frame.validate();
+
+    // Center the window
+    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+    Dimension frameSize = frame.getSize();
+    if (frameSize.height > screenSize.height)
+      {
+        frameSize.height = screenSize.height;
+      }
+    if (frameSize.width > screenSize.width)
+      {
+        frameSize.width = screenSize.width;
+      }
+    frame.setLocation((screenSize.width - frameSize.width) / 2,
+      (screenSize.height - frameSize.height) / 2);
+    frame.setVisible(true);
+
+    // Set the ior.
+    try
+      {
+        if (OrbStarter.WRITE_URL_TO_FILE != null)
+          {
+            File saved_ior = new File(OrbStarter.WRITE_URL_TO_FILE);
+            if (saved_ior.exists())
+              {
+                FileReader f = new FileReader(saved_ior);
+                String s = new BufferedReader(f).readLine();
+                frame.taUrl.setText(s);
+              }
+          }
+      }
+    catch (Exception e)
+      {
+        // We will print the exception, because this is a demo program -
+        // expected to be modified by user.
+        e.printStackTrace();
+      }
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java
new file mode 100644 (file)
index 0000000..4d632e8
--- /dev/null
@@ -0,0 +1,68 @@
+/* GameManager.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The game manager interface.
+ * 
+ * Defines the operations of the game server that connects two players into
+ * the game. The game server does not participate in the game itself.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public interface GameManager extends Remote
+{
+  /**
+   * Register the newPlayer as the person who is willing to play. When another
+   * player calls this method, the Manager connects them by calling
+   * {@link PlayerCommunicator#start_game}. The manager provides the partner
+   * and sets (randomly) the starting side.
+   */
+  void requestTheGame(Player newPlayer) throws RemoteException;
+
+  /**
+   * Unregister the player that left and is no longer waiting for a playing
+   * partner to come.
+   * @throws RemoteException
+   */
+  void unregister(Player player) throws RemoteException;
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java
new file mode 100644 (file)
index 0000000..fc449bc
--- /dev/null
@@ -0,0 +1,135 @@
+/* GameManagerImpl.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.rmi.RemoteException;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+
+/**
+ * The manager connects two players into the game.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class GameManagerImpl
+  implements GameManager
+{
+  /**
+   * The game manager IOR.
+   */
+  static String ior;
+
+  /**
+   * The game manager ORB.
+   */
+  static ORB orb;
+
+  /**
+   * True if the manager started ok.
+   */
+  static boolean ok;
+
+  /**
+   * Another player that is already waiting for the game.
+   */
+  Player queuedPlayer = null;
+
+  public synchronized void requestTheGame(Player newPlayer)
+    throws RemoteException
+  {
+    System.out.println("Game requested");
+
+    if (queuedPlayer == null)
+      {
+        // No other player so far.
+        newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+          "Request registered, waiting for the other player to come...");
+        System.out.println("Player queued.");
+        queuedPlayer = newPlayer;
+      }
+    else if (queuedPlayer.equals(newPlayer))
+      {
+        // The same player applies again.
+        newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+          "No other player so far... Please wait.");
+      }
+    else
+      {
+        // As the queued player waited for the game, we allow him/her
+        // to start the game. This is a reward for waiting.
+        newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+          "The other player is waiting. The game started, your "
+            + "partner begins...");
+        queuedPlayer.receive_chat(ChatConstants.GAME_SERVER,
+          "The other player arrived. Lets play, you begin the game now...");
+
+        newPlayer.start_game(queuedPlayer, false);
+        queuedPlayer.start_game(newPlayer, true);
+
+        queuedPlayer = null;
+        System.out.println("Players connected.");
+      }
+  }
+
+  /**
+   * Unregister the player who left and is no longer waiting for another side.
+   */
+  public void unregister(Player player)
+    throws RemoteException
+  {
+    if (queuedPlayer != null)
+      {
+        // We need to verify the identity of the player being unregistered.
+        // The stubs, being derived from the org.omg.CORBA.Object, have the
+        // method for this. This method compares the player host address,
+        // used port and the object key.
+        if (player instanceof Object && queuedPlayer instanceof Object)
+          {
+            Object a = (Object) player;
+            Object b = (Object) queuedPlayer;
+
+            if (a._is_equivalent(b))
+              queuedPlayer = null;
+          }
+        else
+          queuedPlayer = null;
+      }
+    System.out.println("Unregistering player");
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java
new file mode 100644 (file)
index 0000000..a976def
--- /dev/null
@@ -0,0 +1,124 @@
+/* IorReader.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.DATA_CONVERSION;
+
+/**
+ * Reads the remote URL. Following formal/04-03-12, CORBA should be able to do 
+ * this without the help of this class. However some popular class libraries
+ * are written using the older CORBA specifications and may not handle 
+ * functionality, require by this game. This class substitutes the functionality,
+ * ensuring that these implementations will also start and we will be able
+ * to test the interoperability.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class IorReader
+{
+  /**
+   * Read IOR from the remote URL.
+   */
+  public static String readUrl(String url)
+  {
+    URL u;
+    try
+      {
+        u = new URL(url);
+      }
+    catch (MalformedURLException mex)
+      {
+        throw new BAD_PARAM("Malformed URL: '" + url + "'");
+      }
+
+    try
+      {
+        InputStreamReader r = new InputStreamReader(u.openStream());
+
+        StringBuffer b = new StringBuffer();
+        int c;
+
+        while ((c = r.read()) > 0)
+          b.append((char) c);
+
+        return b.toString().trim();
+      }
+    catch (Exception exc)
+      {
+        DATA_CONVERSION d = new DATA_CONVERSION("Reading " + url + " failed.");
+        throw d;
+      }
+  }
+  
+  /**
+   * Read IOR from the file in the local file system.
+   */
+  public static String readFile(String file)
+  {
+    File f = new File(file);
+    if (!f.exists())
+      {
+        DATA_CONVERSION err = new DATA_CONVERSION(f.getAbsolutePath()
+          + " does not exist.");
+        throw err;
+      }
+    try
+      {
+        char[] c = new char[(int) f.length()];
+        FileReader fr = new FileReader(f);
+        fr.read(c);
+        fr.close();
+        return new String(c).trim();
+      }
+    catch (IOException ex)
+      {
+        DATA_CONVERSION d = new DATA_CONVERSION();
+        d.initCause(ex);
+        throw (d);
+      }
+  }  
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java
new file mode 100644 (file)
index 0000000..3852945
--- /dev/null
@@ -0,0 +1,236 @@
+/* OrbStarter.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.rmi.RemoteException;
+import java.util.Properties;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.ORB;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Starts the ORBs, involved into this application.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class OrbStarter
+{
+  /**
+   * The game manager name server port. This server allows to access the game
+   * manager by host (IP) and port rather than by the rather long IOR string.
+   */
+  static int MANAGER_NAMER_PORT = 1500;
+         
+  /**
+   * The used port range (understood and used by GNU Classpath only).
+   */
+  static String USED_PORT_RANGE = "1501-1503";
+         
+  /**
+   * Specify the file where under start the game manager writes its IOR.
+   * You may specify the path if the game manager and player clients have
+   * access to some share file system or if you prefer to write IOR to
+   * floppy and then read from the floppy on the client side. Both clients
+   * and server will use this constant. Set to null not to write the IOR.
+   */
+  static String WRITE_URL_TO_FILE = "game_manager_ior.txt";    
+       
+  /**
+   * Start the manager ORB.
+   * @return the manager URL if it starts.
+   */
+  public static String startManager(final String[] args)
+  {
+    GameManagerImpl.ior = null;
+    GameManagerImpl.ok = false;
+
+    final Properties p = new Properties();
+    p.put("gnu.CORBA.ListenerPort", USED_PORT_RANGE);
+
+    try
+      {
+        new Thread()
+        {
+          public void run()
+          {
+            try
+              {
+                GameManagerImpl.orb = ORB.init(args, p);
+
+                // Obtain the root poa:
+                POA rootPOA = POAHelper.narrow(GameManagerImpl.orb.resolve_initial_references("RootPOA"));
+
+                GameManagerImpl impl = new GameManagerImpl();
+
+                PortableRemoteObject.exportObject(impl);
+
+                // Construct the tie that is also the servant.
+                Tie tie = new _GameManagerImpl_Tie();
+
+                // Set the invocation target for this tie.
+                tie.setTarget(impl);
+
+                // Obtain the reference to the corresponding CORBA object:
+                org.omg.CORBA.Object object = rootPOA.servant_to_reference((Servant) tie);
+
+                GameManagerImpl.ok = true;
+
+                // Activate the root POA.
+                rootPOA.the_POAManager().activate();
+
+                // Get the IOR URL that must be passed to clients.
+                GameManagerImpl.ior = GameManagerImpl.orb.object_to_string(object);
+
+                GameManagerImpl.orb.run();
+              }
+            catch (Exception exc)
+              {
+                exc.printStackTrace();
+                GameManagerImpl.ior = "Unable to start the ORB: " + exc;
+              }
+          }
+        }.start();
+
+        // Wait the thread to enter orb.run.
+        long t = System.currentTimeMillis();
+        while (GameManagerImpl.ior == null
+          && System.currentTimeMillis() - t < 20000)
+          {
+            Thread.sleep(100);
+          }
+
+        return GameManagerImpl.ior;
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+        return "Exception: " + e;
+      }
+  }
+  
+  /**
+   * Start the client ORB.
+   */
+  public static String startPlayer(final Player player, final PlayingDesk desk)
+  {
+    desk.ior = null;
+    desk.ok = false;
+    
+    final Properties p = new Properties();
+    p.put("gnu.CORBA.ListenerPort", USED_PORT_RANGE);
+    
+    try
+      {
+        new Thread()
+        {
+          public void run()
+          {
+            try
+              {
+                desk.orb = ORB.init(new String[0], p);
+
+                POA rootPOA = POAHelper.narrow(desk.orb.resolve_initial_references("RootPOA"));
+                rootPOA.the_POAManager().activate();
+
+                // Construct the tie.
+                Tie tie = new _PlayerImpl_Tie();
+
+                // Set the implementing class (invocation target).
+                tie.setTarget(new PlayerImpl());
+
+                // Connect the tie as POA servant.
+                org.omg.CORBA.Object object = rootPOA.servant_to_reference((Servant) tie);
+
+                // Get the stringified reference.
+                desk.ior = desk.orb.object_to_string(object);
+
+                // Mark that the object was created OK.
+                desk.ok = true;
+                desk.orb.run();
+              }
+            catch (Exception exc)
+              {
+                exc.printStackTrace();
+                desk.ior = "Unable to start the ORB: " + exc;
+              }
+          }
+        }.start();
+
+        long t = System.currentTimeMillis();
+        while (desk.ior == null && System.currentTimeMillis() - t < 20000)
+          {
+            Thread.sleep(100);
+          }
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+        return "Exception: " + e;
+      }
+
+    // Add shutdown hook to unregister from the manager.
+    Runtime.getRuntime().addShutdownHook(new Thread()
+    {
+      public void run()
+      {
+        if (desk.manager != null && player != null)
+          {
+            try
+              {
+                desk.manager.unregister(player);
+              }
+            catch (RemoteException ex)
+              {
+                // We will print the exception because this is a demo
+                // application that
+                // may be modified for learning purposes.
+                ex.printStackTrace();
+              }
+            desk.manager = null;
+          }
+      }
+    });
+    return desk.ior;
+  }  
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java
new file mode 100644 (file)
index 0000000..ff5624b
--- /dev/null
@@ -0,0 +1,96 @@
+/* Player.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Point;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Defines remote methods that are invoked by another player or by the
+ * challenge server.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public interface Player extends Remote
+{
+  /**
+   * Receive the invitation to play from the patner or the game manager.
+   *
+   * @param address the address (host and port) of the remote partner.
+   * @param youStart if true, the game manager instructs to start
+   * the game first (another side is instructed to start the game second).
+   *
+   * @return true on success.
+   */
+  boolean start_game(Player otherPlayer, boolean youStart)
+    throws RemoteException;
+
+  /**
+   * Get the state of the local player (one of the constants, defined
+   * in this interface).
+   */
+  int get_current_state() throws RemoteException;
+
+  /**
+   * Receive the chat message from the friend or challenge server (remote).
+   * Possible at any state, always remote.
+   *
+   * @param color the color code, used to highlight the message.
+   * @param text the message text.
+   */
+  void receive_chat(byte color, String test) throws RemoteException;
+
+  /**
+   * Indicated that the remote side leaves the game (capitulating).
+   */
+  void disconnect() throws RemoteException;
+
+  /**
+   * Receive friends move (possible at I_WAIT_FOR_YOUR_MOVE).
+   *
+   * @param x grid position.
+   * @param y grid position.
+   *
+   * @param sessionId the session id, must match (otherwise the call is ignored).
+   * @param victory if not a null, the friend thinks that it has won, the parameter
+   * containing the ends of the builded line.
+   */
+  void receive_move(int x, int y, Point[] victory) throws RemoteException;
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java
new file mode 100644 (file)
index 0000000..c30f7d5
--- /dev/null
@@ -0,0 +1,275 @@
+/* PlayerImpl.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Color;
+import java.awt.Point;
+
+import java.rmi.RemoteException;
+
+/**
+ * The implementation of the PlayerCommunicator, providing the local
+ * functionality. Apart remote methods, the class also defines some local
+ * methods, needed for the co-ordinated work with the game user interface.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class PlayerImpl
+  implements Player, State
+{
+  /**
+   * The playing table.
+   */
+  PlayingDesk desk;
+
+  /**
+   * The state of this player (one of the constants, defined in the player
+   * interface.
+   */
+  private int state = DISCONNECTED;
+
+  /**
+   * The other player.
+   */
+  Player partner;
+
+  /**
+   * Called when the local player refuses to continue the game.
+   */
+  public void leave()
+  {
+    try
+      {
+        if (state == I_THINK || state == I_WAIT_FOR_YOUR_MOVE)
+          {
+            partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+              "Your partner has left the game.");
+            partner.disconnect();
+          }
+        else if (state == State.QUEUED)
+          {
+            if (desk.manager != null)
+              desk.manager.unregister(desk.player);
+            receive_chat(ChatConstants.SYSTEM,
+              "Do not be so pessimistic, try to play first!");
+          }
+        set_current_state(State.DISCONNECTED);
+
+        desk.frame.bChat.setEnabled(false);
+        desk.frame.bLeave.setEnabled(false);
+        desk.frame.bConnect.setEnabled(true);
+        desk.frame.taUrl.setText(desk.frame.mior);
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application that
+        // may be modified for learning purposes.
+        ex.printStackTrace();
+      }
+  }
+
+  /**
+   * Called when we make the move. The PlayingTable is responsible for checking
+   * the correctness of the move and detecting the victory.
+   * 
+   * @param x x position of the new dot.
+   * @param y y position of the new dot.
+   * 
+   * @param victory array of two memebers, representing the endpoints of the
+   * drawn line (victory detected) or null if no such yet exists.
+   */
+  public void we_move(int x, int y, Point[] victory)
+  {
+    try
+      {
+        set_current_state(I_WAIT_FOR_YOUR_MOVE);
+        partner.receive_move(x, y, victory);
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application that
+        // may be modified for learning purposes.
+        ex.printStackTrace();
+
+        state = ERROR;
+      }
+  }
+
+  /**
+   * Set the current state.
+   */
+  public void set_current_state(int new_state)
+  {
+    state = new_state;
+
+    if (state == DISCONNECTED)
+      {
+        setStatus("Disconnected");
+      }
+    else if (state == I_THINK)
+      {
+        setStatus("Our move");
+      }
+    else if (state == I_WAIT_FOR_YOUR_MOVE)
+      {
+        setStatus("Partner's move");
+      }
+    else if (state == ERROR)
+      {
+        setStatus("Error.");
+      }
+    else if (state == I_HAVE_LOST)
+      {
+        setStatus("We lost");
+      }
+    else if (state == I_HAVE_WON)
+      {
+        setStatus("Victory");
+      }
+    else if (state == QUEUED)
+      {
+        setStatus("Queued");
+      }
+    else
+      {
+        setStatus("State " + state);
+      }
+
+    boolean connected = state != State.DISCONNECTED;
+
+    desk.frame.bConnect.setEnabled(!connected && state != State.QUEUED);
+    desk.frame.bReset.setEnabled(connected);
+    desk.frame.bLeave.setEnabled(connected);
+    desk.frame.bChat.setEnabled(connected);
+  }
+
+  /**
+   * Show the state in the status line.
+   */
+  public void setStatus(String status)
+  {
+    desk.frame.lbState.setText(status);
+  }
+
+  /**
+   * Receive the invitation to play from the patner or the game manager.
+   * 
+   * @param address the address (host and port) of the remote partner.
+   * @param youStart if true, the game manager instructs to start the game first
+   * (another side is instructed to start the game second).
+   * 
+   * Game server may also chat a little bit with both players, saying that the
+   * game has started.
+   * 
+   * @return true on success.
+   */
+  public boolean start_game(Player otherPlayer, boolean youStart)
+    throws RemoteException
+  {
+    partner = otherPlayer;
+    desk.reset();
+
+    if (youStart)
+      {
+        set_current_state(I_THINK);
+      }
+    else
+      {
+        set_current_state(I_WAIT_FOR_YOUR_MOVE);
+      }
+
+    desk.frame.taUrl.setText("");
+
+    return true;
+  }
+
+  /**
+   * Get the state of the local player (one of the constants, defined in this
+   * interface).
+   */
+  public int get_current_state()
+    throws RemoteException
+  {
+    return state;
+  }
+
+  /**
+   * Receive the chat message from the friend or challenge server (remote).
+   * Possible at any state, always remote.
+   * 
+   * @param color the color code, used to highlight the message.
+   * @param text the message text.
+   */
+  public void receive_chat(byte color, String text)
+    throws RemoteException
+  {
+    if (color >= ChatConstants.colors.length)
+      color = ChatConstants.REMOTE_PLAYER;
+
+    desk.frame.talk(ChatConstants.colors[color], text);
+  }
+
+  /**
+   * Indicated that the remote side leaves the game (capitulating).
+   */
+  public void disconnect()
+    throws RemoteException
+  {
+    desk.frame.talk(Color.red, "The partner leaves the game.");
+    partner = null;
+    set_current_state(DISCONNECTED);
+
+    desk.frame.taUrl.setText(desk.frame.mior);
+  }
+
+  /**
+   * Receive friends move (possible at I_WAIT_FOR_YOUR_MOVE).
+   * 
+   * @param x grid position.
+   * @param y grid position.
+   * @param victory if not a null, the friend thinks that it has won, the
+   * parameter containing the ends of the builded line.
+   */
+  public void receive_move(int x, int y, Point[] victory)
+    throws RemoteException
+  {
+    // The state changes are handled by the PlayingTable
+    desk.friendsMove(x, y, victory);
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java
new file mode 100644 (file)
index 0000000..83178f9
--- /dev/null
@@ -0,0 +1,512 @@
+/* PlayingDesk.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.JComponent;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * Manages actions, related to the game rules and also does all painting.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PlayingDesk
+  extends JComponent
+  implements MouseListener, State
+{
+  /**
+   * Use serialVersionUID for interoperability.
+   */
+  private static final long serialVersionUID = 1;
+
+  /**
+   * Indicates that the field point state is the red oval.
+   */
+  public static final int RED = 0;
+
+  /**
+   * Indicates that the field point state is the black cross.
+   */
+  public static final int BLACK = 1;
+
+  /**
+   * Indicates that the field point state is the hint, suggested by the fan.
+   */
+  public static final int HINT = 2;
+
+  /**
+   * The access to the main frame methods.
+   */
+  ClientFrame frame;
+
+  /**
+   * The access to the player communicator.
+   */
+  PlayerImpl player;
+
+  /**
+   * The game manager.
+   */
+  GameManager manager;
+
+  /**
+   * The player ORB.
+   */
+  ORB orb;
+
+  /**
+   * The player IOR.
+   */
+  String ior;
+
+  /**
+   * True if the player ORB started ok.
+   */
+  boolean ok;
+
+  /**
+   * The grid spacing.
+   */
+  static int W = 16;
+
+  /**
+   * The radius of the dots being painted.
+   */
+  static int R = W / 3;
+
+  /**
+   * The collection of the red dots.
+   */
+  ArrayList reds = new ArrayList();
+
+  /**
+   * The collection of the black dots.
+   */
+  ArrayList blacks = new ArrayList();
+
+  /**
+   * The array of hints.
+   */
+  ArrayList hints = new ArrayList();
+
+  /**
+   * When the game is completed, obtains the value of the two end points of the
+   * created line.
+   */
+  Point[] endOfGame;
+
+  public PlayingDesk()
+  {
+    try
+      {
+        player = new PlayerImpl();
+        player.desk = this;
+
+        OrbStarter.startPlayer(player, this);
+
+        jbInit();
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+  }
+
+  /**
+   * Paint this component.
+   */
+  public void paintComponent(Graphics g)
+  {
+    int w = getWidth();
+    int h = getHeight();
+
+    g.setColor(Color.white);
+    g.fillRect(0, 0, w, h);
+
+    drawGrid(w, h, g);
+    drawFigures(g);
+  }
+
+  /**
+   * Check maybe a game is finished after setting the point N
+   */
+  public Point[] checkFinished(Collection x, Point N)
+  {
+    Iterator iter = x.iterator();
+    Point p;
+
+    // The victory, if happens, must occur inside these boundaries:
+    int ax = N.x - 5;
+    int bx = N.x + 5;
+
+    int ay = N.y - 5;
+    int by = N.y + 5;
+
+    while (iter.hasNext())
+      {
+        p = (Point) iter.next();
+
+        if (p.x > ax && p.x < bx && p.y > ay && p.y < by)
+          {
+            // Check the vertical line down
+            if (pointPresent(p.x, p.y + 1, x))
+              if (pointPresent(p.x, p.y + 2, x))
+                if (pointPresent(p.x, p.y + 3, x))
+                  if (pointPresent(p.x, p.y + 4, x))
+                    return new Point[] { p, new Point(p.x, p.y + 4) };
+
+            // Check the horizontal line left
+            if (pointPresent(p.x + 1, p.y, x))
+              if (pointPresent(p.x + 2, p.y, x))
+                if (pointPresent(p.x + 3, p.y, x))
+                  if (pointPresent(p.x + 4, p.y, x))
+                    return new Point[] { p, new Point(p.x + 4, p.y) };
+
+            // Check the diagonal line right down.
+            if (pointPresent(p.x + 1, p.y + 1, x))
+              if (pointPresent(p.x + 2, p.y + 2, x))
+                if (pointPresent(p.x + 3, p.y + 3, x))
+                  if (pointPresent(p.x + 4, p.y + 4, x))
+                    return new Point[] { p, new Point(p.x + 4, p.y + 4) };
+
+            // Check the diagonal line left down.
+            if (pointPresent(p.x - 1, p.y + 1, x))
+              if (pointPresent(p.x - 2, p.y + 2, x))
+                if (pointPresent(p.x - 3, p.y + 3, x))
+                  if (pointPresent(p.x - 4, p.y + 4, x))
+                    return new Point[] { p, new Point(p.x - 4, p.y + 4) };
+          }
+      }
+    return null;
+  }
+
+  /**
+   * Called when the "end of the game" situation is detected.
+   */
+  public void drawFinishLine(int xa, int ya, int xb, int yb, Graphics g)
+  {
+    g.setColor(Color.blue);
+
+    int hW = W / 2;
+    g.drawLine(xa * W + hW, ya * W + hW, xb * W + hW, yb * W + hW);
+  }
+
+  /**
+   * Check for the presence of the given point in the collection.
+   */
+  public final boolean pointPresent(int x, int y, Collection in)
+  {
+    Iterator iter = in.iterator();
+    Point p;
+    while (iter.hasNext())
+      {
+        p = (Point) iter.next();
+        if (p.x == x && p.y == y)
+          return true;
+      }
+    return false;
+  }
+
+  public void drawGrid(int w, int h, Graphics g)
+  {
+    g.setColor(Color.lightGray);
+
+    // Draw vertical lines:
+    for (int x = 0; x < w; x += W)
+      {
+        g.drawLine(x, 0, x, h);
+      }
+
+    // Draw horizontal lines:
+    for (int y = 0; y < h; y += W)
+      {
+        g.drawLine(0, y, w, y);
+      }
+      
+    g.setColor(Color.gray);
+    g.drawRect(0,0, frame.DESK_SIZE.width, frame.DESK_SIZE.height);
+    g.drawRect(0,0, frame.DESK_SIZE.width+3, frame.DESK_SIZE.height+3);    
+  }
+
+  public void drawFigures(Graphics g)
+  {
+    g.setColor(Color.red);
+    drawDots(reds, g, RED);
+
+    g.setColor(Color.black);
+    drawDots(blacks, g, BLACK);
+
+    g.setColor(Color.lightGray);
+    drawDots(hints, g, HINT);
+
+    if (endOfGame != null)
+      drawFinishLine(endOfGame[0].x, endOfGame[0].y, endOfGame[1].x,
+        endOfGame[1].y, g);
+  }
+
+  public Point makePoint(int x, int y)
+  {
+    return new Point(x / W, y / W);
+  }
+
+  /**
+   * Draw a collection of dots (the collor must be set before calling the
+   * method).
+   */
+  public void drawDots(Collection dots, Graphics g, int mode)
+  {
+    Iterator iter = dots.iterator();
+    int x;
+    int y;
+
+    int hW = W / 2;
+    int RR = R * 2;
+    int hR = R / 2;
+    Point p;
+    while (iter.hasNext())
+      {
+        p = (Point) iter.next();
+        x = p.x * W + hW;
+        y = p.y * W + hW;
+
+        if (mode == RED)
+          g.drawOval(x - R, y - R, RR, RR);
+        else if (mode == BLACK)
+          {
+            g.drawLine(x - R, y - R, x + R, y + R);
+            g.drawLine(x - R, y + R, x + R, y - R);
+          }
+        else
+          {
+            // Hint.
+            g.drawOval(x - hR, y - hR, R, R);
+          }
+      }
+  }
+
+  private void jbInit()
+    throws Exception
+  {
+    addMouseListener(this);
+  }
+
+  public void mouseClicked(MouseEvent e)
+  {
+    try
+      {
+        int state = player.get_current_state();
+
+        // Check if the state is correct.
+        if (state == I_WAIT_FOR_YOUR_MOVE)
+          {
+            frame.talk(Color.black,
+              "It is now time for our partner's move, not ours. Please wait.");
+          }
+        else if (state == DISCONNECTED)
+          {
+            frame.talk(Color.black,
+              "We are not connected to the playing partner yet.");
+          }
+        else if (state == I_HAVE_LOST)
+          {
+            frame.talk(Color.black,
+              "We have already lost this battle, but why not to try again?");
+          }
+        else if (state == I_HAVE_WON)
+          {
+            frame.talk(Color.black,
+              "The victory is ours, nothing more to do here.");
+          }
+        else if (player.partner == null)
+          frame.talk(Color.black, "No other player so far.");
+        else
+          {
+            int x = e.getX();
+            int y = e.getY();
+
+            if (x>frame.DESK_SIZE.width ||
+                y>frame.DESK_SIZE.height)
+            {
+              frame.talk(Color.black,"Outside the game area.");
+              return;
+            }
+
+            Point p = makePoint(x, y);
+
+            // Ignore clicks on the occupied cells.
+            if (pointPresent(p.x, p.y, reds)
+              || (pointPresent(p.x, p.y, blacks)))
+              {
+                frame.talk(Color.black,
+                  "This is against the rules, select the unoccupied cell.");
+                return;
+              }
+
+            reds.add(p);
+
+            endOfGame = checkFinished(reds, p);
+            repaint();
+
+            if (endOfGame != null)
+              {
+                frame.talk(Color.red, "Our move " + p.x + "-" + p.y
+                  + " and we win!");
+                player.set_current_state(I_HAVE_WON);
+              }
+            else
+              {
+                frame.talk(Color.black, "Our move " + p.x + "-" + p.y
+                  + ". Waiting for the other side move...");
+                player.set_current_state(I_WAIT_FOR_YOUR_MOVE);
+              }
+
+            player.partner.receive_move(p.x, p.y, endOfGame);
+          }
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application
+        // that may be modified for learning purposes.
+        ex.printStackTrace();
+      }
+  }
+
+  /**
+   * Handle the move of the other playing side.
+   */
+  public void friendsMove(int x, int y, Point[] victory)
+  {
+    try
+      {
+        int state = player.get_current_state();
+        if (state != I_WAIT_FOR_YOUR_MOVE || pointPresent(x, y, blacks))
+          {
+            stateFailed("Move " + x + "-" + y);
+          }
+        else
+          {
+            blacks.add(new Point(x, y));
+            repaint();
+
+            if (victory != null)
+              {
+                frame.talk(Color.red,
+                  " We have lost this time, unfortunately..");
+                player.set_current_state(I_HAVE_LOST);
+                endOfGame = victory;
+              }
+            else
+              {
+                frame.talk(Color.black, "Partner goes " + x + "-" + y
+                  + ". Your move?");
+                player.set_current_state(I_THINK);
+              }
+          }
+      }
+    catch (RemoteException rex)
+      {
+        rex.printStackTrace();
+      }
+  }
+
+  /**
+   * Prepare for the new game.
+   */
+  public void reset()
+  {
+    blacks.clear();
+    reds.clear();
+    hints.clear();
+    endOfGame = null;
+    repaint();
+  }
+
+  public void mouseEntered(MouseEvent m)
+  {
+    // Nothing to do.
+  }
+
+  public void mousePressed(MouseEvent m)
+  {
+    // Nothing to do.
+  }
+
+  public void mouseReleased(MouseEvent m)
+  {
+    // Nothing to do.
+  }
+
+  public void mouseExited(MouseEvent m)
+  {
+    // Nothing to do.
+  }
+
+  /**
+   * The systems detected the error conditions. The game cannot continue (the
+   * chat is still possible).
+   */
+  public void stateFailed(String reason)
+  {
+    try
+      {
+        player.receive_chat(ChatConstants.REMOTE_PLAYER,
+          "Wrong move, game cannot continue (our state was "
+            + player.get_current_state() + ")");
+        frame.talk(Color.red, "The remote side violates communicating rules.");
+        player.set_current_state(State.ERROR);
+      }
+    catch (RemoteException ex)
+      {
+        // We will print the exception because this is a demo application
+        // that may be modified for learning purposes.
+        ex.printStackTrace();
+      }
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java
new file mode 100644 (file)
index 0000000..7285396
--- /dev/null
@@ -0,0 +1,82 @@
+/* State.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+/**
+ * Defines the states in that the player can be.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public interface State {
+  /**
+   * The initial ("disconnected") state.
+   */
+  int DISCONNECTED = 0;
+  
+  /**
+   * The state, indicating that the player has been queued for the game and
+   * waiting for the partner to come.
+   */
+  int QUEUED = 1;
+
+  /**
+   * The "my move" state.
+   */
+  int I_THINK = 2;
+
+  /**
+   * The "friend's move" state.
+   */
+  int I_WAIT_FOR_YOUR_MOVE = 3;
+
+  /**
+   * States that we have won.
+   */
+  int I_HAVE_WON = 4;
+
+  /**
+   * States that we have lost.
+   */
+  int I_HAVE_LOST = 5;
+  
+  /**
+   * The "inconsistent" state when it is not possible to continue the game.
+   */
+  int ERROR = -1;
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java
new file mode 100644 (file)
index 0000000..2ef9241
--- /dev/null
@@ -0,0 +1,175 @@
+/* GameManagerAddressServer.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * The main executable class of the game manager server.
+ * 
+ * The manager address server returns the IOR address string of the game
+ * manager. Hence the user does not need to enter the rather long IOR address
+ * string and only needs to specify the host and port of the machine where the
+ * game manager is running.
+ * 
+ * The manager address server starts the main game manager as well.
+ * 
+ * This server acts as a HTTP server that always returns the same response. This
+ * primitive functionality is sufficient for its task.
+ * 
+ * The more complex CORBA applications should use the name service instead. We
+ * do not use the name service as this would require to start additional
+ * external application, specific for the different java platforms.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class X5Server
+{
+  /**
+   * Start the game manager.
+   */
+  public static void main(String[] args)
+  {
+    // Start the game manager, write the IOR to the agreed location.
+    OrbStarter.startManager(args);
+
+    if (!GameManagerImpl.ok)
+      {
+        System.out.println("Unable to start the game manager:");
+        System.exit(1);
+      }
+
+    // Print the IOR.
+    System.out.println(GameManagerImpl.ior);
+
+    String manager_address = null;
+
+    // Start the game manager server.
+    ServerSocket nameServer = null;
+    try
+      {
+        nameServer = new ServerSocket(OrbStarter.MANAGER_NAMER_PORT);
+
+        System.out.println("The game manager is listening at:");
+        manager_address = "http://"
+          + InetAddress.getLocalHost().getHostAddress() + ":"
+          + nameServer.getLocalPort();
+
+        System.out.println(manager_address);
+
+        System.out.println("Enter this address to the "
+          + "input field of the game client.");
+
+        System.out.println("Use ^C to stop the manager.");
+      }
+    catch (Exception ex)
+      {
+        System.out.println("The port " + OrbStarter.MANAGER_NAMER_PORT
+          + " is not available. The game manager namer will not start.");
+        System.exit(1);
+      }
+
+    // Write the IOR to the local file system.
+    if (OrbStarter.WRITE_URL_TO_FILE != null)
+      {
+        try
+          {
+            File gmf = new File(OrbStarter.WRITE_URL_TO_FILE);
+            FileWriter f = new FileWriter(gmf);
+            BufferedWriter b = new BufferedWriter(f);
+
+            b.write(manager_address);
+            b.close();
+          }
+        catch (IOException e)
+          {
+            System.out.println("Local filesystem not accessible."
+              + "Read IOR from console.");
+          }
+      }
+
+    // Do forever.
+    while (true)
+      {
+        try
+          {
+            Socket socket = nameServer.accept();
+
+            System.out.println("Connected.");
+
+            // Set the two minutes timeout.
+            socket.setSoTimeout(1000 * 120);
+
+            OutputStream out = socket.getOutputStream();
+
+            int length = GameManagerImpl.ior.length();
+
+            StringBuffer b = new StringBuffer();
+            b.append("HTTP/1.0 200 OK\r\n");
+            b.append("Content-Length: " + length + "\r\n");
+            b.append("Connection: close\r\n");
+            b.append("Content-Type: text/plain; charset=UTF-8\r\n");
+            b.append("\r\n");
+
+            b.append(GameManagerImpl.ior);
+
+            out.write(b.toString().getBytes("UTF-8"));
+
+            socket.shutdownOutput();
+
+            if (!socket.isClosed())
+              socket.close();
+
+            System.out.println("Completed.");
+          }
+        catch (Exception exc)
+          {
+            exc.printStackTrace();
+            System.out.println("Network problem.");
+          }
+      }
+  }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java
new file mode 100644 (file)
index 0000000..17a6260
--- /dev/null
@@ -0,0 +1,214 @@
+/* _GameManagerImpl_Tie.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.rmi.Remote;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Normally generated with rmic compiler, this class represents the GameManager
+ * Tie on the client side. The Game Manager methods contain the code for remote
+ * invocation.
+ * 
+ * This class is normally generated with rmic from the {@link GameManagerImpl}:
+ * 
+ * <pre>
+ *   rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
+ * </pre>
+ * 
+ * (the compiled package must be present in the current folder).
+ * 
+ * In this example the class was manually edited and commented for better
+ * understanding of functionality.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class _GameManagerImpl_Tie
+  extends Servant
+  implements Tie
+{
+  /**
+   * The target, where remote invocations are forwarded.
+   */
+  private GameManagerImpl target = null;
+
+  /**
+   * The GameManager repository Id.
+   */
+  private static final String[] _type_ids = 
+  { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" };
+
+  /**
+   * Set the target where the remote invocations are forwarded.
+   */
+  public void setTarget(Remote a_target)
+  {
+    this.target = (GameManagerImpl) a_target;
+  }
+
+  /**
+   * Get the target where the remote invocations are forwarded.
+   */
+  public Remote getTarget()
+  {
+    return target;
+  }
+
+  /**
+   * Get the CORBA object for that this Tie is currently serving the request.
+   * The same tie may serve multiple requests for the different objects in
+   * parallel threads.
+   */
+  public org.omg.CORBA.Object thisObject()
+  {
+    return _this_object();
+  }
+
+  /**
+   * Deactivate this object.
+   */
+  public void deactivate()
+  {
+    try
+      {
+        _poa().deactivate_object(_poa().servant_to_id(this));
+      }
+    catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
+      {
+      }
+    catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
+      {
+      }
+    catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
+      {
+      }
+  }
+
+  /**
+   * Get the ORB for this tie.
+   */
+  public ORB orb()
+  {
+    return _orb();
+  }
+
+  /**
+   * Set the ORB for this tie.
+   */
+  public void orb(ORB orb)
+  {
+    try
+      {
+        ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+      }
+    catch (ClassCastException e)
+      {
+        throw new org.omg.CORBA.BAD_PARAM(
+          "POA Servant requires an instance of org.omg.CORBA_2_3.ORB");
+      }
+  }
+
+  /**
+   * Return all interfaces, supported by this method.
+   */
+  public String[] _all_interfaces(org.omg.PortableServer.POA poa,
+    byte[] objectId)
+  {
+    return _type_ids;
+  }
+
+  /**
+   * This method is invoked by CORBA system to handle the remote invocation.
+   * 
+   * @param method the name of the method being invoked.
+   * @param _in the stream to read the method parameters.
+   * @param reply the responsed handler that can create the output stream to
+   * write the parameters being returned.
+   */
+  public OutputStream _invoke(String method, InputStream _in,
+    ResponseHandler reply)
+    throws SystemException
+  {
+    try
+      {
+        org.omg.CORBA_2_3.portable.InputStream in = 
+          (org.omg.CORBA_2_3.portable.InputStream) _in;
+        if (method.equals("requestTheGame"))
+          {
+            Player p = (Player) PortableRemoteObject.narrow(
+              in.read_Object(), Player.class);
+            target.requestTheGame(p);
+
+            OutputStream out = reply.createReply();
+            return out;
+          }
+        else if (method.equals("unregister"))
+          {
+            Player p = (Player) PortableRemoteObject.narrow(
+              in.read_Object(), Player.class);
+            target.unregister(p);
+
+            OutputStream out = reply.createReply();
+            return out;
+          }
+        else
+          throw new BAD_OPERATION();
+      }
+    catch (SystemException ex)
+      {
+        throw ex;
+      }
+    catch (Throwable ex)
+      {
+        ex.printStackTrace();
+        throw new UnknownException(ex);
+      }
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java
new file mode 100644 (file)
index 0000000..e927996
--- /dev/null
@@ -0,0 +1,207 @@
+/* _GameManager_Stub.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+/**
+ * Normally generated with rmic compiler, this class represents the GameManager
+ * Stub on the client side. The Game Manager methods contain the code for
+ * remote invocation.
+ * 
+ * This class is normally generated with rmic from the {@link GameManagerImpl}:
+ * <pre>
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
+ * </pre>
+ * (the compiled package must be present in the current folder).
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class _GameManager_Stub extends Stub implements GameManager
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  private static final String[] _type_ids =
+    { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" };
+
+  public String[] _ids()
+  {
+    return _type_ids;
+  }
+  
+  /**
+   * Notify the manager that the player is no longer willing to play and
+   * should be removed from the queue.
+   */
+  public void unregister(Player p)
+    throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA.portable.InputStream in = null;
+            try
+              {
+                OutputStream out = _request("unregister", true);
+                Util.writeRemoteObject(out, p);
+                _invoke(out);
+              }
+            catch (ApplicationException ex)
+              {
+                in = ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                unregister(p);
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so =
+          _servant_preinvoke("requestTheGame", GameManager.class);
+        if (so == null)
+          {
+            unregister(p);
+            return;
+          }
+        try
+          {
+            ((GameManager) so.servant).unregister(p);
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+  
+  /**
+   * The method that the user should invoke.
+   */
+  public void requestTheGame(Player arg0) throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA.portable.InputStream in = null;
+            try
+              {
+                OutputStream out = _request("requestTheGame", true);
+                Util.writeRemoteObject(out, arg0);
+                _invoke(out);
+              }
+            catch (ApplicationException ex)
+              {
+                in = ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                requestTheGame(arg0);
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so =
+          _servant_preinvoke("requestTheGame", GameManager.class);
+        if (so == null)
+          {
+            requestTheGame(arg0);
+            return;
+          }
+        try
+          {
+            Player arg0Copy = (Player) Util.copyObject(arg0, _orb());
+            ((GameManager) so.servant).requestTheGame(arg0Copy);
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java
new file mode 100644 (file)
index 0000000..730c6f4
--- /dev/null
@@ -0,0 +1,212 @@
+/* _PlayerImpl_Tie.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Point;
+import java.rmi.Remote;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Generate with rmic, command line
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
+ * (the compiled package must be present in the current folder).
+ * 
+ * This class is normally generated with rmic from the {@link PlayerImpl}:
+ * <pre>
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
+ * </pre>
+ * (the compiled package must be present in the current folder).
+ * 
+ * In this example the class was manually edited and commented for better 
+ * understanding of functionality.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class _PlayerImpl_Tie extends Servant implements Tie
+{
+  private PlayerImpl target = null;
+  private static final String[] _type_ids =
+    { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" };
+
+  public void setTarget(Remote a_target)
+  {
+    this.target = (PlayerImpl) a_target;
+  }
+
+  public Remote getTarget()
+  {
+    return target;
+  }
+
+  public org.omg.CORBA.Object thisObject()
+  {
+    return _this_object();
+  }
+
+  public void deactivate()
+  {
+    try
+      {
+        _poa().deactivate_object(_poa().servant_to_id(this));
+      }
+    catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
+      {
+      }
+    catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
+      {
+      }
+    catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
+      {
+      }
+  }
+
+  public ORB orb()
+  {
+    return _orb();
+  }
+
+  public void orb(ORB orb)
+  {
+    try
+      {
+        ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+      }
+    catch (ClassCastException e)
+      {
+        throw new org.omg.CORBA.BAD_PARAM(
+          "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
+        );
+      }
+  }
+
+  public String[] _all_interfaces(org.omg.PortableServer.POA poa,
+    byte[] objectId
+  )
+  {
+    return _type_ids;
+  }
+
+  public OutputStream _invoke(String method, InputStream _in,
+    ResponseHandler reply
+  ) throws SystemException
+  {
+    try
+      {
+        org.omg.CORBA_2_3.portable.InputStream in =
+          (org.omg.CORBA_2_3.portable.InputStream) _in;
+        switch (method.charAt(9))
+          {
+            case 101 :
+              if (method.equals("start_game"))
+                {
+                  Player arg0 =
+                    (Player) PortableRemoteObject.narrow(in.read_Object(),
+                      Player.class
+                    );
+                  boolean arg1 = in.read_boolean();
+                  boolean result = target.start_game(arg0, arg1);
+                  OutputStream out = reply.createReply();
+                  out.write_boolean(result);
+                  return out;
+                }
+
+            case 104 :
+              if (method.equals("receive_chat"))
+                {
+                  byte arg0 = in.read_octet();
+                  String arg1 = (String) in.read_value(String.class);
+                  target.receive_chat(arg0, arg1);
+
+                  OutputStream out = reply.createReply();
+                  return out;
+                }
+
+            case 111 :
+              if (method.equals("receive_move"))
+                {
+                  int arg0 = in.read_long();
+                  int arg1 = in.read_long();
+                  Point[] arg2 = (Point[]) in.read_value(Point[].class);
+                  target.receive_move(arg0, arg1, arg2);
+
+                  OutputStream out = reply.createReply();
+                  return out;
+                }
+
+            case 114 :
+              if (method.equals("_get_J_current_state"))
+                {
+                  int result = target.get_current_state();
+                  OutputStream out = reply.createReply();
+                  out.write_long(result);
+                  return out;
+                }
+
+            case 116 :
+              if (method.equals("disconnect"))
+                {
+                  target.disconnect();
+
+                  OutputStream out = reply.createReply();
+                  return out;
+                }
+          }
+        throw new BAD_OPERATION("No such method: '"+method+"'");
+      }
+    catch (SystemException ex)
+      {
+        throw ex;
+      }
+    catch (Throwable ex)
+      {
+        throw new UnknownException(ex);
+      }
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java
new file mode 100644 (file)
index 0000000..eeb5cf0
--- /dev/null
@@ -0,0 +1,397 @@
+/* _Player_Stub.java --
+ Copyright (C) 2005 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.examples.CORBA.swing.x5;
+
+import java.awt.Point;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+/**
+ * Generate with rmic, command line
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
+ * (the compiled package must be present in the current folder).
+ * 
+ * This class is normally generated with rmic from the {@link GameManagerImpl}:
+ * <pre>
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
+ * </pre>
+ * (the compiled package must be present in the current folder).
+ * 
+ * In this example the class was manually edited and commented for better 
+ * understanding of functionality.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class _Player_Stub extends Stub implements Player
+{
+  /** 
+   * Use serialVersionUID for interoperability. 
+   */
+  private static final long serialVersionUID = 1;
+  
+  private static final String[] _type_ids =
+    { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" };
+
+  public String[] _ids()
+  {
+    return _type_ids;
+  }
+  
+  public boolean start_game(Player arg0, boolean arg1)
+    throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA.portable.InputStream in = null;
+            try
+              {
+                OutputStream out = _request("start_game", true);
+                Util.writeRemoteObject(out, arg0);
+                out.write_boolean(arg1);
+                in = _invoke(out);
+                return in.read_boolean();
+              }
+            catch (ApplicationException ex)
+              {
+                in = ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                return start_game(arg0, arg1);
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so = _servant_preinvoke("start_game", Player.class);
+        if (so == null)
+          {
+            return start_game(arg0, arg1);
+          }
+        try
+          {
+            Player arg0Copy = (Player) Util.copyObject(arg0, _orb());
+            return ((Player) so.servant).start_game(arg0Copy, arg1);
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+
+  public int get_current_state() throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA.portable.InputStream in = null;
+            try
+              {
+                OutputStream out = _request("_get_J_current_state", true);
+                in = _invoke(out);
+                return in.read_long();
+              }
+            catch (ApplicationException ex)
+              {
+                in = ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                return get_current_state();
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so =
+          _servant_preinvoke("_get_J_current_state", Player.class);
+        if (so == null)
+          {
+            return get_current_state();
+          }
+        try
+          {
+            return ((Player) so.servant).get_current_state();
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+
+  public void receive_chat(byte arg0, String arg1) throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA_2_3.portable.InputStream in = null;
+            try
+              {
+                org.omg.CORBA_2_3.portable.OutputStream out =
+                  (org.omg.CORBA_2_3.portable.OutputStream) _request("receive_chat",
+                    true
+                  );
+                out.write_octet(arg0);
+                out.write_value(arg1, String.class);
+                _invoke(out);
+              }
+            catch (ApplicationException ex)
+              {
+                in =
+                  (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                receive_chat(arg0, arg1);
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so = _servant_preinvoke("receive_chat", Player.class);
+        if (so == null)
+          {
+            receive_chat(arg0, arg1);
+            return;
+          }
+        try
+          {
+            ((Player) so.servant).receive_chat(arg0, arg1);
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+
+  public void disconnect() throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA.portable.InputStream in = null;
+            try
+              {
+                OutputStream out = _request("disconnect", true);
+                _invoke(out);
+              }
+            catch (ApplicationException ex)
+              {
+                in = ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                disconnect();
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so = _servant_preinvoke("disconnect", Player.class);
+        if (so == null)
+          {
+            disconnect();
+            return;
+          }
+        try
+          {
+            ((Player) so.servant).disconnect();
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+
+  public void receive_move(int arg0, int arg1, Point[] arg2)
+    throws RemoteException
+  {
+    if (!Util.isLocal(this))
+      {
+        try
+          {
+            org.omg.CORBA_2_3.portable.InputStream in = null;
+            try
+              {
+                org.omg.CORBA_2_3.portable.OutputStream out =
+                  (org.omg.CORBA_2_3.portable.OutputStream) _request("receive_move",
+                    true
+                  );
+                out.write_long(arg0);
+                out.write_long(arg1);
+                out.write_value(cast_array(arg2), Point[].class);
+                _invoke(out);
+              }
+            catch (ApplicationException ex)
+              {
+                in =
+                  (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream();
+
+                String id = in.read_string();
+                throw new UnexpectedException(id);
+              }
+            catch (RemarshalException ex)
+              {
+                receive_move(arg0, arg1, arg2);
+              }
+            finally
+              {
+                _releaseReply(in);
+              }
+          }
+        catch (SystemException ex)
+          {
+            throw Util.mapSystemException(ex);
+          }
+      }
+    else
+      {
+        ServantObject so = _servant_preinvoke("receive_move", Player.class);
+        if (so == null)
+          {
+            receive_move(arg0, arg1, arg2);
+            return;
+          }
+        try
+          {
+            Point[] arg2Copy = (Point[]) Util.copyObject(arg2, _orb());
+            ((Player) so.servant).receive_move(arg0, arg1, arg2Copy);
+          }
+        catch (Throwable ex)
+          {
+            Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+            throw Util.wrapException(exCopy);
+          }
+        finally
+          {
+            _servant_postinvoke(so);
+          }
+      }
+  }
+
+  // This method is required as a work-around for
+  // a bug in the JDK 1.1.6 verifier.
+  private Serializable cast_array(Object obj)
+  {
+    return (Serializable) obj;
+  }
+}
\ No newline at end of file
index f147e81..7b9c34a 100644 (file)
@@ -1612,6 +1612,18 @@ public class OrbFunctional extends OrbRestricted
         // TODO log it.
         return;
       }
+    finally
+      {
+        try 
+          {
+            if (service!=null && !service.isClosed())
+              service.close();
+          }
+        catch (IOException ioex)
+          {
+            // OK.
+          }
+      }
   }
   
   /**
index f5ba3ad..3e3125a 100644 (file)
@@ -44,10 +44,6 @@ import java.awt.Rectangle;
 import java.awt.event.PaintEvent;
 import java.awt.peer.DialogPeer;
 
-import javax.swing.JDialog;
-import javax.swing.JPopupMenu;
-import javax.swing.JToolTip;
-
 public class GtkDialogPeer extends GtkWindowPeer
   implements DialogPeer
 {
@@ -87,27 +83,9 @@ public class GtkDialogPeer extends GtkWindowPeer
   void create ()
   {
     Dialog dialog = (Dialog) awtComponent;
-    int type = GDK_WINDOW_TYPE_HINT_DIALOG;
-
-    if (dialog instanceof JDialog)
-      {
-        Class heavyWeightClass;
-        try
-          {
-            heavyWeightClass = Class.forName("javax.swing.Popup$JWindowPopup");
-          }
-        catch (ClassNotFoundException e)
-          {
-            throw new AssertionError(e);
-          }
-        
-        if (dialog.getClass() == heavyWeightClass 
-            || ((JDialog) dialog).getContentPane() instanceof JToolTip)
-          type = GDK_WINDOW_TYPE_HINT_MENU;
-      }
     
     // Create a decorated dialog window.
-    create (type, !((Dialog) awtComponent).isUndecorated ());
+    create (GDK_WINDOW_TYPE_HINT_DIALOG, !((Dialog) awtComponent).isUndecorated ());
 
     gtkWindowSetModal (dialog.isModal ());
     setTitle (dialog.getTitle ());
index c84d510..57fb87f 100644 (file)
@@ -41,7 +41,6 @@ package gnu.java.awt.peer.gtk;
 import java.awt.Component;
 import java.awt.Frame;
 import java.awt.Window;
-import java.awt.event.ComponentEvent;
 import java.awt.event.WindowEvent;
 import java.awt.peer.WindowPeer;
 
@@ -80,12 +79,16 @@ public class GtkWindowPeer extends GtkContainerPeer
 
   void create (int type, boolean decorated)
   {
+    Window window = (Window) awtComponent;
     GtkWindowPeer parent_peer = null;
     Component parent = awtComponent.getParent();
-
+    
+    if (!window.isFocusableWindow())
+      type = GDK_WINDOW_TYPE_HINT_MENU;
+    
     if (parent != null)
       parent_peer = (GtkWindowPeer) awtComponent.getParent().getPeer();
-
+    
     create (type, decorated, parent_peer);
   }
 
index 52bd048..8e4a413 100644 (file)
@@ -59,6 +59,7 @@ import java.security.Permission;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
+import java.net.MalformedURLException;
 
 /**
  * This subclass of java.net.URLConnection models a URLConnection via
@@ -125,6 +126,54 @@ public class Connection extends URLConnection
   }
   
   /**
+   * Unquote "%" + hex quotes characters
+   *
+   * @param str The string to unquote or null.
+   *
+   * @return The unquoted string or null if str was null.
+   *
+   * @exception MalformedURLException If the given string contains invalid
+   * escape sequences.
+   *
+   * Sadly the same as URI.unquote, but there's nothing we can do to
+   * make it accessible.
+   *
+   */
+  public static String unquote(String str) throws MalformedURLException
+  {
+    if (str == null)
+      return null;
+    byte[] buf = new byte[str.length()];
+    int pos = 0;
+    for (int i = 0; i < str.length(); i++)
+      {
+       char c = str.charAt(i);
+       if (c > 127)
+         throw new MalformedURLException(str + " : Invalid character");
+       if (c == '%')
+         {
+           if (i + 2 >= str.length())
+             throw new MalformedURLException(str + " : Invalid quoted character");
+           int hi = Character.digit(str.charAt(++i), 16);
+           int lo = Character.digit(str.charAt(++i), 16);
+           if (lo < 0 || hi < 0)
+             throw new MalformedURLException(str + " : Invalid quoted character");
+           buf[pos++] = (byte) (hi * 16 + lo);
+         }
+       else
+         buf[pos++] = (byte) c;
+      }
+    try
+      {
+       return new String(buf, 0, pos, "utf-8");
+      }
+    catch (java.io.UnsupportedEncodingException x2)
+      {
+       throw (Error) new InternalError().initCause(x2);
+      }
+  }
+
+  /**
    * "Connects" to the file by opening it.
    */
   public void connect() throws IOException
@@ -134,7 +183,7 @@ public class Connection extends URLConnection
       return;
     
     // If not connected, then file needs to be openned.
-    file = new File (getURL().getFile());
+    file = new File (unquote(getURL().getFile()));
 
     if (! file.isDirectory())
       {
index e854874..e2a052e 100644 (file)
@@ -47,7 +47,10 @@ import java.net.MalformedURLException;
 import java.net.ProtocolException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.Hashtable;
+import java.util.Locale;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.zip.ZipFile;
@@ -60,6 +63,12 @@ import java.util.zip.ZipFile;
  */
 public final class Connection extends JarURLConnection
 {
+  /**
+   * HTTP-style DateFormat, used to format the last-modified header.
+   * Lazy initialized since jar files are used during bootstrapping.
+   */
+  private static SimpleDateFormat dateFormat;
+
   private JarFile jar_file;
   private JarEntry jar_entry;
   private URL jar_url;
@@ -82,7 +91,9 @@ public final class Connection extends JarURLConnection
 
       if ("file".equals (url.getProtocol()))
        {
-         File f = new File (url.getFile());
+         String fn = url.getFile();
+         fn = gnu.java.net.protocol.file.Connection.unquote(fn);
+         File f = new File (fn);
          jf = new JarFile (f, true, ZipFile.OPEN_READ);
        }
       else
@@ -165,6 +176,38 @@ public final class Connection extends JarURLConnection
     return jar_file;
   }
 
+  public String getHeaderField(String field)
+  {
+    try
+      {
+       if (!connected)
+         connect();
+
+       if (field.equals("content-type"))
+          return guessContentTypeFromName(getJarEntry().getName());
+       else if (field.equals("content-length"))
+          return Long.toString(getJarEntry().getSize());
+       else if (field.equals("last-modified"))
+         {
+           // Both creating and manipulating dateFormat need synchronization.
+           synchronized (this.getClass())
+             {
+               if (dateFormat == null)
+                 dateFormat = new SimpleDateFormat
+                   ("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+                    new Locale ("En", "Us", "Unix"));
+
+               return dateFormat.format(new Date(getJarEntry().getTime()));
+             }
+         }
+      }
+    catch (IOException e)
+      {
+        // Fall through.
+      }
+    return null;
+  }
+
   public int getContentLength()
   {
     if (!connected)
@@ -172,4 +215,19 @@ public final class Connection extends JarURLConnection
 
     return (int) jar_entry.getSize();
   }
+
+  public long getLastModified()
+  {
+    if (!connected)
+      return -1;
+
+    try
+      {
+       return getJarEntry().getTime();
+      }
+    catch (IOException e)
+      {
+       return -1;
+      }
+  }
 }
index 9b389e2..ec03d63 100644 (file)
@@ -1409,7 +1409,6 @@ public abstract class Component
       {
         if (parent != null)
           {
-            Rectangle parentBounds = parent.getBounds();
             Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
                                                 oldheight);
             Rectangle newBounds = new Rectangle(x, y, width, height);
@@ -1887,13 +1886,7 @@ public abstract class Component
    */
   public void repaint()
   {   
-    if(!isShowing())
-      {
-        Component p = parent;
-        if (p != null)
-          p.repaint(0, getX(), getY(), width, height);
-      }
-    else
+    if (isShowing())
       repaint(0, 0, 0, width, height);
   }
 
@@ -1908,13 +1901,7 @@ public abstract class Component
    */
   public void repaint(long tm)
   {
-    if(!isShowing())
-      {
-        Component p = parent;
-        if (p != null)
-          p.repaint(tm, getX(), getY(), width, height);
-      }
-    else
+    if (isShowing())
       repaint(tm, 0, 0, width, height);
   }
 
@@ -1932,13 +1919,7 @@ public abstract class Component
    */
   public void repaint(int x, int y, int w, int h)
   {
-    if(!isShowing())
-      {
-        Component p = parent;
-        if (p != null)
-          p.repaint(0, x + getX(), y + getY(), width, height);
-      }
-    else
+    if (isShowing())
       repaint(0, x, y, w, h);
   }
 
@@ -1957,13 +1938,7 @@ public abstract class Component
    */
   public void repaint(long tm, int x, int y, int width, int height)
   {
-    if(!isShowing())
-      {
-        Component p = parent;
-        if (p != null)
-          p.repaint(tm, x + getX(), y + getY(), width, height);
-      }
-    else
+    if (isShowing())
       {
         ComponentPeer p = peer;
         if (p != null)
index 4676895..ed791dc 100644 (file)
@@ -123,6 +123,7 @@ public class Container extends Component
    */
   public Container()
   {
+    // Nothing to do here.
   }
 
   /**
@@ -427,7 +428,8 @@ public class Container extends Component
         for (int j = 0; j < list.length; j++)
               r.removeComponentListener(list[j]);
         
-        r.removeNotify();
+        if (r.isShowing())
+          r.removeNotify();
 
         System.arraycopy(component, index + 1, component, index,
                          ncomponents - index - 1);
@@ -846,7 +848,7 @@ public class Container extends Component
    */
   public void paintComponents(Graphics g)
   {
-    super.paint(g);
+    paint(g);
     visitChildren(g, GfxPaintAllVisitor.INSTANCE, true);
   }
 
@@ -1972,6 +1974,7 @@ public class Container extends Component
        */
       protected AccessibleContainerHandler()
       {
+        // Nothing to do here.
       }
 
       /**
@@ -2039,8 +2042,7 @@ class LightweightDispatcher implements Serializable
    * location, otherwise the appropriate component from the conditions
    * above.
    */
-  Component getDeepestComponentForMouseEventAt (
-                                                              Component parent, int x, int y)
+  Component getDeepestComponentForMouseEventAt(Component parent, int x, int y)
   {
     if (parent == null || (! parent.contains(x, y)))
       return null;
@@ -2064,8 +2066,7 @@ class LightweightDispatcher implements Serializable
     Point p = me.getPoint();
     while (candidate == null && parent != null)
       {
-        candidate =
-          getDeepestComponentForMouseEventAt(parent, p.x, p.y);
+        candidate = getDeepestComponentForMouseEventAt(parent, p.x, p.y);
         if (candidate == null || (candidate.eventMask & me.getID()) == 0)
           {
             candidate = null;
@@ -2147,14 +2148,12 @@ class LightweightDispatcher implements Serializable
         break;
       }
 
-    if (me.getID() == MouseEvent.MOUSE_RELEASED
-        || me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
+    if (me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
         || me.getID() == MouseEvent.MOUSE_DRAGGED)
       {
         // If any of the following events occur while a button is held down,
         // they should be dispatched to the same component to which the
         // original MOUSE_PRESSED event was dispatched:
-        //   - MOUSE_RELEASED
         //   - MOUSE_PRESSED: another button pressed while the first is held
         //     down
         //   - MOUSE_DRAGGED
@@ -2204,10 +2203,13 @@ class LightweightDispatcher implements Serializable
                 // there is a CLICKED event after this, it will do clean up.
                 if (--pressCount == 0
                     && mouseEventTarget != pressedComponent)
-                  pressedComponent = null;
+                  {
+                    pressedComponent = null;
+                    pressCount = 0;
+                  }
                 break;
               }
-            
+
             MouseEvent newEvt =
               AWTUtilities.convertMouseEvent(nativeContainer, me,
                                              mouseEventTarget);
index c27e0bf..95cd408 100644 (file)
@@ -187,7 +187,7 @@ public class MemoryImageSource implements ImageProducer
        ic = (ImageConsumer) list.elementAt(i);
        sendPicture(ic);
        if (animated)
-         ic.imageComplete(ImageConsumer.SINGLEFRAME);
+         ic.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
        else
          ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
       }
index 356787b..31802c6 100644 (file)
@@ -278,13 +278,13 @@ public final class FilePermission extends Permission implements Serializable
        break;
       }
 
-    if (readPerm && ! fp.readPerm)
+    if (fp.readPerm && ! readPerm)
       return false;
-    if (writePerm && ! fp.writePerm)
+    if (fp.writePerm && ! writePerm)
       return false;
-    if (executePerm && ! fp.executePerm)
+    if (fp.executePerm && ! executePerm)
       return false;
-    if (deletePerm && ! fp.deletePerm)
+    if (fp.deletePerm && ! deletePerm)
       return false;
     
     return true;
index 627dbc3..1d947a0 100644 (file)
@@ -408,10 +408,7 @@ public final class URL implements Serializable
            // The 1.2 doc specifically says these are copied to the new URL.
            host = context.host;
            port = context.port;
-           file = context.file;
             userInfo = context.userInfo;
-           if (file == null || file.length() == 0)
-             file = "/";
            authority = context.authority;
          }
       }
@@ -423,10 +420,13 @@ public final class URL implements Serializable
        protocol = context.protocol;
        host = context.host;
        port = context.port;
-       file = context.file;
         userInfo = context.userInfo;
-       if (file == null || file.length() == 0)
-         file = "/";
+       if (spec.indexOf(":/", 1) < 0)
+         {
+           file = context.file;
+           if (file == null || file.length() == 0)
+             file = "/";
+         }
        authority = context.authority;
       }
     else // Protocol NOT specified in spec. and no context available.
index 726778e..9d0e504 100644 (file)
@@ -536,15 +536,15 @@ public class URLClassLoader extends SecureClassLoader
     Resource getResource(String name)
     {
       try 
-       {
-         File file = new File(dir, name).getCanonicalFile();
-         if (file.exists() && !file.isDirectory())
-           return new FileResource(this, file);
-       }
+       {
+         File file = new File(dir, name).getCanonicalFile();
+         if (file.exists() && !file.isDirectory())
+           return new FileResource(this, file);
+       }
       catch (IOException e)
-       {
-         // Fall through...
-       }
+       {
+         // Fall through...
+       }
       return null;
     }
   }
@@ -873,47 +873,47 @@ public class URLClassLoader extends SecureClassLoader
     // construct the class (and watch out for those nasty IOExceptions)
     try
       {
-        byte[] data;
-        InputStream in = resource.getInputStream();
-        try
-          {
-            int length = resource.getLength();
-            if (length != -1)
-              {
-                // We know the length of the data.
-                // Just try to read it in all at once
-                data = new byte[length];
-                int pos = 0;
-                while (length - pos > 0)
-                  {
-                    int len = in.read(data, pos, length - pos);
-                    if (len == -1)
-                      throw new EOFException("Not enough data reading from: "
-                                             + in);
-                    pos += len;
-                  }
-              }
-            else
-              {
-                // We don't know the data length.
-                // Have to read it in chunks.
-                ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
-                byte[] b = new byte[4096];
-                int l = 0;
-                while (l != -1)
-                  {
-                    l = in.read(b);
-                    if (l != -1)
-                      out.write(b, 0, l);
-                  }
-                data = out.toByteArray();
-              }
-          }
-        finally
-          {
-            in.close();
-          }
-        final byte[] classData = data;
+       byte[] data;
+       InputStream in = resource.getInputStream();
+       try
+         {
+           int length = resource.getLength();
+           if (length != -1)
+             {
+               // We know the length of the data.
+               // Just try to read it in all at once
+               data = new byte[length];
+               int pos = 0;
+               while (length - pos > 0)
+                 {
+                   int len = in.read(data, pos, length - pos);
+                   if (len == -1)
+                     throw new EOFException("Not enough data reading from: "
+                                            + in);
+                   pos += len;
+                 }
+             }
+           else
+             {
+               // We don't know the data length.
+               // Have to read it in chunks.
+               ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
+               byte[] b = new byte[4096];
+               int l = 0;
+               while (l != -1)
+                 {
+                   l = in.read(b);
+                   if (l != -1)
+                     out.write(b, 0, l);
+                 }
+               data = out.toByteArray();
+             }
+         }
+       finally
+         {
+           in.close();
+         }
+       final byte[] classData = data;
 
         // Now get the CodeSource
         final CodeSource source = resource.getCodeSource();
index a5851b5..a8a0939 100644 (file)
@@ -37,6 +37,8 @@ exception statement from your version. */
 
 package java.security;
 
+import gnu.classpath.SystemProperties;
+
 /**
  * <p>This <code>ProtectionDomain</code> class encapsulates the characteristics
  * of a domain, which encloses a set of classes whose instances are granted a
@@ -222,7 +224,7 @@ public class ProtectionDomain
    */
   public String toString()
   {
-    String linesep = System.getProperty("line.separator");
+    String linesep = SystemProperties.getProperty("line.separator");
     StringBuffer sb = new StringBuffer("ProtectionDomain (").append(linesep);
 
     if (code_source == null)
index 3ee1046..e90c451 100644 (file)
@@ -189,7 +189,7 @@ public class JApplet extends Applet
 
   protected String paramString()
   {
-    return "JFrame";
+    return super.paramString();
   }
 
   protected void processKeyEvent(KeyEvent e)
index 021a2a3..deb08c5 100644 (file)
@@ -1918,9 +1918,15 @@ public abstract class JComponent extends Container implements Serializable
     g2 = getComponentGraphics(g2);
     g2.setClip(r.x, r.y, r.width, r.height);
     isPaintingDoubleBuffered = true;
-    paint(g2);
-    isPaintingDoubleBuffered = false;
-    g2.dispose();
+    try
+      {
+        paint(g2);
+      }
+    finally
+      {
+        isPaintingDoubleBuffered = false;
+        g2.dispose();
+      }
     
     // Paint the buffer contents on screen.
     g.drawImage(buffer, 0, 0, this);
@@ -2921,8 +2927,7 @@ public abstract class JComponent extends Container implements Serializable
   {
     super.removeNotify();
 
-    // FIXME: remove the WHEN_IN_FOCUSED_WINDOW bindings from the 
-    // KeyboardManager
+    KeyboardManager.getManager().clearBindingsForComp(this);
     
     // Notify ancestor listeners.
     fireAncestorEvent(this, AncestorEvent.ANCESTOR_REMOVED);
index 9ddf970..39f7c1f 100644 (file)
@@ -59,6 +59,9 @@ import javax.swing.text.Document;
 import javax.swing.text.EditorKit;
 import javax.swing.text.Element;
 import javax.swing.text.JTextComponent;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.WrappedPlainView;
 import javax.swing.text.html.HTML;
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.text.html.HTMLEditorKit;
@@ -466,6 +469,30 @@ public class JEditorPane extends JTextComponent
     }
   }
 
+  /**
+   * An EditorKit used for plain text. This is the default editor kit for
+   * JEditorPanes.
+   *
+   * @author Roman Kennke (kennke@aicas.com)
+   */
+  private static class PlainEditorKit extends DefaultEditorKit
+  {
+
+    /**
+     * Returns a ViewFactory that supplies WrappedPlainViews.
+     */
+    public ViewFactory getViewFactory()
+    {
+      return new ViewFactory()
+      {
+        public View create(Element el)
+        {
+          return new WrappedPlainView(el);
+        }
+      };
+    }
+  }
+
   private static final long serialVersionUID = 3140472492599046285L;
   
   private URL page;
@@ -497,12 +524,12 @@ public class JEditorPane extends JTextComponent
 
   protected EditorKit createDefaultEditorKit()
   {
-    return new DefaultEditorKit();
+    return new PlainEditorKit();
   }
 
   public static EditorKit createEditorKitForContentType(String type)
   {
-    return new DefaultEditorKit();
+    return new PlainEditorKit();
   }
 
   /**
index 4f5d3cc..caa7f31 100644 (file)
@@ -1322,7 +1322,11 @@ public class JList extends JComponent implements Accessible, Scrollable
 
 
   /**
-   * Returns index of the cell to which specified location is closest to
+   * Returns index of the cell to which specified location is closest to. If
+   * the location is outside the bounds of the list, then the greatest index
+   * in the list model is returned. If the list model is empty, then
+   * <code>-1</code> is returned.
+   *
    * @param location for which to look for in the list
    * 
    * @return index of the cell to which specified location is closest to.
index 9734eb8..369c44d 100644 (file)
@@ -96,6 +96,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
   public JMenu()
   {
     super();
+    setOpaque(false);
   }
 
   /**
@@ -107,6 +108,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
   {
     super(text);
     popupMenu.setInvoker(this);
+    setOpaque(false);
   }
 
   /**
@@ -120,6 +122,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
     super(action);
     createActionChangeListener(this);
     popupMenu.setInvoker(this);
+    setOpaque(false);
   }
 
   /**
index 7805e92..c02a9cf 100644 (file)
@@ -137,6 +137,6 @@ public class JPanel extends JComponent implements Accessible
     
   protected  String paramString()
   {
-       return "JPanel";
+       return super.paramString();
   }
 }
index cdab7bb..70feefa 100644 (file)
@@ -170,13 +170,15 @@ public class JSplitPane extends JComponent implements Accessible
   public static final int HORIZONTAL_SPLIT = 1;
 
   /** The property fired when the last divider location property changes. */
-  public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";
+  public static final String LAST_DIVIDER_LOCATION_PROPERTY = 
+    "lastDividerLocation";
 
   /** The constraints string used to add components to the left. */
   public static final String LEFT = "left";
 
   /** The property fired when the one touch expandable property changes. */
-  public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";
+  public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = 
+    "oneTouchExpandable";
 
   /** The property fired when the orientation property changes. */
   public static final String ORIENTATION_PROPERTY = "orientation";
@@ -199,7 +201,8 @@ public class JSplitPane extends JComponent implements Accessible
   /** Whether the JSplitPane uses one touch expandable buttons. */
   protected boolean oneTouchExpandable = false;
 
-  // This is the master dividerSize variable and sets the BasicSplitPaneDivider one accordingly
+  // This is the master dividerSize variable and sets the 
+  // BasicSplitPaneDivider one accordingly
 
   /** The size of the divider. */
   protected int dividerSize = 10;
@@ -286,7 +289,8 @@ public class JSplitPane extends JComponent implements Accessible
    */
   public JSplitPane()
   {
-    this(HORIZONTAL_SPLIT, false, null, null);
+    this(HORIZONTAL_SPLIT, false, new JButton("left button"),
+         new JButton("right button"));
   }
 
   /**
@@ -300,7 +304,8 @@ public class JSplitPane extends JComponent implements Accessible
    * @param constraints The constraints string to use.
    * @param index Where to place to component in the list of components.
    *
-   * @throws IllegalArgumentException When the constraints is not a known identifier.
+   * @throws IllegalArgumentException When the constraints is not a known 
+   * identifier.
    */
   protected void addImpl(Component comp, Object constraints, int index)
   {
@@ -310,34 +315,35 @@ public class JSplitPane extends JComponent implements Accessible
     int place;
     if (constraints == null)
       {
-       if (leftComponent == null)
-         constraints = LEFT;
-       else if (rightComponent == null)
-         constraints = RIGHT;
+        if (leftComponent == null)
+          constraints = LEFT;
+        else if (rightComponent == null)
+          constraints = RIGHT;
       }
 
     if (constraints instanceof String)
       {
-       String placement = (String) constraints;
-
-       if (placement.equals(BOTTOM) || placement.equals(RIGHT))
-         {
-           if (rightComponent != null)
-               remove(rightComponent);
-           rightComponent = comp;
-         }
-       else if (placement.equals(LEFT) || placement.equals(TOP))
-         {
-           if (leftComponent != null)
-             remove(leftComponent);
-           leftComponent = comp;
-         }
-       else if (placement.equals(DIVIDER))
-         constraints = null;
-       else
-         throw new IllegalArgumentException("Constraints is not a known identifier.");
-
-       super.addImpl(comp, constraints, index);
+        String placement = (String) constraints;
+
+        if (placement.equals(BOTTOM) || placement.equals(RIGHT))
+          {
+            if (rightComponent != null)
+              remove(rightComponent);
+            rightComponent = comp;
+          }
+        else if (placement.equals(LEFT) || placement.equals(TOP))
+          {
+            if (leftComponent != null)
+              remove(leftComponent);
+            leftComponent = comp;
+          }
+        else if (placement.equals(DIVIDER))
+          constraints = null;
+        else
+          throw new 
+            IllegalArgumentException("Constraints is not a known identifier.");
+
+        super.addImpl(comp, constraints, index);
       }
     invalidate();
     layout();
@@ -614,10 +620,10 @@ public class JSplitPane extends JComponent implements Accessible
   {
     if (newContinuousLayout != continuousLayout)
       {
-       boolean oldValue = continuousLayout;
-       continuousLayout = newContinuousLayout;
-       firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue,
-                          continuousLayout);
+        boolean oldValue = continuousLayout;
+        continuousLayout = newContinuousLayout;
+        firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue,
+                           continuousLayout);
       }
   }
 
@@ -634,7 +640,8 @@ public class JSplitPane extends JComponent implements Accessible
   public void setDividerLocation(double proportionalLocation)
   {
     if (proportionalLocation > 1 || proportionalLocation < 0)
-      throw new IllegalArgumentException("proportion has to be between 0 and 1.");
+      throw new IllegalArgumentException
+        ("proportion has to be between 0 and 1.");
 
     int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight();
     setDividerLocation((int) (proportionalLocation * max));
@@ -649,9 +656,9 @@ public class JSplitPane extends JComponent implements Accessible
   {
     if (ui != null && location != getDividerLocation())
       {
-       int oldLocation = getDividerLocation();
-       ((SplitPaneUI) ui).setDividerLocation(this, location);
-       firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);
+        int oldLocation = getDividerLocation();
+        ((SplitPaneUI) ui).setDividerLocation(this, location);
+        firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);
       }
   }
 
@@ -664,9 +671,9 @@ public class JSplitPane extends JComponent implements Accessible
   {
     if (newSize != dividerSize)
       {
-       int oldSize = dividerSize;
-       dividerSize = newSize;
-       firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize);
+        int oldSize = dividerSize;
+        dividerSize = newSize;
+        firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize);
       }
   }
 
@@ -683,10 +690,10 @@ public class JSplitPane extends JComponent implements Accessible
   {
     if (newLastLocation != lastDividerLocation)
       {
-       int oldValue = lastDividerLocation;
-       lastDividerLocation = newLastLocation;
-       firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue,
-                          lastDividerLocation);
+        int oldValue = lastDividerLocation;
+        lastDividerLocation = newLastLocation;
+        firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue,
+                           lastDividerLocation);
       }
   }
 
@@ -696,11 +703,11 @@ public class JSplitPane extends JComponent implements Accessible
    * @param comp The left component.
    */
   public void setLeftComponent(Component comp)
-  {
+  {    
     if (comp != null)
       add(comp, LEFT);
     else
-      add(new JButton("left button"), LEFT);
+      remove (leftComponent);
   }
 
   /**
@@ -715,10 +722,10 @@ public class JSplitPane extends JComponent implements Accessible
   {
     if (newValue != oneTouchExpandable)
       {
-       boolean oldValue = oneTouchExpandable;
-       oneTouchExpandable = newValue;
-       firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue,
-                          oneTouchExpandable);
+        boolean oldValue = oneTouchExpandable;
+        oneTouchExpandable = newValue;
+        firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue,
+                           oneTouchExpandable);
       }
   }
 
@@ -732,13 +739,14 @@ public class JSplitPane extends JComponent implements Accessible
   public void setOrientation(int orientation)
   {
     if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
-      throw new IllegalArgumentException("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT");
+      throw new IllegalArgumentException
+        ("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT");
     if (orientation != this.orientation)
       {
-       int oldOrientation = this.orientation;
-       this.orientation = orientation;
-       firePropertyChange(ORIENTATION_PROPERTY, oldOrientation,
-                          this.orientation);
+        int oldOrientation = this.orientation;
+        this.orientation = orientation;
+        firePropertyChange(ORIENTATION_PROPERTY, oldOrientation,
+                           this.orientation);
       }
   }
 
@@ -766,7 +774,7 @@ public class JSplitPane extends JComponent implements Accessible
     if (comp != null)
       add(comp, RIGHT);
     else
-       add(new JButton("right button"), RIGHT);
+      remove (rightComponent);
   }
 
   /**
index 1f5b99e..a2aebd4 100644 (file)
@@ -47,7 +47,9 @@ import javax.swing.text.Document;
 import javax.swing.text.EditorKit;
 import javax.swing.text.Element;
 import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
 import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
 import javax.swing.text.StyledDocument;
 import javax.swing.text.StyledEditorKit;
 
@@ -192,9 +194,20 @@ public class JTextPane
    */
   public void insertComponent(Component component)
   {
-    // TODO: One space must be inserted here with attributes set to indicate
-    // that the component must be displayed here. Have to figure out the
-    // attributes.
+    SimpleAttributeSet atts = new SimpleAttributeSet();
+    atts.addAttribute(StyleConstants.ComponentAttribute, component);
+    atts.addAttribute(StyleConstants.NameAttribute,
+                      StyleConstants.ComponentElementName);
+    try
+      {
+        getDocument().insertString(getCaret().getDot(), " ", atts);
+      }
+    catch (BadLocationException ex)
+      {
+        AssertionError err = new AssertionError("Unexpected bad location");
+        err.initCause(ex);
+        throw err;
+      }
   }
 
   /**
@@ -204,9 +217,20 @@ public class JTextPane
    */
   public void insertIcon(Icon icon)
   {
-    // TODO: One space must be inserted here with attributes set to indicate
-    // that the icon must be displayed here. Have to figure out the
-    // attributes.
+    SimpleAttributeSet atts = new SimpleAttributeSet();
+    atts.addAttribute(StyleConstants.IconAttribute, icon);
+    atts.addAttribute(StyleConstants.NameAttribute,
+                      StyleConstants.IconElementName);
+    try
+      {
+        getDocument().insertString(getCaret().getDot(), " ", atts);
+      }
+    catch (BadLocationException ex)
+      {
+        AssertionError err = new AssertionError("Unexpected bad location");
+        err.initCause(ex);
+        throw err;
+      }
   }
 
   /**
index d386830..aa9524c 100644 (file)
@@ -53,7 +53,7 @@ import java.util.Vector;
  * Components register keyboard actions with the condition
  * JComponent.WHEN_IN_FOCUSED_WINDOW.
  * 
- * @author Anthony Balkissoon <abalkiss@redhat.com>
+ * @author Anthony Balkissoon abalkiss at redhat dot com
  *
  */
 class KeyboardManager
index 0383579..289149f 100644 (file)
@@ -173,18 +173,9 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
 
   /** The last known position of the mouse cursor. */
   private static Point currentPoint;
-
-  /**
-   * The panel that holds the tooltip when the tooltip is displayed fully
-   * inside the current container.
-   */
-  private static Container containerPanel;
-
-  /**
-   * The window used when the tooltip doesn't fit inside the current
-   * container.
-   */
-  private static JDialog tooltipWindow;
+  
+  /**  */
+  private static Popup popup;
 
   /**
    * Creates a new ToolTipManager and sets up the timers.
@@ -369,26 +360,27 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
         && getContentPaneDeepestComponent(event) == currentComponent)
       return;
     currentPoint = event.getPoint();
+
     currentComponent = (Component) event.getSource();
 
     if (exitTimer.isRunning())
       {
-       exitTimer.stop();
-       insideTimer.start();
-       return;
+        exitTimer.stop();
+        showTip();
+        return;
       }
-
     // This should always be stopped unless we have just fake-exited.
-    if (! enterTimer.isRunning())
+    if (!enterTimer.isRunning())
       enterTimer.start();
   }
 
   /**
-   * This method is called when the mouse exits a JComponent registered with
-   * the ToolTipManager. When the mouse exits, the tooltip should be hidden
+   * This method is called when the mouse exits a JComponent registered with the
+   * ToolTipManager. When the mouse exits, the tooltip should be hidden
    * immediately.
-   *
-   * @param event The MouseEvent.
+   * 
+   * @param event
+   *          The MouseEvent.
    */
   public void mouseExited(MouseEvent event)
   {
@@ -399,7 +391,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
     currentComponent = null;
     hideTip();
 
-    if (! enterTimer.isRunning() && insideTimer.isRunning())
+    if (! enterTimer.isRunning())
       exitTimer.start();
     if (enterTimer.isRunning())
       enterTimer.stop();
@@ -460,77 +452,36 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
   void showTip()
   {
     if (!enabled || currentComponent == null || !currentComponent.isEnabled()
-        || (currentTip != null && currentTip.isVisible()))
-      return;
+        || !currentComponent.isShowing())
+      {
+        popup = null;
+        return;
+      }
 
     if (currentTip == null || currentTip.getComponent() != currentComponent
         && currentComponent instanceof JComponent)
       currentTip = ((JComponent) currentComponent).createToolTip();
 
-    currentTip.setVisible(true);
-    Container parent = currentComponent.getParent();
     Point p = currentPoint;
+    Point cP = currentComponent.getLocationOnScreen();
     Dimension dims = currentTip.getPreferredSize();
     
-    if (parent instanceof JPopupMenu)
-        setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled());
-    else
-      setLightWeightPopupEnabled(true);
-           
-    if (isLightWeightPopupEnabled())
-      {
-        JLayeredPane pane = null;
-        JRootPane r = ((JRootPane) SwingUtilities.
-            getAncestorOfClass(JRootPane.class, currentComponent));
-        if (r != null)
-          pane = r.getLayeredPane();
-        if (pane == null)
-          return;
-        
-        if (containerPanel != null)
-          hideTip();
-        
-        containerPanel = new Panel();
-        JRootPane root = new JRootPane();
-        root.getContentPane().add(currentTip);
-        containerPanel.add(root);
-
-        LayoutManager lm = containerPanel.getLayout();
-        if (lm instanceof FlowLayout)
-          {
-            FlowLayout fm = (FlowLayout) lm;
-            fm.setVgap(0);
-            fm.setHgap(0);
-          }
-
-        p = SwingUtilities.convertPoint(currentComponent, p, pane);
-        p = adjustLocation(p, pane, dims);
-        
-        pane.add(containerPanel);
-        containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
-        currentTip.setBounds(0, 0, dims.width, dims.height);
-        containerPanel.validate();
-        containerPanel.repaint();
-      }
-    else if (currentComponent.isShowing())
-      {        
-        SwingUtilities.convertPointToScreen(p, currentComponent);
-        p = adjustLocation(p, SwingUtilities.getWindowAncestor(currentComponent), 
-                           dims);
-        
-        tooltipWindow = new JDialog();
-        tooltipWindow.setContentPane(currentTip);
-        tooltipWindow.setUndecorated(true);
-        tooltipWindow.getRootPane().
-                setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
-        tooltipWindow.pack();
-        tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
-        tooltipWindow.show();
-        tooltipWindow.validate();
-        tooltipWindow.repaint();
-        currentTip.revalidate();
-        currentTip.repaint();
-      }
+    JLayeredPane pane = null;
+    JRootPane r = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
+                                                                 currentComponent));
+    if (r != null)
+      pane = r.getLayeredPane();
+    if (pane == null)
+      return;
+    
+    p.translate(cP.x, cP.y);
+    adjustLocation(p, pane, dims);
+    
+    currentTip.setBounds(0, 0, dims.width, dims.height);
+    
+    PopupFactory factory = PopupFactory.getSharedInstance();
+    popup = factory.getPopup(currentComponent, currentTip, p.x, p.y);
+    popup.show();
   }
 
   /**
@@ -550,7 +501,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
     if (p.y + d.height < c.getHeight())
       p.y += d.height;
     if (p.y + d.height > c.getHeight())
-      p.y -= d.height*2;
+      p.y -= d.height;
     
     return p;
   }
@@ -561,29 +512,8 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
    */
   void hideTip()
   {
-    if (currentTip == null || ! currentTip.isVisible() || ! enabled)
-      return;
-    currentTip.setVisible(false);
-    if (containerPanel != null)
-      {
-       Container parent = containerPanel.getParent();
-       if (parent == null)
-         return;
-       parent.remove(containerPanel);
-
-       parent = currentTip.getParent();
-       if (parent == null)
-         return;
-       parent.remove(currentTip);
-       containerPanel = null;
-      }
-    if (tooltipWindow != null)
-      {
-       tooltipWindow.hide();
-       tooltipWindow.dispose();
-       tooltipWindow = null;
-      }
-    currentTip = null;
+    if (popup != null)
+      popup.hide();
   }
 
   /**
index 15a7819..fbf1c7c 100644 (file)
@@ -132,6 +132,11 @@ public class UIManager implements Serializable
   
   static UIDefaults currentUIDefaults;
 
+  /**
+   * UIDefaults set by the user.
+   */
+  static UIDefaults userUIDefaults;
+
   /** Property change listener mechanism. */
   static SwingPropertyChangeSupport listeners 
       = new SwingPropertyChangeSupport(UIManager.class);
@@ -305,7 +310,12 @@ public class UIManager implements Serializable
    */
   public static Object get(Object key)
   {
-    return getLookAndFeelDefaults().get(key);
+    Object val = null;
+    if (userUIDefaults != null)
+      val = userUIDefaults.get(key);
+    if (val == null)
+      val = getLookAndFeelDefaults().get(key);
+    return val;
   }
 
   /**
@@ -318,7 +328,12 @@ public class UIManager implements Serializable
    */
   public static Object get(Object key, Locale locale)
   {
-    return getLookAndFeelDefaults().get(key ,locale);
+    Object val = null;
+    if (userUIDefaults != null)
+      val = userUIDefaults.get(key, locale);
+    if (val == null)
+      val = getLookAndFeelDefaults().get(key, locale);
+    return val;
   }
 
   /**
@@ -329,7 +344,7 @@ public class UIManager implements Serializable
    */
   public static boolean getBoolean(Object key)
   {
-    Boolean value = (Boolean) getLookAndFeelDefaults().get(key);
+    Boolean value = (Boolean) get(key);
     return value != null ? value.booleanValue() : false;
   }
   
@@ -341,7 +356,7 @@ public class UIManager implements Serializable
    */
   public static boolean getBoolean(Object key, Locale locale)
   {
-    Boolean value = (Boolean) getLookAndFeelDefaults().get(key, locale);
+    Boolean value = (Boolean) get(key, locale);
     return value != null ? value.booleanValue() : false;
   }
     
@@ -350,7 +365,7 @@ public class UIManager implements Serializable
    */
   public static Border getBorder(Object key)
   {
-    return (Border) getLookAndFeelDefaults().get(key);
+    return (Border) get(key);
   }
     
   /**
@@ -360,7 +375,7 @@ public class UIManager implements Serializable
    */
   public static Border getBorder(Object key, Locale locale)
   {
-    return (Border) getLookAndFeelDefaults().get(key, locale);
+    return (Border) get(key, locale);
   }
     
   /**
@@ -368,7 +383,7 @@ public class UIManager implements Serializable
    */
   public static Color getColor(Object key)
   {
-    return (Color) getLookAndFeelDefaults().get(key);
+    return (Color) get(key);
   }
 
   /**
@@ -376,7 +391,7 @@ public class UIManager implements Serializable
    */
   public static Color getColor(Object key, Locale locale)
   {
-    return (Color) getLookAndFeelDefaults().get(key);
+    return (Color) get(key);
   }
 
   /**
@@ -405,7 +420,7 @@ public class UIManager implements Serializable
    */
   public static Dimension getDimension(Object key)
   {
-    return (Dimension) getLookAndFeelDefaults().get(key);
+    return (Dimension) get(key);
   }
 
   /**
@@ -413,7 +428,7 @@ public class UIManager implements Serializable
    */
   public static Dimension getDimension(Object key, Locale locale)
   {
-    return (Dimension) getLookAndFeelDefaults().get(key, locale);
+    return (Dimension) get(key, locale);
   }
 
   /**
@@ -426,7 +441,7 @@ public class UIManager implements Serializable
    */
   public static Font getFont(Object key)
   {
-    return (Font) getLookAndFeelDefaults().get(key);
+    return (Font) get(key);
   }
 
   /**
@@ -439,7 +454,7 @@ public class UIManager implements Serializable
    */
   public static Font getFont(Object key, Locale locale)
   {
-    return (Font) getLookAndFeelDefaults().get(key ,locale);
+    return (Font) get(key ,locale);
   }
 
   /**
@@ -447,7 +462,7 @@ public class UIManager implements Serializable
    */
   public static Icon getIcon(Object key)
   {
-    return (Icon) getLookAndFeelDefaults().get(key);
+    return (Icon) get(key);
   }
   
   /**
@@ -455,7 +470,7 @@ public class UIManager implements Serializable
    */
   public static Icon getIcon(Object key, Locale locale)
   {
-    return (Icon) getLookAndFeelDefaults().get(key, locale);
+    return (Icon) get(key, locale);
   }
   
   /**
@@ -463,7 +478,11 @@ public class UIManager implements Serializable
    */
   public static Insets getInsets(Object key)
   {
-    return getLookAndFeelDefaults().getInsets(key);
+    Object o = get(key);
+    if (o instanceof Insets)
+      return (Insets) o;
+    else
+      return null;
   }
 
   /**
@@ -471,7 +490,11 @@ public class UIManager implements Serializable
    */
   public static Insets getInsets(Object key, Locale locale)
   {
-    return getLookAndFeelDefaults().getInsets(key, locale);
+    Object o = get(key, locale);
+    if (o instanceof Insets)
+      return (Insets) o;
+    else
+      return null;
   }
 
   /**
@@ -487,7 +510,7 @@ public class UIManager implements Serializable
 
   public static int getInt(Object key)
   {
-    Integer x = (Integer) getLookAndFeelDefaults().get(key);
+    Integer x = (Integer) get(key);
     if (x == null)
       return 0;
     return x.intValue();
@@ -495,7 +518,7 @@ public class UIManager implements Serializable
 
   public static int getInt(Object key, Locale locale)
   {
-    Integer x = (Integer) getLookAndFeelDefaults().get(key, locale);
+    Integer x = (Integer) get(key, locale);
     if (x == null)
       return 0;
     return x.intValue();
@@ -529,7 +552,7 @@ public class UIManager implements Serializable
    */
   public static String getString(Object key)
   {
-    return (String) getLookAndFeelDefaults().get(key);
+    return (String) get(key);
   }
   
   /**
@@ -537,7 +560,7 @@ public class UIManager implements Serializable
    */
   public static String getString(Object key, Locale locale)
   {
-    return (String) getLookAndFeelDefaults().get(key, locale);
+    return (String) get(key, locale);
   }
   
   /**
@@ -562,7 +585,13 @@ public class UIManager implements Serializable
    */
   public static ComponentUI getUI(JComponent target)
   {
-    return getLookAndFeelDefaults().getUI(target);
+    ComponentUI ui = null;
+    if (userUIDefaults != null
+        && userUIDefaults.get(target.getUIClassID()) != null)
+      ui = userUIDefaults.getUI(target);
+    if (ui == null)
+      ui = currentUIDefaults.getUI(target);
+    return ui;
   }
 
   /**
@@ -591,7 +620,11 @@ public class UIManager implements Serializable
    */
   public static Object put(Object key, Object value)
   {
-    return getLookAndFeelDefaults().put(key,value);
+    Object old = get(key);
+    if (userUIDefaults == null)
+      userUIDefaults = new UIDefaults();
+    userUIDefaults.put(key, value);
+    return old;
   }
 
   /**
@@ -617,7 +650,6 @@ public class UIManager implements Serializable
   {
     if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel())
       throw new UnsupportedLookAndFeelException(newLookAndFeel.getName());
-    
     LookAndFeel oldLookAndFeel = currentLookAndFeel;
     if (oldLookAndFeel != null)
       oldLookAndFeel.uninitialize();
index cec7bec..5d4ce18 100644 (file)
@@ -51,7 +51,6 @@ import javax.swing.JButton;
 import javax.swing.JPopupMenu;
 import javax.swing.JSplitPane;
 import javax.swing.JToolBar;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.border.AbstractBorder;
 import javax.swing.border.BevelBorder;
@@ -95,21 +94,18 @@ public class BasicBorders
    */
   public static Border getButtonBorder()
   {
-    UIDefaults defaults;
     Border outer;
 
-    defaults = UIManager.getLookAndFeelDefaults();
-
     /* The keys for UIDefaults have been determined by writing a
      * test program that dumps the UIDefaults to stdout; that program
      * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
      * the key "light" is usually called "highlight", and "highlight"
      * is usually called "lightHighlight".
      */
-    outer = new ButtonBorder(defaults.getColor("Button.shadow"),
-                             defaults.getColor("Button.darkShadow"),
-                             defaults.getColor("Button.light"),
-                             defaults.getColor("Button.highlight"));
+    outer = new ButtonBorder(UIManager.getColor("Button.shadow"),
+                             UIManager.getColor("Button.darkShadow"),
+                             UIManager.getColor("Button.light"),
+                             UIManager.getColor("Button.highlight"));
 
     /* While the inner border is shared between multiple buttons,
      * we do not share the outer border because ButtonBorders store
@@ -145,11 +141,8 @@ public class BasicBorders
    */
   public static Border getRadioButtonBorder()
   {
-    UIDefaults defaults;
     Border outer;
 
-    defaults = UIManager.getLookAndFeelDefaults();
-
     /* The keys for UIDefaults have been determined by writing a
      * test program that dumps the UIDefaults to stdout; that program
      * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
@@ -157,10 +150,10 @@ public class BasicBorders
      * is usually called "lightHighlight".
      */
     outer = new RadioButtonBorder(
-      defaults.getColor("RadioButton.shadow"),
-      defaults.getColor("RadioButton.darkShadow"),
-      defaults.getColor("RadioButton.light"),
-      defaults.getColor("RadioButton.highlight"));
+      UIManager.getColor("RadioButton.shadow"),
+      UIManager.getColor("RadioButton.darkShadow"),
+      UIManager.getColor("RadioButton.light"),
+      UIManager.getColor("RadioButton.highlight"));
 
     /* While the inner border is shared between multiple buttons, we
      * do not share the outer border because RadioButtonBorders, being
@@ -197,11 +190,8 @@ public class BasicBorders
    */
   public static Border getToggleButtonBorder()
   {
-    UIDefaults defaults;
     Border outer;
 
-    defaults = UIManager.getLookAndFeelDefaults();
-
     /* The keys for UIDefaults have been determined by writing a
      * test program that dumps the UIDefaults to stdout; that program
      * was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
@@ -209,10 +199,10 @@ public class BasicBorders
      * is usually called "lightHighlight".
      */
     outer = new ToggleButtonBorder(
-      defaults.getColor("ToggleButton.shadow"),
-      defaults.getColor("ToggleButton.darkShadow"),
-      defaults.getColor("ToggleButton.light"),
-      defaults.getColor("ToggleButton.highlight"));
+      UIManager.getColor("ToggleButton.shadow"),
+      UIManager.getColor("ToggleButton.darkShadow"),
+      UIManager.getColor("ToggleButton.light"),
+      UIManager.getColor("ToggleButton.highlight"));
 
     /* While the inner border is shared between multiple buttons, we
      * do not share the outer border because ToggleButtonBorders, being
@@ -247,12 +237,9 @@ public class BasicBorders
    */
   public static Border getMenuBarBorder()
   {
-    UIDefaults defaults;
-
     /* See comment in methods above for why this border is not shared. */
-    defaults = UIManager.getLookAndFeelDefaults();
-    return new MenuBarBorder(defaults.getColor("MenuBar.shadow"),
-                             defaults.getColor("MenuBar.highlight"));
+    return new MenuBarBorder(UIManager.getColor("MenuBar.shadow"),
+                             UIManager.getColor("MenuBar.highlight"));
   }
 
 
@@ -279,12 +266,9 @@ public class BasicBorders
    */
   public static Border getSplitPaneBorder()
   {
-    UIDefaults defaults;
-
     /* See comment in methods above for why this border is not shared. */
-    defaults = UIManager.getLookAndFeelDefaults();
-    return new SplitPaneBorder(defaults.getColor("SplitPane.highlight"),
-                               defaults.getColor("SplitPane.darkShadow"));
+    return new SplitPaneBorder(UIManager.getColor("SplitPane.highlight"),
+                               UIManager.getColor("SplitPane.darkShadow"));
   }
 
 
@@ -314,13 +298,10 @@ public class BasicBorders
    */
   public static Border getSplitPaneDividerBorder()
   {
-    UIDefaults defaults;
-
     /* See comment in methods above for why this border is not shared. */
-    defaults = UIManager.getLookAndFeelDefaults();
     return new SplitPaneDividerBorder(
-      defaults.getColor("SplitPane.highlight"),
-      defaults.getColor("SplitPane.darkShadow"));
+      UIManager.getColor("SplitPane.highlight"),
+      UIManager.getColor("SplitPane.darkShadow"));
   }
 
 
@@ -346,15 +327,12 @@ public class BasicBorders
    */
   public static Border getTextFieldBorder()
   {
-    UIDefaults defaults;
-
     /* See comment in methods above for why this border is not shared. */
-    defaults = UIManager.getLookAndFeelDefaults();
     return new FieldBorder(
-      defaults.getColor("TextField.shadow"),
-      defaults.getColor("TextField.darkShadow"),
-      defaults.getColor("TextField.light"),
-      defaults.getColor("TextField.highlight"));
+      UIManager.getColor("TextField.shadow"),
+      UIManager.getColor("TextField.darkShadow"),
+      UIManager.getColor("TextField.light"),
+      UIManager.getColor("TextField.highlight"));
   }
   
 
@@ -394,17 +372,14 @@ public class BasicBorders
    */
   public static Border getInternalFrameBorder()
   {
-    UIDefaults defaults;
     Color shadow, darkShadow, highlight, lightHighlight, line;
 
     /* See comment in methods above for why this border is not shared. */
-    defaults = UIManager.getLookAndFeelDefaults();
-    
-    shadow = defaults.getColor("InternalFrame.borderShadow");
-    darkShadow = defaults.getColor("InternalFrame.borderDarkShadow");
-    highlight = defaults.getColor("InternalFrame.borderLight");
-    lightHighlight = defaults.getColor("InternalFrame.borderHighlight");
-    line = defaults.getColor("InternalFrame.borderColor");
+    shadow = UIManager.getColor("InternalFrame.borderShadow");
+    darkShadow = UIManager.getColor("InternalFrame.borderDarkShadow");
+    highlight = UIManager.getColor("InternalFrame.borderLight");
+    lightHighlight = UIManager.getColor("InternalFrame.borderHighlight");
+    line = UIManager.getColor("InternalFrame.borderColor");
 
     return new BorderUIResource.CompoundBorderUIResource(
       /* outer border */
index 2d3dbd3..7a63331 100644 (file)
@@ -52,7 +52,6 @@ import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ButtonUI;
 import javax.swing.plaf.ComponentUI;
@@ -161,7 +160,6 @@ public class BasicButtonUI extends ButtonUI
     b.setIconTextGap(UIManager.getInt(prefix + "textIconGap"));
     b.setInputMap(JComponent.WHEN_FOCUSED, 
                   (InputMap) UIManager.get(prefix + "focusInputMap"));
-    b.setRolloverEnabled(UIManager.getBoolean(prefix + "rollover"));
   }
 
   /**
@@ -444,9 +442,8 @@ public class BasicButtonUI extends ButtonUI
       }
     else
       {
-        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
         String prefix = getPropertyPrefix();
-        g.setColor(defaults.getColor(prefix + "disabledText"));
+        g.setColor(UIManager.getColor(prefix + "disabledText"));
         g.drawString(text, textRect.x, textRect.y + fm.getAscent());
       }
   } 
index 3cf02a0..14dadb8 100644 (file)
@@ -40,7 +40,6 @@ package javax.swing.plaf.basic;
 
 import javax.swing.Icon;
 import javax.swing.JComponent;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 
@@ -53,12 +52,11 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI
 
   public Icon getDefaultIcon()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    return defaults.getIcon("CheckBox.icon");
+    return UIManager.getIcon("CheckBox.icon");
   }
   
   /**
-   * Returns the prefix for entries in the {@link UIDefaults} table.
+   * Returns the prefix for entries in the {@link UIManager} defaults table.
    *
    * @return "CheckBox."
    */
index 464c8dd..b22aa15 100644 (file)
@@ -805,10 +805,10 @@ public class BasicComboBoxUI extends ComboBoxUI
                 isPressed, hasFocus);
         if (! comboBox.isEnabled())
           {
-            comp.setBackground(UIManager.getLookAndFeelDefaults().getColor(
-                "ComboBox.disabledBackground"));
-            comp.setForeground(UIManager.getLookAndFeelDefaults().getColor(
-                "ComboBox.disabledForeground"));
+            comp.setBackground(UIManager.getColor(
+                                               "ComboBox.disabledBackground"));
+            comp.setForeground(UIManager.getColor(
+                                               "ComboBox.disabledForeground"));
             comp.setEnabled(false);
           }
         comp.setBounds(0, 0, bounds.width, bounds.height);
index d5b34d9..d514a87 100644 (file)
@@ -42,10 +42,7 @@ import javax.swing.JComponent;
 import javax.swing.JEditorPane;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.text.EditorKit;
-import javax.swing.text.Element;
 import javax.swing.text.JTextComponent;
-import javax.swing.text.PlainView;
-import javax.swing.text.View;
 
 /**
  * The UI class for  {@link JEditorPane}s.
@@ -76,14 +73,6 @@ public class BasicEditorPaneUI extends BasicTextUI
     // Do nothing here.
   }
 
-  // FIXME: Should not be overridden here but instead be handled by the
-  // JEditorPane's EditorKit. However, as long as we don't have styles in
-  // place this doesn't make much sense.
-  public View create(Element elem)
-  {
-    return new PlainView(elem);
-  }
-
   /**
    * Returns the property prefix to be used by this UI class. This is
    * <code>EditorPane</code> in this case.
index 9c63965..60179dc 100644 (file)
@@ -79,7 +79,6 @@ import javax.swing.ListCellRenderer;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
@@ -1429,27 +1428,25 @@ public class BasicFileChooserUI extends FileChooserUI
    */
   protected void installStrings(JFileChooser fc)
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+    acceptAllFileFilterText = UIManager.getString("FileChooser.acceptAllFileFilterText");
+    cancelButtonMnemonic = UIManager.getInt("FileChooser.cancelButtonMnemonic");
+    cancelButtonText = UIManager.getString("FileChooser.cancelButtonText");
+    cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText");
 
-    acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText");
-    cancelButtonMnemonic = defaults.getInt("FileChooser.cancelButtonMnemonic");
-    cancelButtonText = defaults.getString("FileChooser.cancelButtonText");
-    cancelButtonToolTipText = defaults.getString("FileChooser.cancelButtonToolTipText");
+    dirDescText = UIManager.getString("FileChooser.directoryDescriptionText");
+    fileDescText = UIManager.getString("FileChooser.fileDescriptionText");
 
-    dirDescText = defaults.getString("FileChooser.directoryDescriptionText");
-    fileDescText = defaults.getString("FileChooser.fileDescriptionText");
+    helpButtonMnemonic = UIManager.getInt("FileChooser.helpButtonMnemonic");
+    helpButtonText = UIManager.getString("FileChooser.helpButtonText");
+    helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText");
 
-    helpButtonMnemonic = defaults.getInt("FileChooser.helpButtonMnemonic");
-    helpButtonText = defaults.getString("FileChooser.helpButtonText");
-    helpButtonToolTipText = defaults.getString("FileChooser.helpButtonToolTipText");
+    openButtonMnemonic = UIManager.getInt("FileChooser.openButtonMnemonic");
+    openButtonText = UIManager.getString("FileChooser.openButtonText");
+    openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText");
 
-    openButtonMnemonic = defaults.getInt("FileChooser.openButtonMnemonic");
-    openButtonText = defaults.getString("FileChooser.openButtonText");
-    openButtonToolTipText = defaults.getString("FileChooser.openButtonToolTipText");
-
-    saveButtonMnemonic = defaults.getInt("FileChooser.saveButtonMnemonic");
-    saveButtonText = defaults.getString("FileChooser.saveButtonText");
-    saveButtonToolTipText = defaults.getString("FileChooser.saveButtonToolTipText");
+    saveButtonMnemonic = UIManager.getInt("FileChooser.saveButtonMnemonic");
+    saveButtonText = UIManager.getString("FileChooser.saveButtonText");
+    saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText");
   }
 
   /**
index 73d3e61..56022f3 100644 (file)
@@ -66,7 +66,6 @@ import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 
 /**
@@ -718,13 +717,11 @@ public class BasicInternalFrameTitlePane extends JComponent
    */
   protected void installDefaults()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
-    title.setFont(defaults.getFont("InternalFrame.titleFont"));
-    selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground");
-    selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground");
-    notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground");
-    notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground");
+    title.setFont(UIManager.getFont("InternalFrame.titleFont"));
+    selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
+    selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
+    notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
+    notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
   
     closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
     iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
@@ -901,6 +898,9 @@ public class BasicInternalFrameTitlePane extends JComponent
    */
   protected void paintTitleBackground(Graphics g)
   {
+    if (!isOpaque())
+      return;
+
     Color saved = g.getColor();
     Dimension dims = getSize();
 
index 3393299..2d66645 100644 (file)
@@ -703,12 +703,17 @@ public class BasicListUI extends ListUI
    */
   protected int getRowHeight(int row)
   {
-    if (row < 0 || row >= cellHeights.length)
-      return -1;
-    else if (cellHeight != -1)
-      return cellHeight;
+    int height;
+    if (cellHeights == null)
+      height = cellHeight;
     else
-      return cellHeights[row];
+      {
+        if (row < 0 || row >= cellHeights.length)
+          height = -1;
+        else
+          height = cellHeights[row];
+      }
+    return height;
   }
 
   /**
@@ -803,9 +808,7 @@ public class BasicListUI extends ListUI
 
     // If a fixed cell height is set, then we can work more efficient.
     if (cellHeight > 0)
-      {
-        index = Math.max(y0 / cellHeight, index);
-      }
+      index = Math.min(y0 / cellHeight, index);
     // If we have no fixed cell height, we must add up each cell height up
     // to y0.
     else
@@ -992,8 +995,7 @@ public class BasicListUI extends ListUI
    */
   protected void installKeyboardActions()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    InputMap focusInputMap = (InputMap)defaults.get("List.focusInputMap");
+    InputMap focusInputMap = (InputMap) UIManager.get("List.focusInputMap");
     InputMapUIResource parentInputMap = new InputMapUIResource();
     // FIXME: The JDK uses a LazyActionMap for parentActionMap
     ActionMap parentActionMap = new ActionMapUIResource();
index 8ebe650..13c78ad 100644 (file)
@@ -1159,7 +1159,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
       "Tree.hash", new ColorUIResource(new Color(128, 128, 128)),
       "Tree.leftChildIndent", new Integer(7),
       "Tree.rightChildIndent", new Integer(13),
-      "Tree.rowHeight", new Integer(16),
+      "Tree.rowHeight", new Integer(0),
       "Tree.scrollsOnExpand", Boolean.TRUE,
       "Tree.selectionBackground", new ColorUIResource(Color.black),
       "Tree.nonSelectionBackground", new ColorUIResource(new Color(255, 255, 255)),
index 2a3556a..c8754a3 100644 (file)
@@ -475,7 +475,6 @@ public class BasicMenuItemUI extends MenuItemUI
     
     menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
     menuItem.setHorizontalAlignment(SwingConstants.LEADING);
-    menuItem.setOpaque(true);
   }
 
   /**
@@ -553,11 +552,20 @@ public class BasicMenuItemUI extends MenuItemUI
    */
   protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
   {
-    Dimension size = getPreferredSize(menuItem);
-    Color foreground = g.getColor();
-    g.setColor(bgColor);
-    g.drawRect(0, 0, size.width, size.height);
-    g.setColor(foreground);
+    // Menu item is considered to be highlighted when it is selected.
+    // But we don't want to paint the background of JCheckBoxMenuItems
+    ButtonModel mod = menuItem.getModel();
+    if ((menuItem.isSelected() && checkIcon == null) || (mod != null && 
+        mod.isArmed())
+        && (menuItem.getParent() instanceof MenuElement))
+      {
+        if (menuItem.isContentAreaFilled())
+          {
+            g.setColor(selectionBackground);
+            g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
+          }
+      }
+
   }
 
   /**
@@ -612,28 +620,6 @@ public class BasicMenuItemUI extends MenuItemUI
     br.width += insets.right + insets.left;
     br.height += insets.top + insets.bottom;
 
-    // Menu item is considered to be highlighted when it is selected.
-    // But we don't want to paint the background of JCheckBoxMenuItems
-    ButtonModel mod = m.getModel();
-    if ((m.isSelected() && checkIcon == null) || (mod != null && 
-        mod.isArmed())
-        && (m.getParent() instanceof MenuElement))
-      {
-        if (m.isContentAreaFilled())
-          {
-            g.setColor(selectionBackground);
-            g.fillRect(br.x, br.y, br.width, br.height);
-          }
-      }
-    else
-      {
-        if (m.isContentAreaFilled())
-          {
-            g.setColor(m.getBackground());
-            g.fillRect(br.x, br.y, br.width, br.height);
-          }
-      }
-
     // If this menu item is a JCheckBoxMenuItem then paint check icon
     if (checkIcon != null)
       {
index 827cbb0..e638b68 100644 (file)
@@ -211,7 +211,6 @@ public class BasicMenuUI extends BasicMenuItemUI
     selectionForeground = UIManager.getColor("Menu.selectionForeground");
     arrowIcon = UIManager.getIcon("Menu.arrowIcon");
     oldBorderPainted = UIManager.getBoolean("Menu.borderPainted");
-    menuItem.setOpaque(true);
   }
 
   /**
index 88d949b..d367466 100644 (file)
@@ -212,6 +212,8 @@ public class BasicProgressBarUI extends ProgressBarUI
 
   /**
    * Holds the value of the bouncing box that is returned by {@link #getBox}.
+   *
+   * @since 1.5
    */ 
   protected Rectangle boxRect;
 
index f3698e8..66e5380 100644 (file)
@@ -48,7 +48,6 @@ import javax.swing.AbstractButton;
 import javax.swing.Icon;
 import javax.swing.JComponent;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 
@@ -122,8 +121,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
    */
   public Icon getDefaultIcon()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    return defaults.getIcon(getPropertyPrefix() + "icon");
+    return UIManager.getIcon(getPropertyPrefix() + "icon");
   }
 
   /**
index 2f5eaf3..a2f5b82 100644 (file)
@@ -62,7 +62,6 @@ import javax.swing.LookAndFeel;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -501,14 +500,12 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
    */
   protected void configureScrollBarColors()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
-    trackColor = defaults.getColor("ScrollBar.track");
-    trackHighlightColor = defaults.getColor("ScrollBar.trackHighlight");
-    thumbColor = defaults.getColor("ScrollBar.thumb");
-    thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
-    thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
-    thumbLightShadowColor = defaults.getColor("ScrollBar.thumbShadow");
+    trackColor = UIManager.getColor("ScrollBar.track");
+    trackHighlightColor = UIManager.getColor("ScrollBar.trackHighlight");
+    thumbColor = UIManager.getColor("ScrollBar.thumb");
+    thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
+    thumbDarkShadowColor = UIManager.getColor("ScrollBar.thumbDarkShadow");
+    thumbLightShadowColor = UIManager.getColor("ScrollBar.thumbShadow");
   }
 
   /**
@@ -660,11 +657,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
        width += decrButton.getPreferredSize().getWidth();
 
        width += (scrollbar.getMaximum() - scrollbar.getMinimum());
-
-       height = Math.max(incrButton.getPreferredSize().height,
-                         decrButton.getPreferredSize().height);
-       height = Math.max(getMinimumThumbSize().height, height);
-       height = Math.min(getMaximumThumbSize().height, height);
+       height = UIManager.getInt("ScrollBar.width");
       }
     else
       {
@@ -672,11 +665,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
        height += decrButton.getPreferredSize().getHeight();
 
        height += (scrollbar.getMaximum() - scrollbar.getMinimum());
-
-       width = Math.max(incrButton.getPreferredSize().width,
-                        decrButton.getPreferredSize().width);
-       width = Math.max(getMinimumThumbSize().width, width);
-       width = Math.min(getMaximumThumbSize().width, width);
+       width = UIManager.getInt("ScrollBar.width");
       }
 
     Insets insets = scrollbar.getInsets();
index 746f628..cf31e8b 100644 (file)
@@ -126,14 +126,14 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       int i = 0;
       if (place == null)
-       i = 2;
+        i = 2;
       else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT))
-       i = 0;
+        i = 0;
       else if (place.equals(JSplitPane.BOTTOM)
                || place.equals(JSplitPane.RIGHT))
-       i = 1;
+        i = 1;
       else
-       throw new IllegalArgumentException("Illegal placement in JSplitPane");
+        throw new IllegalArgumentException("Illegal placement in JSplitPane");
       components[i] = component;
       resetSizeAt(i);
       splitPane.revalidate();
@@ -164,7 +164,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
     protected int getInitialLocation(Insets insets)
     {
       if (insets != null)
-       return insets.left;
+        return insets.left;
       return 0;
     }
 
@@ -205,7 +205,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       Dimension dims = c.getPreferredSize();
       if (dims != null)
-       return dims.width;
+        return dims.width;
       return 0;
     }
 
@@ -250,23 +250,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (container instanceof JSplitPane)
         {
-         JSplitPane split = (JSplitPane) container;
-         distributeExtraSpace();
-         Insets insets = split.getInsets();
-         int width = getInitialLocation(insets);
-         Dimension dims = split.getSize();
-         for (int i = 0; i < components.length; i += 2)
-           {
-             if (components[i] == null)
-               continue;
-             setComponentToSize(components[i], sizes[i], width, insets, dims);
-             width += sizes[i];
-           }
-         if (components[1] != null)
-           {
-             setComponentToSize(components[1], sizes[1], width, insets, dims);
-             width += sizes[1];
-           }
+          JSplitPane split = (JSplitPane) container;
+          distributeExtraSpace();
+          Insets insets = split.getInsets();
+          int width = getInitialLocation(insets);
+          Dimension dims = split.getSize();
+          for (int i = 0; i < components.length; i += 2)
+            {
+              if (components[i] == null)
+                continue;
+              setComponentToSize(components[i], sizes[i], width, insets, dims);
+              width += sizes[i];
+            }
+          if (components[1] != null)
+            {
+              setComponentToSize(components[1], sizes[1], width, insets, dims);
+              width += sizes[1];
+            }
         }
     }
 
@@ -297,23 +297,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (target instanceof JSplitPane)
         {
-         JSplitPane split = (JSplitPane) target;
-         Insets insets = target.getInsets();
-
-         int height = 0;
-         int width = 0;
-         for (int i = 0; i < components.length; i++)
-           {
-             if (components[i] == null)
-               continue;
-             Dimension dims = components[i].getMinimumSize();
-             if (dims != null)
-               {
-                 width += dims.width;
-                 height = Math.max(height, dims.height);
-               }
-           }
-         return new Dimension(width, height);
+          JSplitPane split = (JSplitPane) target;
+          Insets insets = target.getInsets();
+
+          int height = 0;
+          int width = 0;
+          for (int i = 0; i < components.length; i++)
+            {
+              if (components[i] == null)
+                continue;
+              Dimension dims = components[i].getMinimumSize();
+              if (dims != null)
+                {
+                  width += dims.width;
+                  height = Math.max(height, dims.height);
+                }
+            }
+          return new Dimension(width, height);
         }
       return null;
     }
@@ -331,24 +331,24 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (target instanceof JSplitPane)
         {
-         JSplitPane split = (JSplitPane) target;
-         Insets insets = target.getInsets();
-
-         int height = 0;
-         int width = 0;
-         for (int i = 0; i < components.length; i++)
-           {
-             if (components[i] == null)
-               continue;
-             Dimension dims = components[i].getPreferredSize();
-             if (dims != null)
-               {
-                 width += dims.width;
-                 if (! (components[i] instanceof BasicSplitPaneDivider))
-                   height = Math.max(height, dims.height);
-               }
-           }
-         return new Dimension(width, height);  
+          JSplitPane split = (JSplitPane) target;
+          Insets insets = target.getInsets();
+
+          int height = 0;
+          int width = 0;
+          for (int i = 0; i < components.length; i++)
+            {
+              if (components[i] == null)
+                continue;
+              Dimension dims = components[i].getPreferredSize();
+              if (dims != null)
+                {
+                  width += dims.width;
+                  if (!(components[i] instanceof BasicSplitPaneDivider))
+                    height = Math.max(height, dims.height);
+                }
+            }
+          return new Dimension(width, height);
         }
       return null;
     }
@@ -362,11 +362,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       for (int i = 0; i < components.length; i++)
         {
-         if (component == components[i])
-           {
-             components[i] = null;
-             sizes[i] = 0;
-           }
+          if (component == components[i])
+            {
+              components[i] = null;
+              sizes[i] = 0;
+            }
         }
     }
 
@@ -378,7 +378,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
     protected void resetSizeAt(int index)
     {
       if (components[index] != null)
-       sizes[index] = getPreferredSizeOfComponent(components[index]);
+        sizes[index] = getPreferredSizeOfComponent(components[index]);
     }
 
     /**
@@ -387,7 +387,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
     public void resetToPreferredSizes()
     {
       for (int i = 0; i < components.length; i++)
-       resetSizeAt(i);
+        resetSizeAt(i);
     }
 
     /**
@@ -433,13 +433,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
 
       if (left != null)
         {
-         components[0] = left;
-         resetSizeAt(0);
+          components[0] = left;
+          resetSizeAt(0);
         }
       if (right != null)
         {
-         components[1] = right;
-         resetSizeAt(1);
+          components[1] = right;
+          resetSizeAt(1);
         }
       components[2] = divider;
       resetSizeAt(2);
@@ -480,9 +480,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       Dimension dims = components[index].getMinimumSize();
       if (dims != null)
-       return dims.width;
+        return dims.width;
       else
-       return 0;
+        return 0;
     }
   } //end BasicHorizontalLayoutManager
 
@@ -534,7 +534,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       Dimension dims = c.getPreferredSize();
       if (dims != null)
-       return dims.height;
+        return dims.height;
       return 0;
     }
 
@@ -563,23 +563,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (container instanceof JSplitPane)
         {
-         JSplitPane split = (JSplitPane) container;
-         Insets insets = container.getInsets();
-
-         int height = 0;
-         int width = 0;
-         for (int i = 0; i < components.length; i++)
-           {
-             if (components[i] == null)
-               continue;
-             Dimension dims = components[i].getMinimumSize();
-             if (dims != null)
-               {
-                 height += dims.height;
-                 width = Math.max(width, dims.width);
-               }
-           }
-         return new Dimension(width, height);
+          JSplitPane split = (JSplitPane) container;
+          Insets insets = container.getInsets();
+
+          int height = 0;
+          int width = 0;
+          for (int i = 0; i < components.length; i++)
+            {
+              if (components[i] == null)
+                continue;
+              Dimension dims = components[i].getMinimumSize();
+              if (dims != null)
+                {
+                  height += dims.height;
+                  width = Math.max(width, dims.width);
+                }
+            }
+          return new Dimension(width, height);
         }
       return null;
     }
@@ -597,23 +597,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (container instanceof JSplitPane)
         {
-         JSplitPane split = (JSplitPane) container;
-         Insets insets = container.getInsets();
-
-         int height = 0;
-         int width = 0;
-         for (int i = 0; i < components.length; i++)
-           {
-             if (components[i] == null)
-               continue;
-             Dimension dims = components[i].getPreferredSize();
-             if (dims != null)
-               {
-                 height += dims.height;
-                 width = Math.max(width, dims.width);
-               }
-           }
-         return new Dimension(width, height);
+          JSplitPane split = (JSplitPane) container;
+          Insets insets = container.getInsets();
+
+          int height = 0;
+          int width = 0;
+          for (int i = 0; i < components.length; i++)
+            {
+              if (components[i] == null)
+                continue;
+              Dimension dims = components[i].getPreferredSize();
+              if (dims != null)
+                {
+                  height += dims.height;
+                  width = Math.max(width, dims.width);
+                }
+            }
+          return new Dimension(width, height);
         }
       return null;
     }
@@ -652,9 +652,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       Dimension dims = components[index].getMinimumSize();
       if (dims != null)
-       return dims.height;
+        return dims.height;
       else
-       return 0;
+        return 0;
     }
   }
 
@@ -813,27 +813,27 @@ public class BasicSplitPaneUI extends SplitPaneUI
     {
       if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY))
         {
-         int newSize = splitPane.getDividerSize();
-         int[] tmpSizes = layoutManager.getSizes();
-         dividerSize = tmpSizes[2];
-      int newSpace = newSize - tmpSizes[2];
-         tmpSizes[2] = newSize;
-
-         tmpSizes[0] += newSpace / 2;
-         tmpSizes[1] += newSpace / 2;
+          int newSize = splitPane.getDividerSize();
+          int[] tmpSizes = layoutManager.getSizes();
+          dividerSize = tmpSizes[2];
+          int newSpace = newSize - tmpSizes[2];
+          tmpSizes[2] = newSize;
+
+          tmpSizes[0] += newSpace / 2;
+          tmpSizes[1] += newSpace / 2;
       
-         layoutManager.setSizes(tmpSizes);
+          layoutManager.setSizes(tmpSizes);
         }
       else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))
         {
-         int max = layoutManager.getAvailableSize(splitPane.getSize(),
-                                                  splitPane.getInsets());
-         int dividerLoc = getDividerLocation(splitPane);
-         double prop = ((double) dividerLoc) / max;
-
-         resetLayoutManager();
-         if (prop <= 1 && prop >= 0)
-           splitPane.setDividerLocation(prop);
+          int max = layoutManager.getAvailableSize(splitPane.getSize(),
+                                                   splitPane.getInsets());
+          int dividerLoc = getDividerLocation(splitPane);
+          double prop = ((double) dividerLoc) / max;
+
+          resetLayoutManager();
+          if (prop <= 1 && prop >= 0)
+            splitPane.setDividerLocation(prop);
         }
       layoutManager.layoutContainer(splitPane);
       splitPane.repaint();
@@ -843,13 +843,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
       // Don't have to deal with resize_weight (as there
       // will be no extra space associated with this
       // event - the changes to the weighting will
-      // be taken into account the next time the 
+      // be taken into account the next time the
       // sizes change.)
-      // Don't have to deal with divider_location 
+      // Don't have to deal with divider_location
       // The method in JSplitPane calls our setDividerLocation
       // so we'll know about those anyway.
       // Don't have to deal with last_divider_location
-      // Although I'm not sure why, it doesn't seem to 
+      // Although I'm not sure why, it doesn't seem to
       // have any effect on Sun's JSplitPane.
       // one_touch_expandable changes are dealt with
       // by our divider.
@@ -962,10 +962,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
   {
     if (c instanceof JSplitPane)
       {
-       splitPane = (JSplitPane) c;
-       installDefaults();
-       installListeners();
-       installKeyboardActions();
+        splitPane = (JSplitPane) c;
+        installDefaults();
+        installListeners();
+        installKeyboardActions();
       }
   }
 
@@ -1218,8 +1218,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
   {
     if (nonContinuousLayoutDivider == null)
       {
-       nonContinuousLayoutDivider = new Canvas();
-       nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY);
+        nonContinuousLayoutDivider = new Canvas();
+        nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY);
       }
     return nonContinuousLayoutDivider;
   }
@@ -1300,12 +1300,14 @@ public class BasicSplitPaneUI extends SplitPaneUI
   {
     location = validLocation(location);
     Container p = jc.getParent();
-    Dimension rightPrefSize = jc.getRightComponent().getPreferredSize();
+    Component right = jc.getRightComponent();
+    Dimension rightPrefSize = right == null ? new Dimension(0, 0)
+                                           : right.getPreferredSize();
     Dimension size = jc.getSize();
     // check if the size has been set for the splitpane
     if (size.width == 0 && size.height == 0)
       size = jc.getPreferredSize();
-    
+
     if (getOrientation() == 0 && location > size.height)
       {
         location = size.height;
@@ -1324,11 +1326,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
             p = p.getParent();
           }
       }
-    
+
     setLastDragLocation(getDividerLocation(splitPane));
     splitPane.setLastDividerLocation(getDividerLocation(splitPane));
     int[] tmpSizes = layoutManager.getSizes();
-    tmpSizes[0] = location 
+    tmpSizes[0] = location
                   - layoutManager.getInitialLocation(splitPane.getInsets());
     tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),
                                                  splitPane.getInsets())
@@ -1483,19 +1485,21 @@ public class BasicSplitPaneUI extends SplitPaneUI
    */
   protected void startDragging()
   {
+    Component left = splitPane.getLeftComponent();
+    Component right = splitPane.getRightComponent();
     dividerSize = divider.getDividerSize();
     setLastDragLocation(-1);
 
-    if (! splitPane.getLeftComponent().isLightweight()
-        || ! splitPane.getRightComponent().isLightweight())
+    if ((left != null && !left.isLightweight())
+        || (right != null && !right.isLightweight()))
       draggingHW = true;
 
     if (splitPane.isContinuousLayout())
       nonContinuousLayoutDivider.setVisible(false);
     else
       {
-       nonContinuousLayoutDivider.setVisible(true);
-       nonContinuousLayoutDivider.setBounds(divider.getBounds());
+        nonContinuousLayoutDivider.setVisible(true);
+        nonContinuousLayoutDivider.setBounds(divider.getBounds());
       }
     splitPane.revalidate();
     splitPane.repaint();
@@ -1518,12 +1522,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
       splitPane.setDividerLocation(location);
     else
       {
-       Point p = nonContinuousLayoutDivider.getLocation();
-       if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
-         p.x = location;
-       else
-         p.y = location;
-       nonContinuousLayoutDivider.setLocation(p);
+        Point p = nonContinuousLayoutDivider.getLocation();
+        if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
+          p.x = location;
+        else
+          p.y = location;
+        nonContinuousLayoutDivider.setLocation(p);
       }
     setLastDragLocation(location);
     splitPane.repaint();
index 25a845b..0154439 100644 (file)
@@ -66,7 +66,6 @@ import javax.swing.JTextField;
 import javax.swing.KeyStroke;
 import javax.swing.ListSelectionModel;
 import javax.swing.LookAndFeel;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.event.ChangeEvent;
@@ -398,8 +397,7 @@ public class BasicTableUI extends TableUI
 
   protected void installKeyboardActions() 
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap");
+    InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap");
     InputMapUIResource parentInputMap = new InputMapUIResource();
     // FIXME: The JDK uses a LazyActionMap for parentActionMap
     ActionMap parentActionMap = new ActionMapUIResource();
index decbed5..a988c5a 100644 (file)
@@ -45,12 +45,9 @@ import javax.swing.JTextPane;
 import javax.swing.plaf.ColorUIResource;
 import javax.swing.UIDefaults;
 import javax.swing.plaf.ComponentUI;
-import javax.swing.text.Element;
-import javax.swing.text.PlainView;
 import javax.swing.text.Style;
 import javax.swing.text.StyleConstants;
 import javax.swing.text.StyleContext;
-import javax.swing.text.View;
 
 public class BasicTextPaneUI extends BasicEditorPaneUI
 {
@@ -64,11 +61,6 @@ public class BasicTextPaneUI extends BasicEditorPaneUI
     return new BasicTextPaneUI();
   }
 
-  public View create(Element elem)
-  {
-    return new PlainView(elem);
-  }
-
   /**
    * Returns the prefix for entries in the {@link UIDefaults} table.
    *
index b9de926..e8eeece 100644 (file)
@@ -58,7 +58,6 @@ import javax.swing.JComponent;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
@@ -618,13 +617,14 @@ public abstract class BasicTextUI extends TextUI
   protected Keymap createKeymap()
   {
     String prefix = getPropertyPrefix();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
     JTextComponent.KeyBinding[] bindings = 
-      (JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings");
+      (JTextComponent.KeyBinding[]) UIManager.get(prefix + ".keyBindings");
     if (bindings == null)
       {
         bindings = new JTextComponent.KeyBinding[0];
-        defaults.put(prefix + ".keyBindings", bindings);
+        // FIXME: Putting something into the defaults map is certainly wrong.
+        // Must be fixed somehow.
+        UIManager.put(prefix + ".keyBindings", bindings);
       }
 
     Keymap km = JTextComponent.addKeymap(getKeymapName(), 
@@ -661,17 +661,16 @@ public abstract class BasicTextUI extends TextUI
   InputMap getInputMap(int condition)
   {
     String prefix = getPropertyPrefix();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
     switch (condition)
       {
       case JComponent.WHEN_IN_FOCUSED_WINDOW:
         // FIXME: is this the right string? nobody seems to use it.
-        return (InputMap) defaults.get(prefix + ".windowInputMap"); 
+        return (InputMap) UIManager.get(prefix + ".windowInputMap"); 
       case JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
-        return (InputMap) defaults.get(prefix + ".ancestorInputMap");
+        return (InputMap) UIManager.get(prefix + ".ancestorInputMap");
       default:
       case JComponent.WHEN_FOCUSED:
-        return (InputMap) defaults.get(prefix + ".focusInputMap");
+        return (InputMap) UIManager.get(prefix + ".focusInputMap");
       }
   }
 
@@ -685,12 +684,14 @@ public abstract class BasicTextUI extends TextUI
   ActionMap getActionMap()
   {
     String prefix = getPropertyPrefix();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();    
-    ActionMap am = (ActionMap) defaults.get(prefix + ".actionMap");
+    ActionMap am = (ActionMap) UIManager.get(prefix + ".actionMap");
     if (am == null)
       {
         am = createActionMap();
-        defaults.put(prefix + ".actionMap", am);
+        // FIXME: Putting something in the UIDefaults map is certainly wrong.
+        // However, the whole method seems wrong and must be replaced by
+        // something that is less wrong.
+        UIManager.put(prefix + ".actionMap", am);
       }
     return am;
   }
index ef4ed83..7bf2a4a 100644 (file)
@@ -404,6 +404,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
     boolean tmp = ((loc == SwingConstants.NORTH)
                   || (loc == SwingConstants.SOUTH) || (loc == -1));
 
+    cachedOrientation = toolBar.getOrientation();
+    cachedBounds = toolBar.getSize();
     if (((cachedOrientation == SwingConstants.HORIZONTAL) && tmp)
         || ((cachedOrientation == VERTICAL) && ! tmp))
       {
@@ -571,9 +573,6 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
 
     dragWindow = createDragWindow(toolBar);
 
-    cachedBounds = toolBar.getPreferredSize();
-    cachedOrientation = toolBar.getOrientation();
-
     nonRolloverBorder = createNonRolloverBorder();
     rolloverBorder = createRolloverBorder();
 
index e967cd4..2d54983 100644 (file)
@@ -81,7 +81,6 @@ import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.event.CellEditorListener;
 import javax.swing.event.ChangeEvent;
@@ -239,14 +238,14 @@ public class BasicTreeUI extends TreeUI
   /** Boolean to keep track of editing. */
   boolean isEditing;
   
-  /** The bounds of the current cell. */
-  Rectangle bounds;
-  
   /** The current path of the visible nodes in the tree. */
   TreePath currentVisiblePath;
   
   /** The gap between the icon and text. */
   int gap = 4;
+  
+  /** Default row height, if none was set. */
+  int rowHeight = 20;
 
   /** Listeners */
   private PropertyChangeListener propertyChangeListener;
@@ -304,7 +303,7 @@ public class BasicTreeUI extends TreeUI
    */
   protected Color getHashColor()
   {
-    return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");
+    return UIManager.getColor("Tree.hash");
   }
 
   /**
@@ -315,8 +314,8 @@ public class BasicTreeUI extends TreeUI
    */
   protected void setHashColor(Color color)
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    defaults.put("Tree.hash", color);
+    // FIXME: Putting something in the UIDefaults map is certainly wrong.
+    UIManager.put("Tree.hash", color);
   }
 
   /**
@@ -437,6 +436,8 @@ public class BasicTreeUI extends TreeUI
    */
   protected void setRowHeight(int rowHeight)
   {
+    if (rowHeight == 0)
+      rowHeight = this.rowHeight;
     treeState.setRowHeight(rowHeight);
   }
 
@@ -624,21 +625,19 @@ public class BasicTreeUI extends TreeUI
    */
   public Rectangle getPathBounds(JTree tree, TreePath path)
   {
+    Rectangle bounds = null;
+    int row = -1;
+    Object cell = null;
     if (path != null)
       {
-        Object cell = path.getLastPathComponent();
-
-        if (treeModel != null)
-          {
-            Object root = treeModel.getRoot();
-
-            if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
-              root = getNextNode(root);
-            Point loc = getCellLocation(0, 0, tree, treeModel, cell, root);
-            return getCellBounds(loc.x, loc.y, cell);
-          }
+        row = getRowForPath(tree, path);
+        cell = path.getLastPathComponent();
+        bounds = new Rectangle(0, row * getRowHeight(), 0, 0);
       }
-    return null;
+    return nodeDimensions.getNodeDimensions(cell, row,
+                                            getLevel(cell),
+                                            tree.isExpanded(path),
+                                            bounds);
   }
 
   /**
@@ -700,7 +699,6 @@ public class BasicTreeUI extends TreeUI
    */
   public int getRowCount(JTree tree)
   {
-    updateCurrentVisiblePath();
     if (currentVisiblePath != null)
       return currentVisiblePath.getPathCount();
     return 0;
@@ -1035,7 +1033,9 @@ public class BasicTreeUI extends TreeUI
    */
   protected void uninstallKeyboardActions()
   {
-    // TODO: Implement this properly.
+    action = null;
+    tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(null);
+    tree.getActionMap().setParent(null);
   }
 
   /**
@@ -1227,7 +1227,7 @@ public class BasicTreeUI extends TreeUI
     rightChildIndent = UIManager.getInt("Tree.rightChildIndent");
     leftChildIndent = UIManager.getInt("Tree.leftChildIndent");
     setRowHeight(UIManager.getInt("Tree.rowHeight"));
-    tree.setRowHeight(UIManager.getInt("Tree.rowHeight"));
+    tree.setRowHeight(getRowHeight());
     tree.requestFocusInWindow(false);
     tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));
     setExpandedIcon(UIManager.getIcon("Tree.expandedIcon"));
@@ -1239,8 +1239,7 @@ public class BasicTreeUI extends TreeUI
    */
   protected void installKeyboardActions()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    InputMap focusInputMap = (InputMap) defaults.get("Tree.focusInputMap");
+    InputMap focusInputMap = (InputMap) UIManager.get("Tree.focusInputMap");
     InputMapUIResource parentInputMap = new InputMapUIResource();
     ActionMap parentActionMap = new ActionMapUIResource();
     action = new TreeAction();
@@ -1409,14 +1408,30 @@ public class BasicTreeUI extends TreeUI
     JTree tree = (JTree) c;
     if (currentVisiblePath == null)
       updateCurrentVisiblePath();
-    
-    if (currentVisiblePath != null && treeModel != null)
+
+    Rectangle clip = g.getClipBounds();
+    Insets insets = tree.getInsets();
+
+    if (clip != null && treeModel != null && currentVisiblePath != null)
       {
-        Object root = treeModel.getRoot();
-        paintRecursive(g, 0, 0, 0, tree, treeModel, root);
-        
-        if (hasControlIcons())
-          paintControlIcons(g, 0, 0, 0, tree, treeModel, root);
+        int startIndex = tree.getClosestRowForLocation(clip.x, clip.y);
+        int endIndex = tree.getClosestRowForLocation(clip.x + clip.width,
+                                                     clip.y + clip.height);
+
+        paintVerticalPartOfLeg(g, clip, insets, currentVisiblePath);
+        for (int i = startIndex; i <= endIndex; i++)
+          {
+            Object curr = currentVisiblePath.getPathComponent(i);
+            boolean isLeaf = treeModel.isLeaf(curr);
+            TreePath path = new TreePath(getPathToRoot(curr, 0));
+
+            boolean isExpanded = tree.isExpanded(path);
+            Rectangle bounds = getPathBounds(tree, path);
+            paintHorizontalPartOfLeg(g, clip, insets, bounds, path, i,
+                                     isExpanded, false, isLeaf);
+            paintRow(g, clip, insets, bounds, path, i, isExpanded, false,
+                     isLeaf);
+          }
       }
   }
 
@@ -1590,7 +1605,7 @@ public class BasicTreeUI extends TreeUI
     int y;
     if (event == null)
       {
-        bounds = getPathBounds(tree, path);
+        Rectangle bounds = getPathBounds(tree, path);
         x = bounds.x;
         y = bounds.y;
       }
@@ -1670,7 +1685,7 @@ public class BasicTreeUI extends TreeUI
     
     if (!isLeaf(row))
       {
-        bounds = getPathBounds(tree, path);
+        Rectangle bounds = getPathBounds(tree, path);
 
         if (hasControlIcons() && (mouseX < bounds.x) 
             && (mouseX > (bounds.x - getCurrentControlIcon(path).getIconWidth() - gap)))
@@ -1991,7 +2006,7 @@ public class BasicTreeUI extends TreeUI
     }
 
     /**
-     * Creats, if necessary, and starts a Timer to check if needed to resize the
+     * Creates, if necessary, and starts a Timer to check if needed to resize the
      * bounds
      */
     protected void startTimer()
@@ -2227,7 +2242,7 @@ public class BasicTreeUI extends TreeUI
 
       if (path != null)
         {
-          bounds = getPathBounds(tree, path);
+          Rectangle bounds = getPathBounds(tree, path);
           int row = getRowForPath(tree, path);
           boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
 
@@ -2268,6 +2283,7 @@ public class BasicTreeUI extends TreeUI
                   handleExpandControlClick(path, click.x, click.y);
                   if (cellEditor != null)
                     cellEditor.cancelCellEditing();
+                  tree.scrollPathToVisible(path);
                 }
               else if (tree.isEditable())
                 startEditing(path, e);
@@ -2451,9 +2467,12 @@ public class BasicTreeUI extends TreeUI
     }
 
     /**
-     * Responsible for getting the size of a particular node.
+     * Returns, by reference in bounds, the size and x origin to place value at. 
+     * The calling method is responsible for determining the Y location. 
+     * If bounds is null, a newly created Rectangle should be returned, 
+     * otherwise the value should be placed in bounds and returned.
      * 
-     * @param value
+     * @param cell
      *          the value to be represented
      * @param row
      *          row being queried
@@ -2465,10 +2484,23 @@ public class BasicTreeUI extends TreeUI
      *          a Rectangle containing the size needed to represent value
      * @return containing the node dimensions, or null if node has no dimension
      */
-    public Rectangle getNodeDimensions(Object value, int row, int depth,
+    public Rectangle getNodeDimensions(Object cell, int row, int depth,
                                        boolean expanded, Rectangle size)
     {
-      return null;
+      if (size == null || cell == null)
+        return null;
+
+      String s = cell.toString();
+      Font f = tree.getFont();
+      FontMetrics fm = tree.getToolkit().getFontMetrics(f);
+
+      if (s != null)
+        {
+          size.x = getRowX(row, depth);
+          size.width = SwingUtilities.computeStringWidth(fm, s);
+          size.height = fm.getHeight();
+        }
+      return size;
     }
 
     /**
@@ -2478,7 +2510,9 @@ public class BasicTreeUI extends TreeUI
      */
     protected int getRowX(int row, int depth)
     {
-      return 0;
+      if (row == 0)
+        return 0;
+      return depth * rightChildIndent;
     }
   }// NodeDimensionsHandler
 
@@ -3057,241 +3091,6 @@ public class BasicTreeUI extends TreeUI
   }
 
   /**
-   * Returns the cell bounds for painting selected cells Package private for use
-   * in inner classes.
-   * 
-   * @param x
-   *          is the x location of the cell
-   * @param y
-   *          is the y location of the cell
-   * @param cell
-   *          is the Object to get the bounds for
-   * @returns Rectangle that represents the cell bounds
-   */
-  Rectangle getCellBounds(int x, int y, Object cell)
-  {
-    if (cell != null)
-      {
-        String s = cell.toString();
-        Font f = tree.getFont();
-        FontMetrics fm = tree.getToolkit().getFontMetrics(f);
-
-        if (s != null)
-            return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s),
-                               fm.getHeight());
-      }
-    return new Rectangle(x, y, 0, 0);
-  }
-
-  /**
-   * Retrieves the location of some node, recursively starting at from some
-   * node. Package private for use in inner classes.
-   * 
-   * @param x
-   *          is the starting x position, offset
-   * @param y
-   *          is the starting y position, offset
-   * @param tree
-   *          is the tree to traverse
-   * @param mod
-   *          is the TreeModel to use
-   * @param node
-   *          is the node to get the location for
-   * @param startNode
-   *          is the node to start searching from
-   * @return Point - the location of node
-   */
-  Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node,
-                        Object startNode)
-  {
-    int rowHeight = getRowHeight();
-    if (startNode == null || startNode.equals(node))
-      {
-        int level = getLevel(node);
-        if (level == 0)
-          return new Point(x, y);
-        if (!tree.isRootVisible() && 
-            tree.isExpanded(new TreePath(mod.getRoot())))
-          return new Point(x + ((level - 1) * rightChildIndent), y);
-        return new Point(x + (level * rightChildIndent), y);
-      }
-    return getCellLocation(x, y + rowHeight, tree, mod, node,
-                           getNextVisibleNode(startNode));
-  }
-
-  /**
-   * Recursively paints all elements of the tree Package private for use in
-   * inner classes.
-   * 
-   * @param g
-   *          the Graphics context in which to paint
-   * @param indentation
-   *          of the current object
-   * @param descent
-   *          is the number of elements drawn
-   * @param depth
-   *          is the depth of the current object in the tree
-   * @param tree
-   *          is the tree to draw to
-   * @param mod
-   *          is the TreeModel we are using to draw
-   * @param curr
-   *          is the current object to draw
-   * @return int - current descent of the tree
-   */
-  int paintRecursive(Graphics g, int indentation, int descent,
-                     int depth, JTree tree, TreeModel mod, Object curr)
-  {
-    Rectangle clip = tree.getVisibleRect();
-    if (indentation > clip.x + clip.width + rightChildIndent
-        || descent > clip.y + clip.height + getRowHeight())
-      return descent;
-
-    TreePath path = new TreePath(getPathToRoot(curr, 0));
-    int halfHeight = getRowHeight() / 2;
-    int halfWidth = rightChildIndent / 2;
-    int y0 = descent + halfHeight;
-    int heightOfLine = descent + halfHeight;
-    int row = getRowForPath(tree, path);
-    boolean isRootVisible = tree.isRootVisible();
-    boolean isExpanded = tree.isExpanded(path);
-    boolean isLeaf = mod.isLeaf(curr);
-    Rectangle bounds = getPathBounds(tree, path);
-    Object root = mod.getRoot();
-    
-    if (isLeaf)
-      {
-        paintRow(g, clip, null, bounds, path, row, true, false, true);
-        descent += getRowHeight();
-      }
-    else
-      {
-        if (depth > 0 || isRootVisible)
-          {
-            paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
-            descent += getRowHeight();
-            y0 += halfHeight;
-          }
-        
-        if (isExpanded)
-          {
-            int max = mod.getChildCount(curr);
-            for (int i = 0; i < max; i++)
-              {
-                Object child = mod.getChild(curr, i); 
-                boolean childVis = tree.isVisible(new TreePath
-                                                  (getPathToRoot(child, 0)));
-                int indent = indentation + rightChildIndent;
-                if (!isRootVisible && depth == 0)
-                  indent = 0;
-                else if (isRootVisible || 
-                    (!isRootVisible && !curr.equals(root)) && childVis)
-                  {
-                    g.setColor(getHashColor());
-                    heightOfLine = descent + halfHeight;
-                    paintHorizontalLine(g, (JComponent) tree, heightOfLine, 
-                      indentation + halfWidth, indentation + rightChildIndent);
-                  }
-
-                descent = paintRecursive(g, indent, descent, depth + 1,
-                                         tree, mod, child);
-              }
-          }
-      }
-
-    if (isExpanded)
-      if (y0 != heightOfLine
-          && (mod.getChildCount(curr) > 0 && 
-              tree.isVisible(new TreePath(getPathToRoot(mod.getChild
-                                                        (curr, 0), 0)))))
-        {
-          g.setColor(getHashColor());
-          paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0,
-                            heightOfLine);
-        }
-    return descent;
-  }
-  
-  /**
-   * Recursively paints all the control icons on the tree. Package private for
-   * use in inner classes.
-   * 
-   * @param g
-   *          the Graphics context in which to paint
-   * @param indentation
-   *          of the current object
-   * @param descent
-   *          is the number of elements drawn
-   * @param depth
-   *          is the depth of the current object in the tree
-   * @param tree
-   *          is the tree to draw to
-   * @param mod
-   *          is the TreeModel we are using to draw
-   * @param node
-   *          is the current object to draw
-   * @return int current descent of the tree
-   */
-  int paintControlIcons(Graphics g, int indentation, int descent,
-                        int depth, JTree tree, TreeModel mod,
-                        Object node)
-  {
-    int rowHeight = getRowHeight();
-    TreePath path = new TreePath(getPathToRoot(node, 0));
-    Icon icon = getCurrentControlIcon(path);
-       
-    Rectangle clip = tree.getVisibleRect();
-    if (indentation > clip.x + clip.width + rightChildIndent
-        || descent > clip.y + clip.height + getRowHeight())
-      return descent;
-   
-    if (mod.isLeaf(node))
-      descent += rowHeight;
-    else
-      {   
-        if (!node.equals(mod.getRoot()) && 
-            (tree.isRootVisible() || getLevel(node) != 1))
-          {
-            int width = icon.getIconWidth();
-            int height = icon.getIconHeight() + 2;
-            int posX = indentation - rightChildIndent;
-            int posY = descent;
-            if (width > rightChildIndent)
-              posX -= gap;
-            else posX += width/2;
-               
-            if (height < rowHeight)
-              posY += height/2;
-               
-            icon.paintIcon(tree, g, posX, posY);
-          }
-
-        if (depth > 0 || tree.isRootVisible())
-          descent += rowHeight;
-           
-        if (tree.isExpanded(path))
-          {
-            int max = 0;
-            if (!mod.isLeaf(node))
-              max = mod.getChildCount(node);
-               
-            for (int i = 0; i < max; i++)
-              {
-                int indent = indentation + rightChildIndent;
-                Object child = mod.getChild(node, i);
-                if (depth == 0 && !tree.isRootVisible())
-                  indent =  1;
-                if (tree.isVisible(new TreePath(getPathToRoot(child, 0))))
-                  descent = paintControlIcons(g, indent, descent, depth + 1,
-                                            tree, mod, child);
-              }
-          }
-      }
-   
-    return descent;
-  }
-
-  /**
    * Returns true if the LookAndFeel implements the control icons. Package
    * private for use in inner classes.
    * 
@@ -3376,7 +3175,6 @@ public class BasicTreeUI extends TreeUI
    */
   Object getPreviousVisibleNode(Object node)
   {
-    updateCurrentVisiblePath();
     if (currentVisiblePath != null)
       {
         Object[] nodes = currentVisiblePath.getPath();
@@ -3568,16 +3366,22 @@ public class BasicTreeUI extends TreeUI
   int getLevel(Object node)
   {
     int count = -1;
-    
+
     Object current = node;
 
-    do
+    if (treeModel != null)
       {
-        current = getParent(treeModel.getRoot(), current);
-        count++;
+        Object root = treeModel.getRoot();
+        if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
+          count--;
+        
+        do
+          {
+            current = getParent(root, current);
+            count++;
+          }
+        while (current != null);
       }
-    while (current != null);
-    
     return count;
   }
 
@@ -3598,6 +3402,8 @@ public class BasicTreeUI extends TreeUI
   protected void paintVerticalLine(Graphics g, JComponent c, int x, int top,
                                    int bottom)
   {
+    // FIXME: Check if drawing a dashed line or not.
+    g.setColor(getHashColor());
     g.drawLine(x, top, x, bottom);
   }
 
@@ -3618,6 +3424,8 @@ public class BasicTreeUI extends TreeUI
   protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left,
                                      int right)
   {
+    // FIXME: Check if drawing a dashed line or not.
+    g.setColor(getHashColor());
     g.drawLine(left, y, right, y);
   }
 
@@ -3633,14 +3441,19 @@ public class BasicTreeUI extends TreeUI
    * @param x
    *          is the center position in x-direction
    * @param y
-   *          is the center position in y-direction FIXME what to do if x <
-   *          (icon.width / 2). Same with y
+   *          is the center position in y-direction 
    */
   protected void drawCentered(Component c, Graphics g, Icon icon, int x, int y)
   {
-    int beginPositionX = x - icon.getIconWidth() / 2;
-    int beginPositionY = y - icon.getIconHeight() / 2;
-    icon.paintIcon(c, g, beginPositionX, beginPositionY);
+    x -= icon.getIconWidth() / 2;
+    y -= icon.getIconHeight() / 2;
+    
+    if (x < 0)
+      x = 0;
+    if (y < 0)
+      y = 0;
+    
+    icon.paintIcon(c, g, x, y);
   }
   
   /**
@@ -3653,6 +3466,7 @@ public class BasicTreeUI extends TreeUI
    */
   protected void drawDashedHorizontalLine(Graphics g, int y, int x1, int x2)
   {
+    g.setColor(getHashColor());
     for (int i = x1; i < x2; i += 2)
       g.drawLine(i, y, i + 1, y);
   }
@@ -3667,6 +3481,7 @@ public class BasicTreeUI extends TreeUI
    */
   protected void drawDashedVerticalLine(Graphics g, int x, int y1, int y2)
   {
+    g.setColor(getHashColor());
     for (int i = y1; i < y2; i += 2)
       g.drawLine(x, i, x, i + 1);
   }
@@ -3691,8 +3506,15 @@ public class BasicTreeUI extends TreeUI
                                     boolean isExpanded, boolean hasBeenExpanded,
                                     boolean isLeaf)
   {
-    if (treeModel != null && hasControlIcons())
-      paintControlIcons(g, 0, 0, 0, tree, treeModel, path.getLastPathComponent());
+    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf))
+      {
+        Icon icon = getCurrentControlIcon(path);
+        int iconW = icon.getIconWidth();
+        int x = bounds.x - rightChildIndent + iconW/2;
+        if (x + iconW > bounds.x)
+          x = bounds.x - rightChildIndent - gap;
+        icon.paintIcon(tree, g, x, bounds.y + bounds.height/2 - icon.getIconHeight()/2);
+      }
   }
 
   /**
@@ -3703,9 +3525,9 @@ public class BasicTreeUI extends TreeUI
    * @param g - the graphics configuration
    * @param clipBounds - 
    * @param insets - 
-   * @param bounds - bounds of expand control
-   * @param path - path to draw control for
-   * @param row - row to draw control for
+   * @param bounds - bounds of the cell
+   * @param path - path to draw leg for
+   * @param row - row to start drawing at
    * @param isExpanded - is the row expanded
    * @param hasBeenExpanded - has the row already been expanded
    * @param isLeaf - is the path a leaf
@@ -3716,7 +3538,9 @@ public class BasicTreeUI extends TreeUI
                                           boolean isExpanded, boolean hasBeenExpanded,
                                           boolean isLeaf)
   {
-    // FIXME: not implemented
+    if (row != 0)
+      paintHorizontalLine(g, tree, bounds.y + bounds.height/2, bounds.x - gap - 2,
+                          bounds.x);
   }
   
   /**
@@ -3731,7 +3555,24 @@ public class BasicTreeUI extends TreeUI
   protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds,
                                         Insets insets, TreePath path)
   {
-    // FIXME: not implemented
+    int max = tree.getVisibleRowCount();
+    for (int i = 0; i < max; i++)
+      {
+        Object curr = path.getPathComponent(i);
+        TreePath currPath = new TreePath(getPathToRoot(curr, 0));
+        int numChild = treeModel.getChildCount(curr);
+        if (numChild > 0 && tree.isExpanded(currPath))
+          {
+            Rectangle bounds = getPathBounds(tree, currPath);
+            Rectangle lastChildBounds = getPathBounds(tree, 
+                                        new TreePath(getPathToRoot(
+                                        treeModel.getChild(curr, numChild - 1), 
+                                        0)));
+            paintVerticalLine(g, tree, bounds.x + gap + 2, bounds.y + 
+                              bounds.height - 2, lastChildBounds.y + 
+                              lastChildBounds.height/2);
+          }
+      }
   }
 
   /**
@@ -3762,7 +3603,12 @@ public class BasicTreeUI extends TreeUI
       {
         if (!validCachedPreferredSize)
           updateCachedPreferredSize();
-        bounds.x += gap;
+        
+        
+        paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
+        
+        if (row != 0)
+          bounds.x += gap;
         bounds.width = preferredSize.width + bounds.x;
         
         if (editingComponent != null && editingPath != null && isEditing(tree)
@@ -3808,10 +3654,7 @@ public class BasicTreeUI extends TreeUI
                                              boolean isLeaf)
   {
     Object node = path.getLastPathComponent();
-    if (treeModel != null && (!isLeaf && !node.equals(treeModel.getRoot())) && 
-        (tree.isRootVisible() || getLevel(node) != 1))
-      return true;
-    return false;
+    return (!isLeaf && getLevel(node) != 0 && hasControlIcons());
   }
   
   /**
@@ -3824,24 +3667,28 @@ public class BasicTreeUI extends TreeUI
       return;
 
     Object next = treeModel.getRoot();
-    Rectangle bounds = getCellBounds(0, 0, next);
-    boolean rootVisible = isRootVisible();
+    TreePath rootPath = new TreePath(next);
+    Rectangle bounds = getPathBounds(tree, rootPath);
     
     // If root is not a valid size to be visible, or is
     // not visible and the tree is expanded, then the next node acts
     // as the root
-    if ((bounds.width == 0 && bounds.height == 0) || (!rootVisible
+    if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible()
         && tree.isExpanded(new TreePath(next))))
+      {
         next = getNextNode(next);
+        rootPath = new TreePath(next);
+      }
     
     Object root = next;
     TreePath current = null;
     while (next != null)
       {
         if (current == null)
-          current = new TreePath(next);
-        else 
-            current = current.pathByAddingChild(next);
+          current = rootPath;
+        else
+          current = current.pathByAddingChild(next);
+        
         do
           {
             TreePath path = new TreePath(getPathToRoot(next, 0));
@@ -3860,7 +3707,7 @@ public class BasicTreeUI extends TreeUI
                       {
                         next = getNextSibling(parent);
                         if (next == null)
-                          parent = getParent(treeModel.getRoot(), next);
+                          parent = getParent(root, parent);
                       }
                   }
               }
@@ -3870,9 +3717,7 @@ public class BasicTreeUI extends TreeUI
       }
 
     currentVisiblePath = current;
-    if (currentVisiblePath != null)
-      tree.setVisibleRowCount(currentVisiblePath.getPathCount());
-    else tree.setVisibleRowCount(0);
+    tree.setVisibleRowCount(getRowCount(tree));
 
     if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 &&
         currentVisiblePath != null)
index 4fa3b36..28143d5 100644 (file)
@@ -56,7 +56,6 @@ import javax.swing.JTextField;
 import javax.swing.JToggleButton;
 import javax.swing.JToolBar;
 import javax.swing.SwingConstants;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.border.AbstractBorder;
 import javax.swing.border.Border;
@@ -131,6 +130,82 @@ public class MetalBorders
     public void paintBorder(Component c, Graphics g, int x, int y, int w,
                             int h)
     {
+      // With the OceanTheme the button border is painted entirely different.
+      // However, I couldn't figure out how this is determined besides checking
+      // for instanceof OceanTheme. The button painting is definitely not
+      // influenced by a UI default property and it is definitely performed
+      // by the same Border class.
+      if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+        paintOceanButtonBorder(c, g, x, y, w, h);
+      else
+        {
+          ButtonModel bmodel = null;
+      
+          if (c instanceof AbstractButton)
+            bmodel = ((AbstractButton) c).getModel();
+
+          Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
+          Color shadow = MetalLookAndFeel.getControlShadow();
+          Color light = MetalLookAndFeel.getControlHighlight();
+          Color middle = MetalLookAndFeel.getControl();
+
+          if (c.isEnabled())
+            {
+              // draw dark border
+              g.setColor(darkShadow);
+              g.drawRect(x, y, w - 2, h - 2);
+
+              if (!bmodel.isPressed())
+                {
+                  // draw light border
+                  g.setColor(light);
+                  g.drawRect(x + 1, y + 1, w - 2, h - 2);
+
+                  // draw crossing pixels of both borders
+                  g.setColor(middle);
+                  g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
+                  g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
+                }
+              else
+                {
+                  // draw light border
+                  g.setColor(light);
+                  g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
+                  g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
+
+                  // draw shadow border
+                  g.setColor(middle);
+                  g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
+                  g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+                  // draw crossing pixels of both borders
+                  g.setColor(shadow);
+                  g.drawRect(x + 1, y + h - 2, 0, 0);
+                  g.drawRect(x + w - 2, y + 1, 0, 0);
+                }
+            }
+          else 
+            {
+              // draw disabled border
+              g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
+              g.drawRect(x, y, w - 2, h - 2);          
+            }
+        }
+    }
+
+    /**
+     * Paints the button border for the OceanTheme.
+     *
+     * @param c the button
+     * @param g the graphics context
+     * @param x the X coordinate of the upper left corner of the painting rect
+     * @param y the Y coordinate of the upper left corner of the painting rect
+     * @param w the width of the painting rect
+     * @param h the height of the painting rect
+     */
+    private void paintOceanButtonBorder(Component c, Graphics g, int x,
+                                        int y, int w, int h)
+    {
       ButtonModel bmodel = null;
       
       if (c instanceof AbstractButton)
@@ -138,44 +213,31 @@ public class MetalBorders
 
       Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
       Color shadow = MetalLookAndFeel.getControlShadow();
-      Color light = MetalLookAndFeel.getWhite();
+      Color light = MetalLookAndFeel.getControlHighlight();
       Color middle = MetalLookAndFeel.getControl();
 
       if (c.isEnabled())
-      {
-        // draw dark border
-        g.setColor(darkShadow);
-        g.drawRect(x, y, w - 2, h - 2);
-
-        if (!bmodel.isPressed())
-          {
-            // draw light border
-            g.setColor(light);
-            g.drawRect(x + 1, y + 1, w - 2, h - 2);
-
-            // draw crossing pixels of both borders
-            g.setColor(middle);
-            g.drawRect(x + 1, y + h - 2, 0, 0);
-            g.drawRect(x + w - 2, y + 1, 0, 0);
-          }
-        else
-          {
-            // draw light border
-            g.setColor(light);
-            g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
-            g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
-
-            // draw shadow border
-            g.setColor(middle);
-            g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
-            g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
-            // draw crossing pixels of both borders
-            g.setColor(shadow);
-            g.drawRect(x + 1, y + h - 2, 0, 0);
-            g.drawRect(x + w - 2, y + 1, 0, 0);
-          }
-      }
+        {
+          if (bmodel.isPressed())
+            {
+              // draw fat border
+              g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
+              g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+            }
+          else if (bmodel.isRollover())
+            {
+              g.setColor(shadow);
+              g.drawRect(x, y, w - 1, h - 1);
+              g.drawRect(x + 2, y + 2, w - 5, h - 5);
+              g.setColor(darkShadow);
+              g.drawRect(x + 1, y + 1, w - 3, h - 3);
+            }
+          else
+            {
+              g.setColor(darkShadow);
+              g.drawRect(x, y, w - 1, h - 1);
+            }
+        }
       else 
         {
           // draw disabled border
@@ -654,24 +716,23 @@ public class MetalBorders
         {
           JOptionPane pane = (JOptionPane) f.getContentPane();
           int type = pane.getMessageType();
-          UIDefaults defaults = UIManager.getLookAndFeelDefaults();
           if (type == JOptionPane.QUESTION_MESSAGE)
             {
-              Color bc = defaults.getColor(
+              Color bc = UIManager.getColor(
                   "OptionPane.questionDialog.border.background");
               if (bc != null)
                 g.setColor(bc);
             }
           if (type == JOptionPane.WARNING_MESSAGE)
             {
-              Color bc = defaults.getColor(
+              Color bc = UIManager.getColor(
                   "OptionPane.warningDialog.border.background");
               if (bc != null)
                 g.setColor(bc);              
             }
           else if (type == JOptionPane.ERROR_MESSAGE)
             {
-              Color bc = defaults.getColor(
+              Color bc = UIManager.getColor(
                   "OptionPane.errorDialog.border.background");
               if (bc != null)
                 g.setColor(bc);              
index 02c39c1..10e5111 100644 (file)
@@ -47,7 +47,7 @@ import java.awt.Rectangle;
 import javax.swing.AbstractButton;
 import javax.swing.JButton;
 import javax.swing.JComponent;
-import javax.swing.UIDefaults;
+import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.UIResource;
@@ -78,10 +78,9 @@ public class MetalButtonUI
   public MetalButtonUI()
   {
     super();
-    UIDefaults def = UIManager.getLookAndFeelDefaults();
-    focusColor = def.getColor(getPropertyPrefix() + "focus");
-    selectColor = def.getColor(getPropertyPrefix() + "select");
-    disabledTextColor = def.getColor(getPropertyPrefix() + "disabledText");
+    focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+    selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+    disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
   }
 
   /**
@@ -135,11 +134,8 @@ public class MetalButtonUI
   public void installDefaults(AbstractButton button)
   {
     super.installDefaults(button);
-    if (button.isRolloverEnabled())
-      {
-        if (button.getBorder() instanceof UIResource)
-          button.setBorder(MetalBorders.getRolloverBorder());
-      }
+    button.setRolloverEnabled(UIManager.getBoolean(
+                                            getPropertyPrefix() + "rollover"));
   }
     
   /**
@@ -148,8 +144,7 @@ public class MetalButtonUI
   public void uninstallDefaults(AbstractButton button) 
   {
     super.uninstallDefaults(button);
-    if (button.getBorder() instanceof UIResource)
-      button.setBorder(null);
+    button.setRolloverEnabled(false);
   }
 
   /**
@@ -230,4 +225,24 @@ public class MetalButtonUI
         g.drawString(text, textRect.x, textRect.y + fm.getAscent());
       }  
   }
+
+  /**
+   * If the property <code>Button.gradient</code> is set, then a gradient is
+   * painted as background, otherwise the normal superclass behaviour is
+   * called.
+   */
+  public void update(Graphics g, JComponent c)
+  {
+    AbstractButton b = (AbstractButton) c;
+    if (b.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null
+        && !b.getModel().isPressed() && b.isEnabled())
+      {
+        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+                                 SwingConstants.VERTICAL,
+                                 getPropertyPrefix() + "gradient");
+        paint(g, c);
+      }
+    else
+      super.update(g, c);
+  }
 }
index 6b9f31b..fb8280e 100644 (file)
@@ -44,6 +44,8 @@ import java.io.Serializable;
 
 import javax.swing.Icon;
 import javax.swing.JCheckBox;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
 import javax.swing.plaf.UIResource;
 
 /**
@@ -128,6 +130,9 @@ public class MetalCheckBoxIcon
    */
   public void paintIcon(Component c, Graphics g, int x, int y)
   {
+    if (UIManager.get("CheckBox.gradient") != null)
+      MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
+                               SwingConstants.VERTICAL, "CheckBox.gradient");
     border.paintBorder(c, g, x, y, getIconWidth(), getIconHeight());
     JCheckBox cb = (JCheckBox) c;
     if (cb.isSelected())
index 6f4fecc..bcb86e6 100644 (file)
@@ -52,6 +52,8 @@ import javax.swing.JInternalFrame;
 import javax.swing.JRadioButton;
 import javax.swing.JRadioButtonMenuItem;
 import javax.swing.JSlider;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
 import javax.swing.plaf.UIResource;
 
 
@@ -779,6 +781,10 @@ public class MetalIconFactory implements Serializable
      */
     public void paintIcon(Component c, Graphics g, int x, int y) 
     {
+      if (UIManager.get("RadioButton.gradient") != null)
+        MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
+                              SwingConstants.VERTICAL, "RadioButton.gradient");
+
       Color savedColor = g.getColor();
       JRadioButton b = (JRadioButton) c;
       
index 33eb349..2cf5f67 100644 (file)
@@ -55,7 +55,6 @@ import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
 
@@ -260,9 +259,8 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
     notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor();
     notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground();
     
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    paletteTitleHeight = defaults.getInt("InternalFrame.paletteTitleHeight");
-    paletteCloseIcon = defaults.getIcon("InternalFrame.paletteCloseIcon");
+    paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
+    paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
     minIcon = MetalIconFactory.getInternalFrameAltMaximizeIcon(16);
     
     title = new JLabel(frame.getTitle(), 
@@ -351,8 +349,14 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
   {
     Color savedColor = g.getColor();
     Rectangle b = SwingUtilities.getLocalBounds(this);
-    g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
-    g.fillRect(b.x, b.y, b.width, b.height);
+
+    if (UIManager.get("InternalFrame.activeTitleGradient") != null
+        && frame.isSelected())
+      {
+        MetalUtils.paintGradient(g, b.x, b.y, b.width, b.height,
+                                 SwingConstants.VERTICAL,
+                                 "InternalFrame.activeTitleGradient");
+      }
     MetalUtils.fillMetalPattern(this, g, b.x + 4, b.y + 2, b.width 
             - paletteCloseIcon.getIconWidth() - 13, b.height - 5,
             MetalLookAndFeel.getPrimaryControlHighlight(), 
@@ -393,6 +397,14 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
         g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
         
         // draw the metal pattern
+        if (UIManager.get("InternalFrame.activeTitleGradient") != null
+            && frame.isSelected())
+          {
+            MetalUtils.paintGradient(g, 0, 0, getWidth(), getHeight(),
+                                     SwingConstants.VERTICAL,
+                                     "InternalFrame.activeTitleGradient");
+          }
+
         Rectangle b = title.getBounds();
         int startX = b.x + b.width + 5;
         int endX = startX;
index e4eaa71..12b858e 100644 (file)
@@ -43,7 +43,6 @@ import java.awt.Graphics;
 
 import javax.swing.JComponent;
 import javax.swing.JLabel;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicGraphicsUtils;
@@ -83,22 +82,20 @@ public class MetalLabelUI
   
   /**
    * Draws the text for a disabled label, using the color defined in the 
-   * {@link UIDefaults} with the key <code>Label.disabledForeground</code>.
+   * {@link UIManager} defaults with the key
+   * <code>Label.disabledForeground</code>.
    * 
    * @param l  the label.
    * @param g  the graphics device.
    * @param s  the label text.
    * @param textX  the x-coordinate for the label.
    * @param textY  the y-coordinate for the label.
-   * 
-   * @see UIManager#getLookAndFeelDefaults()
    */
   protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
                                  int textY)
   {
     Color savedColor = g.getColor();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    g.setColor(defaults.getColor("Label.disabledForeground"));
+    g.setColor(UIManager.getColor("Label.disabledForeground"));
     int mnemIndex = l.getDisplayedMnemonicIndex();
     if (mnemIndex != -1)
       BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
index ec8014b..da01937 100644 (file)
@@ -693,6 +693,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
       "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
       "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
+      "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
       "PopupMenuSeparatorUI",
       "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
       "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
@@ -1162,7 +1163,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "Tree.line", getPrimaryControl(),
       "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
       "Tree.rightChildIndent", new Integer(13),
-      "Tree.rowHeight", new Integer(20),
+      "Tree.rowHeight", new Integer(0),
       "Tree.scrollsOnExpand", Boolean.TRUE,
       "Tree.selectionBackground", getTextHighlightColor(),
       "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
@@ -1201,4 +1202,13 @@ public class MetalLookAndFeel extends BasicLookAndFeel
     defaults.putDefaults(uiDefaults);
   }
 
+  /**
+   * Returns the current theme setting for the Metal L&amp;F.
+   *
+   * @return the current theme setting for the Metal L&amp;F
+   */
+  public static MetalTheme getCurrentTheme()
+  {
+    return theme;
+  }
 }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
new file mode 100644 (file)
index 0000000..31d8d67
--- /dev/null
@@ -0,0 +1,88 @@
+/* MetalMenuBarUI.java -- MenuBar UI for the Metal L&F
+   Copyright (C) 2005 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 javax.swing.plaf.metal;
+
+import java.awt.Graphics;
+
+import javax.swing.JComponent;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicMenuBarUI;
+
+/**
+ * A UI implementation for MenuBar in the Metal Look &amp; Feel.
+ * 
+ * @author Roman Kennke (kennke@aicas.com)
+ *
+ * @since 1.5
+ */
+public class MetalMenuBarUI extends BasicMenuBarUI
+{
+  /**
+   * Creates and returns a new instance of this UI for the specified component.
+   *
+   * @param c the component to create a UI for
+   *
+   * @return the UI for the component
+   */
+  public static ComponentUI createUI(JComponent c)
+  {
+    return new MetalMenuBarUI();
+  }
+
+
+  /**
+   * If the property <code>MenuBar.gradient</code> is set, then a gradient
+   * is painted as background, otherwise the normal superclass behaviour is
+   * called.
+   */
+  public void update(Graphics g, JComponent c)
+  {
+    if (c.isOpaque() && UIManager.get("MenuBar.gradient") != null)
+      {
+        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+                                 SwingConstants.VERTICAL, "MenuBar.gradient");
+        paint(g, c);
+      }
+    else
+      super.update(g, c);
+  }
+
+}
index f37626e..de71fe8 100644 (file)
@@ -46,7 +46,6 @@ import java.awt.Rectangle;
 import javax.swing.AbstractButton;
 import javax.swing.JComponent;
 import javax.swing.JRadioButton;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicRadioButtonUI;
@@ -96,10 +95,9 @@ public class MetalRadioButtonUI
   public void installDefaults(AbstractButton b)
   {
     super.installDefaults(b);
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    disabledTextColor = defaults.getColor("RadioButton.disabledText");
-    focusColor = defaults.getColor("RadioButton.focus");
-    selectColor = defaults.getColor("RadioButton.select");
+    disabledTextColor = UIManager.getColor("RadioButton.disabledText");
+    focusColor = UIManager.getColor("RadioButton.focus");
+    selectColor = UIManager.getColor("RadioButton.select");
   }
   
   /**
@@ -118,7 +116,7 @@ public class MetalRadioButtonUI
   /**
    * Returns the color used to fill the {@link JRadioButton}'s icon when the
    * button is pressed.  The default color is obtained from the 
-   * {@link UIDefaults} via an entry with the key 
+   * {@link UIManager} defaults via an entry with the key 
    * <code>RadioButton.select</code>.
    * 
    * @return The select color.
@@ -130,8 +128,8 @@ public class MetalRadioButtonUI
   
   /**
    * Returns the color for the {@link JRadioButton}'s text when the button is
-   * disabled.  The default color is obtained from the {@link UIDefaults} via 
-   * an entry with the key <code>RadioButton.disabledText</code>.
+   * disabled.  The default color is obtained from the {@link UIManager}
+   * defaults via an entry with the key <code>RadioButton.disabledText</code>.
    * 
    * @return The disabled text color.
    */
@@ -143,7 +141,7 @@ public class MetalRadioButtonUI
   /**
    * Returns the color used to draw the focus rectangle when the 
    * {@link JRadioButton} has the focus.  The default color is obtained from 
-   * the {@link UIDefaults} via an entry with the key 
+   * the {@link UIManager} defaults via an entry with the key 
    * <code>RadioButton.focus</code>.
    * 
    * @return The color used to draw the focus rectangle.
index 9602ade..0ff501f 100644 (file)
@@ -48,7 +48,6 @@ import java.beans.PropertyChangeListener;
 import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JScrollBar;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicScrollBarUI;
@@ -195,8 +194,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
    */
   protected JButton createDecreaseButton(int orientation)
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    scrollBarWidth = defaults.getInt("ScrollBar.width");
+    scrollBarWidth = UIManager.getInt("ScrollBar.width");
     decreaseButton = new MetalScrollButton(orientation, scrollBarWidth, 
             isFreeStanding);
     return decreaseButton;
@@ -213,8 +211,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
    */
   protected JButton createIncreaseButton(int orientation)
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    scrollBarWidth = defaults.getInt("ScrollBar.width");
+    scrollBarWidth = UIManager.getInt("ScrollBar.width");
     increaseButton = new MetalScrollButton(orientation, scrollBarWidth, 
             isFreeStanding);
     return increaseButton;
@@ -403,8 +400,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
       }
     
     // draw the shadow line
-    UIDefaults def = UIManager.getLookAndFeelDefaults();
-    g.setColor(def.getColor("ScrollBar.shadow"));
+    g.setColor(UIManager.getColor("ScrollBar.shadow"));
     g.drawLine(x + w, y + 1, x + w, y + h - 1);
 
   }
@@ -456,8 +452,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
       }
     
     // draw the shadow line
-    UIDefaults def = UIManager.getLookAndFeelDefaults();
-    g.setColor(def.getColor("ScrollBar.shadow"));
+    g.setColor(UIManager.getColor("ScrollBar.shadow"));
     g.drawLine(x + 1, y + h, x + w - 2, y + h);
   }
   
index b39fb23..dbcc091 100644 (file)
@@ -42,7 +42,6 @@ import java.awt.Color;
 
 import javax.swing.JComponent;
 import javax.swing.JSplitPane;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicSplitPaneDivider;
@@ -83,9 +82,8 @@ public class MetalSplitPaneUI extends BasicSplitPaneUI
    */
   public BasicSplitPaneDivider createDefaultDivider()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    Color light = defaults.getColor("SplitPane.highlight");
-    Color dark = defaults.getColor("SplitPane.darkShadow");
+    Color light = UIManager.getColor("SplitPane.highlight");
+    Color dark = UIManager.getColor("SplitPane.darkShadow");
     return new MetalSplitPaneDivider(this, light, dark);
   }
 }
index 46a19bd..0b56d59 100644 (file)
@@ -47,8 +47,8 @@ import java.awt.Rectangle;
 import javax.swing.AbstractButton;
 import javax.swing.JComponent;
 import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicButtonUI;
@@ -131,10 +131,9 @@ public class MetalToggleButtonUI
   public void installDefaults(AbstractButton b)
   {
     super.installDefaults(b);
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    focusColor = defaults.getColor(getPropertyPrefix() + "focus");
-    selectColor = defaults.getColor(getPropertyPrefix() + "select");
-    disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
+    focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+    selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+    disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
   }
   
   /**
@@ -200,5 +199,23 @@ public class MetalToggleButtonUI
     g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1);
     g.setColor(saved);    
   }
+
+  /**
+   * If the property <code>ToggleButton.gradient</code> is set, then a gradient
+   * is painted as background, otherwise the normal superclass behaviour is
+   * called.
+   */
+  public void update(Graphics g, JComponent c)
+  {
+    if (c.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null)
+      {
+        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+                                 SwingConstants.VERTICAL,
+                                 getPropertyPrefix() + "gradient");
+        paint(g, c);
+      }
+    else
+      super.update(g, c);
+  }
   
 }
index 5085d17..f183ed5 100644 (file)
@@ -56,7 +56,6 @@ import javax.swing.JToolTip;
 import javax.swing.KeyStroke;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.plaf.ComponentUI;
@@ -107,13 +106,12 @@ public class MetalToolTipUI
   public MetalToolTipUI()
   {
     super();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    activeBorder = defaults.getBorder("ToolTip.border");
-    inactiveBorder = defaults.getBorder("ToolTip.borderInactive");
-    isAcceleratorHidden = defaults.getBoolean("ToolTip.hideAccelerator");
-    acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
-    acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
-    acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
+    activeBorder = UIManager.getBorder("ToolTip.border");
+    inactiveBorder = UIManager.getBorder("ToolTip.borderInactive");
+    isAcceleratorHidden = UIManager.getBoolean("ToolTip.hideAccelerator");
+    acceleratorFont = UIManager.getFont("MenuItem.acceleratorFont");
+    acceleratorForeground = UIManager.getColor("MenuItem.acceleratorForeground");
+    acceleratorDelimiter = UIManager.getString("MenuItem.acceleratorDelimiter");
   }
 
   /**
index 0ffa0d1..24432a2 100644 (file)
@@ -41,24 +41,10 @@ package javax.swing.plaf.metal;
 import java.awt.Graphics;
 import java.awt.Insets;
 import java.awt.Rectangle;
-import java.awt.event.ComponentListener;
-import java.awt.event.FocusListener;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseListener;
-import java.beans.PropertyChangeListener;
-import java.util.Hashtable;
 
 import javax.swing.JComponent;
 import javax.swing.JTree;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
-import javax.swing.tree.TreeCellEditor;
-import javax.swing.tree.TreeModel;
 import javax.swing.tree.TreePath;
-import javax.swing.event.CellEditorListener;
-import javax.swing.event.TreeExpansionListener;
-import javax.swing.event.TreeModelListener;
-import javax.swing.event.TreeSelectionListener;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicTreeUI;
 
@@ -67,19 +53,6 @@ import javax.swing.plaf.basic.BasicTreeUI;
  */
 public class MetalTreeUI extends BasicTreeUI
 {
-
-  /** Listeners */
-  private PropertyChangeListener propertyChangeListener;
-  private FocusListener focusListener;
-  private TreeSelectionListener treeSelectionListener;
-  private MouseListener mouseListener;
-  private KeyListener keyListener;
-  private PropertyChangeListener selectionModelPropertyChangeListener;
-  private ComponentListener componentListener;
-  private CellEditorListener cellEditorListener;
-  private TreeExpansionListener treeExpansionListener;
-  private TreeModelListener treeModelListener;
-    
   /**
    * Constructs a new instance of <code>MetalTreeUI</code>.
    */
@@ -128,71 +101,8 @@ public class MetalTreeUI extends BasicTreeUI
    */
   public void installUI(JComponent c)
   {
-    tree = (JTree) c;
-    configureLayoutCache();
-    
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    tree.setFont(defaults.getFont("Tree.font"));
-    tree.setForeground(defaults.getColor("Tree.foreground"));
-    tree.setBackground(defaults.getColor("Tree.background"));
-    tree.setOpaque(true);
-    tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand"));
-    rightChildIndent = defaults.getInt("Tree.rightChildIndent");
-    leftChildIndent = defaults.getInt("Tree.leftChildIndent");
-    setRowHeight(defaults.getInt("Tree.rowHeight"));
-    tree.setRowHeight(defaults.getInt("Tree.rowHeight"));
-    tree.requestFocusInWindow(false);
-    
-    setExpandedIcon(defaults.getIcon("Tree.expandedIcon"));
-    setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon"));
-    
-    currentCellRenderer = createDefaultCellRenderer();
-    rendererPane = createCellRendererPane();
-    createdRenderer = true;
-    setCellEditor(createDefaultCellEditor());
-    createdCellEditor = true;
-    TreeModel mod = tree.getModel();
-    setModel(mod);
-
-    treeSelectionModel = tree.getSelectionModel();
-    drawingCache = new Hashtable();
-    nodeDimensions = createNodeDimensions();
-    
-    propertyChangeListener = createPropertyChangeListener();
-    focusListener = createFocusListener();
-    treeSelectionListener = createTreeSelectionListener();
-    mouseListener = createMouseListener();
-    keyListener = createKeyListener();
-    selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
-    componentListener = createComponentListener();
-    cellEditorListener = createCellEditorListener();
-    treeExpansionListener = createTreeExpansionListener();
-    treeModelListener = createTreeModelListener();
-
-    editingRow = -1;
-    lastSelectedRow = -1;
-    
-    installKeyboardActions();
-    
-    tree.addPropertyChangeListener(propertyChangeListener);
-    tree.addFocusListener(focusListener);
-    tree.addTreeSelectionListener(treeSelectionListener);
-    tree.addMouseListener(mouseListener);
-    tree.addKeyListener(keyListener);
-    tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
-    tree.addComponentListener(componentListener);
-    tree.addTreeExpansionListener(treeExpansionListener);
-    if (treeModel != null)
-      treeModel.addTreeModelListener(treeModelListener);
-    
-    if (mod != null)
-      {
-        TreePath path = new TreePath(mod.getRoot());
-        if (!tree.isExpanded(path))
-          toggleExpandState(path);
-      }
-    
-    completeUIInstall();
+    // TODO: What to do here, if anything?
+    super.installUI(c);
   }
   
   /**
@@ -212,31 +122,8 @@ public class MetalTreeUI extends BasicTreeUI
    */
   public void uninstallUI(JComponent c)
   {
-    tree.setFont(null);
-    tree.setForeground(null);
-    tree.setBackground(null);
-    
-    uninstallKeyboardActions();
-    
-    tree.removePropertyChangeListener(propertyChangeListener);
-    tree.removeFocusListener(focusListener);
-    tree.removeTreeSelectionListener(treeSelectionListener);
-    tree.removeMouseListener(mouseListener);
-    tree.removeKeyListener(keyListener);
-    tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
-    tree.removeComponentListener(componentListener);
-    tree.removeTreeExpansionListener(treeExpansionListener);
-
-    TreeCellEditor tce = tree.getCellEditor();
-    if (tce != null)
-      tce.removeCellEditorListener(cellEditorListener);
-    TreeModel tm = tree.getModel();
-    if (tm != null)
-      tm.removeTreeModelListener(treeModelListener);
-    
-    tree = null;
-    uninstallComponents();
-    completeUIUninstall();
+    // TODO: What to do here?
+    super.uninstallUI(c);
   }
   
   /**
index c0b4e65..50112ce 100644 (file)
@@ -44,6 +44,10 @@ import java.awt.Graphics2D;
 import java.awt.TexturePaint;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
+import java.util.List;
+
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
 
 /**
  * Some utility and helper methods for the Metal Look &amp; Feel.
@@ -151,4 +155,252 @@ class MetalUtils
     g.fillRect(3, 3, 1, 1);
     g.dispose();
   }
+
+  /**
+   * Paints the typical Metal gradient. See {@link #paintGradient(Graphics,
+   * int, int, int, int, double, double, Color, Color, Color, int)}
+   * for more details.
+   *
+   * The parameters are fetched from the UIManager using the key
+   * <code>uiProp</code>. The value is expected to be a {@link List} that
+   * contains 4 values: two {@link Double}s and 3 {@link Color} object that
+   * together make up the parameters passed to the painting method.
+   * 
+   * @param g the graphics context to use
+   * @param x the X coordinate of the upper left corner of the rectangle
+   * @param y the Y coordinate of the upper left corner of the rectangle
+   * @param w the width of the rectangle
+   * @param h the height of the rectangle
+   * @param dir the direction of the gradient, either
+   * @param uiProp the key of the UIManager property that has the parameters
+   */
+  static void paintGradient(Graphics g, int x, int y, int w, int h,
+                            int dir, String uiProp)
+  {
+    List params = (List) UIManager.get(uiProp);
+    double g1 = ((Double) params.get(0)).doubleValue();
+    double g2 = ((Double) params.get(1)).doubleValue();
+    Color c1 = (Color) params.get(2);
+    Color c2 = (Color) params.get(3);
+    Color c3 = (Color) params.get(4);
+    paintGradient(g, x, y, w, h, g1, g2, c1, c2, c3, dir);
+  }
+
+  /**
+   * Paints the typical Metal gradient. The gradient is painted as follows:
+   * <pre>
+   * 
+   * +-------+--------+--------+-----------------------------+
+   * |       |        |        |                             |
+   * +-------+--------+--------+-----------------------------+
+   * c1  ->  c2  --   c2  ->   c1         -------->          c3
+   * < -g1- > < -g2- > < -g1- >
+   * </pre>
+   * 
+   * There are 4 distinct areas in this gradient:
+   * <ol>
+   * <li>A gradient from color 1 to color 2 with the relative width specified
+   *   by <code>g1</code></li>
+   * <li>A solid area with the color 2 and the relative width specified by
+   *  <code>g2</code></li>
+   * <li>A gradient from color 2 to color 1 with the relative width specified
+   *   by <code>g1</code></li>
+   *
+   * @param g the graphics context to use
+   * @param x the X coordinate of the upper left corner of the rectangle
+   * @param y the Y coordinate of the upper left corner of the rectangle
+   * @param w the width of the rectangle
+   * @param h the height of the rectangle
+   * @param g1 the relative width of the c1->c2 gradients
+   * @param g2 the relative width of the c2 solid area
+   * @param c1 the color 1
+   * @param c2 the color 2
+   * @param c3 the color 3
+   * @param dir the direction of the gradient, either
+   *        {@link SwingConstants#HORIZONTAL} or {@link SwingConstants#VERTICAL}
+   */
+  static void paintGradient(Graphics g, int x, int y, int w, int h, double g1,
+                            double g2, Color c1, Color c2, Color c3, int dir)
+  {
+    if (dir == SwingConstants.HORIZONTAL)
+      paintHorizontalGradient(g, x, y, w, h, g1, g2, c1, c2, c3);
+    else
+      paintVerticalGradient(g, x, y, w, h, g1, g2, c1, c2, c3);
+  }
+
+  /**
+   * Paints a horizontal gradient. See {@link #paintGradient(Graphics, int,
+   * int, int, int, double, double, Color, Color, Color, int)} for details.
+   *
+   * @param x the X coordinate of the upper left corner of the rectangle
+   * @param y the Y coordinate of the upper left corner of the rectangle
+   * @param w the width of the rectangle
+   * @param h the height of the rectangle
+   * @param g1 the relative width of the c1->c2 gradients
+   * @param g2 the relative width of the c2 solid area
+   * @param c1 the color 1
+   * @param c2 the color 2
+   * @param c3 the color 3
+   */
+  static void paintHorizontalGradient(Graphics g, int x, int y, int w, int h,
+                                      double g1, double g2, Color c1, Color c2,
+                                      Color c3)
+  {
+    // Calculate the coordinates.
+    // The size of the first gradient area (c1->2).
+    int w1 = (int) (w * g1);
+    // The size of the solid c2 area.
+    int w2 = (int) (w * g2);
+    int x0 = x;
+    int x1 = x0 + w1;
+    int x2 = x1 + w2;
+    int x3 = x2 + w1;
+    int x4 = x + w;
+
+    // Paint first gradient area (c1->c2).
+    int xc; // The current y coordinate.
+    for (xc = x0; xc < x1; xc++)
+      {
+        if (xc > x + w)
+          break;
+
+        // Perform color interpolation;
+        double factor = (xc - x0) / (double) w1;
+        int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+        int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+            + c1.getGreen());
+        int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+            + c1.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(xc, y, xc, y + h);
+      }
+    // Paint solid c2 area.
+    g.setColor(c2);
+    g.fillRect(x1, y, x2 - x1, h);
+
+    // Paint second gradient area (c2->c1).
+    for (xc = x2; xc < x3; xc++)
+      {
+        if (xc > x + w)
+          break;
+
+        // Perform color interpolation;
+        double factor = (xc - x2) / (double) w1;
+        int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+        int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+            + c2.getGreen());
+        int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+            + c2.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(xc, y, xc, y + h);
+      }
+
+    // Paint third gradient area (c1->c3).
+    for (xc = x3; xc < x4; xc++)
+      {
+        if (xc > x + w)
+          break;
+
+        // Perform color interpolation;
+        double factor = (xc - x3) / (double) (x4 - x3);
+        int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+        int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+            + c1.getGreen());
+        int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+            + c1.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(xc, y, xc, y + h);
+      }
+  }
+
+  /**
+   * Paints a vertical gradient. See {@link #paintGradient(Graphics, int, int,
+   * int, int, double, double, Color, Color, Color, int)} for details.
+   *
+   * @param x the X coordinate of the upper left corner of the rectangle
+   * @param y the Y coordinate of the upper left corner of the rectangle
+   * @param w the width of the rectangle
+   * @param h the height of the rectangle
+   * @param g1 the relative width of the c1->c2 gradients
+   * @param g2 the relative width of the c2 solid area
+   * @param c1 the color 1
+   * @param c2 the color 2
+   * @param c3 the color 3
+   */
+  static void paintVerticalGradient(Graphics g, int x, int y, int w, int h,
+                                    double g1, double g2, Color c1, Color c2,
+                                    Color c3)
+  {
+    // Calculate the coordinates.
+    // The size of the first gradient area (c1->2).
+    int w1 = (int) (h * g1);
+    // The size of the solid c2 area.
+    int w2 = (int) (h * g2);
+    int y0 = y;
+    int y1 = y0 + w1;
+    int y2 = y1 + w2;
+    int y3 = y2 + w1;
+    int y4 = y + h;
+
+    // Paint first gradient area (c1->c2).
+    int yc; // The current y coordinate.
+    for (yc = y0; yc < y1; yc++)
+      {
+        if (yc > y + h)
+          break;
+
+        // Perform color interpolation;
+        double factor = (yc - y0) / (double) w1;
+        int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+        int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+            + c1.getGreen());
+        int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+            + c1.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(x, yc, x + w, yc);
+      }
+    // Paint solid c2 area.
+    g.setColor(c2);
+    g.fillRect(x, y1, w, y2 - y1);
+
+    // Paint second gradient area (c2->c1).
+    for (yc = y2; yc < y3; yc++)
+      {
+        if (yc > y + h)
+          break;
+
+        // Perform color interpolation;
+        double factor = (yc - y2) / (double) w1;
+        int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+        int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+            + c2.getGreen());
+        int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+            + c2.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(x, yc, x + w, yc);
+      }
+
+    // Paint third gradient area (c1->c3).
+    for (yc = y3; yc < y4; yc++)
+      {
+        if (yc > y + h)
+          break;
+
+        // Perform color interpolation;
+        double factor = (yc - y3) / (double) (y4 - y3);
+        int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+        int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+            + c1.getGreen());
+        int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+            + c1.getBlue());
+        Color interpolated = new Color(rInt, gInt, bInt);
+        g.setColor(interpolated);
+        g.drawLine(x, yc, x + w, yc);
+      }
+  }
 }
index 85a8cb1..f1886b1 100644 (file)
@@ -37,6 +37,9 @@ exception statement from your version. */
 
 package javax.swing.plaf.metal;
 
+import java.awt.Color;
+import java.util.Arrays;
+
 import javax.swing.UIDefaults;
 import javax.swing.plaf.ColorUIResource;
 
@@ -204,6 +207,37 @@ public class OceanTheme extends DefaultMetalTheme
    */
   public void addCustomEntriesToTable(UIDefaults defaults)
   {
+    defaults.put("Button.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
+      {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
+      new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
+    defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
+      {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
+       new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
+    defaults.put("Slider.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.2), new ColorUIResource(200, 221, 242),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+    defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
+      {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+       new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+
     defaults.put("Button.rollover", Boolean.TRUE);
   }
 }
index baf8608..a324425 100644 (file)
@@ -672,20 +672,8 @@ public abstract class AbstractDocument implements Document, Serializable
       new DefaultDocumentEvent(offset, length,
                               DocumentEvent.EventType.REMOVE);
     
-    // Here we set up the parameters for an ElementChange, if one
-    // needs to be added to the DocumentEvent later
-    Element root = getDefaultRootElement();
-    int start = root.getElementIndex(offset);
-    int end = root.getElementIndex(offset + length);
-    
-    Element[] removed = new Element[end - start + 1];
-    for (int i = start; i <= end; i++)
-      removed[i - start] = root.getElement(i);
-    
     removeUpdate(event);
 
-    Element[] added = new Element[1];
-    added[0] = root.getElement(start);
     boolean shouldFire = content.getString(offset, length).length() != 0;
     
     writeLock();
@@ -694,17 +682,6 @@ public abstract class AbstractDocument implements Document, Serializable
     
     postRemoveUpdate(event);
     
-    GapContent.UndoRemove changes = null;
-    if (content instanceof GapContent)
-      changes = (GapContent.UndoRemove) temp;
-
-    if (changes != null && !(start == end))
-      {
-        // We need to add an ElementChange to our DocumentEvent
-        ElementEdit edit = new ElementEdit (root, start, removed, added);
-        event.addEdit(edit);
-      }
-    
     if (shouldFire)
       fireRemoveUpdate(event);
   }
@@ -2143,7 +2120,10 @@ public abstract class AbstractDocument implements Document, Serializable
      */
     public String getName()
     {
-      return ContentElementName;
+      String name = super.getName();
+      if (name == null)
+        name = ContentElementName;
+      return name;
     }
 
     /**
index f201045..5c9587d 100644 (file)
@@ -476,7 +476,6 @@ public class BoxView
   protected View getViewAtPoint(int x, int y, Rectangle r)
   {
     View result = null;
-
     int count = getViewCount();
     Rectangle copy = new Rectangle(r);
 
@@ -490,7 +489,9 @@ public class BoxView
             break;
           }
       }
-
+    
+    if (result == null && count > 0)
+      return getView(count - 1);
     return result;
   }
 
@@ -498,10 +499,12 @@ public class BoxView
    * Computes the allocation for a child <code>View</code>. The parameter
    * <code>a</code> stores the allocation of this <code>CompositeView</code>
    * and is then adjusted to hold the allocation of the child view.
-   *
-   * @param index the index of the child <code>View</code>
-   * @param a the allocation of this <code>CompositeView</code> before the
-   *        call, the allocation of the child on exit
+   * 
+   * @param index
+   *          the index of the child <code>View</code>
+   * @param a
+   *          the allocation of this <code>CompositeView</code> before the
+   *          call, the allocation of the child on exit
    */
   protected void childAllocation(int index, Rectangle a)
   {
@@ -737,4 +740,22 @@ public class BoxView
       yLayoutValid = false;
     super.preferenceChanged(child, width, height);
   }
+  
+  /**
+   * Maps the document model position <code>pos</code> to a Shape
+   * in the view coordinate space.  This method overrides CompositeView's
+   * method to make sure the children are allocated properly before
+   * calling the super's behaviour.
+   */
+  public Shape modelToView(int pos, Shape a, Position.Bias bias)
+      throws BadLocationException
+  {
+    // Make sure everything is allocated properly and then call super
+    if (!isAllocationValid())
+      {
+        Rectangle bounds = a.getBounds();
+        setSize(bounds.width, bounds.height);
+      }
+    return super.modelToView(pos, a, bias);
+  }
 }
index 16112c8..830dda3 100644 (file)
@@ -38,10 +38,13 @@ exception statement from your version. */
 package javax.swing.text;
 
 import java.awt.Component;
+import java.awt.Container;
 import java.awt.Graphics;
+import java.awt.Rectangle;
 import java.awt.Shape;
 
 import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
 
 /**
  * A {@link View} implementation that is able to render arbitrary
@@ -52,12 +55,17 @@ import javax.swing.SwingConstants;
  * this <code>ComponentView</code>, so this view must not be shared between
  * multiple <code>JTextComponent</code>s.
  *
+ * @author Roman Kennke (kennke@aicas.com)
  * @author original author unknown
- * @author Roman Kennke (roman@kennke.org)
  */
-// FIXME: This class is a complete stub and needs to be implemented properly.
 public class ComponentView extends View
 {
+
+  /**
+   * The component that is displayed by this view.
+   */
+  private Component comp;
+
   /**
    * Creates a new instance of <code>ComponentView</code> for the specified
    * <code>Element</code>.
@@ -77,7 +85,7 @@ public class ComponentView extends View
    *
    * @return the component that is rendered
    */
-  protected  Component createComponent()
+  protected Component createComponent()
   {
     return StyleConstants.getComponent(getElement().getAttributes());
   }
@@ -91,7 +99,14 @@ public class ComponentView extends View
    */
   public float getAlignment(int axis)
   {
-    return 0;
+    float align;
+    if (axis == X_AXIS)
+      align = getComponent().getAlignmentX();
+    else if (axis == Y_AXIS)
+      align = getComponent().getAlignmentY();
+    else
+      throw new IllegalArgumentException();
+    return align;
   }
 
   /**
@@ -103,7 +118,9 @@ public class ComponentView extends View
    */
   public final Component getComponent()
   {
-    return null;
+    if (comp == null)
+      comp = createComponent();
+    return comp;
   }
 
   /**
@@ -118,49 +135,115 @@ public class ComponentView extends View
    */
   public float getMaximumSpan(int axis)
   {
-    return 0;
+    float span;
+    if (axis == X_AXIS)
+      span = getComponent().getMaximumSize().width;
+    else if (axis == Y_AXIS)
+      span = getComponent().getMaximumSize().height;
+    else
+      throw new IllegalArgumentException();
+    return span;
   }
 
   public float getMinimumSpan(int axis)
   {
-    // TODO: Implement this properly.
-    return 0;
+    float span;
+    if (axis == X_AXIS)
+      span = getComponent().getMinimumSize().width;
+    else if (axis == Y_AXIS)
+      span = getComponent().getMinimumSize().height;
+    else
+      throw new IllegalArgumentException();
+    return span;
   }
 
   public float getPreferredSpan(int axis)
   {
-    // TODO: Implement this properly.
-    return 0;
+    float span;
+    if (axis == X_AXIS)
+      span = getComponent().getPreferredSize().width;
+    else if (axis == Y_AXIS)
+      span = getComponent().getPreferredSize().height;
+    else
+      throw new IllegalArgumentException();
+    return span;
   }
 
   public Shape modelToView(int pos, Shape a, Position.Bias b)
     throws BadLocationException
   {
-    // TODO: Implement this properly.
-    return null;
+    Element el = getElement();
+    if (pos < el.getStartOffset() || pos >= el.getEndOffset())
+      throw new BadLocationException("Illegal offset for this view", pos);
+    Rectangle r = a.getBounds();
+    Component c = getComponent();
+    return new Rectangle(r.x, r.y, c.getWidth(), c.getHeight());
   }
-    
+
+  /**
+   * The real painting behavour is performed by normal component painting,
+   * triggered by the text component that hosts this view. This method does
+   * not paint by itself. However, it sets the size of the component according
+   * to the allocation that is passed here.
+   *
+   * @param g the graphics context
+   * @param a the allocation of the child
+   */
   public void paint(Graphics g, Shape a)
   {
-    // TODO: Implement this properly.
+    Rectangle r = a.getBounds();
+    getComponent().setBounds(r.x, r.y, r.width, r.height);
   }
-  
-  public void setParent(View p)
+
+  /**
+   * This sets up the component when the view is added to its parent, or
+   * cleans up the view when it is removed from its parent.
+   *
+   * When this view is added to a parent view, the component of this view
+   * is added to the container that hosts this view. When <code>p</code> is
+   * <code>null</code>, then the view is removed from it's parent and we have
+   * to also remove the component from it's parent container.
+   *
+   * @param p the parent view or <code>null</code> if this view is removed
+   *        from it's parent
+   */
+  public void setParent(final View p)
   {
-    // TODO: Implement this properly.
+    if (SwingUtilities.isEventDispatchThread())
+      setParentImpl(p);
+    else
+      SwingUtilities.invokeLater
+      (new Runnable()
+       {
+         public void run()
+         {
+           setParentImpl(p);
+         }
+       });
   }
-    
-  public void setSize(float width, float height)
+
+  /**
+   * The implementation of {@link #setParent}. This is package private to
+   * avoid a synthetic accessor method.
+   *
+   * @param p the parent view to set
+   */
+  void setParentImpl(View p)
   {
-    // TODO: Implement this properly.
+    if (p != null)
+      {
+        Component c = getComponent();
+        p.getContainer().add(c);
+      }
+    else
+      {
+        Component c = getComponent();
+        Container parent = c.getParent();
+        parent.remove(c);
+        comp = null;
+      }
   }
     
-  public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)
-  {
-    // TODO: Implement this properly.
-    return 0;
-  }
-
   /**
    * Maps coordinates from the <code>View</code>'s space into a position
    * in the document model.
@@ -173,10 +256,13 @@ public class ComponentView extends View
    * @return the position in the document that corresponds to the screen
    *         coordinates <code>x, y</code>
    */
-  public int viewToModel(float x, float y, Shape a, Position.Bias b)
+  public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
   {
-    // FIXME: Implement this properly.
-    return 0;
+    // The element should only have one character position and it is clear
+    // that this position is the position that best matches the given screen
+    // coordinates, simply because this view has only this one position.
+    Element el = getElement();
+    return el.getStartOffset();
   }
 
   /**
@@ -205,7 +291,7 @@ public class ComponentView extends View
                                        Position.Bias[] biasRet)
     throws BadLocationException
   {
-    // TODO: Implement this properly.
-    throw new AssertionError("Not implemented yet.");
+    // FIXME: Implement this method.
+    throw new AssertionError("Not yet implemented");
   }
 }
index bc626a4..e6c2e4c 100644 (file)
@@ -264,50 +264,56 @@ public abstract class CompositeView
    * Maps coordinates from the <code>View</code>'s space into a position
    * in the document model.
    *
-   * @param x the x coordinate in the view space
-   * @param y the y coordinate in the view space
+   * @param x the x coordinate in the view space, x >= 0
+   * @param y the y coordinate in the view space, y >= 0
    * @param a the allocation of this <code>View</code>
    * @param b the bias to use
    *
    * @return the position in the document that corresponds to the screen
-   *         coordinates <code>x, y</code>
+   *         coordinates <code>x, y</code> >= 0
    */
   public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
   {
-    Rectangle r = getInsideAllocation(a);
-    View view = getViewAtPoint((int) x, (int) y, r);
-    return view.viewToModel(x, y, a, b);
+    if (x >= 0 && y >= 0)
+      {
+        Rectangle r = getInsideAllocation(a);
+        View view = getViewAtPoint((int) x, (int) y, r);
+        return view.viewToModel(x, y, a, b);
+      }
+    return 0;
   }
 
   /**
    * Returns the next model location that is visible in eiter north / south
-   * direction or east / west direction. This is used to determine the
-   * placement of the caret when navigating around the document with
-   * the arrow keys.
-   *
-   * This is a convenience method for
-   * {@link #getNextNorthSouthVisualPositionFrom} and
-   * {@link #getNextEastWestVisualPositionFrom}.
-   *
-   * @param pos the model position to start search from
-   * @param b the bias for <code>pos</code>
-   * @param a the allocated region for this view
-   * @param direction the direction from the current position, can be one of
-   *        the following:
-   *        <ul>
-   *        <li>{@link SwingConstants#WEST}</li>
-   *        <li>{@link SwingConstants#EAST}</li>
-   *        <li>{@link SwingConstants#NORTH}</li>
-   *        <li>{@link SwingConstants#SOUTH}</li>
-   *        </ul>
-   * @param biasRet the bias of the return value gets stored here
-   *
+   * direction or east / west direction. This is used to determine the placement
+   * of the caret when navigating around the document with the arrow keys. This
+   * is a convenience method for {@link #getNextNorthSouthVisualPositionFrom}
+   * and {@link #getNextEastWestVisualPositionFrom}.
+   * 
+   * @param pos
+   *          the model position to start search from
+   * @param b
+   *          the bias for <code>pos</code>
+   * @param a
+   *          the allocated region for this view
+   * @param direction
+   *          the direction from the current position, can be one of the
+   *          following:
+   *          <ul>
+   *          <li>{@link SwingConstants#WEST}</li>
+   *          <li>{@link SwingConstants#EAST}</li>
+   *          <li>{@link SwingConstants#NORTH}</li>
+   *          <li>{@link SwingConstants#SOUTH}</li>
+   *          </ul>
+   * @param biasRet
+   *          the bias of the return value gets stored here
    * @return the position inside the model that represents the next visual
    *         location
-   *
-   * @throws BadLocationException if <code>pos</code> is not a valid location
-   *         inside the document model
-   * @throws IllegalArgumentException if <code>direction</code> is invalid
+   * @throws BadLocationException
+   *           if <code>pos</code> is not a valid location inside the document
+   *           model
+   * @throws IllegalArgumentException
+   *           if <code>direction</code> is invalid
    */
   public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
                                        int direction, Position.Bias[] biasRet)
index 66e2f47..3ebeceb 100644 (file)
@@ -781,28 +781,34 @@ public class DefaultCaret extends Rectangle
    */
   public void moveDot(int dot)
   {
-    this.dot = dot;
-    handleHighlight();
-    adjustVisibility(this);
-    appear();
+    if (dot >= 0)
+      {
+        this.dot = dot;
+        handleHighlight();
+        adjustVisibility(this);
+        appear();
+      }
   }
 
   /**
    * Sets the current position of this <code>Caret</code> within the
-   * <code>Document</code>. This also sets the <code>mark</code> to the
-   * new location.
-   *
-   * @param dot the new position to be set
-   *
+   * <code>Document</code>. This also sets the <code>mark</code> to the new
+   * location.
+   * 
+   * @param dot
+   *          the new position to be set
    * @see #moveDot(int)
    */
   public void setDot(int dot)
   {
-    this.dot = dot;
-    this.mark = dot;
-    handleHighlight();
-    adjustVisibility(this);
-    appear();
+    if (dot >= 0)
+      {
+        this.mark = dot;
+        this.dot = dot;
+        handleHighlight();
+        adjustVisibility(this);
+        appear();
+      }
   }
   
   /**
@@ -878,7 +884,7 @@ public class DefaultCaret extends Rectangle
           }
         Rectangle area = null;
         try
-          {
+          {            
             area = getComponent().modelToView(getDot());
           }
         catch (BadLocationException ex)
index fd6785b..765f515 100644 (file)
@@ -601,6 +601,9 @@ public abstract class FlowView extends BoxView
    */
   public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
   {
+    // First we must send the insertUpdate to the logical view so it can
+    // be updated accordingly.
+    layoutPool.insertUpdate(changes, a, vf);
     strategy.insertUpdate(this, changes, getInsideAllocation(a));
   }
 
index eb1fadd..d3dd75e 100644 (file)
@@ -457,9 +457,6 @@ public class GlyphView extends View implements TabableView, Cloneable
                            Bias[] biasRet)
     {
       Rectangle b = a.getBounds();
-      assert b.contains(x, y) : "The coordinates are expected to be within the "
-                                + "view's bounds: x=" + x + ", y=" + y
-                                + "a=" + a;
       int pos = getBoundedPosition(v, v.getStartOffset(), b.x, x - b.x);
       return pos;
     }
index 6dd0f7a..86c27dd 100644 (file)
@@ -39,11 +39,25 @@ exception statement from your version. */
 package javax.swing.text;
 
 import java.awt.Graphics;
+import java.awt.Rectangle;
 import java.awt.Shape;
 
+import javax.swing.Icon;
+import javax.swing.JTextPane;
 import javax.swing.SwingConstants;
 
-// TODO: Implement this class.
+/**
+ * A View that can render an icon. This view is created by the
+ * {@link StyledEditorKit}'s view factory for all elements that have name
+ * {@link StyleConstants#IconElementName}. This is usually created by
+ * inserting an icon into <code>JTextPane</code> using
+ * {@link JTextPane#insertIcon(Icon)}
+ *
+ * The icon is determined using the attribute
+ * {@link StyleConstants#IconAttribute}, which's value must be an {@link Icon}.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
 public class IconView
   extends View
 {
@@ -67,7 +81,9 @@ public class IconView
    */
   public void paint(Graphics g, Shape a)
   {
-    // TODO: Implement me.
+    Icon icon = StyleConstants.getIcon(getElement().getAttributes());
+    Rectangle b = a.getBounds();
+    icon.paintIcon(getContainer(), g, b.x, b.y);
   }
 
   /**
@@ -80,8 +96,15 @@ public class IconView
    */
   public float getPreferredSpan(int axis)
   {
-    // TODO: Implement me.
-    return 0F;
+    Icon icon = StyleConstants.getIcon(getElement().getAttributes());
+    float span;
+    if (axis == X_AXIS)
+      span = icon.getIconWidth();
+    else if (axis == Y_AXIS)
+      span = icon.getIconHeight();
+    else
+      throw new IllegalArgumentException();
+    return span;
   }
 
   /**
@@ -106,8 +129,12 @@ public class IconView
   public Shape modelToView(int pos, Shape a, Position.Bias b)
     throws BadLocationException
   {
-    // Implement me.
-    return null;
+    Element el = getElement();
+    if (pos < el.getStartOffset() || pos >= el.getEndOffset())
+      throw new BadLocationException("Illegal offset for this view", pos);
+    Rectangle r = a.getBounds();
+    Icon icon = StyleConstants.getIcon(el.getAttributes());
+    return new Rectangle(r.x, r.y, icon.getIconWidth(), icon.getIconHeight());
   }
 
   /**
@@ -124,8 +151,11 @@ public class IconView
    */
   public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
   {
-    // FIXME: not implemented
-    return 0;
+    // The element should only have one character position and it is clear
+    // that this position is the position that best matches the given screen
+    // coordinates, simply because this view has only this one position.
+    Element el = getElement();
+    return el.getStartOffset();
   }
 
   /**
@@ -157,4 +187,5 @@ public class IconView
     // TODO: Implement this properly.
     throw new AssertionError("Not implemented yet.");
   }
+
 }
index 6fb121f..c486450 100644 (file)
@@ -38,6 +38,10 @@ exception statement from your version. */
 
 package javax.swing.text;
 
+import java.awt.Shape;
+
+import javax.swing.event.DocumentEvent;
+
 /**
  * A {@link FlowView} that flows it's children horizontally and boxes the rows
  * vertically.
@@ -67,6 +71,26 @@ public class ParagraphView extends FlowView implements TabExpander
   }
 
   /**
+   * The indentation of the first line of the paragraph.
+   */
+  protected int firstLineIndent;
+
+  /**
+   * The justification of the paragraph.
+   */
+  private int justification;
+
+  /**
+   * The line spacing of this paragraph.
+   */
+  private float lineSpacing;
+
+  /**
+   * The TabSet of this paragraph.
+   */
+  private TabSet tabSet;
+
+  /**
    * Creates a new <code>ParagraphView</code> for the given
    * <code>Element</code>.
    *
@@ -116,4 +140,93 @@ public class ParagraphView extends FlowView implements TabExpander
     else
       return 0.0F;
   }
+
+  /**
+   * Receives notification when some attributes of the displayed element
+   * changes. This triggers a refresh of the cached attributes of this
+   * paragraph.
+   *
+   * @param ev the document event
+   * @param a the allocation of this view
+   * @param fv the view factory to use for creating new child views
+   */
+  public void changedUpdate(DocumentEvent ev, Shape a, ViewFactory fv)
+  {
+    setPropertiesFromAttributes();
+  }
+
+  /**
+   * Fetches the cached properties from the element's attributes.
+   */
+  protected void setPropertiesFromAttributes()
+  {
+    Element el = getElement();
+    AttributeSet atts = el.getAttributes();
+    setFirstLineIndent(StyleConstants.getFirstLineIndent(atts));
+    setLineSpacing(StyleConstants.getLineSpacing(atts));
+    setJustification(StyleConstants.getAlignment(atts));
+    tabSet = StyleConstants.getTabSet(atts);
+  }
+
+  /**
+   * Sets the indentation of the first line of the paragraph.
+   *
+   * @param i the indentation to set
+   */
+  protected void setFirstLineIndent(float i)
+  {
+    firstLineIndent = (int) i;
+  }
+
+  /**
+   * Sets the justification of the paragraph.
+   *
+   * @param j the justification to set 
+   */
+  protected void setJustification(int j)
+  {
+    justification = j;
+  }
+
+  /**
+   * Sets the line spacing for this paragraph.
+   *
+   * @param s the line spacing to set
+   */
+  protected void setLineSpacing(float s)
+  {
+    lineSpacing = s;
+  }
+
+  /**
+   * Returns the i-th view from the logical views, before breaking into rows.
+   *
+   * @param i the index of the logical view to return
+   *
+   * @return the i-th view from the logical views, before breaking into rows
+   */
+  protected View getLayoutView(int i)
+  {
+    return layoutPool.getView(i);
+  }
+
+  /**
+   * Returns the number of logical child views.
+   *
+   * @return the number of logical child views
+   */
+  protected int getLayoutViewCount()
+  {
+    return layoutPool.getViewCount();
+  }
+
+  /**
+   * Returns the TabSet used by this ParagraphView.
+   *
+   * @return the TabSet used by this ParagraphView
+   */
+  protected TabSet getTabSet()
+  {
+    return tabSet;
+  }
 }
index 9e600c4..0c00a06 100644 (file)
@@ -105,10 +105,65 @@ public class PlainDocument extends AbstractDocument
     return root;
   }
 
-  protected void insertUpdate(DefaultDocumentEvent event, AttributeSet attributes)
+  protected void insertUpdate(DefaultDocumentEvent event,
+                              AttributeSet attributes)
   {
-    reindex();
+    int offset = event.getOffset();
+    int end = offset + event.getLength();
+    int elementIndex = rootElement.getElementIndex(offset);
+    Element firstElement = rootElement.getElement(elementIndex);
+    
+    // added and removed are Element arrays used to add an ElementEdit
+    // to the DocumentEvent if there were entire lines added or removed.
+    Element[] removed = new Element[1];
+    Element[] added;
+    try 
+      {
+        String str = content.getString(0, content.length());
+        ArrayList elts = new ArrayList();
 
+        // Determine how many NEW lines were added by finding the newline
+        // characters within the newly inserted text
+        int j = firstElement.getStartOffset();
+        int i = str.indexOf('\n', offset);
+        while (i != -1 && i <= end)
+          {            
+            // For each new line, create a new element
+            elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY,
+                                       j, i + 1));
+            j = i + 1;
+            if (j >= str.length())
+              break;
+            i = str.indexOf('\n', j);
+          }
+        // If there were new lines added we have to add an ElementEdit to 
+        // the DocumentEvent and we have to call rootElement.replace to 
+        // insert the new lines
+        if (elts.size() != 0)
+          {
+            // Set up the ElementEdit by filling the added and removed 
+            // arrays with the proper Elements
+            added = new Element[elts.size()];
+            for (int k = 0; k < elts.size(); ++k)
+              added[k] = (Element) elts.get(k);
+            removed[0] = firstElement;
+            
+            // Now create and add the ElementEdit
+            ElementEdit e = new ElementEdit(rootElement, elementIndex, removed,
+                                            added);
+            event.addEdit(e);
+            
+            // And call replace to actually make the changes
+            ((BranchElement) rootElement).replace(elementIndex, 1, added);
+          }
+      }
+    catch (BadLocationException e)
+      {
+        // This shouldn't happen so we throw an AssertionError
+        AssertionError ae = new AssertionError();
+        ae.initCause(e);
+        throw ae;
+      }
     super.insertUpdate(event, attributes);
   }
 
@@ -116,24 +171,37 @@ public class PlainDocument extends AbstractDocument
   {
     super.removeUpdate(event);
 
+    // added and removed are Element arrays used to add an ElementEdit
+    // to the DocumentEvent if there were entire lines added or removed
+    // from the Document
+    Element[] added = new Element[1];
+    Element[] removed;
     int p0 = event.getOffset();
-    int len = event.getLength();
-    int p1 = len + p0;
 
     // check if we must collapse some elements
     int i1 = rootElement.getElementIndex(p0);
-    int i2 = rootElement.getElementIndex(p1);
+    int i2 = rootElement.getElementIndex(p0 + event.getLength());
     if (i1 != i2)
       {
-        Element el1 = rootElement.getElement(i1);
-        Element el2 = rootElement.getElement(i2);
-        int start = el1.getStartOffset();
-        int end = el2.getEndOffset();
-        // collapse elements if the removal spans more than 1 line
-        Element newEl = createLeafElement(rootElement,
+        // If there were lines removed then we have to add an ElementEdit
+        // to the DocumentEvent so we set it up now by filling the Element
+        // arrays "removed" and "added" appropriately
+        removed = new Element [i2 - i1 + 1];
+        for (int i = i1; i <= i2; i++)
+          removed[i-i1] = rootElement.getElement(i);
+        
+        int start = rootElement.getElement(i1).getStartOffset();
+        int end = rootElement.getElement(i2).getEndOffset();        
+        added[0] = createLeafElement(rootElement,
                                           SimpleAttributeSet.EMPTY,
                                           start, end);
-        rootElement.replace(i1, i2 - i1 + 1, new Element[]{ newEl });
+
+        // Now create and add the ElementEdit
+        ElementEdit e = new ElementEdit(rootElement, i1, removed, added);
+        event.addEdit(e);
+
+        // collapse elements if the removal spans more than 1 line
+        rootElement.replace(i1, i2 - i1 + 1, added);
       }
   }
 
@@ -167,7 +235,7 @@ public class PlainDocument extends AbstractDocument
     throws BadLocationException
   {
     String string = str;
-    if (Boolean.TRUE.equals(getProperty("filterNewlines")))
+    if (str != null && Boolean.TRUE.equals(getProperty("filterNewlines")))
       string = str.replaceAll("\n", " ");
     super.insertString(offs, string, atts);
   }
index b905190..b03399d 100644 (file)
@@ -50,7 +50,7 @@ import javax.swing.event.DocumentEvent;
 import javax.swing.text.Position.Bias;
 
 /**
- * @author abalkiss
+ * @author Anthony Balkissoon abalkiss at redhat dot com
  *
  */
 public class WrappedPlainView extends BoxView implements TabExpander
index 2891a77..ae8b99c 100644 (file)
@@ -339,9 +339,8 @@ public class DefaultTreeCellEditor
     lastPath = tree.getLeadSelectionPath();
     tree.addTreeSelectionListener(this);
     editingContainer = createContainer();
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    setFont(defaults.getFont("Tree.font"));
-    setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor"));
+    setFont(UIManager.getFont("Tree.font"));
+    setBorderSelectionColor(UIManager.getColor("Tree.selectionBorderColor"));
     editingIcon = renderer.getIcon();
     timer = new javax.swing.Timer(1200, this);
   }
@@ -735,9 +734,8 @@ public class DefaultTreeCellEditor
    */
   protected TreeCellEditor createTreeCellEditor()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
     realEditor = new DefaultCellEditor(new DefaultTreeCellEditor.DefaultTextField(
-                                  defaults.getBorder("Tree.selectionBorder")));
+                                  UIManager.getBorder("Tree.selectionBorder")));
     return realEditor;
   }
 }
index d1cb9c0..df70ba7 100644 (file)
@@ -51,7 +51,6 @@ import javax.swing.border.Border;
 import javax.swing.Icon;
 import javax.swing.JLabel;
 import javax.swing.JTree;
-import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 import javax.swing.SwingUtilities;
 import javax.swing.plaf.UIResource;
@@ -133,17 +132,15 @@ public class DefaultTreeCellRenderer
    */
   public DefaultTreeCellRenderer()
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
     setLeafIcon(getDefaultLeafIcon());
     setOpenIcon(getDefaultOpenIcon());
     setClosedIcon(getDefaultClosedIcon());
 
-    setTextNonSelectionColor(defaults.getColor("Tree.textForeground"));
-    setTextSelectionColor(defaults.getColor("Tree.selectionForeground"));
-    setBackgroundNonSelectionColor(defaults.getColor("Tree.nonSelectionBackground"));
-    setBackgroundSelectionColor(defaults.getColor("Tree.selectionBackground"));
-    setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor"));
+    setTextNonSelectionColor(UIManager.getColor("Tree.textForeground"));
+    setTextSelectionColor(UIManager.getColor("Tree.selectionForeground"));
+    setBackgroundNonSelectionColor(UIManager.getColor("Tree.nonSelectionBackground"));
+    setBackgroundSelectionColor(UIManager.getColor("Tree.selectionBackground"));
+    setBorderSelectionColor(UIManager.getColor("Tree.selectionBorderColor"));
   }
 
   // -------------------------------------------------------------
@@ -157,7 +154,7 @@ public class DefaultTreeCellRenderer
    */
   public Icon getDefaultOpenIcon()
   {
-    return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
+    return UIManager.getIcon("Tree.openIcon");
   }
 
   /**
@@ -167,7 +164,7 @@ public class DefaultTreeCellRenderer
    */
   public Icon getDefaultClosedIcon()
   {
-    return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
+    return UIManager.getIcon("Tree.closedIcon");
   }
 
   /**
@@ -177,7 +174,7 @@ public class DefaultTreeCellRenderer
    */
   public Icon getDefaultLeafIcon()
   {
-    return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
+    return UIManager.getIcon("Tree.leafIcon");
   }
 
   /**
@@ -412,7 +409,7 @@ public class DefaultTreeCellRenderer
     setOpaque(false);
     setVerticalAlignment(TOP);
     setEnabled(true);
-    super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font"));
+    super.setFont(UIManager.getFont("Tree.font"));
 
     if (selected)
       {
@@ -459,8 +456,7 @@ public class DefaultTreeCellRenderer
     Rectangle tr = new Rectangle();
 
     Insets insets = new Insets(0, 0, 0, 0);
-    Border border = UIManager.getLookAndFeelDefaults().getBorder(
-                                                                 "Tree.selectionBorder");
+    Border border = UIManager.getBorder("Tree.selectionBorder");
     if (border != null)
       insets = border.getBorderInsets(this);
 
index 7f51e53..092e997 100644 (file)
@@ -565,6 +565,13 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
 
   /* gdk_flush(); */
 
+  if (!GDK_IS_DRAWABLE (src->drawable) || 
+   !GDK_IS_DRAWABLE (dst->drawable))
+    {
+      gdk_threads_leave ();
+      return;
+    }
+
   gdk_drawable_get_size (src->drawable, &s_width, &s_height);
   gdk_drawable_get_size (dst->drawable, &d_width, &d_height);
   width = min (s_width, d_width);
index 59b56cf..b14330e 100644 (file)
@@ -135,6 +135,8 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
 
   gtkgenericpeer = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GtkGenericPeer");
 
+  gtkgenericpeer = (*env)->NewGlobalRef(env, gtkgenericpeer);
+
   printCurrentThreadID = (*env)->GetStaticMethodID (env, gtkgenericpeer,
                                                     "printCurrentThread", "()V");
  
index d79bbec..ac8f6a8 100644 (file)
@@ -1204,8 +1204,8 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable
   gdk_threads_enter ();
 
   ptr = NSA_GET_PTR (env, obj);
-
   gtk_window_set_resizable (GTK_WINDOW (ptr), resizable);
+  g_object_set (G_OBJECT (ptr), "allow-shrink", resizable, NULL);
 
   gdk_threads_leave ();
 }
index 846df2e..076f42b 100644 (file)
@@ -71,6 +71,11 @@ Java_java_lang_VMDouble_initIDs (JNIEnv * env, jclass cls __attribute__ ((__unus
     {
       DBG ("unable to get class java.lang.Double\n") return;
     }
+  clsDouble = (*env)->NewGlobalRef(env, clsDouble);
+  if (clsDouble == NULL)
+    {
+      DBG ("unable to register class java.lang.Double as global ref\n") return;
+    }
   isNaNID = (*env)->GetStaticMethodID (env, clsDouble, "isNaN", "(D)Z");
   if (isNaNID == NULL)
     {
diff --git a/libjava/gnu/java/net/protocol/file/Connection.java b/libjava/gnu/java/net/protocol/file/Connection.java
deleted file mode 100644 (file)
index 8e4a413..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-/* FileURLConnection.java -- URLConnection class for "file" protocol
-   Copyright (C) 1998, 1999, 2003 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.net.protocol.file;
-
-import gnu.classpath.SystemProperties;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.Permission;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.net.MalformedURLException;
-
-/**
- * This subclass of java.net.URLConnection models a URLConnection via
- * the "file" protocol.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Nic Ferrier (nferrier@tapsellferrier.co.uk)
- * @author Warren Levy (warrenl@cygnus.com)
- */
-public class Connection extends URLConnection
-{
-  /**
-   * Default permission for a file
-   */
-  private static final String DEFAULT_PERMISSION = "read";
-
-  private static class StaticData
-  {
-    /**
-     * HTTP-style DateFormat, used to format the last-modified header.
-     */
-    static SimpleDateFormat dateFormat
-      = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
-                             new Locale ("En", "Us", "Unix"));
-
-    static String lineSeparator =
-      SystemProperties.getProperty("line.separator");
-  }
-
-  
-  /**
-   * This is a File object for this connection
-   */
-  private File file;
-
-  /**
-   * If a directory, contains a list of files in the directory.
-   */
-  private byte[] directoryListing;
-
-  /**
-   * InputStream if we are reading from the file
-   */
-  private InputStream inputStream;
-
-  /**
-   * OutputStream if we are writing to the file
-   */
-  private OutputStream outputStream;
-  
-  /**
-   * FilePermission to read the file
-   */
-  private FilePermission permission;
-
-  /**
-   * Calls superclass constructor to initialize.
-   */
-  public Connection(URL url)
-  {
-    super (url);
-
-    permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
-  }
-  
-  /**
-   * Unquote "%" + hex quotes characters
-   *
-   * @param str The string to unquote or null.
-   *
-   * @return The unquoted string or null if str was null.
-   *
-   * @exception MalformedURLException If the given string contains invalid
-   * escape sequences.
-   *
-   * Sadly the same as URI.unquote, but there's nothing we can do to
-   * make it accessible.
-   *
-   */
-  public static String unquote(String str) throws MalformedURLException
-  {
-    if (str == null)
-      return null;
-    byte[] buf = new byte[str.length()];
-    int pos = 0;
-    for (int i = 0; i < str.length(); i++)
-      {
-       char c = str.charAt(i);
-       if (c > 127)
-         throw new MalformedURLException(str + " : Invalid character");
-       if (c == '%')
-         {
-           if (i + 2 >= str.length())
-             throw new MalformedURLException(str + " : Invalid quoted character");
-           int hi = Character.digit(str.charAt(++i), 16);
-           int lo = Character.digit(str.charAt(++i), 16);
-           if (lo < 0 || hi < 0)
-             throw new MalformedURLException(str + " : Invalid quoted character");
-           buf[pos++] = (byte) (hi * 16 + lo);
-         }
-       else
-         buf[pos++] = (byte) c;
-      }
-    try
-      {
-       return new String(buf, 0, pos, "utf-8");
-      }
-    catch (java.io.UnsupportedEncodingException x2)
-      {
-       throw (Error) new InternalError().initCause(x2);
-      }
-  }
-
-  /**
-   * "Connects" to the file by opening it.
-   */
-  public void connect() throws IOException
-  {
-    // Call is ignored if already connected.
-    if (connected)
-      return;
-    
-    // If not connected, then file needs to be openned.
-    file = new File (unquote(getURL().getFile()));
-
-    if (! file.isDirectory())
-      {
-       if (doInput)
-         inputStream = new BufferedInputStream(new FileInputStream(file));
-    
-       if (doOutput)
-         outputStream = new BufferedOutputStream(new FileOutputStream(file));
-      }
-    else
-      {
-       if (doInput)
-         {
-            inputStream = new ByteArrayInputStream(getDirectoryListing());
-         }
-
-       if (doOutput)
-         throw new ProtocolException
-           ("file: protocol does not support output on directories");
-      }
-    
-    connected = true;
-  }
-
-  /**
-   * Populates the <code>directoryListing</code> field with a byte array
-   * containing a representation of the directory listing.
-   */
-  byte[] getDirectoryListing()
-    throws IOException
-  {
-    if (directoryListing == null)
-      {
-        ByteArrayOutputStream sink = new ByteArrayOutputStream();
-        // NB uses default character encoding for this system
-        Writer writer = new OutputStreamWriter(sink);
-    
-        String[] files = file.list();
-    
-        for (int i = 0; i < files.length; i++)
-          {
-            writer.write(files[i]);
-            writer.write(StaticData.lineSeparator);
-          }
-
-        directoryListing = sink.toByteArray();
-      }
-    return directoryListing;  
-  }
-  
-  /**
-   * Opens the file for reading and returns a stream for it.
-   *
-   * @return An InputStream for this connection.
-   *
-   * @exception IOException If an error occurs
-   */
-  public InputStream getInputStream()
-    throws IOException
-  {
-    if (!doInput)
-      throw new ProtocolException("Can't open InputStream if doInput is false");
-    
-    if (!connected)
-      connect();
-    
-    return inputStream;
-  }
-
-  /**
-   * Opens the file for writing and returns a stream for it.
-   *
-   * @return An OutputStream for this connection.
-   *
-   * @exception IOException If an error occurs.
-   */
-  public OutputStream getOutputStream()
-    throws IOException
-  {
-    if (!doOutput)
-      throw new
-       ProtocolException("Can't open OutputStream if doOutput is false");
-
-    if (!connected)
-      connect();
-    
-    return outputStream;
-  }
-
-  /**
-   * Get the last modified time of the resource.
-   *
-   * @return the time since epoch that the resource was modified.
-   */
-  public long getLastModified()
-  {
-    try
-      {
-       if (!connected)
-         connect();
-
-       return file.lastModified();
-      }
-    catch (IOException e)
-      {
-       return -1;
-      }
-  }
-  
-  /**
-   *  Get an http-style header field. Just handle a few common ones. 
-   */
-  public String getHeaderField(String field)
-  {
-    try
-      {
-       if (!connected)
-         connect();
-
-       if (field.equals("content-type"))
-          return guessContentTypeFromName(file.getName());
-       else if (field.equals("content-length"))
-          {
-            if (file.isDirectory())
-              {
-                return Integer.toString(getContentLength());
-              }
-            return Long.toString(file.length());
-          }
-       else if (field.equals("last-modified"))
-         {
-           synchronized (StaticData.dateFormat)
-             {
-               return StaticData.dateFormat.format(
-                        new Date(file.lastModified()));
-             }
-         }
-      }
-    catch (IOException e)
-      {
-        // Fall through.
-      }
-    return null;
-  }
-
-  /**
-   * Get the length of content.
-   *
-   * @return the length of the content.
-   */
-  public int getContentLength()
-  {
-    try
-      {
-       if (!connected)
-         connect();
-        
-        if (file.isDirectory())
-          {
-            return getDirectoryListing().length;
-          }
-       return (int) file.length();
-      }
-    catch (IOException e)
-      {
-       return -1;
-      }
-  }
-  
-  /**
-   * This method returns a <code>Permission</code> object representing the
-   * permissions required to access this URL.  This method returns a
-   * <code>java.io.FilePermission</code> for the file's path with a read
-   * permission.
-   *
-   * @return A Permission object
-   */
-  public Permission getPermission() throws IOException
-  {
-    return permission;
-  }
-}
index ddf5c8d..6a0b302 100644 (file)
@@ -975,7 +975,7 @@ gnu/java/net.list: $(gnu_java_net_source_files)
 
 
 gnu_java_net_protocol_file_source_files = \
-gnu/java/net/protocol/file/Connection.java \
+classpath/gnu/java/net/protocol/file/Connection.java \
 classpath/gnu/java/net/protocol/file/Handler.java
 
 gnu_java_net_protocol_file_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files)))
@@ -5133,6 +5133,7 @@ classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java \
 classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java \
 classpath/javax/swing/plaf/metal/MetalLabelUI.java \
 classpath/javax/swing/plaf/metal/MetalLookAndFeel.java \
+classpath/javax/swing/plaf/metal/MetalMenuBarUI.java \
 classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java \
 classpath/javax/swing/plaf/metal/MetalProgressBarUI.java \
 classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java \