summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog820
-rw-r--r--configure.ac1
-rw-r--r--examples/gnu/classpath/examples/datatransfer/Demo.java457
-rw-r--r--examples/gnu/classpath/examples/jawt/DemoJAWT.c147
-rw-r--r--examples/gnu/classpath/examples/jawt/DemoJAWT.java53
-rw-r--r--examples/gnu/classpath/examples/jawt/Makefile20
-rw-r--r--gnu/CORBA/CDR/Vio.java170
-rw-r--r--gnu/CORBA/CDR/cdrInput.java3
-rw-r--r--gnu/CORBA/CDR/cdrOutput.java2
-rw-r--r--gnu/CORBA/CDR/noHeaderInput.java166
-rw-r--r--gnu/CORBA/DynAn/NameValuePairHolder.java7
-rw-r--r--gnu/CORBA/DynAn/abstractDynAny.java177
-rw-r--r--gnu/CORBA/DynAn/abstractRecord.java405
-rw-r--r--gnu/CORBA/DynAn/anyDivideable.java514
-rw-r--r--gnu/CORBA/DynAn/anyUndivideable.java493
-rw-r--r--gnu/CORBA/DynAn/gnuDynAny.java985
-rw-r--r--gnu/CORBA/DynAn/gnuDynAnyFactory.java356
-rw-r--r--gnu/CORBA/DynAn/gnuDynArray.java338
-rw-r--r--gnu/CORBA/DynAn/gnuDynEnum.java250
-rw-r--r--gnu/CORBA/DynAn/gnuDynFixed.java257
-rw-r--r--gnu/CORBA/DynAn/gnuDynSequence.java254
-rw-r--r--gnu/CORBA/DynAn/gnuDynStruct.java109
-rw-r--r--gnu/CORBA/DynAn/gnuDynUnion.java439
-rw-r--r--gnu/CORBA/DynAn/gnuDynValue.java395
-rw-r--r--gnu/CORBA/DynAn/gnuDynValueBox.java389
-rw-r--r--gnu/CORBA/DynAn/valueChangedListener.java50
-rw-r--r--gnu/CORBA/DynAnySeqHolder.java116
-rw-r--r--gnu/CORBA/NameDynAnyPairHolder.java115
-rw-r--r--gnu/CORBA/NameDynAnyPairSeqHolder.java115
-rw-r--r--gnu/CORBA/NameValuePairHolder.java105
-rw-r--r--gnu/CORBA/NameValuePairSeqHolder.java105
-rw-r--r--gnu/CORBA/Poa/ORB_1_4.java11
-rw-r--r--gnu/CORBA/Restricted_ORB.java9
-rw-r--r--gnu/CORBA/fixedTypeCode.java14
-rw-r--r--gnu/CORBA/gnuAny.java94
-rw-r--r--gnu/CORBA/gnuValueHolder.java135
-rw-r--r--gnu/CORBA/holderFactory.java123
-rw-r--r--gnu/CORBA/typeNamer.java13
-rw-r--r--gnu/CORBA/universalHolder.java23
-rw-r--r--gnu/classpath/debug/Component.java6
-rw-r--r--gnu/classpath/jdwp/exception/JdwpInternalErrorException.java9
-rw-r--r--gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java114
-rw-r--r--gnu/classpath/jdwp/processor/ClassTypeCommandSet.java228
-rw-r--r--gnu/classpath/jdwp/processor/EventRequestCommandSet.java208
-rw-r--r--gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java14
-rw-r--r--gnu/classpath/jdwp/processor/StackFrameCommandSet.java164
-rw-r--r--gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java251
-rw-r--r--gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java6
-rw-r--r--gnu/classpath/jdwp/util/LineTable.java96
-rw-r--r--gnu/classpath/jdwp/util/Location.java116
-rw-r--r--gnu/classpath/jdwp/util/MethodResult.java76
-rw-r--r--gnu/classpath/jdwp/util/Value.java16
-rw-r--r--gnu/classpath/jdwp/util/VariableTable.java110
-rw-r--r--gnu/java/awt/ClasspathToolkit.java206
-rw-r--r--gnu/java/awt/peer/gtk/GtkButtonPeer.java8
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java30
-rw-r--r--gnu/java/awt/peer/gtk/GtkLabelPeer.java7
-rw-r--r--gnu/java/awt/peer/gtk/GtkMenuBarPeer.java5
-rw-r--r--gnu/java/awt/peer/gtk/GtkMenuPeer.java5
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java8
-rw-r--r--gnu/java/awt/peer/qt/MainQtThread.java84
-rw-r--r--gnu/java/awt/peer/qt/NativeWrapper.java43
-rw-r--r--gnu/java/awt/peer/qt/QMatrix.java73
-rw-r--r--gnu/java/awt/peer/qt/QPainterPath.java141
-rw-r--r--gnu/java/awt/peer/qt/QPen.java71
-rw-r--r--gnu/java/awt/peer/qt/QtAudioClip.java104
-rw-r--r--gnu/java/awt/peer/qt/QtButtonPeer.java79
-rw-r--r--gnu/java/awt/peer/qt/QtCanvasPeer.java65
-rw-r--r--gnu/java/awt/peer/qt/QtCheckboxPeer.java114
-rw-r--r--gnu/java/awt/peer/qt/QtChoicePeer.java95
-rw-r--r--gnu/java/awt/peer/qt/QtComponentGraphics.java125
-rw-r--r--gnu/java/awt/peer/qt/QtComponentPeer.java714
-rw-r--r--gnu/java/awt/peer/qt/QtContainerPeer.java97
-rw-r--r--gnu/java/awt/peer/qt/QtDialogPeer.java75
-rw-r--r--gnu/java/awt/peer/qt/QtFileDialogPeer.java84
-rw-r--r--gnu/java/awt/peer/qt/QtFontMetrics.java128
-rw-r--r--gnu/java/awt/peer/qt/QtFontPeer.java207
-rw-r--r--gnu/java/awt/peer/qt/QtFramePeer.java137
-rw-r--r--gnu/java/awt/peer/qt/QtGraphics.java699
-rw-r--r--gnu/java/awt/peer/qt/QtGraphicsEnvironment.java108
-rw-r--r--gnu/java/awt/peer/qt/QtImage.java588
-rw-r--r--gnu/java/awt/peer/qt/QtImageConsumer.java154
-rw-r--r--gnu/java/awt/peer/qt/QtImageGraphics.java139
-rw-r--r--gnu/java/awt/peer/qt/QtLabelPeer.java62
-rw-r--r--gnu/java/awt/peer/qt/QtListPeer.java139
-rw-r--r--gnu/java/awt/peer/qt/QtMenuBarPeer.java103
-rw-r--r--gnu/java/awt/peer/qt/QtMenuComponentPeer.java77
-rw-r--r--gnu/java/awt/peer/qt/QtMenuItemPeer.java100
-rw-r--r--gnu/java/awt/peer/qt/QtMenuPeer.java150
-rw-r--r--gnu/java/awt/peer/qt/QtPanelPeer.java57
-rw-r--r--gnu/java/awt/peer/qt/QtPopupMenuPeer.java82
-rw-r--r--gnu/java/awt/peer/qt/QtScreenDevice.java116
-rw-r--r--gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java141
-rw-r--r--gnu/java/awt/peer/qt/QtScrollPanePeer.java91
-rw-r--r--gnu/java/awt/peer/qt/QtScrollbarPeer.java80
-rw-r--r--gnu/java/awt/peer/qt/QtTextAreaPeer.java155
-rw-r--r--gnu/java/awt/peer/qt/QtTextFieldPeer.java143
-rw-r--r--gnu/java/awt/peer/qt/QtToolkit.java478
-rw-r--r--gnu/java/awt/peer/qt/QtVolatileImage.java393
-rw-r--r--gnu/java/awt/peer/qt/QtWindowPeer.java68
-rw-r--r--gnu/java/nio/charset/UTF_16Decoder.java12
-rw-r--r--gnu/java/security/PolicyFile.java93
-rw-r--r--gnu/java/security/provider/DSAKeyPairGenerator.java119
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkButtonPeer.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkLabelPeer.h1
-rw-r--r--java/awt/Component.java53
-rw-r--r--java/awt/Container.java29
-rw-r--r--java/awt/image/ConvolveOp.java6
-rw-r--r--java/awt/peer/MenuBarPeer.java1
-rw-r--r--java/awt/peer/MenuPeer.java1
-rw-r--r--java/io/ObjectInputStream.java86
-rw-r--r--java/net/DatagramSocket.java6
-rw-r--r--java/net/NetworkInterface.java52
-rw-r--r--java/net/URLClassLoader.java6
-rw-r--r--java/security/KeyPairGenerator.java3
-rw-r--r--java/util/Observable.java2
-rw-r--r--java/util/logging/Logger.java48
-rw-r--r--javax/imageio/spi/IIORegistry.java3
-rw-r--r--javax/security/auth/x500/X500Principal.java14
-rw-r--r--javax/swing/DefaultCellEditor.java95
-rw-r--r--javax/swing/JTable.java219
-rw-r--r--javax/swing/JTree.java42
-rw-r--r--javax/swing/plaf/basic/BasicLabelUI.java180
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java17
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java8
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java1046
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java1225
-rw-r--r--javax/swing/plaf/basic/BasicViewportUI.java6
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java4
-rw-r--r--javax/swing/table/DefaultTableCellRenderer.java7
-rw-r--r--javax/swing/text/GapContent.java71
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java9
-rw-r--r--javax/swing/tree/DefaultTreeModel.java842
-rw-r--r--lib/Makefile.am18
-rwxr-xr-xlib/gen-classlist.sh.in9
-rwxr-xr-xlib/split-for-gcj.sh39
-rw-r--r--native/jni/classpath/Makefile.am3
-rw-r--r--native/jni/classpath/classpath_jawt.h8
-rw-r--r--native/jni/gtk-peer/Makefile.am1
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c50
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c38
-rw-r--r--native/jni/gtk-peer/gtk_jawt.c197
-rw-r--r--native/jni/java-net/gnu_java_net_PlainSocketImpl.c1
-rw-r--r--native/jni/qt-peer/buttonevent.h27
-rw-r--r--native/jni/qt-peer/componentevent.cpp133
-rw-r--r--native/jni/qt-peer/componentevent.h203
-rw-r--r--native/jni/qt-peer/containers.h10
-rw-r--r--native/jni/qt-peer/eventmethods.cpp233
-rw-r--r--native/jni/qt-peer/keybindings.cpp545
-rw-r--r--native/jni/qt-peer/keybindings.h18
-rw-r--r--native/jni/qt-peer/mainqtthread.cpp102
-rw-r--r--native/jni/qt-peer/mainthreadinterface.cpp68
-rw-r--r--native/jni/qt-peer/mainthreadinterface.h39
-rw-r--r--native/jni/qt-peer/nativewrapper.cpp64
-rw-r--r--native/jni/qt-peer/nativewrapper.h10
-rw-r--r--native/jni/qt-peer/qmatrix.cpp95
-rw-r--r--native/jni/qt-peer/qpainterpath.cpp238
-rw-r--r--native/jni/qt-peer/qpen.cpp107
-rw-r--r--native/jni/qt-peer/qtaudioclip.cpp114
-rw-r--r--native/jni/qt-peer/qtbuttonpeer.cpp93
-rw-r--r--native/jni/qt-peer/qtcanvaspeer.cpp74
-rw-r--r--native/jni/qt-peer/qtcheckboxpeer.cpp163
-rw-r--r--native/jni/qt-peer/qtchoicepeer.cpp142
-rw-r--r--native/jni/qt-peer/qtcomponent.cpp122
-rw-r--r--native/jni/qt-peer/qtcomponent.h16
-rw-r--r--native/jni/qt-peer/qtcomponentpeer.cpp391
-rw-r--r--native/jni/qt-peer/qtdialogpeer.cpp163
-rw-r--r--native/jni/qt-peer/qtfiledialogpeer.cpp100
-rw-r--r--native/jni/qt-peer/qtfont.h8
-rw-r--r--native/jni/qt-peer/qtfontmetrics.cpp232
-rw-r--r--native/jni/qt-peer/qtfontpeer.cpp91
-rw-r--r--native/jni/qt-peer/qtframepeer.cpp202
-rw-r--r--native/jni/qt-peer/qtgraphics.cpp471
-rw-r--r--native/jni/qt-peer/qtgraphics.h26
-rw-r--r--native/jni/qt-peer/qtimage.cpp396
-rw-r--r--native/jni/qt-peer/qtimage.h8
-rw-r--r--native/jni/qt-peer/qtlabelpeer.cpp152
-rw-r--r--native/jni/qt-peer/qtlistpeer.cpp207
-rw-r--r--native/jni/qt-peer/qtmenubarpeer.cpp149
-rw-r--r--native/jni/qt-peer/qtmenucomponentpeer.cpp66
-rw-r--r--native/jni/qt-peer/qtmenuitempeer.cpp181
-rw-r--r--native/jni/qt-peer/qtmenupeer.cpp259
-rw-r--r--native/jni/qt-peer/qtpanelpeer.cpp73
-rw-r--r--native/jni/qt-peer/qtpopupmenupeer.cpp75
-rw-r--r--native/jni/qt-peer/qtscreendevice.cpp122
-rw-r--r--native/jni/qt-peer/qtscrollbarpeer.cpp141
-rw-r--r--native/jni/qt-peer/qtscrollpanepeer.cpp211
-rw-r--r--native/jni/qt-peer/qtstrings.cpp54
-rw-r--r--native/jni/qt-peer/qtstrings.h10
-rw-r--r--native/jni/qt-peer/qttextareapeer.cpp191
-rw-r--r--native/jni/qt-peer/qttextfieldpeer.cpp287
-rw-r--r--native/jni/qt-peer/qttoolkit.cpp156
-rw-r--r--native/jni/qt-peer/qtvolatileimage.cpp296
-rw-r--r--native/jni/qt-peer/qtwindowpeer.cpp146
-rw-r--r--native/jni/qt-peer/slotcallbacks.cpp199
-rw-r--r--native/jni/qt-peer/slotcallbacks.h18
-rw-r--r--native/jni/qt-peer/slotcallbacks.moc75
-rw-r--r--org/omg/CORBA/Any.java12
-rw-r--r--org/omg/CORBA/ORB.java4
-rw-r--r--org/omg/CORBA/ObjectHelper.java7
-rw-r--r--org/omg/CORBA/ObjectHolder.java17
-rw-r--r--org/omg/CORBA/TypeCode.java66
-rw-r--r--org/omg/CORBA/package.html84
-rw-r--r--org/omg/CORBA_2_3/portable/InputStream.java13
-rw-r--r--org/omg/CORBA_2_3/portable/OutputStream.java2
-rw-r--r--org/omg/DynamicAny/AnySeqHelper.java122
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryHelper.java4
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryOperations.java5
-rw-r--r--org/omg/DynamicAny/DynAnyOperations.java82
-rw-r--r--org/omg/DynamicAny/DynAnySeqHelper.java152
-rw-r--r--org/omg/DynamicAny/DynUnionOperations.java24
-rw-r--r--org/omg/DynamicAny/DynValueBox.java4
-rw-r--r--org/omg/DynamicAny/DynValueCommon.java6
-rw-r--r--org/omg/DynamicAny/FieldNameHelper.java120
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairHelper.java170
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairSeqHelper.java151
-rw-r--r--org/omg/DynamicAny/NameValuePairHelper.java159
-rw-r--r--org/omg/DynamicAny/NameValuePairSeqHelper.java147
-rw-r--r--org/omg/DynamicAny/_DynAnyFactoryStub.java116
-rw-r--r--org/omg/DynamicAny/_DynAnyStub.java630
-rw-r--r--org/omg/DynamicAny/_DynArrayStub.java128
-rw-r--r--org/omg/DynamicAny/_DynEnumStub.java126
-rw-r--r--org/omg/DynamicAny/_DynFixedStub.java106
-rw-r--r--org/omg/DynamicAny/_DynSequenceStub.java151
-rw-r--r--org/omg/DynamicAny/_DynStructStub.java152
-rw-r--r--org/omg/DynamicAny/_DynUnionStub.java184
-rw-r--r--org/omg/DynamicAny/_DynValueStub.java184
-rw-r--r--org/omg/DynamicAny/package.html87
-rw-r--r--org/omg/PortableInterceptor/IORInfo.java56
-rw-r--r--org/omg/PortableInterceptor/IORInfoOperations.java88
-rw-r--r--org/omg/PortableInterceptor/IORInterceptor.java58
-rw-r--r--org/omg/PortableInterceptor/IORInterceptorOperations.java59
-rw-r--r--org/omg/PortableInterceptor/Interceptor.java57
-rw-r--r--org/omg/PortableInterceptor/InterceptorOperations.java77
-rw-r--r--vm/reference/gnu/classpath/jdwp/VMFrame.java101
-rw-r--r--vm/reference/java/net/VMNetworkInterface.java10
-rw-r--r--vm/reference/standard.omit1
237 files changed, 30208 insertions, 2434 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ab83b3b7..7e80f2d60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2005-08-14 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/ClasspathToolkit.java
+ (getScreenSize, getColorModel, getFontMetrics, getImage, createImage,
+ createImageProducer, registerImageIOSpis):
+ Remove redundant (overloaded) methods.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java
+ (registerImageIOSpis): Move registration to static initializer.
+ * javax/imageio/spi/IIORegistry.java:
+ Remove call to Toolkit registration method.
+
+2005-08-13 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java (repaintTimer): Make
+ field final.
+
+2005-08-14 Sven de Marothy <sven@physto.se>
+
+ * java/awt/Container.java
+ (addImpl): Call addNotify() only if the container has a peer.
+
2005-08-13 Tom Tromey <tromey@redhat.com>
* java/util/Collections.java (reverseOrder): New method.
@@ -53,6 +74,805 @@
field.
* java/util/InvalidPropertiesFormatException.java: New file.
+2005-08-13 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/io/ObjectInputStream.java
+ (readClassDescriptor): Don't cache caller's class loader.
+ (resolveClass): Don't cache caller's class loader and support
+ primitive types. Fixes bug #23377.
+
+2005-08-13 Mark Wielaard <mark@klomp.org>
+
+ * scripts/check_jni_methods.sh: Set and check for PROBLEM.
+
+2005-08-13 Mark Wielaard <mark@klomp.org>
+
+ * scripts/check_jni_methods.sh: Don't create temp files in source dir.
+ Don't override existing files. Fast fail on errors.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * vm/reference/gnu/classpath/jdwp/VMFrame.java(getValue):
+ Fix typo in comment.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
+ (executeAllThreads): Use enumerate(Thread[]) instead of
+ enumerate(Thread[], true).
+ (runCommand): Throw NotImplementedException when command is not found.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
+ (executeInvokeMethod): Change MethodInvoker to MethodResult.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/util/VariableTable.java: A class representing a
+ Variable Table for a method.
+ * gnu/classpath/jdwp/util/LineTable.java: A class representing a Line
+ Table for a method.
+
+2005-08-12 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (addMenu(Menu)): New
+ method.
+ * gnu/java/awt/peer/gtk/GtkMenuPeer.java (addSeparator): Likewise.
+ * java/awt/peer/MenuBarPeer.java (addMenu): New method
+ declaration.
+ * java/awt/peer/MenuPeer.java (addSeparator): New method
+ declaration.
+
+2005-08-12 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java (setBounds): Get
+ frame insets directly from peer rather than from Window.getInsets.
+ (toString): New method.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/util/Location.java: New file to handle JDWP
+ locations.
+
+2005-08-12 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkButtonPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
+ (gtkWidgetGetPreferredDimensions): New method.
+ * gnu/java/awt/peer/gtk/GtkLabelPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
+ (gtkWidgetGetPreferredDimensions): New method.
+ * include/gnu_java_awt_peer_gtk_GtkLabelPeer.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GtkButtonPeer.h: Likewise.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/exception/JdwpInternalErrorException.java
+ (JdwpInternalErrorException): Added new constructor.
+ * gnu/classpath/jdwp/util/Value.java
+ (getUntaggedObj):
+ Changed InvalidFieldException to JdwpInternalErrorException.
+ (writeUntaggedValue): Likewise.
+ (writeTaggedValue): Likewise.
+ (writeValue): Likewise.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/EventRequestCommandSet.java:
+ Implemented the EventRequest CommandSet.
+
+2005-08-12 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTable.java:
+ (setValueAt): Do nothing if isCellEditable returns false.
+ (editCelLAt): Removed the Key Listener for the JTextField. Listening
+ for ESCAPE should be handled by the JTable itself. Note, this is not
+ implemented yet.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java:
+ (initComponentDefaults): Added several keybindings to JTable's
+ ancestorInputMap. These are all implemented.
+ * javax/swing/plaf/basic/BasicTableUI.java:
+ (KeyHandler): Removed this class. Note that most of the code from the
+ keyPressed method now resides in the actionPerformed method of the
+ BasicTableUI.TableAction class.
+ (convertModifiers): New private method to convert from new InputEvent
+ modifier masks to the old style.
+ (installKeyboardActions): Implemented. Gets the key bindings from
+ the UIManager and registers them for the JTable.
+ (TableAction): New class. This is where the actions corresponding to
+ key presses resides.
+ (installListeners): Removed installation of KeyListener.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * vm/reference/standard.omit: New file to omit jdwp reference classes
+ from build.
+
+2005-08-12 Aaron Luchko <aluchko@redhat.com>
+
+ * vm/reference/gnu/classpath/jdwp/VMFrame.java: Implemented reference
+ implementation of interface to VM for JDWP frame management.
+ * gnu/classpath/jdwp/processor/StackFrameCommandSet.java: Updated
+ import.
+ (executeGetValues): Use VMFrame instead of Frame.
+ (executeSetValues): Use VMFrame instead of Frame.
+ (executeThisObject): Use VMFrame instead of Frame.
+ * gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java:
+ Updated import.
+ (executeFrames): Changed getLoc() to getLocation() and use
+ VMFrame instead of Frame.
+
+2005-08-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (getCellLocation): Added in a check to make sure the node has children.
+ Fixed loop to use post-increment.
+ (paintRecursive): Fixed loop to use post-increment.
+ (paintControlIcons): Likewise.
+ (getNextNode): Fixed check to make sure that node has children.
+ (getPreviousSibling): Added in check to make sure index is in correct
+ range.
+
+2005-08-12 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/qt/QtButtonPeer.java: Replace uses of
+ toolkit.eventQueue.postEvent() with QtToolkit.eventQueue.postEvent().
+ * gnu/java/awt/peer/qt/QtCheckboxPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtChoicePeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtComponentPeer.java: Likewise and for
+ guiThread.QApplicationPointer and graphicsEnv.getScreenDevices().
+ * gnu/java/awt/peer/qt/QtMenuItemPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtMenuPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtScrollbarPeer.java: Likewise.
+ * gnu/java/security/PolicyFile.javai (refresh): Assign only outside
+ if statement.
+
+2005-08-12 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/text/GapContent.java
+ (insertString): Use replace() to actually insert content.
+ (remove): Use replace() to actually remove content.
+ (shiftGap): Repaired misplaced curly brace in if block of
+ boudary check.
+ (replace): Check for null argument for addItems.
+
+2005-08-12 Roman Kennke <roman@kennke.org>
+
+ Reported by: Ingo Proetel <proetel@aicas.com>
+ * java/net/URLClassLoader.java
+ (findClass): Added null check to avoid NullPointerException.
+
+2005-08-12 Roman Kennke <roman@kennke.org>
+
+ Reported by: Ingo Proetel <proetel@aicas.com>
+ * java/util/logging/Logger.java
+ This applies to a couple of log() methods:
+ (log): Added check if the specified level is actually enabled,
+ otherwise ignore logging request.
+
+2005-08-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ * (getMinimumDividerLocation): Fixed to work similar to
+ getMaximumDividerLocation. Was not able to move divider
+ in both directions before.
+
+2005-08-12 Roman Kennke <roman@kennke.org>
+
+ * java/awt/Component.java
+ (reshape): Simplified repainting of parent.
+ (paint): Don't call peer.paint() here. The paint method is
+ exclusivly meant to be overridden by subclasses that wish to
+ perform custom painting and should do nothing by default.
+ (repaint): Use local variable in null pointer checks to avoid
+ NullPointerExceptions.
+ (imageUpdate): Slight formatting adjustments.
+ (dispatchEvent): Don't call peer.handleEvent() here, this must
+ be done in dispatchEventImpl().
+ (dispatchEventImpl): Dispatch PAINT and UPDATE events to the
+ peer.
+ * java/awt/Container.java
+ (paint): Don't call super.paint() here, this method does nothing
+ anyway. Visit only lightweight children.
+ (update): Instead of clearing the background only for top-level
+ containers, clear the background for all heavyweight containers.
+
+2005-08-12 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * examples/gnu/classpath/examples/jawt/DemoJAWT.c: New file.
+ * examples/gnu/classpath/examples/jawt/DemoJAWT.java: Likewise.
+ * examples/gnu/classpath/examples/jawt/Makefile: Likewise.
+
+2005-08-11 Mark Wielaard <mark@klomp.org>
+
+ * examples/gnu/classpath/examples/datatransfer/Demo.java:
+ New example.
+
+2005-08-11 Tom Tromey <tromey@redhat.com>
+
+ For PR classpath/23008:
+ * gnu/java/nio/charset/UTF_16Decoder.java (decodeLoop): Correctly
+ mask bytes when constructing characters.
+
+2005-08-11 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/classpath/Makefile.am (EXTRA_DIST): Add classpath_jawt.h.
+ * include/gnu_java_awt_peer_qt_*: Removed.
+
+2005-08-11 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/PortableInterceptor/IORInfoOperations.java,
+ org/omg/PortableInterceptor/IORInterceptor.java,
+ org/omg/PortableInterceptor/IORInterceptorOperations.java,
+ org/omg/PortableInterceptor/IORInfo.java: New files.
+
+2005-08-11 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTable
+ (rowAtPoint): Added in a check for null. Was getting NPE.
+ (columnAtPoint): Likewise.
+
+2005-08-11 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicViewportUI.java
+ (paintSimple): Changed to paint the portBounds from (0,0).
+
+2005-08-11 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/image/ConvolveOp.java (filter): Defer numBands check
+ until after null check. PR classpath/22999.
+
+2005-08-11 Tom Tromey <tromey@redhat.com>
+
+ * java/util/Observable.java (addObserver): Throw
+ NullPointerException if necessary. PR classpath/23279.
+
+2005-08-11 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/qt/QtMenuComponentPeer.java,
+ gnu/java/awt/peer/qt/QtGraphics.java,
+ gnu/java/awt/peer/qt/QtTextFieldPeer.java,
+ gnu/java/awt/peer/qt/QtFramePeer.java,
+ gnu/java/awt/peer/qt/QtPanelPeer.java,
+ gnu/java/awt/peer/qt/QtToolkit.java,
+ gnu/java/awt/peer/qt/QtWindowPeer.java,
+ gnu/java/awt/peer/qt/QtButtonPeer.java,
+ gnu/java/awt/peer/qt/QtImageGraphics.java,
+ gnu/java/awt/peer/qt/QtContainerPeer.java,
+ gnu/java/awt/peer/qt/QtComponentPeer.java,
+ gnu/java/awt/peer/qt/QtListPeer.java,
+ gnu/java/awt/peer/qt/QtChoicePeer.java,
+ gnu/java/awt/peer/qt/QtScrollPanePeer.java,
+ gnu/java/awt/peer/qt/MainQtThread.java,
+ gnu/java/awt/peer/qt/QtImage.java,
+ gnu/java/awt/peer/qt/NativeWrapper.java,
+ gnu/java/awt/peer/qt/QtCheckboxPeer.java,
+ gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java,
+ gnu/java/awt/peer/qt/QtTextAreaPeer.java,
+ gnu/java/awt/peer/qt/QtDialogPeer.java,
+ gnu/java/awt/peer/qt/QPen.java,
+ gnu/java/awt/peer/qt/QtCanvasPeer.java,
+ gnu/java/awt/peer/qt/QtLabelPeer.java,
+ gnu/java/awt/peer/qt/QtGraphicsEnvironment.java,
+ gnu/java/awt/peer/qt/QtImageConsumer.java,
+ gnu/java/awt/peer/qt/QtScrollbarPeer.java,
+ gnu/java/awt/peer/qt/QtFontMetrics.java,
+ gnu/java/awt/peer/qt/QtMenuBarPeer.java,
+ gnu/java/awt/peer/qt/QtFontPeer.java,
+ gnu/java/awt/peer/qt/QMatrix.java,
+ gnu/java/awt/peer/qt/QtVolatileImage.java,
+ gnu/java/awt/peer/qt/QPainterPath.java,
+ gnu/java/awt/peer/qt/QtComponentGraphics.java,
+ gnu/java/awt/peer/qt/QtScreenDevice.java,
+ gnu/java/awt/peer/qt/QtMenuPeer.java,
+ gnu/java/awt/peer/qt/QtAudioClip.java,
+ gnu/java/awt/peer/qt/QtPopupMenuPeer.java,
+ gnu/java/awt/peer/qt/QtFileDialogPeer.java,
+ gnu/java/awt/peer/qt/QtMenuItemPeer.java,
+ * native/jni/qt-peer/qpen.cpp,
+ native/jni/qt-peer/keybindings.cpp,
+ native/jni/qt-peer/qtcomponentpeer.cpp,
+ native/jni/qt-peer/buttonevent.h,
+ native/jni/qt-peer/qtdialogpeer.cpp,
+ native/jni/qt-peer/qtmenubarpeer.cpp,
+ native/jni/qt-peer/mainqtthread.cpp,
+ native/jni/qt-peer/qtpanelpeer.cpp,
+ native/jni/qt-peer/qmatrix.cpp,
+ native/jni/qt-peer/qtmenucomponentpeer.cpp,
+ native/jni/qt-peer/qtgraphics.cpp,
+ native/jni/qt-peer/qttoolkit.cpp,
+ native/jni/qt-peer/qtbuttonpeer.cpp,
+ native/jni/qt-peer/keybindings.h,
+ native/jni/qt-peer/qtvolatileimage.cpp,
+ native/jni/qt-peer/qtcomponent.h,
+ native/jni/qt-peer/slotcallbacks.cpp,
+ native/jni/qt-peer/qtpopupmenupeer.cpp,
+ native/jni/qt-peer/qtmenuitempeer.cpp,
+ native/jni/qt-peer/qtchoicepeer.cpp,
+ native/jni/qt-peer/nativewrapper.cpp,
+ native/jni/qt-peer/qtscreendevice.cpp,
+ native/jni/qt-peer/qtfontpeer.cpp,
+ native/jni/qt-peer/qpainterpath.cpp,
+ native/jni/qt-peer/qtstrings.h,
+ native/jni/qt-peer/qttextfieldpeer.cpp,
+ native/jni/qt-peer/qtimage.cpp,
+ native/jni/qt-peer/componentevent.h,
+ native/jni/qt-peer/qtwindowpeer.cpp,
+ native/jni/qt-peer/qtframepeer.cpp,
+ native/jni/qt-peer/qtscrollpanepeer.cpp,
+ native/jni/qt-peer/qtfontmetrics.cpp,
+ native/jni/qt-peer/qtlistpeer.cpp,
+ native/jni/qt-peer/mainthreadinterface.h
+ native/jni/qt-peer/slotcallbacks.h
+ native/jni/qt-peer/qtfiledialogpeer.cpp,
+ native/jni/qt-peer/eventmethods.cpp,
+ native/jni/qt-peer/qtimage.h,
+ native/jni/qt-peer/qtstrings.cpp,
+ native/jni/qt-peer/nativewrapper.h
+ native/jni/qt-peer/qtaudioclip.cpp,
+ native/jni/qt-peer/qtfont.h,
+ native/jni/qt-peer/qtscrollbarpeer.cpp,
+ native/jni/qt-peer/containers.h,
+ native/jni/qt-peer/qtcheckboxpeer.cpp,
+ native/jni/qt-peer/mainthreadinterface.cpp,
+ native/jni/qt-peer/componentevent.cpp,
+ native/jni/qt-peer/qttextareapeer.cpp,
+ native/jni/qt-peer/qtcomponent.cpp,
+ native/jni/qt-peer/qtmenupeer.cpp,
+ native/jni/qt-peer/qtlabelpeer.cpp,
+ native/jni/qt-peer/slotcallbacks.moc
+ native/jni/qt-peer/qtcanvaspeer.cpp,
+ native/jni/qt-peer/qtgraphics.h,
+ * include/gnu_java_awt_peer_qt_QtCheckboxPeer.h,
+ include/gnu_java_awt_peer_qt_QtToolkit.h,
+ include/gnu_java_awt_peer_qt_QtAudioClip.h,
+ include/gnu_java_awt_peer_qt_QtScreenDevice.h,
+ include/gnu_java_awt_peer_qt_QtTextFieldPeer.h,
+ include/gnu_java_awt_peer_qt_QtMenuItemPeer.h,
+ include/gnu_java_awt_peer_qt_QtButtonPeer.h,
+ include/gnu_java_awt_peer_qt_QtWindowPeer.h,
+ include/gnu_java_awt_peer_qt_QtDialogPeer.h,
+ include/gnu_java_awt_peer_qt_QtImage.h,
+ include/gnu_java_awt_peer_qt_QtMenuBarPeer.h,
+ include/gnu_java_awt_peer_qt_QtVolatileImage.h,
+ include/gnu_java_awt_peer_qt_QtFontPeer.h,
+ include/gnu_java_awt_peer_qt_QtChoicePeer.h,
+ include/gnu_java_awt_peer_qt_QtGraphics.h,
+ include/gnu_java_awt_peer_qt_QtComponentPeer.h,
+ include/gnu_java_awt_peer_qt_QtMenuPeer.h,
+ include/gnu_java_awt_peer_qt_QtTextAreaPeer.h,
+ include/gnu_java_awt_peer_qt_QPen.h,
+ include/gnu_java_awt_peer_qt_QtPanelPeer.h,
+ include/gnu_java_awt_peer_qt_QPainterPath.h,
+ include/gnu_java_awt_peer_qt_QtFontMetrics.h,
+ include/gnu_java_awt_peer_qt_QtScrollPanePeer.h,
+ include/gnu_java_awt_peer_qt_QtGraphicsEnvironment.h,
+ include/gnu_java_awt_peer_qt_QMatrix.h,
+ include/gnu_java_awt_peer_qt_QtLabelPeer.h,
+ include/gnu_java_awt_peer_qt_QtPopupMenuPeer.h,
+ include/gnu_java_awt_peer_qt_QtFramePeer.h,
+ include/gnu_java_awt_peer_qt_QtListPeer.h,
+ include/gnu_java_awt_peer_qt_QtScrollbarPeer.h,
+ include/gnu_java_awt_peer_qt_QtCanvasPeer.h,
+ include/gnu_java_awt_peer_qt_QtMenuComponentPeer.h,
+ include/gnu_java_awt_peer_qt_MainQtThread.h,
+ include/gnu_java_awt_peer_qt_QtFileDialogPeer.h,
+ include/gnu_java_awt_peer_qt_QtContainerPeer.h:
+ New files.
+
+2005-08-11 Tom Tromey <tromey@redhat.com>
+
+ For PR classpath/23238:
+ * lib/gen-classlist.sh.in: Use @SHELL@; invoke split-for-gcj.sh
+ with it.
+ * configure.ac (SH): Removed subst.
+
+2005-08-11 Andrew Haley <aph@redhat.com>
+
+ * lib/split-for-gcj.sh: Comment.
+
+2005-08-11 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicViewportUI.java
+ (paintSimple): This line was causing problems with the JTable viewport.
+ However, the scrollpane still needs to be fixed. It is still not
+ painting beyond the view's bounds.
+
+2005-08-10 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * lib/split-for-gcj.sh: Don't use unportable %{parameter%word}.
+ Don't use unportable !.
+
+2005-08-10 Tom Tromey <tromey@redhat.com>
+
+ * lib/gen-classlist.sh.in (GCJ): New subst.
+ Invoke split-for-gcj.sh if the results changed.
+ * lib/Makefile.am (CLEANFILES): Removed old entries.
+ (compile-classes): Don't run split-for-gcj.sh.
+
+2005-08-10 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java:
+ Implemented the ThreadReference CommandSet.
+
+2005-08-10 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/ClassTypeCommandSet.java:
+ Implemented the ClassType CommandSet.
+ * gnu/classpath/jdwp/util/MethodResult.java: Class to wrap
+ around results of method executions.
+
+2005-08-10 Tom Tromey <tromey@redhat.com>
+
+ For PR classpath/22580:
+ * lib/Makefile.am (compile-classes): Made conditional on
+ FOUND_GCJ.
+ (JAVAC): Redefined when FOUND_GCJ.
+
+2005-08-10 Tom Tromey <tromey@redhat.com>
+
+ * lib/Makefile.am (JAVAC): Use $(SHELL) to invoke
+ split-for-gcj.sh. For PR classpath/23238.
+
+2005-08-10 Tom Tromey <tromey@redhat.com>
+
+ * lib/split-for-gcj.sh: Use 'while' loop to avoid length limits.
+
+2005-08-10 Andreas Tobler <toa@pop.agri.ch>
+
+ * native/jni/java-net/gnu_java_net_PlainSocketImpl.c: Include
+ target_native_file.h. PR classpath/22926.
+
+2005-08-10 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTree.java
+ (doExpandParents): Took out call to checkExpandParents.
+ (checkExpandParents): Helper method not needed. Caused problems since
+ fireTreeWillExpand was being called too many times. fireTreeWillExpand
+ is called from BasicTreeUI whenever a node is expanded.
+
+2005-08-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/PortableInterceptor/Interceptor.java,
+ org/omg/PortableInterceptor/InterceptorOperations.java: New files.
+ * org/omg/DynamicAny/_DynAnyFactoryStub.java,
+ org/omg/DynamicAny/_DynAnyStub.java,
+ org/omg/DynamicAny/_DynArrayStub.java,
+ org/omg/DynamicAny/_DynEnumStub.java,
+ org/omg/DynamicAny/_DynFixedStub.java,
+ org/omg/DynamicAny/_DynStructStub.java,
+ org/omg/DynamicAny/_DynUnionStub.java,
+ org/omg/DynamicAny/_DynValueStub.java,
+ org/omg/DynamicAny/_DynSequenceStub.java: Added _opsClass field.
+
+2005-08-10 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Formatted entire class.
+
+2005-08-10 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (mouseClicked): Called fireTreeWillExpand and fireTreeWillCollapse when
+ appropriate.
+ (keyPressed): Likewise.
+
+2005-08-10 Roman Kennke <roman@kennke.org>
+
+ * java/awt/Container.java
+ (paint): Call visitChildren with lightweightOnly == true.
+ (update): Only call paint if we are not in a toplevel container.
+
+2005-08-09 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/StackFrameCommandSet.java:
+ Implemented the StackFrame CommandSet.
+
+2005-08-09 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTable.java:
+ (editingCancelled): Implemented.
+ (editCellAt): Added a KeyListener to our editor to listen for
+ the ESCAPE key and cancel editing upon receiving it.
+
+2005-08-09 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTable.java
+ (setRowHeight): Fixed condition on when to throw exception.
+ (setRowHeight): Parameters were mixed up.
+
+2005-08-09 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicLabelUI.java
+ (paint): Added in painting code for label border.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (paintControlIcons): Fixed location for control icons.
+ * javax/swing/plaf/metal/MetalLookAndFeel.java:
+ Added defaults for selection and non-selection border for
+ tree cells.
+ * javax/swing/tree/DefaultTreeCellRenderer.java
+ (getTreeCellRendererComponent): Set borders for node. Also,
+ made node transparent (not opaque), So JLabel draws icon,
+ text and border appropriately.
+
+2005-08-09 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicLabelUI.java
+ (paint): Added in code to paint background rect according to
+ API. Also, formatting changes.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (setCellRenderer): Fixed to changed renderer in JTree.
+ (uninstallDefaults): Line taken out because not needed.
+ (paintNode): Took out unneeded code because BasicLabelUI was fixed.
+ (paintRecursive): Fixed so lines are only drawn when parents have
+ children.
+
+2005-08-09 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/DefaultCellEditor.java:
+ (EditorDelegate.setValue): Implemented.
+ (EditorDelegate.getCellEditorValue): Implemented.
+ (EditorDelegate.isCellEditable): Implemented.
+ (EditorDelegate.shouldSelectCell): Implemented.
+ (EditorDelegate.stopCellEditing): Implemented.
+ (EditorDelegate.cancelCellEditing): Implemented.
+ (EditorDelegate.startCellEditing): Implemented.
+ (EditorDelegate.actionPerformed): Implemented.
+ (EditorDelegate.itemStateChanged): Implemented.
+ (EditorDelegate.fireEditingStopped): New implementation method.
+ (EditorDelegate.fireEditingCancelled): New implementation method.
+ (DefaultCellEditor): Implemented 3 constructors.
+ (getComponent): Implemented.
+ (getClickCountToStart): Implemented.
+ (setClickCountToStart): Implemented.
+ (getCellEditorValue): Implemented.
+ (isCellEditable): Implemented.
+ (shouldSelectCell): Implemented.
+ (cancelCellEditing): Implemented.
+ (getTableCellEditorComponent): Implemented.
+ * javax/swing/JTable.java:
+ (EditorUpdateTimer): New private class.
+ (editingStopped): Implemented.
+ (setValueAt): If the Object value is a Component, add it to the JTable
+ so it can obtain focus.
+ (editCellAt): Implemented.
+ (removeEditor): Implemented.
+ (prepareEditor): Implemented.
+ * javax/swing/plaf/basic/BasicTableUI.java:
+ (KeyHandler.keyPressed): Added F2 "start editing" key action.
+ (MouseHandler.mousePressed): Added check to see if a new cell was
+ selected and we need to stop editing.
+ (paint): If the cell is a JTextField, paint its Caret as well.
+ * javax/swing/table/DefaultTableCellRenderer.java:
+ (getTableCellRendererComponent): If a JTextField is passed in, return
+ one. This is used for editing JTable cells.
+
+2005-08-09 Aaron Luchko <aluchko@redhat.com>
+
+ * gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java:
+ Implemented the ClassLoaderReference CommandSet.
+
+2005-08-09 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/tree/DefaultTreeModel.java: Fix copyright
+ boilerplate formatting.
+
+2005-08-09 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/tree/DefaultTreeModel.java:
+ Fixed formatting of class.
+
+2005-08-09 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #23255
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Fixed entire class to use Objects as opposed to TreeNodes.
+ (getPathBounds): Changed root to Object
+ (getPathForRow): Likewise.
+ (getRowCount): Likewise.
+ (getPreferredSize): Changed root and nextNode to be of type
+ Object.
+ (isLeaf): Took out unnecessary code.
+ (keyPressed): Changed all TreeNodes to be of type Object.
+ (getCellLocation): Likewise.
+ (paintNode): Likewise.
+ (paintRecursive): Likewise.
+ (getParent): Implemented.
+ (findNode): Helper Implemented.
+ (getNextVisibleNode): Changed return and parameter type to Object.
+ (getPreviousVisibleNode): Likewise.
+ (getNextNode): Likewise.
+ (getPreviousNode): Likewise.
+ (getNextSibling): Likewise.
+ (getPreviousSibling): Likewise.
+ (getPathToRoot): Likewise.
+ (getLevel): Likewise.
+ * javax/swing/tree/DefaultTreeModel.java
+ (getIndexOfChild): Implemented.
+
+2005-08-09 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/package.html: Documentation update.
+ * org/omg/DynamicAny/package.html: New file.
+
+2005-08-08 Casey Marshall <csm@gnu.org>
+
+ PR classpath/23120
+ * gnu/java/security/provider/DSAKeyPairGenerator.java
+ (<init>): made public; set default values.
+ (initialize): just call 'initialize(int,boolean,SecureRandom).'
+ (initialize): just call 'initialize(DSAParams,SecureRandom).'
+ (initialize): check all values for 'null' before overwriting.
+ (initialize): fill in defaults or generate new parameters here.
+ (generateKeyPair): don't create parameters; fill in 'random' if
+ 'null;' use 'random,' not a new Random object, when generating
+ random numbers.
+ (getDefaults): fix keysize check.
+
+ PR classpath/22990
+ * java/security/KeyPairGenerator.java (initialize): do nothing.
+
+2005-08-08 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/23285:
+ * native/jni/classpath/classpath_jawt.h
+ (classpath_jawt_get_awt_version, classpath_jawt_lock,
+ classpath_jawt_unlock, classpath_jawt_create_lock,
+ classpath_jawt_destroy_lock): Use '(void)' in prototype.
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Added
+ gtk_jawt.c.
+ * native/jni/gtk-peer/gtk_jawt.c: New file from libgcj.
+ (classpath_jawt_create_lock, classpath_jawt_destroy_lock): Use
+ cp_gtk_gdk_env.
+
+2005-08-08 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/DynamicAny/FieldNameHelper.java: New file.
+
+2005-08-08 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/DynamicAny/_DynAnyFactoryStub.java,
+ org/omg/DynamicAny/_DynAnyStub.java,
+ org/omg/DynamicAny/_DynArrayStub.java,
+ org/omg/DynamicAny/_DynEnumStub.java,
+ org/omg/DynamicAny/_DynFixedStub.java,
+ org/omg/DynamicAny/_DynStructStub.java,
+ org/omg/DynamicAny/_DynUnionStub.java,
+ org/omg/DynamicAny/_DynValueStub.java,
+ org/omg/DynamicAny/_DynSequenceStub.java: New files.
+
+2005-08-08 Lillian Angel <langel@redhat.com>
+
+ Fixes bug #23252
+ * javax/swing/JTree.java
+ (setModel): Changed to allow model to be null.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (setModel): Changed to depend on JTree functions
+ (getPathBounds): Fixed to work when model = null.
+ (getPathForRow): Likewise.
+ (getRowCount): Likewise.
+ (installListeners): Likewise.
+ (installUI): Likewise.
+ (paint): Likewise.
+ (getPreferredSize): Likewise.
+
+2005-08-08 Casey Marshall <csm@gnu.org>
+
+ Fixes bug #22914
+ * gnu/classpath/debug/Component.java (POLICY): new constant.
+ * gnu/java/security/PolicyFile.java (logger): new constant.
+ (DEBUG,debug,debug): removed.
+ (DEFAULT_POLICY): use 'SystemProperties' class to bypass security
+ check.
+ (DEFAULT_USER_POLICY): new constant.
+ (getPermissions): replace 'debug' calls with logger calls.
+ (refresh): add 'DEFAULT_USER_POLICY' to the initial list;
+ interpret 'java.security.policy' and 'policy.url' properties
+ properly; replace 'debug' calls with logger calls.
+ (parse): replace 'debug' calls with logger calls.
+
+2005-08-07 Casey Marshall <csm@gnu.org>
+
+ * javax/security/auth/x500/X500Principal.java
+ (encodeDer): use the right iterator for the inner loop.
+ (parseString): test for end of input.
+ (readAttributeType): provide detail message for exception.
+ (readAttributeValue): return the result on end of input;
+ read the next character while looping.
+ (putComponent): accept 'o' and 'ou' short names.
+
+2005-08-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/DynamicAny/AnySeqHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairSeqHelper.java,
+ org/omg/DynamicAny/NameValuePairHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairHelper.java,
+ org/omg/DynamicAny/NameValuePairSeqHelper.java,
+ org/omg/DynamicAny/DynAnySeqHelper.java,
+ gnu/CORBA/DynAnySeqHolder.java,
+ gnu/CORBA/NameDynAnyPairSeqHolder.java,
+ gnu/CORBA/NameDynAnyPairHolder.java,
+ gnu/CORBA/NameValuePairSeqHolder.java,
+ gnu/CORBA/NameValuePairHolder.java: New files.
+
+2005-08-07 Ito Kazumitsu <kaz@maczuka.gcd.org>
+
+ Fixes bug #22929
+ * java/net/NetworkInterface.java
+ (condense): New static private method.
+ (getNetworkInterfaces): Call condense().
+ (getByName, getByInetAddress): Call getNetworkInterfaces()
+ so that condensed result may be returned.
+ * vm/reference/java/net/VMNetworkInterface.java (getInterfaces):
+ Clarify return value in documentation.
+
+2005-08-07 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #22920
+ * java/net/DatagramSocket.java (DatagramSocket(SocketAddress)):
+ Use gnu.classpath.SystemProperties to get impl.prefix.
+
+2005-08-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/noHeaderInput.java,
+ gnu/CORBA/gnuValueHolder.java,
+ gnu/CORBA/DynAn/gnuDynAny.java,
+ gnu/CORBA/DynAn/gnuDynArray.java,
+ gnu/CORBA/DynAn/gnuDynSequence.java,
+ gnu/CORBA/DynAn/gnuDynValueBox.java,
+ gnu/CORBA/DynAn/abstractRecord.java,
+ gnu/CORBA/DynAn/gnuDynAnyFactory.java,
+ gnu/CORBA/DynAn/gnuDynValue.java,
+ gnu/CORBA/DynAn/gnuDynStruct.java,
+ gnu/CORBA/DynAn/anyDivideable.java,
+ gnu/CORBA/DynAn/anyUndivideable.java,
+ gnu/CORBA/DynAn/gnuDynEnum.java,
+ gnu/CORBA/DynAn/abstractDynAny.java,
+ gnu/CORBA/DynAn/gnuDynFixed.java,
+ gnu/CORBA/DynAn/valueChangedListener.java,
+ gnu/CORBA/DynAn/gnuDynUnion.java: New files.
+ * org/omg/DynamicAny/DynUnionOperations.java,
+ org/omg/DynamicAny/DynAnyOperations.java,
+ org/omg/DynamicAny/DynAnyFactoryOperations.java,
+ org/omg/DynamicAny/DynValueBox.java,
+ org/omg/DynamicAny/DynValueCommon.java,
+ org/omg/DynamicAny/DynAnyFactoryHelper.java,
+ gnu/CORBA/typeNamer.java,
+ gnu/CORBA/fixedTypeCode.java,
+ gnu/CORBA/CDR/Vio.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/holderFactory.java,
+ gnu/CORBA/universalHolder.java,
+ gnu/CORBA/Poa/ORB_1_4.java,
+ gnu/CORBA/Restricted_ORB.java,
+ gnu/CORBA/gnuAny.java,
+ org/omg/CORBA/TypeCode.java
+ org/omg/CORBA/Any.java,
+ org/omg/CORBA/ORB.java,
+ org/omg/CORBA/ObjectHelper.java,
+ org/omg/CORBA/ObjectHolder.java,
+ org/omg/CORBA_2_3/portable/InputStream.java,
+ org/omg/CORBA_2_3/portable/OutputStream.java,
+ gnu/CORBA/DynAn/NameValuePairHolder.java: Rewritten.
+
+2005-08-06 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/io/ObjectInputStream.java
+ (readClassDescriptor): Removed bogus handling of primitive types.
+ (readFields.GetField.defaulted): Pass cause to exception.
+ (readFields.GetField.getField): Pass cause to exception.
+ (newObject, callReadMethod): Call initCause on exception.
+
+2005-08-06 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/IllegalArgumentException.java,
+ java/lang/IllegalStateException.java,
+ java/lang/SecurityException.java,
+ java/lang/UnsupportedOperationException.java: Merged from generics
+ branch.
+
2005-08-05 Lillian Angel <langel@redhat.com>
* javax/swing/plaf/basic/BasicTreeUI.java:
diff --git a/configure.ac b/configure.ac
index 6f9a0156a..7363eb492 100644
--- a/configure.ac
+++ b/configure.ac
@@ -391,7 +391,6 @@ AC_SUBST(REMOVE)
dnl -----------------------------------------------------------
dnl This is probably useless.
dnl -----------------------------------------------------------
-AC_PATH_PROG(SH, sh)
AC_PATH_PROG(MKDIR, mkdir)
AC_PATH_PROG(CP, cp)
AC_PATH_PROG(DATE, date)
diff --git a/examples/gnu/classpath/examples/datatransfer/Demo.java b/examples/gnu/classpath/examples/datatransfer/Demo.java
new file mode 100644
index 000000000..93fa18f7d
--- /dev/null
+++ b/examples/gnu/classpath/examples/datatransfer/Demo.java
@@ -0,0 +1,457 @@
+/* Demo.java -- And example of copy/paste datatransfer
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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. */
+
+package gnu.classpath.examples.datatransfer;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.datatransfer.*;
+
+import java.io.*;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Random;
+
+class Demo
+ extends Frame
+ implements ActionListener
+{
+ public static void main(String args[])
+ {
+ new Demo();
+ }
+
+ private TextArea text;
+ private Button copyText;
+ private Button pasteText;
+
+ private ImageComponent image;
+ private Button copyImage;
+ private Button pasteImage;
+
+ private ObjectComponent object;
+ private Button copyObject;
+ private Button pasteObject;
+
+ private FilesComponent files;
+ private Button copyFiles;
+ private Button pasteFiles;
+
+ private Demo()
+ {
+ super("GNU Classpath datatransfer");
+ setLayout(new GridLayout(4, 1, 5, 5));
+ add(createTextPanel());
+ add(createImagePanel());
+ add(createObjectPanel());
+ add(createFilesPanel());
+ addWindowListener(new WindowAdapter ()
+ {
+ public void windowClosing (WindowEvent e)
+ {
+ dispose();
+ }
+ });
+ pack();
+ show();
+ }
+
+ private Panel createTextPanel()
+ {
+ Panel textPanel = new Panel();
+ textPanel.setLayout(new BorderLayout());
+ text = new TextArea("GNU Everywhere!",
+ 4, 40,
+ TextArea.SCROLLBARS_VERTICAL_ONLY);
+ text.setEditable(false);
+ text.setEnabled(true);
+ Panel textButtons = new Panel();
+ textButtons.setLayout(new FlowLayout());
+ copyText = new Button("Copy text");
+ copyText.addActionListener(this);
+ pasteText = new Button("Paste text");
+ pasteText.addActionListener(this);
+ textButtons.add(copyText);
+ textButtons.add(pasteText);
+ textPanel.add(text, BorderLayout.CENTER);
+ textPanel.add(textButtons, BorderLayout.SOUTH);
+ return textPanel;
+ }
+
+ private Panel createImagePanel()
+ {
+ Panel imagePanel = new Panel();
+ imagePanel.setLayout(new BorderLayout());
+ URL imageurl = this.getClass()
+ .getResource("/gnu/classpath/examples/icons/big-fullscreen.png");
+ Image img = Toolkit.getDefaultToolkit().createImage(imageurl);
+ image = new ImageComponent(img);
+ Panel imageButtons = new Panel();
+ copyImage = new Button("Copy image");
+ copyImage.addActionListener(this);
+ pasteImage = new Button("Paste image");
+ pasteImage.addActionListener(this);
+ imageButtons.add(copyImage);
+ imageButtons.add(pasteImage);
+ imagePanel.add(image, BorderLayout.CENTER);
+ imagePanel.add(imageButtons, BorderLayout.SOUTH);
+ return imagePanel;
+ }
+
+ private Panel createObjectPanel()
+ {
+ Panel objectPanel = new Panel();
+ objectPanel.setLayout(new BorderLayout());
+ Random random = new Random();
+ int x = (byte) random.nextInt();
+ int y = (byte) random.nextInt();
+ object = new ObjectComponent(new Point(x, y));
+ Panel objectButtons = new Panel();
+ copyObject = new Button("Copy object");
+ copyObject.addActionListener(this);
+ pasteObject = new Button("Paste object");
+ pasteObject.addActionListener(this);
+ objectButtons.add(copyObject);
+ objectButtons.add(pasteObject);
+ objectPanel.add(object, BorderLayout.CENTER);
+ objectPanel.add(objectButtons, BorderLayout.SOUTH);
+ return objectPanel;
+ }
+
+ private Panel createFilesPanel()
+ {
+ Panel filesPanel = new Panel();
+ filesPanel.setLayout(new BorderLayout());
+ files = new FilesComponent(new File(".").listFiles());
+ Panel filesButtons = new Panel();
+ copyFiles = new Button("Copy files");
+ copyFiles.addActionListener(this);
+ pasteFiles = new Button("Paste files");
+ pasteFiles.addActionListener(this);
+ filesButtons.add(copyFiles);
+ filesButtons.add(pasteFiles);
+ filesPanel.add(files, BorderLayout.CENTER);
+ filesPanel.add(filesButtons, BorderLayout.SOUTH);
+ return filesPanel;
+ }
+
+ public void actionPerformed (ActionEvent evt)
+ {
+ Button b = (Button) evt.getSource();
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ if (b == copyText)
+ c.setContents(new StringSelection(text.getText()), null);
+
+ if (b == pasteText)
+ {
+ String s = null;
+ try
+ {
+ s = (String) c.getData(DataFlavor.stringFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (s == null)
+ t.beep();
+ else
+ text.setText(s);
+ }
+
+ if (b == copyImage)
+ c.setContents(new ImageSelection(image.getImage()), null);
+
+ if (b == pasteImage)
+ {
+ Image i = null;
+ try
+ {
+ i = (Image) c.getData(DataFlavor.imageFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (i == null)
+ t.beep();
+ else
+ image.setImage(i);
+ }
+
+ if (b == copyObject)
+ c.setContents(new ObjectSelection(object.getObject()), null);
+
+ if (b == pasteObject)
+ {
+ Serializable o = null;
+ try
+ {
+ o = (Serializable) c.getData
+ (new DataFlavor(DataFlavor.javaSerializedObjectMimeType));
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ }
+ if (o == null)
+ t.beep();
+ else
+ object.setObject(o);
+ }
+
+ if (b == copyFiles)
+ c.setContents(new FilesSelection(files.getFiles()), null);
+
+ if (b == pasteFiles)
+ {
+ java.util.List fs = null;
+ try
+ {
+ fs = (java.util.List) c.getData(DataFlavor.javaFileListFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (fs == null)
+ t.beep();
+ else
+ files.setFiles(fs);
+ }
+ }
+
+ static class ImageComponent extends Component
+ {
+ private Image image;
+
+ ImageComponent(Image image)
+ {
+ setSize(120, 120);
+ setImage(image);
+ }
+
+ Image getImage()
+ {
+ return image;
+ }
+
+ void setImage(Image image)
+ {
+ this.image = image;
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
+ }
+ }
+
+ static class ObjectComponent extends TextArea
+ {
+ private Serializable object;
+
+ ObjectComponent(Serializable object)
+ {
+ super("", 2, 40, TextArea.SCROLLBARS_NONE);
+ setEditable(false);
+ setEnabled(false);
+ setObject(object);
+ }
+
+ Serializable getObject()
+ {
+ return object;
+ }
+
+ void setObject(Serializable object)
+ {
+ this.object = object;
+ setText("Class: " + object.getClass().getName()
+ + "\n"
+ + "toString(): " + object.toString());
+ repaint();
+ }
+ }
+
+ static class FilesComponent extends List
+ {
+ private File[] files;
+
+ FilesComponent(File[] files)
+ {
+ super(4, true);
+ setFiles(files);
+ }
+
+ File[] getFiles()
+ {
+ String[] strings = getSelectedItems();
+ if (strings == null || strings.length == 0)
+ return (File[]) files.clone();
+
+ File[] fs = new File[strings.length];
+ for (int i = 0; i < strings.length; i++)
+ fs[i] = new File(strings[i]);
+ return fs;
+ }
+
+ void setFiles(File[] files)
+ {
+ this.files = files;
+ removeAll();
+ for (int i = 0; i < files.length; i++)
+ {
+ addItem(files[i].toString());
+ select(i);
+ }
+ }
+
+ void setFiles(java.util.List list)
+ {
+ File[] fs = new File[list.size()];
+ int i = 0;
+ Iterator it = list.iterator();
+ while (it.hasNext())
+ fs[i++] = (File) it.next();
+
+ setFiles(fs);
+ }
+ }
+
+ static class ImageSelection implements Transferable
+ {
+ private final Image img;
+
+ ImageSelection(Image img)
+ {
+ this.img = img;
+ }
+
+ static DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(DataFlavor.imageFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return img;
+ }
+ }
+
+ static class ObjectSelection implements Transferable
+ {
+ private final Serializable obj;
+
+ ObjectSelection(Serializable obj)
+ {
+ this.obj = obj;
+ }
+
+ static DataFlavor objFlavor = new DataFlavor(Serializable.class,
+ "Serialized Object");
+ static DataFlavor[] flavors = new DataFlavor[] { objFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(objFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return obj;
+ }
+ }
+
+ static class FilesSelection implements Transferable
+ {
+ private final File[] files;
+
+ FilesSelection(File[] files)
+ {
+ this.files = files;
+ }
+
+ static DataFlavor[] flavors = new DataFlavor[]
+ { DataFlavor.javaFileListFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(DataFlavor.javaFileListFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return Arrays.asList(files);
+ }
+ }
+}
diff --git a/examples/gnu/classpath/examples/jawt/DemoJAWT.c b/examples/gnu/classpath/examples/jawt/DemoJAWT.c
new file mode 100644
index 000000000..990e1c438
--- /dev/null
+++ b/examples/gnu/classpath/examples/jawt/DemoJAWT.c
@@ -0,0 +1,147 @@
+/* DemoJAWT.c -- native portion of AWT Native Interface demo
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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. */
+
+#include "DemoJAWT.h"
+#include "jawt_md.h"
+#include <string.h>
+
+JNIEXPORT void JNICALL
+Java_DemoJAWT_paint (JNIEnv* env, jobject canvas, jobject graphics)
+{
+ JAWT awt;
+ JAWT_DrawingSurface* surface;
+ JAWT_DrawingSurfaceInfo* surface_info;
+ JAWT_X11DrawingSurfaceInfo* surface_info_x11;
+ jint lock;
+ GC gc;
+ int c;
+ char* test_string = "JAWT";
+ XColor orange;
+ XColor yellow;
+ XColor blue;
+ Display* display;
+ Drawable drawable;
+ Status status;
+
+ awt.version = JAWT_VERSION_1_3;
+ if (JAWT_GetAWT (env, &awt) == JNI_FALSE)
+ {
+ printf ("couldn't find AWT\n");
+ return;
+ }
+
+ surface = awt.GetDrawingSurface (env, canvas);
+ if (surface == NULL)
+ {
+ printf ("drawing surface is NULL\n");
+ return;
+ }
+
+ lock = surface->Lock (surface);
+ if ((lock & JAWT_LOCK_ERROR) != 0)
+ {
+ printf ("couldn't lock drawing surface\n");
+ awt.FreeDrawingSurface (surface);
+ return;
+ }
+
+ surface_info = surface->GetDrawingSurfaceInfo (surface);
+ if (surface_info == NULL)
+ {
+ printf ("couldn't get surface information\n");
+ surface->Unlock (surface);
+ awt.FreeDrawingSurface (surface);
+ return;
+ }
+
+ surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
+
+ display = surface_info_x11->display;
+ drawable = surface_info_x11->drawable;
+
+ gc = XCreateGC (display, drawable, 0, 0);
+ XSetBackground (display, gc, 0);
+
+ orange.red = 254 * 65535 / 255;
+ orange.green = 90 * 65535 / 255;
+ orange.blue = 16 * 65535 / 255;
+
+ /* assume color lookups succeed */
+ status = XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &orange);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ yellow.red = 255 * 65535 / 255;
+ yellow.green = 255 * 65535 / 255;
+ yellow.blue = 0 * 65535 / 255;
+
+ XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &yellow);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ blue.red = 16 * 65535 / 255;
+ blue.green = 30 * 65535 / 255;
+ blue.blue = 137 * 65535 / 255;
+
+ XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &blue);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ for (c = 5; c >= 0; c--)
+ {
+ if (c % 2)
+ XSetForeground (display, gc, yellow.pixel);
+ else
+ XSetForeground (display, gc, orange.pixel);
+
+ XFillArc (display, drawable, gc, 140 - c * 15, 140 - c * 15, c * 30, c * 30, 0, 360 * 64);
+ }
+
+ XSetForeground (display, gc, blue.pixel);
+ XDrawString (display, drawable,
+ gc, 129, 145, test_string, strlen (test_string));
+
+ cleanup:
+ XFreeGC (display, gc);
+
+ surface->FreeDrawingSurfaceInfo (surface_info);
+
+ surface->Unlock (surface);
+
+ awt.FreeDrawingSurface (surface);
+}
diff --git a/examples/gnu/classpath/examples/jawt/DemoJAWT.java b/examples/gnu/classpath/examples/jawt/DemoJAWT.java
new file mode 100644
index 000000000..4f55442fe
--- /dev/null
+++ b/examples/gnu/classpath/examples/jawt/DemoJAWT.java
@@ -0,0 +1,53 @@
+/* DemoJAWT.java -- AWT Native Interface demo
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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. */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class DemoJAWT extends Canvas
+{
+ static
+ {
+ System.loadLibrary ("DemoJAWT");
+ }
+
+ public native void paint (Graphics g);
+
+ public static void main (String[] args)
+ {
+ Frame f = new Frame ();
+
+ f.setBounds (0, 0, 300, 300);
+
+ f.setResizable (false);
+
+ f.add (new DemoJAWT ());
+
+ f.addWindowListener (new WindowAdapter ()
+ {
+ public void windowClosing (WindowEvent evt)
+ {
+ System.exit (0);
+ }
+ });
+
+ f.show ();
+ }
+}
diff --git a/examples/gnu/classpath/examples/jawt/Makefile b/examples/gnu/classpath/examples/jawt/Makefile
new file mode 100644
index 000000000..974a2f487
--- /dev/null
+++ b/examples/gnu/classpath/examples/jawt/Makefile
@@ -0,0 +1,20 @@
+all: \
+ DemoJAWT.h DemoJAWT.class libDemoJAWT.so
+
+%.class: %.java
+ gcj -C $<
+
+%.h: %.class
+ gcjh -jni $(basename $< .class)
+
+DemoJAWT: DemoJAWT.java
+ gcj -g --main=DemoJAWT -fjni -o DemoJAWT DemoJAWT.java
+
+libDemoJAWT.so: DemoJAWT.c
+ gcc -g -O0 -Wall -I. -I/usr/X11R6/include -shared -o $@ DemoJAWT.c -L. -ljawt -L/usr/X11R6/lib -lX11
+
+run:
+ LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:. jamvm DemoJAWT
+
+clean:
+ rm -f DemoJAWT.h DemoJAWT.class DemoJAWT\$$1.class libDemoJAWT.so
diff --git a/gnu/CORBA/CDR/Vio.java b/gnu/CORBA/CDR/Vio.java
index 8f17bd2f5..d7a749dd6 100644
--- a/gnu/CORBA/CDR/Vio.java
+++ b/gnu/CORBA/CDR/Vio.java
@@ -46,6 +46,7 @@ import org.omg.CORBA.DataOutputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.portable.*;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
@@ -55,6 +56,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
+import java.lang.reflect.Method;
+
/**
* A specialised class for reading and writing the value types.
*
@@ -222,7 +225,7 @@ public abstract class Vio
throw new MARSHAL("Unable to instantiate the value type");
else
{
- read_instance(input, ox, value_tag);
+ read_instance(input, ox, value_tag, null);
return (Serializable) ox;
}
}
@@ -285,7 +288,7 @@ public abstract class Vio
}
}
- read_instance(input, ox, value_tag);
+ read_instance(input, ox, value_tag, null);
return (Serializable) ox;
}
catch (Exception ex)
@@ -301,17 +304,22 @@ public abstract class Vio
* an instance.
*
* @param input a stream to read from.
- * @param value_instance an instance of the value.
+ *
+ * @param value_instance an pre-created instance of the value. If the
+ * helper is not null, this parameter is ignored an should be null.
+ *
+ * @param helper a helper to create an instance and read the object-
+ * specific part of the record. If the value_instance is used instead,
+ * this parameter should be null.
*
* @return the loaded value.
*
* @throws MARSHAL if the reading has failed due any reason.
*/
- public static Serializable read(InputStream input, Serializable value_instance)
+ public static Object read(InputStream input, Object value_instance,
+ Object helper
+ )
{
- // Explicitly prevent the stream from closing as we may need
- // to read the subsequent bytes as well. Stream may be auto-closed
- // in its finalizer.
try
{
int value_tag = input.read_long();
@@ -345,8 +353,9 @@ public abstract class Vio
}
}
- read_instance(input, value_instance, value_tag);
- return (Serializable) value_instance;
+ value_instance =
+ read_instance(input, value_instance, value_tag, helper);
+ return value_instance;
}
catch (Exception ex)
{
@@ -355,18 +364,43 @@ public abstract class Vio
}
/**
+ * Read using provided boxed value helper. This method expects
+ * the full value type header, followed by contents, that are
+ * delegated to the provided helper. It handles null.
+ *
+ * @param input the stream to read from.
+ * @param helper the helper that reads the type-specific part of
+ * the content.
+ *
+ * @return the value, created by the helper, or null if the
+ * header indicates that null was previously written.
+ */
+ public static Serializable read(InputStream input, Object helper)
+ {
+ return (Serializable) read(input, null, helper);
+ }
+
+ /**
* Fill in the instance fields by the data from the input stream.
* The method assumes that the value header, if any, is already
* behind. The information from the stream is stored into the
* passed ox parameter.
*
* @param input an input stream to read from.
- * @param value a value type object, must be either Streamable or
- * CustomMarshal.
+ *
+ * @param value a pre-instantiated value type object, must be either
+ * Streamable or CustomMarshal. If the helper is used, this parameter
+ * is ignored and should be null.
+ *
+ * @param value_tag the tag that must be read previously.
+ * @param helper the helper for read object specific part; may be
+ * null to read in using other methods.
+ *
+ * @return the value that was read.
*/
- public static void read_instance(InputStream input, Object value,
- int value_tag
- )
+ private static Object read_instance(InputStream input, Object value,
+ int value_tag, Object helper
+ )
{
try
{
@@ -377,7 +411,7 @@ public abstract class Vio
// Read all chunks.
int chunk_size = input.read_long();
- if (chunk_size <= 0)
+ if (chunk_size < 0)
throw new MARSHAL("Invalid first chunk size " + chunk_size);
byte[] r = new byte[ chunk_size ];
@@ -412,12 +446,29 @@ public abstract class Vio
// More than one chunk was present.
// Add the last chunk.
bout.write(r, 0, n);
- input = new cdrBufInput(bout.toByteArray());
+ input = new noHeaderInput(bout.toByteArray());
}
else
{
// Only one chunk was present.
- input = new cdrBufInput(r);
+ input = new noHeaderInput(r);
+ }
+ }
+ else
+ {
+ if (input instanceof cdrBufInput)
+ {
+ // Highly probable case.
+ input =
+ new noHeaderInput(((cdrBufInput) input).buffer.getBuffer());
+ }
+ else
+ {
+ cdrBufOutput bout = new cdrBufOutput();
+ int c;
+ while ((c = input.read()) >= 0)
+ bout.write((byte) c);
+ input = new noHeaderInput(bout.buffer.toByteArray());
}
}
}
@@ -447,6 +498,11 @@ public abstract class Vio
{
((Streamable) value)._read(input);
}
+ else if (helper instanceof BoxedValueHelper)
+ value = ((BoxedValueHelper) helper).read_value(input);
+ else if (helper instanceof ValueFactory)
+ value =
+ ((ValueFactory) helper).read_value((org.omg.CORBA_2_3.portable.InputStream) input);
else
// Stating the interfaces that the USER should use.
@@ -462,6 +518,8 @@ public abstract class Vio
if (eor >= 0)
throw new MARSHAL("End of state marker has an invalid value " + eor);
}
+
+ return value;
}
/**
@@ -527,7 +585,35 @@ public abstract class Vio
if (value == null)
output.write_long(vt_NULL);
else
- write_instance(output, value, id);
+ write_instance(output, value, id, null);
+ }
+
+ /**
+ * Write standard value type header, followed by contents, produced
+ * by the boxed value helper.
+ *
+ * @param output the stream to write to.
+ * @param value the value to write, can be null.
+ * @param helper the helper that writes the value content if it is
+ * not null.
+ */
+ public static void write(OutputStream output, Serializable value,
+ Object helper
+ )
+ {
+ if (value == null)
+ output.write_long(vt_NULL);
+ else
+ {
+ String id;
+
+ if (helper instanceof BoxedValueHelper)
+ id = ((BoxedValueHelper) helper).get_id();
+ else
+ id = "";
+
+ write_instance(output, value, id, helper);
+ }
}
/**
@@ -537,9 +623,11 @@ public abstract class Vio
* @param output an output stream to write into.
* @param value a value to write.
* @param id a value repository id.
+ * @param helper a helper, writing object - specifica part. Can be null
+ * if the value should be written unsing other methods.
*/
private static void write_instance(OutputStream output, Serializable value,
- String id
+ String id, Object helper
)
{
// This implementation always writes a single repository id.
@@ -563,6 +651,11 @@ public abstract class Vio
output.write_long(value_tag);
output.write_string(id);
+ if (helper instanceof BoxedValueHelper)
+ {
+ ((BoxedValueHelper) helper).write_value(outObj, value);
+ }
+ else
// User defince write method is present.
if (value instanceof CustomMarshal)
{
@@ -580,11 +673,38 @@ public abstract class Vio
((Streamable) value)._write(outObj);
}
else
+ {
+ // Try to find helper via class loader.
+ boolean ok = false;
+ try
+ {
+ Class helperClass = Class.forName(ObjectCreator.toHelperName(id));
+
+ // It will be the helper for the encapsulated boxed value, not the
+ // for the global boxed value type itself.
+ Method write =
+ helperClass.getMethod("write",
+ new Class[]
+ {
+ org.omg.CORBA.portable.OutputStream.class,
+ value.getClass()
+ }
+ );
+ write.invoke(null, new Object[] { outObj, value });
+ ok = true;
+ }
+ catch (Exception ex)
+ {
+ ok = false;
+ }
- // Stating the interfaces that the USER should use.
- throw new MARSHAL("The " + value.getClass().getName() +
- " must implement either StreamableValue or CustomValue."
- );
+ // Stating the interfaces that the USER should use.
+ if (!ok)
+ throw new MARSHAL("The " + value.getClass().getName() +
+ " must implement either StreamableValue" +
+ " or CustomValue."
+ );
+ }
if (USE_CHUNKING)
{
@@ -611,8 +731,8 @@ public abstract class Vio
*
* @throws NO_IMPLEMENT, always.
*/
- private static void incorrect_plug_in(Throwable ex)
- throws NO_IMPLEMENT
+ static void incorrect_plug_in(Throwable ex)
+ throws NO_IMPLEMENT
{
NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in");
no.initCause(ex);
diff --git a/gnu/CORBA/CDR/cdrInput.java b/gnu/CORBA/CDR/cdrInput.java
index 859f93ae5..69f9c8c58 100644
--- a/gnu/CORBA/CDR/cdrInput.java
+++ b/gnu/CORBA/CDR/cdrInput.java
@@ -1180,7 +1180,8 @@ public abstract class cdrInput
}
// Discard the null terminator and, if needed, the endian marker.
- return new String(s, p, n - nt - p);
+ String r = new String(s, p, n - nt - p);
+ return r;
}
catch (EOFException ex)
{
diff --git a/gnu/CORBA/CDR/cdrOutput.java b/gnu/CORBA/CDR/cdrOutput.java
index 86ca3b1cb..36a00e132 100644
--- a/gnu/CORBA/CDR/cdrOutput.java
+++ b/gnu/CORBA/CDR/cdrOutput.java
@@ -99,7 +99,7 @@ public abstract class cdrOutput
/**
* The GIOP version.
*/
- protected Version giop = new Version(1, 0);
+ protected Version giop = new Version(1, 2);
/**
* The code set information.
diff --git a/gnu/CORBA/CDR/noHeaderInput.java b/gnu/CORBA/CDR/noHeaderInput.java
new file mode 100644
index 000000000..0c787ddc2
--- /dev/null
+++ b/gnu/CORBA/CDR/noHeaderInput.java
@@ -0,0 +1,166 @@
+/* noHeaderInput.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.CORBA.CDR;
+
+import org.omg.CORBA.CustomMarshal;
+import org.omg.CORBA.DataInputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.CORBA.portable.ValueFactory;
+
+import java.io.Serializable;
+
+/**
+ * Substitutes the main stream in factories when the header is already
+ * behind. Overrides methods that may be invoked from the factory,
+ * forcing not to read the header if called first time on this stream.
+ *
+ * This stream reverts to default behavior if one or more call are
+ * made (reading value types that are nested fields of the value type).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+class noHeaderInput
+ extends cdrBufInput
+ implements DataInputStream
+{
+ /**
+ * If true, this is not the first call.
+ */
+ boolean notFirst;
+
+ /**
+ * Create an instance, reading from the given buffer.
+ */
+ public noHeaderInput(byte[] buffer)
+ {
+ super(buffer);
+ }
+
+ /**
+ * Read when knowning the class instance.
+ */
+ public Serializable read_value(Class clz)
+ {
+ if (notFirst)
+ return super.read_value(clz);
+ else
+ {
+ try
+ {
+ notFirst = true;
+ return read_value((Serializable) clz.newInstance());
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Unable to create an instance");
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ }
+
+ /**
+ * Tries to read using boxed value helper.
+ */
+ public Serializable read_value(BoxedValueHelper helper)
+ {
+ if (notFirst)
+ return super.read_value(helper);
+ else
+ {
+ notFirst = true;
+ return helper.read_value(this);
+ }
+ }
+
+ /**
+ * Tries to locate a factory using repository id.
+ */
+ public Serializable read_value(String repository_id)
+ {
+ if (notFirst)
+ return super.read_value(repository_id);
+ else
+ {
+ notFirst = true;
+
+ ValueFactory factory =
+ ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
+ if (factory == null)
+ throw new MARSHAL("No factory");
+ return factory.read_value(this);
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Serializable value)
+ {
+ if (notFirst)
+ return super.read_value(value);
+ else
+ {
+ notFirst = true;
+
+ // The user-defines io operations are implemented.
+ if (value instanceof CustomMarshal)
+ {
+ CustomMarshal marsh = (CustomMarshal) value;
+ try
+ {
+ marsh.unmarshal((DataInputStream) this);
+ }
+ catch (ClassCastException ex)
+ {
+ Vio.incorrect_plug_in(ex);
+ }
+ }
+ else
+ // The IDL-generated io operations are implemented.
+ if (value instanceof Streamable)
+ {
+ ((Streamable) value)._read(this);
+ }
+ return value;
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/NameValuePairHolder.java b/gnu/CORBA/DynAn/NameValuePairHolder.java
index 7afc81cd4..2558f5335 100644
--- a/gnu/CORBA/DynAn/NameValuePairHolder.java
+++ b/gnu/CORBA/DynAn/NameValuePairHolder.java
@@ -46,9 +46,8 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
- * The name-value pair holder. The {@link NameValuePair} has no standard
- * holder defined, but it is needed to store the {@link NameValuePair} into
- * {@link Any}.
+ * The name-value pair holder. The {@link NameValuePair} has no standard holder
+ * defined, but it is needed to store the {@link NameValuePair} into {@link Any}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
@@ -92,4 +91,4 @@ public class NameValuePairHolder
{
NameValuePairHelper.write(output, value);
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/abstractDynAny.java b/gnu/CORBA/DynAn/abstractDynAny.java
new file mode 100644
index 000000000..47176c4b5
--- /dev/null
+++ b/gnu/CORBA/DynAn/abstractDynAny.java
@@ -0,0 +1,177 @@
+/* abstractDynAny.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.CORBA.DynAn;
+
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * The top of our DynAny implementation, this class provides ORB that is
+ * required to create anys and factory that is required to initialise DynAnys.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class abstractDynAny
+ extends LocalObject
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The "initial final_type" that can be an alias of the known final_type.
+ */
+ public TypeCode official_type;
+
+ /**
+ * The "basic" final_type to that the final_type finally evaluates.
+ */
+ public final TypeCode final_type;
+
+ /**
+ * The DynAny factory, required in initializations.
+ */
+ public final gnuDynAnyFactory factory;
+
+ /**
+ * The ORB, to that this DynAny belongs.
+ */
+ public final ORB orb;
+
+ /**
+ * The minor code, indicating the error, related to work with non - GNU
+ * Classpath DynAny.
+ */
+ short MINOR = 8148;
+
+ /**
+ * The message about the empty structure or exception.
+ */
+ static final String EMPTY = "Empty structure with no fields.";
+
+ /**
+ * The message about the structure or exception size mismatch.
+ */
+ static final String SIZE = "Size mismatch.";
+
+ /**
+ * The message about the content of this DynAny being equal to
+ * <code>null</code>
+ */
+ static final String ISNULL = "The content is null";
+
+ /**
+ * The change value listener.
+ */
+ valueChangedListener listener;
+
+ /**
+ * Create the abstract dyn any.
+ */
+ public abstractDynAny(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ official_type = oType;
+ final_type = aType;
+ factory = aFactory;
+ orb = anOrb;
+ }
+
+ /**
+ * Get the typecode.
+ */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Create the Any.
+ */
+ public Any createAny()
+ {
+ return orb.create_any();
+ }
+
+ /**
+ * The "value changed" listener.
+ */
+ protected void valueChanged()
+ {
+ if (listener != null)
+ listener.changed();
+ }
+
+ /**
+ * Check the type.
+ */
+ void checkType(TypeCode expected, TypeCode actual)
+ throws TypeMismatch
+ {
+ if (!expected.equal(actual))
+ throw new TypeMismatch(typeMismatch(expected, actual));
+ }
+
+ /**
+ * Format "Type mismatch" string.
+ */
+ String typeMismatch(TypeCode expected, TypeCode actual)
+ {
+ return typeNamer.nameIt(expected) + " expected " +
+ typeNamer.nameIt(actual);
+ }
+
+ /**
+ * Format "size mismatch" string.
+ */
+ String sizeMismatch(int here, int other)
+ {
+ return "Size mismatch, " + other + " (expected " + here + ")";
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/abstractRecord.java b/gnu/CORBA/DynAn/abstractRecord.java
new file mode 100644
index 000000000..8d8b7a559
--- /dev/null
+++ b/gnu/CORBA/DynAn/abstractRecord.java
@@ -0,0 +1,405 @@
+/* abstractRecord.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynValueCommonOperations;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Field;
+
+/**
+ * A shared base for both dynamic structure an dynamic value final_type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class abstractRecord
+ extends anyDivideable
+ implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+ String[] fNames;
+
+ /**
+ * Creates the structure with the given typecode.
+ *
+ * @param fields The DynAny's, representing the fields of the structure.
+ */
+ public abstractRecord(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /** @inheritDoc */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length == 0)
+ throw new TypeMismatch(EMPTY);
+ try
+ {
+ return final_type.member_type(pos).kind();
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ catch (Bounds e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length == 0)
+ throw new TypeMismatch(EMPTY);
+ try
+ {
+ return final_type.member_name(pos);
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ catch (Bounds e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Get content of the structure. This method must be defined on a different
+ * name because get_members_as_dyn_any() throws exception only in some of the
+ * supported interfaces.
+ */
+ public NameDynAnyPair[] gnu_get_members_as_dyn_any()
+ {
+ NameDynAnyPair[] r = new NameDynAnyPair[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ {
+ try
+ {
+ r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Get content of the structure. This method must be defined on a different
+ * name because get_members_as_dyn_any() throws exception only in some of the
+ * supported interfaces.
+ */
+ public NameValuePair[] gnu_get_members()
+ {
+ NameValuePair[] r = new NameValuePair[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ {
+ try
+ {
+ r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any());
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Set members from the provided array.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ DynAny dynAny = value [ i ].value;
+ checkType(dynAny.type(), i);
+ checkName(value [ i ].id, i);
+
+ array [ i ] = dynAny;
+ }
+ pos = 0;
+ }
+
+ /**
+ * Check the name at the given position ("" matches everything).
+ */
+ private void checkName(String xName, int i)
+ throws TypeMismatch
+ {
+ if (xName.length() > 0 && fNames [ i ].length() > 0)
+ if (!xName.equals(fNames [ i ]))
+ throw new TypeMismatch("Field name mismatch " + xName + " expected " +
+ fNames [ i ]
+ );
+ }
+
+ /**
+ * Check the type at the given position.
+ */
+ private void checkType(TypeCode t, int i)
+ throws TypeMismatch
+ {
+ if (!array [ i ].type().equal(t))
+ throw new TypeMismatch(typeMismatch(array [ i ].type(), t) + " field " +
+ i
+ );
+ }
+
+ /**
+ * Set members from the provided array.
+ */
+ public void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ Any any = value [ i ].value;
+ checkType(any.type(), i);
+ checkName(value [ i ].id, i);
+
+ array [ i ].from_any(any);
+ }
+ pos = 0;
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynStruct)
+ {
+ try
+ {
+ set_members_as_dyn_any(((DynStruct) from).get_members_as_dyn_any());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ }
+ else
+ throw new TypeMismatch("Not a DynStruct");
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ abstractRecord d = newInstance(official_type, final_type, factory, orb);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Create a new instance when copying.
+ */
+ protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory,
+ ORB anOrb
+ );
+
+ /**
+ * Done via reflection.
+ */
+ public Any to_any()
+ {
+ try
+ {
+ Streamable sHolder = holderFactory.createHolder(official_type);
+
+ Class sHolderClass = sHolder.getClass();
+ Field sHolderValue = sHolderClass.getField("value");
+ Class sClass = sHolderValue.getType();
+
+ Object structure = sClass.newInstance();
+ Object member;
+ Any am;
+ Field vread;
+ Field vwrite;
+ Streamable memberHolder;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ am = array [ i ].to_any();
+ memberHolder = am.extract_Streamable();
+ vwrite = structure.getClass().getField(final_type.member_name(i));
+ vread = memberHolder.getClass().getField("value");
+ member = vread.get(memberHolder);
+ vwrite.set(structure, member);
+ }
+
+ Any g = createAny();
+ sHolderValue.set(sHolder, structure);
+ g.insert_Streamable(sHolder);
+ g.type(official_type);
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ Streamable s = an_any.extract_Streamable();
+ if (s == null)
+ {
+ if (this instanceof DynValueCommonOperations)
+ {
+ ((DynValueCommonOperations) this).set_to_null();
+ return;
+ }
+ else
+ throw new InvalidValue(ISNULL);
+ }
+
+ Object structure = s.getClass().getField("value").get(s);
+ if (structure == null && (this instanceof DynValueCommonOperations))
+ {
+ ((DynValueCommonOperations) this).set_to_null();
+ return;
+ }
+
+ Any member;
+ Streamable holder;
+ Object field;
+ TypeCode fType;
+ Field fField;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ fField = structure.getClass().getField(fNames [ i ]);
+ field = fField.get(structure);
+ fType = array [ i ].type();
+ holder = holderFactory.createHolder(fType);
+
+ member = createAny();
+ holder.getClass().getField("value").set(holder, field);
+ member.insert_Streamable(holder);
+ member.type(fType);
+
+ array [ i ].from_any(member);
+ }
+
+ if (this instanceof DynValueCommonOperations)
+ ((DynValueCommonOperations) this).set_to_value();
+ }
+ catch (InvalidValue v)
+ {
+ throw v;
+ }
+ catch (NoSuchFieldException ex)
+ {
+ TypeMismatch v =
+ new TypeMismatch("holder value does not match typecode");
+ v.initCause(ex);
+ throw v;
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/anyDivideable.java b/gnu/CORBA/DynAn/anyDivideable.java
new file mode 100644
index 000000000..5f52c8078
--- /dev/null
+++ b/gnu/CORBA/DynAn/anyDivideable.java
@@ -0,0 +1,514 @@
+/* anyDivideable.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.CORBA.DynAn;
+
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynValueCommon;
+
+import java.io.Serializable;
+
+/**
+ * Provides a base for DynAnys, having multiple components.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class anyDivideable
+ extends abstractDynAny
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The array of the components that in general case may have different
+ * final_type.
+ */
+ protected DynAny[] array;
+
+ /**
+ * The internal pointer.
+ */
+ protected int pos = 0;
+
+ public anyDivideable(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /**
+ * Advance forward.
+ */
+ public boolean next()
+ {
+ pos++;
+ return array.length > pos;
+ }
+
+ /**
+ * Set zero position.
+ */
+ public void rewind()
+ {
+ pos = 0;
+ }
+
+ /**
+ * Set a position.
+ */
+ public boolean seek(int p)
+ {
+ pos = p;
+ return pos >= 0 && array.length > pos;
+ }
+
+ /**
+ * Get the insertion point as DynAny. This method may throw exceptions if the
+ * current insertion point does not support reading or insertion of the
+ * primitive types.
+ *
+ * @return the focused component, from where the primitve value can be read or
+ * where it can be inserted.
+ * @throws InvalidValue if the primitive value cannot be inserted at the given
+ * point.
+ */
+ protected DynAny focused()
+ throws InvalidValue, TypeMismatch
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ].component_count() == 0)
+ return array [ pos ];
+ else
+ throw new TypeMismatch("Multiple coponents at " + pos);
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ }
+
+ /** {@inheritDoc} */
+ public int component_count()
+ {
+ return array.length;
+ }
+
+ /**
+ * Return the second (enclosed any) that is stored in the wrapped Any.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_any();
+ }
+
+ /** {@inheritDoc} */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_boolean();
+ }
+
+ /** {@inheritDoc} */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_char();
+ }
+
+ /** {@inheritDoc} */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_double();
+ }
+
+ /** {@inheritDoc} */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_float();
+ }
+
+ /** {@inheritDoc} */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_long();
+ }
+
+ /** {@inheritDoc} */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_longlong();
+ }
+
+ /** {@inheritDoc} */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_octet();
+ }
+
+ /** {@inheritDoc} */
+ public Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_reference();
+ }
+
+ /** {@inheritDoc} */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_short();
+ }
+
+ /** {@inheritDoc} */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_string();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_typecode();
+ }
+
+ /** {@inheritDoc} */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ulong();
+ }
+
+ /** {@inheritDoc} */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ulonglong();
+ }
+
+ /** {@inheritDoc} */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ushort();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ] instanceof DynValueCommon)
+ return array [ pos ].get_val();
+ else
+ throw new TypeMismatch();
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ }
+
+ /** {@inheritDoc} */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_wchar();
+ }
+
+ /** {@inheritDoc} */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_wstring();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_any(Any a_x)
+ throws TypeMismatch, InvalidValue
+ {
+ focused().insert_any(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_boolean(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_char(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_double(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_float(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_long(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_longlong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_octet(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_reference(Object a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_reference(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_short(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_string(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_typecode(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ulong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ulonglong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ushort(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ] instanceof DynValueCommon)
+ array [ pos ].insert_val(a_x);
+ else
+ throw new TypeMismatch();
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_wchar(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_wstring(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_dyn_any();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_dyn_any(DynAny insert_it)
+ throws TypeMismatch, InvalidValue
+ {
+ focused().insert_dyn_any(insert_it);
+ }
+
+ /**
+ * Get current component.
+ *
+ * @return current component or <code>null</code> if the pointer is out of
+ * bounds.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ if (array.length == 0)
+ throw new TypeMismatch("empty");
+ return (pos >= 0 && pos < array.length) ? array [ pos ] : null;
+ }
+
+ /**
+ * No action, cleanup is done by garbage collector in java.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Involved in equal(DynAny).
+ */
+ public abstract Any to_any()
+ throws TypeMismatch;
+
+ /**
+ * Compares with other DynAny for equality. The final_type, array size and
+ * array members must match.
+ */
+ public boolean equal(DynAny other)
+ {
+ try
+ {
+ if (!official_type.equal(other.type()))
+ return false;
+ else if (other instanceof anyDivideable)
+ {
+ anyDivideable x = (anyDivideable) other;
+ if (x.array.length != array.length)
+ return false;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ if (!array [ i ].equal(x.array [ i ]))
+ return false;
+ }
+ return true;
+ }
+ else if (other == null || other instanceof abstractDynAny)
+ return false;
+ else
+ return other.to_any().equal(to_any());
+ }
+ catch (TypeMismatch e)
+ {
+ UNKNOWN u = new UNKNOWN(MINOR, CompletionStatus.COMPLETED_NO);
+ u.initCause(e);
+ throw u;
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/anyUndivideable.java b/gnu/CORBA/DynAn/anyUndivideable.java
new file mode 100644
index 000000000..b31a6b357
--- /dev/null
+++ b/gnu/CORBA/DynAn/anyUndivideable.java
@@ -0,0 +1,493 @@
+/* Undivideable.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.CORBA.DynAn;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Represent DynAny that has no internal components (DynEnum and so on). The
+ * methods, related to internal components, throw exceptions or return agreed
+ * values like null.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class anyUndivideable
+ extends abstractDynAny
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create a new instance with the given typecode.
+ */
+ public anyUndivideable(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /**
+ * There are no components.
+ *
+ * @return 0, always.
+ */
+ public int component_count()
+ {
+ return 0;
+ }
+
+ /**
+ * There is no current component.
+ *
+ * @throws TypeMismatch, always.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ throw new TypeMismatch("Not applicable");
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Not in use.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_dyn_any(DynAny insert_it)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_reference(Object a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean next()
+ {
+ return false;
+ }
+
+ /**
+ * Not in use.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean seek(int p)
+ {
+ return false;
+ }
+
+ /**
+ * Get the typecode of this enumeration.
+ */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Compares with other DynAny for equality.
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ if (other instanceof DynAny)
+ return equal((DynAny) other);
+ else
+ return false;
+ }
+
+ /**
+ * This depends on an object.
+ */
+ public abstract boolean equal(DynAny other);
+
+}
diff --git a/gnu/CORBA/DynAn/gnuDynAny.java b/gnu/CORBA/DynAn/gnuDynAny.java
new file mode 100644
index 000000000..a12706176
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynAny.java
@@ -0,0 +1,985 @@
+/* primitiveDynAny.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.CORBA.DynAn;
+
+import gnu.CORBA.*;
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.OctetHolder;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.WCharHolder;
+import gnu.CORBA.WStringHolder;
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.AnyHolder;
+import org.omg.CORBA.BooleanHolder;
+import org.omg.CORBA.CharHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.FloatHolder;
+import org.omg.CORBA.IntHolder;
+import org.omg.CORBA.LongHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ObjectHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodeHolder;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.*;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import java.util.Arrays;
+
+/**
+ * The primitive dynamic Any holds the value basic final_type that cannot be
+ * traversed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynAny
+ extends abstractDynAny
+ implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The enclosed Streamable, holding the actual value.
+ */
+ protected Streamable holder;
+
+ /**
+ * Create DynAny providing the holder.
+ *
+ * @param a_holder
+ */
+ public gnuDynAny(Streamable aHolder, TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ holder = aHolder;
+ }
+
+ /**
+ * Assign the contents of the given {@link DynAny} to this DynAny.
+ *
+ * @param from the source to assign from.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof gnuDynAny)
+ holder = ((gnuDynAny) from).holder;
+ else
+ holder = from.to_any().extract_Streamable();
+ valueChanged();
+ }
+
+ /**
+ * Create a copy of this {@link DynAny} via buffer read/write.
+ */
+ public DynAny copy()
+ {
+ if (holder != null)
+ {
+ cdrBufOutput buffer = new cdrBufOutput();
+ holder._write(buffer);
+
+ gnuDynAny other;
+ try
+ {
+ other =
+ new gnuDynAny((Streamable) (holder.getClass().newInstance()),
+ official_type, final_type, factory, orb
+ );
+ }
+ catch (Exception e)
+ {
+ // Holder must have parameterless constructor.
+ throw new Unexpected(e);
+ }
+ other.holder._read(buffer.create_input_stream());
+ return other;
+ }
+ else
+ {
+ return new gnuDynAny(null, official_type, final_type, factory, orb);
+ }
+ }
+
+ /**
+ * Always returns <code>null</code>.
+ *
+ * @return <code>null</code>, always.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ throw new TypeMismatch("Not applicable for " +
+ typeNamer.nameIt(final_type)
+ );
+ }
+
+ /**
+ * Returns without action, leaving all work to the garbage collector.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Takes the passed parameter as the enclosed {@link Any} reference.
+ *
+ * @param an_any the {@link Any} that will be used as an enclosed reference.
+ *
+ * @throws TypeMismatch if the final_type of the passed Any is not the same as
+ * the final_type, currently stored in this Any.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+
+ Streamable a_holder = an_any.extract_Streamable();
+ if (a_holder == null)
+ {
+ throw new InvalidValue(ISNULL);
+ }
+ else if (a_holder instanceof universalHolder)
+ {
+ holder = holderFactory.createHolder(official_type);
+ if (holder == null)
+ holder = holderFactory.createHolder(final_type);
+
+ if (holder == null)
+ holder = ((universalHolder) a_holder).Clone();
+ else
+ {
+ InputStream in = an_any.create_input_stream();
+ holder._read(in);
+ try
+ {
+ in.close();
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ InputStream in = an_any.create_input_stream();
+ holder = (Streamable) a_holder.getClass().newInstance();
+ holder._read(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ }
+ valueChanged();
+ }
+
+ /**
+ * Return the second (enclosed any) that is stored in the wrapped Any.
+ */
+ public Any get_any()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((AnyHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean get_boolean()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((BooleanHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public char get_char()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((CharHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public double get_double()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((DoubleHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public float get_float()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((FloatHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int get_long()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((IntHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public long get_longlong()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((LongHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public byte get_octet()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((OctetHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Object get_reference()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((ObjectHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public short get_short()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((ShortHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String get_string()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((StringHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode get_typecode()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((TypeCodeHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int get_ulong()
+ throws TypeMismatch
+ {
+ check(TCKind.tk_ulong);
+ return get_long();
+ }
+
+ /** {@inheritDoc} */
+ public long get_ulonglong()
+ throws TypeMismatch
+ {
+ check(TCKind.tk_ulonglong);
+ return get_longlong();
+ }
+
+ /** {@inheritDoc} */
+ public short get_ushort()
+ throws TypeMismatch
+ {
+ check(TCKind.tk_ushort);
+ return get_short();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((ValueBaseHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public char get_wchar()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((WCharHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String get_wstring()
+ throws TypeMismatch
+ {
+ try
+ {
+ return ((WStringHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_any(Any a_x)
+ throws TypeMismatch, InvalidValue
+ {
+ try
+ {
+ if (a_x.type().kind().value() == TCKind._tk_null)
+ ((AnyHolder) holder).value = a_x;
+ else
+ {
+ OutputStream buf = a_x.create_output_stream();
+ buf.write_any(a_x);
+ holder._read(buf.create_input_stream());
+ buf.close();
+ }
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (MARSHAL m)
+ {
+ InvalidValue v = new InvalidValue();
+ v.initCause(m);
+ throw v;
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((BooleanHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((CharHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((DoubleHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((FloatHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((IntHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((LongHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((OctetHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_reference(Object a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ObjectHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ShortHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ if (a_x != null && final_type.length() > 0 &&
+ a_x.length() > final_type.length()
+ )
+ throw new InvalidValue(a_x.length() + " exceeds bound, " +
+ final_type.length()
+ );
+ ((StringHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((TypeCodeHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((IntHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((LongHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ShortHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ValueBaseHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((WCharHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ if (a_x != null && final_type.length() > 0 &&
+ a_x.length() > type().length()
+ )
+ throw new InvalidValue(a_x.length() + " exceeds bound, " +
+ final_type.length()
+ );
+ ((WStringHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * The objects, enclosed inside this class, have only one component (self).
+ *
+ * @return false, always (no other action).
+ */
+ public boolean next()
+ {
+ return false;
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * This objects, stored in this wrapper, never have multiple internal
+ * components to seek.
+ *
+ * @return false, always (no other action).
+ */
+ public boolean seek(int p)
+ {
+ return false;
+ }
+
+ /**
+ * Returns the enclosed {@link Any}.
+ *
+ * @return the enclosed {@link Any}.
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ a.insert_Streamable(holder);
+ a.type(official_type);
+ return a;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Compute hashcode in a trivial way.
+ */
+ protected int getHashCodeSimple(int maximum)
+ {
+ int h = super.hashCode() / 2;
+ if (h < 0)
+ h = -h;
+ return h % maximum;
+ }
+
+ /**
+ * Inserts Any, contained in the parameter, into Any, contained in this
+ * DynAny.
+ */
+ public void insert_dyn_any(DynAny d)
+ throws TypeMismatch, InvalidValue
+ {
+ check(d.type().kind());
+
+ Any a = d.to_any();
+ holder = a.extract_Streamable();
+ valueChanged();
+ }
+
+ /**
+ * Checks for equality. The DynAnys are equal if the stored Anys are equal.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof abstractDynAny)
+ {
+ if (other instanceof gnuDynAny)
+ {
+ gnuDynAny x = (gnuDynAny) other;
+
+ if (!x.holder.getClass().equals(holder.getClass()))
+ return false;
+
+ cdrBufOutput b1 = new cdrBufOutput();
+ x.holder._write(b1);
+
+ cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10);
+ holder._write(b2);
+
+ return Arrays.equals(b1.buffer.toByteArray(),
+ b2.buffer.toByteArray()
+ );
+ }
+ else
+ return false;
+ }
+ if (other == null)
+ return false;
+ else if (other.component_count() != component_count() ||
+ !official_type.equal(other.type())
+ )
+ return false;
+ else
+ return other.to_any().equal(to_any());
+ }
+
+ /**
+ * This final_type has no components.
+ *
+ * @return 0, always.
+ */
+ public int component_count()
+ {
+ return 0;
+ }
+
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ return new gnuDynAny(holder, official_type, final_type, factory, orb);
+ }
+
+ private void check(TCKind t)
+ throws TypeMismatch
+ {
+ if (t.value() != final_type.kind().value())
+ throw new TypeMismatch(t.value() + "!=" + final_type.kind().value());
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynAnyFactory.java b/gnu/CORBA/DynAn/gnuDynAnyFactory.java
new file mode 100644
index 000000000..dd1762890
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynAnyFactory.java
@@ -0,0 +1,356 @@
+/* gnuDynAnyFactory.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.CORBA.DynAn;
+
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactory;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynArray;
+import org.omg.DynamicAny.DynEnum;
+import org.omg.DynamicAny.DynFixed;
+import org.omg.DynamicAny.DynSequence;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynUnion;
+import org.omg.DynamicAny.DynValue;
+import org.omg.DynamicAny.DynValueBox;
+
+/**
+ * This class is returned by ORB when resolving
+ * initial reference "DynAnyFactory".
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynAnyFactory
+ extends LocalObject
+ implements DynAnyFactory
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The ORB, to that the factory belongs.
+ */
+ final ORB_1_4 orb;
+
+ /**
+ * Create a new factory, specifying the ORB to that the factory belongs.
+ *
+ * @param anOrb
+ */
+ public gnuDynAnyFactory(ORB_1_4 anOrb)
+ {
+ orb = anOrb;
+ }
+
+ /**
+ * Get the orb.
+ */
+ public ORB_1_4 getOrb()
+ {
+ return orb;
+ }
+
+ /**
+ * Create an initialised array.
+ */
+ public DynArray create_array(TypeCode official, TypeCode type)
+ {
+ return new gnuDynArray(official, type, this, orb, true);
+ }
+
+ /**
+ * Create an empty sequence.
+ */
+ public DynSequence create_sequence(TypeCode official, TypeCode type)
+ {
+ return new gnuDynSequence(official, type, this, orb);
+ }
+
+ /**
+ * Create structure.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynStruct create_structure(TypeCode official, TypeCode type)
+ {
+ return new gnuDynStruct(official, type, this, orb);
+ }
+
+ /**
+ * Create union.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynUnion create_union(TypeCode official, TypeCode type)
+ {
+ try
+ {
+ return new gnuDynUnion(official, type, this, orb);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Create value.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynValue create_value(TypeCode official, TypeCode type)
+ {
+ return new gnuDynValue(official, type, this, orb);
+ }
+
+ /**
+ * Create value box.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynValueBox create_value_box(TypeCode official, TypeCode type)
+ {
+ return new gnuDynValueBox(official, type, this, orb);
+ }
+
+ /**
+ * Create enumeration.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynEnum create_enumeration(TypeCode official, TypeCode type)
+ {
+ return new gnuDynEnum(official, type, this, orb);
+ }
+
+ /**
+ * Create fixed.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynFixed create_fixed(TypeCode official, TypeCode type)
+ {
+ return new gnuDynFixed(official, type, this, orb);
+ }
+
+ /**
+ * Create alias.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynAny create_alias(TypeCode official, TypeCode type)
+ throws InconsistentTypeCode
+ {
+ try
+ {
+ return create_dyn_any_from_type_code(official, type.content_type());
+ }
+ catch (BadKind e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Create the undivideable DynAny.
+ */
+ public DynAny create_simple(TypeCode official, TypeCode type)
+ {
+ Streamable holder = holderFactory.createHolder(type);
+ return new gnuDynAny(holder, official, type, this, orb);
+ }
+
+ /**
+ * Create the DynAny from typecode.
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode type)
+ throws InconsistentTypeCode
+ {
+ return create_dyn_any_from_type_code(type, type);
+ }
+
+ /**
+ * Create the DynAny from typecode.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode official, TypeCode type)
+ throws InconsistentTypeCode
+ {
+ DynAny d;
+ try
+ {
+ switch (type.kind().value())
+ {
+ case TCKind._tk_array :
+ return create_array(official, type);
+
+ case TCKind._tk_sequence :
+ return create_sequence(official, type);
+
+ case TCKind._tk_struct :
+ case TCKind._tk_except :
+ return create_structure(official, type);
+
+ case TCKind._tk_union :
+ return create_union(official, type);
+
+ case TCKind._tk_value :
+ return create_value(official, type);
+
+ case TCKind._tk_value_box :
+ return create_value_box(official, type);
+
+ case TCKind._tk_enum :
+ return create_enumeration(official, type);
+
+ case TCKind._tk_fixed :
+ return create_fixed(official, type);
+
+ case TCKind._tk_alias :
+ return create_alias(official, type);
+
+ case TCKind._tk_null :
+ return new gnuDynAny(null, official, type, this, orb);
+
+ case TCKind._tk_TypeCode :
+ d = create_simple(official, type);
+ d.insert_typecode(orb.get_primitive_tc(TCKind.tk_null));
+ return d;
+
+ case TCKind._tk_any :
+ d = create_simple(official, type);
+
+ Any empty_any = orb.create_any();
+ empty_any.type(orb.get_primitive_tc(TCKind.tk_null));
+ d.insert_any(empty_any);
+ return d;
+
+ case TCKind._tk_wstring :
+ d = create_simple(official, type);
+ d.insert_wstring("");
+ return d;
+
+ case TCKind._tk_string :
+ d = create_simple(official, type);
+ d.insert_string("");
+ return d;
+
+ case TCKind._tk_native :
+ case TCKind._tk_Principal :
+ case TCKind._tk_abstract_interface :
+ throw new InconsistentTypeCode("Following API, the " +
+ typeNamer.nameIt(type) +
+ " must not be supported."
+ );
+
+ default :
+ return create_simple(official, type);
+ }
+ }
+ catch (UserException uex)
+ {
+ InconsistentTypeCode it = new InconsistentTypeCode();
+ it.initCause(uex);
+ throw it;
+ }
+ }
+
+ /**
+ * Create the DynAny using the passed value as template and assign this value.
+ */
+ public DynAny create_dyn_any(Any value)
+ throws InconsistentTypeCode
+ {
+ DynAny created = create_dyn_any_from_type_code(value.type());
+ try
+ {
+ created.from_any(value);
+ }
+ catch (UserException uex)
+ {
+ InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
+ t.initCause(uex);
+ throw t;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ return created;
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynArray.java b/gnu/CORBA/DynAn/gnuDynArray.java
new file mode 100644
index 000000000..1c08496d4
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynArray.java
@@ -0,0 +1,338 @@
+/* gnuDynArray.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynArray;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+
+/**
+ * Provides support for dynamic array or sequence, where all members have the
+ * same final_type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynArray
+ extends anyDivideable
+ implements DynArray, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The component "official" type (may be alias).
+ */
+ final TypeCode official_components;
+
+ /**
+ * The component "final" type, after resolving any aliases.
+ */
+ final TypeCode final_components;
+
+ /**
+ * Creates new array.
+ *
+ * @param aType the final_type of array.
+ * @param aFactory the factory, used to initialise default values.
+ * @param orb the ORB to that this DynAny belongs.
+ * @param initialise_array if false, the array is not initialised in
+ * constructor.
+ *
+ *
+ * @throws BAD_PARAM if the passed typecode does not provide the length().
+ */
+ public gnuDynArray(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb, boolean initialise_array
+ )
+ throws BAD_PARAM
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ try
+ {
+ official_components = final_type.content_type();
+
+ TypeCode component = official_components;
+ while (component.kind().value() == TCKind._tk_alias)
+ component = component.content_type();
+ final_components = component;
+
+ if (initialise_array)
+ {
+ array = new DynAny[ aType.length() ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(official_components);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Unable to initialise array");
+ bad.initCause(e);
+ throw bad;
+ }
+ }
+
+ /**
+ * Copy one DynAny into another.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynArray && from.component_count() == array.length)
+ {
+ DynArray dyn = (DynArray) from;
+ array = dyn.get_elements_as_dyn_any();
+ }
+ else
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ gnuDynArray d =
+ new gnuDynArray(official_type, final_type, factory, orb, false);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Get elements as array of anys.
+ */
+ public Any[] get_elements()
+ {
+ Any[] r = new Any[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ r [ i ] = array [ i ].to_any();
+ return r;
+ }
+
+ /** {@inheritDoc} */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ DynAny[] a = new DynAny[ array.length ];
+ for (int i = 0; i < a.length; i++)
+ {
+ a [ i ] = array [ i ].copy();
+ }
+ return a;
+ }
+
+ /**
+ * Set elements when array of dyn anys is provided. This method can set nested
+ * data structures as an array components.
+ */
+ public void set_elements_as_dyn_any(DynAny[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ array [ i ].assign(value [ i ]);
+ }
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Set elements when array of ordinary anys is provided.
+ */
+ public void set_elements(Any[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ try
+ {
+ array [ i ] = factory.create_dyn_any(value [ i ]);
+ }
+ catch (InconsistentTypeCode e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public Any to_any()
+ {
+ try
+ {
+ Streamable memberHolder =
+ holderFactory.createHolder(official_components);
+
+ if (memberHolder == null)
+ memberHolder = holderFactory.createHolder(final_components);
+
+ Class memberHolderClass = memberHolder.getClass();
+ Class memberClass = memberHolderClass.getField("value").getType();
+
+ Object members = Array.newInstance(memberClass, array.length);
+ Object member;
+ Any am;
+ Field value = memberHolder.getClass().getField("value");
+
+ for (int i = 0; i < array.length; i++)
+ {
+ // Recursive call should support multidimensional arrays.
+ am = array [ i ].to_any();
+ memberHolder = am.extract_Streamable();
+ member = value.get(memberHolder);
+ Array.set(members, i, member);
+ }
+
+ Streamable arrayHolder = holderFactory.createHolder(official_type);
+ arrayHolder.getClass().getField("value").set(arrayHolder, members);
+
+ Any g = createAny();
+ g.insert_Streamable(arrayHolder);
+ g.type(official_type);
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ Streamable s = an_any.extract_Streamable();
+ Object members = s.getClass().getField("value").get(s);
+
+ checkArrayValid(members);
+
+ Any member;
+ Streamable holder;
+ Class holderClass = null;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ if (holderClass == null)
+ {
+ holder = holderFactory.createHolder(official_components);
+ if (holder == null)
+ holder = holderFactory.createHolder(final_components);
+ holderClass = holder.getClass();
+ }
+ else
+ holder = (Streamable) holderClass.newInstance();
+
+ member = createAny();
+ holder.getClass().getField("value").set(holder,
+ Array.get(members, i)
+ );
+ member.insert_Streamable(holder);
+ member.type(official_components);
+
+ // This may lead to recursion, supporting multidimensional
+ // arrays.
+ array [ i ].from_any(member);
+ }
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /**
+ * Check if array size is valid and (for sequences) resized
+ * if required. Called from from_any.
+ */
+ protected void checkArrayValid(Object members)
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length != Array.getLength(members))
+ throw new InvalidValue(sizeMismatch(array.length, Array.getLength(members)));
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynEnum.java b/gnu/CORBA/DynAn/gnuDynEnum.java
new file mode 100644
index 000000000..148d99375
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynEnum.java
@@ -0,0 +1,250 @@
+/* gnuDynEnum.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynEnum;
+
+import java.io.*;
+
+import java.util.Arrays;
+
+/**
+ * Our implementation of dynamic enumeration.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynEnum
+ extends anyUndivideable
+ implements DynEnum
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The valid string values of the enumeration. Most of enumerations are short,
+ * counting 2-5 memebers. With so small number of memebers, it seems not
+ * reasonable to use hashtables.
+ */
+ final String[] values;
+
+ /**
+ * The current value of enum.
+ */
+ int current;
+
+ /**
+ * Create a new dyn enum from the given typecode.
+ */
+ public gnuDynEnum(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ values = new String[ final_type.member_count() ];
+
+ for (int i = 0; i < values.length; i++)
+ {
+ values [ i ] = final_type.member_name(i);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new BAD_PARAM("Not enum");
+ }
+ }
+
+ /**
+ * Create a clone of the given enum, sharing values and final_type.
+ */
+ public gnuDynEnum(gnuDynEnum from)
+ {
+ super(from.official_type, from.final_type, from.factory, from.orb);
+ values = from.values;
+ }
+
+ /**
+ * Assign the Enum from the passed value. The passed DynAny must hold the
+ * enumeration of exactly the same final_type.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (!(from instanceof DynEnum))
+ throw new TypeMismatch("Not a DynEnum");
+ try
+ {
+ set_as_ulong(((DynEnum) from).get_as_ulong());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Copy this DynEnum.
+ */
+ public DynAny copy()
+ {
+ gnuDynEnum other = new gnuDynEnum(this);
+ other.current = current;
+ return other;
+ }
+
+ /**
+ * Compares for equality.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof gnuDynEnum)
+ {
+ gnuDynEnum oe = (gnuDynEnum) other;
+ return current == oe.current &&
+ (oe.values == values || Arrays.equals(values, oe.values));
+ }
+ else if (other instanceof DynEnum)
+ {
+ DynEnum oe = (DynEnum) other;
+ return current == oe.get_as_ulong() && official_type.equal(oe.type());
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Set value from any that must contain enumeration.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ InputStream in = an_any.create_input_stream();
+ set_as_ulong(in.read_long());
+ in.close();
+ }
+ catch (MARSHAL eof)
+ {
+ throw new InvalidValue();
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Get the value of this enumeration as string.
+ */
+ public String get_as_string()
+ {
+ return values [ current ];
+ }
+
+ /**
+ * Get the value of this enumeration as int.
+ */
+ public int get_as_ulong()
+ {
+ return current;
+ }
+
+ /**
+ * Set the value of this enumeration as string.
+ */
+ public void set_as_string(String value)
+ throws InvalidValue
+ {
+ for (int i = 0; i < values.length; i++)
+ {
+ if (values [ i ].equals(value))
+ {
+ current = i;
+ valueChanged();
+ return;
+ }
+ }
+ throw new InvalidValue(value);
+ }
+
+ /**
+ * Set the value of this enumeration as int.
+ */
+ public void set_as_ulong(int value)
+ throws InvalidValue
+ {
+ if (value < 0 || value >= values.length)
+ throw new InvalidValue(value + " not in [0.." + values.length);
+ else
+ {
+ current = value;
+ valueChanged();
+ }
+ }
+
+ /**
+ * Wrap the enumeration value into any.
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ a.insert_long(current);
+ a.type(official_type);
+ return a;
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynFixed.java b/gnu/CORBA/DynAn/gnuDynFixed.java
new file mode 100644
index 000000000..13ec24e6c
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynFixed.java
@@ -0,0 +1,257 @@
+/* gnuDynFixed.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.CORBA.DynAn;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.*;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynFixed;
+import org.omg.DynamicAny.DynFixedOperations;
+
+import java.math.BigDecimal;
+
+/**
+ * Implements DynAny, holding CORBA <code>fixed</code>. This class is derived
+ * from gnuDynEnm to avoid repetetive inclusion of unused DynAny methods.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynFixed
+ extends anyUndivideable
+ implements DynFixed
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The default value, assigned in the new instance.
+ */
+ static final BigDecimal ZERO = new BigDecimal("0.0");
+
+ /**
+ * The content of the dyn fixed, wrapped in this DynAny.
+ */
+ BigDecimal value;
+
+ /**
+ * The number of digits after the decimal point.
+ */
+ final int scale;
+
+ /**
+ * The number of digits.
+ */
+ final int digits;
+
+ /**
+ * Create a new instance of the dyn fixed.
+ */
+ public gnuDynFixed(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ digits = final_type.fixed_digits();
+ scale = final_type.fixed_scale();
+ }
+ catch (Exception e)
+ {
+ throw new BAD_PARAM("Not a fixed");
+ }
+ value = ZERO;
+ }
+
+ /**
+ * Clone the current instance.
+ */
+ public gnuDynFixed(gnuDynFixed from)
+ {
+ super(from.official_type, from.final_type, from.factory, from.orb);
+ digits = from.digits;
+ scale = from.scale;
+ value = from.value;
+ }
+
+ /**
+ * Get the value of the wrapped dyn fixed, as string.
+ */
+ public String get_value()
+ {
+ return value.toString();
+ }
+
+ /**
+ * Set the value.
+ */
+ public boolean set_value(String fixed_value)
+ throws TypeMismatch, InvalidValue
+ {
+ // Count the digits till decimal point.
+ int digs = 0;
+ char c;
+ boolean leading0 = true;
+ Digs:
+ for (int i = 0; i < fixed_value.length(); i++)
+ {
+ c = fixed_value.charAt(i);
+ if (Character.isDigit(c))
+ {
+ if (!(c == '0' && leading0))
+ digs++;
+ if (c != '0')
+ leading0 = false;
+ }
+ else if (c == '.')
+ break Digs;
+ }
+ if (digs > (digits - scale))
+ throw new InvalidValue("Too many digits: " + digs + " for " + digits +
+ "." + scale
+ );
+
+ try
+ {
+ value = new BigDecimal(fixed_value);
+ }
+ catch (NumberFormatException ex)
+ {
+ if (fixed_value.trim().length() == 0)
+ throw new InvalidValue("Empty string passed");
+
+ TypeMismatch inva =
+ new TypeMismatch("Not a number: '" + fixed_value + "'");
+ inva.initCause(ex);
+ throw inva;
+ }
+
+ valueChanged();
+ return value.scale() <= scale;
+ }
+
+ /**
+ * Assign the value from another BigDecimal.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof gnuDynFixed)
+ {
+ gnuDynFixed other = (gnuDynFixed) from;
+ value = other.value;
+ }
+ else if (from instanceof DynFixedOperations)
+ {
+ value = new BigDecimal(((DynFixedOperations) from).get_value());
+ }
+ else
+ throw new TypeMismatch("Not a DynFixed");
+ valueChanged();
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ return new gnuDynFixed(this);
+ }
+
+ /**
+ * Compare for equality.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof gnuDynFixed)
+ {
+ // Normally, this code would be executed.
+ return value.equals(((gnuDynFixed) other).value);
+ }
+ if (other instanceof DynFixedOperations)
+ {
+ // This may be involved when mixing implementations.
+ return ((DynFixedOperations) other).get_value().equals(get_value());
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Set the value from Any (must hold <code>fixed</code> with the matching
+ * typecode.).
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ try
+ {
+ checkType(official_type, an_any.type());
+
+ value = an_any.extract_fixed();
+ valueChanged();
+ }
+ catch (BAD_OPERATION e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Create and return Any, holding this DynFixed value.
+ */
+ public Any to_any()
+ {
+ Any g = createAny();
+ g.insert_fixed(value, official_type);
+ return g;
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynSequence.java b/gnu/CORBA/DynAn/gnuDynSequence.java
new file mode 100644
index 000000000..cfa122f07
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynSequence.java
@@ -0,0 +1,254 @@
+/* gnuDynSequence.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynSequence;
+
+import java.io.Serializable;
+
+import java.lang.reflect.*;
+
+public class gnuDynSequence
+ extends gnuDynArray
+ implements DynSequence, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The bound of the sequence, as defined in typecode.
+ */
+ final int bound;
+
+ /**
+ * Create a new gnuDynSequence with the given typecode.
+ *
+ * @throws BAD_PARAM if the passed typecode is probably not a sequence
+ * typecode.
+ */
+ public gnuDynSequence(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ throws BAD_PARAM
+ {
+ super(oType, aType, aFactory, anOrb, false);
+ array = new DynAny[ 0 ];
+ try
+ {
+ bound = final_type.length();
+ }
+ catch (BadKind ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Get the length of the sequence.
+ */
+ public int get_length()
+ {
+ return array.length;
+ }
+
+ /**
+ * Resize the sequence, preserving components.
+ */
+ public void set_length(int length)
+ throws InvalidValue
+ {
+ checkBound(length);
+ if (length == array.length)
+ return; // Nothing to do.
+ else if (length < array.length)
+ {
+ // Truncate.
+ DynAny[] d = new DynAny[ length ];
+ for (int i = 0; i < d.length; i++)
+ d [ i ] = array [ i ];
+ array = d;
+ }
+ else
+ {
+ // Expand.
+ DynAny[] d = new DynAny[ length ];
+ for (int i = 0; i < array.length; i++)
+ d [ i ] = array [ i ];
+
+ for (int i = array.length; i < d.length; i++)
+ {
+ try
+ {
+ d [ i ] =
+ factory.create_dyn_any_from_type_code(official_components);
+ }
+ catch (InconsistentTypeCode e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ array = d;
+ }
+ valueChanged();
+ }
+
+ /**
+ * Copy one DynAny into another.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynSequence)
+ {
+ DynSequence dyn = (DynSequence) from;
+ array = dyn.get_elements_as_dyn_any();
+ }
+ else
+ throw new TypeMismatch();
+ }
+
+ /*
+ * Set the contenst of the sequence, resizing if required.
+ */
+ public void set_elements_as_dyn_any(DynAny[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ checkBound(value.length);
+ if (array.length != value.length)
+ set_length(value.length);
+
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ array [ i ].assign(value [ i ]);
+ }
+ valueChanged();
+ }
+
+ /**
+ * Set the elements from array of Any's.
+ */
+ public void set_elements(Any[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ checkBound(value.length);
+
+ DynAny[] prev = array;
+
+ array = new DynAny[ value.length ];
+ try
+ {
+ super.set_elements(value);
+
+ // valueChanged() is called in super.set_elements(value).
+ }
+
+ // On the problem, value does not change.
+ catch (TypeMismatch ex)
+ {
+ array = prev;
+ throw ex;
+ }
+ catch (InvalidValue ex)
+ {
+ array = prev;
+ throw ex;
+ }
+ catch (RuntimeException rex)
+ {
+ array = prev;
+ throw rex;
+ }
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ gnuDynSequence d =
+ new gnuDynSequence(official_type, final_type, factory, orb);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Check the bound.
+ *
+ * @param x the value to check.
+ */
+ void checkBound(int x)
+ throws InvalidValue
+ {
+ if (bound != 0)
+ if (x < 0 || x > bound)
+ throw new InvalidValue(x + " out of bounds, valid [0.." + bound + "]");
+ }
+
+ /**
+ * Check if array size is valid. Called from from_any.
+ */
+ protected void checkArrayValid(Object members)
+ throws TypeMismatch, InvalidValue
+ {
+ checkBound(Array.getLength(members));
+ if (get_length() != Array.getLength(members))
+ set_length(Array.getLength(members));
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynStruct.java b/gnu/CORBA/DynAn/gnuDynStruct.java
new file mode 100644
index 000000000..b086d6478
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynStruct.java
@@ -0,0 +1,109 @@
+/* gnuDynStruct.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.CORBA.DynAn;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+import gnu.CORBA.Unexpected;
+import org.omg.DynamicAny.DynAny;
+
+/**
+ * Implementation of the DynStruct.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynStruct
+ extends abstractRecord
+ implements DynStruct, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create an instance.
+ */
+ public gnuDynStruct(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ // Initialise fields.
+ try
+ {
+ array = new DynAny[ final_type.member_count() ];
+ fNames = new String[ array.length ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(final_type.member_type(i));
+ fNames [ i ] = final_type.member_name(i);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /** @inheritDoc */
+ protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ return new gnuDynStruct(oType, aType, aFactory, anOrb);
+ }
+
+ /** @inheritDoc */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ {
+ return super.gnu_get_members_as_dyn_any();
+ }
+
+ /** @inheritDoc */
+ public NameValuePair[] get_members()
+ {
+ return super.gnu_get_members();
+ }
+}
diff --git a/gnu/CORBA/DynAn/gnuDynUnion.java b/gnu/CORBA/DynAn/gnuDynUnion.java
new file mode 100644
index 000000000..ad41e24b6
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynUnion.java
@@ -0,0 +1,439 @@
+/* gnuDynUnion.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynUnion;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of DynUnion.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynUnion
+ extends anyDivideable
+ implements DynUnion, Serializable, valueChangedListener
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The discrimintor of this union.
+ */
+ DynAny discriminator;
+
+ /**
+ * The message string that occurs several times throwing exception.
+ */
+ static String NOAM = "No active member";
+
+ /**
+ * Create a new instance with the given typecode.
+ *
+ * @param aType the final_type, must be final_type of the union.
+ */
+ public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ throws InconsistentTypeCode
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ discriminator =
+ factory.create_dyn_any_from_type_code(final_type.discriminator_type());
+
+ ((abstractDynAny) discriminator).listener = this;
+
+ if (final_type.default_index() >= 0)
+ set_to_default_member();
+ else
+ set_to_no_active_member();
+ }
+ catch (Exception ex)
+ {
+ InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
+ inc.initCause(ex);
+ throw inc;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gnu.CORBA.DynAn.anyDivideable#to_any()
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ OutputStream ou = a.create_output_stream();
+ discriminator.to_any().write_value(ou);
+ if (array.length == 2)
+ array [ 1 ].to_any().write_value(ou);
+ a.read_value(ou.create_input_stream(), final_type);
+ return a;
+ }
+
+ /**
+ * Assign from another identical structure.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (!(from instanceof DynUnion))
+ throw new TypeMismatch("DynUnion required");
+ else
+ {
+ try
+ {
+ DynUnion u = (DynUnion) from;
+ discriminator.assign(u.get_discriminator());
+ if (u.has_no_active_member())
+ {
+ if (array.length != 1)
+ array = new DynAny[] { discriminator };
+ }
+ else
+ {
+ if (array.length != 2)
+ array = new DynAny[] { discriminator, u.member().copy() };
+ else
+ array [ 1 ] = u.member().copy();
+ }
+ }
+ catch (InvalidValue e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public DynAny copy()
+ {
+ try
+ {
+ gnuDynUnion other =
+ new gnuDynUnion(official_type, final_type, factory, orb);
+ other.discriminator = discriminator.copy();
+ ((abstractDynAny) other.discriminator).listener = other;
+ if (array.length == 1)
+ {
+ other.array = new DynAny[] { other.discriminator };
+ }
+ else
+ {
+ other.array =
+ new DynAny[] { other.discriminator, array [ 1 ].copy() };
+ }
+ return other;
+ }
+ catch (InconsistentTypeCode ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Done via reading from stream.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+
+ Any adis = createAny();
+ try
+ {
+ InputStream stream = an_any.create_input_stream();
+ adis.read_value(stream, final_type.discriminator_type());
+
+ DynAny nd = factory.create_dyn_any(adis);
+
+ set_discriminator(nd);
+ if (array.length == 2)
+ {
+ // Reusing the same Any <code>adis</code>.
+ adis.read_value(stream, array [ 1 ].type());
+ array [ 1 ].from_any(adis);
+ }
+ }
+ catch (InconsistentTypeCode it)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(it);
+ throw t;
+ }
+ catch (MARSHAL m)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(m);
+ throw t;
+ }
+ catch (BadKind b)
+ {
+ throw new Unexpected(b);
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public TCKind discriminator_kind()
+ {
+ return discriminator.type().kind();
+ }
+
+ /** @inheritDoc */
+ public DynAny get_discriminator()
+ {
+ return discriminator;
+ }
+
+ /** @inheritDoc */
+ public boolean has_no_active_member()
+ {
+ return array.length == 1;
+ }
+
+ /** @inheritDoc */
+ public TCKind member_kind()
+ throws InvalidValue
+ {
+ return member().type().kind();
+ }
+
+ /**
+ * Get the name of the current variant of the union.
+ */
+ public String member_name()
+ throws InvalidValue
+ {
+ if (array.length == 1)
+ throw new InvalidValue(NOAM);
+ try
+ {
+ Any da = discriminator.to_any();
+
+
+ // Get the discriminator variant.
+ Variants:
+ for (int i = 0; i < final_type.member_count(); i++)
+ {
+ if (final_type.member_label(i).equal(da))
+ return final_type.member_name(i);
+ }
+ throw new InvalidValue(NOAM);
+ }
+ catch (Exception e)
+ {
+ InvalidValue t = new InvalidValue("Err");
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public DynAny member()
+ throws InvalidValue
+ {
+ if (array.length < 2)
+ throw new InvalidValue(NOAM);
+ else
+ return array [ 1 ];
+ }
+
+ /**
+ * Set the union discriminator.
+ */
+ public void set_discriminator(DynAny aDiscriminator)
+ throws TypeMismatch
+ {
+ try
+ {
+ if (!aDiscriminator.type().equal(final_type.discriminator_type()))
+ throw new TypeMismatch("Wrong discriminator final_type for " +
+ final_type.name()
+ );
+
+ // Seting the same discriminator value again should not change
+ // the fields of the current member.
+ if (!discriminator.equal(aDiscriminator))
+ {
+ discriminator.assign(aDiscriminator);
+ updateMember();
+ }
+ else
+ {
+ pos = array.length == 2 ? 1 : 0;
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Set to default member, if one exists.
+ */
+ public void set_to_default_member()
+ throws TypeMismatch
+ {
+ try
+ {
+ int di = final_type.default_index();
+ if (di < 0)
+ throw new TypeMismatch("Union " + final_type.name() +
+ "has no default index"
+ );
+
+ Any da = final_type.member_label(di);
+ discriminator.from_any(da);
+ updateMember();
+ }
+ catch (TypeMismatch m)
+ {
+ // This one OK.
+ throw m;
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public void set_to_no_active_member()
+ throws TypeMismatch
+ {
+ try
+ {
+ if (final_type.default_index() >= 0)
+ {
+ throw new TypeMismatch("Explicit default case defined.");
+ }
+ }
+ catch (BadKind ex)
+ {
+ // The default index is not set.
+ }
+ array = new DynAny[] { discriminator };
+ valueChanged();
+ }
+
+ /**
+ * Update member, in accordance with discriminator value.
+ */
+ public void updateMember()
+ throws TypeMismatch
+ {
+ try
+ {
+ Any da = discriminator.to_any();
+
+
+ // Get the discriminator variant.
+ Variants:
+ for (int i = 0; i < final_type.member_count(); i++)
+ {
+ if (final_type.member_label(i).equal(da))
+ {
+ array =
+ new DynAny[]
+ {
+ discriminator,
+ factory.create_dyn_any_from_type_code(final_type.member_type(i))
+ };
+ pos = 1;
+ valueChanged();
+ return;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+
+ // Discrimintator does not point to valid member.
+ array = new DynAny[] { discriminator };
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Called when the discriminator is changed.
+ */
+ public void changed()
+ {
+ try
+ {
+ updateMember();
+ }
+ catch (TypeMismatch ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynValue.java b/gnu/CORBA/DynAn/gnuDynValue.java
new file mode 100644
index 000000000..db37be016
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynValue.java
@@ -0,0 +1,395 @@
+/* gnuDynValue.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.*;
+import org.omg.CORBA.VM_TRUNCATABLE;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueFactory;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynValue;
+import org.omg.DynamicAny.DynValueCommon;
+import org.omg.DynamicAny.DynValueOperations;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of DynValue.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynValue
+ extends abstractRecord
+ implements DynValue, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * If true, the value of this ValueType is set to null.
+ */
+ boolean isNull;
+
+ /**
+ * Create an instance.
+ */
+ public gnuDynValue(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ // Initialise fields. The array of fields also includes all inherited
+ // fields.
+ try
+ {
+ array = new DynAny[ final_type.member_count() ];
+ fNames = new String[ array.length ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(final_type.member_type(i));
+ fNames [ i ] = final_type.member_name(i);
+ }
+
+ // Search of inherited members.
+ if (final_type.type_modifier() == VM_TRUNCATABLE.value)
+ {
+ TypeCode parent = final_type.concrete_base_type();
+ DynAny ancestor = factory.create_dyn_any_from_type_code(parent);
+
+ if (ancestor instanceof DynValue)
+ {
+ // Add members of ancestor in front of the curren members.
+ DynValue anc = (DynValue) ancestor;
+ anc.set_to_value();
+ NameDynAnyPair[] aar = anc.get_members_as_dyn_any();
+ inheritFields(aar);
+ }
+ else if (ancestor instanceof DynStruct)
+ {
+ // Add members of ancestor in front of the curren members.
+ DynStruct anc = (DynStruct) ancestor;
+ NameDynAnyPair[] aar = anc.get_members_as_dyn_any();
+ inheritFields(aar);
+ }
+ else
+ throw new BAD_PARAM("The parent of " + final_type.id() + ", " +
+ parent.id() +
+ ", is not structure nor value."
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+
+ set_to_null();
+ }
+
+ /**
+ * Inherit the provided fields.
+ */
+ private void inheritFields(NameDynAnyPair[] aar)
+ {
+ DynAny[] nArray = new DynAny[ array.length + aar.length ];
+ String[] nNames = new String[ array.length + aar.length ];
+ int p = 0;
+ for (int i = 0; i < aar.length; i++)
+ {
+ nArray [ p ] = aar [ i ].value;
+ nNames [ p ] = aar [ i ].id;
+ p++;
+ }
+
+ for (int i = 0; i < array.length; i++)
+ {
+ nArray [ p ] = array [ i ];
+ nNames [ p ] = fNames [ i ];
+ p++;
+ }
+
+ array = nArray;
+ fNames = nNames;
+ }
+
+ /** @inheritDoc */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.current_member_kind();
+ }
+ ;
+
+ /** @inheritDoc */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.current_member_name();
+ }
+ ;
+
+ /** @inheritDoc */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ throws InvalidValue
+ {
+ if (isNull)
+ throw new InvalidValue(ISNULL);
+ return super.gnu_get_members_as_dyn_any();
+ }
+ ;
+
+ /** @inheritDoc */
+ public NameValuePair[] get_members()
+ throws InvalidValue
+ {
+ if (isNull)
+ throw new InvalidValue(ISNULL);
+ else
+ return super.gnu_get_members();
+ }
+ ;
+
+ /** @inheritDoc */
+ public void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ super.set_members_as_dyn_any(value);
+ isNull = false;
+ }
+ ;
+
+ /** @inheritDoc */
+ public void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ super.set_members(value);
+ isNull = false;
+ }
+ ;
+
+ /** @inheritDoc */
+ public boolean is_null()
+ {
+ return isNull;
+ }
+
+ /** @inheritDoc */
+ public void set_to_null()
+ {
+ isNull = true;
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_value()
+ {
+ isNull = false;
+ valueChanged();
+ }
+
+ /**
+ * Create a new instance.
+ */
+ protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ gnuDynValue v = new gnuDynValue(oType, aType, aFactory, anOrb);
+ if (isNull)
+ v.set_to_null();
+ else
+ v.set_to_value();
+ return v;
+ }
+
+ /**
+ * Compare for equality, minding null values.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof DynValueOperations)
+ {
+ DynValueCommon o = (DynValueCommon) other;
+ if (isNull)
+ return o.is_null() && o.type().equal(official_type);
+ else
+ return !o.is_null() && super.equal(other);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the focused component, throwing exception if the current value is null.
+ */
+ protected DynAny focused()
+ throws InvalidValue, TypeMismatch
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.focused();
+ }
+
+ /**
+ * Convert into Any.
+ */
+ public Any to_any()
+ {
+ if (isNull)
+ {
+ Any a0 = createAny();
+ a0.type(orb.get_primitive_tc(TCKind.tk_null));
+ return a0;
+ }
+ else
+ {
+ try
+ {
+ ValueFactory factory =
+ ((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id());
+ if (factory == null)
+ throw new MARSHAL("Factory for " + official_type.id() +
+ " not registered."
+ );
+
+ OutputStream out = orb.create_output_stream();
+
+ for (int i = 0; i < array.length; i++)
+ array [ i ].to_any().write_value(out);
+
+ org.omg.CORBA_2_3.portable.InputStream in =
+ (org.omg.CORBA_2_3.portable.InputStream) out.create_input_stream();
+ Serializable v = factory.read_value(in);
+
+ Any g = createAny();
+ g.type(official_type);
+ g.insert_Value(v, official_type);
+
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof DynValue)
+ {
+ DynValue other = (DynValue) from;
+ if (other.is_null())
+ set_to_null();
+ else
+ {
+ set_to_value();
+ try
+ {
+ DynValueOperations src = (DynValueOperations) from;
+ set_members_as_dyn_any(src.get_members_as_dyn_any());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ }
+ }
+ else
+ throw new TypeMismatch("Not a DynValue");
+ }
+
+ /**
+ * Get the number of components.
+ */
+ public int component_count()
+ {
+ return isNull ? 0 : super.component_count();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ return to_any().extract_Value();
+ }
+
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ Any a = to_any();
+ a.insert_Value(a_x);
+ from_any(a);
+ valueChanged();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynValueBox.java b/gnu/CORBA/DynAn/gnuDynValueBox.java
new file mode 100644
index 000000000..66e18f3b2
--- /dev/null
+++ b/gnu/CORBA/DynAn/gnuDynValueBox.java
@@ -0,0 +1,389 @@
+/* gnuDynValueBox.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.CORBA.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynValueBox;
+import org.omg.DynamicAny.DynValueBoxOperations;
+import org.omg.DynamicAny.DynValueCommon;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Field;
+
+/**
+ * Implementation of the DynValueBox.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynValueBox
+ extends anyDivideable
+ implements DynValueBox, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The final_type of contents of this value box.
+ */
+ final TypeCode content;
+
+ /**
+ * The string for some TypeMismatch exceptions.
+ */
+ String CONTENT = "Box content final_type mismatch";
+
+ /**
+ * Create a new instance of gnuDynValueBox.
+ */
+ public gnuDynValueBox(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ content = final_type.content_type();
+ array = new DynAny[] { factory.create_dyn_any_from_type_code(content) };
+ set_to_null();
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynValueBoxOperations)
+ {
+ DynValueBoxOperations other = (DynValueBoxOperations) from;
+ if (other.is_null())
+ set_to_null();
+ else
+ {
+ DynAny inBox;
+ try
+ {
+ inBox = other.get_boxed_value_as_dyn_any();
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ if (!content.equal(inBox.type()))
+ throw new TypeMismatch(CONTENT);
+ array = new DynAny[] { inBox.copy() };
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public DynAny copy()
+ {
+ gnuDynValueBox other =
+ new gnuDynValueBox(official_type, final_type, factory, orb);
+ if (is_null())
+ other.set_to_null();
+ else
+ {
+ try
+ {
+ other.array = new DynAny[] { array [ 0 ].copy() };
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ return other;
+ }
+
+ /**
+ * Returns null for null value, delegates to super. otherwise.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ if (is_null())
+ return null;
+ else
+ return super.current_component();
+ }
+
+ /**
+ * Compare for equality, minding null values.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof DynValueCommon)
+ {
+ DynValueCommon o = (DynValueCommon) other;
+ if (is_null())
+ return o.is_null() && o.type().equal(official_type);
+ else
+ return !o.is_null() && super.equal(other);
+ }
+ else
+ return false;
+ }
+
+ /** @inheritDoc */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ if (!an_any.type().content_type().equal(content))
+ throw new InvalidValue(CONTENT);
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch("Not a box");
+ t.initCause(e);
+ throw t;
+ }
+
+ Serializable s = an_any.extract_Value();
+ if (s == null)
+ set_to_null();
+ else
+ {
+ try
+ {
+ Streamable holder = holderFactory.createHolder(content);
+ Field v = holder.getClass().getField("value");
+ v.set(holder, s);
+
+ Any cont = createAny();
+ cont.insert_Streamable(holder);
+
+ array = new DynAny[] { factory.create_dyn_any(cont) };
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public Any get_boxed_value()
+ throws InvalidValue
+ {
+ try
+ {
+ if (is_null())
+ throw new InvalidValue(ISNULL);
+ else
+ return array [ 0 ].to_any();
+ }
+ catch (Exception e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public DynAny get_boxed_value_as_dyn_any()
+ throws InvalidValue
+ {
+ if (is_null())
+ throw new InvalidValue(ISNULL);
+ else
+ return array [ 0 ].copy();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ return to_any().extract_Value();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ Any a = to_any();
+ a.insert_Value(a_x);
+ from_any(a);
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public boolean is_null()
+ {
+ return array.length == 0;
+ }
+
+ /** @inheritDoc */
+ public void set_boxed_value(Any boxIt)
+ throws TypeMismatch
+ {
+ if (!content.equal(boxIt.type()))
+ throw new TypeMismatch(CONTENT);
+ try
+ {
+ if (is_null())
+ {
+ array = new DynAny[] { factory.create_dyn_any(boxIt) };
+ }
+ else
+ {
+ array [ 0 ].from_any(boxIt);
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_boxed_value_as_dyn_any(DynAny boxIt)
+ throws TypeMismatch
+ {
+ if (!content.equal(boxIt.type()))
+ throw new TypeMismatch(CONTENT);
+ try
+ {
+ if (is_null())
+ {
+ array = new DynAny[] { boxIt.copy() };
+ }
+ else
+ {
+ array [ 0 ].assign(boxIt);
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_null()
+ {
+ array = new DynAny[ 0 ];
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_value()
+ {
+ try
+ {
+ if (array.length == 0)
+ {
+ array =
+ new DynAny[] { factory.create_dyn_any_from_type_code(content) };
+ }
+ }
+ catch (InconsistentTypeCode e)
+ {
+ throw new Unexpected(e);
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public Any to_any()
+ {
+ Any a = createAny();
+
+ if (!is_null())
+ {
+ try
+ {
+ Streamable holder;
+ if (array [ 0 ] instanceof gnuDynAny)
+ holder = ((gnuDynAny) array [ 0 ]).holder;
+ else
+ {
+ Any uan = array [ 0 ].to_any();
+ holder = uan.extract_Streamable();
+ }
+
+ Field v = holder.getClass().getField("value");
+ Serializable value = (Serializable) v.get(holder);
+ a.type(official_type);
+ a.insert_Value(value, content);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ else
+ a.type(orb.get_primitive_tc(TCKind.tk_null));
+ return a;
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/valueChangedListener.java b/gnu/CORBA/DynAn/valueChangedListener.java
new file mode 100644
index 000000000..94ddffbec
--- /dev/null
+++ b/gnu/CORBA/DynAn/valueChangedListener.java
@@ -0,0 +1,50 @@
+/* valueChangedListener.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.CORBA.DynAn;
+
+/**
+ * An interface, able to receive notification about the change of value
+ * of some DynAny.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface valueChangedListener
+{
+ void changed();
+} \ No newline at end of file
diff --git a/gnu/CORBA/DynAnySeqHolder.java b/gnu/CORBA/DynAnySeqHolder.java
new file mode 100644
index 000000000..52d66d9e9
--- /dev/null
+++ b/gnu/CORBA/DynAnySeqHolder.java
@@ -0,0 +1,116 @@
+/* DynAnySeqHolder.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.CORBA;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnySeqHelper;
+
+/**
+ * A holder for the sequence of {@link DynAny}
+ * ({@link DynAnySeq}).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DynAnySeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>DynAny</code>.
+ */
+ public DynAny[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public DynAnySeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public DynAnySeqHolder(DynAny[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = DynAnySeqHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ DynAnySeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the DynAny.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return DynAnySeqHelper.type();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/NameDynAnyPairHolder.java b/gnu/CORBA/NameDynAnyPairHolder.java
new file mode 100644
index 000000000..6ceb9aae0
--- /dev/null
+++ b/gnu/CORBA/NameDynAnyPairHolder.java
@@ -0,0 +1,115 @@
+/* NameDynAnyPairHolder.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.CORBA;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameDynAnyPairHelper;
+
+/**
+ * A holder for the structure {@link NameDynAnyPair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameDynAnyPairHolder
+ implements Streamable
+{
+ /**
+ * The stored NameDynAnyPair value.
+ */
+ public NameDynAnyPair value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public NameDynAnyPairHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public NameDynAnyPairHolder(NameDynAnyPair initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameDynAnyPairHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ NameDynAnyPairHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameDynAnyPair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameDynAnyPairHelper.type();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/NameDynAnyPairSeqHolder.java b/gnu/CORBA/NameDynAnyPairSeqHolder.java
new file mode 100644
index 000000000..71b6174c1
--- /dev/null
+++ b/gnu/CORBA/NameDynAnyPairSeqHolder.java
@@ -0,0 +1,115 @@
+/* NameDynAnyPairSeqHolder.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.CORBA;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameDynAnyPairSeqHelper;
+
+/**
+ * A holder for the sequence of {@link NameDynAnyPair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameDynAnyPairSeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>NameDynAnyPair</code>.
+ */
+ public NameDynAnyPair[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public NameDynAnyPairSeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public NameDynAnyPairSeqHolder(NameDynAnyPair[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameDynAnyPairSeqHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ NameDynAnyPairSeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameDynAnyPair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameDynAnyPairSeqHelper.type();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/NameValuePairHolder.java b/gnu/CORBA/NameValuePairHolder.java
new file mode 100644
index 000000000..9a939d5e3
--- /dev/null
+++ b/gnu/CORBA/NameValuePairHolder.java
@@ -0,0 +1,105 @@
+/* NameValuePairHolder.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.CORBA;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameValuePair;
+import org.omg.DynamicAny.NameValuePairHelper;
+
+/**
+ * A holder for the structure {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameValuePairHolder
+ implements Streamable
+{
+ /**
+ * The stored NameValuePair value.
+ */
+ public NameValuePair value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public NameValuePairHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public NameValuePairHolder(NameValuePair initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameValuePairHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ NameValuePairHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameValuePair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameValuePairHelper.type();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/NameValuePairSeqHolder.java b/gnu/CORBA/NameValuePairSeqHolder.java
new file mode 100644
index 000000000..216d78e04
--- /dev/null
+++ b/gnu/CORBA/NameValuePairSeqHolder.java
@@ -0,0 +1,105 @@
+/* NameValuePairSeqHolder.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.CORBA;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameValuePair;
+import org.omg.DynamicAny.NameValuePairSeqHelper;
+
+/**
+ * A holder for the sequence of {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameValuePairSeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>NameValuePair</code>.
+ */
+ public NameValuePair[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public NameValuePairSeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public NameValuePairSeqHolder(NameValuePair[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the {@link value} array from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameValuePairSeqHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ NameValuePairSeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameValuePair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameValuePairSeqHelper.type();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/Poa/ORB_1_4.java b/gnu/CORBA/Poa/ORB_1_4.java
index 6302ddf12..00ca3bf76 100644
--- a/gnu/CORBA/Poa/ORB_1_4.java
+++ b/gnu/CORBA/Poa/ORB_1_4.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.DynAn.gnuDynAnyFactory;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.OBJECT_NOT_EXIST;
@@ -62,10 +63,15 @@ public class ORB_1_4
* Maps the active threads to the invocation data ("Current's").
*/
public gnuPoaCurrent currents = new gnuPoaCurrent();
+
+ /**
+ * Creates dynamic anys.
+ */
+ public gnuDynAnyFactory factory = new gnuDynAnyFactory(this);
/**
- * Calls the parent constructor and additionally puts the "RootPOA" and
- * "RootPOAManager" into initial references.
+ * Calls the parent constructor and additionally puts the "RootPOA",
+ * "RootPOAManager", "POACurrent" and "DynAnyFactory" into initial references.
*/
public ORB_1_4()
{
@@ -84,6 +90,7 @@ public class ORB_1_4
initial_references.put("RootPOA", rootPOA);
initial_references.put("RootPOAManager", rootPOA.the_POAManager());
initial_references.put("POACurrent", currents);
+ initial_references.put("DynAnyFactory", factory);
}
/**
diff --git a/gnu/CORBA/Restricted_ORB.java b/gnu/CORBA/Restricted_ORB.java
index 801154e20..698c8b11e 100644
--- a/gnu/CORBA/Restricted_ORB.java
+++ b/gnu/CORBA/Restricted_ORB.java
@@ -240,13 +240,16 @@ public class Restricted_ORB
}
/** {@inheritDoc} */
- public TypeCode create_union_tc(String id, String name, TypeCode type,
+ public TypeCode create_union_tc(String id, String name,
+ TypeCode discriminator_type,
UnionMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_union);
r.setId(id);
r.setName(name);
+ r.setDiscriminator_type(discriminator_type);
+ r.setDefaultIndex(0);
for (int i = 0; i < members.length; i++)
{
@@ -454,7 +457,9 @@ public class Restricted_ORB
if (f != null)
return f;
- f = (ValueFactory) ObjectCreator.createObject(repository_id, "DefaultFactory");
+ f = (ValueFactory) ObjectCreator.createObject(repository_id,
+ "DefaultFactory"
+ );
if (f != null)
factories.put(repository_id, f);
diff --git a/gnu/CORBA/fixedTypeCode.java b/gnu/CORBA/fixedTypeCode.java
index ec88c22be..eb610417b 100644
--- a/gnu/CORBA/fixedTypeCode.java
+++ b/gnu/CORBA/fixedTypeCode.java
@@ -109,16 +109,12 @@ public class fixedTypeCode
return number.unscaledValue().abs().toString().length();
}
- public boolean equals(Object other)
+ /**
+ * Compare with other type code for equality.
+ */
+ public boolean equal(TypeCode other)
{
- if (other == this)
- {
- return true;
- }
- if (!(other instanceof TypeCode))
- {
- return false;
- }
+ if (other == this) return true;
try
{
TypeCode that = (TypeCode) other;
diff --git a/gnu/CORBA/gnuAny.java b/gnu/CORBA/gnuAny.java
index a48c50d61..7e5ef3351 100644
--- a/gnu/CORBA/gnuAny.java
+++ b/gnu/CORBA/gnuAny.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.CDR.Vio;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
@@ -63,6 +64,7 @@ import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodeHolder;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
import java.io.IOException;
@@ -499,20 +501,33 @@ public class gnuAny
}
/** {@inheritDoc} */
- public void insert_Value(Serializable x, TypeCode typecode)
+ public void insert_Value(Serializable x, TypeCode c_typecode)
{
- type(typecode);
- insert_Value(x);
+ if (typecode != null && typecode.kind() == TCKind.tk_value_box)
+ {
+ has = new gnuValueHolder(x, typecode);
+ }
+ else
+ {
+ type(typecode);
+ insert_Value(x);
+ }
}
/** {@inheritDoc} */
public void insert_Value(Serializable x)
{
- resetTypes();
- if (has instanceof ValueBaseHolder)
- ((ValueBaseHolder) has).value = x;
+ if (typecode != null && typecode.kind() == TCKind.tk_value_box)
+ {
+ has = new gnuValueHolder(x, typecode);
+ }
else
- has = new ValueBaseHolder(x);
+ {
+ if (has instanceof ValueBaseHolder)
+ ((ValueBaseHolder) has).value = x;
+ else
+ has = new ValueBaseHolder(x);
+ }
}
/**
@@ -748,15 +763,38 @@ public class gnuAny
}
}
type(a_type);
- has._read(input);
- }
- catch (BadKind ex)
- {
- throw new MARSHAL("Bad kind: " + ex.getMessage());
+
+ if (!(has instanceof universalHolder) &&
+ (kind == TCKind._tk_value_box))
+ {
+ // The streamable only contains operations for
+ // reading the value, not the value header.
+ Field vField = has.getClass().getField("value");
+
+ BoxedValueHelper helper;
+
+ try
+ {
+ Class helperClass =
+ Class.forName(ObjectCreator.toHelperName(a_type.id()));
+ helper = (BoxedValueHelper) helperClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ helper = null;
+ }
+
+ Object content = Vio.read(input, helper);
+ vField.set(has, content);
+ }
+ else
+ has._read(input);
}
- catch (IOException ex)
+ catch (Exception ex)
{
- throw new MARSHAL("IO exception: " + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.initCause(ex);
+ throw m;
}
}
@@ -790,6 +828,12 @@ public class gnuAny
{
if (has != null)
has._write(output);
+ else
+ // These kinds support null.
+ if (xKind == TCKind._tk_null || xKind == TCKind._tk_objref ||
+ xKind == TCKind._tk_value || xKind == TCKind._tk_value_box
+ )
+ output.write_long(0);
}
/**
@@ -806,16 +850,26 @@ public class gnuAny
if (xKind >= 0)
{
if (xKind != kind)
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " when stored " + typeNamer.nameIt(xKind)
- );
+ if (!(
+ xKind == TCKind._tk_alias &&
+ has._type().kind().value() == kind
+ )
+ )
+ throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
+ " when stored " + typeNamer.nameIt(xKind)
+ );
}
else
{
if (type().kind().value() != kind)
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " stored " + typeNamer.nameIt(type())
- );
+ if (!(
+ type().kind().value() == TCKind._tk_alias &&
+ has._type().kind().value() == kind
+ )
+ )
+ throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
+ " stored " + typeNamer.nameIt(type())
+ );
}
}
diff --git a/gnu/CORBA/gnuValueHolder.java b/gnu/CORBA/gnuValueHolder.java
new file mode 100644
index 000000000..0b3826489
--- /dev/null
+++ b/gnu/CORBA/gnuValueHolder.java
@@ -0,0 +1,135 @@
+/* gnuValueHolder.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.CORBA;
+
+import gnu.CORBA.CDR.Vio;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+
+/**
+ * Boxed value holder that also remembers the value type and the value helper.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuValueHolder
+ extends ValueBaseHolder
+{
+ /**
+ * The type code of the stored value.
+ */
+ TypeCode type;
+
+ /**
+ * The helper that could read and write fields of the boxed value.
+ */
+ transient BoxedValueHelper helper;
+
+ /**
+ * If true, the helper not available.
+ */
+ transient boolean helper_NA;
+
+ /**
+ * Create a new instance for the given value and given type.
+ */
+ public gnuValueHolder(Serializable value, TypeCode a_type)
+ {
+ super(value);
+ type = a_type;
+ }
+
+ /**
+ * Get the true type, as it was passed in the constructor.
+ */
+ public TypeCode _type()
+ {
+ return type;
+ }
+
+ /**
+ * Write content to the output stream. Tries to locate the
+ * corresponding helper class.
+ */
+ public void _write(OutputStream output)
+ {
+ findHelper();
+ if (helper == null)
+ super._write(output);
+ else
+ Vio.write(output, value, helper);
+ }
+
+ /**
+ * Read, trying to locate helper, if possible.
+ */
+ public void _read(InputStream input)
+ {
+ findHelper();
+ if (helper == null)
+ super._read(input);
+ else
+ value = Vio.read(input, helper);
+ }
+
+ /**
+ * Set the read and write methods.
+ */
+ void findHelper()
+ {
+ if (helper != null || helper_NA)
+ return;
+ try
+ {
+ Class helperClass =
+ Class.forName(ObjectCreator.toHelperName(type.id()));
+
+ helper = (BoxedValueHelper) helperClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ helper_NA = true;
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/holderFactory.java b/gnu/CORBA/holderFactory.java
index 177797a9c..159d22332 100644
--- a/gnu/CORBA/holderFactory.java
+++ b/gnu/CORBA/holderFactory.java
@@ -68,74 +68,76 @@ import org.omg.CORBA.UShortSeqHolder;
import org.omg.CORBA.WCharSeqHolder;
import org.omg.CORBA.WStringSeqHolder;
import org.omg.CORBA.portable.Streamable;
+import org.omg.CORBA.ObjectHolder;
/**
- * Creates the suitable holder for storing the value of the given
- * type.
+ * Creates the suitable holder for storing the value of the given final_type.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class holderFactory
{
/**
- * The array, sufficiently large to use any {@link TCKind}._tk* constant
- * as an index.
+ * The array, sufficiently large to use any {@link TCKind}._tk* constant as
+ * an index.
*/
private static final Class[] holders;
+
private static final Class[] seqHolders;
static
- {
- holders = new Class[ 32 ];
- holders [ TCKind._tk_Principal ] = PrincipalHolder.class;
- holders [ TCKind._tk_TypeCode ] = TypeCodeHolder.class;
- holders [ TCKind._tk_any ] = AnyHolder.class;
- holders [ TCKind._tk_boolean ] = BooleanHolder.class;
- holders [ TCKind._tk_char ] = CharHolder.class;
- holders [ TCKind._tk_double ] = DoubleHolder.class;
- holders [ TCKind._tk_float ] = FloatHolder.class;
- holders [ TCKind._tk_fixed ] = FixedHolder.class;
- holders [ TCKind._tk_long ] = IntHolder.class;
- holders [ TCKind._tk_longdouble ] = DoubleHolder.class;
- holders [ TCKind._tk_longlong ] = LongHolder.class;
- holders [ TCKind._tk_octet ] = OctetHolder.class;
- holders [ TCKind._tk_short ] = ShortHolder.class;
- holders [ TCKind._tk_string ] = StringHolder.class;
- holders [ TCKind._tk_ulong ] = IntHolder.class;
- holders [ TCKind._tk_ulonglong ] = LongHolder.class;
- holders [ TCKind._tk_ushort ] = ShortHolder.class;
- holders [ TCKind._tk_wchar ] = WCharHolder.class;
- holders [ TCKind._tk_wstring ] = WStringHolder.class;
-
- seqHolders = new Class[ 32 ];
-
- seqHolders [ TCKind._tk_ulonglong ] = ULongLongSeqHolder.class;
- seqHolders [ TCKind._tk_short ] = ShortSeqHolder.class;
- seqHolders [ TCKind._tk_octet ] = OctetSeqHolder.class;
- seqHolders [ TCKind._tk_any ] = AnySeqHolder.class;
- seqHolders [ TCKind._tk_long ] = LongSeqHolder.class;
- seqHolders [ TCKind._tk_longlong ] = LongLongSeqHolder.class;
- seqHolders [ TCKind._tk_float ] = FloatSeqHolder.class;
- seqHolders [ TCKind._tk_double ] = DoubleSeqHolder.class;
- seqHolders [ TCKind._tk_char ] = CharSeqHolder.class;
- seqHolders [ TCKind._tk_boolean ] = BooleanSeqHolder.class;
- seqHolders [ TCKind._tk_wchar ] = WCharSeqHolder.class;
- seqHolders [ TCKind._tk_ushort ] = UShortSeqHolder.class;
- seqHolders [ TCKind._tk_ulong ] = ULongSeqHolder.class;
- seqHolders [ TCKind._tk_string ] = StringSeqHolder.class;
- seqHolders [ TCKind._tk_wstring ] = WStringSeqHolder.class;
- }
+ {
+ holders = new Class[32];
+ holders[TCKind._tk_Principal] = PrincipalHolder.class;
+ holders[TCKind._tk_TypeCode] = TypeCodeHolder.class;
+ holders[TCKind._tk_any] = AnyHolder.class;
+ holders[TCKind._tk_boolean] = BooleanHolder.class;
+ holders[TCKind._tk_char] = CharHolder.class;
+ holders[TCKind._tk_double] = DoubleHolder.class;
+ holders[TCKind._tk_float] = FloatHolder.class;
+ holders[TCKind._tk_fixed] = FixedHolder.class;
+ holders[TCKind._tk_long] = IntHolder.class;
+ holders[TCKind._tk_longdouble] = DoubleHolder.class;
+ holders[TCKind._tk_longlong] = LongHolder.class;
+ holders[TCKind._tk_octet] = OctetHolder.class;
+ holders[TCKind._tk_short] = ShortHolder.class;
+ holders[TCKind._tk_string] = StringHolder.class;
+ holders[TCKind._tk_ulong] = IntHolder.class;
+ holders[TCKind._tk_ulonglong] = LongHolder.class;
+ holders[TCKind._tk_ushort] = ShortHolder.class;
+ holders[TCKind._tk_wchar] = WCharHolder.class;
+ holders[TCKind._tk_wstring] = WStringHolder.class;
+ holders[TCKind._tk_objref] = ObjectHolder.class;
+
+ seqHolders = new Class[32];
+
+ seqHolders[TCKind._tk_ulonglong] = ULongLongSeqHolder.class;
+ seqHolders[TCKind._tk_short] = ShortSeqHolder.class;
+ seqHolders[TCKind._tk_octet] = OctetSeqHolder.class;
+ seqHolders[TCKind._tk_any] = AnySeqHolder.class;
+ seqHolders[TCKind._tk_long] = LongSeqHolder.class;
+ seqHolders[TCKind._tk_longlong] = LongLongSeqHolder.class;
+ seqHolders[TCKind._tk_float] = FloatSeqHolder.class;
+ seqHolders[TCKind._tk_double] = DoubleSeqHolder.class;
+ seqHolders[TCKind._tk_char] = CharSeqHolder.class;
+ seqHolders[TCKind._tk_boolean] = BooleanSeqHolder.class;
+ seqHolders[TCKind._tk_wchar] = WCharSeqHolder.class;
+ seqHolders[TCKind._tk_ushort] = UShortSeqHolder.class;
+ seqHolders[TCKind._tk_ulong] = ULongSeqHolder.class;
+ seqHolders[TCKind._tk_string] = StringSeqHolder.class;
+ seqHolders[TCKind._tk_wstring] = WStringSeqHolder.class;
+ }
/**
- * Create a holder for storing the value of the given built-in type.
- * This function returns the defined holders for the built-in primitive
- * types and they sequences.
+ * Create a holder for storing the value of the given built-in final_type. This
+ * function returns the defined holders for the built-in primitive types and
+ * they sequences.
*
* @param t the typecode
*
- * @return an instance of the corresponding built-in holder of null
- * if no such is defined for this type. The holder is created with a
- * parameterless constructor.
+ * @return an instance of the corresponding built-in holder of null if no such
+ * is defined for this final_type. The holder is created with a parameterless
+ * constructor.
*/
public static Streamable createHolder(TypeCode t)
{
@@ -145,24 +147,23 @@ public class holderFactory
int componentKind;
Streamable holder = null;
- Streamable component;
- if (kind < holders.length && holders [ kind ] != null)
- holder = (Streamable) holders [ kind ].newInstance();
+ if (kind < holders.length && holders[kind] != null)
+ holder = (Streamable) holders[kind].newInstance();
if (holder != null)
return holder;
switch (kind)
{
- case TCKind._tk_sequence :
- componentKind = t.content_type().kind().value();
- if (componentKind < seqHolders.length)
- return (Streamable) seqHolders [ componentKind ].newInstance();
- break;
-
- default :
- break;
+ case TCKind._tk_sequence:
+ componentKind = t.content_type().kind().value();
+ if (componentKind < seqHolders.length)
+ return (Streamable) seqHolders[componentKind].newInstance();
+ break;
+
+ default:
+ break;
}
}
catch (Exception ex)
diff --git a/gnu/CORBA/typeNamer.java b/gnu/CORBA/typeNamer.java
index 8b701015e..f790dc959 100644
--- a/gnu/CORBA/typeNamer.java
+++ b/gnu/CORBA/typeNamer.java
@@ -83,7 +83,7 @@ public class typeNamer
new primitiveTypeCode(TCKind.tk_any),
new primitiveTypeCode(TCKind.tk_TypeCode),
new primitiveTypeCode(TCKind.tk_Principal),
- new primitiveTypeCode(TCKind.tk_objref),
+ new recordTypeCode(TCKind.tk_objref),
new primitiveTypeCode(TCKind.tk_struct),
new primitiveTypeCode(TCKind.tk_union),
new primitiveTypeCode(TCKind.tk_enum),
@@ -104,6 +104,15 @@ public class typeNamer
new primitiveTypeCode(TCKind.tk_abstract_interface)
};
+ static
+ {
+ // The Id of the "abstract object" is defined as empty string.
+ recordTypeCode object =
+ (recordTypeCode) primitveCodes [ TCKind._tk_objref ];
+ object.setId("");
+ object.setName("Object");
+ }
+
/**
* Get the primitive type code.
*
@@ -168,4 +177,4 @@ public class typeNamer
return "type of kind '" + type.kind().value() + "'";
}
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/universalHolder.java b/gnu/CORBA/universalHolder.java
index 6d8b77472..c20dac442 100644
--- a/gnu/CORBA/universalHolder.java
+++ b/gnu/CORBA/universalHolder.java
@@ -60,7 +60,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-class universalHolder
+public class universalHolder
implements Streamable
{
/**
@@ -71,7 +71,7 @@ class universalHolder
/**
* Create the universal holder that uses the given buffer to store the data.
*/
- universalHolder(cdrBufOutput buffer)
+ public universalHolder(cdrBufOutput buffer)
{
value = buffer;
}
@@ -154,4 +154,21 @@ class universalHolder
{
return value.create_input_stream();
}
-}
+
+ /**
+ * Clone.
+ */
+ public universalHolder Clone()
+ {
+ try
+ {
+ cdrBufOutput nb = new cdrBufOutput(value.buffer.size());
+ value.buffer.writeTo(nb);
+ return new universalHolder(nb);
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/classpath/debug/Component.java b/gnu/classpath/debug/Component.java
index 3dfc8927b..242419ce4 100644
--- a/gnu/classpath/debug/Component.java
+++ b/gnu/classpath/debug/Component.java
@@ -110,6 +110,12 @@ public final class Component extends Level
*/
public static final Component X509 = new Component ("X.509", 6);
+ /**
+ * Trace access control policies, including the parsing of
+ * java.policy files.
+ */
+ public static final Component POLICY = new Component ("POLICY", 7);
+
private final int startIndex;
private final int endIndex;
diff --git a/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java b/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java
index c022dc537..3cf8592f4 100644
--- a/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java
+++ b/gnu/classpath/jdwp/exception/JdwpInternalErrorException.java
@@ -50,8 +50,13 @@ import gnu.classpath.jdwp.JdwpConstants;
public class JdwpInternalErrorException
extends JdwpException
{
- public JdwpInternalErrorException (Throwable cause)
+ public JdwpInternalErrorException(Throwable cause)
{
- super (JdwpConstants.Error.INTERNAL, cause);
+ super(JdwpConstants.Error.INTERNAL, cause);
+ }
+
+ public JdwpInternalErrorException(String msg)
+ {
+ super(JdwpConstants.Error.INTERNAL, msg);
}
}
diff --git a/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java
new file mode 100644
index 000000000..fb5802794
--- /dev/null
+++ b/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java
@@ -0,0 +1,114 @@
+/* ClassLoaderReferenceCommandSet.java -- class to implement the
+ ClassLoaderReference Command Set
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.processor;
+
+import gnu.classpath.jdwp.IVirtualMachine;
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.IdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A class representing the ClassLoaderReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ClassLoaderReferenceCommandSet implements CommandSet
+{
+ // Our hook into the jvm
+ private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
+
+ // Manages all the different ids that are assigned by jdwp
+ private final IdManager idMan = Jdwp.getIdManager();
+
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+
+ // Although there's only a single command to choose from we still use
+ // a switch to maintain consistency with the rest of the CommandSets
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ClassLoaderReference.VISIBLE_CLASSES:
+ executeVisibleClasses(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ClassLoaderReference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ public void executeVisibleClasses(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oId = idMan.readId(bb);
+ ClassLoader cl = (ClassLoader) oId.getObject();
+ ArrayList loadRequests = vm.getLoadRequests(cl);
+ os.writeInt(loadRequests.size());
+ for (Iterator iter = loadRequests.iterator(); iter.hasNext();)
+ {
+ Class clazz = (Class)iter.next();
+ ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+ refId.writeTagged(os);
+ }
+ }
+
+}
diff --git a/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java b/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
new file mode 100644
index 000000000..2d84abbbd
--- /dev/null
+++ b/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
@@ -0,0 +1,228 @@
+/* ClassTypeCommandSet.java -- class to implement the ClassType
+ Command Set
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.processor;
+
+import gnu.classpath.jdwp.IVirtualMachine;
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.IdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.MethodResult;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ClassType Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ClassTypeCommandSet implements CommandSet
+{
+ // Our hook into the jvm
+ private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
+
+ // Manages all the different ids that are assigned by jdwp
+ private final IdManager idMan = Jdwp.getIdManager();
+
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ClassType.SUPERCLASS:
+ executeSuperclass(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.SET_VALUES:
+ executeSetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.INVOKE_METHOD:
+ executeInvokeMethod(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.NEW_INSTANCE:
+ executeNewInstance(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ClassType Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeSuperclass(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+ Class superClazz = clazz.getSuperclass();
+
+ ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
+ clazzId.write(os);
+ }
+
+ private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+
+ // We don't actually seem to need this...
+ Class clazz = refId.getType();
+
+ int numValues = bb.getInt();
+
+ for (int i = 0; i < numValues; i++)
+ {
+ ObjectId fieldId = idMan.readId(bb);
+ Field field = (Field) (fieldId.getObject());
+ Object value = Value.getUntaggedObj(bb, field.getType());
+ try
+ {
+ field.setAccessible(true); // Might be a private field
+ field.set(null, value);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ throw new InvalidFieldException(ex);
+ }
+ catch (IllegalAccessException ex)
+ { // Since we set it as accessible this really shouldn't happen
+ throw new JdwpInternalErrorException(ex);
+ }
+ }
+ }
+
+ private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ MethodResult mr = invokeMethod(bb);
+
+ Object value = mr.getReturnedValue();
+ Exception exception = mr.getThrownException();
+ ObjectId eId = idMan.getId(exception);
+
+ Value.writeTaggedValue(os, value);
+ eId.writeTagged(os);
+ }
+
+ private void executeNewInstance(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ MethodResult mr = invokeMethod(bb);
+
+ Object obj = mr.getReturnedValue();
+ ObjectId oId = idMan.getId(obj);
+ Exception exception = mr.getThrownException();
+ ObjectId eId = idMan.getId(exception);
+
+ oId.writeTagged(os);
+ eId.writeTagged(os);
+ }
+
+ /**
+ * Execute the static method and return the resulting MethodResult.
+ */
+ private MethodResult invokeMethod(ByteBuffer bb) throws JdwpException,
+ IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+
+ ObjectId tId = idMan.readId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ ObjectId mId = idMan.readId(bb);
+ Method method = (Method) mId.getObject();
+
+ int args = bb.getInt();
+ Object[] values = new Object[args];
+
+ for (int i = 0; i < args; i++)
+ {
+ values[i] = Value.getObj(bb);
+ }
+ boolean suspendSuccess = false;
+ int invokeOpts = bb.getInt();
+ try
+ {
+ if ((invokeOpts & JdwpConstants.InvokeOptions.INVOKE_SINGLE_THREADED)
+ != 0)
+ {
+ // We must suspend all running threads first
+ suspendSuccess = vm.suspendAllThreadsExcept(Thread.currentThread().
+ getThreadGroup());
+ }
+ MethodResult mr = vm.executeMethod(null, thread, clazz, method, values,
+ false);
+ if (suspendSuccess)
+ { // We must call resume if we suspended threads
+ suspendSuccess = false;
+ vm.resumeAllThreadsExcept(Thread.currentThread().getThreadGroup());
+ }
+ return mr;
+ }
+ catch (Exception ex)
+ {
+ if (suspendSuccess)
+ { // We must call resume if we suspended threads
+ vm.resumeAllThreadsExcept(Thread.currentThread().getThreadGroup());
+ }
+ throw new JdwpInternalErrorException(ex);
+ }
+ }
+}
diff --git a/gnu/classpath/jdwp/processor/EventRequestCommandSet.java b/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
new file mode 100644
index 000000000..b2eb2ea7b
--- /dev/null
+++ b/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
@@ -0,0 +1,208 @@
+/* EventRequestCommandSet.java -- class to implement the EventRequest Command
+ Set
+ Copyright (C) 2005 Free Software Foundation
+
+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.jdwp.processor;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.event.EventManager;
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.event.filters.ConditionalFilter;
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.event.filters.ExceptionOnlyFilter;
+import gnu.classpath.jdwp.event.filters.FieldOnlyFilter;
+import gnu.classpath.jdwp.event.filters.IEventFilter;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.event.filters.LocationOnlyFilter;
+import gnu.classpath.jdwp.event.filters.StepFilter;
+import gnu.classpath.jdwp.event.filters.ThreadFilter;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.IdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+
+/**
+ * A class representing the EventRequest Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class EventRequestCommandSet implements CommandSet
+{
+ // Manages all the different ids that are assigned by jdwp
+ private final IdManager idMan = Jdwp.getIdManager();
+
+ // The Event Manager
+ private final EventManager evMan = Jdwp.getDefault().getEventManager();
+
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.EventRequest.SET:
+ executeSet(bb, os);
+ break;
+ case JdwpConstants.CommandSet.EventRequest.CLEAR:
+ executeClear(bb, os);
+ break;
+ case JdwpConstants.CommandSet.EventRequest.CLEAR_ALL_BREAKPOINTS:
+ executeClearAllBreakpoints(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in EventRequest Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeSet(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ byte eventKind = bb.get();
+ byte suspendPolicy = bb.get();
+ int modifiers = bb.getInt();
+
+ EventRequest eventReq = new EventRequest(eventKind, suspendPolicy);
+ IEventFilter filter = null;
+ ReferenceTypeId refId;
+ for (int i = 0; i < modifiers; i++)
+ {
+ byte modKind = bb.get();
+ switch (modKind)
+ {
+ case 1:
+ filter = new CountFilter(bb.getInt());
+ break;
+ case 2:
+ filter = new ConditionalFilter(idMan.readId(bb));
+ break;
+ case 3:
+ filter = new ThreadFilter((ThreadId) idMan.readId(bb));
+ break;
+ case 4:
+ filter = new ClassOnlyFilter(idMan.readReferenceTypeId(bb));
+ break;
+ case 5:
+ filter = new ClassMatchFilter(JdwpString.readString(bb));
+ break;
+ case 6:
+ filter = new ClassExcludeFilter(JdwpString.readString(bb));
+ break;
+ case 7:
+ filter = new LocationOnlyFilter(new Location(bb));
+ break;
+ case 8:
+ long id = bb.getLong();
+ if (id == 0)
+ refId = null;
+ else
+ refId = idMan.readReferenceTypeId(bb);
+ boolean caught = (bb.get() == 0) ? false : true;
+ boolean unCaught = (bb.get() == 0) ? false : true;
+ filter = new ExceptionOnlyFilter(refId, caught, unCaught);
+ break;
+ case 9:
+ refId = idMan.readReferenceTypeId(bb);
+ ReferenceTypeId fieldId = idMan.readReferenceTypeId(bb);
+ filter = new FieldOnlyFilter(refId, fieldId);
+ break;
+ case 10:
+ ObjectId tid = idMan.readId(bb);
+ int size = bb.getInt();
+ int depth = bb.getInt();
+ filter = new StepFilter(tid, size, depth);
+ break;
+ case 11:
+ ObjectId oid = idMan.readId(bb);
+ filter = new InstanceOnlyFilter(oid.getObject());
+ break;
+ default:
+ throw new NotImplementedException("modKind " + modKind
+ + " is not implemented.");
+ }
+ eventReq.addFilter(filter);
+ }
+ evMan.requestEvent(eventReq);
+ os.writeInt(eventReq.getId());
+
+ }
+
+ private void executeClear(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ byte eventKind = bb.get();
+ int requestId = bb.getInt();
+ EventRequest request = evMan.getRequest(eventKind, requestId);
+ evMan.deleteRequest(request);
+ }
+
+ private void executeClearAllBreakpoints(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ Iterator evReqIter = evMan.getAllRequests(EventRequest.EVENT_BREAKPOINT);
+ while (evReqIter.hasNext())
+ {
+ EventRequest evReq = (EventRequest) evReqIter.next();
+ evMan.deleteRequest(evReq);
+ }
+ }
+
+}
diff --git a/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
index 56980eecd..31f629ffe 100644
--- a/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
@@ -1,4 +1,4 @@
-/* ObjectReferenceCommandSet.java -- lass to implement the ObjectReference
+/* ObjectReferenceCommandSet.java -- class to implement the ObjectReference
Command Set
Copyright (C) 2005 Free Software Foundation
@@ -50,7 +50,7 @@ import gnu.classpath.jdwp.id.IdManager;
import gnu.classpath.jdwp.id.ObjectId;
import gnu.classpath.jdwp.id.ReferenceTypeId;
import gnu.classpath.jdwp.util.Value;
-import gnu.classpath.jdwp.util.MethodInvoker;
+import gnu.classpath.jdwp.util.MethodResult;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -232,14 +232,14 @@ public class ObjectReferenceCommandSet implements CommandSet
nonVirtual = true;
else
nonVirtual = false;
- MethodInvoker vmi = new MethodInvoker(vm);
- vmi.executeMethod(obj, thread, clazz, method, values, nonVirtual);
- Object value = vmi.getReturnedValue();
- ObjectId exceptionId = vmi.getExceptionId();
+ MethodResult mr = vm.executeMethod(obj, thread, clazz, method, values, nonVirtual);
+ Object value = mr.getReturnedValue();
+ Exception exception = mr.getThrownException();
+ ObjectId eId = idMan.getId(exception);
Value.writeTaggedValue(os, value);
- exceptionId.writeTagged(os);
+ eId.writeTagged(os);
}
private void executeDisableCollection(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/StackFrameCommandSet.java b/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
new file mode 100644
index 000000000..97315c0e8
--- /dev/null
+++ b/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
@@ -0,0 +1,164 @@
+/* StackFrameCommandSet.java -- class to implement the StackFrame Command Set
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.processor;
+
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.IVirtualMachine;
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.IdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the StackFrame Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class StackFrameCommandSet implements CommandSet
+{
+ // Our hook into the jvm
+ private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
+
+ // Manages all the different ids that are assigned by jdwp
+ private final IdManager idMan = Jdwp.getIdManager();
+
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ boolean keepRunning = true;
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.StackFrame.GET_VALUES:
+ executeGetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.SET_VALUES:
+ executeSetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.THIS_OBJECT:
+ executeThisObject(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.POP_FRAMES:
+ executePopFrames(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in Stack Frame Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ // Although Frames look like other ids they are not. First they are not
+ // ObjectIds since they don't exist in the users code. Storing them as an
+ // ObjectId would mean they could be garbage collected since no one else
+ // has a reference to them. Furthermore they are not ReferenceTypeIds since
+ // these are held permanently and we want these to be held only as long as
+ // the Thread is suspended.
+ VMFrame frame = vm.getVMFrame(thread, bb);
+ int slots = bb.getInt();
+ os.writeInt(slots); // Looks pointless but this is the protocol
+ for (int i = 0; i < slots; i++)
+ {
+ int slot = bb.getInt();
+ byte sig = bb.get();
+ Object val = frame.getValue(slot);
+ Value.writeTaggedValue(os, val);
+ }
+ }
+
+ private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ VMFrame frame = vm.getVMFrame(thread, bb);
+
+ int slots = bb.getInt();
+ for (int i = 0; i < slots; i++)
+ {
+ int slot = bb.getInt();
+ Object value = Value.getObj(bb);
+ frame.setValue(slot, value);
+ }
+ }
+
+ private void executeThisObject(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ VMFrame frame = vm.getVMFrame(thread, bb);
+
+ Object thisObject = frame.getObject();
+ Value.writeTaggedValue(os, thisObject);
+ }
+
+ private void executePopFrames(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException("Command PopFrames not implemented.");
+ }
+}
diff --git a/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
new file mode 100644
index 000000000..871096960
--- /dev/null
+++ b/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
@@ -0,0 +1,251 @@
+/* ThreadReferenceCommandSet.java -- class to implement the ThreadReference
+ Command Set Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.processor;
+
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.IVirtualMachine;
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.IdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+/**
+ * A class representing the ThreadReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ThreadReferenceCommandSet implements CommandSet
+{
+ // Our hook into the jvm
+ private final IVirtualMachine vm = Jdwp.getIVirtualMachine();
+
+ // Manages all the different ids that are assigned by jdwp
+ private final IdManager idMan = Jdwp.getIdManager();
+
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ThreadReference.NAME:
+ executeName(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.SUSPEND:
+ executeSuspend(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.RESUME:
+ executeResume(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.STATUS:
+ executeStatus(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.THREAD_GROUP:
+ executeThreadGroup(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.FRAMES:
+ executeFrames(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.FRAME_COUNT:
+ executeFrameCount(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.OWNED_MONITORS:
+ executeOwnedMonitors(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.CURRENT_CONTENDED_MONITOR:
+ executeCurrentContendedMonitor(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.STOP:
+ executeStop(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.INTERRUPT:
+ executeInterrupt(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.SUSPEND_COUNT:
+ executeSuspendCount(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in Thread Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeName(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ JdwpString.writeString(os, thread.getName());
+ }
+
+ private void executeSuspend(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ vm.suspendThread(thread);
+ }
+
+ private void executeResume(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ vm.suspendThread(thread);
+ }
+
+ private void executeStatus(ByteBuffer bb, DataOutputStream os)
+ throws InvalidObjectException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ int threadStatus = vm.getThreadStatus(thread);
+ // There's only one possible SuspendStatus...
+ int suspendStatus = JdwpConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED;
+
+ os.writeInt(threadStatus);
+ os.writeInt(suspendStatus);
+ }
+
+ private void executeThreadGroup(ByteBuffer bb, DataOutputStream os)
+ throws InvalidObjectException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ ThreadGroup group = thread.getThreadGroup();
+ ObjectId groupId = idMan.getId(group);
+ groupId.write(os);
+ }
+
+ private void executeFrames(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ int startFrame = bb.getInt();
+ int length = bb.getInt();
+
+ ArrayList frames = vm.getVMFrames(thread, startFrame, length);
+ os.writeInt(frames.size());
+ for (int i = 0; i < frames.size(); i++)
+ {
+ VMFrame frame = (VMFrame) frames.get(i);
+ os.writeLong(frame.getId());
+ Location loc = frame.getLocation();
+ loc.write(os);
+ }
+ }
+
+ private void executeFrameCount(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+
+ int frameCount = vm.getFrameCount(thread);
+ os.writeInt(frameCount);
+ }
+
+ private void executeOwnedMonitors(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException(
+ "Command OwnedMonitors not implemented.");
+ }
+
+ private void executeCurrentContendedMonitor(ByteBuffer bb,
+ DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException(
+ "Command CurrentContentedMonitors not implemented.");
+ }
+
+ private void executeStop(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ ObjectId exception = idMan.readId(bb);
+ vm.stopThread(thread, (Exception) exception.getObject());
+ }
+
+ private void executeInterrupt(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ thread.interrupt();
+ }
+
+ private void executeSuspendCount(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readId(bb);
+ Thread thread = (Thread) tid.getObject();
+ int suspendCount = vm.getSuspendCount(thread);
+ os.writeInt(suspendCount);
+ }
+}
diff --git a/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java b/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
index 32b987817..938e1e060 100644
--- a/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
+++ b/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
@@ -144,9 +144,9 @@ public class VirtualMachineCommandSet implements CommandSet
case JdwpConstants.CommandSet.VirtualMachine.ALL_CLASSES_WITH_GENERIC:
executeAllClassesWithGeneric(bb, os);
break;
-
default:
- break;
+ throw new NotImplementedException("Command " + command +
+ " not found in VirtualMachine Command Set.");
}
}
catch (IOException ex)
@@ -246,7 +246,7 @@ public class VirtualMachineCommandSet implements CommandSet
int numThreads = root.activeCount();
Thread allThreads[] = new Thread[numThreads];
- root.enumerate(allThreads, true);
+ root.enumerate(allThreads);
// We need to loop through for the true count since some threads may have
// been destroyed since we got
diff --git a/gnu/classpath/jdwp/util/LineTable.java b/gnu/classpath/jdwp/util/LineTable.java
new file mode 100644
index 000000000..90d460ff3
--- /dev/null
+++ b/gnu/classpath/jdwp/util/LineTable.java
@@ -0,0 +1,96 @@
+/* LineTable.java -- A class representing a Line Table for a method
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Line Table for a method.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class LineTable
+{
+
+ private final long start;
+ private final long end;
+ private final int[] lineNum;
+ private final long[] lineCI;
+ private final int lines;
+
+ /**
+ * Construct a line table with the given parameters.
+ *
+ * @param start lowest code index for method, -1 if native
+ * @param end highest code index for method, -1 if native
+ * @param lines number of entries in line table
+ * @param lineCI code indexes for entries in line tables (of length lines)
+ * @param lineNum line numbers for in line tables (of length lines)
+ */
+ public LineTable(long start, long end, int lines, long lineCI[],
+ int lineNum[])
+ {
+ this.start = start;
+ this.end = end;
+ this.lines = lines;
+ this.lineCI = lineCI;
+ this.lineNum = lineNum;
+ }
+
+ /**
+ * Writes this line table to the given DataOutputStream.
+ *
+ * @param os the stream to write it to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeLong(start);
+ os.writeLong(end);
+ os.writeInt(lines);
+ for (int i = 0; i < lines; i++)
+ {
+ os.writeLong(lineCI[i]);
+ os.writeInt(lineNum[i]);
+ }
+ }
+}
diff --git a/gnu/classpath/jdwp/util/Location.java b/gnu/classpath/jdwp/util/Location.java
new file mode 100644
index 000000000..1c13c5eb6
--- /dev/null
+++ b/gnu/classpath/jdwp/util/Location.java
@@ -0,0 +1,116 @@
+/* Location.java -- class to read/write JDWP locations
+ Copyright (C) 2005 Free Software Foundation
+
+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.jdwp.util;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to read/write JDWP locations.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class Location
+{
+
+ private ClassReferenceTypeId crti;
+
+ private int index;
+
+ private byte tag;
+
+ private ObjectId mid;
+
+ /**
+ * Create a location with the given parameters.
+ *
+ * @param tag the type of construct the location is in
+ * @param clazz the class the location is in
+ * @param meth the Method
+ * @param index location in the method
+ * @throws JdwpException
+ */
+ public Location(byte tag, Class clazz, Method meth, int index)
+ throws JdwpException
+ {
+ this.tag = tag;
+ this.crti =
+ (ClassReferenceTypeId) Jdwp.getIdManager().getReferenceTypeId(clazz);
+ this.mid = Jdwp.getIdManager().getId(meth);
+ this.index = index;
+ }
+
+ /**
+ * Read a location from the given bytebuffer, consists of a TAG (byte),
+ * followed by a ReferenceTypeId, a MethodId and an index (int).
+ *
+ * @param bb this holds the location
+ * @throws IOException
+ * @throws JdwpException
+ */
+ public Location(ByteBuffer bb) throws IOException, JdwpException
+ {
+ this.tag = bb.get();
+ this.crti =
+ (ClassReferenceTypeId) Jdwp.getIdManager().readReferenceTypeId(bb);
+ this.mid = Jdwp.getIdManager().readId(bb);
+ this.index = bb.getInt();
+ }
+
+ /**
+ * Write the given location to an output stream.
+ *
+ * @param os stream to write to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os) throws IOException
+ {
+ os.writeByte(tag);
+ crti.write(os);
+ mid.write(os);
+ os.writeInt(index);
+ }
+}
diff --git a/gnu/classpath/jdwp/util/MethodResult.java b/gnu/classpath/jdwp/util/MethodResult.java
new file mode 100644
index 000000000..fd1d5cac4
--- /dev/null
+++ b/gnu/classpath/jdwp/util/MethodResult.java
@@ -0,0 +1,76 @@
+/* MethodResult.java -- class to wrap around values returned from a Method call
+ in the VM
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.util;
+
+/**
+ * A class to wrap around values returned from a Method call in the VM.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class MethodResult
+{
+ // The Object returned by the executing method
+ private Object returnedValue;
+
+ // Any Exception that was thrown by the executing method
+ private Exception thrownException;
+
+ public Object getReturnedValue()
+ {
+ return returnedValue;
+ }
+
+ public void setReturnedValue(Object returnedValue)
+ {
+ this.returnedValue = returnedValue;
+ }
+
+ public Exception getThrownException()
+ {
+ return thrownException;
+ }
+
+ public void setThrownException(Exception thrownException)
+ {
+ this.thrownException = thrownException;
+ }
+
+}
diff --git a/gnu/classpath/jdwp/util/Value.java b/gnu/classpath/jdwp/util/Value.java
index de7194dc7..a4bd9b946 100644
--- a/gnu/classpath/jdwp/util/Value.java
+++ b/gnu/classpath/jdwp/util/Value.java
@@ -43,6 +43,7 @@ import gnu.classpath.jdwp.JdwpConstants;
import gnu.classpath.jdwp.exception.InvalidFieldException;
import gnu.classpath.jdwp.exception.JdwpException;
import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
import gnu.classpath.jdwp.id.ObjectId;
import java.io.DataOutputStream;
@@ -65,7 +66,7 @@ public class Value
* @throws InvalidFieldException
*/
public static void writeUntaggedValue(DataOutputStream os, Object obj)
- throws InvalidFieldException, IOException
+ throws JdwpException, IOException
{
writeValue(os, obj, false);
}
@@ -79,7 +80,7 @@ public class Value
* @throws InvalidFieldException
*/
public static void writeTaggedValue(DataOutputStream os, Object obj)
- throws InvalidFieldException, IOException
+ throws JdwpException, IOException
{
writeValue(os, obj, true);
}
@@ -96,7 +97,7 @@ public class Value
*/
private static void writeValue(DataOutputStream os, Object obj,
boolean tagged)
- throws IOException, InvalidFieldException
+ throws IOException, JdwpException
{
Class clazz = obj.getClass();
if (clazz.isPrimitive())
@@ -156,7 +157,8 @@ public class Value
}
else
{ // This shouldn't be possible
- throw new InvalidFieldException("Field has invalid primitive!");
+ throw new JdwpInternalErrorException(
+ "Field has invalid primitive!");
}
}
else
@@ -235,7 +237,8 @@ public class Value
return new byte[0];
else
{ // This shouldn't be possible
- throw new InvalidFieldException("Field has invalid primitive!");
+ throw new JdwpInternalErrorException(
+ "Field has invalid primitive!");
}
}
else
@@ -291,7 +294,8 @@ public class Value
ObjectId oid = Jdwp.getIdManager().readId(bb);
return oid.getObject();
default:
- throw new JdwpInternalErrorException("Could not find TAG:" + tag);
+ throw new NotImplementedException("Tag " + tag
+ + " is not implemented.");
}
}
}
diff --git a/gnu/classpath/jdwp/util/VariableTable.java b/gnu/classpath/jdwp/util/VariableTable.java
new file mode 100644
index 000000000..3fb3bba90
--- /dev/null
+++ b/gnu/classpath/jdwp/util/VariableTable.java
@@ -0,0 +1,110 @@
+/* VariableTable.java -- A class representing a Variable Table for a method
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Variable Table for a method.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class VariableTable
+{
+
+ private final long argCnt;
+
+ private final long slots;
+
+ private final long[] lineCI;
+
+ private int[] slot;
+
+ private int[] lengths;
+
+ private String[] sigs;
+
+ private String[] names;
+
+ /**
+ * Make a new variable table with the given values.
+ *
+ * @param argCnt number of words used by arguments in this frame
+ * @param slots number of variables
+ * @param lineCI first code index of given variable (size slots)
+ * @param names name of given variable (size slots)
+ * @param sigs signature of given variable (size slots)
+ * @param lengths size of region where variable is active (size slots)
+ * @param slot index of variable in this frame (size slots)
+ */
+ public VariableTable(int argCnt, int slots, long lineCI[], String names[],
+ String sigs[], int lengths[], int slot[])
+ {
+ this.argCnt = argCnt;
+ this.slots = slots;
+ this.lineCI = lineCI;
+ this.names = names;
+ this.sigs = sigs;
+ this.lengths = lengths;
+ this.slot = slot;
+ }
+
+ /**
+ * Writes this line table to the given DataOutputStream.
+ *
+ * @param os the stream to write it to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os) throws IOException
+ {
+ os.writeLong(argCnt);
+ os.writeLong(slots);
+ for (int i = 0; i < slots; i++)
+ {
+ os.writeLong(lineCI[i]);
+ JdwpString.writeString(os, names[i]);
+ JdwpString.writeString(os, sigs[i]);
+ os.writeInt(lengths[i]);
+ os.writeInt(slot[i]);
+ }
+ }
+
+}
diff --git a/gnu/java/awt/ClasspathToolkit.java b/gnu/java/awt/ClasspathToolkit.java
index 5fb444f98..1d25cc1da 100644
--- a/gnu/java/awt/ClasspathToolkit.java
+++ b/gnu/java/awt/ClasspathToolkit.java
@@ -92,14 +92,6 @@ public abstract class ClasspathToolkit
extends Toolkit
{
/**
- * A map from URLs to previously loaded images, used by {@link
- * #getImage(java.net.URL)}. For images that were loaded via a path
- * to an image file, the map contains a key with a file URL.
- */
- private HashMap imageCache;
-
-
- /**
* Returns a shared instance of the local, platform-specific
* graphics environment.
*
@@ -109,59 +101,6 @@ public abstract class ClasspathToolkit
*/
public abstract GraphicsEnvironment getLocalGraphicsEnvironment();
-
- /**
- * Determines the current size of the default, primary screen.
- *
- * @throws HeadlessException if the local graphics environment is
- * headless, which means that no screen is attached and no user
- * interaction is allowed.
- */
- public Dimension getScreenSize()
- {
- DisplayMode mode;
-
- // getDefaultScreenDevice throws HeadlessException if the
- // local graphics environment is headless.
- mode = GraphicsEnvironment.getLocalGraphicsEnvironment()
- .getDefaultScreenDevice().getDisplayMode();
-
- return new Dimension(mode.getWidth(), mode.getHeight());
- }
-
-
- /**
- * Determines the current color model of the default, primary
- * screen.
- *
- * @see GraphicsEnvironment#getDefaultScreenDevice()
- * @see java.awt.GraphicsDevice#getDefaultConfiguration()
- * @see java.awt.GraphicsConfiguration#getColorModel()
- *
- * @throws HeadlessException if the local graphics environment is
- * headless, which means that no screen is attached and no user
- * interaction is allowed.
- */
- public ColorModel getColorModel()
- {
- // getDefaultScreenDevice throws HeadlessException if the
- // local graphics environment is headless.
- return GraphicsEnvironment.getLocalGraphicsEnvironment()
- .getDefaultScreenDevice().getDefaultConfiguration()
- .getColorModel();
- }
-
- /**
- * Retrieves the metrics for rendering a font on the screen.
- *
- * @param font the font whose metrics are requested.
- */
- public FontMetrics getFontMetrics(Font font)
- {
- return ((ClasspathFontPeer) font.getPeer ()).getFontMetrics (font);
- }
-
-
/**
* Acquires an appropriate {@link ClasspathFontPeer}, for use in
* classpath's implementation of {@link java.awt.Font}.
@@ -185,8 +124,8 @@ public abstract class ClasspathToolkit
* Creates a {@link Font}, in a platform-specific manner.
*
* The default implementation simply constructs a {@link Font}, but some
- * toolkits may wish to override this, to return {@link Font} subclasses which
- * implement {@link java.awt.font.OpenType} or
+ * toolkits may wish to override this, to return {@link Font} subclasses
+ * which implement {@link java.awt.font.OpenType} or
* {@link java.awt.font.MultipleMaster}.
*/
public Font getFont (String name, Map attrs)
@@ -194,7 +133,6 @@ public abstract class ClasspathToolkit
return new Font (name, attrs);
}
-
/**
* Creates a font, reading the glyph definitions from a stream.
*
@@ -223,137 +161,6 @@ public abstract class ClasspathToolkit
*/
public abstract Font createFont(int format, InputStream stream);
-
- /**
- * Returns an image from the specified file, which must be in a
- * recognized format. The set of recognized image formats may vary
- * from toolkit to toolkit.
- *
- * <p>This method maintains a cache for images. If an image has been
- * loaded from the same path before, the cached copy will be
- * returned. The implementation may hold cached copies for an
- * indefinite time, which can consume substantial resources with
- * large images. Users are therefore advised to use {@link
- * #createImage(java.lang.String)} instead.
- *
- * <p>The default implementation creates a file URL for the
- * specified path and invokes {@link #getImage(URL)}.
- *
- * @param path A path to the image file.
- *
- * @return IllegalArgumentException if <code>path</code> does not
- * designate a valid path.
- */
- public Image getImage(String path)
- {
- try
- {
- return getImage(new File(path).toURL());
- }
- catch (MalformedURLException muex)
- {
- throw (IllegalArgumentException) new IllegalArgumentException(path)
- .initCause(muex);
- }
- }
-
-
- /**
- * Loads an image from the specified URL. The image data must be in
- * a recognized format. The set of recognized image formats may vary
- * from toolkit to toolkit.
- *
- * <p>This method maintains a cache for images. If an image has been
- * loaded from the same URL before, the cached copy will be
- * returned. The implementation may hold cached copies for an
- * indefinite time, which can consume substantial resources with
- * large images. Users are therefore advised to use {@link
- * #createImage(java.net.URL)} instead.
- *
- * @param url the URL from where the image is read.
- */
- public Image getImage(URL url)
- {
- Image result;
-
- synchronized (this)
- {
- // Many applications never call getImage. Therefore, we lazily
- // create the image cache when it is actually needed.
- if (imageCache == null)
- imageCache = new HashMap();
- else
- {
- result = (Image) imageCache.get(url);
- if (result != null)
- return result;
- }
-
- // The createImage(URL) method, which is specified by
- // java.awt.Toolkit, is not implemented by this abstract class
- // because it is platform-dependent. Once Classpath has support
- // for the javax.imageio package, it might be worth considering
- // that toolkits provide native stream readers. Then, the class
- // ClasspathToolkit could provide a general implementation that
- // delegates the image format parsing to javax.imageio.
- result = createImage(url);
-
- // It is not clear whether it would be a good idea to use weak
- // references here. The advantage would be reduced memory
- // consumption, since loaded images would not be kept
- // forever. But on VMs that frequently perform garbage
- // collection (which includes VMs with a parallel or incremental
- // collector), the image might frequently need to be re-loaded,
- // possibly over a slow network connection.
- imageCache.put(url, result);
-
- return result;
- }
- }
-
-
- /**
- * Returns an image from the specified file, which must be in a
- * recognized format. The set of recognized image formats may vary
- * from toolkit to toolkit.
- *
- * <p>A new image is created every time this method gets called,
- * even if the same path has been passed before.
- *
- * <p>The default implementation creates a file URL for the
- * specified path and invokes {@link #createImage(URL)}.
- *
- * @param path A path to the file to be read in.
- */
- public Image createImage(String path)
- {
- try
- {
- // The abstract method createImage(URL) is defined by
- // java.awt.Toolkit, but intentionally not implemented by
- // ClasspathToolkit because it is platform specific.
- return createImage(new File(path).toURL());
- }
- catch (MalformedURLException muex)
- {
- throw (IllegalArgumentException) new IllegalArgumentException(path)
- .initCause(muex);
- }
- }
-
- /**
- * Creates an ImageProducer from the specified URL. The image is assumed
- * to be in a recognised format. If the toolkit does not implement the
- * image format or the image format is not recognised, null is returned.
- * This default implementation is overriden by the Toolkit implementations.
- *
- * @param url URL to read image data from.
- */
- public ImageProducer createImageProducer(URL url)
- {
- return null;
- }
-
public abstract RobotPeer createRobot (GraphicsDevice screen)
throws AWTException;
@@ -365,15 +172,8 @@ public abstract class ClasspathToolkit
*/
public abstract EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w);
- /**
- * Used to register ImageIO SPIs provided by the toolkit.
- */
-
- public void registerImageIOSpis(IIORegistry reg)
- {
- }
-
public abstract boolean nativeQueueEmpty();
public abstract void wakeNativeQueue();
public abstract void iterateNativeQueue(EventQueue locked, boolean block);
}
+
diff --git a/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
index ab5df9f46..a8b746ce2 100644
--- a/gnu/java/awt/peer/gtk/GtkButtonPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
@@ -46,6 +46,9 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.peer.ButtonPeer;
+// A composite widget. GtkButtons have transparent backgrounds. An
+// AWT Button is opaque. To compensate, a GtkButtonPeer is a
+// GtkButton packed in a GtkEventBox.
public class GtkButtonPeer extends GtkComponentPeer
implements ButtonPeer
{
@@ -61,6 +64,11 @@ public class GtkButtonPeer extends GtkComponentPeer
native void gtkWidgetRequestFocus ();
native void setNativeBounds (int x, int y, int width, int height);
+ // Because this is a composite widget, we need to retrieve the
+ // GtkButton's preferred dimensions, not the enclosing
+ // GtkEventBox's.
+ native void gtkWidgetGetPreferredDimensions (int[] dim);
+
public GtkButtonPeer (Button b)
{
super (b);
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index a7aea091d..e272bfafc 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -85,7 +85,7 @@ public class GtkComponentPeer extends GtkGenericPeer
boolean isInRepaint;
- Timer repaintTimer = new Timer (true);
+ static final Timer repaintTimer = new Timer (true);
/* this isEnabled differs from Component.isEnabled, in that it
knows if a parent is disabled. In that case Component.isEnabled
@@ -418,6 +418,9 @@ public class GtkComponentPeer extends GtkGenericPeer
public void setBounds (int x, int y, int width, int height)
{
+ int new_x = x;
+ int new_y = y;
+
Component parent = awtComponent.getParent ();
// Heavyweight components that are children of one or more
@@ -438,8 +441,8 @@ public class GtkComponentPeer extends GtkGenericPeer
i = ((Container) parent).getInsets ();
- x += parent.getX () + i.left;
- y += parent.getY () + i.top;
+ new_x += parent.getX () + i.left;
+ new_y += parent.getY () + i.top;
parent = parent.getParent ();
}
@@ -448,18 +451,22 @@ public class GtkComponentPeer extends GtkGenericPeer
// placing a heavyweight component in a Window.
if (parent instanceof Window && !lightweightChild)
{
- Insets insets = ((Window) parent).getInsets ();
GtkWindowPeer peer = (GtkWindowPeer) parent.getPeer ();
+ // important: we want the window peer's insets here, not the
+ // window's, since user sub-classes of Window can override
+ // getInset and we only want to correct for the frame borders,
+ // not for any user-defined inset values
+ Insets insets = peer.getInsets ();
+
int menuBarHeight = 0;
if (peer instanceof GtkFramePeer)
menuBarHeight = ((GtkFramePeer) peer).getMenuBarHeight ();
- // Convert from Java coordinates to GTK coordinates.
- setNativeBounds (x - insets.left, y - insets.top + menuBarHeight,
- width, height);
+ new_x = x - insets.left;
+ new_y = y - insets.top + menuBarHeight;
}
- else
- setNativeBounds (x, y, width, height);
+
+ setNativeBounds (new_x, new_y, width, height);
}
void setCursor ()
@@ -671,4 +678,9 @@ public class GtkComponentPeer extends GtkGenericPeer
{
backBuffer.flush();
}
+
+ public String toString ()
+ {
+ return "peer of " + awtComponent.toString();
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
index fdd5fd15f..3d099e9ca 100644
--- a/gnu/java/awt/peer/gtk/GtkLabelPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
@@ -41,6 +41,9 @@ package gnu.java.awt.peer.gtk;
import java.awt.Label;
import java.awt.peer.LabelPeer;
+// A composite widget. GtkLabels have transparent backgrounds. An
+// AWT Label is opaque. To compensate, a GtkLabelPeer is a GtkLabel
+// packed in a GtkEventBox.
public class GtkLabelPeer extends GtkComponentPeer
implements LabelPeer
{
@@ -51,6 +54,10 @@ public class GtkLabelPeer extends GtkComponentPeer
public native void setText(String text);
native void setNativeBounds (int x, int y, int width, int height);
+ // Because this is a composite widget, we need to retrieve the
+ // GtkLabel's preferred dimensions, not the enclosing GtkEventBox's.
+ native void gtkWidgetGetPreferredDimensions (int[] dim);
+
void create ()
{
Label label = (Label) awtComponent;
diff --git a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
index 79eeaf9ba..a1a1cbd6d 100644
--- a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
@@ -77,4 +77,9 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer
}
public native void delMenu(int index);
+
+ public void addMenu (Menu m)
+ {
+ // FIXME: implement
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkMenuPeer.java b/gnu/java/awt/peer/gtk/GtkMenuPeer.java
index 80332dd6a..fabcf1f09 100644
--- a/gnu/java/awt/peer/gtk/GtkMenuPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkMenuPeer.java
@@ -100,4 +100,9 @@ public class GtkMenuPeer extends GtkMenuItemPeer
}
public native void delItem(int index);
+
+ public void addSeparator()
+ {
+ // FIXME: implement
+ }
}
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 69901102f..951a7c32e 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -121,6 +121,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
portableNativeSync = 0; // false
gtkInit(portableNativeSync);
+
+ // Register ImageIO SPIs
+ GdkPixbufDecoder.registerSpis( IIORegistry.getDefaultInstance() );
}
public GtkToolkit ()
@@ -641,11 +644,6 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return new GdkRobotPeer (screen);
}
- public void registerImageIOSpis(IIORegistry reg)
- {
- GdkPixbufDecoder.registerSpis(reg);
- }
-
public native boolean nativeQueueEmpty();
public native void wakeNativeQueue();
public native void iterateNativeQueue(EventQueue locked, boolean block);
diff --git a/gnu/java/awt/peer/qt/MainQtThread.java b/gnu/java/awt/peer/qt/MainQtThread.java
new file mode 100644
index 000000000..24082f643
--- /dev/null
+++ b/gnu/java/awt/peer/qt/MainQtThread.java
@@ -0,0 +1,84 @@
+/* MainQtThread.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.java.awt.peer.qt;
+
+/**
+ * This Thread is the main Qt thread.
+ *
+ * It doesn't appear to do much here, since all custom code executed by
+ * this thread is injected into Qt's main event loop through the (native)
+ * MainThreadInterface class.
+ */
+public class MainQtThread extends Thread
+{
+ long QApplicationPointer;
+ long mainThreadInterface;
+ String theme;
+ private boolean running;
+
+ public MainQtThread( String theme )
+ {
+ this.theme = theme;
+ running = false;
+ }
+
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ /**
+ * Creates the QApplication
+ */
+ public native long init(String theme);
+
+ /**
+ * Runs the QApplication (doesn't return.)
+ */
+ public native void exec(long ptr);
+
+ public void run()
+ {
+ QApplicationPointer = init(theme);
+ running = true;
+ exec(QApplicationPointer);
+ }
+
+}
+
+
diff --git a/gnu/java/awt/peer/qt/NativeWrapper.java b/gnu/java/awt/peer/qt/NativeWrapper.java
new file mode 100644
index 000000000..706e0df6c
--- /dev/null
+++ b/gnu/java/awt/peer/qt/NativeWrapper.java
@@ -0,0 +1,43 @@
+/* NativeWrapper.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.java.awt.peer.qt;
+
+public class NativeWrapper
+{
+ protected long nativeObject;
+}
diff --git a/gnu/java/awt/peer/qt/QMatrix.java b/gnu/java/awt/peer/qt/QMatrix.java
new file mode 100644
index 000000000..428cda173
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QMatrix.java
@@ -0,0 +1,73 @@
+/* QMatrix.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.java.awt.peer.qt;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * A simple wrapper class for a QMatrix,
+ * interfacing it to an AffineTransform.
+ */
+public class QMatrix extends NativeWrapper
+{
+
+ public QMatrix( AffineTransform t )
+ {
+ double[] matrix = new double[6];
+ t.getMatrix( matrix );
+ init( matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] );
+ }
+
+ private native void init(double m00, double m10, double m01, double m11,
+ double m02, double m12 );
+
+ private native double[] getMatrix();
+
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( getMatrix() );
+ }
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QPainterPath.java b/gnu/java/awt/peer/qt/QPainterPath.java
new file mode 100644
index 000000000..8d176a156
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QPainterPath.java
@@ -0,0 +1,141 @@
+/* QPainterPath.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.java.awt.peer.qt;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.GeneralPath;
+
+/**
+ * A simple wrapper class for a QPainterPath,
+ * createable from an AWT Shape
+ */
+public class QPainterPath extends NativeWrapper
+{
+ QPainterPath()
+ {
+ }
+
+ public QPainterPath( Shape s )
+ {
+ PathIterator pi = s.getPathIterator( new AffineTransform() );
+ double[] coords = new double[6];
+
+ init( pi.getWindingRule() );
+
+ while( !pi.isDone() )
+ {
+ switch( pi.currentSegment(coords) )
+ {
+ case PathIterator.SEG_MOVETO:
+ moveTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ close();
+ break;
+
+ case PathIterator.SEG_LINETO:
+ lineTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_QUADTO:
+ quadTo( coords[0], coords[1], coords[2], coords[3] );
+ break;
+
+ case PathIterator.SEG_CUBICTO:
+ cubicTo( coords[0], coords[1],
+ coords[2], coords[3],
+ coords[4], coords[5] );
+ break;
+ }
+ pi.next();
+ }
+ }
+
+ /**
+ * Constructor for rectangles.
+ */
+ public QPainterPath( double x, double y, double w, double h )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x, y );
+ lineTo( x + w, y );
+ lineTo( x + w, y + h );
+ lineTo( x , y + h );
+ lineTo( x, y );
+ close();
+ }
+
+ /**
+ * Constructor for lines.
+ */
+ public QPainterPath( double x1, double y1, double x2, double y2, boolean s )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x1, y1 );
+ lineTo( x2, y2 );
+ }
+
+ /**
+ * Returns the QPainterPath as a GeneralPath
+ */
+ public native GeneralPath getPath();
+
+ private native void init(int windingRule);
+
+ private native void moveTo(double x, double y);
+
+ private native void close();
+
+ private native void lineTo(double x, double y);
+
+ private native void quadTo(double x1, double y1, double x2, double y2);
+
+ private native void cubicTo(double x1, double y1, double x2, double y2,
+ double x3, double y3);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QPen.java b/gnu/java/awt/peer/qt/QPen.java
new file mode 100644
index 000000000..ec41015ed
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QPen.java
@@ -0,0 +1,71 @@
+/* QPen.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.java.awt.peer.qt;
+
+import java.awt.Stroke;
+import java.awt.BasicStroke;
+
+/**
+ * A simple wrapper class for a QPen,
+ * interfacing it to an BasicStroke.
+ */
+public class QPen extends NativeWrapper
+{
+
+ public QPen( Stroke stroke )
+ {
+ if( !( stroke instanceof BasicStroke ) )
+ throw new IllegalArgumentException("Not a basic stroke.");
+
+ BasicStroke s = (BasicStroke)stroke;
+ if(s.getDashArray() != null)
+ throw new IllegalArgumentException("Can't handle dashed strokes.");
+
+ init(s.getLineWidth(), s.getEndCap(), s.getLineJoin(), s.getMiterLimit());
+ }
+
+ private native void init(double width, int cap, int join, double miterlimit);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QtAudioClip.java b/gnu/java/awt/peer/qt/QtAudioClip.java
new file mode 100644
index 000000000..8d2ec5706
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtAudioClip.java
@@ -0,0 +1,104 @@
+/* QtAudioClip.java -- Qt implementation of the applet AudioClip interface
+ 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.java.awt.peer.qt;
+
+import java.applet.AudioClip;
+import java.io.File;
+import java.io.IOException;
+import java.awt.Toolkit;
+
+/**
+ * Implementation of the applet AudioClip interface on a Qt
+ * QSound object.
+ */
+public class QtAudioClip extends NativeWrapper implements AudioClip
+{
+ private static Toolkit t = null;
+
+ public QtAudioClip(String filename)
+ {
+ checkForQt();
+ File f = new File(filename);
+ try
+ {
+ String fn = f.getCanonicalPath();
+ loadClip( fn );
+ }
+ catch(IOException e)
+ {
+ }
+ }
+
+ private native void loadClip(String filename);
+
+ private native void play(boolean looped);
+
+ private native boolean isAvailable();
+
+ /**
+ * Checks that Qt and sound is available.
+ */
+ private void checkForQt()
+ {
+ if( t == null )
+ t = Toolkit.getDefaultToolkit();
+ if( !( t instanceof QtToolkit) )
+ throw new IllegalStateException("This requires Qt peers.");
+ }
+
+ // *************** Public methods *******************
+
+ public void loop()
+ {
+ play( true );
+ }
+
+ public void play()
+ {
+ play( false );
+ }
+
+ public native void stop();
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtButtonPeer.java b/gnu/java/awt/peer/qt/QtButtonPeer.java
new file mode 100644
index 000000000..3dd607b19
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtButtonPeer.java
@@ -0,0 +1,79 @@
+/* QtButtonPeer.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.java.awt.peer.qt;
+
+import java.awt.Button;
+import java.awt.event.ActionEvent;
+import java.awt.peer.ButtonPeer;
+
+public class QtButtonPeer extends QtComponentPeer implements ButtonPeer
+{
+ public QtButtonPeer( QtToolkit kit, Button owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setLabel( ((Button)owner).getLabel() );
+ }
+
+ /**
+ * Callback for button click events
+ */
+ void fireClick(int modifiers)
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Button)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF));
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLabel( String label );
+}
+
+
+
+
diff --git a/gnu/java/awt/peer/qt/QtCanvasPeer.java b/gnu/java/awt/peer/qt/QtCanvasPeer.java
new file mode 100644
index 000000000..2367cd066
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtCanvasPeer.java
@@ -0,0 +1,65 @@
+/* QtCanvasPeer.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.java.awt.peer.qt;
+
+import java.awt.Canvas;
+import java.awt.Dimension;
+import java.awt.peer.CanvasPeer;
+
+public class QtCanvasPeer extends QtComponentPeer implements CanvasPeer
+{
+ public QtCanvasPeer( QtToolkit kit, Canvas owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ /**
+ * Overloaded, because a Canvas doesn't have a preferred size.
+ */
+ public Dimension getPreferredSize()
+ {
+ return owner.getSize();
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtCheckboxPeer.java b/gnu/java/awt/peer/qt/QtCheckboxPeer.java
new file mode 100644
index 000000000..788e08ee1
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtCheckboxPeer.java
@@ -0,0 +1,114 @@
+/* QtCheckboxPeer.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.java.awt.peer.qt;
+
+import java.awt.Rectangle;
+import java.awt.Checkbox;
+import java.awt.CheckboxGroup;
+import java.awt.event.ItemEvent;
+import java.awt.peer.CheckboxPeer;
+import java.util.WeakHashMap;
+
+public class QtCheckboxPeer extends QtComponentPeer implements CheckboxPeer
+{
+ private CheckboxGroup group;
+
+ // Map QButtonGroup<->CheckboxGroup
+ private static WeakHashMap groupMap;
+
+ static
+ {
+ groupMap = new WeakHashMap();
+ }
+
+ public QtCheckboxPeer( QtToolkit kit, Checkbox owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setCheckboxGroup( ((Checkbox)owner).getCheckboxGroup() );
+ setLabel( ((Checkbox)owner).getLabel() );
+ setState( ((Checkbox)owner).getState() );
+ }
+
+ private void fireToggle(boolean checked)
+ {
+ if (group == null)
+ ((Checkbox)owner).setState( checked );
+ else
+ if ( checked )
+ group.setSelectedCheckbox((Checkbox)owner);
+
+ int sel = checked ? ItemEvent.SELECTED : ItemEvent.DESELECTED;
+ ItemEvent e = new ItemEvent((Checkbox)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Checkbox)owner).getLabel(),
+ sel);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void setCheckboxGroup( CheckboxGroup group )
+ {
+ if(this.group == group)
+ return;
+
+ // if we change from a checkbox to a radio button or vice versa
+ if((this.group == null) != (group == null))
+ {
+ this.group = group;
+ callInit();
+ setup();
+ }
+
+ this.group = group;
+ }
+
+ public native void setLabel( String label );
+
+ public native void setState( boolean state );
+
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtChoicePeer.java b/gnu/java/awt/peer/qt/QtChoicePeer.java
new file mode 100644
index 000000000..30674b36e
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtChoicePeer.java
@@ -0,0 +1,95 @@
+/* QtChoicePeer.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.java.awt.peer.qt;
+
+import java.awt.Choice;
+import java.awt.event.ItemEvent;
+import java.awt.peer.ChoicePeer;
+
+public class QtChoicePeer extends QtComponentPeer implements ChoicePeer
+{
+ public QtChoicePeer( QtToolkit kit, Choice owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+
+ Choice c = (Choice) owner;
+ int n = c.getItemCount();
+ for ( int i = 0; i < n ; i++ )
+ add( c.getItem( i ), i );
+ select( c.getSelectedIndex() );
+ }
+
+ private void fireChoice( int index )
+ {
+ ((Choice)owner).select( index );
+ ItemEvent e = new ItemEvent((Choice)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Choice)owner).getItem(index),
+ ItemEvent.SELECTED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void add( String item, int index );
+
+ public void addItem( String item, int index )
+ {
+ add(item, index);
+ }
+
+ public native void remove( int index );
+
+ public void removeAll()
+ {
+ int n = ((Choice)owner).getItemCount();
+ for (int i = 0; i < n; i++)
+ remove( i );
+ }
+
+ public native void select( int index );
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtComponentGraphics.java b/gnu/java/awt/peer/qt/QtComponentGraphics.java
new file mode 100644
index 000000000..4f3803dc6
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtComponentGraphics.java
@@ -0,0 +1,125 @@
+/* QtComponentGraphics.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.java.awt.peer.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Paint;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting directly to AWT
+ * components. They require an existing QPainter object (the one passed into
+ * the native paint method), and are created there (ONLY).
+ *
+ * Since this context does direct on-screen drawing it is NOT thread-safe,
+ * and should NOT be used outside the thread in which it was created.
+ *
+ * In other words,
+ * this is intended for use by QtComponentPeer.paintEvent() only.
+ *
+ */
+public class QtComponentGraphics extends QtGraphics
+{
+ private QtComponentPeer peer;
+
+ /**
+ * Creates a new ComponentGraphics from an *existing* QPainter object.
+ *
+ * @param ptr the pointer to the QPainter object.
+ */
+ public QtComponentGraphics(long ptr, QtComponentPeer component)
+ {
+ nativeObject = ptr;
+ peer = component;
+
+ Rectangle r = component.owner.getBounds();
+ r.setLocation(0, 0);
+ initialClip = r;
+
+ currentAlpha = 1.0;
+ Color c = component.owner.getBackground();
+ if(c == null)
+ setBackground(Color.white);
+ else
+ setBackground( c );
+
+ c = component.owner.getForeground();
+ if(c == null)
+ setColor( Color.black );
+ else
+ setColor( c );
+
+ setup();
+ setClip( initialClip );
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtComponentGraphics( QtComponentGraphics g )
+ {
+ super( g ); // Slalom is fun
+ }
+
+ public Graphics create()
+ {
+ return new QtComponentGraphics( this );
+ }
+
+ /**
+ * This is a tricky one
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ // FIXME
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ return peer.getGraphicsConfiguration();
+ }
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtComponentPeer.java b/gnu/java/awt/peer/qt/QtComponentPeer.java
new file mode 100644
index 000000000..bfebdfdd4
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtComponentPeer.java
@@ -0,0 +1,714 @@
+/* QtComponentPeer.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.java.awt.peer.qt;
+
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Image;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.peer.ComponentPeer;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.event.ComponentEvent; // 100%
+import java.awt.event.FocusEvent; // 100%
+import java.awt.event.InputEvent; // (abstract)
+import java.awt.event.KeyEvent; // 2/3
+import java.awt.event.MouseEvent; // 70%?
+import java.awt.event.PaintEvent; // Yup.
+import java.awt.event.WindowEvent; // 2/ 12
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class QtComponentPeer extends NativeWrapper implements ComponentPeer
+{
+
+ /**
+ * Popup trigger button, may differ between platforms
+ */
+ protected static final int POPUP_TRIGGER = 3;
+
+ /**
+ * The toolkit which manufactured this peer.
+ */
+ protected QtToolkit toolkit;
+
+ /**
+ * The component which owns this peer.
+ */
+ Component owner;
+
+ /**
+ * Timestamp of last MouseMotionEvent.
+ */
+ private long lastMME;
+
+ /**
+ * Classpath updates our eventMask.
+ */
+ private long eventMask;
+
+ /**
+ * if the thing has mouse motion listeners or not.
+ */
+ private boolean hasMotionListeners;
+
+ /**
+ * The component's double buffer for off-screen drawing.
+ */
+ private QtImage backBuffer;
+
+ /**
+ * Stores if the backBuffer is dirty or not
+ */
+ private boolean dirtyBackBuffer;
+
+ protected long qtApp;
+
+ private boolean settingUp;
+
+ QtComponentPeer( QtToolkit kit, Component owner )
+ {
+ this.owner = owner;
+ this.toolkit = kit;
+ qtApp = QtToolkit.guiThread.QApplicationPointer;
+ nativeObject = 0;
+ callInit(); // Calls the init method FROM THE MAIN THREAD.
+ setup();
+ hasMotionListeners = false;
+ }
+
+ protected native void callInit();
+
+ /**
+ * Init does the creation of native widgets, it is therefore
+ * called from the main thread. (the constructor waits for this to happen.)
+ */
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ settingUp = true;
+ if (owner != null)
+ {
+// if (owner.getBackground() != null)
+// setBackground(owner.getBackground());
+// else
+ owner.setBackground(getNativeBackground());
+
+ if (owner.getForeground() != null)
+ setForeground(owner.getForeground());
+ else
+ setForeground( Color.black );
+
+ if (owner.getCursor() != null)
+ if (owner.getCursor().getType() != Cursor.DEFAULT_CURSOR)
+ setCursor(owner.getCursor());
+
+ if (owner.getFont() != null)
+ setFont(owner.getFont());
+
+ setEnabled( owner.isEnabled() );
+ setVisible( owner.isVisible() );
+
+ Rectangle r = owner.getBounds();
+ setBounds( r.x, r.y, r.width, r.height );
+ if( drawableComponent() )
+ backBuffer = new QtImage( r.width, r.height );
+ else
+ backBuffer = null;
+ dirtyBackBuffer = true;
+ }
+ settingUp = false;
+ }
+
+ native void QtUpdate();
+ native void QtUpdateArea(int x, int y, int w, int h);
+ private synchronized native void disposeNative();
+ private native void setGround(int r, int g, int b, boolean isForeground);
+ private native void setBoundsNative(int x, int y, int width, int height);
+ private native void setCursor(int ctype);
+ private native Color getNativeBackground();
+ private native void setFontNative(QtFontPeer fp);
+ private native int whichScreen();
+
+ private boolean drawableComponent()
+ {
+ return ((this instanceof QtContainerPeer &&
+ !(this instanceof QtScrollPanePeer)) ||
+ (this instanceof QtCanvasPeer));
+ }
+
+ // ************ Event methods *********************
+
+ /**
+ * Window closing event
+ */
+ protected void closeEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_CLOSING);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void enterEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_ENTERED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusInEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_GAINED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusOutEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_LOST);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyPressEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_PRESSED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ if (!manager.dispatchEvent (e))
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyReleaseEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_RELEASED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void leaveEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_EXITED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // FIXME: Coalesce press-release events into clicks.
+ protected void mouseDoubleClickEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_CLICKED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseMoveEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+
+ long timeStamp = System.currentTimeMillis();
+ if( timeStamp - lastMME > 100 )
+ hasMotionListeners = (owner.getMouseMotionListeners().length > 0);
+ if( hasMotionListeners )
+ {
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_MOVED,
+ timeStamp,
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ lastMME = timeStamp;
+ }
+
+ protected void mousePressEvent( int modifiers, int x, int y, int clickCount)
+ {
+ // if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ // return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_PRESSED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ ( button == POPUP_TRIGGER ),
+ button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseReleaseEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_RELEASED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void moveEvent()
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_MOVED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void paintEvent(QtGraphics g)
+ {
+ if (backBuffer != null)
+ {
+ if (dirtyBackBuffer)
+ {
+ backBuffer.clear();
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ owner.paint(bbg);
+ bbg.dispose();
+ dirtyBackBuffer = false;
+ }
+ backBuffer.drawPixels(g, 0, 0, 0, 0, 0, false );
+ }
+ }
+
+ protected void resizeEvent(int oldWidth, int oldHeight,
+ int width, int height)
+ {
+ dirtyBackBuffer = true;
+ if( drawableComponent() )
+ backBuffer = new QtImage(width, height);
+ owner.setSize(width, height);
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_RESIZED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void showEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_OPENED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ else
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_SHOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void hideEvent()
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_HIDDEN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native Dimension getMinimumSizeNative();
+
+ private native Dimension getPreferredSizeNative();
+
+ // ************ Public methods *********************
+
+ /** Classpath-specific method */
+ public void setEventMask(long x)
+ {
+ eventMask = x;
+ }
+
+
+ public boolean canDetermineObscurity()
+ {
+ return true;
+ }
+
+ public int checkImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.checkImage(img, w, h, o);
+ }
+
+ public void createBuffers(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ // FIXME
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return toolkit.createImage(producer);
+ }
+
+ public Image createImage(int width, int height)
+ {
+ return new QtImage(width, height);
+ }
+
+ public void coalescePaintEvent(PaintEvent e)
+ {
+ // FIXME
+ }
+
+ public VolatileImage createVolatileImage(int w, int h)
+ {
+ return new QtVolatileImage( w, h );
+ }
+
+ public void destroyBuffers()
+ {
+ // FIXME
+ }
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void dispose()
+ {
+ disposeNative();
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void flip(BufferCapabilities.FlipContents contents)
+ {
+ // FIXME
+ }
+
+ public Image getBackBuffer()
+ {
+ return backBuffer;
+ }
+
+ public ColorModel getColorModel()
+ {
+ return toolkit.getColorModel();
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics( font, getGraphics() );
+ }
+
+ public Graphics getGraphics()
+ {
+ if( backBuffer == null)
+ {
+ Rectangle r = owner.getBounds();
+ backBuffer = new QtImage( r.width, r.height );
+ }
+ dirtyBackBuffer = true;
+ return backBuffer.getGraphics();
+ }
+
+ public GraphicsConfiguration getGraphicsConfiguration()
+ {
+ int id = whichScreen(); // get the ID of the screen the widget is on.
+ GraphicsDevice[] devs = QtToolkit.graphicsEnv.getScreenDevices();
+ return devs[id].getDefaultConfiguration();
+ }
+
+ public native Point getLocationOnScreen();
+
+ public Dimension getMinimumSize()
+ {
+ Dimension d = getMinimumSizeNative();
+ if(d == null)
+ return new Dimension(0, 0);
+ return d;
+ }
+
+ public Dimension getPreferredSize()
+ {
+ Dimension d = getPreferredSizeNative();
+ if(d == null)
+ return owner.getSize();
+ return d;
+ }
+
+ public Toolkit getToolkit()
+ {
+ return toolkit;
+ }
+
+ public native boolean handlesWheelScrolling();
+
+ public void hide()
+ {
+ setVisible(false);
+ }
+
+ public native boolean isFocusable();
+
+ public boolean isFocusTraversable()
+ {
+ // FIXME
+ return false;
+ }
+
+ public native boolean isObscured();
+
+ public Dimension minimumSize()
+ {
+ return getMinimumSize();
+ }
+
+ public Dimension preferredSize()
+ {
+ return getPreferredSize();
+ }
+
+ public native void requestFocus();
+
+ public boolean requestFocus (Component source, boolean bool1,
+ boolean bool2, long x)
+ {
+ // FIXME
+ return true;
+ }
+
+ public void reshape(int x,
+ int y,
+ int width,
+ int height)
+ {
+ dirtyBackBuffer = true;
+ setBounds( x, y, width, height );
+ }
+
+ public void setBackground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), false);
+ }
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ if(width > 0 && height > 0)
+ backBuffer = new QtImage(width, height);
+ setBoundsNative(x, y, width, height);
+ }
+
+ public void setCursor(Cursor cursor)
+ {
+ if (cursor != null)
+ setCursor(cursor.getType());
+ }
+
+ public native void setEnabled(boolean b);
+
+ public void setFont(Font f)
+ {
+ if( f == null || f.getPeer() == null)
+ throw new IllegalArgumentException("Null font.");
+ setFontNative( (QtFontPeer)f.getPeer() );
+ }
+
+ public void setForeground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), true);
+ }
+
+ public native void setVisible(boolean b);
+
+ public void show()
+ {
+ setVisible(true);
+ }
+
+ public void handleEvent (AWTEvent e)
+ {
+ int eventID = e.getID();
+ switch (eventID)
+ {
+ case ComponentEvent.COMPONENT_SHOWN:
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ dirtyBackBuffer = true;
+ QtUpdate();
+ break;
+ case KeyEvent.KEY_PRESSED:
+ // FIXME
+ break;
+ case KeyEvent.KEY_RELEASED:
+ // FIXME
+ break;
+ }
+ }
+
+ public void paint(Graphics g)
+ {
+ // We don't need to do anything here.
+ }
+
+ public boolean prepareImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.prepareImage(img, w, h, o);
+ }
+
+ public void print(Graphics g)
+ {
+ // FIXME
+ }
+
+ /**
+ * Schedules a timed repaint.
+ */
+ public void repaint(long tm,
+ int x,
+ int y,
+ int width,
+ int height)
+ {
+ Timer t = new Timer();
+ t.schedule(new RepaintTimerTask(x, y, width, height), tm);
+ }
+
+ /**
+ * Update the cursor (note that setCursor is usually not called)
+ */
+ public void updateCursorImmediately()
+ {
+ if (owner.getCursor() != null)
+ setCursor(owner.getCursor().getType());
+ }
+
+ /**
+ * Timed repainter
+ */
+ private class RepaintTimerTask extends TimerTask
+ {
+ private int x, y, w, h;
+ RepaintTimerTask(int x, int y, int w, int h)
+ {
+ this.x=x;
+ this.y=y;
+ this.w=w;
+ this.h=h;
+ }
+ public void run()
+ {
+ QtUpdateArea(x, y, w, h);
+ }
+ }
+
+}
diff --git a/gnu/java/awt/peer/qt/QtContainerPeer.java b/gnu/java/awt/peer/qt/QtContainerPeer.java
new file mode 100644
index 000000000..25b5c1786
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtContainerPeer.java
@@ -0,0 +1,97 @@
+/* QtContainerPeer.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.java.awt.peer.qt;
+
+import java.awt.Component;
+import java.awt.Insets;
+import java.awt.peer.ContainerPeer;
+
+public class QtContainerPeer extends QtComponentPeer implements ContainerPeer
+{
+ public QtContainerPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+ public void beginLayout()
+ {
+ }
+
+ public void beginValidate()
+ {
+ }
+
+ public void endLayout()
+ {
+ // FIXME
+ QtUpdate();
+ }
+
+ public void endValidate()
+ {
+ }
+
+ public Insets getInsets()
+ {
+ return new Insets(0, 0, 0, 0);
+ }
+
+ public Insets insets()
+ {
+ return getInsets();
+ }
+
+ public boolean isPaintPending()
+ {
+ // FIXME etc.
+ return false;
+ }
+}
+
+
+
diff --git a/gnu/java/awt/peer/qt/QtDialogPeer.java b/gnu/java/awt/peer/qt/QtDialogPeer.java
new file mode 100644
index 000000000..0da2e4ebc
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtDialogPeer.java
@@ -0,0 +1,75 @@
+/* QtDialogPeer.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.java.awt.peer.qt;
+
+import java.awt.Dialog;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+import java.awt.peer.DialogPeer;
+
+public class QtDialogPeer extends QtWindowPeer implements DialogPeer
+{
+ public QtDialogPeer( QtToolkit kit, Dialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Dialog)owner).getTitle() );
+ setResizable( ((Dialog)owner).isResizable() );
+ setModal( ((Dialog)owner).isModal() );
+ }
+
+ native void setModal(boolean modal);
+
+ private native void setBoundsNative(int x, int y, int width, int height, boolean fixed);
+
+ // ************ Public methods *********************
+
+ public native void setResizable (boolean resizeable);
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ setBoundsNative(x, y, width, height,
+ !((Dialog)owner).isResizable());
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtFileDialogPeer.java b/gnu/java/awt/peer/qt/QtFileDialogPeer.java
new file mode 100644
index 000000000..4937031aa
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtFileDialogPeer.java
@@ -0,0 +1,84 @@
+/* QtFileDialogPeer.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.java.awt.peer.qt;
+
+import java.awt.FileDialog;
+import java.io.FilenameFilter;
+import java.awt.peer.FileDialogPeer;
+
+public class QtFileDialogPeer extends QtDialogPeer implements FileDialogPeer
+{
+ public QtFileDialogPeer( QtToolkit kit, FileDialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setMode( ((FileDialog)owner).getMode() );
+ }
+
+ /**
+ * Sets load or save mode
+ */
+ private native void setMode(int mode);
+
+ private void fileDialogDone(String path, String filename)
+ {
+ }
+
+ // ************ Public methods *********************
+ public void setFile (String file)
+ {
+ // FIXME
+ }
+
+ public void setDirectory (String dir)
+ {
+ // FIXME
+ }
+
+ public void setFilenameFilter (FilenameFilter ff)
+ {
+ // FIXME
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QtFontMetrics.java b/gnu/java/awt/peer/qt/QtFontMetrics.java
new file mode 100644
index 000000000..e403239e9
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtFontMetrics.java
@@ -0,0 +1,128 @@
+/* QtFontMetrics.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.java.awt.peer.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+
+public class QtFontMetrics extends FontMetrics
+{
+
+ private long nativeObject;
+ private QtFontPeer peer;
+
+ public QtFontMetrics( Font f )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ peer = (QtFontPeer) f.getPeer();
+ init( peer );
+ }
+
+ public QtFontMetrics( Font f, Graphics g )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = (QtFontPeer) f.getPeer();
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ QtFontMetrics( QtFontPeer f, Graphics g )
+ {
+ super( null );
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = f;
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ public QtFontMetrics( QtFontPeer fp )
+ {
+ super( (Font)null );
+ peer = fp;
+ init( peer );
+ }
+
+ private native void init(QtFontPeer fp);
+
+ private native void initGraphics(QtFontPeer fp, QtGraphics g);
+
+ private native void dispose();
+
+ native Rectangle2D getStringBounds(String s);
+
+ // ****************** Package private ***************************
+
+ native boolean canDisplay( char c );
+
+ // ****************** Public methods ****************************
+
+ public native int getAscent();
+
+ public native int getDescent();
+
+ public native int getHeight();
+
+ public native int getLeading();
+
+ public native int getMaxAdvance();
+
+ public native int charWidth(char c);
+
+ public int charsWidth(char[] chars, int off, int len)
+ {
+ return stringWidth( new String(chars, off, len) );
+ }
+
+ public native int stringWidth(String str);
+
+ public Rectangle2D getStringBounds(String str, Graphics context)
+ {
+ QtFontMetrics fm = new QtFontMetrics(peer, context);
+ return fm.getStringBounds( str );
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtFontPeer.java b/gnu/java/awt/peer/qt/QtFontPeer.java
new file mode 100644
index 000000000..ce63577a8
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtFontPeer.java
@@ -0,0 +1,207 @@
+/* QtFontPeer.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.java.awt.peer.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.text.CharacterIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.awt.peer.FontPeer;
+
+import gnu.java.awt.peer.ClasspathFontPeer;
+
+public class QtFontPeer extends ClasspathFontPeer
+{
+ // Pointer to native QFont structure.
+ private long nativeObject;
+ private QtFontMetrics metrics;
+
+
+ public QtFontPeer (String name, int style)
+ {
+ this(name, style, 12);
+ }
+
+ public QtFontPeer (String name, int style, int size)
+ {
+ super(name, style, size);
+ init();
+ }
+
+ public QtFontPeer (String name, Map attributes)
+ {
+ super(name, attributes);
+ init();
+ }
+
+ public void init()
+ {
+ if(this.familyName == null)
+ throw new IllegalArgumentException("null family name");
+ if(this.familyName.equals("Helvetica"))
+ this.familyName = "sans serif";
+ create(this.familyName, this.style, (int)this.size);
+ metrics = new QtFontMetrics(this);
+ }
+
+ /**
+ * Creates the QFont object.
+ */
+ private native void create(String name, int style, int size);
+
+ /**
+ * Destroys the QFont.
+ */
+ public native void dispose();
+
+
+ // ****************** ClasspathFontPeer Methods.
+
+ public boolean canDisplay (Font font, char c)
+ {
+ return metrics.canDisplay( c );
+ }
+
+ public int canDisplayUpTo (Font font, CharacterIterator i,
+ int start, int limit)
+ {
+ int index = start;
+ char c = i.setIndex( index );
+ while( index <= limit )
+ {
+ if(!canDisplay(font, c))
+ return index;
+ index++;
+ c = i.next();
+ }
+ return -1;
+ }
+
+ public String getSubFamilyName (Font font, Locale locale)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPostScriptName (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNumGlyphs (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getMissingGlyphCode (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getBaselineFor (Font font, char c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getGlyphName (Font font, int glyphIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext frc,
+ CharacterIterator ci)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext ctx,
+ int[] glyphCodes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector layoutGlyphVector (Font font,
+ FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new QtFontMetrics( this );
+ }
+
+ public boolean hasUniformLineMetrics (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public LineMetrics getLineMetrics (Font font,
+ CharacterIterator ci,
+ int begin, int limit,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Rectangle2D getMaxCharBounds (Font font,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Rectangle2D getStringBounds (Font font,
+ CharacterIterator ci,
+ int begin, int limit,
+ FontRenderContext frc)
+ {
+ int index = begin;
+ String s = "" + ci.setIndex( index );
+ while( index++ <= limit )
+ s = s + ci.next();
+ return metrics.getStringBounds(s);
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtFramePeer.java b/gnu/java/awt/peer/qt/QtFramePeer.java
new file mode 100644
index 000000000..56f6132e5
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtFramePeer.java
@@ -0,0 +1,137 @@
+/* QtFramePeer.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.java.awt.peer.qt;
+
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+import java.awt.peer.FramePeer;
+
+public class QtFramePeer extends QtWindowPeer implements FramePeer
+{
+ private int theState; // FIXME
+
+ long frameObject;
+
+ public QtFramePeer( QtToolkit kit, Frame owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Frame)owner).getTitle() );
+ }
+
+ private native void setIcon(QtImage image);
+
+ private native void setMaximizedBounds(int w, int h);
+
+ private native void setMenu(QtMenuBarPeer mb);
+
+ private native int menuBarHeight();
+
+ // ************ Public methods *********************
+
+ public void destroy()
+ {
+ dispose();
+ }
+
+ public int getState()
+ {
+ // FIXME
+ return theState;
+ }
+
+ public Insets getInsets()
+ {
+ int mbHeight;
+ if( ((Frame)owner).getMenuBar() != null )
+ mbHeight = menuBarHeight();
+ else
+ mbHeight = 0;
+
+ // FIXME : more accurate?
+ return new Insets(0, 0, mbHeight, 0);
+ }
+
+ public void setIconImage(Image im)
+ {
+ if (im instanceof QtImage)
+ setIcon ((QtImage)im);
+ // FIXME
+ }
+
+ public void setMaximizedBounds(Rectangle rect)
+ {
+ // FIXME
+ }
+
+ public void setMenuBar(MenuBar mb)
+ {
+ if( mb != null)
+ {
+ QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer != null)
+ {
+ mbpeer.addMenus();
+ setMenu( mbpeer );
+ }
+ }
+ else
+ setMenu( null );
+ }
+
+ public void setResizable(boolean resizeable)
+ {
+ // FIXME
+ }
+
+ public void setState(int s)
+ {
+ theState = s;
+ // FIXME
+ }
+
+}
diff --git a/gnu/java/awt/peer/qt/QtGraphics.java b/gnu/java/awt/peer/qt/QtGraphics.java
new file mode 100644
index 000000000..8fada89a0
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtGraphics.java
@@ -0,0 +1,699 @@
+/* QtGraphics.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.java.awt.peer.qt;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.GradientPaint;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Rectangle;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.util.Map;
+
+/**
+ * QtGraphics is an abstract implementation of Graphics2D over a QPainter
+ * object. This is to be subclassed for different drawing contexts,
+ * which may have different requirements.
+ */
+public abstract class QtGraphics extends Graphics2D
+{
+ /**
+ * Native QPainter pointer.
+ */
+ protected long nativeObject;
+
+ private static final AffineTransform identity = new AffineTransform();
+
+ // Graphics state
+ protected Font font; // Current font.
+ protected Color color, bgcolor; // Current color and background color.
+ protected Shape clip; // Current clipping area.
+ protected Shape initialClip; // Initial clip bounds
+ protected AffineTransform xform; // Current transform
+ protected Stroke currentStroke; // the current stroke
+ protected boolean nativeStroking; // whether we're using Qt's stroking or not
+ protected Composite composite; // current composite operator
+ protected double currentAlpha; // current alpha
+ protected Paint currentPaint; // current paint
+ protected RenderingHints renderingHints; // the rendering hints.
+
+ /**
+ * Owner Graphics, used by subcontext created by create()
+ * to avoid GC of the original context.
+ */
+ Graphics parent;
+
+ /**
+ * Do-nothing constructor.
+ */
+ QtGraphics()
+ {
+ }
+
+ /**
+ * Copying constructor - used by copy() and subclasses.
+ */
+ QtGraphics(QtGraphics parent)
+ {
+ cloneNativeContext( parent );
+ setFont( parent.getFont() );
+ setAlpha( parent.currentAlpha );
+ setBackground( parent.getBackground() );
+ setColor( parent.getColor() );
+ setClip( (initialClip = parent.getClip()) );
+ setTransform( parent.getTransform() );
+ setStroke( parent.getStroke() );
+ setComposite( parent.getComposite() );
+ setPaint( parent.getPaint() );
+ setRenderingHints( parent.getRenderingHints() );
+ }
+
+ /**
+ * Set up some generic defaults.
+ */
+ protected void setup()
+ {
+ font = new Font ("Dialog", Font.PLAIN, 12);
+ setTransform( identity );
+ setStroke( new BasicStroke() );
+ renderingHints = new RenderingHints( null );
+ }
+
+ public synchronized native void delete();
+ public synchronized native void dispose();
+
+ // ********************** etc *******************************
+
+ private void resetClip()
+ {
+ AffineTransform current = getTransform();
+ setTransform( identity );
+ setClip( initialClip );
+ setTransform( current );
+ }
+
+ // NOTE: Image here must be a QImage or wrapper!
+ protected native void initImage(Image image);
+
+ // Creates a new native QPainter object on the same context.
+ private native void cloneNativeContext( QtGraphics parent );
+ private native void setColor(int r, int g, int b, int a);
+ private native void drawNative( QPainterPath p );
+ private native void fillNative( QPainterPath p );
+ private native void setClipNative( QPainterPath p );
+ private native void setClipRectNative( int x, int y, int w, int h );
+ private native void intersectClipNative( QPainterPath p );
+ private native void intersectClipRectNative( int x, int y, int w, int h );
+ private native void setQtTransform(QMatrix m);
+ private native void setNativeStroke(QPen p);
+ private native void setNativeComposite(int alphaMode);
+ private native void drawStringNative(String string, double x, double y);
+ private native void setLinearGradient(int r1, int g1, int b1,
+ int r2, int g2, int b2,
+ double x1, double y1,
+ double x2, double y2, boolean cyclic);
+ private native void setAlphaNative(double alpha);
+ private native void setFontNative(QtFontPeer font);
+ private native QPainterPath getClipNative();
+
+ private void setAlpha(double alpha)
+ {
+ currentAlpha = alpha;
+ setAlphaNative(currentAlpha);
+ }
+
+ // ************ Public methods *********************
+
+ /**
+ * Context-sensitive methods are declared abstract.
+ */
+ public abstract Graphics create();
+
+ public abstract void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ public abstract GraphicsConfiguration getDeviceConfiguration();
+
+
+ public Color getColor()
+ {
+ return new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public void setColor(Color c)
+ {
+ this.color = c;
+ int alpha = (int)(c.getAlpha() * currentAlpha);
+ setColor(c.getRed(), c.getGreen(), c.getBlue(), alpha);
+ }
+
+ public void setBackground(Color color)
+ {
+ bgcolor = new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public Color getBackground()
+ {
+ return new Color(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue());
+ }
+
+ public void setPaintMode()
+ {
+ }
+
+ public void setXORMode(Color color)
+ {
+ // FIXME
+ }
+
+ public boolean hit(Rectangle rect, Shape s, boolean onStroke)
+ {
+ if( onStroke )
+ {
+ Shape stroked = currentStroke.createStrokedShape( s );
+ return stroked.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+ return s.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+
+ // ******************* Font ***********************
+ public Font getFont()
+ {
+ return font;
+ }
+
+ public void setFont(Font font)
+ {
+ this.font = font;
+ if(font.getPeer() != null && font.getPeer() instanceof QtFontPeer)
+ setFontNative( (QtFontPeer)font.getPeer() );
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font, this);
+ }
+
+ // ***************** Clipping *********************
+
+ /**
+ * Intersects the current clip with the shape
+ */
+ public void clip(Shape s)
+ {
+ intersectClipNative( new QPainterPath( s ) );
+ }
+
+ public void clipRect(int x, int y, int width, int height)
+ {
+ intersectClipRectNative( x, y, width, height );
+ }
+
+ public void setClip(int x, int y, int width, int height)
+ {
+ setClipRectNative( x, y, width, height );
+ }
+
+ public Shape getClip()
+ {
+ return getClipNative().getPath();
+ }
+
+ public native Rectangle getClipBounds();
+
+ /**
+ * Sets the clip
+ */
+ public void setClip(Shape clip)
+ {
+ if (clip == null)
+ resetClip();
+ else
+ setClipNative(new QPainterPath( clip ));
+ }
+
+ // ***************** Drawing primitives *********************
+
+ public void draw(Shape s)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath(s) );
+ else
+ fillNative( new QPainterPath( currentStroke.createStrokedShape( s ) ) );
+ }
+
+ public void fill(Shape s)
+ {
+ fillNative( new QPainterPath(s) );
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x1, (double)y1, (double)x2, (double)y2, true) );
+ else
+ draw( new Line2D.Double((double)x1, (double)y1, (double)x2, (double)y2) );
+ }
+
+ public void drawRect(int x, int y, int width, int height)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x, (double)y,
+ (double)width, (double)height) );
+ else
+ fillNative( new QPainterPath
+ ( currentStroke.createStrokedShape
+ (new Rectangle2D.Double
+ ((double)x, (double)y,
+ (double)width, (double)height) ) ) );
+ }
+
+ public void fillRect(int x, int y, int width, int height)
+ {
+ fillNative( new QPainterPath( x, y, width, height ) );
+ }
+
+ public void clearRect(int x, int y, int width, int height)
+ {
+ Color c = color;
+ setColor( bgcolor ); // FIXME
+ fillRect( x, y, width, height );
+ setColor( c );
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ draw( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ fill( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void drawOval(int x, int y, int width, int height)
+ {
+ draw( new Ellipse2D.Double((double)x, (double)y,
+ (double)width, (double)height) );
+ }
+
+ public void fillOval(int x, int y, int width, int height)
+ {
+ fill( new Ellipse2D.Double(x, y, width, height) );
+ }
+
+ public void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ draw( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.OPEN) );
+ }
+
+ public void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ fill( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.CHORD) );
+ }
+
+ public void drawPolyline(int xPoints[], int yPoints[], int npoints)
+ {
+ for( int i = 0; i < npoints - 1; i++)
+ drawLine(xPoints[i], yPoints[i], xPoints[i + 1], yPoints[i + 1]);
+ }
+
+ public void drawPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ draw( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public void fillPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ fill( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public native void fill3DRect(int x, int y, int width, int height, boolean raised);
+
+ public native void draw3DRect(int x, int y, int width, int height, boolean raised);
+
+ // *********************** Text rendering *************************
+
+ public void drawString(String string, int x, int y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString(String string, float x, float y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString (AttributedCharacterIterator ci, int x, int y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawString(AttributedCharacterIterator ci,
+ float x, float y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawGlyphVector(GlyphVector v, float x, float y)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ // ******************* Image drawing ******************************
+ public boolean drawImage(Image image,
+ AffineTransform Tx,
+ ImageObserver obs)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, new QMatrix( Tx ), obs);
+
+ return (new QtImage(image.getSource())).drawImage(this,
+ new QMatrix( Tx ),
+ obs);
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, bgcolor, observer);
+
+ return (new QtImage(image.getSource())).drawImage(this, dx1, dy1,
+ dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, width, height,
+ bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ width, height,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ return drawImage(image, x, y, width, height, null, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+ {
+ return drawImage(image, x, y, null, observer);
+ }
+
+ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
+ {
+ return drawImage(image, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, null, observer);
+ }
+
+ // *********************** Transform methods *************************
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( xform );
+ }
+
+ public void setTransform(AffineTransform Tx)
+ {
+ xform = new AffineTransform( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta)
+ {
+ xform.rotate( theta );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta, double x, double y)
+ {
+ xform.rotate(theta, x, y);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void scale(double sx, double sy)
+ {
+ xform.scale(sx, sy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void shear(double shx, double shy)
+ {
+ xform.shear(shx, shy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void transform(AffineTransform Tx)
+ {
+ xform.concatenate( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(double tx, double ty)
+ {
+ xform.translate( tx, ty );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(int x, int y)
+ {
+ translate((double)x, (double)y);
+ }
+
+ // *************** Stroking, Filling, Compositing *****************
+ public void setStroke(Stroke s)
+ {
+ try // ..to convert the stroke into a native one.
+ {
+ QPen pen = new QPen( s );
+ nativeStroking = true;
+ setNativeStroke( pen );
+ setColor( color );
+ }
+ catch (IllegalArgumentException e)
+ {
+ nativeStroking = false;
+ }
+ currentStroke = s;
+ }
+
+ public Stroke getStroke()
+ { // FIXME: return copy?
+ return currentStroke;
+ }
+
+ public void setComposite(Composite comp)
+ {
+ if( comp == null)
+ {
+ setNativeComposite( AlphaComposite.SRC_OVER );
+ return;
+ }
+
+ if( comp instanceof AlphaComposite )
+ {
+ if( ((AlphaComposite)comp).getRule() != AlphaComposite.XOR )
+ setAlpha( ((AlphaComposite)comp).getAlpha() );
+ setNativeComposite( ((AlphaComposite)comp).getRule() );
+ composite = comp;
+ }
+ else
+ throw new UnsupportedOperationException("We don't support custom"+
+ " composites yet.");
+ }
+
+ public Composite getComposite()
+ {
+ return composite;
+ }
+
+ public void setPaint(Paint p)
+ {
+ if( p == null )
+ return;
+
+ // FIXME
+ currentPaint = p;
+ if( p instanceof GradientPaint )
+ {
+ GradientPaint lg = (GradientPaint)p;
+ setLinearGradient(lg.getColor1().getRed(), lg.getColor1().getGreen(),
+ lg.getColor1().getBlue(), lg.getColor2().getRed(),
+ lg.getColor2().getGreen(), lg.getColor2().getBlue(),
+ lg.getPoint1().getX(), lg.getPoint1().getY(),
+ lg.getPoint2().getX(), lg.getPoint2().getY(),
+ lg.isCyclic() );
+ return;
+ }
+ if( p instanceof Color )
+ {
+ setColor((Color) p);
+ return;
+ }
+ throw new UnsupportedOperationException("We don't support custom"+
+ " paints yet.");
+ }
+
+ public Paint getPaint()
+ {
+ // FIXME
+ return currentPaint;
+ }
+
+ // ********************** Rendering Hints *************************
+
+ public void addRenderingHints(Map hints)
+ {
+ renderingHints.putAll( hints );
+ }
+
+ public Object getRenderingHint(RenderingHints.Key hintKey)
+ {
+ return renderingHints.get( hintKey );
+ }
+
+ public RenderingHints getRenderingHints()
+ {
+ return new RenderingHints( renderingHints );
+ }
+
+ public void setRenderingHints(Map hints)
+ {
+ renderingHints = new RenderingHints( hints );
+ updateRenderingHints();
+ }
+
+ public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
+ {
+ renderingHints.put( hintKey, hintValue );
+ updateRenderingHints();
+ }
+
+ private void updateRenderingHints()
+ {
+ // FIXME - update native settings.
+ }
+
+ ////////////////////////////// unimplemented /////////////////////
+
+ public FontRenderContext getFontRenderContext()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderableImage(RenderableImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java b/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
new file mode 100644
index 000000000..142b140cf
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
@@ -0,0 +1,108 @@
+/* QtGraphicsEnvironment.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.java.awt.peer.qt;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+
+public class QtGraphicsEnvironment extends GraphicsEnvironment
+{
+ QtToolkit toolkit;
+ GraphicsDevice[] screens;
+
+ public QtGraphicsEnvironment (QtToolkit tk)
+ {
+ super();
+ toolkit = tk;
+ // Get the number of screens from Qt.
+ int n = toolkit.numScreens();
+
+ /**
+ * Create the screen device objects
+ */
+ screens = new GraphicsDevice[ n ];
+ for(int i = 0; i < n; i++)
+ screens[ i ] = new QtScreenDevice( i );
+ }
+
+ public Font[] getAllFonts ()
+ {
+ String[] fonts = getAvailableFontFamilyNames();
+ Font[] fontObjs = new Font[fonts.length];
+ for( int i = 0; i < fonts.length; i++)
+ fontObjs[i] = new Font(fonts[i], Font.PLAIN, 12);
+ return fontObjs;
+ }
+
+ public String[] getAvailableFontFamilyNames()
+ {
+ return toolkit.getFontList();
+ }
+
+ public String[] getAvailableFontFamilyNames(Locale l)
+ {
+ return getAvailableFontFamilyNames();
+ }
+
+ public GraphicsDevice getDefaultScreenDevice ()
+ {
+ return screens[ toolkit.defaultScreen() ];
+ }
+
+ public Graphics2D createGraphics (BufferedImage image)
+ {
+ return (Graphics2D)image.getGraphics();
+ }
+
+ public GraphicsDevice[] getScreenDevices()
+ {
+ return screens;
+ }
+
+ public QtToolkit getToolkit()
+ {
+ return toolkit;
+ }
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtImage.java b/gnu/java/awt/peer/qt/QtImage.java
new file mode 100644
index 000000000..6289f2825
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtImage.java
@@ -0,0 +1,588 @@
+/* QtImage.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.java.awt.peer.qt;
+
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.MemoryImageSource;
+import java.awt.image.ImageConsumer;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.io.File;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedInputStream;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * QtImage - wraps a QImage
+ *
+ */
+public class QtImage extends Image
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Loaded or not flag, for asynchronous compatibility.
+ */
+ boolean isLoaded;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /**
+ * Observer queue.
+ */
+ Vector observers;
+
+ /**
+ * Error flag for loading.
+ */
+ boolean errorLoading;
+
+ /**
+ * Original source, if created from an ImageProducer.
+ */
+ ImageProducer source;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Sets the pixel data from a java array.
+ */
+ private native void setPixels(int[] pixels);
+
+ /**
+ * Loads an image
+ */
+ private native boolean loadImage(String name);
+
+ /**
+ * Loads an image from data.
+ */
+ private native boolean loadImageFromData(byte[] data);
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * Frees the above.
+ */
+ private synchronized native void freeImage();
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ private native void drawPixelsScaledFlipped (QtGraphics gc,
+ int bg_red, int bg_green,
+ int bg_blue,
+ boolean flipX, boolean flipY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight,
+ int dstX, int dstY,
+ int dstWidth, int dstHeight,
+ boolean composite);
+
+ /**
+ * Creates the image from an ImageProducer. May result in an error image.
+ */
+ public QtImage (ImageProducer producer)
+ {
+ isLoaded = false;
+ observers = new Vector();
+ source = producer;
+ errorLoading = false;
+ if( producer != null )
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+
+ /**
+ * Creates the image from a URL. May result in an error image.
+ */
+ public QtImage (URL url)
+ {
+ isLoaded = false;
+ observers = new Vector();
+ errorLoading = false;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream( 5000 );
+ try
+ {
+ BufferedInputStream bis = new BufferedInputStream(url.openStream());
+
+ byte[] buf = new byte[5000];
+ int n = 0;
+
+ while ( (n = bis.read( buf )) != -1 )
+ baos.write(buf, 0, n);
+ bis.close();
+ }
+ catch(IOException e)
+ {
+ throw new IllegalArgumentException("Couldn't load image.");
+ }
+ if ( loadImageFromData( baos.toByteArray() ) != true )
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ isLoaded = true;
+ observers = null;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs a QtImage by loading a given file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (String filename)
+ {
+ File f = new File(filename);
+ observers = null;
+ props = new Hashtable();
+ try
+ {
+ String fn = f.getCanonicalPath();
+ if (loadImage( fn ) != true)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+ }
+ catch(IOException e)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+
+ errorLoading = false;
+ isLoaded = true;
+ }
+
+ /**
+ * Constructs a QtImage from a byte array of an image file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (byte[] data)
+ {
+ if (loadImageFromData(data) != true)
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ isLoaded = true;
+ observers = null;
+ errorLoading = false;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs an empty QtImage.
+ */
+ public QtImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ observers = null;
+ errorLoading = false;
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtImage (QtImage src, int width, int height, int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ observers = null;
+ errorLoading = false;
+
+ createScaledImage(src, hints);
+ }
+
+ /**
+ * Callback from the image consumer.
+ */
+ public void setImage(int width, int height,
+ int[] pixels, Hashtable properties)
+ {
+ this.width = width;
+ this.height = height;
+ props = (properties != null) ? properties : new Hashtable();
+
+ if (width <= 0 || height <= 0 || pixels == null)
+ {
+ errorLoading = true;
+ return;
+ }
+
+ isLoaded = true;
+ deliver();
+ createImage();
+ setPixels(pixels);
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return width;
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return height;
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return UndefinedProperty;
+
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ if (!isLoaded)
+ return null;
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ if (!isLoaded)
+ return null;
+
+ return new QtImageGraphics(this);
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtImage(this, width, height, hints);
+ }
+
+ /**
+ * If the image is loaded and comes from an ImageProducer,
+ * regenerate the image from there.
+ *
+ * I have no idea if this is ever actually used. Since QtImage can't be
+ * instantiated directly, how is the user to know if it was created from
+ * an ImageProducer or not?
+ */
+ public synchronized void flush ()
+ {
+ if (isLoaded && source != null)
+ {
+ observers = new Vector();
+ isLoaded = false;
+ freeImage();
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+ }
+
+ public void finalize()
+ {
+ if (isLoaded)
+ freeImage();
+ }
+
+ public void dispose()
+ {
+ finalize();
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ {
+ if (errorLoading == true)
+ return ImageObserver.ERROR;
+ else
+ return 0;
+ }
+
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ drawPixelsTransformed (g, matrix);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ if(bgcolor != null)
+ drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, width, height, true);
+ else
+ drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ boolean flipX = (dx1 > dx2)^(sx1 > sx2);
+ boolean flipY = (dy1 > dy2)^(sy1 > sy2);
+ int dstWidth = Math.abs (dx2 - dx1);
+ int dstHeight = Math.abs (dy2 - dy1);
+ int srcWidth = Math.abs (sx2 - sx1);
+ int srcHeight = Math.abs (sy2 - sy1);
+ int srcX = (sx1 < sx2) ? sx1 : sx2;
+ int srcY = (sy1 < sy2) ? sy1 : sy2;
+ int dstX = (dx1 < dx2) ? dx1 : dx2;
+ int dstY = (dy1 < dy2) ? dy1 : dy2;
+
+ // Clipping. This requires the dst to be scaled as well,
+ if (srcWidth > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ if(bgcolor != null)
+ drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (),
+ flipX, flipY,
+ srcX, srcY,
+ srcWidth, srcHeight,
+ dstX, dstY,
+ dstWidth, dstHeight,
+ true);
+ else
+ drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
+ srcX, srcY, srcWidth, srcHeight,
+ dstX, dstY, dstWidth, dstHeight,
+ false);
+ return true;
+ }
+
+ public native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ // Private methods ////////////////////////////////////////////////
+
+ /**
+ * Delivers notifications to all queued observers.
+ */
+ private void deliver()
+ {
+ int flags = ImageObserver.HEIGHT |
+ ImageObserver.WIDTH |
+ ImageObserver.PROPERTIES |
+ ImageObserver.ALLBITS;
+
+ if (observers != null)
+ for(int i=0; i < observers.size(); i++)
+ ((ImageObserver)observers.elementAt(i)).
+ imageUpdate(this, flags, 0, 0, width, height);
+
+ observers = null;
+ }
+
+ /**
+ * Adds an observer, if we need to.
+ * @return true if an observer was added.
+ */
+ private boolean addObserver(ImageObserver observer)
+ {
+ if (!isLoaded)
+ {
+ if(observer != null)
+ if (!observers.contains (observer))
+ observers.addElement (observer);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtImageConsumer.java b/gnu/java/awt/peer/qt/QtImageConsumer.java
new file mode 100644
index 000000000..aec0671f8
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtImageConsumer.java
@@ -0,0 +1,154 @@
+/* QtImageConsumer.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.java.awt.peer.qt;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageConsumer;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Helper class to QtImage. Sits and gathers pixels for a QtImage and then
+ * calls QtImage.setImage().
+ *
+ * @author Sven de Marothy
+ */
+public class QtImageConsumer implements ImageConsumer
+{
+ private QtImage target;
+ private int width, height;
+ private Hashtable properties;
+ private int[] pixelCache = null;
+ private ImageProducer source;
+
+ public QtImageConsumer(QtImage target, ImageProducer source)
+ {
+ this.target = target;
+ this.source = source;
+ }
+
+ public synchronized void imageComplete (int status)
+ {
+ source.removeConsumer(this);
+ target.setImage(width, height, pixelCache, properties);
+ }
+
+ public synchronized void setColorModel (ColorModel model)
+ {
+ // This method is to inform on what the most used color model
+ // in the image is, for optimization reasons. We ignore this
+ // information.
+ }
+
+ public synchronized void setDimensions (int width, int height)
+ {
+ pixelCache = new int[width*height];
+
+ this.width = width;
+ this.height = height;
+ }
+
+ public synchronized void setHints (int flags)
+ {
+ // This method informs us in which order the pixels are
+ // delivered, for progressive-loading support, etc.
+ // Since we wait until it's all loaded, we can ignore the hints.
+ }
+
+ public synchronized void setPixels (int x, int y, int width, int height,
+ ColorModel cm, byte[] pixels,
+ int offset, int scansize)
+ {
+ setPixels (x, y, width, height, cm, convertPixels (pixels), offset,
+ scansize);
+ }
+
+ public synchronized void setPixels (int x, int y, int width, int height,
+ ColorModel cm, int[] pixels,
+ int offset, int scansize)
+ {
+ if (pixelCache == null)
+ return; // Not sure this should ever happen.
+
+ if (cm.equals(QtImage.nativeModel))
+ for (int i = 0; i < height; i++)
+ System.arraycopy (pixels, offset + (i * scansize),
+ pixelCache, (y + i) * this.width + x,
+ width);
+ else
+ {
+ for (int i = 0; i < height; i++)
+ for (int j = 0; j < width; j++)
+ {
+ // get in AARRGGBB and convert to AABBGGRR
+ int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]);
+ byte b = (byte)(pix & 0xFF);
+ byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF);
+ pix &= 0xFF00FF00;
+ pix |= ((b & 0xFF) << 16);
+ pix |= (r & 0xFF);
+ pixelCache[(y + i) * this.width + x + j] = pix;
+ }
+ }
+ }
+
+ /**
+ * This is an old method, no idea if it's correct.
+ */
+ private int[] convertPixels (byte[] pixels)
+ {
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = pixels[i] & 0xFF;
+
+ return ret;
+ }
+
+ public synchronized void setProperties (Hashtable props)
+ {
+ this.properties = props;
+ }
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtImageGraphics.java b/gnu/java/awt/peer/qt/QtImageGraphics.java
new file mode 100644
index 000000000..1f866a489
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtImageGraphics.java
@@ -0,0 +1,139 @@
+/* QtImageGraphics.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.java.awt.peer.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.util.Stack;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting to QtImage and
+ * QtVolatileImages.
+ */
+public class QtImageGraphics extends QtGraphics
+{
+ Image parentImage;
+ Stack owners;
+ QtImageGraphics topParent;
+
+ public QtImageGraphics(Image image)
+ {
+ if(!( image instanceof QtVolatileImage || image instanceof QtImage))
+ throw new IllegalArgumentException("Cannot create QtImageGraphics for a non-QImage context.");
+
+ owners = new Stack();
+ owners.push(this);
+ topParent = null;
+ int w, h;
+ if(image instanceof QtImage)
+ {
+ w = ((QtImage)image).width;
+ h = ((QtImage)image).height;
+ }
+ else
+ {
+ w = ((QtVolatileImage)image).width;
+ h = ((QtVolatileImage)image).height;
+ }
+
+ initImage( image );
+ parentImage = image;
+ initialClip = new Rectangle( 0, 0, w, h );
+ setClip( initialClip );
+ setBackground(Color.white); // fixme
+ currentAlpha = 1.0;
+ setColor(Color.black);
+ setup();
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtImageGraphics( QtImageGraphics g )
+ {
+ super( g );
+ parentImage = g.parentImage;
+ if( g.topParent == null )
+ topParent = g;
+ else
+ topParent = g.topParent;
+ topParent.owners.push( this );
+ }
+
+ public void dispose()
+ {
+ while(!owners.empty())
+ ((QtImageGraphics)owners.pop()).delete();
+ }
+
+
+ /**
+ * Create a copy of this context.
+ */
+ public Graphics create()
+ {
+ return new QtImageGraphics( this );
+ }
+
+ /**
+ * Copy an area.
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ if(parentImage instanceof QtImage)
+ ((QtImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ else
+ ((QtVolatileImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
+
diff --git a/gnu/java/awt/peer/qt/QtLabelPeer.java b/gnu/java/awt/peer/qt/QtLabelPeer.java
new file mode 100644
index 000000000..6e9c0734b
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtLabelPeer.java
@@ -0,0 +1,62 @@
+/* QtLabelPeer.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.java.awt.peer.qt;
+
+import java.awt.Label;
+import java.awt.peer.LabelPeer;
+
+public class QtLabelPeer extends QtComponentPeer implements LabelPeer
+{
+ public QtLabelPeer( QtToolkit kit, Label owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText( ((Label)owner).getText() );
+ setAlignment( ((Label)owner).getAlignment() );
+ }
+
+ public native void setAlignment( int alignment );
+
+ public native void setText( String label );
+}
diff --git a/gnu/java/awt/peer/qt/QtListPeer.java b/gnu/java/awt/peer/qt/QtListPeer.java
new file mode 100644
index 000000000..0ea00ca4c
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtListPeer.java
@@ -0,0 +1,139 @@
+/* QtListPeer.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.java.awt.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.List;
+import java.awt.peer.ListPeer;
+
+public class QtListPeer extends QtComponentPeer implements ListPeer
+{
+ public QtListPeer( QtToolkit kit, List owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ List o = (List)owner;
+ String[] items = o.getItems();
+ setMultipleMode(o.isMultipleMode());
+ for (int i = 0; i < items.length; i++)
+ add(items[i], i);
+ int[] selected = o.getSelectedIndexes();
+ for (int i = 0; i < selected.length; i++)
+ select(selected[i]);
+ }
+
+ private native void select(int index, boolean selected);
+
+ // ************ Public methods *********************
+
+ public native void add(String item, int index);
+
+ public void addItem(String item, int index)
+ {
+ add(item, index);
+ }
+
+ public void clear()
+ {
+ removeAll();
+ }
+
+ /**
+ * Deletes items from the starting index to the ending index (inclusive).
+ */
+ public native void delItems(int start_index, int end_index);
+
+ public void deselect(int index)
+ {
+ select(index, false);
+ }
+
+ public native int[] getSelectedIndexes();
+
+ public native void makeVisible(int index);
+
+ public Dimension minimumSize(int s)
+ {
+ return getMinimumSize(s);
+ }
+
+ public Dimension preferredSize(int s)
+ {
+ return getPreferredSize(s);
+ }
+
+ public void removeAll()
+ {
+ delItems(0, ((List)owner).getItemCount() - 1);
+ }
+
+ public void select(int index)
+ {
+ select(index, true);
+ }
+
+ /**
+ * Sets multiple-selection mode.
+ * WONTFIX: QAbstractItemView::MultiSelection does not work as it should
+ * in Qt 4.0.0, Trolltech bug reporter says this will be fixed in 4.1.0.
+ */
+ public native void setMultipleMode(boolean multi);
+
+ public void setMultipleSelections(boolean multi)
+ {
+ setMultipleMode(multi);
+ }
+
+ public Dimension getPreferredSize(int s)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public Dimension getMinimumSize(int s)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtMenuBarPeer.java b/gnu/java/awt/peer/qt/QtMenuBarPeer.java
new file mode 100644
index 000000000..7c71da01e
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtMenuBarPeer.java
@@ -0,0 +1,103 @@
+/* QtMenuBarPeer.java -- Qt peer for a menu bar.
+ 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.java.awt.peer.qt;
+
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.peer.MenuBarPeer;
+import java.util.Vector;
+
+public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
+{
+ public QtMenuBarPeer( QtToolkit kit, MenuBar owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ }
+
+ /**
+ * Recurses the menubar adding menus (and menu items),
+ * called from the Frame peer.
+ */
+ void addMenus()
+ {
+ MenuBar o = (MenuBar)owner;
+ int help = (o.getHelpMenu() != null) ? 1 : 0;
+ for (int i = 0; i < o.getMenuCount() - help; i++)
+ addMenu( o.getMenu(i) );
+ if(o.getHelpMenu() != null)
+ addHelpMenu( o.getHelpMenu() );
+ }
+
+ private native void addMenu( QtMenuPeer mp );
+
+ private native void addHelpMenu( QtMenuPeer mp );
+
+ private native void delMenu( QtMenuPeer mp );
+
+ // ************ Public methods *********************
+
+ public void addMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ return; // throw null pointer exception? illegalstateexception?
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void addHelpMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ return;
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addHelpMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void delMenu( int index )
+ {
+ Menu m = ((MenuBar)owner).getMenu( index );
+ if(m != null)
+ delMenu( (QtMenuPeer)m.getPeer() );
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QtMenuComponentPeer.java b/gnu/java/awt/peer/qt/QtMenuComponentPeer.java
new file mode 100644
index 000000000..b6344fe42
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtMenuComponentPeer.java
@@ -0,0 +1,77 @@
+/* QtMenuComponentPeer.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.java.awt.peer.qt;
+
+import java.awt.MenuComponent;
+import java.awt.peer.MenuComponentPeer;
+
+public class QtMenuComponentPeer extends NativeWrapper
+ implements MenuComponentPeer
+{
+ protected QtToolkit toolkit;
+ protected MenuComponent owner;
+
+ public QtMenuComponentPeer( QtToolkit kit, MenuComponent owner )
+ {
+ this.toolkit = kit;
+ this.owner = owner;
+ nativeObject = 0;
+ callInit();
+ setup();
+ }
+
+ protected native void callInit();
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ // ************ Public methods *********************
+
+ public native void dispose();
+
+}
diff --git a/gnu/java/awt/peer/qt/QtMenuItemPeer.java b/gnu/java/awt/peer/qt/QtMenuItemPeer.java
new file mode 100644
index 000000000..5baf74029
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtMenuItemPeer.java
@@ -0,0 +1,100 @@
+/* QtMenuItemPeer.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.java.awt.peer.qt;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.CheckboxMenuItem;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+
+public class QtMenuItemPeer extends QtMenuComponentPeer
+ implements MenuItemPeer, CheckboxMenuItemPeer
+{
+ public QtMenuItemPeer( QtToolkit toolkit, MenuItem owner )
+ {
+ super(toolkit, owner);
+ }
+
+ protected void init()
+ {
+ String label = ((MenuItem)owner).getLabel();
+ create(label, label.equals("-"), (owner instanceof CheckboxMenuItem));
+ }
+
+ protected void setup()
+ {
+ }
+
+ private native void create(String label, boolean isSeperator, boolean isCheckable);
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public native void dispose();
+
+ private void fireClick()
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((MenuItem)owner).getActionCommand());
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean b);
+
+ public native void setLabel(String label);
+
+ public native void setState(boolean state);
+}
+
diff --git a/gnu/java/awt/peer/qt/QtMenuPeer.java b/gnu/java/awt/peer/qt/QtMenuPeer.java
new file mode 100644
index 000000000..2ad05ced5
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtMenuPeer.java
@@ -0,0 +1,150 @@
+/* QtMenuPeer.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.java.awt.peer.qt;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.PopupMenu;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuPeer;
+import java.util.Vector;
+
+public class QtMenuPeer extends QtMenuComponentPeer implements MenuPeer
+{
+ Vector items;
+ boolean itemsAdded;
+
+ public QtMenuPeer( QtToolkit kit, Menu owner )
+ {
+ super( kit, owner );
+ itemsAdded = false;
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ items = new Vector();
+ setLabel( ((Menu)owner).getLabel() );
+ if( ((Menu)owner).isTearOff() )
+ allowTearOff();
+ }
+
+ // Recurse the menu tree adding items,
+ // called from the MenuBar addMenus() method, called from the Frame peer.
+ void addItems()
+ {
+ if(!itemsAdded)
+ {
+ Menu o = (Menu)owner;
+ for( int i=0; i < o.getItemCount(); i++ )
+ {
+ MenuItem ci = (MenuItem)o.getItem(i);
+ if (ci instanceof Menu && ci.getPeer() != null)
+ ((QtMenuPeer)ci.getPeer()).addItems();
+ addItem( ci );
+ }
+ itemsAdded = true;
+ }
+ }
+
+ private void fireClick()
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Menu)owner).getActionCommand());
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native void allowTearOff();
+
+ private native long insertSeperator();
+
+ private native long insertItem(QtMenuItemPeer p);
+
+ private native long insertMenu(QtMenuPeer menu);
+
+ private native void delItem(long ptr);
+
+ // ************ Public methods *********************
+
+ public void addItem( MenuItem item )
+ {
+ long ptr;
+ if( item instanceof Menu || item instanceof PopupMenu)
+ ptr = insertMenu((QtMenuPeer)item.getPeer());
+ else
+ {
+ QtMenuItemPeer p = (QtMenuItemPeer)item.getPeer();
+ ptr = insertItem(p);
+ }
+ items.add(new Long(ptr));
+ }
+
+ public void addSeparator()
+ {
+ long ptr = insertSeperator();
+ items.add(new Long(ptr));
+ }
+
+ public void delItem( int index )
+ {
+ long ptr = ((Long)items.elementAt(index)).longValue();
+ delItem(ptr);
+ items.removeElementAt(index);
+ }
+
+ // Inherited methods..
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean enabled);
+
+ public native void setLabel(String text);
+}
+
+
+
diff --git a/gnu/java/awt/peer/qt/QtPanelPeer.java b/gnu/java/awt/peer/qt/QtPanelPeer.java
new file mode 100644
index 000000000..8beb0eadb
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtPanelPeer.java
@@ -0,0 +1,57 @@
+/* QtPanelPeer.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.java.awt.peer.qt;
+
+import java.awt.Component;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.LightweightPeer;
+
+public class QtPanelPeer extends QtContainerPeer implements PanelPeer, LightweightPeer
+{
+ public QtPanelPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtPopupMenuPeer.java b/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
new file mode 100644
index 000000000..81577cc6c
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
@@ -0,0 +1,82 @@
+/* QtPopupMenuPeer.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.java.awt.peer.qt;
+
+import java.awt.Component;
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.Event;
+import java.awt.event.ActionEvent;
+import java.awt.peer.PopupMenuPeer;
+
+public class QtPopupMenuPeer extends QtMenuPeer implements PopupMenuPeer
+{
+ public QtPopupMenuPeer( QtToolkit kit, PopupMenu owner )
+ {
+ super( kit, owner );
+ }
+
+ private native void showNative(int x, int y);
+
+ // ************ Public methods *********************
+
+ /**
+ * Part of the older API, replaced by event version instead.
+ */
+ public void show (Component origin, int x, int y)
+ {
+ if( origin == null )
+ throw new NullPointerException("Null parent component.");
+ addItems();
+
+ Point p = origin.getLocationOnScreen();
+ showNative( (int)p.getX() + x, (int)p.getY() + y );
+ }
+
+ public void show (Event e)
+ {
+ if (!(e.target instanceof Component))
+ throw new IllegalArgumentException("Expecting a component Event target!");
+ show((Component)e.target, e.x, e.y);
+ }
+}
+
+
+
diff --git a/gnu/java/awt/peer/qt/QtScreenDevice.java b/gnu/java/awt/peer/qt/QtScreenDevice.java
new file mode 100644
index 000000000..c2d73aed1
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtScreenDevice.java
@@ -0,0 +1,116 @@
+/* QtScreenDevice.java -- Wrapper on a Qt screen Widget
+ 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.java.awt.peer.qt;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.DisplayMode;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.Rectangle;
+import java.awt.Window;
+
+public class QtScreenDevice extends GraphicsDevice
+{
+ private long nativeObject;
+ private int id;
+ private String IDstring;
+ QtScreenDeviceConfiguration config;
+
+ public QtScreenDevice(int id)
+ {
+ this.id = id;
+ IDstring = "QtScreen" + id;
+ init( id );
+ config = new QtScreenDeviceConfiguration(this);
+ }
+
+ public native void init( int id );
+ public native void dispose();
+
+ // Package-private methods used by QtScreenDeviceConfiguration
+ native Rectangle getBounds();
+ native int getDpiX();
+ native int getDpiY();
+ native int depth();
+
+ // ****************** Public methods ***********************
+
+ public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct)
+ {
+ return config;
+ }
+
+ public GraphicsConfiguration[] getConfigurations()
+ {
+ return new GraphicsConfiguration[]{ config };
+ }
+
+ public GraphicsConfiguration getDefaultConfiguration()
+ {
+ return config;
+ }
+
+ public String getIDstring()
+ {
+ return IDstring;
+ }
+
+ public int getType()
+ {
+ return TYPE_RASTER_SCREEN;
+ }
+
+ public boolean isDisplayChangeSupported()
+ {
+ return false;
+ }
+
+ public boolean isFullScreenSupported()
+ {
+ return false;
+ }
+
+ public void setDisplayMode(DisplayMode dm)
+ {
+ }
+
+ public void setFullScreenWindow(Window w)
+ {
+ }
+}
+
diff --git a/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java b/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
new file mode 100644
index 000000000..a9241ee09
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
@@ -0,0 +1,141 @@
+/* QtScreenDeviceConfiguration.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.java.awt.peer.qt;
+
+import java.awt.DisplayMode;
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.geom.AffineTransform;
+
+public class QtScreenDeviceConfiguration extends GraphicsConfiguration {
+
+ private QtScreenDevice owner;
+ private Rectangle bounds;
+ private double dpiX, dpiY;
+ private int depth;
+
+ public QtScreenDeviceConfiguration(QtScreenDevice owner)
+ {
+ this.owner = owner;
+ bounds = owner.getBounds();
+ dpiX = owner.getDpiX();
+ dpiY = owner.getDpiY();
+ depth = owner.depth();
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height)
+ {
+ switch( depth )
+ {
+ case 24:
+ return new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+ case 16:
+ return new BufferedImage(width, height,
+ BufferedImage.TYPE_USHORT_565_RGB);
+ case 8:
+ return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
+ default:
+ case 32:
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ }
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height, int transparency)
+ {
+ // FIXME: Take the transpareny flag into account?
+ // For now, ignore it and just use an alpha channel.
+ if(depth == 32)
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ return createCompatibleImage(width, height);
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height)
+ {
+ return new QtVolatileImage( width, height );
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ ImageCapabilities caps)
+ {
+ return createCompatibleVolatileImage( width, height );
+ }
+
+ public Rectangle getBounds()
+ {
+ return bounds;
+ }
+
+ public ColorModel getColorModel()
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public ColorModel getColorModel(int transparency)
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public AffineTransform getDefaultTransform()
+ {
+ return new AffineTransform();
+ }
+
+ public GraphicsDevice getDevice()
+ {
+ return owner;
+ }
+
+ /**
+ * Returns the transform which transforms from this display's resolution
+ * to a 72 DPI resolution.
+ */
+ public AffineTransform getNormalizingTransform()
+ {
+ AffineTransform nTrans = new AffineTransform();
+ nTrans.scale( 72.0 / dpiX, 72.0 / dpiY );
+ return nTrans;
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtScrollPanePeer.java b/gnu/java/awt/peer/qt/QtScrollPanePeer.java
new file mode 100644
index 000000000..02fa8fb22
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtScrollPanePeer.java
@@ -0,0 +1,91 @@
+/* QtScrollPanePeer.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.java.awt.peer.qt;
+
+import java.awt.Adjustable;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.ScrollPane;
+import java.awt.peer.ScrollPanePeer;
+
+public class QtScrollPanePeer extends QtContainerPeer implements ScrollPanePeer
+{
+ public QtScrollPanePeer( QtToolkit kit, ScrollPane owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setPolicy( ((ScrollPane)owner).getScrollbarDisplayPolicy() );
+ }
+
+ private native void setPolicy(int policy);
+
+ // ************ Public methods *********************
+
+ public native void childResized(int width, int height);
+
+ public native int getHScrollbarHeight();
+
+ public native int getVScrollbarWidth();
+
+ public native void setScrollPosition(int x, int y);
+
+ public Insets getInsets()
+ {
+ // FIXME : more accurate?
+ return new Insets(5 + getHScrollbarHeight(), // Top
+ 5 + getVScrollbarWidth(), // Left
+ 5, // Bottom
+ 5); // Right
+ }
+
+ public void setUnitIncrement(Adjustable item, int inc)
+ {
+ // FIXME
+ }
+
+ public void setValue(Adjustable item, int value)
+ {
+ // FIXME
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtScrollbarPeer.java b/gnu/java/awt/peer/qt/QtScrollbarPeer.java
new file mode 100644
index 000000000..838cca62d
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtScrollbarPeer.java
@@ -0,0 +1,80 @@
+/* QtScrollbarPeer.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.java.awt.peer.qt;
+
+import java.awt.Scrollbar;
+import java.awt.event.AdjustmentEvent;
+import java.awt.peer.ScrollbarPeer;
+
+public class QtScrollbarPeer extends QtComponentPeer implements ScrollbarPeer
+{
+ public QtScrollbarPeer( QtToolkit kit, Scrollbar owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ Scrollbar o = (Scrollbar)owner;
+ setValues(o.getValue(), o.getVisible(), o.getMinimum(), o.getMaximum());
+ setOrientation(o.getOrientation());
+ setLineIncrement(o.getLineIncrement());
+ setPageIncrement(o.getPageIncrement());
+ }
+
+ private native void setOrientation(int orientation);
+
+ private void fireMoved(int type, int value)
+ {
+ AdjustmentEvent e = new AdjustmentEvent((Scrollbar)owner,
+ AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
+ type, value);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLineIncrement(int inc);
+
+ public native void setPageIncrement(int inc);
+
+ public native void setValues(int value, int visible, int min, int max);
+}
diff --git a/gnu/java/awt/peer/qt/QtTextAreaPeer.java b/gnu/java/awt/peer/qt/QtTextAreaPeer.java
new file mode 100644
index 000000000..7f023f1e3
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtTextAreaPeer.java
@@ -0,0 +1,155 @@
+/* QtTextAreaPeer.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.java.awt.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextArea;
+import java.awt.peer.TextAreaPeer;
+
+public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
+{
+ public QtTextAreaPeer( QtToolkit kit, TextArea owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+// setText(((TextArea)owner).getText());
+// setEditable(((TextArea)owner).isEditable());
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long filter)
+ {
+ return filter;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int pos)
+ {
+ // FIXME
+ return new Rectangle(0,0,0,0);
+ }
+
+ public native int getIndexAtPoint(int x, int y);
+
+// public void reshape(int x, int y,
+// int width, int height)
+// {
+// if(width != 0 || height != 0)
+// super.reshape(x, y, width, height);
+// else
+// super.reshape(x, y, 10, 10);
+// }
+
+ public Dimension getMinimumSize(int rows, int cols)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+
+ public Dimension getPreferredSize(int rows, int cols)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public native void insert(String text, int pos);
+
+ public void insertText(String text, int pos)
+ {
+ insert(text, pos);
+ }
+
+ public Dimension minimumSize(int rows, int cols)
+ {
+ return getMinimumSize(rows, cols);
+ }
+
+ public Dimension preferredSize(int rows, int cols)
+ {
+ return getPreferredSize(rows, cols);
+ }
+
+ public void replaceRange(String insert, int start_pos, int end_pos)
+ {
+ // Not very efficient, no.
+ String text = getText();
+ String right = text.substring(0, start_pos);
+ String left = text.substring(end_pos);
+ setText(right + insert + left);
+ }
+
+ public void replaceText(String text, int start_pos, int end_pos)
+ {
+ replaceRange(text, start_pos, end_pos);
+ }
+
+ public native void setText(String text);
+
+ public native void select(int start_pos, int end_pos);
+
+ public native void setEditable(boolean editable);
+
+ public native void setCaretPosition(int pos);
+}
+
diff --git a/gnu/java/awt/peer/qt/QtTextFieldPeer.java b/gnu/java/awt/peer/qt/QtTextFieldPeer.java
new file mode 100644
index 000000000..151adb064
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtTextFieldPeer.java
@@ -0,0 +1,143 @@
+/* QtTextFieldPeer.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.java.awt.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextField;
+import java.awt.peer.TextFieldPeer;
+
+public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
+{
+ public QtTextFieldPeer( QtToolkit kit, TextField owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText(((TextField)owner).getText());
+ setEditable(((TextField)owner).isEditable());
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ private native Dimension getMinimumSizeNative(int columns);
+
+ private native Dimension getPreferredSizeNative(int columns);
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long e)
+ {
+ return e;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int i)
+ {
+ return new Rectangle(0,0,0,0);
+ }
+
+ public int getIndexAtPoint(int x, int y)
+ {
+ // FIXME
+ return 0;
+ }
+
+ public Dimension getMinimumSize(int columns)
+ {
+ Dimension d = getMinimumSizeNative( columns );
+ if ( d == null )
+ return new Dimension(10, 10);
+ return d;
+ }
+
+ public Dimension getPreferredSize(int columns)
+ {
+ Dimension d = getPreferredSizeNative( columns );
+ if ( d == null )
+ return owner.getSize();
+ return d;
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public Dimension minimumSize(int cols)
+ {
+ return getMinimumSize(cols);
+ }
+
+ public Dimension preferredSize(int cols)
+ {
+ return getPreferredSize(cols);
+ }
+
+ public native void select(int selStart, int selEnd);
+
+ public native void setCaretPosition(int pos);
+
+ public void setEchoCharacter(char c)
+ {
+ setEchoChar(c);
+ }
+
+ public native void setEchoChar(char echoChar);
+
+ public native void setEditable(boolean editable);
+
+ public native void setText(String l);
+}
+
diff --git a/gnu/java/awt/peer/qt/QtToolkit.java b/gnu/java/awt/peer/qt/QtToolkit.java
new file mode 100644
index 000000000..5a57b8551
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtToolkit.java
@@ -0,0 +1,478 @@
+/* QtToolkit.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.java.awt.peer.qt;
+
+import gnu.java.awt.EmbeddedWindow;
+import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.awt.peer.ClasspathTextLayoutPeer;
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.MenuBar;
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.FileDialog;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.Scrollbar;
+import java.awt.ScrollPane;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.event.AWTEventListener;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.LightweightPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.MenuComponentPeer;
+import java.awt.peer.TextComponentPeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.WindowPeer;
+import java.awt.font.FontRenderContext;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.AttributedString;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import javax.imageio.spi.IIORegistry;
+
+import gnu.java.awt.ClasspathToolkit;
+
+public class QtToolkit extends ClasspathToolkit
+{
+ public static EventQueue eventQueue = null; // the native event queue
+ public static MainQtThread guiThread = null;
+ public static QtGraphicsEnvironment graphicsEnv = null;
+
+ private static void initToolkit()
+ {
+ eventQueue = new EventQueue();
+
+ System.loadLibrary("qtpeer");
+
+ String theme = null;
+ try
+ {
+ String style = System.getProperty("qtoptions.style");
+ if(style != null)
+ theme = style;
+ }
+ catch(SecurityException e)
+ {
+ }
+ catch(IllegalArgumentException e)
+ {
+ }
+
+ guiThread = new MainQtThread( theme );
+ guiThread.start();
+ }
+
+ /**
+ * Construct the toolkit!
+ */
+ public QtToolkit()
+ {
+ if( guiThread == null )
+ initToolkit();
+
+ while (!guiThread.isRunning()); // make sure the GUI thread has started.
+
+ if( graphicsEnv == null )
+ graphicsEnv = new QtGraphicsEnvironment( this );
+ }
+
+ native String[] nativeFontFamilies();
+
+ native int numScreens();
+
+ native int defaultScreen();
+
+ // ************ Public methods *********************
+
+ public synchronized native void beep();
+
+ public int checkImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return ((QtImage)image).checkImage(observer);
+
+ return ImageObserver.ERROR; // FIXME
+ }
+
+ protected ButtonPeer createButton( Button target )
+ {
+ return new QtButtonPeer( this, target );
+ }
+
+ protected CanvasPeer createCanvas(Canvas target)
+ {
+ return new QtCanvasPeer( this, target );
+ }
+
+ protected LightweightPeer createComponent(Component target)
+ {
+ return new QtPanelPeer( this, target );
+ }
+
+ protected CheckboxPeer createCheckbox(Checkbox target)
+ {
+ return new QtCheckboxPeer( this, target );
+ }
+
+ protected ChoicePeer createChoice(Choice target)
+ {
+ return new QtChoicePeer( this, target );
+ }
+
+ protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected FramePeer createFrame(Frame target)
+ {
+ return new QtFramePeer( this, target );
+ }
+
+ protected FileDialogPeer createFileDialog(FileDialog target)
+ {
+ return new QtFileDialogPeer( this, target );
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return new QtImage( producer );
+ }
+
+ public Image createImage(byte[] imageData,
+ int imageOffset,
+ int imageLength)
+ {
+ byte[] dataCopy = new byte[imageLength];
+ System.arraycopy(imageData, imageOffset, dataCopy, 0, imageLength);
+ return new QtImage( dataCopy );
+ }
+
+ public Image createImage(String filename)
+ {
+ return new QtImage( filename );
+ }
+
+ public Image createImage(URL url)
+ {
+ return new QtImage( url );
+ }
+
+ protected TextFieldPeer createTextField(TextField target)
+ {
+ return new QtTextFieldPeer(this,target);
+ }
+
+ protected LabelPeer createLabel(Label target)
+ {
+ return new QtLabelPeer( this, target );
+ }
+
+ protected ListPeer createList(List target)
+ {
+ return new QtListPeer( this, target );
+ }
+
+ protected ScrollbarPeer createScrollbar(Scrollbar target)
+ {
+ return new QtScrollbarPeer( this, target );
+ }
+
+ protected ScrollPanePeer createScrollPane(ScrollPane target)
+ {
+ return new QtScrollPanePeer( this, target );
+ }
+
+ protected TextAreaPeer createTextArea(TextArea target)
+ {
+ return new QtTextAreaPeer( this, target );
+ }
+
+ protected PanelPeer createPanel(Panel target)
+ {
+ return new QtPanelPeer( this, target);
+ }
+
+ protected WindowPeer createWindow(Window target)
+ {
+ return new QtWindowPeer( this, target );
+ }
+
+ protected DialogPeer createDialog(Dialog target)
+ {
+ return new QtDialogPeer( this, target );
+ }
+
+ protected MenuBarPeer createMenuBar(MenuBar target)
+ {
+ return new QtMenuBarPeer( this, target );
+ }
+
+ protected MenuPeer createMenu(Menu target)
+ {
+ return new QtMenuPeer( this, target );
+ }
+
+ protected PopupMenuPeer createPopupMenu(PopupMenu target)
+ {
+ return new QtPopupMenuPeer( this, target );
+ }
+
+ protected MenuItemPeer createMenuItem(MenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners()
+ {
+ return null; // FIXME
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners(long mask)
+ {
+ return null; // FIXME
+ }
+
+ public ColorModel getColorModel()
+ {
+ return new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ }
+
+ /**
+ * Just return the defaults.
+ */
+ public String[] getFontList()
+ {
+ String[] builtIn = new String[] { "Dialog",
+ "DialogInput",
+ "Monospaced",
+ "Serif",
+ "SansSerif" };
+ String[] nat = nativeFontFamilies();
+ String[] allFonts = new String[ nat.length + 5 ];
+ System.arraycopy(builtIn, 0, allFonts, 0, 5);
+ System.arraycopy(nat, 0, allFonts, 5, nat.length);
+ return allFonts;
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font);
+ }
+
+ protected FontPeer getFontPeer(String name,
+ int style)
+ {
+ Map attrs = new HashMap ();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
+ return getClasspathFontPeer (name, attrs);
+ }
+
+ public Image getImage(String filename)
+ {
+ return new QtImage(filename);
+ }
+
+ public Image getImage(URL url)
+ {
+ return createImage( url );
+ }
+
+ public PrintJob getPrintJob(Frame frame,
+ String jobtitle,
+ Properties props)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ public Clipboard getSystemClipboard()
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected EventQueue getSystemEventQueueImpl()
+ {
+ return eventQueue;
+ }
+
+ public native Dimension getScreenSize();
+
+ public native int getScreenResolution();
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ {
+ return null; // FIXME
+ }
+
+ public boolean prepareImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return true;
+ return false; // FIXME?
+ }
+
+ public native void sync();
+
+ // ********************** ClasspathToolkit methods
+
+ public GraphicsEnvironment getLocalGraphicsEnvironment()
+ {
+ return graphicsEnv;
+ }
+
+ public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
+ {
+ return new QtFontPeer (name, attrs);
+ }
+
+ public ClasspathTextLayoutPeer getClasspathTextLayoutPeer(AttributedString str,
+ FontRenderContext frc)
+ {
+ return null;
+ }
+
+ // FIXME
+ public Font createFont(int format, InputStream stream)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ // FIXME
+ public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ // REMOVE.
+ public void registerImageIOSpis(IIORegistry reg)
+ {
+ }
+
+ public EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
+ {
+ return null; // FIXME
+ }
+
+ // Yucky.
+
+ public boolean nativeQueueEmpty()
+ {
+ return true;
+ }
+
+ public void wakeNativeQueue()
+ {
+ }
+
+ public void iterateNativeQueue(EventQueue locked, boolean block)
+ {
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtVolatileImage.java b/gnu/java/awt/peer/qt/QtVolatileImage.java
new file mode 100644
index 000000000..2bb2260d1
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtVolatileImage.java
@@ -0,0 +1,393 @@
+/* QtVolatileImage.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.java.awt.peer.qt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.MemoryImageSource;
+import java.awt.image.ImageConsumer;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * QtVolatileImage - wraps a QImage
+ *
+ */
+public class QtVolatileImage extends VolatileImage
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * Frees the above.
+ */
+ private native void freeImage();
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtVolatileImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ private native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ private native void drawPixelsScaledFlipped (QtGraphics gc,
+ int bg_red, int bg_green,
+ int bg_blue,
+ boolean flipX, boolean flipY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight,
+ int dstX, int dstY,
+ int dstWidth, int dstHeight,
+ boolean composite);
+
+ /**
+ * Constructs an empty QtVolatileImage.
+ */
+ public QtVolatileImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtVolatileImage (QtVolatileImage src, int width, int height,
+ int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+
+ createScaledImage(src, hints);
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ return getWidth();
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ return getHeight();
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ return new QtImageGraphics( this );
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtVolatileImage(this, width, height, hints);
+ }
+
+ /**
+ */
+ public void flush ()
+ {
+ // FIXME ?
+ }
+
+ public void finalize()
+ {
+ freeImage();
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ drawPixelsTransformed (g, matrix);
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if(bgcolor != null)
+ drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, width, height, true);
+ else
+ drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ boolean flipX = (dx1 > dx2)^(sx1 > sx2);
+ boolean flipY = (dy1 > dy2)^(sy1 > sy2);
+ int dstWidth = Math.abs (dx2 - dx1);
+ int dstHeight = Math.abs (dy2 - dy1);
+ int srcWidth = Math.abs (sx2 - sx1);
+ int srcHeight = Math.abs (sy2 - sy1);
+ int srcX = (sx1 < sx2) ? sx1 : sx2;
+ int srcY = (sy1 < sy2) ? sy1 : sy2;
+ int dstX = (dx1 < dx2) ? dx1 : dx2;
+ int dstY = (dy1 < dy2) ? dy1 : dy2;
+
+ // Clipping. This requires the dst to be scaled as well,
+ if (srcWidth > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ if(bgcolor != null)
+ drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (),
+ flipX, flipY,
+ srcX, srcY,
+ srcWidth, srcHeight,
+ dstX, dstY,
+ dstWidth, dstHeight,
+ true);
+ else
+ drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
+ srcX, srcY, srcWidth, srcHeight,
+ dstX, dstY, dstWidth, dstHeight,
+ false);
+ return true;
+ }
+
+ public native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ //******************** VolatileImage stuff ********************
+
+ public boolean contentsLost()
+ {
+ return false;
+ }
+
+ public Graphics2D createGraphics()
+ {
+ return new QtImageGraphics(this);
+ }
+
+ public ImageCapabilities getCapabilities()
+ {
+ return new ImageCapabilities(false)
+ {
+ public boolean isTrueVolatile()
+ {
+ return false;
+ }
+ };
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public BufferedImage getSnapshot()
+ {
+ BufferedImage bi = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ bi.setRGB( 0, 0, width, height, getPixels(), 0, width);
+ return bi;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int validate(GraphicsConfiguration gc)
+ {
+ return IMAGE_OK;
+ }
+}
diff --git a/gnu/java/awt/peer/qt/QtWindowPeer.java b/gnu/java/awt/peer/qt/QtWindowPeer.java
new file mode 100644
index 000000000..e64ee65a1
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtWindowPeer.java
@@ -0,0 +1,68 @@
+/* QtWindowPeer.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.java.awt.peer.qt;
+
+import java.awt.Window;
+import java.awt.peer.WindowPeer;
+
+public class QtWindowPeer extends QtContainerPeer implements WindowPeer
+{
+ public QtWindowPeer( QtToolkit kit, Window owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+
+ public native void toBack();
+
+ public native void toFront();
+
+ /*
+ * Belongs to Frame and Dialog, but no sense in duplicating code.
+ */
+ public native void setTitle(String title);
+
+}
diff --git a/gnu/java/nio/charset/UTF_16Decoder.java b/gnu/java/nio/charset/UTF_16Decoder.java
index 302c83e62..e3927d994 100644
--- a/gnu/java/nio/charset/UTF_16Decoder.java
+++ b/gnu/java/nio/charset/UTF_16Decoder.java
@@ -1,5 +1,5 @@
/* UTF_16Decoder.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -105,8 +105,9 @@ final class UTF_16Decoder extends CharsetDecoder
}
// FIXME: Change so you only do a single comparison here.
- char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | b2)
- : (char) ((b2 << 8) | b1);
+ char c = (byteOrder == BIG_ENDIAN
+ ? (char) (((b1 & 0xFF) << 8) | (b2 & 0xFF))
+ : (char) (((b2 & 0xFF) << 8) | (b1 & 0xFF)));
if (0xD800 <= c && c <= 0xDFFF)
{
@@ -119,8 +120,9 @@ final class UTF_16Decoder extends CharsetDecoder
return CoderResult.UNDERFLOW;
byte b3 = in.get ();
byte b4 = in.get ();
- char d = byteOrder == BIG_ENDIAN ? (char) ((b3 << 8) | b4)
- : (char) ((b4 << 8) | b3);
+ char d = (byteOrder == BIG_ENDIAN
+ ? (char) (((b3 & 0xFF) << 8) | (b4 & 0xFF))
+ : (char) (((b4 & 0xFF) << 8) | (b3 & 0xFF)));
// make sure d is a low surrogate
if (d < 0xDC00 || d > 0xDFFF)
return CoderResult.malformedForLength (2);
diff --git a/gnu/java/security/PolicyFile.java b/gnu/java/security/PolicyFile.java
index dd3a4dec4..c6a3061ea 100644
--- a/gnu/java/security/PolicyFile.java
+++ b/gnu/java/security/PolicyFile.java
@@ -37,6 +37,10 @@ exception statement from your version. */
package gnu.java.security;
+import gnu.classpath.SystemProperties;
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -66,6 +70,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.logging.Logger;
/**
* An implementation of a {@link java.security.Policy} object whose
@@ -143,24 +148,16 @@ public final class PolicyFile extends Policy
// Constants and fields.
// -------------------------------------------------------------------------
- private static final boolean DEBUG = true;
- // Package-private to avoid a trampoline.
- static void debug(String msg)
- {
- System.err.print(">> PolicyFile: ");
- System.err.println(msg);
- }
-
- private static void debug(Throwable t)
- {
- System.err.println(">> PolicyFile");
- t.printStackTrace(System.err);
- }
+ private static final Logger logger = SystemLogger.SYSTEM;
- private static final String DEFAULT_POLICY = System.getProperty("java.home")
- + System.getProperty("file.separator") + "lib"
- + System.getProperty("file.separator") + "security"
- + System.getProperty("file.separator") + "java.policy";
+ private static final String DEFAULT_POLICY =
+ SystemProperties.getProperty("java.home")
+ + SystemProperties.getProperty("file.separator") + "lib"
+ + SystemProperties.getProperty("file.separator") + "security"
+ + SystemProperties.getProperty("file.separator") + "java.policy";
+ private static final String DEFAULT_USER_POLICY =
+ SystemProperties.getProperty ("user.home") +
+ SystemProperties.getProperty ("file.separator") + ".java.policy";
private final Map cs2pc;
@@ -185,7 +182,8 @@ public final class PolicyFile extends Policy
CodeSource cs = (CodeSource) e.getKey();
if (cs.implies(codeSource))
{
- if (DEBUG) debug(cs+" -> "+codeSource);
+ logger.log (Component.POLICY, "{0} -> {1}", new Object[]
+ { cs, codeSource });
PermissionCollection pc = (PermissionCollection) e.getValue();
for (Enumeration ee = pc.elements(); ee.hasMoreElements(); )
{
@@ -193,50 +191,69 @@ public final class PolicyFile extends Policy
}
}
else
- if (DEBUG) debug(cs+" !-> "+codeSource);
+ logger.log (Component.POLICY, "{0} !-> {1}", new Object[]
+ { cs, codeSource });
}
- if (DEBUG) debug ("returning permissions " + perms + " for " + codeSource);
+ logger.log (Component.POLICY, "returning permissions {0} for {1}",
+ new Object[] { perms, codeSource });
return perms;
}
public void refresh()
{
cs2pc.clear();
- List policyFiles = new LinkedList();
+ final List policyFiles = new LinkedList();
try
{
- policyFiles.add(new File(DEFAULT_POLICY).toURL());
- if (DEBUG) debug ("defualt policy is " + DEFAULT_POLICY);
- policyFiles.addAll((List) AccessController.doPrivileged(
+ policyFiles.add (new File (DEFAULT_POLICY).toURL());
+ policyFiles.add (new File (DEFAULT_USER_POLICY).toURL ());
+
+ AccessController.doPrivileged(
new PrivilegedExceptionAction()
{
public Object run() throws Exception
{
- LinkedList l = new LinkedList();
+ String allow = Security.getProperty ("policy.allowSystemProperty");
+ if (allow == null || Boolean.getBoolean (allow))
+ {
+ String s = SystemProperties.getProperty ("java.security.policy");
+ logger.log (Component.POLICY, "java.security.policy={0}", s);
+ if (s != null)
+ {
+ boolean only = s.startsWith ("=");
+ if (only)
+ s = s.substring (1);
+ policyFiles.clear ();
+ policyFiles.add (new URL (s));
+ if (only)
+ return null;
+ }
+ }
for (int i = 1; ; i++)
{
- String s = Security.getProperty("policy.file."+i);
- if (DEBUG) debug("policy.file."+i+"="+s);
+ String pname = "policy.url." + i;
+ String s = Security.getProperty (pname);
+ logger.log (Component.POLICY, "{0}={1}", new Object []
+ { pname, s });
if (s == null)
break;
- l.add(new URL(s));
+ policyFiles.add (new URL (s));
}
- String s = System.getProperty("java.security.policy");
- if (DEBUG) debug("java.security.policy="+s);
- if (s != null)
- l.add(new URL(s));
- return l;
+ return null;
}
- }));
+ });
}
catch (PrivilegedActionException pae)
{
- if (DEBUG) debug(pae);
+ logger.log (Component.POLICY, "reading policy properties", pae);
}
catch (MalformedURLException mue)
{
- if (DEBUG) debug(mue);
+ logger.log (Component.POLICY, "setting default policies", mue);
}
+
+ logger.log (Component.POLICY, "building policy from URLs {0}",
+ policyFiles);
for (Iterator it = policyFiles.iterator(); it.hasNext(); )
{
try
@@ -246,7 +263,7 @@ public final class PolicyFile extends Policy
}
catch (IOException ioe)
{
- if (DEBUG) debug(ioe);
+ logger.log (Component.POLICY, "reading policy", ioe);
}
}
}
@@ -273,7 +290,7 @@ public final class PolicyFile extends Policy
*/
private void parse(final URL url) throws IOException
{
- if (DEBUG) debug ("reading policy file from " + url);
+ logger.log (Component.POLICY, "reading policy file from {0}", url);
final StreamTokenizer in = new StreamTokenizer(new InputStreamReader(url.openStream()));
in.resetSyntax();
in.slashSlashComments(true);
diff --git a/gnu/java/security/provider/DSAKeyPairGenerator.java b/gnu/java/security/provider/DSAKeyPairGenerator.java
index 2c643d5c3..d326d2bfe 100644
--- a/gnu/java/security/provider/DSAKeyPairGenerator.java
+++ b/gnu/java/security/provider/DSAKeyPairGenerator.java
@@ -1,5 +1,5 @@
/* GnuDSAKeyPairGenerator.java --- Gnu DSA Key Pair Generator
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,10 +45,12 @@ import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidParameterException;
import java.security.KeyPair;
import java.security.KeyPairGeneratorSpi;
+import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.interfaces.DSAParams;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.DSAParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
import java.util.Random;
public class DSAKeyPairGenerator extends KeyPairGeneratorSpi
@@ -60,18 +62,15 @@ private BigInteger q = null; // the small prime
private BigInteger p = null; // the big prime
private BigInteger g = null;
-DSAKeyPairGenerator()
+public DSAKeyPairGenerator()
{
keysize = 1024;
+ getDefaults ();
}
public void initialize(int keysize, SecureRandom random)
{
- //if( ((keysize % 64) != 0) || (keysize < 512) || (keysize > 1024) )
- // throw new InvalidAlgorithmParameterException("Invalid key size");
-
- this.keysize = keysize;
- this.random = random;
+ initialize (keysize, false, random);
}
public void initialize(AlgorithmParameterSpec params,
@@ -81,65 +80,87 @@ public void initialize(AlgorithmParameterSpec params,
if( !( params instanceof DSAParameterSpec ) )
throw new InvalidAlgorithmParameterException("Must be DSAParameterSpec");
+ try
+ {
+ initialize ((DSAParams) params, random);
+ }
+ catch (InvalidParameterException ipe)
+ {
+ InvalidAlgorithmParameterException iape =
+ new InvalidAlgorithmParameterException();
+ iape.initCause (ipe);
+ throw iape;
+ }
+}
+
+public void initialize (DSAParams params, SecureRandom random)
+{
DSAParameterSpec dsaparameterspec = (DSAParameterSpec)params;
+ if (dsaparameterspec.getP() == null
+ || dsaparameterspec.getQ() == null
+ || dsaparameterspec.getG() == null)
+ {
+ throw new InvalidParameterException ("none of p, q, or g may be null");
+ }
p = dsaparameterspec.getP();
q = dsaparameterspec.getQ();
g = dsaparameterspec.getG();
this.random = random;
}
-public void initialize(DSAParams params, SecureRandom random)
- throws InvalidParameterException
-{
- if(params.getP() != null)
- p = params.getP();
- else
- throw new InvalidParameterException();
-
- if(params.getQ() != null)
- q = params.getQ();
- else
- throw new InvalidParameterException();
-
- if(params.getG() != null)
- g = params.getG();
- else
- throw new InvalidParameterException();
-
- this.random = random;
-}
-
public void initialize(int modlen, boolean genParams, SecureRandom random)
throws InvalidParameterException
{
if( ((modlen % 64) != 0) || (modlen < 512) || (modlen > 1024) )
throw new InvalidParameterException();
- if( (genParams == false) && (modlen != 512) && (modlen != 768) && (modlen != 1024) )
- throw new InvalidParameterException();
- this.keysize = modlen;
- this.random = random;
- p = null;
- q = null;
- g = null;
+ this.keysize = keysize;
+ this.random = random;
+ if (this.random == null)
+ {
+ this.random = new SecureRandom ();
+ }
+ if (genParams)
+ {
+ try
+ {
+ AlgorithmParameterGenerator apgDSA = AlgorithmParameterGenerator.getInstance("DSA");
+ apgDSA.init (modlen, random);
+ AlgorithmParameters apDSA = apgDSA.generateParameters();
+ DSAParameterSpec dsaparameterspec = (DSAParameterSpec)apDSA.getParameterSpec( DSAParameterSpec.class );
+ p = dsaparameterspec.getP();
+ q = dsaparameterspec.getQ();
+ g = dsaparameterspec.getG();
+ }
+ catch (NoSuchAlgorithmException nsae)
+ {
+ InvalidParameterException ipe =
+ new InvalidParameterException ("can't generate DSA parameters");
+ ipe.initCause (nsae);
+ throw ipe;
+ }
+ catch (InvalidParameterSpecException ipse)
+ {
+ InvalidParameterException ipe =
+ new InvalidParameterException ("can't generate DSA parameters");
+ ipe.initCause (ipse);
+ throw ipe;
+ }
+ }
+ else if (!getDefaults ())
+ {
+ throw new InvalidParameterException ("unsupported key size: " + modlen);
+ }
}
public KeyPair generateKeyPair()
{
- if( getDefaults() == false) {
- try {
- AlgorithmParameterGenerator apgDSA = AlgorithmParameterGenerator.getInstance("DSA");
- AlgorithmParameters apDSA = apgDSA.generateParameters();
- DSAParameterSpec dsaparameterspec = (DSAParameterSpec)apDSA.getParameterSpec( DSAParameterSpec.class );
- p = dsaparameterspec.getP();
- q = dsaparameterspec.getQ();
- g = dsaparameterspec.getG();
- } catch ( Exception e ) {
- return null;
- }
- }
+ if (random == null)
+ {
+ random = new SecureRandom ();
+ }
- BigInteger x = new BigInteger( 159, new Random() );
+ BigInteger x = new BigInteger( 159, random );
BigInteger y = g.modPow( x, p );
@@ -160,7 +181,7 @@ private boolean getDefaults()
p = new BigInteger("e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d890141922d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d777d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf", 16);
q = new BigInteger("9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511", 16);
g = new BigInteger("30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d83c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252", 16);
- } else if( keysize == 512) {
+ } else if( keysize == 1024) {
p = new BigInteger("fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7", 16);
q = new BigInteger("9760508f15230bccb292b982a2eb840bf0581cf5", 16);
g = new BigInteger("f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a", 16);
diff --git a/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h b/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h
index 06dad77f6..9601e83ae 100644
--- a/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h
@@ -19,6 +19,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetBack
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkActivate (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetRequestFocus (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetGetPreferredDimensions (JNIEnv *env, jobject, jintArray);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h b/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
index cde8d931e..485509075 100644
--- a/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
@@ -15,6 +15,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFo
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_nativeSetAlignment (JNIEnv *env, jobject, jfloat);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText (JNIEnv *env, jobject, jstring);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetGetPreferredDimensions (JNIEnv *env, jobject, jintArray);
#ifdef __cplusplus
}
diff --git a/java/awt/Component.java b/java/awt/Component.java
index d5b8027eb..3e9d1688d 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -1404,9 +1404,6 @@ public abstract class Component
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight() && isShowing ())
{
- boolean shouldRepaintParent = false;
- boolean shouldRepaintSelf = false;
-
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
@@ -1416,14 +1413,11 @@ public abstract class Component
Rectangle newBounds = new Rectangle(parent.getX() + x,
parent.getY() + y,
width, height);
- shouldRepaintParent = parentBounds.intersects(oldBounds);
- shouldRepaintSelf = parentBounds.intersects(newBounds);
+ Rectangle destroyed = oldBounds.union(newBounds);
+ if (!destroyed.isEmpty())
+ parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
+ destroyed.height);
}
-
- if (shouldRepaintParent && parent != null)
- parent.repaint(oldx, oldy, oldwidth, oldheight);
- if (shouldRepaintSelf)
- repaint();
}
// Only post event if this component is visible and has changed size.
@@ -1830,9 +1824,8 @@ public abstract class Component
*/
public void paint(Graphics g)
{
- // Paint the heavyweight peer
- if (!isLightweight() && peer != null)
- peer.paint(g);
+ // This is a callback method and is meant to be overridden by subclasses
+ // that want to perform custom painting.
}
/**
@@ -1858,7 +1851,8 @@ public abstract class Component
{
// Tests show that the clearing of the background is only done in
// two cases:
- // - If the component is lightwight (yes this is in contrast to the spec).
+ // - If the component is lightweight (yes this is in contrast to the spec).
+ // or
// - If the component is a toplevel container.
if (isLightweight() || getParent() == null)
{
@@ -1943,14 +1937,18 @@ public abstract class Component
*/
public void repaint(long tm, int x, int y, int width, int height)
{
- // Handle lightweight repainting by forwarding to native parent
- if (isLightweight() && parent != null)
+ if(!isShowing())
{
- if (parent != null)
- parent.repaint(tm, x + getX(), y + getY(), width, height);
+ Component p = parent;
+ if (p != null)
+ p.repaint(tm, x + getX(), y + getY(), width, height);
+ }
+ else
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ p.repaint(tm, x, y, width, height);
}
- else if (peer != null)
- peer.repaint(tm, x, y, width, height);
}
/**
@@ -2011,7 +2009,7 @@ public abstract class Component
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
{
if ((flags & (FRAMEBITS | ALLBITS)) != 0)
- repaint ();
+ repaint();
else if ((flags & SOMEBITS) != 0)
{
if (incrementalDraw)
@@ -2021,10 +2019,10 @@ public abstract class Component
long tm = redrawRate.longValue();
if (tm < 0)
tm = 0;
- repaint (tm);
+ repaint(tm);
}
else
- repaint (100);
+ repaint(100);
}
}
return (flags & (ALLBITS | ABORT | ERROR)) == 0;
@@ -2322,8 +2320,6 @@ public abstract class Component
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(e);
- if (peer != null && ! e.consumed)
- peer.handleEvent(e);
}
/**
@@ -4787,7 +4783,7 @@ p * <li>the set of backward traversal keys
* @param e the event to dispatch
*/
- void dispatchEventImpl (AWTEvent e)
+ void dispatchEventImpl(AWTEvent e)
{
Event oldEvent = translateEvent (e);
@@ -4821,7 +4817,10 @@ p * <li>the set of backward traversal keys
break;
}
}
- processEvent (e);
+ if (e.id == PaintEvent.PAINT || e.id == PaintEvent.UPDATE)
+ peer.handleEvent(e);
+ else
+ processEvent(e);
}
}
diff --git a/java/awt/Container.java b/java/awt/Container.java
index d17a7602a..a3b566bc7 100644
--- a/java/awt/Container.java
+++ b/java/awt/Container.java
@@ -43,6 +43,7 @@ import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
+import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener;
@@ -342,11 +343,11 @@ public class Container extends Component
comp.parent.remove(comp);
comp.parent = this;
- // Notify the component that it has a new parent.
- comp.addNotify();
-
if (peer != null)
{
+ // Notify the component that it has a new parent.
+ comp.addNotify();
+
if (comp.isLightweight ())
{
enableEvents (comp.eventMask);
@@ -759,8 +760,7 @@ public class Container extends Component
{
if (!isShowing())
return;
- // Paint self first.
- super.paint(g);
+
// Visit heavyweights as well, in case they were
// erased when we cleared the background for this container.
visitChildren(g, GfxPaintVisitor.INSTANCE, false);
@@ -778,16 +778,25 @@ public class Container extends Component
* @specnote The specification suggests that this method forwards the
* update() call to all its lightweight children. Tests show
* that this is not done either in the JDK. The exact behaviour
- * seems to be that top-level container call super.update()
- * (causing the background to be cleared), and all other containers
+ * seems to be that the background is cleared in heavyweight
+ * Containers, and all other containers
* directly call paint(), causing the (lightweight) children to
* be painted.
*/
public void update(Graphics g)
{
- if (getParent() == null)
- super.update(g);
-
+ // It seems that the JDK clears the background of containers like Panel
+ // and Window (within this method) but not of 'plain' Containers or
+ // JComponents. This could
+ // lead to the assumption that it only clears heavyweight containers.
+ // However that is not quite true. In a test with a custom Container
+ // that overrides isLightweight() to return false, the background is
+ // also not cleared. So we do a check on !(peer instanceof LightweightPeer)
+ // instead.
+ ComponentPeer p = peer;
+ if (p != null && !(p instanceof LightweightPeer))
+ g.clearRect(0, 0, getWidth(), getHeight());
+
paint(g);
}
diff --git a/java/awt/image/ConvolveOp.java b/java/awt/image/ConvolveOp.java
index 9b89b6519..49ca2a6ea 100644
--- a/java/awt/image/ConvolveOp.java
+++ b/java/awt/image/ConvolveOp.java
@@ -1,5 +1,5 @@
/* ConvolveOp.java --
- Copyright (C) 2004 Free Software Foundation -- ConvolveOp
+ Copyright (C) 2004, 2005 Free Software Foundation -- ConvolveOp
This file is part of GNU Classpath.
@@ -191,8 +191,6 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest) {
- if (src.numBands != dest.numBands)
- throw new ImagingOpException(null);
if (src == dest)
throw new IllegalArgumentException();
if (src.getWidth() < kernel.getWidth() ||
@@ -201,6 +199,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
if (dest == null)
dest = createCompatibleDestRaster(src);
+ else if (src.numBands != dest.numBands)
+ throw new ImagingOpException(null);
// Deal with bottom edge
if (edge == EDGE_ZERO_FILL)
diff --git a/java/awt/peer/MenuBarPeer.java b/java/awt/peer/MenuBarPeer.java
index c5f7c581f..44e37e2d4 100644
--- a/java/awt/peer/MenuBarPeer.java
+++ b/java/awt/peer/MenuBarPeer.java
@@ -42,6 +42,7 @@ import java.awt.Menu;
public interface MenuBarPeer extends MenuComponentPeer
{
+ void addMenu(Menu m);
void addHelpMenu(Menu menu);
void delMenu(int index);
} // interface MenuBarPeer
diff --git a/java/awt/peer/MenuPeer.java b/java/awt/peer/MenuPeer.java
index c51ea73bb..91d0f0d11 100644
--- a/java/awt/peer/MenuPeer.java
+++ b/java/awt/peer/MenuPeer.java
@@ -43,6 +43,7 @@ import java.awt.MenuItem;
public interface MenuPeer extends MenuItemPeer
{
void addItem (MenuItem item);
+ void addSeparator ();
void delItem (int index);
}
diff --git a/java/io/ObjectInputStream.java b/java/io/ObjectInputStream.java
index 83e5ece67..f32703d09 100644
--- a/java/io/ObjectInputStream.java
+++ b/java/io/ObjectInputStream.java
@@ -508,8 +508,7 @@ public class ObjectInputStream extends InputStream
flags, fields);
assignNewHandle(osc);
- if (callersClassLoader == null)
- callersClassLoader = currentLoader();
+ ClassLoader callersClassLoader = currentLoader();
for (int i = 0; i < field_count; i++)
{
@@ -535,36 +534,7 @@ public class ObjectInputStream extends InputStream
/* Now that fields have been read we may resolve the class
* (and read annotation if needed). */
- Class clazz;
- try
- {
- clazz = resolveClass(osc);
- }
- catch (ClassNotFoundException cnfe)
- {
- // Maybe it was an primitive class?
- if (name.equals("void"))
- clazz = Void.TYPE;
- else if (name.equals("boolean"))
- clazz = Boolean.TYPE;
- else if (name.equals("byte"))
- clazz = Byte.TYPE;
- else if (name.equals("short"))
- clazz = Short.TYPE;
- else if (name.equals("char"))
- clazz = Character.TYPE;
- else if (name.equals("int"))
- clazz = Integer.TYPE;
- else if (name.equals("long"))
- clazz = Long.TYPE;
- else if (name.equals("float"))
- clazz = Float.TYPE;
- else if (name.equals("double"))
- clazz = Double.TYPE;
- else
- throw cnfe;
- }
-
+ Class clazz = resolveClass(osc);
boolean oldmode = setBlockDataMode(true);
osc.setClass(clazz, lookupClass(clazz.getSuperclass()));
classLookupTable.put(clazz, osc);
@@ -777,16 +747,34 @@ public class ObjectInputStream extends InputStream
protected Class resolveClass(ObjectStreamClass osc)
throws ClassNotFoundException, IOException
{
- if (callersClassLoader == null)
+ String name = osc.getName();
+ try
{
- callersClassLoader = currentLoader ();
- if (DEBUG && dump)
- {
- dumpElementln ("CallersClassLoader = " + callersClassLoader);
- }
+ return Class.forName(name, true, currentLoader());
+ }
+ catch(ClassNotFoundException x)
+ {
+ if (name.equals("void"))
+ return Void.TYPE;
+ else if (name.equals("boolean"))
+ return Boolean.TYPE;
+ else if (name.equals("byte"))
+ return Byte.TYPE;
+ else if (name.equals("char"))
+ return Character.TYPE;
+ else if (name.equals("short"))
+ return Short.TYPE;
+ else if (name.equals("int"))
+ return Integer.TYPE;
+ else if (name.equals("long"))
+ return Long.TYPE;
+ else if (name.equals("float"))
+ return Float.TYPE;
+ else if (name.equals("double"))
+ return Double.TYPE;
+ else
+ throw x;
}
-
- return Class.forName(osc.getName(), true, callersClassLoader);
}
/**
@@ -1282,7 +1270,7 @@ public class ObjectInputStream extends InputStream
}
catch (NoSuchFieldException e)
{
- throw new IllegalArgumentException(e.getMessage());
+ throw new IllegalArgumentException(e);
}
}
@@ -1427,6 +1415,7 @@ public class ObjectInputStream extends InputStream
ObjectStreamField field = clazz.getField(name);
boolean illegal = false;
+ // XXX This code is horrible and needs to be rewritten!
try
{
try
@@ -1486,7 +1475,7 @@ public class ObjectInputStream extends InputStream
catch (NoSuchFieldException e)
{
if (field == null)
- throw new IllegalArgumentException(e.getMessage());
+ throw new IllegalArgumentException(e);
}
}
@@ -1830,8 +1819,8 @@ public class ObjectInputStream extends InputStream
}
catch (InstantiationException e)
{
- throw new ClassNotFoundException
- ("Instance of " + real_class + " could not be created");
+ throw (ClassNotFoundException) new ClassNotFoundException
+ ("Instance of " + real_class + " could not be created").initCause(e);
}
}
@@ -1872,13 +1861,13 @@ public class ObjectInputStream extends InputStream
if (exception instanceof ClassNotFoundException)
throw (ClassNotFoundException) exception;
- throw new IOException("Exception thrown from readObject() on " +
- klass + ": " + exception.getClass().getName());
+ throw (IOException) new IOException(
+ "Exception thrown from readObject() on " + klass).initCause(x);
}
catch (Exception x)
{
- throw new IOException("Failure invoking readObject() on " +
- klass + ": " + x.getClass().getName());
+ throw (IOException) new IOException(
+ "Failure invoking readObject() on " + klass).initCause(x);
}
// Invalidate fields which has been read through readFields.
@@ -1906,7 +1895,6 @@ public class ObjectInputStream extends InputStream
private Hashtable<Class,ObjectStreamClass> classLookupTable;
private GetField prereadFields;
- private ClassLoader callersClassLoader;
private static boolean dump;
// The nesting depth for debugging output
diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java
index 8596b7f80..875ddc778 100644
--- a/java/net/DatagramSocket.java
+++ b/java/net/DatagramSocket.java
@@ -1,5 +1,5 @@
/* DatagramSocket.java -- A class to model UDP sockets
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.net;
+import gnu.classpath.SystemProperties;
+
import gnu.java.net.PlainDatagramSocketImpl;
import gnu.java.nio.DatagramChannelImpl;
@@ -172,7 +174,7 @@ public class DatagramSocket
*/
public DatagramSocket(SocketAddress address) throws SocketException
{
- String propVal = System.getProperty("impl.prefix");
+ String propVal = SystemProperties.getProperty("impl.prefix");
if (propVal == null || propVal.equals(""))
impl = new PlainDatagramSocketImpl();
else
diff --git a/java/net/NetworkInterface.java b/java/net/NetworkInterface.java
index eccd2dac9..47b1c67ca 100644
--- a/java/net/NetworkInterface.java
+++ b/java/net/NetworkInterface.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package java.net;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Vector;
/**
@@ -143,9 +148,7 @@ public final class NetworkInterface
public static NetworkInterface getByName(String name)
throws SocketException
{
- Vector networkInterfaces = VMNetworkInterface.getInterfaces();
-
- for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();)
+ for (Enumeration e = getNetworkInterfaces(); e.hasMoreElements();)
{
NetworkInterface tmp = (NetworkInterface) e.nextElement();
@@ -170,9 +173,7 @@ public final class NetworkInterface
public static NetworkInterface getByInetAddress(InetAddress addr)
throws SocketException
{
- Vector networkInterfaces = VMNetworkInterface.getInterfaces();
-
- for (Enumeration interfaces = networkInterfaces.elements();
+ for (Enumeration interfaces = getNetworkInterfaces();
interfaces.hasMoreElements();)
{
NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
@@ -188,6 +189,41 @@ public final class NetworkInterface
throw new SocketException("no network interface is bound to such an IP address");
}
+ static private Collection condense(Collection interfaces)
+ {
+ final Map condensed = new HashMap();
+
+ final Iterator interfs = interfaces.iterator();
+ while (interfs.hasNext()) {
+
+ final NetworkInterface face = (NetworkInterface) interfs.next();
+ final String name = face.getName();
+
+ if (condensed.containsKey(name))
+ {
+ final NetworkInterface conface = (NetworkInterface) condensed.get(name);
+ if (!conface.inetAddresses.containsAll(face.inetAddresses))
+ {
+ final Iterator faceAddresses = face.inetAddresses.iterator();
+ while (faceAddresses.hasNext())
+ {
+ final InetAddress faceAddress = (InetAddress) faceAddresses.next();
+ if (!conface.inetAddresses.contains(faceAddress))
+ {
+ conface.inetAddresses.add(faceAddress);
+ }
+ }
+ }
+ }
+ else
+ {
+ condensed.put(name, face);
+ }
+ }
+
+ return condensed.values();
+ }
+
/**
* Return an <code>Enumeration</code> of all available network interfaces
*
@@ -202,7 +238,9 @@ public final class NetworkInterface
if (networkInterfaces.isEmpty())
return null;
- return networkInterfaces.elements();
+ Collection condensed = condense(networkInterfaces);
+
+ return Collections.enumeration(condensed);
}
/**
diff --git a/java/net/URLClassLoader.java b/java/net/URLClassLoader.java
index d84d7ab2a..85b385781 100644
--- a/java/net/URLClassLoader.java
+++ b/java/net/URLClassLoader.java
@@ -900,7 +900,11 @@ public class URLClassLoader extends SecureClassLoader
else
result = defineClass(className, classData, 0, classData.length, source);
- super.setSigners(result, resource.getCertificates());
+ // Avoid NullPointerExceptions.
+ Certificate[] resourceCertificates = resource.getCertificates();
+ if(resourceCertificates != null)
+ super.setSigners(result, resourceCertificates);
+
return result;
}
catch (IOException ioe)
diff --git a/java/security/KeyPairGenerator.java b/java/security/KeyPairGenerator.java
index e6f926e2b..a6e010be2 100644
--- a/java/security/KeyPairGenerator.java
+++ b/java/security/KeyPairGenerator.java
@@ -1,5 +1,5 @@
/* KeyPairGenerator.java --- Key Pair Generator Class
- Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -300,7 +300,6 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
*/
public void initialize(int keysize, SecureRandom random)
{
- initialize(keysize, random);
}
/**
diff --git a/java/util/Observable.java b/java/util/Observable.java
index 4c2cddb54..916abe4ac 100644
--- a/java/util/Observable.java
+++ b/java/util/Observable.java
@@ -77,6 +77,8 @@ public class Observable
*/
public synchronized void addObserver(Observer observer)
{
+ if (observer == null)
+ throw new NullPointerException("can't add null observer");
observers.add(observer);
}
diff --git a/java/util/logging/Logger.java b/java/util/logging/Logger.java
index ae985a93c..367faad97 100644
--- a/java/util/logging/Logger.java
+++ b/java/util/logging/Logger.java
@@ -577,7 +577,8 @@ public class Logger
public void log(Level level, String message)
{
- log(level, message, (Object[]) null);
+ if (isLoggable(level))
+ log(level, message, (Object[]) null);
}
@@ -585,12 +586,15 @@ public class Logger
String message,
Object param)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- param);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ param);
+ }
}
@@ -598,12 +602,15 @@ public class Logger
String message,
Object[] params)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- params);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ params);
+ }
}
@@ -611,12 +618,15 @@ public class Logger
String message,
Throwable thrown)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- thrown);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ thrown);
+ }
}
diff --git a/javax/imageio/spi/IIORegistry.java b/javax/imageio/spi/IIORegistry.java
index a0e111290..2024a69b0 100644
--- a/javax/imageio/spi/IIORegistry.java
+++ b/javax/imageio/spi/IIORegistry.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package javax.imageio.spi;
import gnu.classpath.ServiceFactory;
-import gnu.java.awt.ClasspathToolkit;
import java.awt.Toolkit;
import java.util.HashMap;
@@ -82,8 +81,6 @@ public final class IIORegistry extends ServiceRegistry
// XXX: Register built-in Spis here.
Toolkit toolkit = Toolkit.getDefaultToolkit();
- if (toolkit instanceof ClasspathToolkit)
- ((ClasspathToolkit)toolkit).registerImageIOSpis(this);
registerApplicationClasspathSpis();
}
diff --git a/javax/security/auth/x500/X500Principal.java b/javax/security/auth/x500/X500Principal.java
index dbe8b9c86..78c35ade1 100644
--- a/javax/security/auth/x500/X500Principal.java
+++ b/javax/security/auth/x500/X500Principal.java
@@ -274,7 +274,7 @@ public final class X500Principal implements Principal, Serializable
Set rdn = new HashSet();
for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
{
- Map.Entry e = (Map.Entry) it.next();
+ Map.Entry e = (Map.Entry) it2.next();
ArrayList atav = new ArrayList(2);
atav.add(new DERValue(DER.OBJECT_IDENTIFIER, e.getKey()));
atav.add(new DERValue(DER.UTF8_STRING, e.getValue()));
@@ -300,6 +300,8 @@ public final class X500Principal implements Principal, Serializable
putComponent(key, value);
if (sep == ',')
newRelativeDistinguishedName();
+ if (sep == -1)
+ break;
}
}
@@ -312,7 +314,7 @@ public final class X500Principal implements Principal, Serializable
if (ch == -1)
{
if (buf.length() > 0)
- throw new EOFException();
+ throw new EOFException("partial name read: " + buf);
return null;
}
if (ch > 127)
@@ -416,10 +418,12 @@ public final class X500Principal implements Principal, Serializable
case ';':
throw new IOException("illegal character: " + (char) ch);
case -1:
- throw new EOFException();
+ sep = -1;
+ return buf.toString ();
default:
buf.append((char) ch);
}
+ ch = in.read ();
}
}
}
@@ -484,6 +488,10 @@ public final class X500Principal implements Principal, Serializable
putComponent(STREET, value);
else if (name.equals("st"))
putComponent(ST, value);
+ else if (name.equals ("o"))
+ putComponent (O, value);
+ else if (name.equals ("ou"))
+ putComponent (OU, value);
else if (name.equals("dc"))
putComponent(DC, value);
else if (name.equals("uid"))
diff --git a/javax/swing/DefaultCellEditor.java b/javax/swing/DefaultCellEditor.java
index 52d2e5254..c1c016a27 100644
--- a/javax/swing/DefaultCellEditor.java
+++ b/javax/swing/DefaultCellEditor.java
@@ -43,9 +43,13 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.awt.event.MouseEvent;
import java.io.Serializable;
import java.util.EventObject;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;
import javax.swing.tree.TreeCellEditor;
@@ -91,8 +95,10 @@ public class DefaultCellEditor
*
* @param event TODO
*/
- public void setValue(Object event)
+ public void setValue(Object value)
{
+ // TODO: should be setting the value in the editorComp
+ this.value = value;
}
/**
@@ -102,7 +108,8 @@ public class DefaultCellEditor
*/
public Object getCellEditorValue()
{
- return null; // TODO
+ // TODO: should be getting the updated value from the editorComp
+ return value;
} // getCellEditorValue()
/**
@@ -114,7 +121,11 @@ public class DefaultCellEditor
*/
public boolean isCellEditable(EventObject event)
{
- return false; // TODO
+ if (!(event instanceof MouseEvent))
+ return true;
+
+ //Todo: if the right number of clicks has occured, return true;
+ return false;
} // isCellEditable()
/**
@@ -126,7 +137,8 @@ public class DefaultCellEditor
*/
public boolean shouldSelectCell(EventObject event)
{
- return false; // TODO
+ // return true to indicate that the editing cell may be selected
+ return true;
} // shouldSelectCell()
/**
@@ -136,7 +148,8 @@ public class DefaultCellEditor
*/
public boolean stopCellEditing()
{
- return false; // TODO
+ fireEditingStopped();
+ return true;
} // stopCellEditing()
/**
@@ -144,7 +157,7 @@ public class DefaultCellEditor
*/
public void cancelCellEditing()
{
- // TODO
+ fireEditingCanceled();
} // cancelCellEditing()
/**
@@ -156,7 +169,8 @@ public class DefaultCellEditor
*/
public boolean startCellEditing(EventObject event)
{
- return false; // TODO
+ // return true to indicate that editing has begun
+ return true;
} // startCellEditing()
/**
@@ -166,7 +180,7 @@ public class DefaultCellEditor
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ stopCellEditing();
} // actionPerformed()
/**
@@ -176,9 +190,23 @@ public class DefaultCellEditor
*/
public void itemStateChanged(ItemEvent event)
{
- // TODO
+ stopCellEditing();
} // itemStateChanged()
+ void fireEditingStopped()
+ {
+ CellEditorListener[] listeners = getCellEditorListeners();
+ for (int index = 0; index < listeners.length; index++)
+ listeners[index].editingStopped(changeEvent);
+
+ }
+
+ void fireEditingCanceled()
+ {
+ CellEditorListener[] listeners = getCellEditorListeners();
+ for (int index = 0; index < listeners.length; index++)
+ listeners[index].editingCanceled(changeEvent);
+ }
} // EditorDelegate
/**
@@ -203,7 +231,8 @@ public class DefaultCellEditor
*/
public DefaultCellEditor(JTextField textfield)
{
- // TODO
+ editorComponent = textfield;
+ clickCountToStart = 2;
} // DefaultCellEditor()
/**
@@ -213,7 +242,8 @@ public class DefaultCellEditor
*/
public DefaultCellEditor(JCheckBox checkbox)
{
- // TODO
+ editorComponent = checkbox;
+ clickCountToStart = 1;
} // DefaultCellEditor()
/**
@@ -223,7 +253,8 @@ public class DefaultCellEditor
*/
public DefaultCellEditor(JComboBox combobox)
{
- // TODO
+ editorComponent = combobox;
+ clickCountToStart = 1;
} // DefaultCellEditor()
/**
@@ -233,7 +264,7 @@ public class DefaultCellEditor
*/
public Component getComponent()
{
- return null; // TODO
+ return editorComponent;
} // getComponent()
/**
@@ -243,7 +274,7 @@ public class DefaultCellEditor
*/
public int getClickCountToStart()
{
- return 0; // TODO
+ return clickCountToStart;
} // getClickCountToStart()
/**
@@ -253,7 +284,7 @@ public class DefaultCellEditor
*/
public void setClickCountToStart(int count)
{
- // TODO
+ clickCountToStart = count;
} // setClickCountToStart()
/**
@@ -263,7 +294,7 @@ public class DefaultCellEditor
*/
public Object getCellEditorValue()
{
- return null; // TODO
+ return delegate.getCellEditorValue();
} // getCellEditorValue()
/**
@@ -275,7 +306,7 @@ public class DefaultCellEditor
*/
public boolean isCellEditable(EventObject event)
{
- return false; // TODO
+ return delegate.isCellEditable(event);
} // isCellEditable()
/**
@@ -287,7 +318,7 @@ public class DefaultCellEditor
*/
public boolean shouldSelectCell(EventObject event)
{
- return false; // TODO
+ return delegate.shouldSelectCell(event);
} // shouldSelectCell()
/**
@@ -297,7 +328,7 @@ public class DefaultCellEditor
*/
public boolean stopCellEditing()
{
- return false; // TODO
+ return delegate.stopCellEditing();
} // stopCellEditing()
/**
@@ -305,7 +336,7 @@ public class DefaultCellEditor
*/
public void cancelCellEditing()
{
- // TODO
+ delegate.cancelCellEditing();
} // cancelCellEditing()
/**
@@ -339,10 +370,30 @@ public class DefaultCellEditor
*
* @returns Component
*/
- public Component getTableCellEditorComponent(JTable tree, Object value,
+ public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row,
int column)
{
- return null; // TODO
+ // NOTE: as specified by Sun, we don't call new() everytime, we return
+ // editorComponent on each call to getTableCellEditorComponent or
+ // getTreeCellEditorComponent. However, currently JTextFields have a
+ // problem with getting rid of old text, so without calling new() there
+ // are some strange results. If you edit more than one cell in the table
+ // text from previously edited cells may unexpectedly show up in the
+ // cell you are currently editing. This will be fixed automatically
+ // when JTextField is fixed.
+ if (editorComponent instanceof JTextField)
+ {
+ ((JTextField)editorComponent).setText(value.toString());
+ delegate = new EditorDelegate();
+ ((JTextField)editorComponent).addActionListener(delegate);
+ }
+ else
+ {
+ // TODO
+ }
+ return editorComponent;
} // getTableCellEditorComponent()
+
+
}
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index e683d509f..1c63c3b37 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -43,9 +43,14 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Date;
+import java.util.EventObject;
import java.util.Hashtable;
import java.util.Vector;
@@ -69,6 +74,7 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
+import javax.swing.text.Caret;
public class JTable extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener,
@@ -351,6 +357,7 @@ public class JTable extends JComponent
*/
protected transient Component editorComp;
+
/**
* Whether or not the table should automatically compute a matching
* {@link TableColumnModel} and assign it to the {@link #columnModel}
@@ -555,7 +562,27 @@ public class JTable extends JComponent
*/
protected JTableHeader tableHeader;
-
+ /**
+ * The row of the cell being edited.
+ */
+ int rowBeingEdited = -1;
+
+ /**
+ * The column of the cell being edited.
+ */
+ int columnBeingEdited = -1;
+
+ /**
+ * The action listener for the editor's Timer.
+ */
+ Timer editorTimer = new EditorUpdateTimer();
+
+ /**
+ * Stores the old value of a cell before it was edited, in case
+ * editing is cancelled
+ */
+ Object oldCellValue;
+
/**
* Creates a new <code>JTable</code> instance.
*/
@@ -673,6 +700,51 @@ public class JTable extends JComponent
this(new DefaultTableModel(data, columnNames));
}
+ /**
+ * The timer that updates the editor component.
+ */
+ private class EditorUpdateTimer
+ extends Timer
+ implements ActionListener
+ {
+ /**
+ * Creates a new EditorUpdateTimer object with a default delay of 0.5 seconds.
+ */
+ public EditorUpdateTimer()
+ {
+ super(500, null);
+ addActionListener(this);
+ }
+
+ /**
+ * Lets the caret blink and repaints the table.
+ */
+ public void actionPerformed(ActionEvent ev)
+ {
+ Caret c = ((JTextField)JTable.this.editorComp).getCaret();
+ if (c != null)
+ c.setVisible(!c.isVisible());
+ JTable.this.repaint();
+ }
+
+ /**
+ * Updates the blink delay according to the current caret.
+ */
+ public void update()
+ {
+ stop();
+ Caret c = ((JTextField)JTable.this.editorComp).getCaret();
+ if (c != null)
+ {
+ setDelay(c.getBlinkRate());
+ if (((JTextField)JTable.this.editorComp).isEditable())
+ start();
+ else
+ c.setVisible(false);
+ }
+ }
+ }
+
public void addColumn(TableColumn column)
{
if (column.getHeaderValue() == null)
@@ -774,11 +846,40 @@ public class JTable extends JComponent
public void editingCanceled (ChangeEvent event)
{
+ if (rowBeingEdited > -1 && columnBeingEdited > -1)
+ {
+ if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField)
+ {
+ remove ((Component)getValueAt(rowBeingEdited, columnBeingEdited));
+ setValueAt(oldCellValue, rowBeingEdited, columnBeingEdited);
+ }
+ rowBeingEdited = -1;
+ columnBeingEdited = -1;
+ }
+ editorTimer.stop();
+ editorComp = null;
+ cellEditor = null;
+ requestFocusInWindow(false);
repaint();
}
public void editingStopped (ChangeEvent event)
{
+ if (rowBeingEdited > -1 && columnBeingEdited > -1)
+ {
+ if (getValueAt(rowBeingEdited, columnBeingEdited) instanceof JTextField)
+ {
+ remove((Component)getValueAt(rowBeingEdited, columnBeingEdited));
+ setValueAt(((JTextField)editorComp).getText(),
+ rowBeingEdited, columnBeingEdited);
+ }
+ rowBeingEdited = -1;
+ columnBeingEdited = -1;
+ }
+ editorTimer.stop();
+ editorComp = null;
+ cellEditor = null;
+ requestFocusInWindow(false);
repaint();
}
@@ -809,20 +910,23 @@ public class JTable extends JComponent
*/
public int columnAtPoint(Point point)
{
- int x0 = getLocation().x;
- int ncols = getColumnCount();
- Dimension gap = getIntercellSpacing();
- TableColumnModel cols = getColumnModel();
- int x = point.x;
-
- for (int i = 0; i < ncols; ++i)
+ if (point != null)
{
- int width = cols.getColumn(i).getWidth() + (gap == null ? 0 : gap.width);
- if (0 <= x && x < width)
- return i;
- x -= width;
+ int x0 = getLocation().x;
+ int ncols = getColumnCount();
+ Dimension gap = getIntercellSpacing();
+ TableColumnModel cols = getColumnModel();
+ int x = point.x;
+
+ for (int i = 0; i < ncols; ++i)
+ {
+ int width = cols.getColumn(i).getWidth()
+ + (gap == null ? 0 : gap.width);
+ if (0 <= x && x < width)
+ return i;
+ x -= width;
+ }
}
-
return -1;
}
@@ -836,19 +940,21 @@ public class JTable extends JComponent
*/
public int rowAtPoint(Point point)
{
- int y0 = getLocation().y;
- int nrows = getRowCount();
- Dimension gap = getIntercellSpacing();
- int height = getRowHeight() + (gap == null ? 0 : gap.height);
- int y = point.y;
-
- for (int i = 0; i < nrows; ++i)
+ if (point != null)
{
- if (0 <= y && y < height)
- return i;
- y -= height;
+ int y0 = getLocation().y;
+ int nrows = getRowCount();
+ Dimension gap = getIntercellSpacing();
+ int height = getRowHeight() + (gap == null ? 0 : gap.height);
+ int y = point.y;
+
+ for (int i = 0; i < nrows; ++i)
+ {
+ if (0 <= y && y < height)
+ return i;
+ y -= height;
+ }
}
-
return -1;
}
@@ -980,7 +1086,7 @@ public class JTable extends JComponent
if (editor == null)
editor = getDefaultEditor(dataModel.getColumnClass(column));
-
+
return editor;
}
@@ -1475,7 +1581,7 @@ public class JTable extends JComponent
*/
public void setRowHeight(int r)
{
- if (rowHeight < 1)
+ if (r < 1)
throw new IllegalArgumentException();
rowHeight = r;
@@ -1490,7 +1596,7 @@ public class JTable extends JComponent
* @param rh is the new rowHeight
* @param row is the row to change the rowHeight of
*/
- public void setRowHeight(int rh, int row)
+ public void setRowHeight(int row, int rh)
{
setRowHeight(rh);
// FIXME: not implemented
@@ -2116,6 +2222,11 @@ public class JTable extends JComponent
public void setValueAt(Object value, int row, int column)
{
+ if (!isCellEditable(row, column))
+ return;
+
+ if (value instanceof Component)
+ add((Component)value);
dataModel.setValueAt(value, row, convertColumnIndexToModel(column));
}
@@ -2207,4 +2318,58 @@ public class JTable extends JComponent
}
}
+
+ /**
+ * Programmatically starts editing the specified cell.
+ *
+ * @param row the row of the cell to edit.
+ * @param column the column of the cell to edit.
+ */
+ public boolean editCellAt (int row, int column)
+ {
+ oldCellValue = getValueAt(row, column);
+ setCellEditor(getCellEditor(row, column));
+ editorComp = prepareEditor(cellEditor, row, column);
+ cellEditor.addCellEditorListener(this);
+ rowBeingEdited = row;
+ columnBeingEdited = column;
+ setValueAt(editorComp, row, column);
+ ((JTextField)editorComp).requestFocusInWindow(false);
+ editorTimer.start();
+ return true;
+ }
+
+ /**
+ * Programmatically starts editing the specified cell.
+ *
+ * @param row the row of the cell to edit.
+ * @param column the column of the cell to edit.
+ */
+ public boolean editCellAt (int row, int column, EventObject e)
+ {
+ return editCellAt(row, column);
+ }
+
+ /**
+ * Discards the editor object.
+ */
+ public void removeEditor()
+ {
+ editingStopped(new ChangeEvent(this));
+ }
+
+ /**
+ * Prepares the editor by querying for the value and selection state of the
+ * cell at (row, column).
+ *
+ * @param editor the TableCellEditor to set up
+ * @param row the row of the cell to edit
+ * @param column the column of the cell to edit
+ * @return the Component being edited
+ */
+ public Component prepareEditor (TableCellEditor editor, int row, int column)
+ {
+ return editor.getTableCellEditorComponent
+ (this, getValueAt(row, column), isCellSelected(row, column), row, column);
+ }
}
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 638f28ff3..e5de57550 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -775,16 +775,17 @@ public class JTree
{
if (treeModel == model)
return;
-
- TreeModel oldValue = treeModel;
- treeModel = model;
-
- firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
-
+
// add treeModelListener to the new model
if (treeModelListener == null)
treeModelListener = createTreeModelListener();
- model.addTreeModelListener(treeModelListener);
+ if (model != null) // as setModel(null) is allowed
+ model.addTreeModelListener(treeModelListener);
+
+ TreeModel oldValue = treeModel;
+ treeModel = model;
+
+ firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
}
/**
@@ -1296,7 +1297,7 @@ public class JTree
// Don't expand if last path component is a leaf node.
if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))
return;
-
+
setExpandedState(path, true);
}
@@ -1502,21 +1503,9 @@ public class JTree
return null;
}
- private void checkExpandParents(TreePath path) throws ExpandVetoException
- {
-
- TreePath parent = path.getParentPath();
-
- if (parent != null)
- checkExpandParents(parent);
-
- fireTreeWillExpand(path);
- }
-
private void doExpandParents(TreePath path, boolean state)
{
- TreePath parent = path.getParentPath();
-
+ TreePath parent = path.getParentPath();
if (isExpanded(parent))
{
nodeStates.put(path, state ? EXPANDED : COLLAPSED);
@@ -1536,17 +1525,6 @@ public class JTree
TreePath parent = path.getParentPath();
- try
- {
- if (parent != null)
- checkExpandParents(parent);
- }
- catch (ExpandVetoException e)
- {
- // Expansion vetoed.
- return;
- }
-
doExpandParents(path, state);
}
diff --git a/javax/swing/plaf/basic/BasicLabelUI.java b/javax/swing/plaf/basic/BasicLabelUI.java
index e71e82f03..16c132dfc 100644
--- a/javax/swing/plaf/basic/BasicLabelUI.java
+++ b/javax/swing/plaf/basic/BasicLabelUI.java
@@ -1,39 +1,39 @@
/* BasicLabelUI.java
- Copyright (C) 2002, 2004 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. */
+ Copyright (C) 2002, 2004 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.basic;
@@ -56,12 +56,13 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
-
/**
* This is the Basic Look and Feel class for the JLabel. One BasicLabelUI
* object is used to paint all JLabels that utilize the Basic Look and Feel.
*/
-public class BasicLabelUI extends LabelUI implements PropertyChangeListener
+public class BasicLabelUI
+ extends LabelUI
+ implements PropertyChangeListener
{
/** The labelUI that is shared by all labels. */
protected static BasicLabelUI labelUI;
@@ -99,20 +100,20 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
*
* @return The preferred size.
*/
- public Dimension getPreferredSize(JComponent c)
+ public Dimension getPreferredSize(JComponent c)
{
- JLabel lab = (JLabel)c;
+ JLabel lab = (JLabel) c;
Rectangle vr = new Rectangle();
Rectangle ir = new Rectangle();
Rectangle tr = new Rectangle();
- Insets insets = lab.getInsets();
+ Insets insets = lab.getInsets();
FontMetrics fm = lab.getToolkit().getFontMetrics(lab.getFont());
layoutCL(lab, fm, lab.getText(), lab.getIcon(), vr, ir, tr);
Rectangle cr = tr.union(ir);
- return new Dimension(insets.left + cr.width + insets.right,
- insets.top + cr.height + insets.bottom);
-
- }
+ return new Dimension(insets.left + cr.width + insets.right, insets.top
+ + cr.height + insets.bottom);
+
+ }
/**
* This method returns the minimum size of the {@link JComponent} given. If
@@ -144,7 +145,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
/**
* The method that paints the label according to its current state.
- *
+ *
* @param g The {@link Graphics} object to paint with.
* @param c The {@link JComponent} to paint.
*/
@@ -169,26 +170,39 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
vr.width = 0;
if (vr.height < 0)
vr.height = 0;
-
+
Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
String text = layoutCL(b, fm, b.getText(), icon, vr, ir, tr);
-
+
if (icon != null)
- icon.paintIcon(b, g, ir.x, ir.y);
- if (text != null && ! text.equals(""))
+ icon.paintIcon(b, g, ir.x, ir.y);
+ if (text != null && !text.equals(""))
+ {
+ g.setColor(b.getBackground());
+
+ if (b.isOpaque())
+ g.fillRect(vr.x, vr.y, vr.width, vr.height);
+ else
{
- if (b.isEnabled())
- paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
- else
- paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+ g.fillRect(tr.x, tr.y, tr.width, tr.height);
+ if (b.getBorder() != null)
+ b.getBorder().paintBorder(b, g, tr.x, tr.y, tr.width, tr.height);
+ b.setBorder(null);
}
+
+ if (b.isEnabled())
+ paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+ else
+ paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+ }
+
g.setFont(saved_font);
}
/**
* This method is simply calls SwingUtilities's layoutCompoundLabel.
- *
+ *
* @param label The label to lay out.
* @param fontMetrics The FontMetrics for the font used.
* @param text The text to paint.
@@ -196,20 +210,16 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* @param viewR The entire viewable rectangle.
* @param iconR The icon bounds rectangle.
* @param textR The text bounds rectangle.
- *
+ *
* @return A possibly clipped version of the text.
*/
- protected String layoutCL(JLabel label, FontMetrics fontMetrics,
- String text, Icon icon, Rectangle viewR,
- Rectangle iconR, Rectangle textR)
+ protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text,
+ Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
{
return SwingUtilities.layoutCompoundLabel(label, fontMetrics, text, icon,
- label.getVerticalAlignment(),
- label.getHorizontalAlignment(),
- label.getVerticalTextPosition(),
- label.getHorizontalTextPosition(),
- viewR, iconR, textR,
- label.getIconTextGap());
+ label.getVerticalAlignment(), label.getHorizontalAlignment(), label
+ .getVerticalTextPosition(), label.getHorizontalTextPosition(),
+ viewR, iconR, textR, label.getIconTextGap());
}
/**
@@ -225,7 +235,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* @param textY The y coordinate of the start of the baseline.
*/
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
- int textY)
+ int textY)
{
Color saved_color = g.getColor();
@@ -235,14 +245,14 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
if (mnemIndex != -1)
BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
- textY);
+ textY);
else
g.drawString(s, textX, textY);
g.setColor(l.getBackground().darker());
if (mnemIndex != -1)
BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX + 1,
- textY + 1);
+ textY + 1);
else
g.drawString(s, textX + 1, textY + 1);
@@ -260,7 +270,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* @param textY The y coordinate of the start of the baseline.
*/
protected void paintEnabledText(JLabel l, Graphics g, String s, int textX,
- int textY)
+ int textY)
{
Color saved_color = g.getColor();
g.setColor(l.getForeground());
@@ -269,7 +279,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
if (mnemIndex != -1)
BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
- textY);
+ textY);
else
g.drawString(s, textX, textY);
@@ -287,14 +297,14 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
{
super.installUI(c);
if (c instanceof JLabel)
- {
- JLabel l = (JLabel) c;
-
- installComponents(l);
- installDefaults(l);
- installListeners(l);
- installKeyboardActions(l);
- }
+ {
+ JLabel l = (JLabel) c;
+
+ installComponents(l);
+ installDefaults(l);
+ installListeners(l);
+ installKeyboardActions(l);
+ }
}
/**
@@ -308,14 +318,14 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
{
super.uninstallUI(c);
if (c instanceof JLabel)
- {
- JLabel l = (JLabel) c;
-
- uninstallKeyboardActions(l);
- uninstallListeners(l);
- uninstallDefaults(l);
- uninstallComponents(l);
- }
+ {
+ JLabel l = (JLabel) c;
+
+ uninstallKeyboardActions(l);
+ uninstallListeners(l);
+ uninstallDefaults(l);
+ uninstallComponents(l);
+ }
}
/**
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 2161d5d97..3d84e5ad3 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -886,13 +886,24 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"shift KP_DOWN", "selectNextRowExtendSelection",
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
"ESCAPE", "cancel",
- "ctrl shift PAGE_UP", "scrollRightExtendSelection",
+ "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
"shift KP_RIGHT", " selectNextColumnExtendSelection",
"ctrl PAGE_UP", "scrollLeftChangeSelection",
"shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
+ "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
"ctrl PAGE_DOWN", "scrollRightChangeSelection",
- "PAGE_UP", "scrollUpChangeSelection"
+ "PAGE_UP", "scrollUpChangeSelection",
+ "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift UP", "selectPreviousRowExtendSelection",
+ "ctrl shift RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift DOWN", "selectNextRowExtendSelection",
+ "ctrl BACK_SLASH", "clearSelection",
+ "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl SLASH", "selectAll",
+ "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
}),
"Table.background", new ColorUIResource(light),
"Table.focusCellBackground", new ColorUIResource(light),
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index ff7e8acfb..fd7224757 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -1337,9 +1337,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public int getMinimumDividerLocation(JSplitPane jc)
{
- int value = layoutManager.getInitialLocation(jc.getInsets());
- if (layoutManager.components[0] != null)
- value += layoutManager.minimumSizeOfComponent(0);
+ int value = layoutManager.getInitialLocation(jc.getInsets())
+ - layoutManager.getAvailableSize(jc.getSize(), jc.getInsets())
+ + splitPane.getDividerSize();
+ if (layoutManager.components[1] != null)
+ value += layoutManager.minimumSizeOfComponent(1);
return value;
}
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index d13373008..9312d13dc 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -45,6 +45,7 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
@@ -52,14 +53,19 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
+import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.CellRendererPane;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
+import javax.swing.event.ChangeEvent;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TableUI;
@@ -87,6 +93,9 @@ public class BasicTableUI
/** The cell border for selected/highlighted cells. */
Border highlightCellBorder;
+ /** The action bound to KeyStrokes. */
+ TableAction action;
+
class FocusHandler implements FocusListener
{
public void focusGained(FocusEvent e)
@@ -97,174 +106,202 @@ public class BasicTableUI
}
}
- class KeyHandler implements KeyListener
+ class MouseInputHandler implements MouseInputListener
{
+ Point begin, curr;
- /**
- * A helper method for the keyPressed event. Used because the actions
- * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
- *
- * Selects the next (previous if SHIFT pressed) column for TAB, or row for
- * ENTER from within the currently selected cells.
- *
- * @param firstModel the ListSelectionModel for columns (TAB) or
- * rows (ENTER)
- * @param firstMin the first selected index in firstModel
- * @param firstMax the last selected index in firstModel
- * @param secondModel the ListSelectionModel for rows (TAB) or
- * columns (ENTER)
- * @param secondMin the first selected index in secondModel
- * @param secondMax the last selected index in secondModel
- * @param reverse true if shift was held for the event
- * @param eventIsTab true if TAB was pressed, false if ENTER pressed
- */
- void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin,
- int firstMax, ListSelectionModel secondModel,
- int secondMin, int secondMax, boolean reverse,
- boolean eventIsTab)
+ private void updateSelection(boolean controlPressed)
{
- // If eventIsTab, all the "firsts" correspond to columns, otherwise, to rows
- // "seconds" correspond to the opposite
- int firstLead = firstModel.getLeadSelectionIndex();
- int secondLead = secondModel.getLeadSelectionIndex();
- int numFirsts = eventIsTab ?
- table.getModel().getColumnCount() : table.getModel().getRowCount();
- int numSeconds = eventIsTab ?
- table.getModel().getRowCount() : table.getModel().getColumnCount();
-
- // check if we have to wrap the "firsts" around, going to the other side
- if ((firstLead == firstMax && !reverse) ||
- (reverse && firstLead == firstMin))
+ // Update the rows
+ int lo_row = table.rowAtPoint(begin);
+ int hi_row = table.rowAtPoint(curr);
+ ListSelectionModel rowModel = table.getSelectionModel();
+ if (lo_row != -1 && hi_row != -1)
{
- firstModel.addSelectionInterval(reverse ? firstMax : firstMin,
- reverse ? firstMax : firstMin);
-
- // check if we have to wrap the "seconds"
- if ((secondLead == secondMax && !reverse) ||
- (reverse && secondLead == secondMin))
- secondModel.addSelectionInterval(reverse ? secondMax : secondMin,
- reverse ? secondMax : secondMin);
-
- // if we're not wrapping the seconds, we have to find out where we
- // are within the secondModel and advance to the next cell (or
- // go back to the previous cell if reverse == true)
+ if (controlPressed && rowModel.getSelectionMode()
+ != ListSelectionModel.SINGLE_SELECTION)
+ rowModel.addSelectionInterval(lo_row, hi_row);
else
- {
- int[] secondsSelected;
- if (eventIsTab && table.getRowSelectionAllowed() ||
- !eventIsTab && table.getColumnSelectionAllowed())
- secondsSelected = eventIsTab ?
- table.getSelectedRows() : table.getSelectedColumns();
- else
- {
- // if row selection is not allowed, then the entire column gets
- // selected when you click on it, so consider ALL rows selected
- secondsSelected = new int[numSeconds];
- for (int i = 0; i < numSeconds; i++)
- secondsSelected[i] = i;
- }
-
- // and now find the "next" index within the model
- int secondIndex = reverse ? secondsSelected.length - 1 : 0;
- if (!reverse)
- while (secondsSelected[secondIndex] <= secondLead)
- secondIndex++;
- else
- while (secondsSelected[secondIndex] >= secondLead)
- secondIndex--;
-
- // and select it - updating the lead selection index
- secondModel.addSelectionInterval(secondsSelected[secondIndex],
- secondsSelected[secondIndex]);
- }
+ rowModel.setSelectionInterval(lo_row, hi_row);
}
- // We didn't have to wrap the firsts, so just find the "next" first
- // and select it, we don't have to change "seconds"
- else
+
+ // Update the columns
+ int lo_col = table.columnAtPoint(begin);
+ int hi_col = table.columnAtPoint(curr);
+ ListSelectionModel colModel = table.getColumnModel().
+ getSelectionModel();
+ if (lo_col != -1 && hi_col != -1)
{
- int[] firstsSelected;
- if (eventIsTab && table.getColumnSelectionAllowed() ||
- !eventIsTab && table.getRowSelectionAllowed())
- firstsSelected = eventIsTab ?
- table.getSelectedColumns() : table.getSelectedRows();
+ if (controlPressed && colModel.getSelectionMode() !=
+ ListSelectionModel.SINGLE_SELECTION)
+ colModel.addSelectionInterval(lo_col, hi_col);
else
- {
- // if selection not allowed, consider ALL firsts to be selected
- firstsSelected = new int[numFirsts];
- for (int i = 0; i < numFirsts; i++)
- firstsSelected[i] = i;
- }
- int firstIndex = reverse ? firstsSelected.length - 1 : 0;
- if (!reverse)
- while (firstsSelected[firstIndex] <= firstLead)
- firstIndex++;
- else
- while (firstsSelected[firstIndex] >= firstLead)
- firstIndex--;
- firstModel.addSelectionInterval(firstsSelected[firstIndex],
- firstsSelected[firstIndex]);
- secondModel.addSelectionInterval(secondLead, secondLead);
+ colModel.setSelectionInterval(lo_col, hi_col);
}
}
-
- /**
- * A helper method for the keyPressed event. Used because the actions
- * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
- *
- * Selects the next (previous if SHIFT pressed) column (TAB) or row (ENTER)
- * in the table, changing the current selection. All cells in the table
- * are eligible, not just the ones that are currently selected.
- * @param firstModel the ListSelectionModel for columns (TAB) or rows
- * (ENTER)
- * @param firstMax the last index in firstModel
- * @param secondModel the ListSelectionModel for rows (TAB) or columns
- * (ENTER)
- * @param secondMax the last index in secondModel
- * @param reverse true if SHIFT was pressed for the event
- */
- void advanceSingleSelection (ListSelectionModel firstModel, int firstMax,
- ListSelectionModel secondModel, int secondMax,
- boolean reverse)
+ public void mouseClicked(MouseEvent e)
{
- // for TABs, "first" corresponds to columns and "seconds" to rows.
- // the opposite is true for ENTERs
- int firstLead = firstModel.getLeadSelectionIndex();
- int secondLead = secondModel.getLeadSelectionIndex();
-
- // if we are going backwards subtract 2 because we later add 1
- // for a net change of -1
- if (reverse && (firstLead == 0))
- {
- // check if we have to wrap around
- if (secondLead == 0)
- secondLead += secondMax + 1;
- secondLead -= 2;
+ }
+ public void mouseDragged(MouseEvent e)
+ {
+ curr = new Point(e.getX(), e.getY());
+ updateSelection(e.isControlDown());
+ }
+ public void mouseEntered(MouseEvent e)
+ {
+ }
+ public void mouseExited(MouseEvent e)
+ {
+ }
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+ public void mousePressed(MouseEvent e)
+ {
+ ListSelectionModel rowModel = table.getSelectionModel();
+ ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
+ int rowLead = rowModel.getLeadSelectionIndex();
+ int colLead = colModel.getLeadSelectionIndex();
+
+ begin = new Point(e.getX(), e.getY());
+ curr = new Point(e.getX(), e.getY());
+ //if control is pressed and the cell is already selected, deselect it
+ if (e.isControlDown() && table.
+ isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
+ {
+ table.getSelectionModel().
+ removeSelectionInterval(table.rowAtPoint(begin),
+ table.rowAtPoint(begin));
+ table.getColumnModel().getSelectionModel().
+ removeSelectionInterval(table.columnAtPoint(begin),
+ table.columnAtPoint(begin));
}
-
- // do we have to wrap the "seconds"?
- if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax))
- secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1),
- (secondLead + 1)%(secondMax + 1));
- // if not, just reselect the current lead
else
- secondModel.setSelectionInterval(secondLead, secondLead);
-
- // if we are going backwards, subtract 2 because we add 1 later
- // for net change of -1
- if (reverse)
- {
- // check for wraparound
- if (firstLead == 0)
- firstLead += firstMax + 1;
- firstLead -= 2;
- }
- // select the next "first"
- firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1),
- (firstLead + 1)%(firstMax + 1));
+ updateSelection(e.isControlDown());
+
+ // If we were editing, but the moved to another cell, stop editing
+ if (rowLead != rowModel.getLeadSelectionIndex() ||
+ colLead != colModel.getLeadSelectionIndex())
+ if (table.isEditing())
+ table.editingStopped(new ChangeEvent(e));
+ }
+ public void mouseReleased(MouseEvent e)
+ {
+ begin = null;
+ curr = null;
}
+ }
+
+ protected FocusListener createFocusListener()
+ {
+ return new FocusHandler();
+ }
+
+ protected MouseInputListener createMouseInputListener()
+ {
+ return new MouseInputHandler();
+ }
+
+ public Dimension getMaximumSize(JComponent comp)
+ {
+ return getPreferredSize(comp);
+ }
+
+ public Dimension getMinimumSize(JComponent comp)
+ {
+ return getPreferredSize(comp);
+ }
+
+ public Dimension getPreferredSize(JComponent comp)
+ {
+ int width = table.getColumnModel().getTotalColumnWidth();
+ int height = table.getRowCount() * table.getRowHeight();
+ return new Dimension(width, height);
+ }
- public void keyPressed(KeyEvent evt)
+ protected void installDefaults()
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ table.setFont(defaults.getFont("Table.font"));
+ table.setGridColor(defaults.getColor("Table.gridColor"));
+ table.setForeground(defaults.getColor("Table.foreground"));
+ table.setBackground(defaults.getColor("Table.background"));
+ table.setSelectionForeground(defaults.getColor("Table.selectionForeground"));
+ table.setSelectionBackground(defaults.getColor("Table.selectionBackground"));
+ table.setOpaque(true);
+
+ highlightCellBorder = defaults.getBorder("Table.focusCellHighlightBorder");
+ cellBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
+ }
+
+ private int convertModifiers(int mod)
+ {
+ if ((mod & KeyEvent.SHIFT_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.SHIFT_MASK;
+ mod &= ~KeyEvent.SHIFT_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.CTRL_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.CTRL_MASK;
+ mod &= ~KeyEvent.CTRL_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.META_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.META_MASK;
+ mod &= ~KeyEvent.META_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.ALT_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.ALT_MASK;
+ mod &= ~KeyEvent.ALT_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.ALT_GRAPH_MASK;
+ mod &= ~KeyEvent.ALT_GRAPH_DOWN_MASK;
+ }
+ return mod;
+ }
+
+ protected void installKeyboardActions()
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap");
+ action = new TableAction();
+ Object keys[] = ancestorMap.allKeys();
+ // Register the key bindings with the JTable.
+ // Note that we register key bindings with both the old and new modifier
+ // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on.
+ for (int i = 0; i < keys.length; i++)
+ {
+ table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]),
+ KeyStroke.getKeyStroke
+ (((KeyStroke)keys[i]).getKeyCode(), convertModifiers(((KeyStroke)keys[i]).getModifiers())),
+ JComponent.WHEN_FOCUSED);
+
+ table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]),
+ KeyStroke.getKeyStroke
+ (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()),
+ JComponent.WHEN_FOCUSED);
+ }
+ }
+
+ /**
+ * This class implements the actions that we want to happen
+ * when specific keys are pressed for the JTable. The actionPerformed
+ * method is called when a key that has been registered for the JTable
+ * is received.
+ */
+ class TableAction extends AbstractAction
+ {
+ /**
+ * What to do when this action is called.
+ *
+ * @param e the ActionEvent that caused this action.
+ */
+ public void actionPerformed (ActionEvent e)
{
ListSelectionModel rowModel = table.getSelectionModel();
ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
@@ -275,224 +312,141 @@ public class BasicTableUI
int colLead = colModel.getLeadSelectionIndex();
int colMax = table.getModel().getColumnCount() - 1;
- if ((evt.getKeyCode() == KeyEvent.VK_DOWN)
- || (evt.getKeyCode() == KeyEvent.VK_KP_DOWN))
+ if (e.getActionCommand().equals("selectPreviousRowExtendSelection"))
{
- if (evt.getModifiers() == 0)
- {
-
- table.clearSelection();
- rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax),
- Math.min(rowLead + 1, rowMax));
- colModel.setSelectionInterval(colLead,colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax));
- colModel.setLeadSelectionIndex(colLead);
- }
+ rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0));
+ colModel.setLeadSelectionIndex(colLead);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_UP)
- || (evt.getKeyCode() == KeyEvent.VK_KP_UP))
+ else if (e.getActionCommand().equals("selectLastColumn"))
{
- if (evt.getModifiers() == 0)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(Math.max(rowLead - 1, 0),
- Math.max(rowLead - 1, 0));
- colModel.setSelectionInterval(colLead,colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0));
- colModel.setLeadSelectionIndex(colLead);
- }
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ colModel.setSelectionInterval(colMax, colMax);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_LEFT)
- || (evt.getKeyCode() == KeyEvent.VK_KP_LEFT))
+ else if (e.getActionCommand().equals("startEditing"))
{
- if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0));
- rowModel.setLeadSelectionIndex(rowLead);
- }
- else if (evt.getModifiers() == 0)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(rowLead,rowLead);
- colModel.setSelectionInterval(Math.max(colLead - 1, 0),
- Math.max(colLead - 1, 0));
- }
+ if (table.isCellEditable(rowLead, colLead))
+ table.editCellAt(rowLead,colLead);
+ }
+ else if (e.getActionCommand().equals("selectFirstRowExtendSelection"))
+ {
+ rowModel.setLeadSelectionIndex(0);
+ colModel.setLeadSelectionIndex(colLead);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_RIGHT)
- || (evt.getKeyCode() == KeyEvent.VK_KP_RIGHT))
+ else if (e.getActionCommand().equals("selectFirstColumn"))
{
- if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax));
- rowModel.setLeadSelectionIndex(rowLead);
- }
- else if (evt.getModifiers() == 0)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(rowLead,rowLead);
- colModel.setSelectionInterval(Math.min(colLead + 1, colMax),
- Math.min(colLead + 1, colMax));
- }
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ colModel.setSelectionInterval(0, 0);
}
- else if (evt.getKeyCode() == KeyEvent.VK_END)
+ else if (e.getActionCommand().equals("selectFirstColumnExtendSelection"))
{
- if (evt.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
- {
- rowModel.setLeadSelectionIndex(rowMax);
- colModel.setLeadSelectionIndex(colLead);
- }
- else if (evt.getModifiers() == InputEvent.CTRL_MASK)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(rowMax,rowMax);
- colModel.setSelectionInterval(colLead, colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- colModel.setLeadSelectionIndex(colMax);
- rowModel.setLeadSelectionIndex(rowLead);
- }
- else if (evt.getModifiers() == 0)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(rowLead, rowLead);
- colModel.setSelectionInterval(colMax, colMax);
- }
+ colModel.setLeadSelectionIndex(0);
+ rowModel.setLeadSelectionIndex(rowLead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_HOME)
+ else if (e.getActionCommand().equals("selectLastRow"))
{
- if (evt.getModifiers() ==
- (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
- {
- rowModel.setLeadSelectionIndex(0);
- colModel.setLeadSelectionIndex(colLead);
- }
- else if (evt.getModifiers() == InputEvent.CTRL_MASK)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(0,0);
- colModel.setSelectionInterval(colLead, colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- colModel.setLeadSelectionIndex(0);
- rowModel.setLeadSelectionIndex(rowLead);
- }
- else if (evt.getModifiers() == 0)
- {
- table.clearSelection();
- rowModel.setSelectionInterval(rowLead, rowLead);
- colModel.setSelectionInterval(0, 0);
- }
+ rowModel.setSelectionInterval(rowMax,rowMax);
+ colModel.setSelectionInterval(colLead, colLead);
+ }
+ else if (e.getActionCommand().equals("selectNextRowExtendSelection"))
+ {
+ rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax));
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (e.getActionCommand().equals("selectFirstRow"))
+ {
+ rowModel.setSelectionInterval(0,0);
+ colModel.setSelectionInterval(colLead, colLead);
+ }
+ else if (e.getActionCommand().equals("selectNextColumnExtendSelection"))
+ {
+ colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax));
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (e.getActionCommand().equals("selectLastColumnExtendSelection"))
+ {
+ colModel.setLeadSelectionIndex(colMax);
+ rowModel.setLeadSelectionIndex(rowLead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_F2)
+ else if (e.getActionCommand().equals("selectPreviousColumnExtendSelection"))
{
- // FIXME: Implement "start editing"
+ colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0));
+ rowModel.setLeadSelectionIndex(rowLead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP)
+ else if (e.getActionCommand().equals("selectNextRow"))
+ {
+ rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax),
+ Math.min(rowLead + 1, rowMax));
+ colModel.setSelectionInterval(colLead,colLead);
+ }
+ else if (e.getActionCommand().equals("scrollUpExtendSelection"))
{
int target;
- if (!evt.isControlDown())
- {
- if (rowLead == getFirstVisibleRowIndex())
- target = Math.max
- (0, rowLead - (getLastVisibleRowIndex() -
- getFirstVisibleRowIndex() + 1));
- else
- target = getFirstVisibleRowIndex();
-
- if (evt.getModifiers() == 0)
- {
- rowModel.setSelectionInterval(target, target);
- colModel.setSelectionInterval(colLead, colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- rowModel.setLeadSelectionIndex(target);
- colModel.setLeadSelectionIndex(colLead);
- }
- }
+ if (rowLead == getFirstVisibleRowIndex())
+ target = Math.max
+ (0, rowLead - (getLastVisibleRowIndex() -
+ getFirstVisibleRowIndex() + 1));
else
- {
- if (colLead == getFirstVisibleColumnIndex())
- target = Math.max
- (0, colLead - (getLastVisibleColumnIndex() -
- getFirstVisibleColumnIndex() + 1));
- else
- target = getFirstVisibleColumnIndex();
-
- if (evt.getModifiers() == InputEvent.CTRL_MASK)
- {
- colModel.setSelectionInterval(target, target);
- rowModel.setSelectionInterval(rowLead, rowLead);
- }
- else if (evt.getModifiers() ==
- (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
- {
- colModel.setLeadSelectionIndex(target);
- rowModel.setLeadSelectionIndex(rowLead);
- }
- }
+ target = getFirstVisibleRowIndex();
+
+ rowModel.setLeadSelectionIndex(target);
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (e.getActionCommand().equals("selectPreviousRow"))
+ {
+ rowModel.setSelectionInterval(Math.max(rowLead - 1, 0),
+ Math.max(rowLead - 1, 0));
+ colModel.setSelectionInterval(colLead,colLead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
+ else if (e.getActionCommand().equals("scrollRightChangeSelection"))
{
int target;
- if (!evt.isControlDown())
- {
- if (rowLead == getLastVisibleRowIndex())
- target = Math.min
- (rowMax, rowLead + (getLastVisibleRowIndex() -
- getFirstVisibleRowIndex() + 1));
- else
- target = getLastVisibleRowIndex();
-
- if (evt.getModifiers() == 0)
- {
- rowModel.setSelectionInterval(target, target);
- colModel.setSelectionInterval(colLead, colLead);
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- {
- rowModel.setLeadSelectionIndex(target);
- colModel.setLeadSelectionIndex(colLead);
- }
- }
+ if (colLead == getLastVisibleColumnIndex())
+ target = Math.min
+ (colMax, colLead + (getLastVisibleColumnIndex() -
+ getFirstVisibleColumnIndex() + 1));
else
- {
- if (colLead == getLastVisibleColumnIndex())
- target = Math.min
- (colMax, colLead + (getLastVisibleColumnIndex() -
- getFirstVisibleColumnIndex() + 1));
- else
- target = getLastVisibleColumnIndex();
-
- if (evt.getModifiers() == InputEvent.CTRL_MASK)
- {
- colModel.setSelectionInterval(target, target);
- rowModel.setSelectionInterval(rowLead, rowLead);
- }
- else if (evt.getModifiers() ==
- (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
- {
- colModel.setLeadSelectionIndex(target);
- rowModel.setLeadSelectionIndex(rowLead);
- }
- }
+ target = getLastVisibleColumnIndex();
+
+ colModel.setSelectionInterval(target, target);
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ }
+ else if (e.getActionCommand().equals("selectPreviousColumn"))
+ {
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.max(colLead - 1, 0),
+ Math.max(colLead - 1, 0));
}
- else if (evt.getKeyCode() == KeyEvent.VK_TAB
- || evt.getKeyCode() == KeyEvent.VK_ENTER)
+ else if (e.getActionCommand().equals("scrollLeftChangeSelection"))
{
- // If modifers other than SHIFT are pressed, do nothing
- if (evt.getModifiers() != 0 && evt.getModifiers() !=
- InputEvent.SHIFT_MASK)
- return;
+ int target;
+ if (colLead == getFirstVisibleColumnIndex())
+ target = Math.max
+ (0, colLead - (getLastVisibleColumnIndex() -
+ getFirstVisibleColumnIndex() + 1));
+ else
+ target = getFirstVisibleColumnIndex();
+ colModel.setSelectionInterval(target, target);
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ }
+ else if (e.getActionCommand().equals("clearSelection"))
+ {
+ table.clearSelection();
+ }
+ else if (e.getActionCommand().equals("cancel"))
+ {
+ // FIXME: implement other parts of "cancel" like undo-ing last
+ // selection. Right now it just calls editingCancelled if
+ // we're currently editing.
+ if (table.isEditing())
+ table.editingCanceled(new ChangeEvent("cancel"));
+ }
+ else if (e.getActionCommand().equals("selectNextRowCell")
+ || e.getActionCommand().equals("selectPreviousRowCell")
+ || e.getActionCommand().equals("selectNextColumnCell")
+ || e.getActionCommand().equals("selectPreviousColumnCell"))
+ {
// If nothing is selected, select the first cell in the table
if (table.getSelectedRowCount() == 0 &&
table.getSelectedColumnCount() == 0)
@@ -517,25 +471,24 @@ public class BasicTableUI
// multRowsSelected and multColsSelected tell us if multiple rows or
// columns are selected, respectively
boolean multRowsSelected, multColsSelected;
- multRowsSelected = (table.getSelectedRowCount() > 1) ||
- (!table.getRowSelectionAllowed() &&
- table.getSelectedColumnCount() > 0);
- multColsSelected = (table.getSelectedColumnCount() > 1) ||
- (!table.getColumnSelectionAllowed() &&
- table.getSelectedRowCount() > 0);
+ multRowsSelected = table.getSelectedRowCount() > 1 &&
+ table.getRowSelectionAllowed();
+
+ multColsSelected = table.getSelectedColumnCount() > 1 &&
+ table.getColumnSelectionAllowed();
// If there is just one selection, select the next cell, and wrap
// when you get to the edges of the table.
- if (!multColsSelected || !multRowsSelected)
+ if (!multColsSelected && !multRowsSelected)
{
- if (evt.getKeyCode() == KeyEvent.VK_TAB)
+ if (e.getActionCommand().indexOf("Column") != -1)
advanceSingleSelection(colModel, colMax, rowModel, rowMax,
- (evt.getModifiers() ==
- InputEvent.SHIFT_MASK));
+ (e.getActionCommand().equals
+ ("selectPreviousColumnCell")));
else
advanceSingleSelection(rowModel, rowMax, colModel, colMax,
- (evt.getModifiers() ==
- InputEvent.SHIFT_MASK));
+ (e.getActionCommand().equals
+ ("selectPreviousRowCell")));
return;
}
@@ -555,56 +508,112 @@ public class BasicTableUI
// If there are multiple rows and columns selected, select the next
// cell and wrap at the edges of the selection.
- if (evt.getKeyCode() == KeyEvent.VK_TAB)
+ if (e.getActionCommand().indexOf("Column") != -1)
advanceMultipleSelection(colModel, colMinSelected, colMaxSelected,
rowModel, rowMinSelected, rowMaxSelected,
- (evt.getModifiers() ==
- InputEvent.SHIFT_MASK), true);
+ (e.getActionCommand().equals
+ ("selectPreviousColumnCell")), true);
+
else
advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected,
colModel, colMinSelected, colMaxSelected,
- (evt.getModifiers() ==
- InputEvent.SHIFT_MASK), false);
+ (e.getActionCommand().equals
+ ("selectPreviousRowCell")), false);
table.repaint();
}
- else if (evt.getKeyCode() == KeyEvent.VK_ESCAPE)
+ else if (e.getActionCommand().equals("selectNextColumn"))
+ {
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.min(colLead + 1, colMax),
+ Math.min(colLead + 1, colMax));
+ }
+ else if (e.getActionCommand().equals("scrollLeftExtendSelection"))
{
- // FIXME: implement "cancel"
+ int target;
+ if (colLead == getFirstVisibleColumnIndex())
+ target = Math.max
+ (0, colLead - (getLastVisibleColumnIndex() -
+ getFirstVisibleColumnIndex() + 1));
+ else
+ target = getFirstVisibleColumnIndex();
+
+ colModel.setLeadSelectionIndex(target);
+ rowModel.setLeadSelectionIndex(rowLead);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode()
- == KeyEvent.VK_SLASH) && (evt.getModifiers() ==
- InputEvent.CTRL_MASK))
+ else if (e.getActionCommand().equals("scrollDownChangeSelection"))
+ {
+ int target;
+ if (rowLead == getLastVisibleRowIndex())
+ target = Math.min
+ (rowMax, rowLead + (getLastVisibleRowIndex() -
+ getFirstVisibleRowIndex() + 1));
+ else
+ target = getLastVisibleRowIndex();
+
+ rowModel.setSelectionInterval(target, target);
+ colModel.setSelectionInterval(colLead, colLead);
+ }
+ else if (e.getActionCommand().equals("scrollRightExtendSelection"))
+ {
+ int target;
+ if (colLead == getLastVisibleColumnIndex())
+ target = Math.min
+ (colMax, colLead + (getLastVisibleColumnIndex() -
+ getFirstVisibleColumnIndex() + 1));
+ else
+ target = getLastVisibleColumnIndex();
+
+ colModel.setLeadSelectionIndex(target);
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (e.getActionCommand().equals("selectAll"))
{
table.selectAll();
}
- else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH
- && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ else if (e.getActionCommand().equals("selectLastRowExtendSelection"))
{
- table.clearSelection();
+ rowModel.setLeadSelectionIndex(rowMax);
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (e.getActionCommand().equals("scrollDownExtendSelection"))
+ {
+ int target;
+ if (rowLead == getLastVisibleRowIndex())
+ target = Math.min
+ (rowMax, rowLead + (getLastVisibleRowIndex() -
+ getFirstVisibleRowIndex() + 1));
+ else
+ target = getLastVisibleRowIndex();
+
+ rowModel.setLeadSelectionIndex(target);
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (e.getActionCommand().equals("scrollUpChangeSelection"))
+ {
+ int target;
+ if (rowLead == getFirstVisibleRowIndex())
+ target = Math.max
+ (0, rowLead - (getLastVisibleRowIndex() -
+ getFirstVisibleRowIndex() + 1));
+ else
+ target = getFirstVisibleRowIndex();
+
+ rowModel.setSelectionInterval(target, target);
+ colModel.setSelectionInterval(colLead, colLead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_SPACE
- && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ else
{
- table.changeSelection(rowLead, colLead, true, false);
+ // If we're here that means we bound this TableAction class
+ // to a keyboard input but we either want to ignore that input
+ // or we just haven't implemented its action yet.
}
+
table.scrollRectToVisible
(table.getCellRect(rowModel.getLeadSelectionIndex(),
colModel.getLeadSelectionIndex(), false));
}
-
- public void keyReleased(KeyEvent e)
- {
- }
-
- public void keyTyped(KeyEvent e)
- {
- }
-
- /**
- * Returns the column index of the first visible column.
- *
- */
+
int getFirstVisibleColumnIndex()
{
ComponentOrientation or = table.getComponentOrientation();
@@ -663,133 +672,172 @@ public class BasicTableUI
}
return table.rowAtPoint(r.getLocation());
}
- }
-
- class MouseInputHandler implements MouseInputListener
- {
- Point begin, curr;
- private void updateSelection(boolean controlPressed)
+ /**
+ * A helper method for the key bindings. Used because the actions
+ * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
+ *
+ * Selects the next (previous if SHIFT pressed) column for TAB, or row for
+ * ENTER from within the currently selected cells.
+ *
+ * @param firstModel the ListSelectionModel for columns (TAB) or
+ * rows (ENTER)
+ * @param firstMin the first selected index in firstModel
+ * @param firstMax the last selected index in firstModel
+ * @param secondModel the ListSelectionModel for rows (TAB) or
+ * columns (ENTER)
+ * @param secondMin the first selected index in secondModel
+ * @param secondMax the last selected index in secondModel
+ * @param reverse true if shift was held for the event
+ * @param eventIsTab true if TAB was pressed, false if ENTER pressed
+ */
+ void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin,
+ int firstMax, ListSelectionModel secondModel,
+ int secondMin, int secondMax, boolean reverse,
+ boolean eventIsTab)
{
- // Update the rows
- int lo_row = table.rowAtPoint(begin);
- int hi_row = table.rowAtPoint(curr);
- ListSelectionModel rowModel = table.getSelectionModel();
- if (lo_row != -1 && hi_row != -1)
+ // If eventIsTab, all the "firsts" correspond to columns, otherwise, to rows
+ // "seconds" correspond to the opposite
+ int firstLead = firstModel.getLeadSelectionIndex();
+ int secondLead = secondModel.getLeadSelectionIndex();
+ int numFirsts = eventIsTab ?
+ table.getModel().getColumnCount() : table.getModel().getRowCount();
+ int numSeconds = eventIsTab ?
+ table.getModel().getRowCount() : table.getModel().getColumnCount();
+
+ // check if we have to wrap the "firsts" around, going to the other side
+ if ((firstLead == firstMax && !reverse) ||
+ (reverse && firstLead == firstMin))
{
- if (controlPressed && rowModel.getSelectionMode()
- != ListSelectionModel.SINGLE_SELECTION)
- rowModel.addSelectionInterval(lo_row, hi_row);
+ firstModel.addSelectionInterval(reverse ? firstMax : firstMin,
+ reverse ? firstMax : firstMin);
+
+ // check if we have to wrap the "seconds"
+ if ((secondLead == secondMax && !reverse) ||
+ (reverse && secondLead == secondMin))
+ secondModel.addSelectionInterval(reverse ? secondMax : secondMin,
+ reverse ? secondMax : secondMin);
+
+ // if we're not wrapping the seconds, we have to find out where we
+ // are within the secondModel and advance to the next cell (or
+ // go back to the previous cell if reverse == true)
else
- rowModel.setSelectionInterval(lo_row, hi_row);
+ {
+ int[] secondsSelected;
+ if (eventIsTab && table.getRowSelectionAllowed() ||
+ !eventIsTab && table.getColumnSelectionAllowed())
+ secondsSelected = eventIsTab ?
+ table.getSelectedRows() : table.getSelectedColumns();
+ else
+ {
+ // if row selection is not allowed, then the entire column gets
+ // selected when you click on it, so consider ALL rows selected
+ secondsSelected = new int[numSeconds];
+ for (int i = 0; i < numSeconds; i++)
+ secondsSelected[i] = i;
+ }
+
+ // and now find the "next" index within the model
+ int secondIndex = reverse ? secondsSelected.length - 1 : 0;
+ if (!reverse)
+ while (secondsSelected[secondIndex] <= secondLead)
+ secondIndex++;
+ else
+ while (secondsSelected[secondIndex] >= secondLead)
+ secondIndex--;
+
+ // and select it - updating the lead selection index
+ secondModel.addSelectionInterval(secondsSelected[secondIndex],
+ secondsSelected[secondIndex]);
+ }
}
-
- // Update the columns
- int lo_col = table.columnAtPoint(begin);
- int hi_col = table.columnAtPoint(curr);
- ListSelectionModel colModel = table.getColumnModel().
- getSelectionModel();
- if (lo_col != -1 && hi_col != -1)
+ // We didn't have to wrap the firsts, so just find the "next" first
+ // and select it, we don't have to change "seconds"
+ else
{
- if (controlPressed && colModel.getSelectionMode() !=
- ListSelectionModel.SINGLE_SELECTION)
- colModel.addSelectionInterval(lo_col, hi_col);
+ int[] firstsSelected;
+ if (eventIsTab && table.getColumnSelectionAllowed() ||
+ !eventIsTab && table.getRowSelectionAllowed())
+ firstsSelected = eventIsTab ?
+ table.getSelectedColumns() : table.getSelectedRows();
else
- colModel.setSelectionInterval(lo_col, hi_col);
+ {
+ // if selection not allowed, consider ALL firsts to be selected
+ firstsSelected = new int[numFirsts];
+ for (int i = 0; i < numFirsts; i++)
+ firstsSelected[i] = i;
+ }
+ int firstIndex = reverse ? firstsSelected.length - 1 : 0;
+ if (!reverse)
+ while (firstsSelected[firstIndex] <= firstLead)
+ firstIndex++;
+ else
+ while (firstsSelected[firstIndex] >= firstLead)
+ firstIndex--;
+ firstModel.addSelectionInterval(firstsSelected[firstIndex],
+ firstsSelected[firstIndex]);
+ secondModel.addSelectionInterval(secondLead, secondLead);
}
}
+
+ /**
+ * A helper method for the key bindings. Used because the actions
+ * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
+ *
+ * Selects the next (previous if SHIFT pressed) column (TAB) or row (ENTER)
+ * in the table, changing the current selection. All cells in the table
+ * are eligible, not just the ones that are currently selected.
+ * @param firstModel the ListSelectionModel for columns (TAB) or rows
+ * (ENTER)
+ * @param firstMax the last index in firstModel
+ * @param secondModel the ListSelectionModel for rows (TAB) or columns
+ * (ENTER)
+ * @param secondMax the last index in secondModel
+ * @param reverse true if SHIFT was pressed for the event
+ */
- public void mouseClicked(MouseEvent e)
- {
- }
- public void mouseDragged(MouseEvent e)
- {
- curr = new Point(e.getX(), e.getY());
- updateSelection(e.isControlDown());
- }
- public void mouseEntered(MouseEvent e)
- {
- }
- public void mouseExited(MouseEvent e)
- {
- }
- public void mouseMoved(MouseEvent e)
- {
- }
- public void mousePressed(MouseEvent e)
+ void advanceSingleSelection (ListSelectionModel firstModel, int firstMax,
+ ListSelectionModel secondModel, int secondMax,
+ boolean reverse)
{
- begin = new Point(e.getX(), e.getY());
- curr = new Point(e.getX(), e.getY());
- //if control is pressed and the cell is already selected, deselect it
- if (e.isControlDown() && table.
- isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
- {
- table.getSelectionModel().
- removeSelectionInterval(table.rowAtPoint(begin),
- table.rowAtPoint(begin));
- table.getColumnModel().getSelectionModel().
- removeSelectionInterval(table.columnAtPoint(begin),
- table.columnAtPoint(begin));
+ // for TABs, "first" corresponds to columns and "seconds" to rows.
+ // the opposite is true for ENTERs
+ int firstLead = firstModel.getLeadSelectionIndex();
+ int secondLead = secondModel.getLeadSelectionIndex();
+
+ // if we are going backwards subtract 2 because we later add 1
+ // for a net change of -1
+ if (reverse && (firstLead == 0))
+ {
+ // check if we have to wrap around
+ if (secondLead == 0)
+ secondLead += secondMax + 1;
+ secondLead -= 2;
}
+
+ // do we have to wrap the "seconds"?
+ if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax))
+ secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1),
+ (secondLead + 1)%(secondMax + 1));
+ // if not, just reselect the current lead
else
- updateSelection(e.isControlDown());
+ secondModel.setSelectionInterval(secondLead, secondLead);
- }
- public void mouseReleased(MouseEvent e)
- {
- begin = null;
- curr = null;
+ // if we are going backwards, subtract 2 because we add 1 later
+ // for net change of -1
+ if (reverse)
+ {
+ // check for wraparound
+ if (firstLead == 0)
+ firstLead += firstMax + 1;
+ firstLead -= 2;
+ }
+ // select the next "first"
+ firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1),
+ (firstLead + 1)%(firstMax + 1));
}
}
- protected FocusListener createFocusListener()
- {
- return new FocusHandler();
- }
- protected KeyListener createKeyListener()
- {
- return new KeyHandler();
- }
- protected MouseInputListener createMouseInputListener()
- {
- return new MouseInputHandler();
- }
-
- public Dimension getMaximumSize(JComponent comp)
- {
- return getPreferredSize(comp);
- }
-
- public Dimension getMinimumSize(JComponent comp)
- {
- return getPreferredSize(comp);
- }
-
- public Dimension getPreferredSize(JComponent comp)
- {
- int width = table.getColumnModel().getTotalColumnWidth();
- int height = table.getRowCount() * table.getRowHeight();
- return new Dimension(width, height);
- }
-
- protected void installDefaults()
- {
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- table.setFont(defaults.getFont("Table.font"));
- table.setGridColor(defaults.getColor("Table.gridColor"));
- table.setForeground(defaults.getColor("Table.foreground"));
- table.setBackground(defaults.getColor("Table.background"));
- table.setSelectionForeground(defaults.getColor("Table.selectionForeground"));
- table.setSelectionBackground(defaults.getColor("Table.selectionBackground"));
- table.setOpaque(true);
-
- highlightCellBorder = defaults.getBorder("Table.focusCellHighlightBorder");
- cellBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
- }
- protected void installKeyboardActions()
- {
- }
-
protected void installListeners()
{
table.addFocusListener(focusListener);
@@ -834,7 +882,6 @@ public class BasicTableUI
{
table = (JTable)comp;
focusListener = createFocusListener();
- keyListener = createKeyListener();
mouseInputListener = createMouseInputListener();
installDefaults();
installKeyboardActions();
@@ -896,6 +943,8 @@ public class BasicTableUI
((JComponent) comp).setBorder(cellBorder);
}
comp.paint(gfx);
+ if (comp instanceof JTextField)
+ ((JTextField)comp).getCaret().paint(gfx);
gfx.translate(-x, -y);
}
y += height;
@@ -948,6 +997,5 @@ public class BasicTableUI
}
gfx.setColor(save);
}
-
}
}
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index 0ccc0f5be..74bd6110b 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -1,39 +1,39 @@
/* BasicTreeUI.java --
- Copyright (C) 2002, 2004, 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. */
+ Copyright (C) 2002, 2004, 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.basic;
@@ -90,6 +90,7 @@ import javax.swing.plaf.TreeUI;
import javax.swing.tree.AbstractLayoutCache;
import javax.swing.tree.DefaultTreeCellEditor;
import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.FixedHeightLayoutCache;
import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeCellRenderer;
@@ -106,128 +107,138 @@ import javax.swing.tree.TreeSelectionModel;
* @author Sascha Brawer (brawer@dandelis.ch)
* @author Lillian Angel (langel@redhat.com)
*/
-public class BasicTreeUI extends TreeUI
+public class BasicTreeUI
+ extends TreeUI
{
/** Collapse Icon for the tree. */
protected transient Icon collapsedIcon;
-
+
/** Expanded Icon for the tree. */
protected transient Icon expandedIcon;
-
+
/** Distance between left margin and where vertical dashes will be drawn. */
protected int leftChildIndent;
-
+
/**
* Distance between leftChildIndent and where cell contents will be drawn.
*/
protected int rightChildIndent;
-
+
/**
* Total fistance that will be indented. The sum of leftChildIndent and
* rightChildIndent .
*/
protected int totalChildIndent;
-
+
/** Minimum preferred size. */
protected Dimension preferredMinsize;
-
+
/** Index of the row that was last selected. */
protected int lastSelectedRow;
-
+
/** Component that we're going to be drawing onto. */
protected JTree tree;
-
+
/** Renderer that is being used to do the actual cell drawing. */
protected transient TreeCellRenderer currentCellRenderer;
-
+
/**
* Set to true if the renderer that is currently in the tree was created by
* this instance.
*/
protected boolean createdRenderer;
-
+
/** Editor for the tree. */
protected transient TreeCellEditor cellEditor;
-
+
/**
* Set to true if editor that is currently in the tree was created by this
* instance.
*/
protected boolean createdCellEditor;
-
+
/**
* Set to false when editing and shouldSelectCall() returns true meaning the
* node should be selected before editing, used in completeEditing.
*/
protected boolean stopEditingInCompleteEditing;
-
+
/** Used to paint the TreeCellRenderer. */
protected CellRendererPane rendererPane;
-
+
/** Size needed to completely display all the nodes. */
protected Dimension preferredSize;
-
+
/** Is the preferredSize valid? */
protected boolean validCachedPreferredSize;
-
+
/** Object responsible for handling sizing and expanded issues. */
protected AbstractLayoutCache treeState;
-
+
/** Used for minimizing the drawing of vertical lines. */
protected Hashtable drawingCache;
-
+
/**
* True if doing optimizations for a largeModel. Subclasses that don't
* support this may wish to override createLayoutCache to not return a
* FixedHeightLayoutCache instance.
*/
protected boolean largeModel;
-
+
/** Responsible for telling the TreeState the size needed for a node. */
protected AbstractLayoutCache.NodeDimensions nodeDimensions;
-
+
/** Used to determine what to display. */
protected TreeModel treeModel;
-
+
/** Model maintaining the selection. */
protected TreeSelectionModel treeSelectionModel;
-
+
/**
* How much the depth should be offset to properly calculate x locations.
* This is based on whether or not the root is visible, and if the root
* handles are visible.
*/
protected int depthOffset;
-
+
/**
* When editing, this will be the Component that is doing the actual editing.
*/
protected Component editingComponent;
-
+
/** Path that is being edited. */
protected TreePath editingPath;
-
+
/**
* Row that is being edited. Should only be referenced if editingComponent is
* null.
*/
protected int editingRow;
-
+
/** Set to true if the editor has a different size than the renderer. */
protected boolean editorHasDifferentSize;
-
+
/** Listeners */
private PropertyChangeListener propertyChangeListener;
+
private FocusListener focusListener;
+
private TreeSelectionListener treeSelectionListener;
+
private MouseInputListener mouseInputListener;
+
private KeyListener keyListener;
+
private PropertyChangeListener selectionModelPropertyChangeListener;
+
private ComponentListener componentListener;
+
private CellEditorListener cellEditorListener;
+
private TreeExpansionListener treeExpansionListener;
+
private TreeModelListener treeModelListener;
-
+
/**
* Creates a new BasicTreeUI object.
*/
@@ -239,7 +250,7 @@ public class BasicTreeUI extends TreeUI
nodeDimensions = createNodeDimensions();
rendererPane = createCellRendererPane();
configureLayoutCache();
-
+
propertyChangeListener = createPropertyChangeListener();
focusListener = createFocusListener();
treeSelectionListener = createTreeSelectionListener();
@@ -250,13 +261,13 @@ public class BasicTreeUI extends TreeUI
cellEditorListener = createCellEditorListener();
treeExpansionListener = createTreeExpansionListener();
treeModelListener = createTreeModelListener();
-
+
createdRenderer = true;
createdCellEditor = true;
editingRow = -1;
lastSelectedRow = -1;
}
-
+
/**
* Returns an instance of the UI delegate for the specified component.
*
@@ -268,7 +279,7 @@ public class BasicTreeUI extends TreeUI
{
return new BasicTreeUI();
}
-
+
/**
* Returns the Hash color.
*
@@ -278,7 +289,7 @@ public class BasicTreeUI extends TreeUI
{
return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");
}
-
+
/**
* Sets the Hash color.
*
@@ -287,9 +298,9 @@ public class BasicTreeUI extends TreeUI
protected void setHashColor(Color color)
{
// FIXME: not implemented
-
+
}
-
+
/**
* Sets the left child's indent value.
*
@@ -299,7 +310,7 @@ public class BasicTreeUI extends TreeUI
{
leftChildIndent = newAmount;
}
-
+
/**
* Returns the indent value for the left child.
*
@@ -309,7 +320,7 @@ public class BasicTreeUI extends TreeUI
{
return leftChildIndent;
}
-
+
/**
* Sets the right child's indent value.
*
@@ -319,7 +330,7 @@ public class BasicTreeUI extends TreeUI
{
rightChildIndent = newAmount;
}
-
+
/**
* Returns the indent value for the right child.
*
@@ -329,7 +340,7 @@ public class BasicTreeUI extends TreeUI
{
return rightChildIndent;
}
-
+
/**
* Sets the expanded icon.
*
@@ -339,7 +350,7 @@ public class BasicTreeUI extends TreeUI
{
expandedIcon = newG;
}
-
+
/**
* Returns the current expanded icon.
*
@@ -349,7 +360,7 @@ public class BasicTreeUI extends TreeUI
{
return expandedIcon;
}
-
+
/**
* Sets the collapsed icon.
*
@@ -359,7 +370,7 @@ public class BasicTreeUI extends TreeUI
{
collapsedIcon = newG;
}
-
+
/**
* Returns the current collapsed icon.
*
@@ -369,7 +380,7 @@ public class BasicTreeUI extends TreeUI
{
return collapsedIcon;
}
-
+
/**
* Updates the componentListener, if necessary.
*
@@ -384,7 +395,7 @@ public class BasicTreeUI extends TreeUI
tree.addComponentListener(componentListener);
}
}
-
+
/**
* Returns true if largeModel is set
*
@@ -394,7 +405,7 @@ public class BasicTreeUI extends TreeUI
{
return largeModel;
}
-
+
/**
* Sets the row height.
*
@@ -404,7 +415,7 @@ public class BasicTreeUI extends TreeUI
{
treeState.setRowHeight(rowHeight);
}
-
+
/**
* Returns the current row height.
*
@@ -414,7 +425,7 @@ public class BasicTreeUI extends TreeUI
{
return treeState.getRowHeight();
}
-
+
/**
* Sets the TreeCellRenderer to <code>tcr</code>. This invokes
* <code>updateRenderer</code>.
@@ -424,9 +435,10 @@ public class BasicTreeUI extends TreeUI
protected void setCellRenderer(TreeCellRenderer tcr)
{
currentCellRenderer = tcr;
+ tree.setCellRenderer(tcr);
updateRenderer();
}
-
+
/**
* Return currentCellRenderer, which will either be the trees renderer, or
* defaultCellRenderer, which ever was not null.
@@ -437,10 +449,10 @@ public class BasicTreeUI extends TreeUI
{
if (currentCellRenderer != null)
return currentCellRenderer;
-
+
return createDefaultCellRenderer();
}
-
+
/**
* Sets the tree's model.
*
@@ -449,9 +461,9 @@ public class BasicTreeUI extends TreeUI
protected void setModel(TreeModel model)
{
tree.setModel(model);
- treeModel = model;
+ treeModel = tree.getModel();
}
-
+
/**
* Returns the tree's model
*
@@ -461,7 +473,7 @@ public class BasicTreeUI extends TreeUI
{
return treeModel;
}
-
+
/**
* Sets the root to being visible.
*
@@ -471,7 +483,7 @@ public class BasicTreeUI extends TreeUI
{
tree.setRootVisible(newValue);
}
-
+
/**
* Returns true if the root is visible.
*
@@ -481,7 +493,7 @@ public class BasicTreeUI extends TreeUI
{
return tree.isRootVisible();
}
-
+
/**
* Determines whether the node handles are to be displayed.
*
@@ -491,7 +503,7 @@ public class BasicTreeUI extends TreeUI
{
tree.setShowsRootHandles(newValue);
}
-
+
/**
* Returns true if the node handles are to be displayed.
*
@@ -501,7 +513,7 @@ public class BasicTreeUI extends TreeUI
{
return tree.getShowsRootHandles();
}
-
+
/**
* Sets the cell editor.
*
@@ -511,7 +523,7 @@ public class BasicTreeUI extends TreeUI
{
cellEditor = editor;
}
-
+
/**
* Returns the <code>TreeCellEditor</code> for this tree.
*
@@ -521,7 +533,7 @@ public class BasicTreeUI extends TreeUI
{
return cellEditor;
}
-
+
/**
* Configures the receiver to allow, or not allow, editing.
*
@@ -531,7 +543,7 @@ public class BasicTreeUI extends TreeUI
{
tree.setEditable(newValue);
}
-
+
/**
* Returns true if the receiver allows editing.
*
@@ -541,7 +553,7 @@ public class BasicTreeUI extends TreeUI
{
return tree.isEditable();
}
-
+
/**
* Resets the selection model. The appropriate listeners are installed on the
* model.
@@ -556,7 +568,7 @@ public class BasicTreeUI extends TreeUI
tree.setSelectionModel(treeSelectionModel);
}
}
-
+
/**
* Returns the current selection model.
*
@@ -566,7 +578,7 @@ public class BasicTreeUI extends TreeUI
{
return treeSelectionModel;
}
-
+
/**
* Returns the Rectangle enclosing the label portion that the last item in
* path will be drawn to. Will return null if any component in path is
@@ -583,17 +595,19 @@ public class BasicTreeUI extends TreeUI
{
Object cell = path.getLastPathComponent();
TreeModel mod = tree.getModel();
- TreeNode root = (TreeNode) mod.getRoot();
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath(root)))
- root = getNextNode(root);
-
- Point loc = getCellLocation(0, 0, tree, mod, cell, root);
- return getCellBounds(loc.x, loc.y, cell);
+ if (mod != null)
+ {
+ Object root = mod.getRoot();
+ if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
+ root = getNextNode(root);
+
+ Point loc = getCellLocation(0, 0, tree, mod, cell, root);
+ return getCellBounds(loc.x, loc.y, cell);
+ }
}
return null;
}
-
+
/**
* Returns the path for passed in row. If row is not visible null is
* returned.
@@ -605,22 +619,25 @@ public class BasicTreeUI extends TreeUI
*/
public TreePath getPathForRow(JTree tree, int row)
{
- TreeNode node = ((TreeNode) (tree.getModel()).getRoot());
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath(getPathToRoot(node, 0))))
- node = getNextNode(node);
-
- for (int i = 0; i < row; i++)
- node = getNextVisibleNode(node);
-
- // in case nothing was found
- if (node == null)
- return null;
-
- // something was found
- return new TreePath(getPathToRoot(node, 0));
+ TreeModel mod = tree.getModel();
+ if (mod != null)
+ {
+ Object node = mod.getRoot();
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath(getPathToRoot(node, 0))))
+ node = getNextNode(node);
+
+ for (int i = 0; i < row; i++)
+ node = getNextVisibleNode(node);
+
+ if (node == null)
+ return null;
+
+ return new TreePath(getPathToRoot(node, 0));
+ }
+ return null;
}
-
+
/**
* Returns the row that the last item identified in path is visible at. Will
* return -1 if any of the elments in the path are not currently visible.
@@ -638,7 +655,7 @@ public class BasicTreeUI extends TreeUI
// expand/collapse is not implemented
return path.getPathCount() - 1;
}
-
+
/**
* Returns the number of rows that are being displayed.
*
@@ -647,23 +664,24 @@ public class BasicTreeUI extends TreeUI
*/
public int getRowCount(JTree tree)
{
- TreeNode node = ((TreeNode) (tree.getModel())
- .getRoot());
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath((getPathToRoot(node, 0)))))
- node = getNextNode(node);
-
+ TreeModel mod = tree.getModel();
int count = 0;
-
- while (node != null)
+ if (mod != null)
{
- count++;
- node = getNextVisibleNode(node);
+ Object node = mod.getRoot();
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath((getPathToRoot(node, 0)))))
+ node = getNextNode(node);
+
+ while (node != null)
+ {
+ count++;
+ node = getNextVisibleNode(node);
+ }
}
-
return count;
}
-
+
/**
* Returns the path to the node that is closest to x,y. If there is nothing
* currently visible this will return null, otherwise it'll always return a
@@ -679,20 +697,20 @@ public class BasicTreeUI extends TreeUI
{
//FIXME: what if root is hidden? should not depend on (0,0)
// should start counting rows from where root is.
-
+
int row = Math.round(y / getRowHeight());
TreePath path = getPathForRow(tree, row);
-
+
// no row is visible at this node
while (row > 0 && path == null)
{
--row;
path = getPathForRow(tree, row);
}
-
+
return path;
}
-
+
/**
* Returns true if the tree is being edited. The item that is being edited
* can be returned by getEditingPath().
@@ -705,7 +723,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Stops the current editing session. This has no effect if the tree is not
* being edited. Returns true if the editor allows the editing session to
@@ -719,7 +737,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Cancels the current editing session.
*
@@ -729,7 +747,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Selects the last item in path and tries to edit it. Editing will fail if
* the CellEditor won't allow it for the selected item.
@@ -741,7 +759,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Returns the path to the element that is being editted.
*
@@ -753,7 +771,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return null;
}
-
+
/**
* Invoked after the tree instance variable has been set, but before any
* default/listeners have been installed.
@@ -762,7 +780,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Invoked from installUI after all the defaults/listeners have been
* installed.
@@ -771,7 +789,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Invoked from uninstallUI after all the defaults/listeners have been
* uninstalled.
@@ -780,7 +798,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Installs the subcomponents of the tree, which is the renderer pane.
*/
@@ -788,7 +806,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Creates an instance of NodeDimensions that is able to determine the size
* of a given node in the tree.
@@ -800,7 +818,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return null;
}
-
+
/**
* Creates a listener that is reponsible for the updates the UI based on how
* the tree changes.
@@ -811,7 +829,7 @@ public class BasicTreeUI extends TreeUI
{
return new PropertyChangeHandler();
}
-
+
/**
* Creates the listener responsible for updating the selection based on mouse
* events.
@@ -822,7 +840,7 @@ public class BasicTreeUI extends TreeUI
{
return new MouseHandler();
}
-
+
/**
* Creates the listener that is responsible for updating the display when
* focus is lost/grained.
@@ -833,7 +851,7 @@ public class BasicTreeUI extends TreeUI
{
return new FocusHandler();
}
-
+
/**
* Creates the listener reponsible for getting key events from the tree.
*
@@ -843,7 +861,7 @@ public class BasicTreeUI extends TreeUI
{
return new KeyHandler();
}
-
+
/**
* Creates the listener responsible for getting property change events from
* the selection model.
@@ -855,7 +873,7 @@ public class BasicTreeUI extends TreeUI
{
return new SelectionModelPropertyChangeHandler();
}
-
+
/**
* Creates the listener that updates the display based on selection change
* methods.
@@ -866,7 +884,7 @@ public class BasicTreeUI extends TreeUI
{
return new TreeSelectionHandler();
}
-
+
/**
* Creates a listener to handle events from the current editor
*
@@ -876,7 +894,7 @@ public class BasicTreeUI extends TreeUI
{
return new CellEditorHandler();
}
-
+
/**
* Creates and returns a new ComponentHandler. This is used for the large
* model to mark the validCachedPreferredSize as invalid when the component
@@ -888,7 +906,7 @@ public class BasicTreeUI extends TreeUI
{
return new ComponentHandler();
}
-
+
/**
* Creates and returns the object responsible for updating the treestate when
* a nodes expanded state changes.
@@ -899,7 +917,7 @@ public class BasicTreeUI extends TreeUI
{
return new TreeExpansionHandler();
}
-
+
/**
* Creates the object responsible for managing what is expanded, as well as
* the size of nodes.
@@ -910,7 +928,7 @@ public class BasicTreeUI extends TreeUI
{
return new FixedHeightLayoutCache();
}
-
+
/**
* Returns the renderer pane that renderer components are placed in.
*
@@ -920,7 +938,7 @@ public class BasicTreeUI extends TreeUI
{
return new CellRendererPane();
}
-
+
/**
* Creates a default cell editor.
*
@@ -928,10 +946,12 @@ public class BasicTreeUI extends TreeUI
*/
protected TreeCellEditor createDefaultCellEditor()
{
- return new DefaultTreeCellEditor(tree,
- (DefaultTreeCellRenderer) createDefaultCellRenderer(), cellEditor);
+ return new DefaultTreeCellEditor(
+ tree,
+ (DefaultTreeCellRenderer) createDefaultCellRenderer(),
+ cellEditor);
}
-
+
/**
* Returns the default cell renderer that is used to do the stamping of each
* node.
@@ -943,7 +963,7 @@ public class BasicTreeUI extends TreeUI
{
return new DefaultTreeCellRenderer();
}
-
+
/**
* Returns a listener that can update the tree when the model changes.
*
@@ -953,7 +973,7 @@ public class BasicTreeUI extends TreeUI
{
return new TreeModelHandler();
}
-
+
/**
* Uninstall all registered listeners
*/
@@ -967,7 +987,7 @@ public class BasicTreeUI extends TreeUI
tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
tree.removeComponentListener(componentListener);
tree.removeTreeExpansionListener(treeExpansionListener);
-
+
TreeCellEditor tce = tree.getCellEditor();
if (tce != null)
tce.removeCellEditorListener(cellEditorListener);
@@ -975,14 +995,14 @@ public class BasicTreeUI extends TreeUI
if (tm != null)
tm.removeTreeModelListener(treeModelListener);
}
-
+
/**
* Uninstall all keyboard actions.
*/
protected void uninstallKeyboardActions()
{
}
-
+
/**
* Uninstall the rendererPane.
*/
@@ -990,7 +1010,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* The vertical element of legs between nodes starts at the bottom of the
* parent node by default. This method makes the leg start below that.
@@ -1002,7 +1022,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return 0;
}
-
+
/**
* The horizontal element of legs between nodes starts at the right of the
* left-hand side of the child node by default. This method makes the leg end
@@ -1015,7 +1035,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return 0;
}
-
+
/**
* Make all the nodes that are expanded in JTree expanded in LayoutCache.
* This invokes update ExpandedDescendants with the root path.
@@ -1024,7 +1044,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Updates the expanded state of all the descendants of the <code>path</code>
* by getting the expanded descendants from the tree and forwarding to the
@@ -1036,7 +1056,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Returns a path to the last child of <code>parent</code>
*
@@ -1047,7 +1067,7 @@ public class BasicTreeUI extends TreeUI
{
return ((TreePath) parent.getLastPathComponent());
}
-
+
/**
* Updates how much each depth should be offset by.
*/
@@ -1055,7 +1075,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Updates the cellEditor based on editability of the JTree that we're
* contained in. Ig the tree is editable but doesn't have a cellEditor, a
@@ -1065,7 +1085,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Messaged from the tree we're in when the renderer has changed.
*/
@@ -1073,7 +1093,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Resets the treeState instance based on the tree we're providing the look
* and feel for.
@@ -1082,7 +1102,7 @@ public class BasicTreeUI extends TreeUI
{
treeState = createLayoutCache();
}
-
+
/**
* Marks the cached size as being invalid, and messages the tree with
* <code>treeDidChange</code>.
@@ -1091,7 +1111,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Updates the <code>preferredSize</code> instance variable, which is
* returned from <code>getPreferredSize()</code>. For left to right
@@ -1103,7 +1123,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Messaged from the VisibleTreeNode after it has been expanded.
*
@@ -1113,7 +1133,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Messaged from the VisibleTreeNode after it has collapsed
*/
@@ -1121,7 +1141,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Install all defaults for the tree.
*
@@ -1130,24 +1150,24 @@ public class BasicTreeUI extends TreeUI
protected void installDefaults(JTree tree)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
+
tree.setFont(defaults.getFont("Tree.font"));
tree.setForeground(defaults.getColor("Tree.foreground"));
tree.setBackground(defaults.getColor("Tree.background"));
tree.setOpaque(true);
-
+
rightChildIndent = defaults.getInt("Tree.rightChildIndent");
leftChildIndent = defaults.getInt("Tree.leftChildIndent");
setRowHeight(defaults.getInt("Tree.rowHeight"));
}
-
+
/**
* Install all keyboard actions for this
*/
protected void installKeyboardActions()
{
}
-
+
/**
* Install all listeners for this
*/
@@ -1162,9 +1182,10 @@ public class BasicTreeUI extends TreeUI
tree.addComponentListener(componentListener);
cellEditor.addCellEditorListener(cellEditorListener);
tree.addTreeExpansionListener(treeExpansionListener);
- treeModel.addTreeModelListener(treeModelListener);
+ if (treeModel != null)
+ treeModel.addTreeModelListener(treeModelListener);
}
-
+
/**
* Install the UI for the component
*
@@ -1175,15 +1196,17 @@ public class BasicTreeUI extends TreeUI
super.installUI(c);
installDefaults((JTree) c);
tree = (JTree) c;
- setModel(tree.getModel());
+ TreeModel mod = tree.getModel();
+ setModel(mod);
tree.setRootVisible(true);
- tree.expandPath(new TreePath(tree.getModel().getRoot()));
+ if (mod != null)
+ tree.expandPath(new TreePath(mod.getRoot()));
treeSelectionModel = tree.getSelectionModel();
installListeners();
installKeyboardActions();
completeUIInstall();
}
-
+
/**
* Uninstall the defaults for the tree
*
@@ -1191,13 +1214,11 @@ public class BasicTreeUI extends TreeUI
*/
protected void uninstallDefaults(JTree tree)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
tree.setFont(null);
tree.setForeground(null);
tree.setBackground(null);
- tree.setCellRenderer(null);
}
-
+
/**
* Uninstall the UI for the component
*
@@ -1211,7 +1232,7 @@ public class BasicTreeUI extends TreeUI
tree = null;
completeUIUninstall();
}
-
+
/**
* Paints the specified component appropriate for the look and feel. This
* method is invoked from the ComponentUI.update method when the specified
@@ -1227,17 +1248,20 @@ public class BasicTreeUI extends TreeUI
{
JTree tree = (JTree) c;
TreeModel mod = tree.getModel();
- Object root = mod.getRoot();
-
- if (!tree.isRootVisible())
- tree.expandPath(new TreePath(root));
-
- paintRecursive(g, 0, 0, 0, 0, tree, mod, root);
-
- if (hasControlIcons())
- paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);
- }
-
+ if (mod != null)
+ {
+ Object root = mod.getRoot();
+
+ if (!tree.isRootVisible())
+ tree.expandPath(new TreePath(root));
+
+ paintRecursive(g, 0, 0, 0, 0, tree, mod, root);
+
+ if (hasControlIcons())
+ paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);
+ }
+ }
+
/**
* Ensures that the rows identified by beginRow through endRow are visible.
*
@@ -1248,7 +1272,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Sets the preferred minimum size.
*
@@ -1258,7 +1282,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Gets the preferred minimum size.
*
@@ -1269,7 +1293,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return null;
}
-
+
/**
* Returns the preferred size to properly display the tree, this is a cover
* method for getPreferredSize(c, false).
@@ -1283,7 +1307,7 @@ public class BasicTreeUI extends TreeUI
{
return getPreferredSize(c, false);
}
-
+
/**
* Returns the preferred size to represent the tree in c. If checkConsistancy
* is true, checkConsistancy is messaged first.
@@ -1295,26 +1319,30 @@ public class BasicTreeUI extends TreeUI
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)
{
// FIXME: checkConsistancy not implemented, c not used
- TreeNode node = ((TreeNode) (tree.getModel())
- .getRoot());
+ TreeModel model = tree.getModel();
int maxWidth = 0;
int count = 0;
- if (node != null)
+ if (model != null)
{
- maxWidth = (int) (getCellBounds(0, 0, node).getWidth());
- while (node != null)
+ Object node = model.getRoot();
+ if (node != null)
{
- count++;
- TreeNode nextNode = getNextVisibleNode(node);
- if (nextNode != null)
- maxWidth = Math.max(maxWidth, (int) (getCellBounds(0, 0, nextNode)
- .getWidth()));
- node = nextNode;
+ maxWidth = (int) (getCellBounds(0, 0, node).getWidth());
+ while (node != null)
+ {
+ count++;
+ Object nextNode = getNextVisibleNode(node);
+ if (nextNode != null)
+ maxWidth = Math.max(
+ maxWidth,
+ (int) (getCellBounds(0, 0, nextNode).getWidth()));
+ node = nextNode;
+ }
}
}
return new Dimension(maxWidth, (getRowHeight() * count));
}
-
+
/**
* Returns the minimum size for this component. Which will be the min
* preferred size or (0,0).
@@ -1327,7 +1355,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return getPreferredSize(c);
}
-
+
/**
* Returns the maximum size for the component, which will be the preferred
* size if the instance is currently in JTree or (0,0).
@@ -1340,7 +1368,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return getPreferredSize(c);
}
-
+
/**
* Messages to stop the editing session. If the UI the receiver is providing
* the look and feel for returns true from
@@ -1352,7 +1380,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Stops the editing session. If messageStop is true, the editor is messaged
* with stopEditing, if messageCancel is true the editor is messaged with
@@ -1368,7 +1396,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Will start editing for node if there is a cellEditor and shouldSelectCall
* returns true. This assumes that path is valid and visible.
@@ -1382,7 +1410,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* If the <code>mouseX</code> and <code>mouseY</code> are in the expand
* or collapse region of the row, this will toggle the row.
@@ -1396,7 +1424,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Returns true if the <code>mouseX</code> and <code>mouseY</code> fall
* in the area of row that is used to expand/collpse the node and the node at
@@ -1415,7 +1443,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Messaged when the user clicks the particular row, this invokes
* toggleExpandState.
@@ -1428,7 +1456,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Expands path if it is not expanded, or collapses row if it is expanded. If
* expanding a path and JTree scroll on expand, ensureRowsAreVisible is
@@ -1441,7 +1469,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Returning true signifies a mouse event on the node should toggle the
* selection of only the row under the mouse.
@@ -1455,7 +1483,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Returning true signifies a mouse event on the node should select from the
* anchor point.
@@ -1469,7 +1497,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Returning true indicates the row under the mouse should be toggled based
* on the event. This is invoked after checkForClickInExpandControl, implying
@@ -1484,7 +1512,7 @@ public class BasicTreeUI extends TreeUI
// FIXME: not implemented
return false;
}
-
+
/**
* Messaged to update the selection based on a MouseEvent over a particular
* row. If the even is a toggle selection event, the row is either selected,
@@ -1500,7 +1528,7 @@ public class BasicTreeUI extends TreeUI
{
// FIXME: not implemented
}
-
+
/**
* Returns true if the node at <code>row</code> is a leaf.
*
@@ -1512,37 +1540,33 @@ public class BasicTreeUI extends TreeUI
TreePath pathForRow = getPathForRow(tree, row);
if (pathForRow == null)
return true;
-
+
Object node = pathForRow.getLastPathComponent();
-
- if (node instanceof TreeNode)
- return ((TreeNode) node).isLeaf();
- else
- return true;
+ return tree.getModel().isLeaf(node);
}
-
+
/**
* Updates the preferred size when scrolling, if necessary.
*/
public class ComponentHandler
- extends ComponentAdapter
- implements ActionListener
+ extends ComponentAdapter
+ implements ActionListener
{
/**
* Timer used when inside a scrollpane and the scrollbar is adjusting
*/
protected Timer timer;
-
+
/** ScrollBar that is being adjusted */
protected JScrollBar scrollBar;
-
+
/**
* Constructor
*/
public ComponentHandler()
{
}
-
+
/**
* Invoked when the component's position changes.
*
@@ -1551,7 +1575,7 @@ public class BasicTreeUI extends TreeUI
public void componentMoved(ComponentEvent e)
{
}
-
+
/**
* Creats, if necessary, and starts a Timer to check if needed to resize
* the bounds
@@ -1559,7 +1583,7 @@ public class BasicTreeUI extends TreeUI
protected void startTimer()
{
}
-
+
/**
* Returns the JScrollPane housing the JTree, or null if one isn't found.
*
@@ -1569,7 +1593,7 @@ public class BasicTreeUI extends TreeUI
{
return null;
}
-
+
/**
* Public as a result of Timer. If the scrollBar is null, or not
* adjusting, this stops the timer and updates the sizing.
@@ -1580,13 +1604,13 @@ public class BasicTreeUI extends TreeUI
{
}
}// ComponentHandler
-
+
/**
* Listener responsible for getting cell editing events and updating the tree
* accordingly.
*/
public class CellEditorHandler
- implements CellEditorListener
+ implements CellEditorListener
{
/**
* Constructor
@@ -1594,7 +1618,7 @@ public class BasicTreeUI extends TreeUI
public CellEditorHandler()
{
}
-
+
/**
* Messaged when editing has stopped in the tree. Tells the listeners
* editing has stopped.
@@ -1604,7 +1628,7 @@ public class BasicTreeUI extends TreeUI
public void editingStopped(ChangeEvent e)
{
}
-
+
/**
* Messaged when editing has been canceled in the tree. This tells the
* listeners the editor has canceled editing.
@@ -1615,12 +1639,12 @@ public class BasicTreeUI extends TreeUI
{
}
}// CellEditorHandler
-
+
/**
* Repaints the lead selection row when focus is lost/grained.
*/
public class FocusHandler
- implements FocusListener
+ implements FocusListener
{
/**
* Constructor
@@ -1628,7 +1652,7 @@ public class BasicTreeUI extends TreeUI
public FocusHandler()
{
}
-
+
/**
* Invoked when focus is activated on the tree we're in, redraws the lead
* row. Invoked when a component gains the keyboard focus.
@@ -1638,7 +1662,7 @@ public class BasicTreeUI extends TreeUI
public void focusGained(FocusEvent e)
{
}
-
+
/**
* Invoked when focus is deactivated on the tree we're in, redraws the
* lead row. Invoked when a component loses the keyboard focus.
@@ -1649,27 +1673,27 @@ public class BasicTreeUI extends TreeUI
{
}
}// FocusHandler
-
+
/**
* This is used to get multiple key down events to appropriately genereate
* events.
*/
public class KeyHandler
- extends KeyAdapter
+ extends KeyAdapter
{
/** Key code that is being generated for. */
protected Action repeatKeyAction;
-
+
/** Set to true while keyPressed is active */
protected boolean isKeyDown;
-
+
/**
* Constructor
*/
public KeyHandler()
{
}
-
+
/**
* Invoked when a key has been typed. Moves the keyboard focus to the
* first element whose first letter matches the alphanumeric key pressed
@@ -1681,7 +1705,7 @@ public class BasicTreeUI extends TreeUI
public void keyTyped(KeyEvent e)
{
}
-
+
/**
* Invoked when a key has been pressed.
*
@@ -1689,63 +1713,84 @@ public class BasicTreeUI extends TreeUI
*/
public void keyPressed(KeyEvent e)
{
+ TreeModel mod = BasicTreeUI.this.tree.getModel();
TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath();
- TreeNode last = null;
+ Object last = null;
if (start != null)
- last = (TreeNode) start.getLastPathComponent();
-
+ last = start.getLastPathComponent();
+
if (last != null)
{
// DOWN, KP_DOWN
if (e.getKeyCode() == KeyEvent.VK_DOWN
|| e.getKeyCode() == KeyEvent.VK_KP_DOWN)
{
- TreeNode next = (TreeNode) BasicTreeUI.this.
- getNextVisibleNode(last);
+ Object next = BasicTreeUI.this.getNextVisibleNode(last);
if (next != null)
{
TreePath newPath = new TreePath(getPathToRoot(next, 0));
BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath);
if (e.isControlDown())
tree.setLeadSelectionPath(newPath);
- else if (!next.isLeaf() && e.isShiftDown())
+ else if (!mod.isLeaf(next) && e.isShiftDown())
{
BasicTreeUI.this.tree.expandPath(newPath);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillExpand(newPath);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeExpanded(newPath);
}
}
}
// UP, KP_UP
else if (e.getKeyCode() == KeyEvent.VK_UP
- || e.getKeyCode() == KeyEvent.VK_KP_UP)
+ || e.getKeyCode() == KeyEvent.VK_KP_UP)
{
- TreeNode prev = (TreeNode) BasicTreeUI.this.
- getPreviousVisibleNode(last);
-
+ Object prev = BasicTreeUI.this.getPreviousVisibleNode(last);
+
if (prev != null)
{
TreePath newPath = new TreePath(getPathToRoot(prev, 0));
BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
- new TreePath(getPathToRoot(prev, 0)));
+ new TreePath(getPathToRoot(prev,
+ 0)));
if (e.isControlDown())
tree.setLeadSelectionPath(newPath);
- else if (!prev.isLeaf() && e.isShiftDown())
+ else if (!mod.isLeaf(prev) && e.isShiftDown())
{
BasicTreeUI.this.tree.expandPath(newPath);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillExpand(newPath);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeExpanded(newPath);
}
}
}
// LEFT, KP_LEFT
else if (e.getKeyCode() == KeyEvent.VK_LEFT
- || e.getKeyCode() == KeyEvent.VK_KP_LEFT)
+ || e.getKeyCode() == KeyEvent.VK_KP_LEFT)
{
TreePath path = new TreePath(getPathToRoot(last, 0));
- TreeNode p = last.getParent();
-
- if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path))
+ Object p = getParent(mod.getRoot(), last);
+
+ if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isExpanded(path))
{
BasicTreeUI.this.tree.collapsePath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillCollapse(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeCollapsed(path);
}
else if (p != null)
@@ -1754,46 +1799,70 @@ public class BasicTreeUI extends TreeUI
}
// RIGHT, KP_RIGHT
else if (e.getKeyCode() == KeyEvent.VK_RIGHT
- || e.getKeyCode() == KeyEvent.VK_KP_RIGHT)
+ || e.getKeyCode() == KeyEvent.VK_KP_RIGHT)
{
TreePath path = new TreePath(getPathToRoot(last, 0));
-
- if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path))
+
+ if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isCollapsed(path))
{
BasicTreeUI.this.tree.expandPath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillExpand(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeExpanded(path);
}
else
{
- TreeNode next = (TreeNode) BasicTreeUI.this.
- getNextVisibleNode(last);
-
+ Object next = BasicTreeUI.this.getNextVisibleNode(last);
+
if (next != null)
- BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
- new TreePath(getPathToRoot(next, 0)));
+ BasicTreeUI.this.selectPath(
+ BasicTreeUI.this.tree,
+ new TreePath(
+ getPathToRoot(
+ next,
+ 0)));
}
}
// Enter
else if (e.getKeyCode() == KeyEvent.VK_ENTER)
{
TreePath path = new TreePath(getPathToRoot(last, 0));
- if (!last.isLeaf())
+ if (!mod.isLeaf(last))
{
if (BasicTreeUI.this.tree.isExpanded(path))
{
BasicTreeUI.this.tree.collapsePath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillCollapse(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeCollapsed(path);
}
else
{
BasicTreeUI.this.tree.expandPath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillExpand(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeExpanded(path);
}
}
}
}
}
-
+
/**
* Invoked when a key has been released
*
@@ -1803,14 +1872,14 @@ public class BasicTreeUI extends TreeUI
{
}
}// KeyHandler
-
+
/**
* MouseListener is responsible for updating the selevtion based on mouse
* events.
*/
public class MouseHandler
- extends MouseAdapter
- implements MouseMotionListener
+ extends MouseAdapter
+ implements MouseMotionListener
{
/**
* Constructor
@@ -1818,7 +1887,7 @@ public class BasicTreeUI extends TreeUI
public MouseHandler()
{
}
-
+
/**
* Invoked when a mouse button has been pressed on a component.
*
@@ -1827,7 +1896,7 @@ public class BasicTreeUI extends TreeUI
public void mousePressed(MouseEvent e)
{
}
-
+
/**
* Invoked when a mouse button is pressed on a component and then dragged.
* MOUSE_DRAGGED events will continue to be delivered to the component
@@ -1840,7 +1909,7 @@ public class BasicTreeUI extends TreeUI
public void mouseDragged(MouseEvent e)
{
}
-
+
/**
* Invoked when the mouse button has been moved on a component (with no
* buttons no down).
@@ -1850,7 +1919,7 @@ public class BasicTreeUI extends TreeUI
public void mouseMoved(MouseEvent e)
{
}
-
+
/**
* Invoked when a mouse button has been released on a component.
*
@@ -1860,27 +1929,27 @@ public class BasicTreeUI extends TreeUI
{
}
}// MouseHandler
-
+
/**
* MouseInputHandler handles passing all mouse events, including mouse motion
* events, until the mouse is released to the destination it is constructed
* with.
*/
public class MouseInputHandler
- implements MouseInputListener
+ implements MouseInputListener
{
/** Source that events are coming from */
protected Component source;
-
+
/** Destination that receives all events. */
protected Component destination;
-
+
/** Number of mouse clicks on a non-leaf */
private int clickCount = 0;
-
+
/** The last non-leaf cell that was clicked */
private Object lastClicked = null;
-
+
/**
* Constructor
*
@@ -1892,7 +1961,7 @@ public class BasicTreeUI extends TreeUI
MouseEvent e)
{
}
-
+
/**
* Invoked when the mouse button has been clicked (pressed and released)
* on a component.
@@ -1903,28 +1972,28 @@ public class BasicTreeUI extends TreeUI
{
Point click = e.getPoint();
int row = Math.round(click.y / BasicTreeUI.this.getRowHeight());
- TreePath path = BasicTreeUI.this.getClosestPathForLocation(tree,
- click.x, click.y);
-
+ TreePath path = BasicTreeUI.this.getClosestPathForLocation(tree, click.x,
+ click.y);
+
if (path != null)
{
boolean inBounds = false;
boolean cntlClick = false;
Rectangle bounds = BasicTreeUI.this.getPathBounds(
- BasicTreeUI.this.tree, path);
-
+ BasicTreeUI.this.tree,
+ path);
+
bounds.x -= rightChildIndent - 4;
bounds.width += rightChildIndent + 4;
-
+
if (bounds.contains(click.x, click.y))
inBounds = true;
else if (BasicTreeUI.this.hasControlIcons()
- && (click.x < (bounds.x - rightChildIndent + 5) &&
- click.x > (bounds.x - rightChildIndent - 5)))
+ && (click.x < (bounds.x - rightChildIndent + 5) && click.x > (bounds.x
+ - rightChildIndent - 5)))
cntlClick = true;
-
- if ((inBounds || cntlClick)
- && BasicTreeUI.this.tree.isVisible(path))
+
+ if ((inBounds || cntlClick) && BasicTreeUI.this.tree.isVisible(path))
{
if (!cntlClick && !BasicTreeUI.this.isLeaf(row))
{
@@ -1937,7 +2006,7 @@ public class BasicTreeUI extends TreeUI
clickCount = 1;
}
}
-
+
if (clickCount == 2 || cntlClick == true)
{
clickCount = 0;
@@ -1946,20 +2015,34 @@ public class BasicTreeUI extends TreeUI
if (BasicTreeUI.this.tree.isExpanded(path))
{
BasicTreeUI.this.tree.collapsePath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillCollapse(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeCollapsed(path);
}
else
{
BasicTreeUI.this.tree.expandPath(path);
+ try
+ {
+ BasicTreeUI.this.tree.fireTreeWillExpand(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
BasicTreeUI.this.tree.fireTreeExpanded(path);
}
}
-
+
BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, path);
}
}
}
-
+
/**
* Invoked when a mouse button has been pressed on a component.
*
@@ -1968,7 +2051,7 @@ public class BasicTreeUI extends TreeUI
public void mousePressed(MouseEvent e)
{
}
-
+
/**
* Invoked when a mouse button has been released on a component.
*
@@ -1977,7 +2060,7 @@ public class BasicTreeUI extends TreeUI
public void mouseReleased(MouseEvent e)
{
}
-
+
/**
* Invoked when the mouse enters a component.
*
@@ -1986,7 +2069,7 @@ public class BasicTreeUI extends TreeUI
public void mouseEntered(MouseEvent e)
{
}
-
+
/**
* Invoked when the mouse exits a component.
*
@@ -1995,7 +2078,7 @@ public class BasicTreeUI extends TreeUI
public void mouseExited(MouseEvent e)
{
}
-
+
/**
* Invoked when a mouse button is pressed on a component and then dragged.
* MOUSE_DRAGGED events will continue to be delivered to the component
@@ -2008,7 +2091,7 @@ public class BasicTreeUI extends TreeUI
public void mouseDragged(MouseEvent e)
{
}
-
+
/**
* Invoked when the mouse cursor has been moved onto a component but no
* buttons have been pushed.
@@ -2018,7 +2101,7 @@ public class BasicTreeUI extends TreeUI
public void mouseMoved(MouseEvent e)
{
}
-
+
/**
* Removes event from the source
*/
@@ -2026,14 +2109,14 @@ public class BasicTreeUI extends TreeUI
{
}
}// MouseInputHandler
-
+
/**
* Class responsible for getting size of node, method is forwarded to
* BasicTreeUI method. X location does not include insets, that is handled in
* getPathBounds.
*/
public class NodeDimensionsHandler
- extends AbstractLayoutCache.NodeDimensions
+ extends AbstractLayoutCache.NodeDimensions
{
/**
* Constructor
@@ -2041,7 +2124,7 @@ public class BasicTreeUI extends TreeUI
public NodeDimensionsHandler()
{
}
-
+
/**
* Responsible for getting the size of a particular node.
*
@@ -2058,7 +2141,7 @@ public class BasicTreeUI extends TreeUI
{
return null;
}
-
+
/**
* Returns the amount to indent the given row
*
@@ -2069,22 +2152,22 @@ public class BasicTreeUI extends TreeUI
return 0;
}
}// NodeDimensionsHandler
-
+
/**
* PropertyChangeListener for the tree. Updates the appropriate varaible, or
* TreeState, based on what changes.
*/
public class PropertyChangeHandler
- implements PropertyChangeListener
+ implements PropertyChangeListener
{
-
+
/**
* Constructor
*/
public PropertyChangeHandler()
{
}
-
+
/**
* This method gets called when a bound property is changed.
*
@@ -2095,22 +2178,22 @@ public class BasicTreeUI extends TreeUI
{
}
}// PropertyChangeHandler
-
+
/**
* Listener on the TreeSelectionModel, resets the row selection if any of the
* properties of the model change.
*/
public class SelectionModelPropertyChangeHandler
- implements PropertyChangeListener
+ implements PropertyChangeListener
{
-
+
/**
* Constructor
*/
public SelectionModelPropertyChangeHandler()
{
}
-
+
/**
* This method gets called when a bound property is changed.
*
@@ -2121,21 +2204,21 @@ public class BasicTreeUI extends TreeUI
{
}
}// SelectionModelPropertyChangeHandler
-
+
/**
* ActionListener that invokes cancelEditing when action performed.
*/
public class TreeCancelEditingAction
- extends AbstractAction
+ extends AbstractAction
{
-
+
/**
* Constructor
*/
public TreeCancelEditingAction()
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2144,7 +2227,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2155,21 +2238,21 @@ public class BasicTreeUI extends TreeUI
return false;
}
}// TreeCancelEditingAction
-
+
/**
* Updates the TreeState in response to nodes expanding/collapsing.
*/
public class TreeExpansionHandler
- implements TreeExpansionListener
+ implements TreeExpansionListener
{
-
+
/**
* Constructor
*/
public TreeExpansionHandler()
{
}
-
+
/**
* Called whenever an item in the tree has been expanded.
*
@@ -2179,7 +2262,7 @@ public class BasicTreeUI extends TreeUI
{
BasicTreeUI.this.tree.repaint();
}
-
+
/**
* Called whenever an item in the tree has been collapsed.
*
@@ -2190,18 +2273,18 @@ public class BasicTreeUI extends TreeUI
BasicTreeUI.this.tree.repaint();
}
}// TreeExpansionHandler
-
+
/**
* TreeHomeAction is used to handle end/home actions. Scrolls either the
* first or last cell to be visible based on direction.
*/
public class TreeHomeAction
- extends AbstractAction
+ extends AbstractAction
{
-
+
/** direction is either home or end */
protected int direction;
-
+
/**
* Constructor
*
@@ -2211,7 +2294,7 @@ public class BasicTreeUI extends TreeUI
public TreeHomeAction(int direction, String name)
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2220,7 +2303,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2231,18 +2314,18 @@ public class BasicTreeUI extends TreeUI
return false;
}
}// TreeHomeAction
-
+
/**
* TreeIncrementAction is used to handle up/down actions. Selection is moved
* up or down based on direction.
*/
public class TreeIncrementAction
- extends AbstractAction
+ extends AbstractAction
{
-
+
/** Specifies the direction to adjust the selection by. */
protected int direction;
-
+
/**
* Constructor
*
@@ -2252,7 +2335,7 @@ public class BasicTreeUI extends TreeUI
public TreeIncrementAction(int direction, String name)
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2261,7 +2344,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2272,12 +2355,12 @@ public class BasicTreeUI extends TreeUI
return false;
}
}// TreeIncrementAction
-
+
/**
* Forwards all TreeModel events to the TreeState.
*/
public class TreeModelHandler
- implements TreeModelListener
+ implements TreeModelListener
{
/**
* Constructor
@@ -2285,7 +2368,7 @@ public class BasicTreeUI extends TreeUI
public TreeModelHandler()
{
}
-
+
/**
* Invoked after a node (or a set of siblings) has changed in some way.
* The node(s) have not changed locations in the tree or altered their
@@ -2301,7 +2384,7 @@ public class BasicTreeUI extends TreeUI
public void treeNodesChanged(TreeModelEvent e)
{
}
-
+
/**
* Invoked after nodes have been inserted into the tree. Use e.getPath()
* to get the parent of the new node(s). e.getChildIndices() returns the
@@ -2312,7 +2395,7 @@ public class BasicTreeUI extends TreeUI
public void treeNodesInserted(TreeModelEvent e)
{
}
-
+
/**
* Invoked after nodes have been removed from the tree. Note that if a
* subtree is removed from the tree, this method may only be invoked once
@@ -2326,7 +2409,7 @@ public class BasicTreeUI extends TreeUI
public void treeNodesRemoved(TreeModelEvent e)
{
}
-
+
/**
* Invoked after the tree has drastically changed structure from a given
* node down. If the path returned by e.getPath() is of length one and the
@@ -2340,16 +2423,16 @@ public class BasicTreeUI extends TreeUI
{
}
}// TreeModelHandler
-
+
/**
* TreePageAction handles page up and page down events.
*/
public class TreePageAction
- extends AbstractAction
+ extends AbstractAction
{
/** Specifies the direction to adjust the selection by. */
protected int direction;
-
+
/**
* Constructor
*
@@ -2359,7 +2442,7 @@ public class BasicTreeUI extends TreeUI
public TreePageAction(int direction, String name)
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2368,7 +2451,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2379,13 +2462,13 @@ public class BasicTreeUI extends TreeUI
return false;
}
}// TreePageAction
-
+
/**
* Listens for changes in the selection model and updates the display
* accordingly.
*/
public class TreeSelectionHandler
- implements TreeSelectionListener
+ implements TreeSelectionListener
{
/**
* Constructor
@@ -2393,7 +2476,7 @@ public class BasicTreeUI extends TreeUI
public TreeSelectionHandler()
{
}
-
+
/**
* Messaged when the selection changes in the tree we're displaying for.
* Stops editing, messages super and displays the changed paths.
@@ -2404,12 +2487,12 @@ public class BasicTreeUI extends TreeUI
{
}
}// TreeSelectionHandler
-
+
/**
* For the first selected row expandedness will be toggled.
*/
public class TreeToggleAction
- extends AbstractAction
+ extends AbstractAction
{
/**
* Constructor
@@ -2419,7 +2502,7 @@ public class BasicTreeUI extends TreeUI
public TreeToggleAction(String name)
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2428,7 +2511,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2439,20 +2522,20 @@ public class BasicTreeUI extends TreeUI
return false;
}
} // TreeToggleAction
-
+
/**
* TreeTraverseAction is the action used for left/right keys. Will toggle
* the expandedness of a node, as well as potentially incrementing the
* selection.
*/
public class TreeTraverseAction
- extends AbstractAction
+ extends AbstractAction
{
/**
* Determines direction to traverse, 1 means expand, -1 means collapse.
*/
protected int direction;
-
+
/**
* Constructor
*
@@ -2462,7 +2545,7 @@ public class BasicTreeUI extends TreeUI
public TreeTraverseAction(int direction, String name)
{
}
-
+
/**
* Invoked when an action occurs.
*
@@ -2471,7 +2554,7 @@ public class BasicTreeUI extends TreeUI
public void actionPerformed(ActionEvent e)
{
}
-
+
/**
* Returns true if the action is enabled.
*
@@ -2482,7 +2565,7 @@ public class BasicTreeUI extends TreeUI
return false;
}
} // TreeTraverseAction
-
+
/**
* Returns the cell bounds for painting selected cells
* Package private for use in inner classes.
@@ -2500,14 +2583,15 @@ public class BasicTreeUI extends TreeUI
String s = cell.toString();
Font f = tree.getFont();
FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());
-
+
if (s != null)
- return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4,
+ return new Rectangle(x, y,
+ SwingUtilities.computeStringWidth(fm, s) + 4,
fm.getHeight());
}
return new Rectangle(x, y, 0, 0);
}
-
+
/**
* Retrieves the location of some node, recursively starting at from
* some node.
@@ -2522,34 +2606,32 @@ public class BasicTreeUI extends TreeUI
*
* @return Point - the location of node
*/
- Point getCellLocation(int x, int y, JTree tree, TreeModel mod,
- Object node, Object startNode)
+ Point getCellLocation(int x, int y, JTree tree, TreeModel mod, Object node,
+ Object startNode)
{
int rowHeight = getRowHeight();
if (startNode == null || startNode.equals(node))
{
- if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot())))
- return new Point(x + ((getLevel((TreeNode) node)) *
- rightChildIndent), y);
-
- return new Point(x + ((getLevel((TreeNode) node) + 1)
- * rightChildIndent), y);
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath(mod.getRoot())))
+ return new Point(x + ((getLevel(node)) * rightChildIndent), y);
+
+ return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y);
}
-
+
if (!mod.isLeaf(startNode)
- && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode),
- 0))))
+ && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0)))
+ && mod.getChildCount(startNode) > 0)
{
Object child = mod.getChild(startNode, 0);
if (child != null)
- return getCellLocation(x, y + rowHeight, tree, mod,
- node, child);
+ return getCellLocation(x, y + rowHeight, tree, mod, node, child);
}
-
+
return getCellLocation(x, y + rowHeight, tree, mod, node,
- getNextVisibleNode((TreeNode) startNode));
+ getNextVisibleNode(startNode));
}
-
+
/**
* Paints a node in the tree Package private for use in inner classes.
*
@@ -2562,61 +2644,28 @@ public class BasicTreeUI extends TreeUI
void paintNode(Graphics g, int x, int y, JTree tree, Object node,
boolean isLeaf)
{
- TreePath curr = new TreePath(getPathToRoot(((TreeNode) node), 0));
+ TreePath curr = new TreePath(getPathToRoot(node, 0));
boolean selected = tree.isPathSelected(curr);
boolean expanded = false;
boolean hasIcons = false;
-
+
if (tree.isVisible(curr))
{
- DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)
- createDefaultCellRenderer();
-
+ TreeCellRenderer dtcr = tree.getCellRenderer();
+ if (dtcr == null)
+ dtcr = createDefaultCellRenderer();
+
if (!isLeaf)
expanded = tree.isExpanded(curr);
-
- Icon icon = null;
- if (!isLeaf && expanded)
- icon = dtcr.getOpenIcon();
- else if (!isLeaf && !expanded)
- icon = dtcr.getClosedIcon();
- else
- icon = dtcr.getLeafIcon();
-
- if (icon.getIconHeight() > -1 && icon.getIconWidth() > -1)
- hasIcons = true;
-
+
Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
- expanded, isLeaf, 0, false);
-
- if (hasIcons)
- {
- if (selected)
- {
- Rectangle cell = getPathBounds(tree, curr);
- g.setColor(dtcr.getBackgroundSelectionColor());
- g.fillRect(cell.x + icon.getIconWidth()/2, cell.y, cell.width,
- cell.height);
-
- if (curr.equals(tree.getLeadSelectionPath()))
- {
- g.setColor(UIManager.getLookAndFeelDefaults().getColor(
- "Tree.selectionBorderColor"));
- g.drawRect(cell.x + icon.getIconWidth()/2, cell.y,
- cell.width, cell.height);
- }
- }
-
- g.translate(x, y);
- c.paint(g);
- g.translate(-x, -y);
- }
- else
- rendererPane.paintComponent(g, c, c.getParent(),
- getCellBounds(x, y, node));
+ expanded, isLeaf, 0,
+ false);
+ rendererPane.paintComponent(g, c, c.getParent(), getCellBounds(x, y,
+ node));
}
}
-
+
/**
* Recursively paints all elements of the tree Package private for use in
* inner classes.
@@ -2632,20 +2681,20 @@ public class BasicTreeUI extends TreeUI
*
* @return int - current descent of the tree
*/
- int paintRecursive(Graphics g, int indentation, int descent,
- int childNumber, int depth, JTree tree, TreeModel mod, Object curr)
+ int paintRecursive(Graphics g, int indentation, int descent, int childNumber,
+ int depth, JTree tree, TreeModel mod, Object curr)
{
Rectangle clip = g.getClipBounds();
if (indentation > clip.x + clip.width + rightChildIndent
|| descent > clip.y + clip.height + getRowHeight())
return descent;
-
+
int halfHeight = getRowHeight() / 2;
int halfWidth = rightChildIndent / 2;
int y0 = descent + halfHeight;
int heightOfLine = descent + halfHeight;
boolean isRootVisible = tree.isRootVisible();
-
+
if (mod.isLeaf(curr))
{
paintNode(g, indentation + 4, descent, tree, curr, true);
@@ -2659,42 +2708,41 @@ public class BasicTreeUI extends TreeUI
descent += getRowHeight();
y0 += halfHeight;
}
-
+
int max = mod.getChildCount(curr);
- if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) curr), 0))))
+ if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
{
- for (int i = 0; i < max; ++i)
+ for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
if (!isRootVisible && depth == 0)
indent = 0;
- else if ((!isRootVisible && !curr.equals(mod.getRoot())) ||
- isRootVisible)
+ else if ((!isRootVisible && !curr.equals(mod.getRoot()))
+ || isRootVisible)
{
g.setColor(getHashColor());
heightOfLine = descent + halfHeight;
- g.drawLine(indentation + halfWidth, heightOfLine, indentation
- + rightChildIndent, heightOfLine);
+ g.drawLine(indentation + halfWidth, heightOfLine,
+ indentation + rightChildIndent, heightOfLine);
}
-
- descent = paintRecursive(g, indent,
- descent, i, depth + 1, tree, mod,
- mod.getChild(curr, i));
+
+ descent = paintRecursive(g, indent, descent, i, depth + 1,
+ tree, mod, mod.getChild(curr, i));
}
}
}
-
- if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) curr), 0))))
- if (y0 != heightOfLine)
+
+ if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
+ if (y0 != heightOfLine && mod.getChildCount(curr) > 0)
{
g.setColor(getHashColor());
g.drawLine(indentation + halfWidth, y0, indentation + halfWidth,
heightOfLine);
}
-
+
return descent;
}
-
+
/**
* Recursively paints all the control icons on the tree.
* Package private for use in inner classes.
@@ -2711,51 +2759,49 @@ public class BasicTreeUI extends TreeUI
* @return int - current descent of the tree
*/
int paintControlIcons(Graphics g, int indentation, int descent,
- int childNumber, int depth, JTree tree, TreeModel mod, Object node)
+ int childNumber, int depth, JTree tree, TreeModel mod,
+ Object node)
{
int h = descent;
int rowHeight = getRowHeight();
- Icon ei = UIManager.getLookAndFeelDefaults()
- .getIcon("Tree.expandedIcon");
- Icon ci = UIManager.getLookAndFeelDefaults()
- .getIcon("Tree.collapsedIcon");
+ Icon ei = UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon");
+ Icon ci = UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon");
Rectangle clip = g.getClipBounds();
if (indentation > clip.x + clip.width + rightChildIndent
|| descent > clip.y + clip.height + getRowHeight())
return descent;
-
+
if (mod.isLeaf(node))
descent += rowHeight;
- else
+ else
{
if (depth > 0 || tree.isRootVisible())
descent += rowHeight;
-
+
int max = mod.getChildCount(node);
- if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) node), 0))))
+ if (tree.isExpanded(new TreePath(getPathToRoot(node, 0))))
{
if (!node.equals(mod.getRoot()))
- drawCentered(tree, g, ei, indentation - rightChildIndent - 3, h);
-
- for (int i = 0; i < max; ++i)
+ ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h);
+
+ for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
if (depth == 0 && !tree.isRootVisible())
indent = -1;
-
- descent = paintControlIcons(g, indent,
- descent, i, depth + 1, tree, mod,
- mod.getChild(node, i));
+
+ descent = paintControlIcons(g, indent, descent, i, depth + 1,
+ tree, mod, mod.getChild(node, i));
}
}
else if (!node.equals(mod.getRoot()))
- drawCentered(tree, g, ei, indentation - rightChildIndent - 3,
+ ci.paintIcon(tree, g, indentation - rightChildIndent - 3,
descent - getRowHeight());
}
-
+
return descent;
}
-
+
/**
* Returns true if the LookAndFeel implements the control icons
* Package private for use in inner classes.
@@ -2764,47 +2810,84 @@ public class BasicTreeUI extends TreeUI
*/
boolean hasControlIcons()
{
- if (UIManager.getLookAndFeelDefaults().
- getIcon("Tree.expandedIcon") == null ||
- UIManager.getLookAndFeelDefaults().
- getIcon("Tree.collapsedIcon") == null)
+ if (UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon") == null
+ || UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon") == null)
return false;
return true;
}
-
+
/**
- * Get next visible node in the tree.
- * Package private for use in inner classes.
+ * Returns the parent of the current node
+ *
+ * @param root is the root of the tree
+ * @param node is the current node
+ * @return is the parent of the current node
+ */
+ Object getParent(Object root, Object node)
+ {
+ if (root == null || node == null)
+ return null;
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getParent();
+ return findNode(root, node);
+ }
+
+ /**
+ * Recursively checks the tree for the specified node, starting
+ * at the root.
+ *
+ * @param root is starting node to start searching at.
+ * @param node is the node to search for
+ * @return the parent node of node
+ */
+ private Object findNode(Object root, Object node)
+ {
+ TreeModel mod = tree.getModel();
+ for (int i = 0; i < mod.getChildCount(root); i++)
+ {
+ if (mod.getIndexOfChild(root, node) != -1)
+ return root;
+
+ Object n = findNode(mod.getChild(root, i), node);
+ if (n != null)
+ return n;
+ }
+ return null;
+ }
+
+ /**
+ * Get next visible node in the tree. Package private for use in inner
+ * classes.
*
* @param the current node
* @return the next visible node in the JTree. Return null if there are no
* more.
*/
- TreeNode getNextVisibleNode(TreeNode node)
+ Object getNextVisibleNode(Object node)
{
- TreeNode next = null;
+ Object next = null;
TreePath current = null;
-
+
if (node != null)
next = getNextNode(node);
-
+
if (next != null)
{
current = new TreePath(getPathToRoot(next, 0));
if (tree.isVisible(current))
return next;
-
+
while (next != null && !tree.isVisible(current))
{
next = getNextNode(next);
-
+
if (next != null)
current = new TreePath(getPathToRoot(next, 0));
}
}
return next;
}
-
+
/**
* Get previous visible node in the tree.
* Package private for use in inner classes.
@@ -2813,53 +2896,54 @@ public class BasicTreeUI extends TreeUI
* @return the next visible node in the JTree. Return null if there are no
* more.
*/
- TreeNode getPreviousVisibleNode(TreeNode node)
+ Object getPreviousVisibleNode(Object node)
{
- TreeNode prev = null;
+ Object prev = null;
TreePath current = null;
-
+
if (node != null)
prev = getPreviousNode(node);
-
+
if (prev != null)
{
current = new TreePath(getPathToRoot(prev, 0));
if (tree.isVisible(current))
return prev;
-
+
while (prev != null && !tree.isVisible(current))
{
prev = getPreviousNode(prev);
-
+
if (prev != null)
current = new TreePath(getPathToRoot(prev, 0));
}
}
return prev;
}
-
+
/**
* Returns the next node in the tree
* Package private for use in inner classes.
*
- * @return TreeNode, the next node in the tree
+ * @param the current node
+ * @return the next node in the tree
*/
- TreeNode getNextNode(TreeNode curr)
+ Object getNextNode(Object curr)
{
- if (curr.getChildCount() != 0)
- return curr.getChildAt(0);
+ TreeModel mod = tree.getModel();
+ if (mod.getChildCount(curr) > 0)
+ return mod.getChild(curr, 0);
+
+ Object node = curr;
+ Object sibling = null;
- TreeNode node = curr;
- TreeNode sibling;
-
do
{
sibling = getNextSibling(node);
- node = node.getParent();
+ node = getParent(mod.getRoot(), node);
}
- while (sibling == null &&
- node != null);
-
+ while (sibling == null && node != null);
+
return sibling;
}
@@ -2867,69 +2951,75 @@ public class BasicTreeUI extends TreeUI
* Returns the previous node in the tree
* Package private for use in inner classes.
*
- * @return TreeNode, the previous node in the tree
+ * @param the current node
+ * @return the previous node in the tree
*/
- TreeNode getPreviousNode(TreeNode node)
+ Object getPreviousNode(Object node)
{
- TreeNode parent = node.getParent();
+ TreeModel mod = tree.getModel();
+ Object parent = getParent(mod.getRoot(), node);
if (parent == null)
return null;
-
- TreeNode sibling = getPreviousSibling(node);
+
+ Object sibling = getPreviousSibling(node);
if (sibling == null)
return parent;
- int size = sibling.getChildCount();
+ int size = mod.getChildCount(sibling);
while (size > 0)
- {
- sibling = sibling.getChildAt(size - 1);
- size = sibling.getChildCount();
- }
-
+ {
+ sibling = mod.getChild(sibling, size - 1);
+ size = mod.getChildCount(sibling);
+ }
+
return sibling;
}
-
+
/**
* Returns the next sibling in the tree
* Package private for use in inner classes.
*
- * @return TreeNode, the next sibling in the tree
+ * @param the current node
+ * @return the next sibling in the tree
*/
- TreeNode getNextSibling(TreeNode node)
+ Object getNextSibling(Object node)
{
- TreeNode parent = node.getParent();
+ TreeModel mod = tree.getModel();
+ Object parent = getParent(mod.getRoot(), node);
if (parent == null)
return null;
- int index = parent.getIndex(node) + 1;
-
- if (index == parent.getChildCount())
+ int index = mod.getIndexOfChild(parent, node) + 1;
+
+ if (index == 0 || index >= mod.getChildCount(parent))
return null;
- return parent.getChildAt(index);
+ return mod.getChild(parent, index);
}
/**
* Returns the previous sibling in the tree
* Package private for use in inner classes.
- *
- * @return TreeNode, the previous sibling in the tree
+ *
+ * @param the current node
+ * @return the previous sibling in the tree
*/
- TreeNode getPreviousSibling(TreeNode node)
+ Object getPreviousSibling(Object node)
{
- TreeNode parent = node.getParent();
+ TreeModel mod = tree.getModel();
+ Object parent = getParent(mod.getRoot(), node);
if (parent == null)
return null;
- int index = parent.getIndex(node) - 1;
+ int index = mod.getIndexOfChild(parent, node) - 1;
- if (index < 0)
+ if (index < 0 || index >= mod.getChildCount(parent))
return null;
- return parent.getChildAt(index);
+ return mod.getChild(parent, index);
}
-
+
/**
* Selects the specified path in the tree depending on modes.
* Package private for use in inner classes.
@@ -2943,15 +3033,13 @@ public class BasicTreeUI extends TreeUI
{
if (tree.isPathSelected(path))
tree.removeSelectionPath(path);
- else if (tree.getSelectionModel().getSelectionMode()
- == TreeSelectionModel.SINGLE_TREE_SELECTION)
+ else if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION)
{
tree.getSelectionModel().clearSelection();
tree.addSelectionPath(path);
tree.setLeadSelectionPath(path);
}
- else if (tree.getSelectionModel().getSelectionMode()
- == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION)
+ else if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION)
{
// TODO
}
@@ -2964,7 +3052,7 @@ public class BasicTreeUI extends TreeUI
}
}
}
-
+
/**
* Returns the path from node to the root.
* Package private for use in inner classes.
@@ -2974,41 +3062,43 @@ public class BasicTreeUI extends TreeUI
*
* @return an array of tree nodes that represent the path to node.
*/
- TreeNode[] getPathToRoot(TreeNode node, int depth)
+ Object[] getPathToRoot(Object node, int depth)
{
+ TreeModel mod = tree.getModel();
if (node == null)
{
if (depth == 0)
return null;
-
- return new TreeNode[depth];
+
+ return new Object[depth];
}
- TreeNode[] path = getPathToRoot(node.getParent(), depth + 1);
+ Object[] path = getPathToRoot(getParent(mod.getRoot(), node), depth + 1);
path[path.length - depth - 1] = node;
return path;
}
-
+
/**
* Returns the level of the node in the tree.
*
+ * @param the current node
* @return the number of the level
*/
- public int getLevel(TreeNode node)
+ int getLevel(Object node)
{
int count = -1;
- TreeNode current = node;
+ Object current = node;
do
{
- current = current.getParent();
+ current = getParent(tree.getModel().getRoot(), current);
count++;
}
while (current != null);
return count;
}
-
+
/**
* Draws a vertical line using the given graphic context
*
@@ -3018,10 +3108,12 @@ public class BasicTreeUI extends TreeUI
* @param top specifies the top of the line
* @param bottom specifies the bottom of the line
*/
- protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) {
+ protected void paintVerticalLine(Graphics g, JComponent c, int x, int top,
+ int bottom)
+ {
g.drawLine(x, top, x, bottom);
}
-
+
/**
* Draws a horizontal line using the given graphic context
*
@@ -3031,10 +3123,12 @@ public class BasicTreeUI extends TreeUI
* @param left specifies the left point of the line
* @param right specifies the right point of the line
*/
- protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) {
+ protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left,
+ int right)
+ {
g.drawLine(left, y, right, y);
}
-
+
/**
* Draws an icon at around a specific position
*
@@ -3046,9 +3140,10 @@ public class BasicTreeUI extends TreeUI
*
* FIXME what to do if x < (icon.width / 2). Same with y
*/
- protected void drawCentered(JComponent c, Graphics g, Icon icon, int x, int y) {
+ protected void drawCentered(JComponent 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);
- }
-} // BasicTreeUI \ No newline at end of file
+ }
+} // BasicTreeUI
diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java
index 29074e60f..0d461332a 100644
--- a/javax/swing/plaf/basic/BasicViewportUI.java
+++ b/javax/swing/plaf/basic/BasicViewportUI.java
@@ -161,17 +161,17 @@ public class BasicViewportUI extends ViewportUI
Rectangle portBounds)
{
Rectangle oldClip = g.getClipBounds();
- g.setClip(portBounds);
+ g.setClip(new Rectangle(0, 0, portBounds.width, portBounds.height));
g.translate (-pos.x, -pos.y);
try
- {
+ {
view.paint(g);
}
finally
{
g.translate (pos.x, pos.y);
g.setClip (oldClip);
- }
+ }
}
private void paintBackingStore(Graphics g,
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
index a6cce510d..7579c689b 100644
--- a/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -44,6 +44,8 @@ import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
+import javax.swing.border.Border;
+import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.IconUIResource;
@@ -864,6 +866,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Tree.selectionBackground", new ColorUIResource(new Color(204, 204, 255)),
"Tree.nonSelectionBackground", new ColorUIResource(Color.white),
"Tree.selectionBorderColor", new ColorUIResource(new Color(102, 102, 153)),
+ "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
+ "Tree.nonSelectionBorder", new BorderUIResource.LineBorderUIResource(Color.white),
"Tree.selectionForeground", new ColorUIResource(Color.black),
"Tree.textBackground", new ColorUIResource(new Color(204, 204, 255)),
"Tree.textForeground", new ColorUIResource(Color.black),
diff --git a/javax/swing/table/DefaultTableCellRenderer.java b/javax/swing/table/DefaultTableCellRenderer.java
index 02e9fd7dc..349f4baad 100644
--- a/javax/swing/table/DefaultTableCellRenderer.java
+++ b/javax/swing/table/DefaultTableCellRenderer.java
@@ -47,6 +47,7 @@ import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
+import javax.swing.JTextField;
/**
* Class to display every cells.
@@ -123,7 +124,11 @@ public class DefaultTableCellRenderer extends JLabel
int row, int column)
{
if (value != null)
- super.setText(value.toString());
+ {
+ if (value instanceof JTextField)
+ return new JTextField(((JTextField)value).getText());
+ super.setText(value.toString());
+ }
setOpaque(true);
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index d7bad0a08..dcd81d5b0 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -228,19 +228,8 @@ public class GapContent
throw new BadLocationException("the where argument cannot be greater"
+ " than the content length", where);
- // check if the gap is big enough to hold the string
- if ((gapEnd - gapStart) < strLen)
- // make room for this string and some more
- shiftEnd(strLen + DEFAULT_BUFSIZE);
-
- // are we at the gap boundary?
- if (where != gapStart)
- shiftGap(where);
-
- // now we can simple copy the string into the gap and adjust the
- // gap boundaries
- System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen);
- gapStart += strLen;
+ replace(where, 0, str.toCharArray(), str.length());
+
return null;
}
@@ -268,12 +257,8 @@ public class GapContent
throw new BadLocationException("where + nitems cannot be greater"
+ " than the content length", where + nitems);
- // check if we are at the gap boundary
- if (where != gapStart)
- shiftGap(where);
+ replace(where, nitems, null, 0);
- // now we simply have to enlarge the gap
- gapEnd += nitems;
return null;
}
@@ -419,40 +404,40 @@ public class GapContent
// Update the positions between newGapEnd and (old) gapEnd. The marks
// must be shifted by (gapEnd - newGapEnd).
- int index1 = Collections.binarySearch(positions, new GapContentPosition(
- gapEnd));
- int index2 = Collections.binarySearch(positions, new GapContentPosition(
- newGapEnd));
+ int index1 = Collections.binarySearch(positions,
+ new GapContentPosition(gapEnd));
+ int index2 = Collections.binarySearch(positions,
+ new GapContentPosition(newGapEnd));
if (index1 > 0 && index2 > 0)
- {
- int i1 = Math.min(index1, index2);
- int i2 = Math.max(index1, index2);
- for (ListIterator i = positions.listIterator(i1); i.hasNext();)
{
- if (i.nextIndex() > i2)
- break;
-
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark += gapEnd - newGapEnd;
+ int i1 = Math.min(index1, index2);
+ int i2 = Math.max(index1, index2);
+ for (ListIterator i = positions.listIterator(i1); i.hasNext();)
+ {
+ if (i.nextIndex() > i2)
+ break;
+
+ GapContentPosition p = (GapContentPosition) i.next();
+ p.mark += gapEnd - newGapEnd;
+ }
}
- if (newGapStart == gapStart)
- return;
- else if (newGapStart < gapStart)
+ if (newGapStart == gapStart)
+ return;
+ else if (newGapStart < gapStart)
{
System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart
- - newGapStart);
+ - newGapStart);
gapStart = newGapStart;
gapEnd = newGapEnd;
}
- else
+ else
{
System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart
- - gapStart);
+ - gapStart);
gapStart = newGapStart;
gapEnd = newGapEnd;
}
- }
}
/**
@@ -473,7 +458,8 @@ public class GapContent
* @param addItems the items to add at location
* @param addSize the number of items to add
*/
- protected void replace(int position, int rmSize, Object addItems, int addSize)
+ protected void replace(int position, int rmSize, Object addItems,
+ int addSize)
{
// Remove content
shiftGap(position);
@@ -484,7 +470,10 @@ public class GapContent
shiftEnd(addSize);
// Add new items to the buffer.
- System.arraycopy(addItems, 0, buffer, gapStart, addSize);
- gapStart += addSize;
+ if (addItems != null)
+ {
+ System.arraycopy(addItems, 0, buffer, gapStart, addSize);
+ gapStart += addSize;
+ }
}
}
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index 0f1792161..c3d96e297 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -44,6 +44,7 @@ import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
+import javax.swing.border.Border;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JTree;
@@ -390,7 +391,7 @@ public class DefaultTreeCellRenderer
this.selected = selected;
this.hasFocus = hasFocus;
setHorizontalAlignment(LEFT);
- setOpaque(true);
+ setOpaque(false);
setVerticalAlignment(TOP);
setEnabled(true);
super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font"));
@@ -399,13 +400,15 @@ public class DefaultTreeCellRenderer
{
super.setBackground(getBackgroundSelectionColor());
setForeground(getTextSelectionColor());
+ setBorder(UIManager.getLookAndFeelDefaults().getBorder("Tree.selectionBorder"));
}
else
{
super.setBackground(getBackgroundNonSelectionColor());
setForeground(getTextNonSelectionColor());
- }
-
+ setBorder(UIManager.getLookAndFeelDefaults().getBorder("Tree.nonSelectionBorder"));
+ }
+
return this;
}
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index e4291e130..b8042a47a 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -1,6 +1,6 @@
-/* DefaultTreeModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
-
+/* DefaultTreeModel.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -10,16 +10,16 @@ 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
+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
+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
+making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
@@ -29,13 +29,12 @@ 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
+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
+obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing.tree;
import java.io.IOException;
@@ -51,405 +50,434 @@ import javax.swing.tree.DefaultMutableTreeNode;
/**
* DefaultTreeModel
+ *
* @author Andrew Selkirk
*/
public class DefaultTreeModel
- implements Serializable, TreeModel
+ implements Serializable, TreeModel
{
- static final long serialVersionUID = -2621068368932566998L;
-
- /**
- * root
- */
- protected TreeNode root = null;
-
- /**
- * listenerList
- */
- protected EventListenerList listenerList = new EventListenerList();
-
- /**
- * asksAllowsChildren
- */
- protected boolean asksAllowsChildren;
-
- /**
- * Constructor DefaultTreeModel
- * @param root the tree root.
- */
- public DefaultTreeModel(TreeNode root)
- {
- if (root == null)
- root = new DefaultMutableTreeNode();
- setRoot(root);
- }
-
- /**
- * Constructor DefaultTreeModel
- * @param root the tree root.
- * @param asksAllowsChildren TODO
- */
- public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
- {
- setRoot(root);
- this.asksAllowsChildren = asksAllowsChildren;
- }
-
- /**
- * writeObject
- * @param obj the object.
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream obj) throws IOException
- {
- // TODO
- }
-
- /**
- * readObject
- * @param value0 TODO
- * @exception IOException TODO
- * @exception ClassNotFoundException TODO
- */
- private void readObject(ObjectInputStream value0) throws IOException,
- ClassNotFoundException
- {
- // TODO
- }
-
- /**
- * asksAllowsChildren
- * @return boolean
- */
- public boolean asksAllowsChildren()
- {
- return asksAllowsChildren;
- }
-
- /**
- * setAsksAllowsChildren
- * @param value TODO
- */
- public void setAsksAllowsChildren(boolean value)
- {
- asksAllowsChildren = value; // TODO
- }
-
- /**
- * setRoot
- * @param root the root node.
- */
- public void setRoot(TreeNode root)
- {
- // Sanity Check
- if (root == null)
- {
- throw new IllegalArgumentException("null root");
- }
- // Set new root
- this.root = root;
-
- // TODO
- }
-
- /**
- * getRoot
- * @return Object
- */
- public Object getRoot()
- {
- return root;
- }
-
- /**
- * getIndexOfChild
- * @param parent TODO
- * @param child TODO
- * @return int
- */
- public int getIndexOfChild(Object parent, Object child)
- {
- return 0; // TODO
- }
-
- /**
- * getChild
- * @param node TODO
- * @param idx TODO
- * @return Object
- */
- public Object getChild(Object node, int idx)
- {
- if (node instanceof TreeNode)
- return ((TreeNode) node).getChildAt(idx);
- else
- return null;
- }
-
- /**
- * getChildCount
- * @param node TODO
- * @return int
- */
- public int getChildCount(Object node)
- {
- if (node instanceof TreeNode)
- return ((TreeNode) node).getChildCount();
- else
- return 0;
- }
-
- /**
- * isLeaf
- * @param node TODO
- * @return boolean
- */
- public boolean isLeaf(Object node)
- {
- if (node instanceof TreeNode)
- return ((TreeNode) node).isLeaf();
- else
- return true;
- }
-
- /**
- * reload
- */
- public void reload()
- {
- // TODO
- }
-
- /**
- * reload
- * @param value0 TODO
- */
- public void reload(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * valueForPathChanged
- * @param value0 TODO
- * @param value1 TODO
- */
- public void valueForPathChanged(TreePath value0, Object value1)
- {
- // TODO
- }
-
- /**
- * insertNodeInto
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- */
- public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1,
- int value2)
- {
- // TODO
- }
-
- /**
- * removeNodeFromParent
- * @param value0 TODO
- */
- public void removeNodeFromParent(MutableTreeNode value0)
- {
- // TODO
- }
-
- /**
- * nodeChanged
- * @param value0 TODO
- */
- public void nodeChanged(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * nodesWereInserted
- * @param value0 TODO
- * @param value1 TODO
- */
- public void nodesWereInserted(TreeNode value0, int[] value1)
- {
- // TODO
- }
-
- /**
- * nodesWereRemoved
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- */
- public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
- {
- // TODO
- }
-
- /**
- * nodesChanged
- * @param value0 TODO
- * @param value1 TODO
- */
- public void nodesChanged(TreeNode value0, int[] value1)
- {
- // TODO
- }
-
- /**
- * nodeStructureChanged
- * @param value0 TODO
- */
- public void nodeStructureChanged(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * getPathToRoot
- * @param value0 TODO
- * @return TreeNode[]
- */
- public TreeNode[] getPathToRoot(TreeNode value0)
- {
- return null; // TODO
- }
-
- /**
- * getPathToRoot
- * @param value0 TODO
- * @param value1 TODO
- * @return TreeNode[]
- */
- protected TreeNode[] getPathToRoot(TreeNode value0, int value1)
- {
- return null; // TODO
- }
-
- /**
- * Registers a listere to the model.
- *
- * @param listener the listener to add
- */
- public void addTreeModelListener(TreeModelListener listener)
- {
- listenerList.add(TreeModelListener.class, listener);
- }
-
- /**
- * Removes a listener from the model.
- *
- * @param listener the listener to remove
- */
- public void removeTreeModelListener(TreeModelListener listener)
- {
- listenerList.remove(TreeModelListener.class, listener);
- }
-
- /**
- * Returns all registered <code>TreeModelListener</code> listeners.
- *
- * @return an array of listeners.
- *
- * @since 1.4
- */
- public TreeModelListener[] getTreeModelListeners()
- {
- return (TreeModelListener[]) listenerList
- .getListeners(TreeModelListener.class);
- }
-
- /**
- * fireTreeNodesChanged
- *
- * @param source the node being changed
- * @param path the path to the root node
- * @param childIndices the indices of the changed elements
- * @param children the changed elements
- */
- protected void fireTreeNodesChanged(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
- children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesChanged(event);
- }
-
- /**
- * fireTreeNodesInserted
- *
- * @param source the node where new nodes got inserted
- * @param path the path to the root node
- * @param childIndices the indices of the new elements
- * @param children the new elements
- */
- protected void fireTreeNodesInserted(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
- children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesInserted(event);
- }
-
- /**
- * fireTreeNodesRemoved
- *
- * @param source the node where nodes got removed-
- * @param path the path to the root node
- * @param childIndices the indices of the removed elements
- * @param children the removed elements
- */
- protected void fireTreeNodesRemoved(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
- children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesRemoved(event);
- }
-
- /**
- * fireTreeStructureChanged
- *
- * @param source the node where the model has changed
- * @param path the path to the root node
- * @param childIndices the indices of the affected elements
- * @param children the affected elements
- */
- protected void fireTreeStructureChanged(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
- children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeStructureChanged(event);
- }
-
- /**
- * Returns the registered listeners of a given type.
- *
- * @param listenerType the listener type to return
- *
- * @return an array of listeners
- *
- * @since 1.3
- */
- public EventListener[] getListeners(Class listenerType)
- {
- return listenerList.getListeners(listenerType);
- }
+ static final long serialVersionUID = -2621068368932566998L;
+
+ /**
+ * root
+ */
+ protected TreeNode root = null;
+
+ /**
+ * listenerList
+ */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * asksAllowsChildren
+ */
+ protected boolean asksAllowsChildren;
+
+ /**
+ * Constructor DefaultTreeModel
+ *
+ * @param root the tree root.
+ */
+ public DefaultTreeModel(TreeNode root)
+ {
+ if (root == null)
+ root = new DefaultMutableTreeNode();
+ setRoot(root);
+ }
+
+ /**
+ * Constructor DefaultTreeModel
+ *
+ * @param root the tree root.
+ * @param asksAllowsChildren TODO
+ */
+ public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
+ {
+ setRoot(root);
+ this.asksAllowsChildren = asksAllowsChildren;
+ }
+
+ /**
+ * writeObject
+ *
+ * @param obj the object.
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream obj) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ *
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0) throws IOException,
+ ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * asksAllowsChildren
+ *
+ * @return boolean
+ */
+ public boolean asksAllowsChildren()
+ {
+ return asksAllowsChildren;
+ }
+
+ /**
+ * setAsksAllowsChildren
+ *
+ * @param value TODO
+ */
+ public void setAsksAllowsChildren(boolean value)
+ {
+ asksAllowsChildren = value; // TODO
+ }
+
+ /**
+ * setRoot
+ *
+ * @param root the root node.
+ */
+ public void setRoot(TreeNode root)
+ {
+ // Sanity Check
+ if (root == null)
+ {
+ throw new IllegalArgumentException("null root");
+ }
+ // Set new root
+ this.root = root;
+
+ // TODO
+ }
+
+ /**
+ * getRoot
+ *
+ * @return Object
+ */
+ public Object getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * getIndexOfChild
+ *
+ * @param parent TODO
+ * @param child TODO
+ * @return int
+ */
+ public int getIndexOfChild(Object parent, Object child)
+ {
+ for (int i = 0; i < getChildCount(parent); i++)
+ {
+ if (getChild(parent, i).equals(child))
+ return i;
+ }
+ return -1;
+ }
+
+ /**
+ * getChild
+ *
+ * @param node TODO
+ * @param idx TODO
+ * @return Object
+ */
+ public Object getChild(Object node, int idx)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildAt(idx);
+ else
+ return null;
+ }
+
+ /**
+ * getChildCount
+ *
+ * @param node TODO
+ * @return int
+ */
+ public int getChildCount(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildCount();
+ else
+ return 0;
+ }
+
+ /**
+ * isLeaf
+ *
+ * @param node TODO
+ * @return boolean
+ */
+ public boolean isLeaf(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).isLeaf();
+ else
+ return true;
+ }
+
+ /**
+ * reload
+ */
+ public void reload()
+ {
+ // TODO
+ }
+
+ /**
+ * reload
+ *
+ * @param value0 TODO
+ */
+ public void reload(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * valueForPathChanged
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void valueForPathChanged(TreePath value0, Object value1)
+ {
+ // TODO
+ }
+
+ /**
+ * insertNodeInto
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1,
+ int value2)
+ {
+ // TODO
+ }
+
+ /**
+ * removeNodeFromParent
+ *
+ * @param value0 TODO
+ */
+ public void removeNodeFromParent(MutableTreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeChanged
+ *
+ * @param value0 TODO
+ */
+ public void nodeChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereInserted
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesWereInserted(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereRemoved
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesChanged
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesChanged(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeStructureChanged
+ *
+ * @param value0 TODO
+ */
+ public void nodeStructureChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * getPathToRoot
+ *
+ * @param value0 TODO
+ * @return TreeNode[]
+ */
+ public TreeNode[] getPathToRoot(TreeNode value0)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getPathToRoot
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return TreeNode[]
+ */
+ protected TreeNode[] getPathToRoot(TreeNode value0, int value1)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Registers a listere to the model.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.add(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Removes a listener from the model.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.remove(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Returns all registered <code>TreeModelListener</code> listeners.
+ *
+ * @return an array of listeners.
+ *
+ * @since 1.4
+ */
+ public TreeModelListener[] getTreeModelListeners()
+ {
+ return (TreeModelListener[]) listenerList
+ .getListeners(TreeModelListener.class);
+ }
+
+ /**
+ * fireTreeNodesChanged
+ *
+ * @param source the node being changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the changed elements
+ * @param children the changed elements
+ */
+ protected void fireTreeNodesChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesChanged(event);
+ }
+
+ /**
+ * fireTreeNodesInserted
+ *
+ * @param source the node where new nodes got inserted
+ * @param path the path to the root node
+ * @param childIndices the indices of the new elements
+ * @param children the new elements
+ */
+ protected void fireTreeNodesInserted(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesInserted(event);
+ }
+
+ /**
+ * fireTreeNodesRemoved
+ *
+ * @param source the node where nodes got removed-
+ * @param path the path to the root node
+ * @param childIndices the indices of the removed elements
+ * @param children the removed elements
+ */
+ protected void fireTreeNodesRemoved(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesRemoved(event);
+ }
+
+ /**
+ * fireTreeStructureChanged
+ *
+ * @param source the node where the model has changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the affected elements
+ * @param children the affected elements
+ */
+ protected void fireTreeStructureChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeStructureChanged(event);
+ }
+
+ /**
+ * Returns the registered listeners of a given type.
+ *
+ * @param listenerType the listener type to return
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9875fd09d..8273f4f87 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -17,10 +17,9 @@ if FOUND_ECJ
JAVAC = $(ECJ) -1.5 -warn:-deprecation,serial -proceedOnError -bootclasspath '' -classpath $(compile_classpath) -d . @classes
else
if FOUND_GCJ
-# Since we don't feed all classes at once gcj needs to know where to find
-# the generated classes (in top_builddir).
-JAVAC = $(srcdir)/split-for-gcj.sh && $(MAKE) -f $(srcdir)/Makefile.gcj \
- GCJ='$(GCJ)' compile_classpath='$(top_builddir):$(compile_classpath)'
+## This should never be used when gcj is the compiler.
+## See the compile-classes target.
+JAVAC = exit 1
else
if FOUND_JIKES
JAVAC = $(JIKES) +Pno-shadow +Pno-switchcheck +F $(JIKESENCODING) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(compile_classpath) -d . @classes
@@ -123,13 +122,22 @@ endif # REGEN_PARSER
$(JAVA_DEPEND): genclasses
+if FOUND_GCJ
+## When building with gcj, we do a recursive make. We split this rule
+## out specially, rather than simply defining JAVAC, so that GNU make
+## will see the recursive make invocation and still allow parallel
+## builds.
+compile-classes: classes $(JAVA_SRCS) Makefile
+ $(MAKE) -f $(srcdir)/Makefile.gcj \
+ GCJ='$(GCJ)' compile_classpath='$(top_builddir):$(compile_classpath)'
+else
compile-classes: classes $(JAVA_SRCS) Makefile
$(JAVAC)
touch compile-classes
+endif
EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
CLEANFILES = compile-classes resources classes \
- classes.standard classes.awt classes.standardx classes.xml \
glibj.zip classes.1 \
$(top_builddir)/java/util/LocaleData.java \
$(JAVA_DEPEND)
diff --git a/lib/gen-classlist.sh.in b/lib/gen-classlist.sh.in
index c091caa20..456696589 100755
--- a/lib/gen-classlist.sh.in
+++ b/lib/gen-classlist.sh.in
@@ -1,10 +1,13 @@
-#! @SH@
+#! @SHELL@
# @configure_input@
# Make sure sorting is done the same on all configurations
LC_ALL=C; export LC_ALL
LANG=C; export LANG
+# We use this to decide whether we need to invoke the split script.
+GCJ="@GCJ@"
+
echo "Adding java source files from srcdir '@top_srcdir@'."
@FIND@ @top_srcdir@/java @top_srcdir@/javax @top_srcdir@/gnu \
@top_srcdir@/org \
@@ -82,6 +85,10 @@ if test "$new" = "true"; then
for i in `cat ${top_builddir}/lib/classes` ; do
echo $i "\\" >> ${top_builddir}/lib/java.dep
done
+
+ if test -n "$GCJ"; then
+ @SHELL@ ${top_srcdir}/lib/split-for-gcj.sh
+ fi
fi
exit 0
diff --git a/lib/split-for-gcj.sh b/lib/split-for-gcj.sh
index bda7fda88..071529887 100755
--- a/lib/split-for-gcj.sh
+++ b/lib/split-for-gcj.sh
@@ -1,17 +1,40 @@
#! /bin/sh
-# Split in multiple parts for gcj. This uses a somewhat hacky
-# procedure for finding the package of a given file.
+# This script is used when compiling Classpath with gcj. The idea is
+# to compile one package at a time, and only recompile packages when
+# actually required.
+
+# We build java->class by package so we need to know what .java files
+# correspond to what package.
+
+# We have a .stamp file for each package; this is the makefile target.
+# We also have a .list file for each package, which lists all the
+# input files in that package.
+
+# gen-classlist.sh makes a list of all the .java files we are going to compile.
+
+# This script generates Makefile.deps, which looks like this:
+#
+# java/awt/AWTUtilities.class: lists/java-awt.stamp
+# lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/AWTUtilities.java
+# java/awt/BitMaskExtent.class: lists/java-awt.stamp
+# lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/BitMaskExtent.java
+# java/awt/BitwiseXORComposite.class: lists/java-awt.stamp
+# lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
+
+# This uses a somewhat hacky procedure for finding the package of a
+# given file.
+
echo "Splitting for gcj"
rm -f Makefile.deps > /dev/null 2>&1
test -d lists || mkdir lists
for dir in java javax gnu org; do
- for file in `cat classes | fgrep /$dir/`; do
+ fgrep /$dir/ classes | while read file; do
pkg=`echo "$file " | sed -n -e "s,^.*/\($dir/.*\)/[^/]*$,\1,p"`
list=lists/`echo $pkg | sed -e 's,/,-,g'`
echo "$file" >> ${list}.list.1
f2=`echo "$file" | sed -n -e "s,^.*/\($dir/.*\)$,\1,p"`
- f2=${f2%.java}.class
+ f2=`echo "$f2" | sed -e 's/.java$//'`.class
echo "$f2: ${list}.stamp" >> Makefile.deps
echo "${list}.list: $file" >> Makefile.deps
done
@@ -19,10 +42,10 @@ done
# Only update a .list file if it changed.
for file in lists/*.list.1; do
- real=${file%.1}
- if ! cmp -s $real $file; then
- mv $file $real
- else
+ real=`echo "$file" | sed -e 's/.1$//'`
+ if cmp -s $real $file; then
rm $file
+ else
+ mv $file $real
fi
done
diff --git a/native/jni/classpath/Makefile.am b/native/jni/classpath/Makefile.am
index 0171d3728..2baa60abc 100644
--- a/native/jni/classpath/Makefile.am
+++ b/native/jni/classpath/Makefile.am
@@ -1,3 +1,6 @@
+# Header needed for jawt implementations such as the one found in ../gtk-peer.
+EXTRA_DIST = classpath_jawt.h
+
noinst_LTLIBRARIES = libclasspath.la
libclasspath_la_SOURCES = jcl.c jcl.h \
diff --git a/native/jni/classpath/classpath_jawt.h b/native/jni/classpath/classpath_jawt.h
index 66ba9c70a..967f66fed 100644
--- a/native/jni/classpath/classpath_jawt.h
+++ b/native/jni/classpath/classpath_jawt.h
@@ -50,15 +50,15 @@ exception statement from your version. */
#define CLASSPATH_JAWT_VERSION 0x10004
-jint classpath_jawt_get_awt_version ();
+jint classpath_jawt_get_awt_version (void);
Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas);
Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas);
VisualID classpath_jawt_get_visualID (JNIEnv* env, jobject canvas);
jint classpath_jawt_object_lock (jobject lock);
void classpath_jawt_object_unlock (jobject lock);
-jint classpath_jawt_lock ();
-void classpath_jawt_unlock ();
-jobject classpath_jawt_create_lock ();
+jint classpath_jawt_lock (void);
+void classpath_jawt_unlock (void);
+jobject classpath_jawt_create_lock (void);
void classpath_jawt_destroy_lock (jobject lock);
#endif /* __classpath_jawt_h__ */
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index f4e7bdfcc..0fe6d8311 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -47,6 +47,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gdkfont.h \
gthread-jni.h \
gtkcairopeer.h \
+ gtk_jawt.c \
gtkpeer.h
libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
index 5e8ab26c3..140fbb54b 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
@@ -86,6 +86,56 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create
gdk_threads_leave ();
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetGetPreferredDimensions
+ (JNIEnv *env, jobject obj, jintArray jdims)
+{
+ void *ptr;
+ jint *dims;
+ GtkWidget *button;
+ GtkWidget *label;
+ GtkRequisition current_req;
+ GtkRequisition current_label_req;
+ GtkRequisition natural_req;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ button = gtk_bin_get_child (GTK_BIN (ptr));
+ label = gtk_bin_get_child (GTK_BIN (button));
+
+ dims = (*env)->GetIntArrayElements (env, jdims, 0);
+ dims[0] = dims[1] = 0;
+
+ /* Save the button's current size request. */
+ gtk_widget_size_request (GTK_WIDGET (button), &current_req);
+
+ /* Save the label's current size request. */
+ gtk_widget_size_request (GTK_WIDGET (label), &current_label_req);
+
+ /* Get the widget's "natural" size request. */
+ gtk_widget_set_size_request (GTK_WIDGET (button), -1, -1);
+ gtk_widget_set_size_request (GTK_WIDGET (label), -1, -1);
+
+ gtk_widget_size_request (GTK_WIDGET (button), &natural_req);
+
+ /* Reset the button's size request. */
+ gtk_widget_set_size_request (GTK_WIDGET (button),
+ current_req.width, current_req.height);
+
+ /* Reset the label's size request. */
+ gtk_widget_set_size_request (GTK_WIDGET (label),
+ current_label_req.width, current_label_req.height);
+
+ dims[0] = natural_req.width;
+ dims[1] = natural_req.height;
+
+ (*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+
+ gdk_threads_leave ();
+}
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals
(JNIEnv *env, jobject obj)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
index 7968ca773..74180a784 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
@@ -66,6 +66,44 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create
gdk_threads_leave ();
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetGetPreferredDimensions
+ (JNIEnv *env, jobject obj, jintArray jdims)
+{
+ void *ptr;
+ jint *dims;
+ GtkWidget *label;
+ GtkRequisition current_req;
+ GtkRequisition natural_req;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ label = gtk_bin_get_child (GTK_BIN (ptr));
+
+ dims = (*env)->GetIntArrayElements (env, jdims, 0);
+ dims[0] = dims[1] = 0;
+
+ /* Save the widget's current size request. */
+ gtk_widget_size_request (GTK_WIDGET (label), &current_req);
+
+ /* Get the widget's "natural" size request. */
+ gtk_widget_set_size_request (GTK_WIDGET (label), -1, -1);
+ gtk_widget_size_request (GTK_WIDGET (label), &natural_req);
+
+ /* Reset the widget's size request. */
+ gtk_widget_set_size_request (GTK_WIDGET (label),
+ current_req.width, current_req.height);
+
+ dims[0] = natural_req.width;
+ dims[1] = natural_req.height;
+
+ (*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+
+ gdk_threads_leave ();
+}
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont
(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
diff --git a/native/jni/gtk-peer/gtk_jawt.c b/native/jni/gtk-peer/gtk_jawt.c
new file mode 100644
index 000000000..d540c1e56
--- /dev/null
+++ b/native/jni/gtk-peer/gtk_jawt.c
@@ -0,0 +1,197 @@
+/* gtk_jawt.c -- GTK implementation of classpath_jawt.h
+ 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. */
+
+
+#include "gtkpeer.h"
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include "classpath_jawt.h"
+
+jint
+classpath_jawt_get_awt_version ()
+{
+ return CLASSPATH_JAWT_VERSION;
+}
+
+Display*
+classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
+{
+ GdkDisplay *display;
+ Display *xdisplay;
+ GtkWidget *widget;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ /* retrieve peer object */
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ gdk_threads_enter ();
+
+ widget = GTK_WIDGET (ptr);
+
+ /* widget should be realized before Canvas.paint is called. */
+ g_assert (GTK_WIDGET_REALIZED (widget));
+
+ display = gtk_widget_get_display (widget);
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+ gdk_threads_leave ();
+
+ return xdisplay;
+}
+
+VisualID
+classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
+{
+ GtkWidget *widget;
+ Visual *visual;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ gdk_threads_enter ();
+
+ widget = GTK_WIDGET (ptr);
+
+ g_assert (GTK_WIDGET_REALIZED (widget));
+
+ visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
+ g_assert (visual != NULL);
+
+ gdk_threads_leave ();
+
+ return visual->visualid;
+}
+
+Drawable
+classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
+{
+ GtkWidget *widget;
+ int drawable;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ gdk_threads_enter ();
+
+ widget = GTK_WIDGET (ptr);
+
+ g_assert (GTK_WIDGET_REALIZED (widget));
+
+ drawable = GDK_DRAWABLE_XID (widget->window);
+
+ gdk_threads_leave ();
+
+ return drawable;
+}
+
+jint
+classpath_jawt_object_lock (jobject lock)
+{
+ JNIEnv *env = cp_gtk_gdk_env();
+ (*env)->MonitorEnter (env, lock);
+ return 0;
+}
+
+void
+classpath_jawt_object_unlock (jobject lock)
+{
+ JNIEnv *env = cp_gtk_gdk_env();
+ (*env)->MonitorExit (env, lock);
+}
+
+jint
+classpath_jawt_lock ()
+{
+ gdk_threads_enter ();
+ return 0;
+}
+
+void
+classpath_jawt_unlock ()
+{
+ gdk_threads_leave ();
+}
+
+jobject
+classpath_jawt_create_lock ()
+{
+ JNIEnv *env = cp_gtk_gdk_env ();
+ jobject lock = (*env)->NewStringUTF (env, "jawt-lock");
+ NSA_SET_GLOBAL_REF (env, lock);
+ return lock;
+}
+
+void
+classpath_jawt_destroy_lock (jobject lock)
+{
+ JNIEnv *env = cp_gtk_gdk_env ();
+ NSA_DEL_GLOBAL_REF (env, lock);
+}
diff --git a/native/jni/java-net/gnu_java_net_PlainSocketImpl.c b/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
index a5261514d..f5f22ab77 100644
--- a/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_PlainSocketImpl.c
@@ -50,6 +50,7 @@ exception statement from your version. */
#include "target_native.h"
#ifndef WITHOUT_NETWORK
+#include "target_native_file.h" /* Get FIONREAD on Solaris. */
#include "target_native_network.h"
#endif /* WITHOUT_NETWORK */
diff --git a/native/jni/qt-peer/buttonevent.h b/native/jni/qt-peer/buttonevent.h
new file mode 100644
index 000000000..aab11dd03
--- /dev/null
+++ b/native/jni/qt-peer/buttonevent.h
@@ -0,0 +1,27 @@
+#ifndef BUTTONEVENT_H
+#define BUTTONEVENT_H
+
+#include <QAbstractButton>
+#include "mainthreadinterface.h"
+
+class AWTLabelEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ QString *string;
+
+ public:
+ AWTLabelEvent(QAbstractButton *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+#endif
diff --git a/native/jni/qt-peer/componentevent.cpp b/native/jni/qt-peer/componentevent.cpp
new file mode 100644
index 000000000..4a46a5a52
--- /dev/null
+++ b/native/jni/qt-peer/componentevent.cpp
@@ -0,0 +1,133 @@
+/* componentevent.cpp --
+ 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. */
+
+#include "componentevent.h"
+
+AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()
+{
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+}
+
+void AWTInitEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+ jmethodID initID = env->GetMethodID( targetCls,
+ "init",
+ "()V" );
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, initID );
+ env->MonitorExit( target );
+ env->DeleteGlobalRef( target );
+}
+
+AWTShowEvent::AWTShowEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ visible = v;
+}
+
+void AWTShowEvent::runEvent()
+{
+ widget->setVisible( visible );
+}
+
+AWTEnableEvent::AWTEnableEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ enabled = v;
+}
+
+void AWTEnableEvent::runEvent()
+{
+ widget->setEnabled( enabled );
+}
+
+AWTCursorEvent::AWTCursorEvent(QWidget *w, Qt::CursorShape s) : AWTEvent()
+{
+ widget = w;
+ shape = s;
+}
+
+void AWTCursorEvent::runEvent()
+{
+ QCursor *s = new QCursor(shape);
+ widget->setCursor( *s );
+}
+
+AWTResizeEvent::AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0)
+{
+ widget = wid;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+}
+
+void AWTResizeEvent::runEvent()
+{
+ widget->setGeometry( x, y, w, h );
+}
+
+AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)
+{
+ widget = wid;
+ foreground = fg;
+ color = clr;
+}
+
+void AWTBackgroundEvent::runEvent()
+{
+ QPalette p = widget->palette();
+ if (foreground)
+ {
+ p.setColor(QPalette::Active, QPalette::Foreground, *color);
+ p.setColor(QPalette::Active, QPalette::Text, *color);
+ }
+ else
+ {
+ p.setColor(QPalette::Active, QPalette::Background, *color);
+ p.setColor(QPalette::Active, QPalette::Button, *color);
+ p.setColor(QPalette::Active, QPalette::Base, *color);
+ p.setColor(QPalette::Active, QPalette::AlternateBase, *color);
+ }
+ widget->setPalette(p);
+ widget->repaint();
+ delete color;
+}
+
diff --git a/native/jni/qt-peer/componentevent.h b/native/jni/qt-peer/componentevent.h
new file mode 100644
index 000000000..cfcbef860
--- /dev/null
+++ b/native/jni/qt-peer/componentevent.h
@@ -0,0 +1,203 @@
+#ifndef CALLBACKEVENT_H
+#define CALLBACKEVENT_H
+
+#include <jni.h>
+#include <QEvent>
+#include <QColor>
+#include <QCursor>
+#include <QFont>
+#include <QPoint>
+#include <QWidget>
+#include <QSize>
+
+#include "mainthreadinterface.h"
+
+class AWTInitEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+
+ public:
+ AWTInitEvent(JNIEnv *env, jobject obj);
+ void runEvent();
+};
+
+class AWTDestroyEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTDestroyEvent(QWidget *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ delete widget;
+ }
+};
+
+class AWTFontEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QFont *font;
+
+ public:
+ AWTFontEvent(QWidget *w, QFont *f)
+ {
+ widget = w;
+ font = f;
+ }
+
+ void runEvent()
+ {
+ widget->setFont( *font );
+ }
+};
+
+class AWTUpdateEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x,y,w,h;
+ bool updateAll;
+
+ public:
+ AWTUpdateEvent(QWidget *src, bool all, int x0, int y0, int w0, int h0)
+ {
+ widget = src;
+ updateAll = all;
+ x = x0; y = y0; w = w0; h = h0;
+ }
+
+ void runEvent()
+ {
+ if(updateAll)
+ widget->update();
+ else
+ widget->update(x,y,w,h);
+ }
+};
+
+class AWTShowEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool visible;
+
+ public:
+ AWTShowEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTEnableEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool enabled;
+
+ public:
+ AWTEnableEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTCursorEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ Qt::CursorShape shape;
+
+ public:
+ AWTCursorEvent(QWidget *w, Qt::CursorShape s);
+ void runEvent();
+};
+
+class AWTResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x, y, w, h;
+
+ public:
+ AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0);
+ void runEvent();
+};
+
+class AWTBackgroundEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool foreground;
+ QColor *color;
+
+ public:
+ AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr);
+ void runEvent();
+};
+
+class AWTReqFocusEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTReqFocusEvent(QWidget *w) : AWTEvent()
+ {
+ widget = w;
+ }
+ void runEvent()
+ {
+ widget->setFocus();
+ }
+};
+
+class AWTGetOriginEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QPoint **origin;
+
+ public:
+ AWTGetOriginEvent(QWidget *w, QPoint **o) : AWTEvent()
+ {
+ widget = w;
+ origin = o;
+ }
+ void runEvent()
+ {
+ *origin = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
+ }
+};
+
+class AWTGetSizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool preferred;
+
+ public:
+
+ QSize **size;
+
+ AWTGetSizeEvent(QWidget *w, QSize **s, bool pref) : AWTEvent()
+ {
+ widget = w;
+ preferred = pref;
+ size = s;
+ }
+ void runEvent()
+ {
+ QSize s;
+ if( preferred )
+ s = widget->sizeHint();
+ else
+ s = widget->minimumSizeHint();
+ *size = new QSize( s.width(), s.height() );
+ }
+};
+
+#endif
diff --git a/native/jni/qt-peer/containers.h b/native/jni/qt-peer/containers.h
new file mode 100644
index 000000000..a2ae76af0
--- /dev/null
+++ b/native/jni/qt-peer/containers.h
@@ -0,0 +1,10 @@
+#ifndef QTFRAME_H
+#define QTFRAME_H
+
+#include <jni.h>
+#include <QWidget>
+
+QWidget *frameChildWidget( JNIEnv *env, jobject component );
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component);
+
+#endif
diff --git a/native/jni/qt-peer/eventmethods.cpp b/native/jni/qt-peer/eventmethods.cpp
new file mode 100644
index 000000000..3e5482622
--- /dev/null
+++ b/native/jni/qt-peer/eventmethods.cpp
@@ -0,0 +1,233 @@
+/* eventmethods.cpp --
+ 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. */
+
+#ifdef I_KNOW_WHAT_IM_DOING
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+
+ void setup(JNIEnv *env, jobject obj)
+ {
+ env->GetJavaVM(&vm);
+ componentCls = NULL;
+ target = env->NewGlobalRef(obj);
+ componentCls = (jclass)env->NewGlobalRef(env->GetObjectClass( target ));
+ setMouseTracking( true );
+ }
+
+ void destroy()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ env->DeleteGlobalRef(componentCls);
+ }
+
+ void callVoidMethod(char *methodName)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ }
+
+ void callMouseMethod(char *methodName,
+ int modifiers, int x, int y, int clickCount)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "(IIII)V" );
+ env->CallVoidMethod( target, fireEventID, modifiers, x, y, clickCount );
+ }
+
+protected:
+
+ void closeEvent( QCloseEvent *e )
+ {
+ PARENT::closeEvent(e);
+ callVoidMethod("closeEvent");
+ }
+
+ void focusInEvent( QFocusEvent *e )
+ {
+ PARENT::focusInEvent(e);
+ callVoidMethod("focusInEvent");
+ }
+
+ void focusOutEvent( QFocusEvent *e )
+ {
+ PARENT::focusOutEvent(e);
+ callVoidMethod("focusOutEvent");
+ }
+
+ void enterEvent( QEvent *e )
+ {
+ PARENT::enterEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("enterEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void keyPressEvent( QKeyEvent *e )
+ {
+ PARENT::keyPressEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyPressEvent", modifiers, x, y, 0);
+ }
+
+ void keyReleaseEvent( QKeyEvent *e )
+ {
+ PARENT::keyReleaseEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void leaveEvent( QEvent *e )
+ {
+ PARENT::leaveEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("leaveEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void mouseDoubleClickEvent( QMouseEvent *e )
+ {
+ PARENT::mouseDoubleClickEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 2;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseDoubleClickEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseMoveEvent( QMouseEvent *e )
+ {
+ PARENT::mouseMoveEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseMoveEvent", modifiers, x, y, clickCount);
+ }
+
+ void mousePressEvent( QMouseEvent *e )
+ {
+ PARENT::mousePressEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mousePressEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseReleaseEvent( QMouseEvent *e )
+ {
+ PARENT::mouseReleaseEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseReleaseEvent", modifiers, x, y, clickCount);
+ }
+
+ void moveEvent( QMoveEvent *e )
+ {
+ PARENT::moveEvent(e);
+ callVoidMethod("moveEvent");
+ }
+
+ void resizeEvent( QResizeEvent *e )
+ {
+ PARENT::resizeEvent(e);
+ callMouseMethod("resizeEvent",
+ e->oldSize().width(), e->oldSize().height(),
+ e->size().width(), e->size().height());
+ }
+
+ void hideEvent( QHideEvent *e )
+ {
+ PARENT::hideEvent(e);
+ callVoidMethod("hideEvent");
+ }
+
+ void showEvent( QShowEvent *e )
+ {
+ PARENT::showEvent(e);
+ callVoidMethod("showEvent");
+ }
+
+ void paintEvent ( QPaintEvent * e )
+ {
+ PARENT::paintEvent(e);
+ // Create a QPainter
+ GraphicsPainter painter( this );
+
+ // Get the environment.
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+
+ // create a QtGraphics wrapper for the QPainter
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtComponentGraphics" );
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(JLgnu/java/awt/peer/qt/QtComponentPeer;)V");
+ jobject graphics = env->NewObject(cls, mid, (jlong)&painter, target);
+
+ // call QtComponentPeer.paintEvent()
+ jmethodID paintEventID = env->GetMethodID( componentCls,
+ "paintEvent",
+ "(Lgnu/java/awt/peer/qt/QtGraphics;)V" );
+ env->CallVoidMethod( target, paintEventID, graphics );
+ env->DeleteLocalRef( cls );
+ env->DeleteLocalRef( graphics );
+ }
+
+#endif
diff --git a/native/jni/qt-peer/keybindings.cpp b/native/jni/qt-peer/keybindings.cpp
new file mode 100644
index 000000000..ff2a8a461
--- /dev/null
+++ b/native/jni/qt-peer/keybindings.cpp
@@ -0,0 +1,545 @@
+/* keybindings.cpp --
+ 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. */
+
+#include "keybindings.h"
+
+/* InputEvent key modifiers */
+#define SHIFT_MASK 1
+#define CTRL_MASK 2
+#define META_MASK 4
+#define ALT_MASK 8
+#define ALT_GRAPH_MASK 0x20
+#define BUTTON1_MASK 0x10
+#define BUTTON2_MASK 8
+#define BUTTON3_MASK 4
+
+#define SHIFT_DOWN_MASK 0x0040
+#define CTRL_DOWN_MASK 0x0080
+#define META_DOWN_MASK 0x0100
+#define ALT_DOWN_MASK 0x0200
+#define BUTTON1_DOWN_MASK 0x0400
+#define BUTTON2_DOWN_MASK 0x0800
+#define BUTTON3_DOWN_MASK 0x1000
+#define ALT_GRAPH_DOWN_MASK 0x2000
+
+/* Virtual Keys */
+/* This list should be kept in the same order as the VK_ field
+ declarations in KeyEvent.java. */
+#define VK_ENTER '\n'
+#define VK_BACK_SPACE '\b'
+#define VK_TAB '\t'
+#define VK_CANCEL 3
+#define VK_CLEAR 12
+#define VK_SHIFT 16
+#define VK_CONTROL 17
+#define VK_ALT 18
+#define VK_PAUSE 19
+#define VK_CAPS_LOCK 20
+#define VK_ESCAPE 27
+#define VK_SPACE ' '
+#define VK_PAGE_UP 33
+#define VK_PAGE_DOWN 34
+#define VK_END 35
+#define VK_HOME 36
+#define VK_LEFT 37
+#define VK_UP 38
+#define VK_RIGHT 39
+#define VK_DOWN 40
+#define VK_COMMA ','
+#define VK_MINUS '-'
+#define VK_PERIOD '.'
+#define VK_SLASH '/'
+#define VK_0 '0'
+#define VK_1 '1'
+#define VK_2 '2'
+#define VK_3 '3'
+#define VK_4 '4'
+#define VK_5 '5'
+#define VK_6 '6'
+#define VK_7 '7'
+#define VK_8 '8'
+#define VK_9 '9'
+#define VK_SEMICOLON ';'
+#define VK_EQUALS '='
+#define VK_A 'A'
+#define VK_B 'B'
+#define VK_C 'C'
+#define VK_D 'D'
+#define VK_E 'E'
+#define VK_F 'F'
+#define VK_G 'G'
+#define VK_H 'H'
+#define VK_I 'I'
+#define VK_J 'J'
+#define VK_K 'K'
+#define VK_L 'L'
+#define VK_M 'M'
+#define VK_N 'N'
+#define VK_O 'O'
+#define VK_P 'P'
+#define VK_Q 'Q'
+#define VK_R 'R'
+#define VK_S 'S'
+#define VK_T 'T'
+#define VK_U 'U'
+#define VK_V 'V'
+#define VK_W 'W'
+#define VK_X 'X'
+#define VK_Y 'Y'
+#define VK_Z 'Z'
+#define VK_OPEN_BRACKET '['
+#define VK_BACK_SLASH '\\'
+#define VK_CLOSE_BRACKET ']'
+#define VK_NUMPAD0 96
+#define VK_NUMPAD1 97
+#define VK_NUMPAD2 98
+#define VK_NUMPAD3 99
+#define VK_NUMPAD4 100
+#define VK_NUMPAD5 101
+#define VK_NUMPAD6 102
+#define VK_NUMPAD7 103
+#define VK_NUMPAD8 104
+#define VK_NUMPAD9 105
+#define VK_MULTIPLY 106
+#define VK_ADD 107
+#define VK_SEPARATER 108
+#define VK_SEPARATOR 108
+#define VK_SUBTRACT 109
+#define VK_DECIMAL 110
+#define VK_DIVIDE 111
+#define VK_DELETE 127
+#define VK_NUM_LOCK 144
+#define VK_SCROLL_LOCK 145
+#define VK_F1 112
+#define VK_F2 113
+#define VK_F3 114
+#define VK_F4 115
+#define VK_F5 116
+#define VK_F6 117
+#define VK_F7 118
+#define VK_F8 119
+#define VK_F9 120
+#define VK_F10 121
+#define VK_F11 122
+#define VK_F12 123
+#define VK_F13 61440
+#define VK_F14 61441
+#define VK_F15 61442
+#define VK_F16 61443
+#define VK_F17 61444
+#define VK_F18 61445
+#define VK_F19 61446
+#define VK_F20 61447
+#define VK_F21 61448
+#define VK_F22 61449
+#define VK_F23 61450
+#define VK_F24 61451
+#define VK_PRINTSCREEN 154
+#define VK_INSERT 155
+#define VK_HELP 156
+#define VK_META 157
+#define VK_BACK_QUOTE 192
+#define VK_QUOTE 222
+#define VK_KP_UP 224
+#define VK_KP_DOWN 225
+#define VK_KP_LEFT 226
+#define VK_KP_RIGHT 227
+#define VK_DEAD_GRAVE 128
+#define VK_DEAD_ACUTE 129
+#define VK_DEAD_CIRCUMFLEX 130
+#define VK_DEAD_TILDE 131
+#define VK_DEAD_MACRON 132
+#define VK_DEAD_BREVE 133
+#define VK_DEAD_ABOVEDOT 134
+#define VK_DEAD_DIAERESIS 135
+#define VK_DEAD_ABOVERING 136
+#define VK_DEAD_DOUBLEACUTE 137
+#define VK_DEAD_CARON 138
+#define VK_DEAD_CEDILLA 139
+#define VK_DEAD_OGONEK 140
+#define VK_DEAD_IOTA 141
+#define VK_DEAD_VOICED_SOUND 142
+#define VK_DEAD_SEMIVOICED_SOUND 143
+#define VK_AMPERSAND 150
+#define VK_ASTERISK 151
+#define VK_QUOTEDBL 152
+#define VK_LESS 153
+#define VK_GREATER 160
+#define VK_BRACELEFT 161
+#define VK_BRACERIGHT 162
+#define VK_AT 512
+#define VK_COLON 513
+#define VK_CIRCUMFLEX 514
+#define VK_DOLLAR 515
+#define VK_EURO_SIGN 516
+#define VK_EXCLAMATION_MARK 517
+#define VK_INVERTED_EXCLAMATION_MARK 518
+#define VK_LEFT_PARENTHESIS 519
+#define VK_NUMBER_SIGN 520
+#define VK_PLUS 521
+#define VK_RIGHT_PARENTHESIS 522
+#define VK_UNDERSCORE 523
+#define VK_FINAL 24
+#define VK_CONVERT 28
+#define VK_NONCONVERT 29
+#define VK_ACCEPT 30
+#define VK_MODECHANGE 31
+#define VK_KANA 21
+#define VK_KANJI 25
+#define VK_ALPHANUMERIC 240
+#define VK_KATAKANA 241
+#define VK_HIRAGANA 242
+#define VK_FULL_WIDTH 243
+#define VK_HALF_WIDTH 244
+#define VK_ROMAN_CHARACTERS 245
+#define VK_ALL_CANDIDATES 256
+#define VK_PREVIOUS_CANDIDATE 257
+#define VK_CODE_INPUT 258
+#define VK_JAPANESE_KATAKANA 259
+#define VK_JAPANESE_HIRAGANA 260
+#define VK_JAPANESE_ROMAN 261
+#define VK_KANA_LOCK 262
+#define VK_INPUT_METHOD_ON_OFF 263
+#define VK_CUT 65489
+#define VK_COPY 65485
+#define VK_PASTE 65487
+#define VK_UNDO 65483
+#define VK_AGAIN 65481
+#define VK_FIND 65488
+#define VK_PROPS 65482
+#define VK_STOP 65480
+#define VK_COMPOSE 65312
+#define VK_ALT_GRAPH 65406
+#define VK_UNDEFINED 0
+
+
+int mapKeyCode(QKeyEvent *key)
+{
+ switch(key->key())
+ {
+ case Qt::Key_Escape:
+ return VK_ESCAPE;
+ case Qt::Key_Tab:
+ return VK_TAB;
+ case Qt::Key_Backspace:
+ return VK_BACK_SPACE;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ return VK_ENTER;
+ case Qt::Key_Insert:
+ return VK_INSERT;
+ case Qt::Key_Delete:
+ return VK_DELETE;
+ case Qt::Key_Pause:
+ return VK_PAUSE;
+ case Qt::Key_Print:
+ case Qt::Key_SysReq:
+ return VK_PRINTSCREEN;
+ case Qt::Key_Home:
+ return VK_HOME;
+ case Qt::Key_End:
+ return VK_END;
+ case Qt::Key_Left:
+ return VK_LEFT;
+ case Qt::Key_Up:
+ return VK_UP;
+ case Qt::Key_Right:
+ return VK_RIGHT;
+ case Qt::Key_Down:
+ return VK_DOWN;
+ case Qt::Key_PageUp:
+ return VK_PAGE_UP;
+ case Qt::Key_PageDown:
+ return VK_PAGE_DOWN;
+ case Qt::Key_Shift:
+ return VK_SHIFT;
+ case Qt::Key_Control:
+ return VK_CONTROL;
+ case Qt::Key_Meta:
+ return VK_META;
+ case Qt::Key_Alt:
+ return VK_ALT;
+ case Qt::Key_CapsLock:
+ return VK_CAPS_LOCK;
+ case Qt::Key_NumLock:
+ return VK_NUM_LOCK;
+ case Qt::Key_ScrollLock:
+ return VK_SCROLL_LOCK;
+ case Qt::Key_Clear:
+ return VK_CLEAR;
+ case Qt::Key_F1:
+ return VK_F1;
+ case Qt::Key_F2:
+ return VK_F2;
+ case Qt::Key_F3:
+ return VK_F3;
+ case Qt::Key_F4:
+ return VK_F4;
+ case Qt::Key_F5:
+ return VK_F5;
+ case Qt::Key_F6:
+ return VK_F6;
+ case Qt::Key_F7:
+ return VK_F7;
+ case Qt::Key_F8:
+ return VK_F8;
+ case Qt::Key_F9:
+ return VK_F9;
+ case Qt::Key_F10:
+ return VK_F10;
+ case Qt::Key_F11:
+ return VK_F11;
+ case Qt::Key_F12:
+ return VK_F12;
+ case Qt::Key_F13:
+ return VK_F13;
+ case Qt::Key_F14:
+ return VK_F14;
+ case Qt::Key_F15:
+ return VK_F15;
+ case Qt::Key_F16:
+ return VK_F16;
+ case Qt::Key_F17:
+ return VK_F17;
+ case Qt::Key_F18:
+ return VK_F18;
+ case Qt::Key_F19:
+ return VK_F19;
+ case Qt::Key_F20:
+ return VK_F20;
+ case Qt::Key_F21:
+ return VK_F21;
+ case Qt::Key_F22:
+ return VK_F22;
+ case Qt::Key_F23:
+ return VK_F23;
+ case Qt::Key_F24:
+ return VK_F24;
+ case Qt::Key_Help:
+ return VK_HELP;
+
+ case Qt::Key_Space:
+ return VK_SPACE;
+
+ case Qt::Key_Exclam:
+ return VK_EXCLAMATION_MARK;
+ case Qt::Key_QuoteDbl:
+ return VK_QUOTEDBL;
+ case Qt::Key_NumberSign:
+ return VK_NUMBER_SIGN;
+
+ case Qt::Key_Dollar:
+ return VK_DOLLAR;
+
+
+ case Qt::Key_Ampersand:
+ return VK_AMPERSAND;
+
+ case Qt::Key_ParenLeft:
+ return VK_LEFT_PARENTHESIS;
+ case Qt::Key_ParenRight:
+ return VK_RIGHT_PARENTHESIS;
+ case Qt::Key_Asterisk:
+ return VK_ASTERISK;
+ case Qt::Key_Plus:
+ return VK_PLUS;
+ case Qt::Key_Comma:
+ return VK_COMMA;
+ case Qt::Key_Minus:
+ return VK_MINUS;
+ case Qt::Key_Period:
+ return VK_PERIOD;
+ case Qt::Key_Slash:
+ return VK_SLASH;
+
+ case Qt::Key_0:
+ return VK_0;
+ case Qt::Key_1:
+ return VK_1;
+ case Qt::Key_2:
+ return VK_2;
+ case Qt::Key_3:
+ return VK_3;
+ case Qt::Key_4:
+ return VK_4;
+ case Qt::Key_5:
+ return VK_5 ;
+ case Qt::Key_6:
+ return VK_6;
+ case Qt::Key_7:
+ return VK_7;
+ case Qt::Key_8:
+ return VK_8;
+ case Qt::Key_9:
+ return VK_9;
+
+ case Qt::Key_Colon:
+ return VK_COLON;
+ case Qt::Key_Semicolon:
+ return VK_SEMICOLON;
+ case Qt::Key_Less:
+ return VK_LESS;
+ case Qt::Key_Equal:
+ return VK_EQUALS;
+ case Qt::Key_Greater:
+ return VK_GREATER;
+ case Qt::Key_Question:
+ case Qt::Key_At:
+
+ case Qt::Key_A:
+ return VK_A;
+ case Qt::Key_B:
+ return VK_B;
+ case Qt::Key_C:
+ return VK_C;
+ case Qt::Key_D:
+ return VK_D;
+ case Qt::Key_E:
+ return VK_E;
+ case Qt::Key_F:
+ return VK_F;
+ case Qt::Key_G:
+ return VK_G;
+ case Qt::Key_H:
+ return VK_H;
+ case Qt::Key_I:
+ return VK_I;
+ case Qt::Key_J:
+ return VK_J;
+ case Qt::Key_K:
+ return VK_K;
+ case Qt::Key_L:
+ return VK_L;
+ case Qt::Key_M:
+ return VK_M;
+ case Qt::Key_N:
+ return VK_N;
+ case Qt::Key_O:
+ return VK_O;
+ case Qt::Key_P:
+ return VK_P;
+ case Qt::Key_Q:
+ return VK_Q;
+ case Qt::Key_R:
+ return VK_R;
+ case Qt::Key_S:
+ return VK_S;
+ case Qt::Key_T:
+ return VK_T;
+ case Qt::Key_U:
+ return VK_U;
+ case Qt::Key_V:
+ return VK_V;
+ case Qt::Key_W:
+ return VK_W;
+ case Qt::Key_X:
+ return VK_X;
+ case Qt::Key_Y:
+ return VK_Y;
+ case Qt::Key_Z:
+ return VK_Z;
+ case Qt::Key_division:
+ return VK_DIVIDE;
+ case Qt::Key_BracketLeft:
+ return VK_OPEN_BRACKET;
+ case Qt::Key_Backslash:
+ return VK_BACK_SLASH;
+ case Qt::Key_BracketRight:
+ return VK_CLOSE_BRACKET;
+ case Qt::Key_BraceLeft:
+ return VK_BRACELEFT;
+ case Qt::Key_BraceRight:
+ return VK_BRACERIGHT;
+ case Qt::Key_brokenbar:
+ return VK_SEPARATOR; // correct?
+
+ default:
+ return VK_UNDEFINED;
+ }
+}
+
+int getUnicode(QKeyEvent *key)
+{
+ QString s = key->text();
+ if(s.isEmpty())
+ return 0; // CHAR_UNDEFINED
+ QChar c = s.at(0);
+ return (int)c.unicode();
+}
+
+int getKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ return modifier;
+}
+
+int getMouseModifiers(QMouseEvent *e)
+{
+ int modifier = 0;
+ int buttons = e->buttons();
+ int state = e->modifiers();
+
+ if( buttons & Qt::LeftButton )
+ modifier |= BUTTON1_DOWN_MASK;
+ if( buttons & Qt::MidButton )
+ modifier |= BUTTON2_DOWN_MASK;
+ if( buttons & Qt::RightButton )
+ modifier |= BUTTON3_DOWN_MASK;
+
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ // FIXME: Alt Gr?
+ return modifier;
+}
+
+
diff --git a/native/jni/qt-peer/keybindings.h b/native/jni/qt-peer/keybindings.h
new file mode 100644
index 000000000..02ff894bd
--- /dev/null
+++ b/native/jni/qt-peer/keybindings.h
@@ -0,0 +1,18 @@
+#ifndef KEYBINDINGS_H
+#define KEYBINDINGS_H
+
+#include <QApplication>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPoint>
+#include <qwidget.h>
+#include <qstring.h>
+#include "qtgraphics.h"
+
+int mapKeyCode(QKeyEvent *key);
+int getUnicode(QKeyEvent *key);
+int getKeyModifiers(Qt::KeyboardModifiers state);
+int getMouseModifiers(QMouseEvent *event);
+
+#endif
diff --git a/native/jni/qt-peer/mainqtthread.cpp b/native/jni/qt-peer/mainqtthread.cpp
new file mode 100644
index 000000000..a908370b4
--- /dev/null
+++ b/native/jni/qt-peer/mainqtthread.cpp
@@ -0,0 +1,102 @@
+/* mainqtthread.cpp --
+ 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. */
+
+#include <jni.h>
+#include <QApplication>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_MainQtThread.h>
+#include "mainthreadinterface.h"
+
+MainThreadInterface *mainThread;
+QApplication *qApplication;
+
+/**
+ * Starts up a QApplication
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init
+(JNIEnv *env, jobject obj, jstring theme)
+{
+ int *argc;
+ char **argv;
+
+ if(theme != NULL)
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 3;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ argv[1] = (char *)malloc(10 * sizeof(char));
+ argv[2] = (char *)malloc(100 * sizeof(char));
+ strncpy(argv[0], "\0", 2);
+ strncpy(argv[1], "-style\0", 8);
+ strncpy(argv[2], (char *)env->GetStringUTFChars( theme, NULL ), 100);
+ }
+ else
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 1;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ strncpy(argv[0], " \0", 3);
+ }
+ QApplication *qtApp = new QApplication( *argc, argv );
+ assert( qtApp );
+
+ qApplication = qtApp;
+
+ if( theme != NULL)
+ env->ReleaseStringUTFChars( theme, argv[1] );
+
+ mainThread = new MainThreadInterface( qtApp );
+
+ jclass cls = env->GetObjectClass(obj);
+ jfieldID nofid = env->GetFieldID( cls, "mainThreadInterface", "J" );
+ env->SetLongField( obj, nofid, (jlong)mainThread );
+
+ return (jlong)qtApp;
+}
+
+/*
+ * Calls QApplication::exec()
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_exec
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QApplication *app = (QApplication *)ptr;
+ if(app)
+ app->exec();
+}
diff --git a/native/jni/qt-peer/mainthreadinterface.cpp b/native/jni/qt-peer/mainthreadinterface.cpp
new file mode 100644
index 000000000..6eb2a0df0
--- /dev/null
+++ b/native/jni/qt-peer/mainthreadinterface.cpp
@@ -0,0 +1,68 @@
+/* mainthreadinterface.cpp --
+ 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. */
+
+#include <QWidget>
+#include <QThread>
+#include "mainthreadinterface.h"
+
+MainThreadInterface::MainThreadInterface(QApplication *parent) : QObject( parent )
+{
+ mainApp = parent;
+}
+
+/**
+ * This is called from the main Qt event loop, and delegates the work to
+ * the AWTEvent runEvent method.
+ */
+bool MainThreadInterface::event ( QEvent * e )
+{
+ if( e->type() == QEvent::User)
+ {
+ AWTEvent *fe = (AWTEvent *)e;
+ fe->runEvent();
+ }
+ return true;
+}
+
+/**
+ * Posts the event to the main Qt event loop for execution.
+ */
+void MainThreadInterface::postEventToMain(AWTEvent *event)
+{
+ mainApp->postEvent(this, event);
+}
+
diff --git a/native/jni/qt-peer/mainthreadinterface.h b/native/jni/qt-peer/mainthreadinterface.h
new file mode 100644
index 000000000..cabf44775
--- /dev/null
+++ b/native/jni/qt-peer/mainthreadinterface.h
@@ -0,0 +1,39 @@
+#ifndef MAINTHREADINTERFACE_H
+#define MAINTHREADINTERFACE_H
+
+#include <jni.h>
+#include <QApplication>
+#include <QObject>
+#include <QWidget>
+#include <QEvent>
+
+class AWTEvent : public QEvent {
+
+ public:
+ AWTEvent() : QEvent( QEvent::User )
+ {
+ }
+
+ virtual void runEvent()
+ {
+ }
+
+};
+
+#define AWT_INIT 0
+#define AWT_SETVISIBLE 1
+
+class MainThreadInterface : public QObject {
+
+ private:
+ QApplication *mainApp;
+
+ public:
+ MainThreadInterface(QApplication *parent);
+ bool event ( QEvent * e );
+ void postEventToMain(AWTEvent *event);
+};
+
+extern MainThreadInterface *mainThread;
+
+#endif
diff --git a/native/jni/qt-peer/nativewrapper.cpp b/native/jni/qt-peer/nativewrapper.cpp
new file mode 100644
index 000000000..0dec02c96
--- /dev/null
+++ b/native/jni/qt-peer/nativewrapper.cpp
@@ -0,0 +1,64 @@
+/* nativewrapper.cpp --
+ 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. */
+
+#include "nativewrapper.h"
+
+#define WRAPPER_CLASS "gnu/java/awt/peer/qt/NativeWrapper"
+
+/*
+ * Sets the native object field.
+ */
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jlong value = (jlong) ptr;
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( qtcomponent, nofid, value );
+ env->DeleteLocalRef( cls );
+}
+
+/**
+ * Gets the native object field.
+ */
+void *getNativeObject( JNIEnv *env, jobject qtcomponent )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ jlong value = env->GetLongField( qtcomponent, nofid );
+ env->DeleteLocalRef( cls );
+ return (void *) value;
+}
diff --git a/native/jni/qt-peer/nativewrapper.h b/native/jni/qt-peer/nativewrapper.h
new file mode 100644
index 000000000..1207aa1d3
--- /dev/null
+++ b/native/jni/qt-peer/nativewrapper.h
@@ -0,0 +1,10 @@
+#ifndef NATIVEWRAPPER_H
+#define NATIVEWRAPPER_H
+
+#include <jni.h>
+
+void *getNativeObject( JNIEnv *env, jobject qtcomponent );
+
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr );
+
+#endif
diff --git a/native/jni/qt-peer/qmatrix.cpp b/native/jni/qt-peer/qmatrix.cpp
new file mode 100644
index 000000000..96a9407d8
--- /dev/null
+++ b/native/jni/qt-peer/qmatrix.cpp
@@ -0,0 +1,95 @@
+/* qmatrix.cpp --
+ 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. */
+
+#include <QMatrix>
+#include <gnu_java_awt_peer_qt_QMatrix.h>
+#include "nativewrapper.h"
+
+/*
+ * Creates a QMatrix
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_init
+(JNIEnv *env, jobject obj, jdouble m00, jdouble m10, jdouble m01, jdouble m11,
+ jdouble m02, jdouble m12 )
+{
+ QMatrix *matrix = new QMatrix( (qreal) m00, (qreal) m10,
+ (qreal) m01, (qreal) m11,
+ (qreal) m02, (qreal) m12 );
+ assert( matrix );
+ setNativeObject(env, obj, matrix);
+}
+
+/*
+ * Returns the matrix a java array of doubles,
+ * in m00, m10, m01, m11, m02, m12 (java notation) format.
+ * Note that qt has different notations for the array elements.
+ */
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_qt_QMatrix_getMatrix
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ assert( matrix );
+
+ jdoubleArray result_array;
+ jdouble *dst;
+
+ result_array = env->NewDoubleArray( 6 );
+ dst = env->GetDoubleArrayElements(result_array, NULL);
+
+ dst[0] = (jdouble)matrix->m11(); // qt m11 = java m00
+ dst[1] = (jdouble)matrix->m12(); // qt m12 = java m10
+ dst[2] = (jdouble)matrix->m21(); // qt m21 = java m01
+ dst[3] = (jdouble)matrix->m22(); // qt m22 = java m11
+ dst[4] = (jdouble)matrix->dx(); // qt dx = java m02
+ dst[5] = (jdouble)matrix->dy(); // qt dy = java m12
+
+ env->ReleaseDoubleArrayElements (result_array, dst, 0);
+ return result_array;
+}
+
+/*
+ * Dispose of the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_dispose
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ if( matrix )
+ delete matrix;
+ setNativeObject(env, obj, NULL);
+}
+
diff --git a/native/jni/qt-peer/qpainterpath.cpp b/native/jni/qt-peer/qpainterpath.cpp
new file mode 100644
index 000000000..97103d6a5
--- /dev/null
+++ b/native/jni/qt-peer/qpainterpath.cpp
@@ -0,0 +1,238 @@
+/* qpainterpath.cpp --
+ 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. */
+
+#include <QPainterPath>
+#include <gnu_java_awt_peer_qt_QPainterPath.h>
+#include "nativewrapper.h"
+
+// java.awt.geom.PathIterator constants.
+#define WIND_EVEN_ODD 0
+#define WIND_NON_ZERO 1
+
+
+/*
+ * Creates an empty QPainterPath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_init
+(JNIEnv *env, jobject obj, jint windingRule)
+{
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+ path->setFillRule( (windingRule == WIND_EVEN_ODD) ?
+ Qt::OddEvenFill : Qt::WindingFill );
+ setNativeObject(env, obj, path);
+}
+
+/*
+ * MoveTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_moveTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->moveTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * Closes the subpath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_close
+(JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->closeSubpath();
+}
+
+/*
+ * LineTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_lineTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->lineTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * QuadraticTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_quadTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->quadTo( (qreal)x, (qreal)y, (qreal)x2, (qreal)y2 );
+}
+
+/*
+ * CubicTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_cubicTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2,
+ jdouble x3, jdouble y3)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->cubicTo( (qreal)x, (qreal)y,
+ (qreal)x2, (qreal)y2,
+ (qreal)x3, (qreal)y3 );
+}
+
+/*
+ * Delete the native object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_dispose
+ (JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ if ( path )
+ delete path;
+}
+
+/********* GeneralPath functions *****************************/
+
+// FIXME : Cache method ids.
+
+static void gp_moveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "moveTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_lineTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "lineTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_curveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3 )
+{
+ jmethodID method;
+ jvalue values[6];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+ values[2].f = (jfloat) x2;
+ values[3].f = (jfloat) y2;
+ values[4].f = (jfloat) x3;
+ values[5].f = (jfloat) y3;
+
+ method = env->GetMethodID(cls, "curveTo", "(FFFFFF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+/**
+ * Returns the QPainterPath obj as a java.awt.geom.GeneralPath.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_getPath
+(JNIEnv *env, jobject obj)
+{
+ jclass cls;
+ jmethodID method;
+ jobject gp;
+ QPainterPath::Element currElement;
+ int windingRule;
+
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+
+ windingRule = (path->fillRule() == Qt::OddEvenFill) ?
+ WIND_EVEN_ODD : WIND_NON_ZERO;
+
+ cls = env->FindClass("java/awt/geom/GeneralPath");
+ method = env->GetMethodID(cls, "<init>", "(I)V");
+ gp = env->NewObject(cls, method, windingRule);
+
+ for( int i = 0; i < path->elementCount(); i++)
+ {
+ currElement = path->elementAt( i );
+ switch(currElement.type)
+ {
+ case QPainterPath::MoveToElement:
+ gp_moveTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::LineToElement:
+ gp_lineTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::CurveToElement:
+ if( i + 2 >= path->elementCount() )
+ break;
+ if(path->elementAt(i + 1).type != QPainterPath::CurveToDataElement ||
+ path->elementAt(i + 2).type != QPainterPath::CurveToDataElement)
+ break;
+ gp_curveTo(env, gp, cls, currElement.x, currElement.y,
+ path->elementAt(i + 1).x, path->elementAt(i + 1).y,
+ path->elementAt(i + 2).x, path->elementAt(i + 2).y );
+ i += 2;
+ break;
+ }
+ }
+ env->DeleteLocalRef( cls );
+ return gp;
+}
+
diff --git a/native/jni/qt-peer/qpen.cpp b/native/jni/qt-peer/qpen.cpp
new file mode 100644
index 000000000..de3cf4721
--- /dev/null
+++ b/native/jni/qt-peer/qpen.cpp
@@ -0,0 +1,107 @@
+/* qpen.cpp --
+ 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. */
+
+#include <QColor>
+#include <QPen>
+#include <gnu_java_awt_peer_qt_QPen.h>
+#include "nativewrapper.h"
+
+/*
+ * java.awt.geom.BasicStroke constants.
+ */
+#define JOIN_MITER 0
+#define JOIN_ROUND 1
+#define JOIN_BEVEL 2
+#define CAP_BUTT 0
+#define CAP_ROUND 1
+#define CAP_SQUARE 2
+
+/**
+ * Create a QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_init
+(JNIEnv *env, jobject obj , jdouble width, jint cap, jint join, jdouble miterlimit)
+{
+ Qt::PenCapStyle qtCap;
+ Qt::PenJoinStyle qtJoin;
+
+ switch(cap)
+ {
+ case CAP_BUTT:
+ qtCap = Qt::FlatCap;
+ break;
+ case CAP_ROUND:
+ qtCap = Qt::RoundCap;
+ break;
+ case CAP_SQUARE:
+ qtCap = Qt::SquareCap;
+ break;
+ }
+
+ switch(join)
+ {
+ case JOIN_MITER:
+ qtJoin = Qt::MiterJoin;
+ break;
+ case JOIN_ROUND:
+ qtJoin = Qt::RoundJoin;
+ break;
+ case JOIN_BEVEL:
+ qtJoin = Qt::BevelJoin;
+ break;
+ }
+
+ QPen *pen = new QPen();
+ assert( pen );
+ pen->setWidthF( (qreal)width );
+ pen->setCapStyle( qtCap );
+ pen->setJoinStyle( qtJoin );
+
+ setNativeObject(env, obj, pen);
+}
+
+/**
+ * Dispose of the QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_dispose
+(JNIEnv *env, jobject obj)
+{
+ QPen *pen = (QPen *)getNativeObject(env, obj);
+ if ( pen )
+ delete pen;
+}
+
diff --git a/native/jni/qt-peer/qtaudioclip.cpp b/native/jni/qt-peer/qtaudioclip.cpp
new file mode 100644
index 000000000..d5689b26d
--- /dev/null
+++ b/native/jni/qt-peer/qtaudioclip.cpp
@@ -0,0 +1,114 @@
+/* qtaudioclip.cpp --
+ 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. */
+
+#include <jni.h>
+#include <assert.h>
+#include <QString>
+#include <QSound>
+#include <gnu_java_awt_peer_qt_QtAudioClip.h>
+#include "qtstrings.h"
+#include "nativewrapper.h"
+
+/*
+ * Loads an audio clip. Returns JNI_TRUE if the load succeded,
+ * JNI_FALSE otherwise.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_loadClip
+(JNIEnv *env, jobject obj, jstring filename)
+{
+ QString *qStr = getQString(env, filename);
+
+ QSound *sound = new QSound( *qStr );
+
+ delete qStr;
+
+ setNativeObject( env, obj, sound );
+}
+
+/*
+ * Plays the audio clip, plays looped if loop equals JNI_TRUE.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_play
+(JNIEnv *env, jobject obj, jboolean loop)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ sound->setLoops( (loop == JNI_TRUE) ? -1 : 1 );
+ sound->play();
+ }
+}
+
+/*
+ * Stops the audio playback.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_stop
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ sound->stop();
+}
+
+/**
+ * Disposes the audio clip
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_dispose
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ setNativeObject( env, obj, NULL );
+ if( !sound->isFinished() )
+ sound->stop();
+ delete sound;
+ }
+}
+
+/**
+ * Returns whether sound is available.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_isAvailable
+(JNIEnv *env, jobject obj)
+{
+ if( QSound::isAvailable() )
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
+}
+
diff --git a/native/jni/qt-peer/qtbuttonpeer.cpp b/native/jni/qt-peer/qtbuttonpeer.cpp
new file mode 100644
index 000000000..cf0ec21d7
--- /dev/null
+++ b/native/jni/qt-peer/qtbuttonpeer.cpp
@@ -0,0 +1,93 @@
+/* qtbuttonpeer.cpp --
+ 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. */
+
+#include <QMainWindow>
+#include <QPushButton>
+#include <QFont>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+
+class MyButton : public QPushButton
+{
+public:
+ MyButton(JNIEnv *env, jobject obj, QWidget *parent) : QPushButton(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyButton()
+ {
+ destroy();
+ }
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QPushButton
+#include "eventmethods.cpp"
+};
+
+/**
+ * Init method
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_init
+(JNIEnv *env, jobject obj)
+{
+
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ MyButton *button = new MyButton( env, obj, parentWidget );
+ assert( button );
+ setNativeObject( env, obj, button );
+ connectButton(button, env, obj); // connect the fireClick method.
+}
+
+/**
+ * Sets the button label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_setLabel
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QPushButton *button = (QPushButton *) getNativeObject( env, obj );
+ assert( button );
+
+ QString *qStr = getQString(env, str); // AWTLabelEvent takes care of disposal.
+ mainThread->postEventToMain( new AWTLabelEvent( button, qStr ) );
+}
+
+
diff --git a/native/jni/qt-peer/qtcanvaspeer.cpp b/native/jni/qt-peer/qtcanvaspeer.cpp
new file mode 100644
index 000000000..f6f6926bf
--- /dev/null
+++ b/native/jni/qt-peer/qtcanvaspeer.cpp
@@ -0,0 +1,74 @@
+/* qtcanvaspeer.cpp --
+ 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. */
+
+#include <QMainWindow>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtCanvasPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyCanvas : public QWidget
+{
+public:
+ MyCanvas(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCanvas()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.cpp"
+};
+
+/*
+ * Construct a QWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCanvasPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ // QWidget *canvas = new QWidget( parentWidget );
+ QWidget *canvas = new MyCanvas( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
diff --git a/native/jni/qt-peer/qtcheckboxpeer.cpp b/native/jni/qt-peer/qtcheckboxpeer.cpp
new file mode 100644
index 000000000..018d2e06c
--- /dev/null
+++ b/native/jni/qt-peer/qtcheckboxpeer.cpp
@@ -0,0 +1,163 @@
+/* qtcheckboxpeer.cpp --
+ 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. */
+
+#include <QAbstractButton>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <gnu_java_awt_peer_qt_QtCheckboxPeer.h>
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+class CheckboxCheckEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ bool checked;
+
+ public:
+ CheckboxCheckEvent(QAbstractButton *w, bool c)
+ {
+ widget = w;
+ checked = c;
+ }
+
+ void runEvent()
+ {
+ if (checked != widget->isChecked())
+ widget->setChecked( checked );
+ }
+};
+
+class MyCheckBox : public QCheckBox
+{
+public:
+ MyCheckBox(JNIEnv *env, jobject obj, QWidget *parent) : QCheckBox( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCheckBox()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QCheckBox
+#include "eventmethods.cpp"
+};
+
+/**
+ * Determines whether the darn native object should be a radio button or not
+ */
+static bool isRadioButton( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtCheckboxPeer" );
+ jfieldID field = env->GetFieldID( cls, "group", "Ljava/awt/CheckboxGroup;" );
+ if (env->GetObjectField( obj, field ) != NULL)
+ return true;
+ return false;
+}
+
+/**
+ * Construct the native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ if (cb)
+ delete cb;
+
+ bool radioButton;
+ {
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "owner", "Ljava/awt/Component;" );
+ assert(field != NULL);
+ jobject owner = env->GetObjectField( obj, field );
+ assert(owner != NULL);
+ cls = env->GetObjectClass( owner );
+ jmethodID method = env->GetMethodID( cls,
+ "getCheckboxGroup",
+ "()Ljava/awt/CheckboxGroup;" );
+ assert(method != NULL);
+ jobject group = env->CallObjectMethod( owner, method, 0);
+ radioButton = (group != NULL);
+ }
+
+ if(radioButton)
+ cb = new QRadioButton( parentWidget );
+ else
+ cb = new QCheckBox( parentWidget );
+ // cb = new MyCheckBox( env, obj, parentWidget );
+ assert( cb );
+
+ connectToggle(cb, env, obj); // connect the native event.
+
+ setNativeObject( env, obj, cb );
+}
+
+/*
+ * Sets the checkbox label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ /* Both QCheckbox and QRadioButton inherit QAbstractButton */
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new AWTLabelEvent( cb, qStr ) );
+ // AWTLabelEvent takes care of disposal of qStr
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+ mainThread->postEventToMain( new CheckboxCheckEvent( cb, (state == JNI_TRUE) ) );
+}
+
diff --git a/native/jni/qt-peer/qtchoicepeer.cpp b/native/jni/qt-peer/qtchoicepeer.cpp
new file mode 100644
index 000000000..b1675bebe
--- /dev/null
+++ b/native/jni/qt-peer/qtchoicepeer.cpp
@@ -0,0 +1,142 @@
+/* qtchoicepeer.cpp --
+ 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. */
+
+#include <QComboBox>
+#include <gnu_java_awt_peer_qt_QtChoicePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+
+class InsertEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ QString *string;
+ int index;
+
+ public:
+ InsertEvent(QComboBox *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class RemoveSelectEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ int index;
+ bool remove;
+
+ public:
+ RemoveSelectEvent(QComboBox *w, int i, bool r) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ remove = r;
+ }
+
+ void runEvent()
+ {
+ if (remove)
+ widget->removeItem( index );
+ else
+ widget->setCurrentIndex( index );
+ }
+};
+
+
+/*
+ * Constructs tha QComboBox object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QComboBox *box = new QComboBox( parentWidget );
+ assert( box );
+
+ setNativeObject( env, obj, box );
+
+ connectChoice(box, env, obj); // connect the fireChoice method.
+}
+
+/*
+ * Inserts a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_add
+(JNIEnv *env, jobject obj, jstring itemLabel, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+
+ QString *qStr = getQString( env, itemLabel );
+ mainThread->postEventToMain( new InsertEvent( box, qStr, index ) );
+}
+
+/*
+ * Removes a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_remove
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, true ) );
+}
+
+/**
+ * Selects a choice box item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_select
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, false ) );
+}
+
diff --git a/native/jni/qt-peer/qtcomponent.cpp b/native/jni/qt-peer/qtcomponent.cpp
new file mode 100644
index 000000000..d9ddd7e20
--- /dev/null
+++ b/native/jni/qt-peer/qtcomponent.cpp
@@ -0,0 +1,122 @@
+/* qtcomponent.cpp --
+ 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. */
+
+#include <jni.h>
+#include <assert.h>
+#include <qmainwindow.h>
+#include <qwidget.h>
+#include "qtcomponent.h"
+#include "containers.h"
+
+#define COMPONENT_CLASS "gnu/java/awt/peer/qt/QtComponentPeer"
+
+/*
+ * Returns the parent widget for a QtComponentPeer
+ */
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer )
+{
+ jclass componentCls = env->FindClass( COMPONENT_CLASS );
+ jfieldID ownerField = env->GetFieldID( componentCls,
+ "owner", "Ljava/awt/Component;" );
+
+ jobject owner = env->GetObjectField( qtcomponentpeer, ownerField );
+ if (owner == NULL)
+ return NULL;
+
+ jclass ownerCls = env->GetObjectClass( owner );
+ jmethodID getParentMID = env->GetMethodID( ownerCls,
+ "getParent",
+ "()Ljava/awt/Container;" );
+ assert(getParentMID);
+
+ jobject parent = env->CallObjectMethod( owner, getParentMID, 0);
+ assert(parent);
+
+ // Get the parents peer
+ jclass parentCls = env->GetObjectClass( parent );
+ {
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ if(env->IsInstanceOf( parent, frameCls ) == JNI_TRUE)
+ return frameChildWidget( env, parent );
+ }
+ {
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ if(env->IsInstanceOf( parent, scrollpaneCls ) == JNI_TRUE)
+ return scrollPaneChildWidget( env, parent );
+ }
+
+ jmethodID getPeerMID = env->GetMethodID( parentCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+ return getNativeObject(env, env->CallObjectMethod( parent, getPeerMID, 0));
+}
+
+/*
+ * Creates a java.awt.Dimension object from a QSize.
+ */
+jobject makeDimension(JNIEnv *env, QSize *size)
+{
+ if( size == NULL )
+ return NULL;
+ if( size->isNull() || !size->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Dimension");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) size->width();
+ values[1].i = (jint) size->height();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Creates a java.awt.Point object from a QPoint.
+ */
+jobject makePoint(JNIEnv *env, QPoint &p)
+{
+ jclass cls = env->FindClass("java/awt/Point");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) p.x();
+ values[1].i = (jint) p.y();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
diff --git a/native/jni/qt-peer/qtcomponent.h b/native/jni/qt-peer/qtcomponent.h
new file mode 100644
index 000000000..3188f03f5
--- /dev/null
+++ b/native/jni/qt-peer/qtcomponent.h
@@ -0,0 +1,16 @@
+#ifndef QTCOMPONENT_H
+#define QTCOMPONENT_H
+
+#include <QSize>
+#include <QPoint>
+//#include <cassert.h>
+#include <jni.h>
+#include "nativewrapper.h"
+
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer );
+
+jobject makeDimension(JNIEnv *env, QSize *size);
+
+jobject makePoint(JNIEnv *env, QPoint &p);
+
+#endif
diff --git a/native/jni/qt-peer/qtcomponentpeer.cpp b/native/jni/qt-peer/qtcomponentpeer.cpp
new file mode 100644
index 000000000..0996b6973
--- /dev/null
+++ b/native/jni/qt-peer/qtcomponentpeer.cpp
@@ -0,0 +1,391 @@
+/* qtcomponentpeer.cpp --
+ 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. */
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QShowEvent>
+#include <QHideEvent>
+#include <QColor>
+#include <QCursor>
+#include <QPoint>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtComponentPeer.h>
+#include "qtcomponent.h"
+#include "componentevent.h"
+#include "qtfont.h"
+
+extern QApplication *qApplication;
+
+// Java Cursor types.
+#define DEFAULT_CURSOR 0
+#define CROSSHAIR_CURSOR 1
+#define TEXT_CURSOR 2
+#define WAIT_CURSOR 3
+#define SW_RESIZE_CURSOR 4
+#define SE_RESIZE_CURSOR 5
+#define NW_RESIZE_CURSOR 6
+#define NE_RESIZE_CURSOR 7
+#define N_RESIZE_CURSOR 8
+#define S_RESIZE_CURSOR 9
+#define W_RESIZE_CURSOR 10
+#define E_RESIZE_CURSOR 11
+#define HAND_CURSOR 12
+#define MOVE_CURSOR 13
+
+/**
+ * Call back the init() method from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+
+ // wait for the thing to be created.
+ void *p = NULL;
+ do
+ {
+ env->MonitorEnter( obj );
+ p = getNativeObject(env, obj);
+ env->MonitorExit( obj );
+ } while( p == NULL);
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_disposeNative
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ if( widget )
+ {
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+ }
+}
+
+/**
+ * Returns the on-screen location of the component.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getLocationOnScreen
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QPoint *p = NULL;
+ mainThread->postEventToMain( new AWTGetOriginEvent( widget, &p) );
+ while (p == NULL); // wait for the thing to be retrived.
+
+ return makePoint(env, *p);
+}
+
+/*
+ * Get the minimum size
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getMinimumSizeNative
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QSize *size = NULL;
+
+ AWTGetSizeEvent *e = new AWTGetSizeEvent( widget, &size, false );
+ mainThread->postEventToMain( e );
+ while(size == NULL);
+ return makeDimension(env, size);
+
+ delete size;
+}
+
+/*
+ * Get the preferred size of the widget
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getPreferredSizeNative
+
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QSize *size = NULL;
+
+ AWTGetSizeEvent *e = new AWTGetSizeEvent( widget, &size, true );
+ mainThread->postEventToMain( e );
+ while(size == NULL);
+
+ return makeDimension(env, size);
+
+ delete size;
+}
+
+/*
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isObscured
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->isVisible() == TRUE) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/*
+ * Returns whether the widget is focusable or not.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isFocusable
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->focusPolicy() != Qt::NoFocus) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/**
+ * Requests the focus
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_requestFocus
+ (JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain( new AWTReqFocusEvent( widget ) );
+}
+
+/*
+ * Sets the size and position. Important.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y ||
+ g.width() != width || g.height() != height)
+ {
+ mainThread->postEventToMain
+ (new AWTResizeEvent( widget, x, y, width, height ) );
+ }
+}
+
+/*
+ * Sets the mouse cursor
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setCursor
+ (JNIEnv *env, jobject obj, jint cursortype)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ Qt::CursorShape shape;
+ switch(cursortype)
+ {
+ case CROSSHAIR_CURSOR:
+ shape = Qt::CrossCursor;
+ break;
+
+ case W_RESIZE_CURSOR:
+ case E_RESIZE_CURSOR:
+ shape = Qt::SizeHorCursor;
+ break;
+ case N_RESIZE_CURSOR:
+ case S_RESIZE_CURSOR:
+ shape = Qt::SizeVerCursor;
+ break;
+ case HAND_CURSOR:
+ shape = Qt::PointingHandCursor;
+ break;
+ case MOVE_CURSOR:
+ shape = Qt::SizeAllCursor;
+ break;
+
+ case NE_RESIZE_CURSOR:
+ case SW_RESIZE_CURSOR:
+ shape = Qt::SizeBDiagCursor;
+ break;
+ case NW_RESIZE_CURSOR:
+ case SE_RESIZE_CURSOR:
+ shape = Qt::SizeFDiagCursor;
+ break;
+ case TEXT_CURSOR:
+ shape = Qt::IBeamCursor;
+ break;
+ case WAIT_CURSOR:
+ shape = Qt::WaitCursor;
+ break;
+
+ case DEFAULT_CURSOR:
+ default:
+ shape = Qt::ArrowCursor;
+ break;
+ }
+
+ mainThread->postEventToMain( new AWTCursorEvent( widget, shape ) );
+}
+
+/*
+ * Enable, disable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+
+ mainThread->postEventToMain( new AWTEnableEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+
+ mainThread->postEventToMain( new AWTFontEvent(widget, font) );
+}
+
+/*
+ * Sets the back- or foreground color.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jboolean isForeground)
+{
+ QColor *color = new QColor(r, g, b);
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget);
+ mainThread->postEventToMain( new AWTBackgroundEvent(widget,
+ (isForeground == JNI_TRUE),
+ color) );
+}
+
+/*
+ * Sets the visibility.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setVisible
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+ mainThread->postEventToMain( new AWTShowEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/*
+ * Returns whether the widget handles wheel scrolling.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_handlesWheelScrolling
+(JNIEnv *env, jobject obj)
+{
+ jboolean handles = JNI_FALSE;
+
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ if( cb->focusPolicy() & Qt::WheelFocus )
+ handles = JNI_TRUE;
+
+ return handles;
+}
+
+/**
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdateArea
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ (cb, false, x, y, w, h ) );
+}
+
+/*
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdate
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ ( cb, true, 0, 0, 0, 0 ) );
+}
+
+/*
+ * Returns the native background color.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getNativeBackground
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ assert(cb);
+ QColor c = cb->palette().background().color().toRgb();
+
+ jclass cls = env->FindClass("java/awt/Color");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(III)V");
+ jvalue values[3];
+
+ values[0].i = (jint) c.red();
+ values[1].i = (jint) c.green();
+ values[2].i = (jint) c.blue();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns which screen the component is on.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_whichScreen
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ return (jint) qApplication->desktop()->screenNumber( widget );
+}
diff --git a/native/jni/qt-peer/qtdialogpeer.cpp b/native/jni/qt-peer/qtdialogpeer.cpp
new file mode 100644
index 000000000..bc7157b15
--- /dev/null
+++ b/native/jni/qt-peer/qtdialogpeer.cpp
@@ -0,0 +1,163 @@
+/* qtdialogpeer.cpp --
+ 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. */
+
+#include <qdialog.h>
+#include <gnu_java_awt_peer_qt_QtDialogPeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+class MyDialog : public QDialog
+{
+public:
+ MyDialog(JNIEnv *env, jobject obj, QWidget *parent) : QDialog(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyDialog()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QDialog
+#include "eventmethods.cpp"
+};
+
+class DialogSettingsEvent : public AWTEvent {
+
+ private:
+ QDialog *widget;
+ bool modal;
+ bool value;
+
+ public:
+ DialogSettingsEvent(QDialog *w, bool m, bool v) : AWTEvent()
+ {
+ widget = w;
+ modal = m;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( modal )
+ widget->setModal( value );
+ else
+ widget->setSizeGripEnabled( value );
+ }
+};
+
+class DialogResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool fixed;
+ int x, y, w, h;
+
+ public:
+ DialogResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0, bool f)
+ {
+ widget = wid;
+ fixed = f;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+ }
+
+ void runEvent()
+ {
+ if( fixed )
+ widget->setFixedSize( w, h );
+ widget->setGeometry( x, y, w, h );
+ }
+};
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ // QDialog *dialog = new QDialog(parentWidget);
+ MyDialog *dialog = new MyDialog(env, obj, parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+
+/*
+ * Sets the modality of the dialog.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setModal
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, true, (flag == JNI_TRUE)));
+}
+
+
+/*
+ * Set resizeable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setResizable
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, false, (flag == JNI_TRUE)));
+}
+
+/*
+ * Overloaded to allow for size locking.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jboolean fixed)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y ||
+ g.width() != width || g.height() != height)
+ mainThread->postEventToMain( new DialogResizeEvent( widget, x, y, width, height, (fixed == JNI_TRUE) ) );
+}
diff --git a/native/jni/qt-peer/qtfiledialogpeer.cpp b/native/jni/qt-peer/qtfiledialogpeer.cpp
new file mode 100644
index 000000000..dbcf6cfdf
--- /dev/null
+++ b/native/jni/qt-peer/qtfiledialogpeer.cpp
@@ -0,0 +1,100 @@
+/* qtfiledialogpeer.cpp --
+ 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. */
+
+#include <QFileDialog>
+#include <QDialog>
+#include <gnu_java_awt_peer_qt_QtFileDialogPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+// Constants from FileDialog
+#define LOAD 0
+#define SAVE 1
+
+class FileDialogMode : public AWTEvent {
+
+ private:
+ QFileDialog *widget;
+ bool open;
+
+ public:
+ FileDialogMode(QFileDialog *w, bool o) : AWTEvent()
+ {
+ widget = w;
+ open = o;
+ }
+
+ void runEvent()
+ {
+ if( open )
+ {
+ widget->setAcceptMode( QFileDialog::AcceptOpen );
+ widget->setFileMode( QFileDialog::ExistingFile );
+ }
+ else
+ {
+ widget->setAcceptMode( QFileDialog::AcceptSave );
+ widget->setFileMode( QFileDialog::AnyFile );
+ }
+ }
+};
+
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QFileDialog *dialog = new QFileDialog(parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+/**
+ * Sets the mode (LOAD or SAVE)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_setMode
+(JNIEnv *env, jobject obj, jint mode)
+{
+ QFileDialog *filedialog = (QFileDialog *) getNativeObject( env, obj );
+ assert( filedialog );
+
+ mainThread->postEventToMain( new FileDialogMode( filedialog, (mode != SAVE) ) );
+}
diff --git a/native/jni/qt-peer/qtfont.h b/native/jni/qt-peer/qtfont.h
new file mode 100644
index 000000000..d13b8e098
--- /dev/null
+++ b/native/jni/qt-peer/qtfont.h
@@ -0,0 +1,8 @@
+#ifndef QTFONT_H
+#define QTFONT_H
+
+#include <jni.h>
+
+QFont *getFont( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/native/jni/qt-peer/qtfontmetrics.cpp b/native/jni/qt-peer/qtfontmetrics.cpp
new file mode 100644
index 000000000..b95c0e111
--- /dev/null
+++ b/native/jni/qt-peer/qtfontmetrics.cpp
@@ -0,0 +1,232 @@
+/* qtfontmetrics.cpp --
+ 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. */
+
+#include <QChar>
+#include <QFont>
+#include <QFontMetrics>
+#include <QString>
+#include <QPainter>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtFontMetrics.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+
+QFontMetrics *getFontMetrics( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFontMetrics *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject makeRectangle(JNIEnv *env, QRect *rect)
+{
+ if( rect == NULL )
+ return NULL;
+ if( rect->isNull() || !rect->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ rect->getRect(&x, &y, &w, &h);
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_init
+(JNIEnv *env, jobject obj, jobject fontPeer)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QFontMetrics *fm = new QFontMetrics( *f );
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_initGraphics
+(JNIEnv *env, jobject obj, jobject fontPeer, jobject graphics)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QFontMetrics *fm = new QFontMetrics( *f , painter->device());
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Dispose
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ if ( fm )
+ delete fm;
+ setNativePtr( env, obj, NULL );
+}
+
+/*
+ * Returns JNI_TRUE if a character is displayable.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_canDisplay
+(JNIEnv *env, jobject obj, jchar c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ bool result = fm->inFont( QChar( (unsigned short)c ) );
+ return (result ? JNI_TRUE : JNI_FALSE);
+}
+
+/*
+ * Returns the ascent.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getAscent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->ascent();
+}
+
+/*
+ * Returns the descent
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getDescent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->descent();
+}
+
+/*
+ * Returns the height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getHeight
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->height();
+}
+
+/*
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getLeading
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->leading();
+}
+
+/*
+ * getStringBounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getStringBounds
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ QRect r = fm->boundingRect( *qStr );
+ delete qStr;
+
+ return makeRectangle( env, &r );
+}
+
+/*
+ * Returns the width of the widest character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getMaxAdvance
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->maxWidth();
+}
+
+/*
+ * Returns the width of a given character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_charWidth
+(JNIEnv *env, jobject obj, jchar c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->width( QChar( (unsigned short)c ) );
+}
+
+/*
+ * Returns the width of a string.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_stringWidth
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ int width = fm->width( *qStr );
+ delete qStr;
+ return width;
+}
+
+
+
diff --git a/native/jni/qt-peer/qtfontpeer.cpp b/native/jni/qt-peer/qtfontpeer.cpp
new file mode 100644
index 000000000..dbf27d0fc
--- /dev/null
+++ b/native/jni/qt-peer/qtfontpeer.cpp
@@ -0,0 +1,91 @@
+/* qtfontpeer.cpp --
+ 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. */
+
+#include <QFont>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtFontPeer.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+
+// java.awt.Font constants
+#define PLAIN 0
+#define BOLD 1
+#define ITALIC 2
+
+QFont *getFont( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFont *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_create
+(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
+{
+ QString *str = getQString(env, name);
+ QFont *font = NULL;
+ font = new QFont( *str, size,
+ ((style & BOLD) != 0) ? QFont::Bold : QFont::Normal,
+ ((style & ITALIC) != 0) );
+ assert( font );
+ delete str;
+ setNativePtr( env, obj, font );
+}
+
+/*
+ * Destroys a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFont *font = getFont( env, obj );
+ if( font )
+ delete font;
+ setNativePtr( env, obj, NULL );
+}
+
diff --git a/native/jni/qt-peer/qtframepeer.cpp b/native/jni/qt-peer/qtframepeer.cpp
new file mode 100644
index 000000000..b2c763943
--- /dev/null
+++ b/native/jni/qt-peer/qtframepeer.cpp
@@ -0,0 +1,202 @@
+/* qtframepeer.cpp --
+ 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. */
+
+#include <QApplication>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtFramePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "containers.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+#define MenuSizeDefault 5
+
+/*
+ * Our QMainWindow subclass
+ */
+class MyWindow : public QMainWindow
+{
+public:
+ MyWindow(JNIEnv *env, jobject obj) : QMainWindow(0, Qt::Window )
+ {
+ setup(env, obj);
+ }
+
+ ~MyWindow()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QMainWindow
+#include "eventmethods.cpp"
+};
+
+/**
+ * Event wrapper for adding a menu bar to the frame
+ * if the QMenuBar pointer is NULL, the current menu bar is removed.
+ */
+class FrameMenuEvent : public AWTEvent {
+
+ private:
+ QMainWindow *widget;
+ QMenuBar *menu;
+
+ public:
+ FrameMenuEvent(QMainWindow *w, QMenuBar *mb) : AWTEvent()
+ {
+ widget = w;
+ menu = mb;
+ }
+
+ void runEvent()
+ {
+ if( menu != NULL)
+ widget->setMenuBar( menu );
+ else
+ delete widget->menuBar();
+ }
+};
+
+/**
+ * Event wrapper for getting the menu bar height
+ */
+class FrameGetMenuHeightEvent : public AWTEvent {
+
+private:
+ QMainWindow *frame;
+ int *value;
+
+public:
+ FrameGetMenuHeightEvent(QMainWindow *w, int *v) : AWTEvent()
+ {
+ frame = w;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ QMenuBar *mb = frame->menuBar();
+ assert( mb );
+ int v;
+ if( mb->isVisible() )
+ v = mb->size().height();
+
+ if(v <= 0 || v >= 0xFFFFF ) // Work around for strange values.
+ v = MenuSizeDefault;
+
+ *value = v;
+ }
+};
+
+/**
+ * Returns the child widget for the frame (the centralWidget in qt terms)
+ */
+QWidget *frameChildWidget( JNIEnv *env, jobject component )
+{
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ assert( frameCls );
+ jmethodID getPeerMID = env->GetMethodID( frameCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+ jobject framepeerobj = env->CallObjectMethod( component, getPeerMID, 0);
+
+ QMainWindow *window = (QMainWindow *)getNativeObject(env, framepeerobj);
+
+ return window->centralWidget();
+}
+
+/*
+ * Constructs a QMainWindow native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init
+(JNIEnv *env, jobject obj)
+{
+ MyWindow *frame = new MyWindow(env, obj);
+ assert( frame );
+
+ QWidget *central = new QWidget( frame );
+ assert( central );
+
+ frame->setCentralWidget( central );
+ setNativeObject( env, obj, frame );
+}
+
+/**
+ * Returns the menu bar height for insets.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_menuBarHeight
+(JNIEnv *env, jobject obj)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ int value = 0;
+ mainThread->postEventToMain( new FrameGetMenuHeightEvent( frame, &value ) );
+
+ while(value == 0); // (Busy) wait for the value to
+ // get set by the main thread.
+
+ return (jint)value;
+}
+
+/*
+ * set Menu bar.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMenu
+(JNIEnv *env, jobject obj, jobject mbPeer)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QMenuBar *menubar = NULL;
+
+ if( mbPeer != NULL )
+ {
+ menubar = (QMenuBar *) getNativeObject( env, mbPeer );
+ assert( menubar );
+ }
+
+ mainThread->postEventToMain( new FrameMenuEvent( frame, menubar ) );
+}
+
+
diff --git a/native/jni/qt-peer/qtgraphics.cpp b/native/jni/qt-peer/qtgraphics.cpp
new file mode 100644
index 000000000..f149c32ec
--- /dev/null
+++ b/native/jni/qt-peer/qtgraphics.cpp
@@ -0,0 +1,471 @@
+/* qtgraphics.cpp --
+ 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. */
+
+#include <jni.h>
+#include <QPainter>
+#include <QBrush>
+#include <QLinearGradient>
+#include <QPen>
+#include <QPaintDevice>
+#include <QPainterPath>
+#include <QImage>
+#include <QColor>
+#include <gnu_java_awt_peer_qt_QtGraphics.h>
+#include "nativewrapper.h"
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "qtgraphics.h"
+#include "qtfont.h"
+
+// Constants from java.awt.AlphaComposite
+#define CLEAR 1
+#define SRC 2
+#define DST 9
+#define SRC_OVER 3
+#define DST_OVER 4
+#define SRC_IN 5
+#define DST_IN 6
+#define SRC_OUT 7
+#define DST_OUT 8
+#define SRC_ATOP 10
+#define DST_ATOP 11
+#define XOR 12
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (GraphicsPainter *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject getToolkit( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtGraphics" );
+
+ jfieldID field = env->GetFieldID( cls, "toolkit",
+ "Lgnu/java/awt/peer/qt/QtToolkit;" );
+ return env->GetObjectField( obj, field );
+}
+
+///////////////////////// JNI methods ////////////////////////////////
+
+/**
+ * Clones the parent QPainter object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_cloneNativeContext
+(JNIEnv *env, jobject obj, jobject parent)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, parent );
+ assert( painter );
+ QPainter *newPainter = new GraphicsPainter( painter->device() );
+ assert( newPainter );
+ setNativePtr(env, obj, newPainter);
+}
+
+/*
+ * Start of JNI methods
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initImage
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QImage *im = getQtImage( env, image );
+ QPainter *painter = new GraphicsPainter( im );
+ assert( painter );
+ setNativePtr(env, obj, painter);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete
+(JNIEnv *env, jobject obj)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ setNativePtr( env, obj, NULL );
+ if( painter )
+ {
+ if( painter->isActive() )
+ painter->end();
+ delete painter;
+ }
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_dispose
+(JNIEnv *env, jobject obj)
+{
+// GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+// setNativePtr( env, obj, NULL );
+// if( painter )
+// {
+// if( painter->isActive() )
+// painter->end();
+// delete painter;
+// }
+}
+
+///////////////////////////////////////////////////////////
+/*
+ * Sets the clip to a path.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp );
+}
+
+/*
+ * Sets the clip to a rectangle.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h );
+}
+
+/*
+ * Intersects a shape with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp, Qt::IntersectClip );
+}
+
+/*
+ * Intersect a rectangle with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h, Qt::IntersectClip );
+}
+
+/*
+ * Returns a QPainterPath object with the clip path of this painter.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipNative
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ jclass cls = env->FindClass("gnu/java/awt/peer/qt/QPainterPath");
+ jmethodID method = env->GetMethodID(cls, "<init>", "()V");
+
+ jobject ppo = env->NewObject(cls, method);
+ QPainterPath qpp = painter->clipPath();
+ setNativeObject(env, ppo, &qpp);
+
+ env->DeleteLocalRef( cls );
+ return ppo;
+}
+
+/*
+ * Returns a Rectangle with the bounds of this painters clip path.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipBounds
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+
+ qreal x, y, w, h;
+ painter->clipPath().boundingRect().getRect(&x, &y, &w, &h);
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ assert( cls != NULL);
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ assert( mid != NULL);
+ jvalue values[4];
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+///////////////////////// Color stuff ////////////////////////
+/**
+ *
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setColor
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jint alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ painter->currentPen->setColor( QColor(r, g, b, alpha) );
+ painter->setPen( *painter->currentPen );
+ painter->currentBrush = new QBrush( QColor(r, g, b, alpha) );
+ painter->setBrush( *painter->currentBrush );
+ painter->currentColor = new QColor(r, g, b, alpha);
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setAlphaNative
+ (JNIEnv *env, jobject obj, jdouble alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+
+ QColor c = painter->currentPen->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentPen->setColor(c);
+
+ c = painter->currentBrush->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentBrush->setColor( c );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: drawNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setPen( *painter->currentPen );
+ painter->setBrush( Qt::NoBrush );
+ painter->drawPath( *pp );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: fillNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fillNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush( *painter->currentBrush );
+ painter->drawPath( *pp );
+}
+
+/**
+ * Draws a string.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawStringNative
+(JNIEnv *env, jobject obj, jstring str, jdouble x, jdouble y)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QString *qStr = getQString(env, str);
+ painter->setBrush( Qt::NoBrush );
+ painter->setPen( *painter->currentPen );
+ painter->drawText(QPointF( (qreal)x, (qreal)y ), *qStr);
+ delete qStr;
+}
+
+/*
+ * Sets the native stroke
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeStroke
+(JNIEnv *env, jobject obj, jobject stroke)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPen *pen = (QPen *)getNativeObject(env, stroke);
+ assert( pen );
+ painter->currentPen = new QPen( *pen );
+ painter->setPen( *painter->currentPen );
+}
+
+/*
+ * Sets the transform
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setQtTransform
+(JNIEnv *env, jobject obj, jobject matrix)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QMatrix *m = (QMatrix *)getNativeObject( env, matrix );
+ assert( m );
+ painter->setMatrix( *m );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+ painter->setFont( *font );
+}
+
+/*
+ * Sets Porter-Duff compositing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeComposite
+(JNIEnv *env, jobject obj, jint compositeMode)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainter::CompositionMode mode;
+
+ switch( compositeMode )
+ {
+ case CLEAR:
+ mode = QPainter::CompositionMode_Clear;
+ break;
+ case SRC:
+ mode = QPainter::CompositionMode_Source;
+ break;
+ case DST:
+ mode = QPainter::CompositionMode_Destination;
+ break;
+ case SRC_OVER:
+ mode = QPainter::CompositionMode_SourceOver;
+ break;
+ case DST_OVER:
+ mode = QPainter::CompositionMode_DestinationOver;
+ break;
+ case SRC_IN:
+ mode = QPainter::CompositionMode_SourceIn;
+ break;
+ case DST_IN:
+ mode = QPainter::CompositionMode_DestinationIn;
+ break;
+ case SRC_OUT:
+ mode = QPainter::CompositionMode_SourceOut;
+ break;
+ case DST_OUT:
+ mode = QPainter::CompositionMode_DestinationOut;
+ break;
+ case SRC_ATOP:
+ mode = QPainter::CompositionMode_SourceAtop;
+ break;
+ case DST_ATOP:
+ mode = QPainter::CompositionMode_DestinationAtop;
+ break;
+ case XOR:
+ mode = QPainter::CompositionMode_Xor;
+ break;
+ }
+ painter->setCompositionMode( mode );
+}
+
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getFontMetrics
+(JNIEnv *env, jobject obj, jobject font)
+{
+}
+
+/**
+ * Sets the current brush to a linear gradient.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setLinearGradient
+(JNIEnv *env, jobject obj, jint r1, jint g1, jint b1, jint r2, jint g2,
+jint b2, jdouble x1, jdouble y1, jdouble x2, jdouble y2, jboolean cyclic)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QLinearGradient *lg = new QLinearGradient(QPointF( (qreal)x1, (qreal)y1 ),
+ QPointF( (qreal)x2, (qreal)y2 ) );
+ lg->setColorAt( (qreal)0.0, QColor(r1, g1, b1) );
+ lg->setColorAt( (qreal)1.0, QColor(r2, g2, b2) );
+ if( cyclic == JNI_TRUE )
+ lg->setSpread( QGradient::ReflectSpread );
+ else
+ lg->setSpread( QGradient::PadSpread );
+ painter->currentBrush = new QBrush( *lg );
+ delete lg;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fill3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ painter->fillRect ( x, y, w, h, QBrush( *painter->currentColor) );
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_draw3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x, y, x + w, y );
+ painter->drawLine( x, y, x, y + h);
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
diff --git a/native/jni/qt-peer/qtgraphics.h b/native/jni/qt-peer/qtgraphics.h
new file mode 100644
index 000000000..5252897db
--- /dev/null
+++ b/native/jni/qt-peer/qtgraphics.h
@@ -0,0 +1,26 @@
+#ifndef QTGRAPHICS_H
+#define QTGRAPHICS_H
+
+#include <jni.h>
+#include <QPainter>
+#include <QPaintDevice>
+#include <QPen>
+#include <QBrush>
+
+class GraphicsPainter : public QPainter
+{
+public:
+ QPen *currentPen;
+ QBrush *currentBrush;
+ QColor *currentColor;
+ GraphicsPainter(QPaintDevice *dev) : QPainter( dev )
+ {
+ currentPen = new QPen();
+ currentBrush = new QBrush();
+ currentColor = new QColor();
+ }
+};
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/native/jni/qt-peer/qtimage.cpp b/native/jni/qt-peer/qtimage.cpp
new file mode 100644
index 000000000..2a86feac9
--- /dev/null
+++ b/native/jni/qt-peer/qtimage.cpp
@@ -0,0 +1,396 @@
+/* qtimage.cpp --
+ 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. */
+
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.h"
+
+/* The constant fields in java.awt.Image */
+#define SCALE_DEFAULT 1
+#define SCALE_FAST 2
+#define SCALE_SMOOTH 4
+#define SCALE_REPLICATE 8
+#define SCALE_AREA_AVERAGING 16
+
+QImage *getQtImage( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QImage *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QImage *image = new QImage ( width, height,
+ QImage::Format_ARGB32_Premultiplied );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ setNativePtr(env, obj, NULL);
+ if ( image )
+ delete image;
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ image->fill(0);
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = image->pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Sets the pixel data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_setPixels
+(JNIEnv *env, jobject obj, jintArray pixels)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+
+ int width, height;
+ jint *src_array, *src;
+
+ width = image->width();
+ height = image->height();
+
+ src = src_array =
+ env->GetIntArrayElements(pixels, NULL);
+
+ for(int i = 0 ; i < height; i++)
+ {
+ uchar *scanline = image->scanLine( i );
+ memcpy((void *)scanline, (void *)src, width * 4);
+ src += width;
+ }
+
+ env->ReleaseIntArrayElements(pixels, src_array, 0);
+}
+
+
+/*
+ * Loads an image from a file,
+ * returns true on success, false on failure.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImage
+(JNIEnv *env, jobject obj, jstring fn)
+{
+ QString *filename = getQString(env, fn);
+
+ QImage *image = new QImage();
+ bool retVal = image->load( *filename );
+ delete filename;
+
+ if(image->isNull() && !retVal)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+/*
+ * Creates the image from an array of java bytes.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImageFromData
+(JNIEnv *env, jobject obj, jbyteArray data)
+{
+ jbyte *src_array, *src;
+ bool retVal;
+
+ src = env->GetByteArrayElements(data, NULL);
+ int len = env->GetArrayLength( data );
+
+ QImage *image = new QImage();
+ retVal = image->loadFromData( (uchar *) src, len);
+ env->ReleaseByteArrayElements(data, src, 0);
+
+ if(image->isNull() || retVal == false)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QImage *image = getQtImage(env, src);
+ assert( image );
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * Simple draw without scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawImage ( QPoint(x, y), *image );
+}
+
+/*
+ * Draw the image with scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draws a transformed image.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+/**
+ * Draws the pixbuf at x, y, scaled to width and height and
+ * optionally composited and/or flipped with a given background color.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jboolean flipx, jboolean flipy,
+ jint srcx, jint srcy, jint srcwidth, jint srcheight,
+ jint dstx, jint dsty, jint dstwidth, jint dstheight,
+ jboolean composite)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ QImage image = originalImage->mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QImage area = image->copy(x, y, w, h);
+ QPainter *p = new QPainter( image );
+ p->drawImage( x + dx, y + dy, area );
+ delete p;
+}
diff --git a/native/jni/qt-peer/qtimage.h b/native/jni/qt-peer/qtimage.h
new file mode 100644
index 000000000..2aeb34207
--- /dev/null
+++ b/native/jni/qt-peer/qtimage.h
@@ -0,0 +1,8 @@
+#ifndef QTIMAGE_H
+#define QTIMAGE_H
+
+#include <QImage>
+
+QImage *getQtImage( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/native/jni/qt-peer/qtlabelpeer.cpp b/native/jni/qt-peer/qtlabelpeer.cpp
new file mode 100644
index 000000000..1ff376a04
--- /dev/null
+++ b/native/jni/qt-peer/qtlabelpeer.cpp
@@ -0,0 +1,152 @@
+/* qtlabelpeer.cpp --
+ 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. */
+
+#include <QLabel>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtLabelPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "keybindings.h"
+
+// java.awt.Label justification fields
+#define LEFT 0
+#define CENTER 1
+#define RIGHT 2
+
+class MyLabel : public QLabel
+{
+public:
+ MyLabel(JNIEnv *env, jobject obj, QWidget *parent) : QLabel( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyLabel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QLabel
+#include "eventmethods.cpp"
+};
+
+class LabelTitle : public AWTEvent {
+
+ private:
+ QLabel *widget;
+ QString *string;
+ Qt::Alignment alignment;
+
+ public:
+ LabelTitle(QLabel *w, QString *s, Qt::Alignment a) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ alignment = a;
+ }
+
+ void runEvent()
+ {
+ if( string != NULL)
+ {
+ widget->setText( *string );
+ delete string;
+ }
+ else
+ {
+ widget->setAlignment( alignment );
+ }
+ }
+};
+
+/*
+ * Init a QLabel
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ // QLabel *label = new QLabel( parentWidget );
+ QLabel *label = new MyLabel( env, obj, parentWidget );
+ assert( label );
+ setNativeObject( env, obj, label );
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new LabelTitle( label, qStr, 0 ) );
+}
+
+/*
+ * Sets the alignment
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setAlignment
+(JNIEnv *env, jobject obj, jint align)
+{
+ Qt::Alignment alignment = Qt::AlignVCenter;
+
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ switch(align)
+ {
+ case LEFT:
+ alignment |= Qt::AlignLeft;
+ break;
+
+ case RIGHT:
+ alignment |= Qt::AlignRight;
+ break;
+
+ default:
+ case CENTER:
+ alignment |= Qt::AlignHCenter;
+ break;
+ }
+
+ mainThread->postEventToMain( new LabelTitle( label, NULL, alignment ) );
+}
diff --git a/native/jni/qt-peer/qtlistpeer.cpp b/native/jni/qt-peer/qtlistpeer.cpp
new file mode 100644
index 000000000..a5d8bff4e
--- /dev/null
+++ b/native/jni/qt-peer/qtlistpeer.cpp
@@ -0,0 +1,207 @@
+/* qtlistpeer.cpp --
+ 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. */
+
+#include <QWidget>
+#include <QListWidget>
+#include <gnu_java_awt_peer_qt_QtListPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class ListInsert : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ QString *string;
+ int index;
+
+ public:
+ ListInsert(QListWidget *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class SelectEvent : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int index;
+ bool selected;
+
+ public:
+ SelectEvent(QListWidget *w, int i, bool s) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ selected = s;
+ }
+
+ void runEvent()
+ {
+ widget->setItemSelected ( widget->item(index), selected );
+ }
+};
+
+class ListDelete : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int startIndex, endIndex;
+
+ public:
+ ListDelete(QListWidget *w, int starti, int endi) : AWTEvent()
+ {
+ widget = w;
+ startIndex = starti;
+ endIndex = endi;
+ }
+
+ void runEvent()
+ {
+ for (int i = endIndex; i >= startIndex; i--)
+ delete widget->takeItem(i);
+ }
+};
+
+/*
+ * Construct a QListWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QListWidget *list = new QListWidget( parentWidget );
+ assert( list );
+
+ setNativeObject( env, obj, list );
+}
+
+/*
+ * Adds an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_add
+(JNIEnv *env, jobject obj, jstring str, jint index)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new ListInsert(list, qStr, index) );
+}
+
+/*
+ * Delete items
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_delItems
+(JNIEnv *env, jobject obj, jint startindex, jint endindex)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ mainThread->postEventToMain( new ListDelete(list, startindex, endindex) );
+}
+
+/*
+ * (De)select an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_select
+(JNIEnv *env, jobject obj, jint index, jboolean sel)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ mainThread->postEventToMain( new SelectEvent(list, index,
+ (sel == JNI_TRUE)) );
+}
+
+/**
+ * Returns the indices of the selected items.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_getSelectedIndexes
+ (JNIEnv *env, jobject obj)
+{
+ jintArray retArray;
+ jint *arr;
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ QList<QListWidgetItem *> items = list->selectedItems();
+ retArray = env->NewIntArray( items.count() );
+ arr = env->GetIntArrayElements( retArray, NULL );
+
+ for(int i = 0; i < items.count(); i++)
+ arr[i] = list->row(items.at(i));
+
+ env->ReleaseIntArrayElements( retArray, arr, 0 );
+ return retArray;
+}
+
+/*
+ * Sets the current item and makes it visible.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_makeVisible
+ (JNIEnv *env, jobject obj, jint index)
+{
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ list->scrollToItem( list->item(index) );
+}
+
+/*
+ * Set multiple selection mode.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_setMultipleMode
+(JNIEnv *env, jobject obj, jboolean allow)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ // FIXME: Multiple selection is buggy in Qt4. Workaround needed.
+ list->setSelectionMode( ((allow == JNI_TRUE) ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection) );
+}
+
diff --git a/native/jni/qt-peer/qtmenubarpeer.cpp b/native/jni/qt-peer/qtmenubarpeer.cpp
new file mode 100644
index 000000000..ae62c8dd0
--- /dev/null
+++ b/native/jni/qt-peer/qtmenubarpeer.cpp
@@ -0,0 +1,149 @@
+/* qtmenubarpeer.cpp --
+ 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. */
+
+#include <QMenuBar>
+#include <QToolBar>
+#include <QMenu>
+#include <QList>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuBarPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+/*
+ * Event wrapper to add a menu to a menu bar
+ */
+class MenuBarAdd : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+ bool isHelp;
+
+ public:
+ MenuBarAdd(QMenuBar *w, QMenu *m, bool help) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ isHelp = help;
+ }
+
+ void runEvent()
+ {
+ if ( isHelp )
+ widget->addSeparator();
+ QAction *ptr = widget->addMenu( menu );
+ }
+};
+
+/**
+ * Event wrapper to remove a menu from a menu bar.
+ */
+class MenuBarRemove : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+
+ public:
+ MenuBarRemove(QMenuBar *w, QMenu *m) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ }
+
+ void runEvent()
+ {
+ // FIXME
+ }
+};
+
+
+/*
+ * Constructs a QMenuBar object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_init
+ (JNIEnv *env, jobject obj)
+{
+ QMenuBar *menubar = new QMenuBar();
+ assert( menubar );
+ setNativeObject( env, obj, menubar );
+}
+
+/*
+ * Adds a menu item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, false ) );
+}
+
+/*
+ * Add a help menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addHelpMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, true ) );
+}
+
+/*
+ * Delete a menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_delMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ // FIXME
+
+}
+
diff --git a/native/jni/qt-peer/qtmenucomponentpeer.cpp b/native/jni/qt-peer/qtmenucomponentpeer.cpp
new file mode 100644
index 000000000..68388fc82
--- /dev/null
+++ b/native/jni/qt-peer/qtmenucomponentpeer.cpp
@@ -0,0 +1,66 @@
+/* qtmenucomponentpeer.cpp --
+ 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. */
+
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtMenuComponentPeer.h>
+#include "nativewrapper.h"
+#include "componentevent.h"
+
+
+/**
+ * Calls back init() from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+ // wait for the thing to be created.
+ while(getNativeObject(env, obj) == 0);
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+}
diff --git a/native/jni/qt-peer/qtmenuitempeer.cpp b/native/jni/qt-peer/qtmenuitempeer.cpp
new file mode 100644
index 000000000..b5dba0393
--- /dev/null
+++ b/native/jni/qt-peer/qtmenuitempeer.cpp
@@ -0,0 +1,181 @@
+/* qtmenuitempeer.cpp --
+ 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. */
+
+#include <QMenu>
+#include <QAction>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuItemPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class MenuItemDestroyEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+
+ public:
+ MenuItemDestroyEvent(QAction *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ delete widget;
+ }
+};
+
+class MenuItemLabelEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ QString *string;
+
+ public:
+ MenuItemLabelEvent(QAction *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+class MenuItemStatusEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ bool enabled;
+ bool value;
+
+ public:
+ MenuItemStatusEvent(QAction *w, bool e, bool v) : AWTEvent()
+ {
+ widget = w;
+ enabled = e;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( enabled )
+ widget->setEnabled( value );
+ else
+ widget->setChecked( value );
+ }
+};
+
+/*
+ * Creates a QAction object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_create
+(JNIEnv *env, jobject obj, jstring label, jboolean isSeperator, jboolean isCheckable)
+{
+ QAction *action;
+ if(label == NULL || isSeperator == JNI_TRUE)
+ {
+ action = new QAction(NULL);
+ action->setSeparator(true);
+ assert( action );
+ }
+ else
+ {
+ QString *qStr = getQString(env, label);
+ action = new QAction(*qStr, NULL);
+ delete qStr;
+ assert( action );
+ action->setCheckable( (isCheckable == JNI_TRUE) );
+ }
+
+ setNativeObject( env, obj, action );
+}
+
+/**
+ * Disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain( new MenuItemDestroyEvent( action ) );
+}
+
+/*
+ * Enables/disables the item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, true,
+ (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the item label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuItemLabelEvent( action, qStr ) );
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, false,
+ (state == JNI_TRUE)));
+}
+
+
+
diff --git a/native/jni/qt-peer/qtmenupeer.cpp b/native/jni/qt-peer/qtmenupeer.cpp
new file mode 100644
index 000000000..e498bbe21
--- /dev/null
+++ b/native/jni/qt-peer/qtmenupeer.cpp
@@ -0,0 +1,259 @@
+/* qtmenupeer.cpp --
+ 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. */
+
+#include <QMenu>
+#include <gnu_java_awt_peer_qt_QtMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+#include "componentevent.h"
+
+#define ADDMENU 0
+#define ADDITEM 1
+#define ADDSEPA 2
+
+// Sets the title, but also tear-off.
+class MenuTitleEvent : public AWTEvent {
+
+ private:
+ QMenu *widget;
+ QString *string;
+ bool tearOff;
+
+ public:
+ MenuTitleEvent(QMenu *w, QString *s, bool tear) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ tearOff = tear;
+ }
+
+ void runEvent()
+ {
+ if (tearOff)
+ widget->setTearOffEnabled( true );
+ else
+ {
+ widget->setTitle( *string );
+ delete string;
+ }
+ }
+};
+
+class MenuAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+ int isMenu; // 0 to add a menu, 1 to add an item, 2 to add a seperator
+ QAction **newAction; // adding an action creates a new duplicate.
+
+public:
+ MenuAction(QMenu *m, QAction *a, QAction **na, bool ismenu) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ isMenu = ismenu;
+ newAction = na;
+ }
+
+ void runEvent()
+ {
+ switch(isMenu)
+ {
+ case ADDMENU:
+ *newAction = menu->addMenu( (QMenu *)action );
+ break;
+ case ADDITEM:
+ *newAction = menu->addAction(action->text());
+ (*newAction)->setSeparator(action->isSeparator());
+ (*newAction)->setCheckable(action->isCheckable());
+ delete action;
+ break;
+ case ADDSEPA:
+ *newAction = menu->addSeparator();
+ break;
+ }
+ }
+};
+
+class MenuRemoveAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+
+public:
+ MenuRemoveAction(QMenu *m, QAction *a) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ }
+
+ void runEvent()
+ {
+ if (action)
+ menu->removeAction(action);
+ }
+};
+
+/*
+ * Constructs a QMenu item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = new QMenu();
+ assert( menu );
+
+ setNativeObject( env, obj, menu );
+}
+
+/**
+ * Allows tear-off: Only called once, if ever.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_allowTearOff
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new MenuTitleEvent( menu, NULL, true ) );
+}
+
+/*
+ * Inserts a seperator.
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertSeperator
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QAction *newAction = NULL;
+ MenuAction *ma = new MenuAction( menu, NULL, &newAction, ADDSEPA );
+
+ while (newAction == NULL); // Wait for new action.
+
+ return (jlong)newAction;
+}
+
+/*
+ * Inserts an item.
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertItem
+(JNIEnv *env, jobject obj, jobject item)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QAction *action = (QAction *)getNativeObject( env, item );
+ assert( action );
+
+ QAction *newAction = NULL;
+ MenuAction *ma = new MenuAction( menu, action, &newAction, ADDITEM );
+ mainThread->postEventToMain( ma );
+
+ while (newAction == NULL); // Wait for new action.
+
+ connectAction(newAction, env, item);
+ setNativeObject(env, item, newAction); // update the MenuItemPeer action.
+
+ return (jlong)newAction;
+}
+
+/*
+ * Inserts a sub-menu
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertMenu
+(JNIEnv *env, jobject obj, jobject menu)
+{
+ assert( menu );
+ QMenu *thisMenu = (QMenu *)getNativeObject( env, obj );
+ assert( thisMenu );
+ QMenu *insMenu = (QMenu *)getNativeObject(env, menu);
+ assert( insMenu );
+
+ QAction *newAction = NULL;
+ MenuAction *ma = new MenuAction( thisMenu, (QAction *)insMenu,
+ &newAction, ADDMENU );
+ mainThread->postEventToMain( ma );
+
+ while (newAction == NULL); // Wait for new action.
+
+ connectAction(newAction, env, menu);
+ return (jlong) newAction;
+}
+
+/*
+ * Removes an item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_delItem
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QAction *action = (QAction *)ptr;
+
+ mainThread->postEventToMain( new MenuRemoveAction( menu, action ) );
+}
+
+/*
+ * Enables/Disables the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+
+ mainThread->postEventToMain(new AWTEnableEvent(menu, (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the menu title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ if(label == NULL)
+ return;
+
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuTitleEvent( menu, qStr, false ) );
+}
+
diff --git a/native/jni/qt-peer/qtpanelpeer.cpp b/native/jni/qt-peer/qtpanelpeer.cpp
new file mode 100644
index 000000000..d9c1ed573
--- /dev/null
+++ b/native/jni/qt-peer/qtpanelpeer.cpp
@@ -0,0 +1,73 @@
+/* qtpanelpeer.cpp --
+ 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. */
+
+#include <qwidget.h>
+#include <gnu_java_awt_peer_qt_QtPanelPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyPanel : public QWidget
+{
+public:
+ MyPanel(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.cpp"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPanelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *canvas = new MyPanel( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
+
+
diff --git a/native/jni/qt-peer/qtpopupmenupeer.cpp b/native/jni/qt-peer/qtpopupmenupeer.cpp
new file mode 100644
index 000000000..a25492e18
--- /dev/null
+++ b/native/jni/qt-peer/qtpopupmenupeer.cpp
@@ -0,0 +1,75 @@
+/* qtpopupmenupeer.cpp --
+ 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. */
+
+#include <QMenu>
+#include <QPoint>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtPopupMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class PopupMenuShowEvent : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ int x, y;
+
+ public:
+ PopupMenuShowEvent(QMenu *m, int x0, int y0) : AWTEvent()
+ {
+ menu = m;
+ x = x0;
+ y = y0;
+ }
+
+ void runEvent()
+ {
+ menu->exec( QPoint( x, y ) );
+ }
+};
+
+/*
+ * Shows the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPopupMenuPeer_showNative
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new PopupMenuShowEvent(menu, x, y ) );
+}
diff --git a/native/jni/qt-peer/qtscreendevice.cpp b/native/jni/qt-peer/qtscreendevice.cpp
new file mode 100644
index 000000000..91217cbba
--- /dev/null
+++ b/native/jni/qt-peer/qtscreendevice.cpp
@@ -0,0 +1,122 @@
+/* qtscreendevice.cpp --
+ 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. */
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <gnu_java_awt_peer_qt_QtScreenDevice.h>
+#include "nativewrapper.h"
+
+extern QApplication *qApplication;
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_init
+(JNIEnv *env, jobject obj, jint id)
+{
+ QWidget *widget = qApplication->desktop()->screen( id );
+ assert( widget );
+ setNativeObject(env, obj, widget);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ setNativeObject(env, obj, NULL);
+ if( widget )
+ delete widget;
+}
+
+/*
+ * Returns the bounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getBounds
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ widget->geometry().getRect( &x, &y, &w, &h );
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns the X DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiX
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiX();
+}
+
+/*
+ * Returns the Y DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiY
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiY();
+}
+
+/*
+ * Returns the bitplane depth
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_depth
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->depth();
+}
+
diff --git a/native/jni/qt-peer/qtscrollbarpeer.cpp b/native/jni/qt-peer/qtscrollbarpeer.cpp
new file mode 100644
index 000000000..af87b4968
--- /dev/null
+++ b/native/jni/qt-peer/qtscrollbarpeer.cpp
@@ -0,0 +1,141 @@
+/* qtscrollbarpeer.cpp --
+ 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. */
+
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollbarPeer.h>
+#include "keybindings.h"
+#include "slotcallbacks.h"
+#include "qtcomponent.h"
+
+// Constant fields from java.awt.Scrollbar
+#define HORIZONTAL 0
+#define VERTICAL 1
+
+class MyScrollBar : public QScrollBar
+{
+public:
+ MyScrollBar(JNIEnv *env, jobject obj, QWidget *parent) : QScrollBar( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollBar()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollBar
+#include "eventmethods.cpp"
+};
+
+/*
+ * Construct a QScrollbar object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollBar *scrollbar = new QScrollBar( parentWidget );
+ MyScrollBar *scrollbar = new MyScrollBar( env, obj, parentWidget );
+ assert( scrollbar );
+
+ setNativeObject( env, obj, scrollbar );
+ connectScrollBar(scrollbar, env, obj);
+}
+
+/*
+ * Set the line increment.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setLineIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setSingleStep(inc);
+}
+
+/**
+ * Sets the orientation of the scrollbar
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setOrientation
+(JNIEnv *env, jobject obj, jint orientation)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ switch(orientation)
+ {
+ case HORIZONTAL:
+ bar->setOrientation ( Qt::Horizontal );
+ break;
+
+ default:
+ case VERTICAL:
+ bar->setOrientation ( Qt::Vertical );
+ break;
+ }
+}
+
+/**
+ * Sets the page increment (equivalent to slider size)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setPageIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setPageStep( inc );
+}
+
+/*
+ * Setvalues.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues
+(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setValue(value);
+ bar->setPageStep( visible ); // page step and slider size are the same in Qt
+ bar->setRange( min , max );
+}
+
diff --git a/native/jni/qt-peer/qtscrollpanepeer.cpp b/native/jni/qt-peer/qtscrollpanepeer.cpp
new file mode 100644
index 000000000..b10c44b06
--- /dev/null
+++ b/native/jni/qt-peer/qtscrollpanepeer.cpp
@@ -0,0 +1,211 @@
+/* qtscrollpanepeer.cpp --
+ 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. */
+
+#include <QScrollArea>
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollPanePeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "keybindings.h"
+
+// Constants in java.awt.ScrollPane
+#define SCROLLBARS_AS_NEEDED 0
+#define SCROLLBARS_ALWAYS 1
+#define SCROLLBARS_NEVER 2
+
+
+class MyScrollArea : public QScrollArea
+{
+public:
+ MyScrollArea(JNIEnv *env, jobject obj, QWidget *parent) : QScrollArea( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollArea()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollArea
+#include "eventmethods.cpp"
+};
+
+
+class ScrollPanePolicy : public AWTEvent {
+
+ private:
+ QScrollArea *widget;
+ Qt::ScrollBarPolicy policy;
+
+ public:
+ ScrollPanePolicy(QScrollArea *w, Qt::ScrollBarPolicy p) : AWTEvent()
+ {
+ widget = w;
+ policy = p;
+ }
+
+ void runEvent()
+ {
+ widget->setHorizontalScrollBarPolicy(policy);
+ widget->setVerticalScrollBarPolicy(policy);
+ }
+};
+
+/**
+ * Returns the child widget, given the owner Component.
+ */
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component )
+{
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ jmethodID getPeerMID = env->GetMethodID( scrollpaneCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+ assert(getPeerMID != 0);
+ jobject scrollpanepeerobj = env->CallObjectMethod( component, getPeerMID, NULL );
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, scrollpanepeerobj );
+ assert(view != 0);
+ return view->viewport();
+}
+
+/*
+ * Creates a QScrollArea object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollArea *pane = new MyScrollArea( env, obj, parentWidget );
+ QScrollArea *pane = new QScrollArea( parentWidget );
+ assert( pane );
+ setNativeObject( env, obj, pane );
+}
+
+/*
+ * Resize the child.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized
+(JNIEnv *env, jobject obj, jint w, jint h)
+{
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, obj );
+ assert( view );
+
+ QWidget *child = view->viewport();
+ assert( child );
+ mainThread->postEventToMain( new AWTResizeEvent(child, 0, 0, w, h) );
+}
+
+/*
+ * Returns the horizontal scrollbar height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getHScrollbarHeight
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *hbar = pane->horizontalScrollBar();
+ if(hbar == NULL)
+ return 0;
+ if(!hbar->isVisible())
+ return 0;
+ int height = hbar->height();
+
+ return height;
+}
+
+/*
+ * Returns the vertical scrollbar width.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getVScrollbarWidth
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *vbar = pane->verticalScrollBar();
+ if(vbar == NULL)
+ return 0;
+ if(!vbar->isVisible())
+ return 0;
+ int width = vbar->width();
+
+ return width;
+}
+
+/*
+ * Sets the current upper-left corner to x, y.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setScrollPosition
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ // pane->scrollContentsBy( x, y );
+}
+
+/*
+ * Sets the scrollbar policy
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setPolicy
+(JNIEnv *env, jobject obj, jint policy)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+
+ Qt::ScrollBarPolicy qtpolicy;
+ switch( policy )
+ {
+ case SCROLLBARS_ALWAYS:
+ qtpolicy = Qt::ScrollBarAlwaysOn;
+ break;
+
+ case SCROLLBARS_NEVER:
+ qtpolicy = Qt::ScrollBarAlwaysOff;
+ break;
+
+ default:
+ case SCROLLBARS_AS_NEEDED:
+ qtpolicy = Qt::ScrollBarAsNeeded;
+ break;
+ }
+
+ mainThread->postEventToMain( new ScrollPanePolicy( pane, qtpolicy ) );
+}
+
diff --git a/native/jni/qt-peer/qtstrings.cpp b/native/jni/qt-peer/qtstrings.cpp
new file mode 100644
index 000000000..c343c6331
--- /dev/null
+++ b/native/jni/qt-peer/qtstrings.cpp
@@ -0,0 +1,54 @@
+/* qtstrings.cpp --
+ 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. */
+
+#include "qtstrings.h"
+
+QString *getQString(JNIEnv *env, jstring str)
+{
+ QString qStr;
+ {
+ const char *chars = env->GetStringUTFChars( str, NULL );
+ qStr = QString::fromUtf8( chars, env->GetStringLength( str ) );
+ env->ReleaseStringUTFChars( str, chars );
+ }
+ return new QString(qStr);
+}
+
+jstring getJavaString(JNIEnv *env, QString *qstring)
+{
+ return env->NewStringUTF(qstring->toUtf8());
+}
diff --git a/native/jni/qt-peer/qtstrings.h b/native/jni/qt-peer/qtstrings.h
new file mode 100644
index 000000000..ba5ab8c99
--- /dev/null
+++ b/native/jni/qt-peer/qtstrings.h
@@ -0,0 +1,10 @@
+#ifndef QTSTRINGS_H
+#define QTSTRINGS_H
+
+#include <jni.h>
+#include <QString>
+
+QString *getQString(JNIEnv *env, jstring str);
+jstring getJavaString(JNIEnv *env, QString *qstring);
+
+#endif
diff --git a/native/jni/qt-peer/qttextareapeer.cpp b/native/jni/qt-peer/qttextareapeer.cpp
new file mode 100644
index 000000000..087640a94
--- /dev/null
+++ b/native/jni/qt-peer/qttextareapeer.cpp
@@ -0,0 +1,191 @@
+/* qttextareapeer.cpp --
+ 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. */
+
+#include <time.h>
+#include <QTextEdit>
+#include <QTextCursor>
+#include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+
+// FIXME: This stuff ain't thread safe.
+
+/*
+ * Construct a QTextEdit object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ QTextEdit *editor = new QTextEdit( parentWidget );
+ editor->setGeometry( 0, 0, 400, 400 );
+ assert( editor );
+
+ // setLineWrapColumnOrWidth ( int w );
+
+ setNativeObject( env, obj, editor );
+}
+
+/*
+ * Returns the cursor position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ int index;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ index = editor->textCursor().position();;
+
+ return (jint)index;
+}
+
+/*
+ * Returns the char index at a given screen point
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getIndexAtPoint
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QPoint *p = new QPoint(x,y);
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QTextCursor curs = editor->cursorForPosition( *p );
+ delete p;
+
+ return curs.position();
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean isStart)
+{
+ int start, end;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ start = editor->textCursor().selectionStart();
+ end = editor->textCursor().selectionEnd();
+
+ return ((isStart == JNI_TRUE) ? start : end);
+}
+
+/*
+ * Returns the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QString text = editor->toPlainText();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Inserts text.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_insert
+(JNIEnv *env, jobject obj, jstring str, jint index)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QTextCursor curs = editor->textCursor();
+ int oldPos = curs.position();
+ curs.setPosition( index );
+ QString *qStr = getQString(env, str);
+ curs.insertText( *qStr );
+ delete qStr;
+ curs.setPosition( oldPos );
+}
+
+/*
+ * Sets the editor text.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QString *qStr = getQString(env, str);
+ editor->setPlainText( *qStr );
+ delete qStr;
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_select
+(JNIEnv *env, jobject obj, jint startpos, jint endpos)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ // FIXME
+// QTextCursor curs = editor->textCursor();
+// editor->setSelection ( 0, startpos, 0, endpos );
+}
+
+/*
+ * Allow or disallow editing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean editable)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ editor->setReadOnly( (editable != JNI_TRUE) );
+}
+
+/*
+ * Sets the cursor position
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint index)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ editor->textCursor().setPosition( index );
+}
diff --git a/native/jni/qt-peer/qttextfieldpeer.cpp b/native/jni/qt-peer/qttextfieldpeer.cpp
new file mode 100644
index 000000000..8ff944cec
--- /dev/null
+++ b/native/jni/qt-peer/qttextfieldpeer.cpp
@@ -0,0 +1,287 @@
+/* qttextfieldpeer.cpp --
+ 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. */
+
+#include <QLineEdit>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtTextFieldPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class TFEchoChar : public AWTEvent {
+ private:
+ QLineEdit *line;
+ jchar c;
+
+ public:
+ TFEchoChar(QLineEdit *w, jchar ch) : AWTEvent()
+ {
+ line = w;
+ c = ch;
+ }
+
+ void runEvent()
+ {
+ line->setEchoMode( (c) ? QLineEdit::Password : QLineEdit::Normal );
+ }
+};
+
+class TFEditable : public AWTEvent {
+ private:
+ QLineEdit *line;
+ bool editable;
+
+ public:
+ TFEditable(QLineEdit *w, bool e) : AWTEvent()
+ {
+ line = w;
+ editable = e;
+ }
+
+ void runEvent()
+ {
+ line->setReadOnly( editable );
+ }
+};
+
+class TFSetText : public AWTEvent {
+ private:
+ QLineEdit *line;
+ QString *text;
+
+ public:
+ TFSetText(QLineEdit *w, QString *t) : AWTEvent()
+ {
+ line = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ line->setText( *text );
+ delete text;
+ }
+};
+
+class TFSetCursorPos : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int pos;
+
+ public:
+ TFSetCursorPos(QLineEdit *w, int p) : AWTEvent()
+ {
+ line = w;
+ pos = p;
+ }
+
+ void runEvent()
+ {
+ line->setCursorPosition(pos);
+ }
+};
+
+class TFSelect : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int start,end;
+
+ public:
+ TFSelect(QLineEdit *w, int s, int e) : AWTEvent()
+ {
+ line = w;
+ start = s;
+ end = e;
+ }
+
+ void runEvent()
+ {
+ line->setSelection(start, end - start);
+ }
+};
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QLineEdit *line = new QLineEdit( parentWidget );
+ assert( line );
+
+ setNativeObject( env, obj, line );
+}
+
+
+/*
+ * Sets the echo char.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEchoChar
+(JNIEnv *env, jobject obj, jchar echo)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFEchoChar( line, echo ) );
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getMinimumSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ // FIXME does this work?
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->minimumSizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getPreferredSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->sizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean edit)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFEditable( line, (edit != JNI_TRUE) ) );
+}
+
+/*
+ * Gets the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ QString text = line->text();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setText
+(JNIEnv *env, jobject obj, jstring text)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ QString *qStr = getQString(env, text);
+ mainThread->postEventToMain( new TFSetText( line, qStr ) );
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean start)
+{
+ int index, length;
+
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ index = line->selectionStart();
+
+ if(start == JNI_TRUE)
+ return index;
+
+ length = (line->selectedText()).length();
+
+ return index + length;
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_select
+(JNIEnv *env, jobject obj, jint start, jint end)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFSelect( line, start, end ) );
+}
+
+/*
+ * Sets the cursor position.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint pos)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFSetCursorPos( line, (int)pos ) );
+}
+
+/*
+ * Returns the caret position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ return line->cursorPosition();
+}
+
diff --git a/native/jni/qt-peer/qttoolkit.cpp b/native/jni/qt-peer/qttoolkit.cpp
new file mode 100644
index 000000000..222b32344
--- /dev/null
+++ b/native/jni/qt-peer/qttoolkit.cpp
@@ -0,0 +1,156 @@
+/* qttoolkit.cpp --
+ 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. */
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QString>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtToolkit.h>
+#include "qtcomponent.h"
+#include "mainthreadinterface.h"
+#include "qtstrings.h"
+
+extern QApplication *qApplication;
+
+/**
+ * Calls syncX();
+ */
+class AWTSyncEvent : public AWTEvent {
+
+ private:
+ QApplication *application;
+
+ public:
+ AWTSyncEvent(QApplication *app) : AWTEvent()
+ {
+ application = app;
+ }
+
+ void runEvent()
+ {
+ application->syncX();
+ }
+};
+
+/*
+ * Causes your machine to beep. Wow.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_beep
+(JNIEnv *env, jobject obj)
+{
+ qApplication->beep();
+}
+
+/**
+ * Returns the # of the default screen.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_defaultScreen
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->primaryScreen();
+}
+
+/**
+ * Returns the # of screens.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_numScreens
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->numScreens();
+}
+
+/*
+ * Returns the screen size.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = QApplication::desktop();
+ QSize s = d->size();
+ return makeDimension( env, &s );
+}
+
+/*
+ * Returns the available fonts
+ */
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_nativeFontFamilies
+(JNIEnv *env, jobject obj)
+{
+ jobjectArray result_array;
+ jobject *result_array_ptr;
+ QFontDatabase db;
+ QStringList fonts = db.families();
+
+ result_array = env->NewObjectArray(fonts.size(),
+ env->FindClass("java/lang/String"),
+ env->NewStringUTF(""));
+ for (int i = 0; i < fonts.size(); i++)
+ {
+ QString qstr = fonts.at(i);
+ jstring jstr = getJavaString(env, &qstr);
+ env->SetObjectArrayElement( result_array, i, jstr );
+ }
+ return result_array;
+}
+
+
+/*
+ * Returns the screen resolution
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenResolution
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = qApplication->desktop();
+
+ // Java assumes square pixels. Qt, more intelligently, does not.
+ // What to do? Well.. Average them?
+ // FIXME: Weird values?
+ int dpi = (d->logicalDpiX() + d->logicalDpiY()) >> 1;
+
+ return (jint)dpi;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_sync
+(JNIEnv *env, jobject obj)
+{
+ // SyncX needs to be called from the main thread.
+ mainThread->postEventToMain( new AWTSyncEvent( qApplication ) );
+}
+
diff --git a/native/jni/qt-peer/qtvolatileimage.cpp b/native/jni/qt-peer/qtvolatileimage.cpp
new file mode 100644
index 000000000..1b618c4eb
--- /dev/null
+++ b/native/jni/qt-peer/qtvolatileimage.cpp
@@ -0,0 +1,296 @@
+/* qtvolatileimage.cpp --
+ 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. */
+
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtVolatileImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.h"
+
+/* The constant fields in java.awt.Image */
+#define SCALE_DEFAULT 1
+#define SCALE_FAST 2
+#define SCALE_SMOOTH 4
+#define SCALE_REPLICATE 8
+#define SCALE_AREA_AVERAGING 16
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ image->fill(0);
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = image->pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QImage *image = new QImage ( width, height,
+ QImage::Format_ARGB32_Premultiplied );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ if ( image )
+ delete image;
+ setNativePtr(env, obj, NULL);
+}
+
+/*
+ * Creates a scaled version.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QImage *image = getQtImage(env, src);
+ assert( image );
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * DrawPixels.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawImage ( QPoint(x, y), *image );
+}
+
+/*
+ * DrawPixels scaled.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draw pixels transformed.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+
+/**
+ * Draw pixels scaled and flipped
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jboolean flipx, jboolean flipy,
+ jint srcx, jint srcy, jint srcwidth, jint srcheight,
+ jint dstx, jint dsty, jint dstwidth, jint dstheight,
+ jboolean composite)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ QImage image = originalImage->mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QImage area = image->copy(x, y, w, h);
+ QPainter *p = new QPainter( image );
+ p->drawImage( x + dx, y + dy, area );
+ delete p;
+}
diff --git a/native/jni/qt-peer/qtwindowpeer.cpp b/native/jni/qt-peer/qtwindowpeer.cpp
new file mode 100644
index 000000000..915c7ce94
--- /dev/null
+++ b/native/jni/qt-peer/qtwindowpeer.cpp
@@ -0,0 +1,146 @@
+/* qtwindowpeer.cpp --
+ 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. */
+
+#include <QWidget>
+#include <qstyle.h>
+#include <gnu_java_awt_peer_qt_QtWindowPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+
+class RaiseLower : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool raise;
+
+ public:
+ RaiseLower(QWidget *w, bool r) : AWTEvent()
+ {
+ widget = w;
+ raise = r;
+ }
+
+ void runEvent()
+ {
+ if (raise)
+ widget->raise();
+ else
+ widget->lower();
+ }
+};
+
+class FrameTitleEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QString *string;
+
+ public:
+ FrameTitleEvent(QWidget *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setWindowTitle( *string );
+ delete string;
+ }
+};
+
+/*
+ * Constructs a top-level QWidget native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = new QWidget(0, (Qt::Window | Qt::FramelessWindowHint) );
+ assert( window );
+ // Qt::WStyle_StaysOnTop
+ setNativeObject( env, obj, window );
+}
+
+/*
+ * Destructor
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_destroy
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+
+ setNativeObject(env, obj, NULL);
+ delete window;
+}
+
+/*
+ * Lower the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toBack
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, false ) );
+}
+
+/*
+ * Raise the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toFront
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, true ) );
+}
+
+/*
+ * Title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_setTitle
+(JNIEnv *env, jobject obj, jstring string)
+{
+ QWidget *frame = (QWidget *) getNativeObject( env, obj );
+ assert( frame );
+ QString *qStr = getQString(env, string);
+ mainThread->postEventToMain( new FrameTitleEvent( frame, qStr ) );
+}
+
diff --git a/native/jni/qt-peer/slotcallbacks.cpp b/native/jni/qt-peer/slotcallbacks.cpp
new file mode 100644
index 000000000..38a22b16a
--- /dev/null
+++ b/native/jni/qt-peer/slotcallbacks.cpp
@@ -0,0 +1,199 @@
+/* slotcallbacks.cpp --
+ 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. */
+
+#include <QObject>
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QPushButton>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+// AdjustmentEvent constants
+#define UNIT_INCREMENT 1
+#define UNIT_DECREMENT 2
+#define BLOCK_DECREMENT 3
+#define BLOCK_INCREMENT 4
+#define TRACK 5
+
+
+class SlotCallback : public QObject {
+ Q_OBJECT;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+ jmethodID fireEventID;
+
+public:
+ QScrollBar *sb; // used only by the scrollbar method.
+
+ SlotCallback(JNIEnv *env, jobject t)
+ {
+ env->GetJavaVM(&vm);
+ target = t;
+ target = env->NewGlobalRef(t);
+ }
+
+ ~SlotCallback()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ }
+
+public slots:
+ void buttonClicked()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireClick",
+ "(I)V" );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void buttonToggled(bool checked)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireToggle",
+ "(Z)V" );
+ if(checked)
+ env->CallVoidMethod( target, fireEventID, JNI_TRUE );
+ else
+ env->CallVoidMethod( target, fireEventID, JNI_FALSE );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void choiceActivated( int index )
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireChoice",
+ "(I)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void scrollBarAction( int action )
+ {
+ JNIEnv *env;
+ int type;
+ int index;
+ switch(action)
+ {
+ case QAbstractSlider::SliderNoAction:
+ return;
+ case QAbstractSlider::SliderSingleStepAdd:
+ type = UNIT_INCREMENT;
+ break;
+ case QAbstractSlider::SliderSingleStepSub:
+ type = UNIT_DECREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepAdd:
+ type = BLOCK_INCREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepSub:
+ type = BLOCK_DECREMENT;
+ break;
+ case QAbstractSlider::SliderToMinimum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderToMaximum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderMove:
+ type = TRACK;
+ break;
+ }
+ index = sb->value();
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireMoved",
+ "(II)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+};
+
+#include "slotcallbacks.moc"
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)
+{
+ SlotCallback *scb = new SlotCallback(env, buttonobj);
+ QObject::connect( button, SIGNAL( clicked() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj)
+{
+ SlotCallback *scb = new SlotCallback(env, choiceobj);
+ QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );
+}
+
+void connectAction(QAction *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( triggered() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( toggled(bool) ), scb, SLOT( buttonToggled(bool) ) );
+}
+
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ scb->sb = scroll;
+ QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );
+}
diff --git a/native/jni/qt-peer/slotcallbacks.h b/native/jni/qt-peer/slotcallbacks.h
new file mode 100644
index 000000000..3929bde7a
--- /dev/null
+++ b/native/jni/qt-peer/slotcallbacks.h
@@ -0,0 +1,18 @@
+#ifndef SLOTCALLBACKS_H
+#define SLOTCALLBACKS_H
+
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QPushButton>
+#include <QScrollBar>
+#include <jni.h>
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj);
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj);
+void connectAction(QAction *action, JNIEnv *env, jobject obj);
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj);
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj);
+
+#endif
diff --git a/native/jni/qt-peer/slotcallbacks.moc b/native/jni/qt-peer/slotcallbacks.moc
new file mode 100644
index 000000000..b36b88b3e
--- /dev/null
+++ b/native/jni/qt-peer/slotcallbacks.moc
@@ -0,0 +1,75 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'slotcallbacks.cpp'
+**
+** Created: Sun Jul 24 22:00:17 2005
+** by: The Qt Meta Object Compiler version 58 (Qt 4.0.0)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'slotcallbacks.cpp' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 58
+#error "This file was generated using the moc from 4.0.0. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_SlotCallback[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 4, 10, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+ 14, 13, 13, 13, 0x0a,
+ 38, 30, 13, 13, 0x0a,
+ 64, 58, 13, 13, 0x0a,
+ 92, 85, 13, 13, 0x0a,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_SlotCallback[] = {
+ "SlotCallback\0\0buttonClicked()\0checked\0buttonToggled(bool)\0index\0"
+ "choiceActivated(int)\0action\0scrollBarAction(int)\0"
+};
+
+const QMetaObject SlotCallback::staticMetaObject = {
+ { &QObject::staticMetaObject, qt_meta_stringdata_SlotCallback,
+ qt_meta_data_SlotCallback, 0 }
+};
+
+const QMetaObject *SlotCallback::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *SlotCallback::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_SlotCallback))
+ return static_cast<void*>(const_cast<SlotCallback*>(this));
+ return QObject::qt_metacast(_clname);
+}
+
+int SlotCallback::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QObject::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: buttonClicked(); break;
+ case 1: buttonToggled(*(bool*)_a[1]); break;
+ case 2: choiceActivated(*(int*)_a[1]); break;
+ case 3: scrollBarAction(*(int*)_a[1]); break;
+ }
+ _id -= 4;
+ }
+ return _id;
+}
diff --git a/org/omg/CORBA/Any.java b/org/omg/CORBA/Any.java
index d8c892d21..1e72709d2 100644
--- a/org/omg/CORBA/Any.java
+++ b/org/omg/CORBA/Any.java
@@ -51,7 +51,7 @@ import org.omg.CORBA.portable.IDLEntity;
public abstract class Any
implements Serializable, IDLEntity
{
- /**
+ /**
* Using v 1.4 serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1217179597823814463L;
@@ -312,12 +312,18 @@ public abstract class Any
public abstract void insert_TypeCode(TypeCode typecode);
/**
- * Insert the CORBA <code>Value</code> into this <code>Any</code>
+ * Insert the CORBA <code>Value</code> into this <code>Any</code>.
+ *
+ * The type of the Any should be set (by {@link #type(TypeCode)})
+ * before inserting the value.
*/
public abstract void insert_Value(Serializable x, TypeCode typecode);
/**
- * Insert the CORBA <code>Value</code> into this <code>Any</code>
+ * Insert the CORBA <code>Value</code> into this <code>Any</code>.
+ *
+ * The type of the Any should be set (by {@link #type(TypeCode)})
+ * before inserting the value.
*/
public abstract void insert_Value(Serializable x);
diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java
index 0cfbc2956..00fa8225d 100644
--- a/org/omg/CORBA/ORB.java
+++ b/org/omg/CORBA/ORB.java
@@ -882,6 +882,10 @@ public abstract class ORB
* <td>Encodes/decodes IDL data types into/from byte arrays.</td>
* </tr>
*
+ * <tr><td>DynAnyFactory</td><td>{@link org.omg.DynamicAny.DynAnyFactory}</td>
+ * <td>Creates DynAny's.</td>
+ * </tr>
+ *
* </table>
*
* @param name the object name.
diff --git a/org/omg/CORBA/ObjectHelper.java b/org/omg/CORBA/ObjectHelper.java
index 0e0efa51e..1324c621f 100644
--- a/org/omg/CORBA/ObjectHelper.java
+++ b/org/omg/CORBA/ObjectHelper.java
@@ -50,10 +50,7 @@ import org.omg.CORBA.portable.OutputStream;
*/
public abstract class ObjectHelper
{
- /**
- * The cached binding list type code.
- */
- private static TypeCode typeCode = new primitiveTypeCode(TCKind.tk_objref);
+ static TypeCode typeCode;
/**
* Extract the array of object from the given {@link Any}.
@@ -100,6 +97,8 @@ public abstract class ObjectHelper
*/
public static TypeCode type()
{
+ if (typeCode == null)
+ typeCode = ORB.init().get_primitive_tc(TCKind.tk_objref);
return typeCode;
}
diff --git a/org/omg/CORBA/ObjectHolder.java b/org/omg/CORBA/ObjectHolder.java
index 02526bee1..27ae67416 100644
--- a/org/omg/CORBA/ObjectHolder.java
+++ b/org/omg/CORBA/ObjectHolder.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.recordTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -59,10 +60,16 @@ public final class ObjectHolder
implements Streamable
{
/**
- * The default type code for this holder.
+ * The default type code for this holder if the object type code with
+ * the zero length string as id.
*/
- private static final TypeCode t_object =
- new primitiveTypeCode(TCKind.tk_objref);
+ private static final recordTypeCode t_object;
+
+ static
+ {
+ t_object = new recordTypeCode(TCKind.tk_objref);
+ t_object.setId("");
+ }
/**
* The <code>org.omg.CORBA.Object</code> (CORBA <code>Object</code>) value,
@@ -109,7 +116,7 @@ public final class ObjectHolder
*/
public TypeCode _type()
{
- return t_object;
+ return ObjectHelper.type();
}
/**
@@ -124,4 +131,4 @@ public final class ObjectHolder
{
output.write_Object(value);
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CORBA/TypeCode.java b/org/omg/CORBA/TypeCode.java
index 38fb0564f..a1ad3db9e 100644
--- a/org/omg/CORBA/TypeCode.java
+++ b/org/omg/CORBA/TypeCode.java
@@ -38,11 +38,11 @@ exception statement from your version. */
package org.omg.CORBA;
-import java.io.Serializable;
-
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.IDLEntity;
+import java.io.Serializable;
+
/**
* An information about a CORBA data type.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
@@ -57,10 +57,12 @@ public abstract class TypeCode
private static final long serialVersionUID = -6521025782489515676L;
/**
- * Returns the concrete base type for this TypeCode.
- * @return a TypeCode, defining the concrete base type for this
- * Typecode.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind
+ * For value types that support inheritance this method returns the
+ * of the ancestor type code.
+ *
+ * @return the ancestor TypeCode.
+ *
+ * @throws BadKind for all typecodes except the value type typecodes.
*/
public abstract TypeCode concrete_base_type()
throws BadKind;
@@ -69,7 +71,7 @@ public abstract class TypeCode
* For sequences, arrays, aliases and value boxes, returns the IDL type for
* the members of the object.
* @return a TypeCode of the memebers of this type.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
+ * @throws BadKind for types other than
* sequences, arrays, aliases and value boxes.
*/
public abstract TypeCode content_type()
@@ -79,7 +81,7 @@ public abstract class TypeCode
* For unions, returs the index of the default member.
* @return the index of the default member, -1 if there is
* no default member.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this type is not
+ * @throws BadKind if this type is not
* a union.
*/
public abstract int default_index()
@@ -88,15 +90,15 @@ public abstract class TypeCode
/**
* Returs definition of member labels for untions
* @return a TypeCode, describing all non-default member labels.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this type is not a
+ * @throws BadKind if this type is not a
* union.
*/
public abstract TypeCode discriminator_type()
throws BadKind;
/**
- * Test two types for equality. The default implementation
- * returs true of the types of the same kind.
+ * Test two types for equality.
+ *
* @param other the other type to compere with
* @return true if the types are interchangeable.
*/
@@ -112,7 +114,7 @@ public abstract class TypeCode
/**
* For the fixed type, returns the number of digits.
* @return the number of digits for the fixed type
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this is not a fixed
+ * @throws BadKind if this is not a fixed
* type.
*/
public abstract short fixed_digits()
@@ -123,7 +125,7 @@ public abstract class TypeCode
* positive (the number of digits to the right of the decimal point) or
* negative (adds zeros to the left of the decimal point).
* @return the scale.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this is not a fixed
+ * @throws BadKind if this is not a fixed
* type.
*/
public abstract short fixed_scale()
@@ -140,7 +142,7 @@ public abstract class TypeCode
* Returns the RepositoryId globally identifying the type, defined by
* this TypeCode.
* @return tje RepositoryId. In some cases, it may be an empty string.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if the type is other than
+ * @throws BadKind if the type is other than
* reference, structure, union, enumeration, alias, exception, valuetype,
* boxed valuetype and also native and abstract interfaces.
*/
@@ -161,7 +163,7 @@ public abstract class TypeCode
*
* @return length or bound
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
+ * @throws BadKind for types other than
* string, sequence and array.
*/
public abstract int length()
@@ -171,7 +173,7 @@ public abstract class TypeCode
* Returns the number of type memebers.
*
* @return the number of memebers
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
+ * @throws BadKind for types other than
* structure, union, enumeration or exception.
*/
public abstract int member_count()
@@ -185,14 +187,14 @@ public abstract class TypeCode
*
* @return the label
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this is not a union
+ * @throws BadKind if this is not a union
* type.
* @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
* valid bounds.
*/
public abstract Any member_label(int index)
- throws BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds;
+ throws BadKind,
+ org.omg.CORBA.TypeCodePackage.Bounds;
/**
* Retrieves the simple name of the member identified by the given index.
@@ -201,14 +203,14 @@ public abstract class TypeCode
*
* @return the member name that in some cases can be an empty string.
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
+ * @throws BadKind for types other than
* structure, union or enumeration.
* @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
* valid bounds.
*/
public abstract String member_name(int index)
- throws BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds;
+ throws BadKind,
+ org.omg.CORBA.TypeCodePackage.Bounds;
/**
* Retrieves the member type of the member identified by the given index.
@@ -217,14 +219,14 @@ public abstract class TypeCode
*
* @return the member type.
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
+ * @throws BadKind for types other than
* structure, union, enumeration or exception.
* @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
* valid bounds.
*/
public abstract TypeCode member_type(int index)
- throws BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds;
+ throws BadKind,
+ org.omg.CORBA.TypeCodePackage.Bounds;
/**
* Returns the visibility scope of the member at the given index.
@@ -234,22 +236,21 @@ public abstract class TypeCode
*
* @return either PRIVATE_MEMBER.value or PUBLIC_MEMBER.value
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind if this is not a non boxed
+ * @throws BadKind if this is not a non boxed
* value type.
*
* @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
* valid bounds.
*/
public abstract short member_visibility(int index)
- throws BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds;
-
+ throws BadKind,
+ org.omg.CORBA.TypeCodePackage.Bounds;
/**
* Retrieves the simple name identifying this TypeCode object
* within its enclosing scope.
* @return the name, can be an empty string.
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for typer other than
+ * @throws BadKind for typer other than
* reference, structure, union, enumeration, alias, exception,
* valuetype, boxed valuetype, native, and abstract interface
*/
@@ -263,9 +264,8 @@ public abstract class TypeCode
* VM_NONE.value, VM_ABSTRACT.value, VM_CUSTOM.value, or
* VM_TRUNCATABLE.value,
*
- * @throws org.omg.CORBA.TypeCodePackage.BadKind for types other than
- * value type.
+ * @throws BadKind for all types other than value type.
*/
public abstract short type_modifier()
throws BadKind;
-}
+} \ No newline at end of file
diff --git a/org/omg/CORBA/package.html b/org/omg/CORBA/package.html
index 8fe9acf5d..5885c65ca 100644
--- a/org/omg/CORBA/package.html
+++ b/org/omg/CORBA/package.html
@@ -40,41 +40,59 @@ exception statement from your version. -->
<head><title>GNU Classpath - org.omg.CORBA</title></head>
<body>
-This package provides the support of <a href="www.omg.org">OMG</a>
-<a href="www.CORBA.org">CORBA</a>; see <a href="#overview">overview</a>
-of the implemented functionality. CORBA is an open, vendor independent
-system that applications use to work together over networks. Thie purpose
-of this package is to provide CORBA APIs to java programming language,
-including the fully functional Object Request Broker ({@link org.omg.CORBA.ORB}).
-
+This package provides the support of <a href="http://www.CORBA.org">CORBA</a>;
+see <a href="#overview">overview</a> of the implemented functionality.
+CORBA a system that applications use to work over networks. CORBA messages
+are binary, not text oriented. They practically cary no "data wrapping"
+information like XML &lt;opening&gt; &lt;/closing&gt; tags. Hence CORBA
+objects much easier exchange large amounts of binary data. CORBA can work
+in such data-intensive application areas as telecommunications or radio
+broadcasting.
<a name="overview">
<h4>Overview of the currently implemented CORBA functionality</h4>
-<p>The CORBA implementation in the Classpath project is now a working prototype.
- This prototype is interoperable with Sun's implementation v 1.4, transferring
- object references, primitive types, narrow and wide strings, arrays, structures
- and trees between these two platforms. The thrown exceptions are also transferred
- and handled. The support for stringified object references (IORs) is implemented.
- The redirection commands works, LOCATION_FORWARD_PERM changing the target address
- until the application is restarted and LOCATION_FORWARD redirecting for the
- current session only. Both Little and Big Endian encoded messages
- are accepted. The encoding of the sent messages is the same as used in the
- stringified IOR reference of that object or Big Endian, if no such data
- available.
- </p>
- <p>
- The current release supports the Value types that appeared since v 1.3 and are
- something between CORBA structures (no methods, data local) and CORBA objects
- (both methods and data remote). Value type has local data, can have
- local methods and is transferred by value, not by IOR reference.
- </p>
- <p>
- You can use both request-oriented (based on {@link org.omg.CORBA.Request})
- and stream-oriented (based on {@link org.omg.CORBA.portable.ObjectImpl})
- invocation models. The current release includes the working examples, demonstrating
- the client-server communication using both methods. These examples also show,
- how to use the Classpath naming service. The IDL compiler is not yet written,
- but as a side effect of the required compatibility, the implementation seems
- accepting the output of the Sun's 1.3 idlj.</p>
+The CORBA implementation in the Classpath project is now a working
+prototype.
+<ul>
+<li>This prototype is interoperable with Sun's implementation v 1.4,
+transferring object references, primitive types, narrow and wide strings,
+arrays, structures and trees between these two platforms.
+</li>
+<li>The prototype provides interoperable support for the Abstract interface
+ and Value types. Those appear in 1.3, being a feature of CORBA 2.3.
+</li>
+<li>The remote exceptions are also transferred and handled as expected.
+</li>
+<li>The support for parsing stringified object references (IORs), both
+Big and Little Endian encoded, is implemented.
+</li>
+<li>The redirection commands works, LOCATION_FORWARD_PERM changing the
+target address until the application is restarted and LOCATION_FORWARD
+redirecting for the current session only.
+</li>
+<li>Both Little and Big Endian encoded messages are accepted. The encoding
+of the sent messages is the same as used in the stringified IOR reference
+of that object or Big Endian, if no such data available.
+</li>
+<li>You can use both request-oriented (based on {@link org.omg.CORBA.Request}
+and stream-oriented (based on {@link org.omg.CORBA.portable.ObjectImpl}
+invocation models. The current release includes the working examples,
+demonstrating the client-server communication using both methods.
+</li>
+<li>These examples also show, how to use the Classpath naming service.
+</li>
+<li>The IDL compiler is not yet written (and not even started), but as a
+ side effect of the required compatibility, the implementation seems
+accepting the output of the Sun's idlj.
+</li>
+<li>The Portable Object Adapter is already released. For details on POA,
+see the {@link org.omg.PortableServer} package.</li>
+<li>We provide the implementation of the {@link org.omg.DynamicAny}
+package. ORB returns the working DynAnyFactory that produces working
+DynAny's as defined in OMG specification.</li>
+<li>All GNU Classpath classes in omg.org namespace are newly written using
+ the OMG .pdf document (Version 3.0.3, formal/04-03-12).
+</li>
+</ul>
@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
</body>
diff --git a/org/omg/CORBA_2_3/portable/InputStream.java b/org/omg/CORBA_2_3/portable/InputStream.java
index 3ab264f60..06ee33e66 100644
--- a/org/omg/CORBA_2_3/portable/InputStream.java
+++ b/org/omg/CORBA_2_3/portable/InputStream.java
@@ -40,7 +40,9 @@ package org.omg.CORBA_2_3.portable;
import gnu.CORBA.CDR.Vio;
+import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.ValueFactory;
import java.io.Serializable;
@@ -170,7 +172,7 @@ public abstract class InputStream
*/
public Serializable read_value(Serializable unitialised_value)
{
- return Vio.read(this, unitialised_value);
+ return (Serializable) Vio.read(this, unitialised_value, null);
}
/**
@@ -190,8 +192,11 @@ public abstract class InputStream
*/
public Serializable read_value(String repository_id)
{
- return ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id)
- .read_value(this);
+ ValueFactory factory =
+ ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
+ if (factory == null)
+ throw new MARSHAL("No factory");
+ return (Serializable) Vio.read(this, null, factory);
}
/**
@@ -203,6 +208,6 @@ public abstract class InputStream
*/
public Serializable read_value(BoxedValueHelper helper)
{
- return helper.read_value(this);
+ return Vio.read(this, helper);
}
} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/OutputStream.java b/org/omg/CORBA_2_3/portable/OutputStream.java
index 2f83a939f..2ff8c226a 100644
--- a/org/omg/CORBA_2_3/portable/OutputStream.java
+++ b/org/omg/CORBA_2_3/portable/OutputStream.java
@@ -117,7 +117,7 @@ public abstract class OutputStream
*/
public void write_value(Serializable value, BoxedValueHelper helper)
{
- helper.write_value(this, value);
+ Vio.write(this, value, helper);
}
/**
diff --git a/org/omg/DynamicAny/AnySeqHelper.java b/org/omg/DynamicAny/AnySeqHelper.java
new file mode 100644
index 000000000..60e4e6ea7
--- /dev/null
+++ b/org/omg/DynamicAny/AnySeqHelper.java
@@ -0,0 +1,122 @@
+/* AnySeqHelper.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 org.omg.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link Any}. This class shares
+ * the same {@link AnySeqHolder} as the {@link org.omg.CORBA.AnySeqHelper}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AnySeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#extract}.
+ */
+ public static Any[] extract(Any any)
+ {
+ return org.omg.CORBA.AnySeqHelper.extract(any);
+ }
+
+ /**
+ * Get the AnySeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/AnySeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/AnySeq:1.0";
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#insert}.
+ */
+ public static void insert(Any any, Any[] those)
+ {
+ org.omg.CORBA.AnySeqHelper.insert(any, those);
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#read}.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static Any[] read(InputStream input)
+ {
+ return org.omg.CORBA.AnySeqHelper.read(input);
+ }
+
+ /**
+ * Get the typecode as officially defined for this helper.
+ *
+ * @return alias of unbounded sequence of Any's, named AnySeq,
+ * with the id, returned by {@link #id()}.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t =
+ orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_any));
+ typeCode = orb.create_alias_tc(id(), "AnySeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#write}.
+ */
+ public static void write(OutputStream output, Any[] value)
+ {
+ org.omg.CORBA.AnySeqHelper.write(output, value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/DynAnyFactoryHelper.java b/org/omg/DynamicAny/DynAnyFactoryHelper.java
index b6fd15151..0c02916e5 100644
--- a/org/omg/DynamicAny/DynAnyFactoryHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryHelper.java
@@ -62,7 +62,7 @@ public abstract class DynAnyFactoryHelper
{
/**
* Cast the passed object into the DynAnyFactory. As DynAnyFactory is a local
- * object, the method just uses java type cast.
+ * object, the method just uses java final_type cast.
*
* @param obj the object to narrow.
* @return narrowed instance.
@@ -82,7 +82,7 @@ public abstract class DynAnyFactoryHelper
}
/**
- * Get the type code of the {@link DynAnyFactory}.
+ * Get the final_type code of the {@link DynAnyFactory}.
*/
public static TypeCode type()
{
diff --git a/org/omg/DynamicAny/DynAnyFactoryOperations.java b/org/omg/DynamicAny/DynAnyFactoryOperations.java
index c3ea4a9dc..058e36958 100644
--- a/org/omg/DynamicAny/DynAnyFactoryOperations.java
+++ b/org/omg/DynamicAny/DynAnyFactoryOperations.java
@@ -118,6 +118,11 @@ public interface DynAnyFactoryOperations
* <td>null</td>
* <td>{@link DynValue}, {@link DynValueBox}</td>
* </tr>
+ * <tr>
+ * <td>TypeCode</td>
+ * <td>Typecode of kind <code>TCKind.tk_null</code></td>
+ * <td>{@link DynValue}, {@link DynValueBox}</td>
+ * </tr>
*
* </table>
*
diff --git a/org/omg/DynamicAny/DynAnyOperations.java b/org/omg/DynamicAny/DynAnyOperations.java
index 67e356cfe..73d8fac23 100644
--- a/org/omg/DynamicAny/DynAnyOperations.java
+++ b/org/omg/DynamicAny/DynAnyOperations.java
@@ -59,7 +59,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if the source DynAny is invalid.
*/
void assign(DynAny from)
- throws TypeMismatch;
+ throws TypeMismatch;
/**
* Fully clones the content of this Any, returning a deep copy.
@@ -77,7 +77,7 @@ public interface DynAnyOperations
* components, like {@link DynEnum}.
*/
DynAny current_component()
- throws TypeMismatch;
+ throws TypeMismatch;
/**
* Destroys this DynAny, freeing the used resources. In java, resources are
@@ -98,7 +98,7 @@ public interface DynAnyOperations
* otherwise invalid.
*/
void from_any(Any an_any)
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* This method is used when the wrapped Any contains an instance of another
@@ -108,7 +108,7 @@ public interface DynAnyOperations
* the typecode of this DynAny.
*/
Any get_any()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the boolean value that is expected to be stored in this DynAny.
@@ -116,7 +116,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
boolean get_boolean()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the char value that is expected to be stored in this DynAny.
@@ -124,7 +124,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
char get_char()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the <code>double</code> value that is expected to be stored in
@@ -133,7 +133,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
double get_double()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the <code>float</code> value that is expected to be stored in
@@ -142,7 +142,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
float get_float()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the int (CORBA long) value that is expected to be stored in this
@@ -151,7 +151,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
int get_long()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the long (CORBA long long) value that is expected to be stored in
@@ -160,7 +160,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
long get_longlong()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the byte (CORBA octet) value that is expected to be stored in this
@@ -169,7 +169,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
byte get_octet()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the CORBA object reference that is expected to be stored in this
@@ -178,7 +178,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
org.omg.CORBA.Object get_reference()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the <code>short</code> value that is expected to be stored in
@@ -187,7 +187,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
short get_short()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the string value that is expected to be stored in this DynAny.
@@ -195,7 +195,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
String get_string()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the {@link TypeCode} value that is expected to be stored in this
@@ -204,7 +204,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
TypeCode get_typecode()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the unsigned int (CORBA ulong) value that is expected to be stored
@@ -213,7 +213,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
int get_ulong()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the unsingel long (CORBA unsigned long long )value that is expected
@@ -222,7 +222,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
long get_ulonglong()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the unsigned short value that is expected to be stored in this
@@ -231,7 +231,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
short get_ushort()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the value that is expected to be stored in this DynAny.
@@ -239,7 +239,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
Serializable get_val()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the wide (usually UTF-16) character value that is expected to be
@@ -248,7 +248,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
char get_wchar()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Extract the wide (usually UFT-16) string that is expected to be stored in
@@ -257,7 +257,7 @@ public interface DynAnyOperations
* @throws TypeMismatch if this DynAny holds the value of the different type.
*/
String get_wstring()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Insert the {@link Any} value into the enclosed {@link Any} inside this
@@ -268,7 +268,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_any(Any an_any)
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Insert the boolean value into the enclosed {@link Any} inside this DynAny
@@ -278,7 +278,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_boolean(boolean a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the char value into the enclosed {@link Any} inside this DynAny
@@ -288,7 +288,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_char(char a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the double value into the enclosed {@link Any} inside this DynAny
@@ -298,7 +298,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_double(double a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the float value into the enclosed {@link Any} inside this DynAny
@@ -308,7 +308,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_float(float a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the int (CORBA long) value into the enclosed {@link Any} inside this
@@ -319,7 +319,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_long(int a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the long (CORBA long long) value into the enclosed {@link Any}
@@ -330,7 +330,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_longlong(long a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the byte (CORBA octet) value into the enclosed {@link Any} inside
@@ -341,7 +341,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_octet(byte a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the object reference into the enclosed {@link Any} inside this
@@ -352,7 +352,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_reference(org.omg.CORBA.Object a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the <code>short</code> value into the enclosed {@link Any} inside
@@ -363,7 +363,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_short(short a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the string value into the enclosed {@link Any} inside this DynAny
@@ -373,7 +373,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_string(String a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the {@link TypeCode} value into the enclosed {@link Any} inside this
@@ -384,7 +384,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_typecode(TypeCode a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the int (CORBA unsinged long) value into the enclosed {@link Any}
@@ -395,7 +395,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_ulong(int a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the long (CORBA unsigned long long) value into the enclosed
@@ -406,7 +406,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_ulonglong(long a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the short (CORBA unsigned short) value into the enclosed {@link Any}
@@ -417,7 +417,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_ushort(short a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the value into the enclosed {@link Any} inside this DynAny
@@ -427,7 +427,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_val(Serializable a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the wide char (usually UTF-16) value into the enclosed {@link Any}
@@ -438,7 +438,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_wchar(char a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Insert the wide string (usually UTF-16) into the enclosed {@link Any}
@@ -449,7 +449,7 @@ public interface DynAnyOperations
* enclosed {@link Any}.
*/
void insert_wstring(String a_x)
- throws InvalidValue, TypeMismatch;
+ throws InvalidValue, TypeMismatch;
/**
* Advances the internal pointer, described in the {@link current_component},
@@ -503,7 +503,7 @@ public interface DynAnyOperations
* @throws InvalidValue if the current position points nowhere.
*/
void insert_dyn_any(DynAny insert_it)
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
/**
* Checks for equality with another Dynamic Any.
@@ -536,5 +536,5 @@ public interface DynAnyOperations
* @throws InvalidValue if the current position points nowhere.
*/
DynAny get_dyn_any()
- throws TypeMismatch, InvalidValue;
+ throws TypeMismatch, InvalidValue;
}
diff --git a/org/omg/DynamicAny/DynAnySeqHelper.java b/org/omg/DynamicAny/DynAnySeqHelper.java
new file mode 100644
index 000000000..87e344523
--- /dev/null
+++ b/org/omg/DynamicAny/DynAnySeqHelper.java
@@ -0,0 +1,152 @@
+/* DynAnySeq.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 org.omg.DynamicAny;
+
+import gnu.CORBA.DynAnySeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link DynAny} ({@link DynAnySeq}).
+ * Following the 1.5 JDK specifications, DynAny (and hence an sequence of
+ * DynAny's) is always a local object, so the two methods of this helper
+ * ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynAnySeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, DynAnyHelper.type());
+ typeCode = orb.create_alias_tc(id(), "DynAnySeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the DynAnySeq into the given Any.
+ * This method uses the DynAnySeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the DynAny[] to insert.
+ */
+ public static void insert(Any any, DynAny[] those)
+ {
+ any.insert_Streamable(new DynAnySeqHolder(those));
+ }
+
+ /**
+ * Extract the DynAnySeq from given Any.
+ * This method uses the DynAnySeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynAnySeq.
+ */
+ public static DynAny[] extract(Any any)
+ {
+ try
+ {
+ return ((DynAnySeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("DynAnySeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the DynAnySeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynAnySeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynAnySeq:1.0";
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynAny[] read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynAny[] value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/DynUnionOperations.java b/org/omg/DynamicAny/DynUnionOperations.java
index b39dd93ff..30b891a2d 100644
--- a/org/omg/DynamicAny/DynUnionOperations.java
+++ b/org/omg/DynamicAny/DynUnionOperations.java
@@ -59,24 +59,28 @@ public interface DynUnionOperations
extends DynAnyOperations
{
/**
- * Get the value of discriminator, defining which content variant (member) is
- * active.
+ * <p>Get the value of discriminator, defining which content variant
+ * (member) is active.
+ * </p><p>
+ * In the current implementation, the later changes on the returned value
+ * alter the state of the union via implemented internal listener.
+ * </p>
*/
DynAny get_discriminator();
/**
- * Set the value of discriminator, activating the member variant that is
+ * <p>Set the value of discriminator, activating the member variant that is
* consistent with the discriminator value. If the current member variant
* matches the discriminator being set, it is unchanged. Otherwise, it is
* replaced by the matching member variant with fields, initialised to default
* values. The current position is set to 0 if the discriminator value does
* not match any member variant. Otherwise, the current position is set to 1,
* index of the member variant.
- *
+ * </p>
* @throws TypeMismatch if the discriminator has a wrong type of this union.
*/
void set_discriminator(DynAny aDiscriminator)
- throws TypeMismatch;
+ throws TypeMismatch;
/**
* Get the kind of the union descriminator.
@@ -94,7 +98,7 @@ public interface DynUnionOperations
* @throws InvalidValue if the union has no active member.
*/
DynAny member()
- throws InvalidValue;
+ throws InvalidValue;
/**
* Returns the kind of the currently active union member.
@@ -104,7 +108,7 @@ public interface DynUnionOperations
* @throws InvalidValue if the union has no active member.
*/
TCKind member_kind()
- throws InvalidValue;
+ throws InvalidValue;
/**
* Returns the name of the currently active union member.
@@ -114,7 +118,7 @@ public interface DynUnionOperations
* @throws InvalidValue if the union has no active member.
*/
String member_name()
- throws InvalidValue;
+ throws InvalidValue;
/**
* Returns true if the union has no active member. This happens if If the
@@ -131,7 +135,7 @@ public interface DynUnionOperations
* @throws TypeMismatch if the default case is not defined for this union.
*/
void set_to_default_member()
- throws TypeMismatch;
+ throws TypeMismatch;
/**
* Set the discriminator to value that does not correspond any content variant
@@ -141,5 +145,5 @@ public interface DynUnionOperations
* @throws TypeMismatch if the union has explicit default case.
*/
void set_to_no_active_member()
- throws TypeMismatch;
+ throws TypeMismatch;
}
diff --git a/org/omg/DynamicAny/DynValueBox.java b/org/omg/DynamicAny/DynValueBox.java
index e3806464f..bd758b50c 100644
--- a/org/omg/DynamicAny/DynValueBox.java
+++ b/org/omg/DynamicAny/DynValueBox.java
@@ -49,7 +49,7 @@ import java.io.Serializable;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface DynValueBox
- extends DynValueBoxOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
- Serializable
+ extends DynValueBoxOperations, DynValueCommon, DynAny, IDLEntity,
+ org.omg.CORBA.Object, Serializable
{
} \ No newline at end of file
diff --git a/org/omg/DynamicAny/DynValueCommon.java b/org/omg/DynamicAny/DynValueCommon.java
index 0982eee12..1b324aa7d 100644
--- a/org/omg/DynamicAny/DynValueCommon.java
+++ b/org/omg/DynamicAny/DynValueCommon.java
@@ -47,16 +47,16 @@ import java.io.Serializable;
* {@link DynValueCommonOperations} provides methods for setting the value to
* <code>null</code> or non-<code>null</code> and checking if the value is
* <code>null</code>.
- *
+ *
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface DynValueCommon
- extends DynValueOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ extends DynValueCommonOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
Serializable
{
/**
* Check if this {@link DynAny} is holding the <code>null</code>.
- *
+ *
* @return true if this {@link DynAny} is holding the <code>null</code>,
* false otherwise.
*/
diff --git a/org/omg/DynamicAny/FieldNameHelper.java b/org/omg/DynamicAny/FieldNameHelper.java
new file mode 100644
index 000000000..7c4cdbf49
--- /dev/null
+++ b/org/omg/DynamicAny/FieldNameHelper.java
@@ -0,0 +1,120 @@
+/* FieldNameHelper.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 org.omg.DynamicAny;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper for the FieldName. The fields {@link NameValuePair#id},
+ * {@link NameDynAnyPair#id} and return values of methods
+ * <code>current_member_name()</code>, <code>member_name()</code> in several
+ * interfaces officially have the "FieldName" type. This type is directly
+ * mapped into java String and needs no helper. The helper
+ * is included only as a part of the formal standard.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class FieldNameHelper
+{
+ /**
+ * Insert the FieldName into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the FieldName from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an alias typecode.
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "FieldName", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the FieldName repository id.
+ * @return "IDL:omg.org/DynamicAny/FieldName:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/FieldName:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param instream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (FieldName) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/NameDynAnyPairHelper.java b/org/omg/DynamicAny/NameDynAnyPairHelper.java
new file mode 100644
index 000000000..d649800b8
--- /dev/null
+++ b/org/omg/DynamicAny/NameDynAnyPairHelper.java
@@ -0,0 +1,170 @@
+/* NameDynAnyPairHelper.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 org.omg.DynamicAny;
+
+import gnu.CORBA.NameDynAnyPairHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the structure {@link NameDynAnyPair}.
+ *
+ * Following the 1.5 JDK specifications, DynAny (and hence any structure,
+ * containing DynAny) is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameDynAnyPairHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the NameDynAnyPair from given Any.
+ * This method uses the NameDynAnyPairHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPair.
+ */
+ public static NameDynAnyPair extract(Any any)
+ {
+ try
+ {
+ return ((NameDynAnyPairHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPair expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameDynAnyPair repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameDynAnyPair:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameDynAnyPair:1.0";
+ }
+
+ /**
+ * Create the NameDynAnyPair typecode (structure,
+ * named "NameDynAnyPair").
+ * The typecode states that the structure contains the
+ * following fields: id, value.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = DynAnyHelper.type();
+ members [ 1 ] = new StructMember("value", field, null);
+ typeCode = orb.create_struct_tc(id(), "NameDynAnyPair", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameDynAnyPair into the given Any.
+ * This method uses the NameDynAnyPairHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the NameDynAnyPair to insert.
+ */
+ public static void insert(Any any, NameDynAnyPair that)
+ {
+ any.insert_Streamable(new NameDynAnyPairHolder(that));
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static NameDynAnyPair read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, NameDynAnyPair value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
new file mode 100644
index 000000000..06a5ced90
--- /dev/null
+++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
@@ -0,0 +1,151 @@
+/* NameDynAnyPairSeq.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 org.omg.DynamicAny;
+
+import gnu.CORBA.NameDynAnyPairSeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link NameDynAnyPair}
+ * ({@link NameDynAnyPairSeq}).
+ *
+ * Following the 1.5 JDK specifications, DynAny (and hence the sequence
+ * of structures, containing DynAny) is always a local object.
+ * Hence the two methods of this helper ({@link #read} and {@link #write} are
+ * not in use, always throwing {@link MARSHAL}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameDynAnyPairSeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, NameDynAnyPairHelper.type());
+ typeCode = orb.create_alias_tc(id(), "NameDynAnyPairSeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameDynAnyPairSeq into the given Any.
+ * This method uses the NameDynAnyPairSeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the NameDynAnyPair[] to insert.
+ */
+ public static void insert(Any any, NameDynAnyPair[] those)
+ {
+ any.insert_Streamable(new NameDynAnyPairSeqHolder(those));
+ }
+
+ /**
+ * Extract the NameDynAnyPairSeq from given Any.
+ * This method uses the NameDynAnyPairSeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPairSeq.
+ */
+ public static NameDynAnyPair[] extract(Any any)
+ {
+ try
+ {
+ return ((NameDynAnyPairSeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPairSeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameDynAnyPairSeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameDynAnyPairSeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameDynAnyPairSeq:1.0";
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static NameDynAnyPair[] read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, NameDynAnyPair[] value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/NameValuePairHelper.java b/org/omg/DynamicAny/NameValuePairHelper.java
new file mode 100644
index 000000000..a3d5bff45
--- /dev/null
+++ b/org/omg/DynamicAny/NameValuePairHelper.java
@@ -0,0 +1,159 @@
+/* NameValuePairHelper.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 org.omg.DynamicAny;
+
+import gnu.CORBA.NameValuePairHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the structure {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameValuePairHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the NameValuePair typecode (structure,
+ * named "NameValuePair").
+ * The typecode states that the structure contains the
+ * following fields: id, value.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = orb.get_primitive_tc(TCKind.tk_any);
+ members [ 1 ] = new StructMember("value", field, null);
+ typeCode = orb.create_struct_tc(id(), "NameValuePair", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameValuePair into the given Any.
+ * This method uses the NameValuePairHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the NameValuePair to insert.
+ */
+ public static void insert(Any any, NameValuePair that)
+ {
+ any.insert_Streamable(new NameValuePairHolder(that));
+ }
+
+ /**
+ * Extract the NameValuePair from given Any.
+ * This method uses the NameValuePairHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameValuePair.
+ */
+ public static NameValuePair extract(Any any)
+ {
+ try
+ {
+ return ((NameValuePairHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameValuePair expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameValuePair repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameValuePair:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameValuePair:1.0";
+ }
+
+ /**
+ * Read the structure from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static NameValuePair read(InputStream input)
+ {
+ NameValuePair value = new NameValuePair();
+ value.id = input.read_string();
+ value.value = input.read_any();
+ return value;
+ }
+
+ /**
+ * Write the structure to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, NameValuePair value)
+ {
+ output.write_string(value.id);
+ output.write_any(value.value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/NameValuePairSeqHelper.java b/org/omg/DynamicAny/NameValuePairSeqHelper.java
new file mode 100644
index 000000000..400708e18
--- /dev/null
+++ b/org/omg/DynamicAny/NameValuePairSeqHelper.java
@@ -0,0 +1,147 @@
+/* NameValuePairSeq.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 org.omg.DynamicAny;
+
+import gnu.CORBA.NameValuePairSeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameValuePairSeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, NameValuePairHelper.type());
+ typeCode = orb.create_alias_tc(id(), "NameValuePairSeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameValuePairSeq into the given Any.
+ * This method uses the NameValuePairSeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the NameValuePair[] to insert.
+ */
+ public static void insert(Any any, NameValuePair[] those)
+ {
+ any.insert_Streamable(new NameValuePairSeqHolder(those));
+ }
+
+ /**
+ * Extract the NameValuePairSeq from given Any.
+ * This method uses the NameValuePairSeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameValuePairSeq.
+ */
+ public static NameValuePair[] extract(Any any)
+ {
+ try
+ {
+ return ((NameValuePairSeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameValuePairSeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameValuePairSeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameValuePairSeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameValuePairSeq:1.0";
+ }
+
+ /**
+ * Read the sequence from the CDR intput stream.
+ * Expects the array size (as CORBA long), followed by
+ * the array members (if any).
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static NameValuePair[] read(InputStream input)
+ {
+ NameValuePair[] value;
+ value = new NameValuePair[ input.read_long() ];
+ for (int i = 0; i < value.length; i++)
+ value [ i ] = NameValuePairHelper.read(input);
+ return value;
+ }
+
+ /**
+ * Write the structure to the CDR output stream.
+ * Writes the array size (as CORBA long), followed by
+ * the array members (if any).
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value an array to write.
+ */
+ public static void write(OutputStream output, NameValuePair[] value)
+ {
+ output.write_long(value.length);
+ for (int i0 = 0; i0 < value.length; i0++)
+ {
+ NameValuePairHelper.write(output, value [ i0 ]);
+ }
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynAnyFactoryStub.java b/org/omg/DynamicAny/_DynAnyFactoryStub.java
new file mode 100644
index 000000000..9a895329c
--- /dev/null
+++ b/org/omg/DynamicAny/_DynAnyFactoryStub.java
@@ -0,0 +1,116 @@
+/* _DynAnyFactoryStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on
+ * DynAnyFactory. As DynAny can never be remote at least till 1.5 inclusive,
+ * this class is not in use. DynAnyFactory should be obtained from the
+ * {@link ORB#resolve_initial_references}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynAnyFactoryStub
+ extends ObjectImpl
+ implements DynAnyFactory, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -6575269659020082310L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynAnyFactoryOperations.class;
+
+ /**
+ * Create the DynAnyFactory stub.
+ */
+ public _DynAnyFactoryStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynAnyFactoryStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynAnyFactoryHelper.id() };
+ }
+
+ /**
+ * The remote call of this DynAnyFactory method is not possible
+ * (the created DynAny would not be transferred to client).
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny create_dyn_any(Any _0)
+ throws InconsistentTypeCode
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of this DynAnyFactory method is not possible
+ * (the created DynAny would not be transferred to client).
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode _0)
+ throws InconsistentTypeCode
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ static String NOT_APPLICABLE =
+ "DynAnyFactory is always local objects. " +
+ "It is never accessed on remote side via stub.";
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynAnyStub.java b/org/omg/DynamicAny/_DynAnyStub.java
new file mode 100644
index 000000000..c9bf3fb08
--- /dev/null
+++ b/org/omg/DynamicAny/_DynAnyStub.java
@@ -0,0 +1,630 @@
+/* _DynAnyStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynAny. As
+ * DynAny can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynAnyStub
+ extends ObjectImpl
+ implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -6521892777941121597L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynAnyOperations.class;
+
+ /**
+ * Create the DynAny stub.
+ */
+ public _DynAnyStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynAnyStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynAnyHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TypeCode type()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean next()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny copy()
+ {
+ return this;
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void assign(DynAny _0)
+ throws TypeMismatch
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int component_count()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean equal(DynAny _0)
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void from_any(Any _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public org.omg.CORBA.Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_any(Any _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_boolean(boolean _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_char(char _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_double(double _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_dyn_any(DynAny _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_float(float _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_long(int _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_longlong(long _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_octet(byte _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_reference(org.omg.CORBA.Object _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_short(short _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_string(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_typecode(TypeCode _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ulong(int _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ulonglong(long _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ushort(short _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_val(Serializable _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_wchar(char _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_wstring(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean seek(int _0)
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any to_any()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ static String NOT_APPLICABLE =
+ "DynAnys are always local objects. " +
+ "They and are never accessed on remote side via stubs.";
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynArrayStub.java b/org/omg/DynamicAny/_DynArrayStub.java
new file mode 100644
index 000000000..f1316e905
--- /dev/null
+++ b/org/omg/DynamicAny/_DynArrayStub.java
@@ -0,0 +1,128 @@
+/* _DynArrayStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynArray. As
+ * DynArray can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynArrayStub
+ extends _DynAnyStub
+ implements DynArray, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -6302474930370950228L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynArrayOperations.class;
+
+ /**
+ * Create the DynArray stub.
+ */
+ public _DynArrayStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynArrayStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynArrayHelper.id() };
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any[] get_elements()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements(Any[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements_as_dyn_any(DynAny[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynEnumStub.java b/org/omg/DynamicAny/_DynEnumStub.java
new file mode 100644
index 000000000..1ab585d43
--- /dev/null
+++ b/org/omg/DynamicAny/_DynEnumStub.java
@@ -0,0 +1,126 @@
+/* _DynEnumStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynEnum. As
+ * DynEnum can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynEnumStub
+ extends _DynAnyStub
+ implements DynEnum, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 696844314172031949L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynEnumOperations.class;
+
+ /**
+ * Create the DynEnum stub.
+ */
+ public _DynEnumStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynEnumStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynEnumHelper.id() };
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_as_string()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_as_ulong()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_as_string(String _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_as_ulong(int _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynFixedStub.java b/org/omg/DynamicAny/_DynFixedStub.java
new file mode 100644
index 000000000..3b9a27282
--- /dev/null
+++ b/org/omg/DynamicAny/_DynFixedStub.java
@@ -0,0 +1,106 @@
+/* _DynFixedStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynFixed. As
+ * DynFixed can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynFixedStub
+ extends _DynAnyStub
+ implements DynFixed, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1932029532964417188L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynFixedOperations.class;
+
+ /**
+ * Create the DynFixed stub.
+ */
+ public _DynFixedStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynFixedStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynFixedHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_value()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean set_value(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynSequenceStub.java b/org/omg/DynamicAny/_DynSequenceStub.java
new file mode 100644
index 000000000..7707c8409
--- /dev/null
+++ b/org/omg/DynamicAny/_DynSequenceStub.java
@@ -0,0 +1,151 @@
+/* _DynSequenceStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynSequence. As
+ * DynSequence can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynSequenceStub
+ extends _DynAnyStub
+ implements DynSequence, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 7191437435669107554L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynSequenceOperations.class;
+
+ /**
+ * Create the DynSequence stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynSequenceStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynSequenceStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynSequenceHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any[] get_elements()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements(Any[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements_as_dyn_any(DynAny[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_length()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_length(int _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynStructStub.java b/org/omg/DynamicAny/_DynStructStub.java
new file mode 100644
index 000000000..514c1163c
--- /dev/null
+++ b/org/omg/DynamicAny/_DynStructStub.java
@@ -0,0 +1,152 @@
+/* _DynStructStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynStruct. As
+ * DynStruct can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynStructStub
+ extends _DynAnyStub
+ implements DynStruct, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -8415786200783826656L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynStructOperations.class;
+
+ /**
+ * Create the DynStruct stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynStructStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynStructStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynStructHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameValuePair[] get_members()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members(NameValuePair[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynUnionStub.java b/org/omg/DynamicAny/_DynUnionStub.java
new file mode 100644
index 000000000..a251d39c0
--- /dev/null
+++ b/org/omg/DynamicAny/_DynUnionStub.java
@@ -0,0 +1,184 @@
+/* _DynUnionStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynUnion. As
+ * DynUnion can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynUnionStub
+ extends _DynAnyStub
+ implements DynUnion, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -8921031953572009897L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynUnionOperations.class;
+
+ /**
+ * Create the DynUnion stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynUnionStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynUnionStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynUnionHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny member()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind discriminator_kind()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny get_discriminator()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean has_no_active_member()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind member_kind()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String member_name()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_discriminator(DynAny _0)
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_default_member()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_no_active_member()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/_DynValueStub.java b/org/omg/DynamicAny/_DynValueStub.java
new file mode 100644
index 000000000..4bedee732
--- /dev/null
+++ b/org/omg/DynamicAny/_DynValueStub.java
@@ -0,0 +1,184 @@
+/* _DynValueStub.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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 org.omg.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynValue. As
+ * DynValue can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynValueStub
+ extends _DynAnyStub
+ implements DynValue, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 5815313794012360824L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynValueOperations.class;
+
+ /**
+ * Create the DynValue stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynValueStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynValueStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynValueHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameValuePair[] get_members()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members(NameValuePair[] a_members)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] a_members)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean is_null()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_null()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_value()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+} \ No newline at end of file
diff --git a/org/omg/DynamicAny/package.html b/org/omg/DynamicAny/package.html
new file mode 100644
index 000000000..997006d2c
--- /dev/null
+++ b/org/omg/DynamicAny/package.html
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+ 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. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.DynamicAny</title></head>
+
+<body>
+<p>DynAny's allow to work with data structures, exact content of those is not
+known at the time of compilation. In this way, the conception of DynAny
+remebers the java reflection mechanism. DynAny usually obtain the value from
+the {@link org.omg.CORBA.Any} that, if needed, can carry highly nested data
+structures (like array of sequences of unions). DynAny's allow to see/modify
+all parts of such structures. This is especially helpful for writing generic
+servers (bridges, event channels supporting, filtering and so on). Similarly,
+DynAny's can create an Any at runtime, without having static knowledge of its
+type. This is helpful for writing generic clients like browsers, debuggers or
+ user interface tools.
+</p><p>
+The API clearly states that DynAny and DynAnyFactory objects are local and
+cannot be transferred to remote server or client. While such methods are
+formally defined in the corresponding helpers, they simply always throw MARSHAL.
+</p><p>
+DynAny's are created by {@link DynAnyFactory}. The factory is obtaines by
+{@link org.omg.CORBA.ORB#resolve_initial_references):
+<code>
+ORB orb = ORB.init(new String[0], null);
+DynAnyFactory f = DynAnyFactoryHelper.narrow(orb.resolve_initial_references("DynAnyFactory"));
+</code>
+DynAny's are also returned by some methods, invoked on another DynAny.
+</p><p>
+The primitive types like string or char are wrapped into an ordinary DynAny. It
+has multiple methods for setting/getting the content like
+{@link DynAnyOperations#get_string()} or
+{@link DynAnyOperations#insert_string(String)}. The more complex types like
+sequences or structures are wrapped into specialised DynAny's, providing means
+to access the enclosed members. In this case, the DynAny has the
+"internal cursor", normally pointing at one of the members in the data
+structure. The "internal cursor" can be set to the needed position
+{@link DynAnyOperations#seek(int)} or advanced forward
+({@link DynAnyOperations#next()}. The member under cursor is returned by
+{@link DynAnyOperations#current_component()}. For composite DynAnys the
+methods like {@link DynAnyOperations#get_string()} or
+{@link DynAnyOperations#insert_string(String)} apply to the selected member,
+not to the complex DynAny in general.
+</p><p>
+DynAnys are created and optimized for traversing values extracted from anys
+or constructing values of anys at runtime. OMG does not recommend to use them
+for other purposes.
+</p><p>
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html> \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/IORInfo.java b/org/omg/PortableInterceptor/IORInfo.java
new file mode 100644
index 000000000..546cacafb
--- /dev/null
+++ b/org/omg/PortableInterceptor/IORInfo.java
@@ -0,0 +1,56 @@
+/* IORInfo.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 org.omg.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Provides the server-side ORB service possibility to add components to the new
+ * IOR being created. Also, provides access to policies, applicable to the
+ * object, referenced by that IOR. The ORB passes an instance of IORInfo as a
+ * parameter to {@link IORInterceptor#establish_components}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInfo
+ extends IORInfoOperations, IDLEntity, org.omg.CORBA.Object, Serializable
+{
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/IORInfoOperations.java b/org/omg/PortableInterceptor/IORInfoOperations.java
new file mode 100644
index 000000000..f44420952
--- /dev/null
+++ b/org/omg/PortableInterceptor/IORInfoOperations.java
@@ -0,0 +1,88 @@
+/* IORInfoOperations.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 org.omg.PortableInterceptor;
+
+import org.omg.CORBA.Policy;
+import org.omg.IOP.TaggedComponent;
+
+/**
+ * The ORB service uses this interface to add the service specific components to
+ * the new IOR being constructed. The interface provides also possibility to get
+ * the POA policies the apply to the IOR being constructed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInfoOperations
+{
+ /**
+ * Adds a service-specific component to the IOR profile being constructed.
+ *
+ * @param tagged_component a tagged component being added.
+ *
+ * @param profile_id the IOR profile to that the component must be added.
+ * The 0 value ({@link org.omg.IOP.TAG_INTERNET_IOP#value}) adds to the
+ * Internet profile where host and port are stored by default.
+ */
+ void add_ior_component_to_profile(TaggedComponent tagged_component,
+ int profile_id
+ );
+
+ /**
+ * Adds a service-specific component to the IOR profile being constructed.
+ * The specified component will be included in all profiles, present in the
+ * IOR being constructed.
+ *
+ * @param tagged_component a tagged component being added.
+ */
+ void add_ior_component(TaggedComponent tagged_component);
+
+ /**
+ * Get the server side policy for an IOR being constructed. The method returns
+ * policies applying for POA where the object, represented by this IOR, is
+ * connected.
+ *
+ * @param policy_type the type of the policy.
+ *
+ * @return the policy of the given type that applies to the IOR being
+ * constructed.
+ *
+ * @see org.omg.PortableServer.POAOperations#create_POA
+ */
+ Policy get_effective_policy(int policy_type);
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/IORInterceptor.java b/org/omg/PortableInterceptor/IORInterceptor.java
new file mode 100644
index 000000000..e543a7a5d
--- /dev/null
+++ b/org/omg/PortableInterceptor/IORInterceptor.java
@@ -0,0 +1,58 @@
+/* IORInterceptor.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 org.omg.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * An ORB service implementation may need to add information describing the
+ * server�s or object�s ORB service related capabilities to object references
+ * (IORs). This is supported through the IORInterceptor and {@link IORInfo}
+ * interfaces. The IOR Interceptor is used to establish tagged components in the
+ * profiles within a new IOR being created.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInterceptor
+ extends IDLEntity, Interceptor, InterceptorOperations, IORInterceptorOperations,
+ org.omg.CORBA.Object, Serializable
+{
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/IORInterceptorOperations.java b/org/omg/PortableInterceptor/IORInterceptorOperations.java
new file mode 100644
index 000000000..60394ec15
--- /dev/null
+++ b/org/omg/PortableInterceptor/IORInterceptorOperations.java
@@ -0,0 +1,59 @@
+/* IORInterceptorOperations.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 org.omg.PortableInterceptor;
+
+
+/**
+ * Defines operation, applicable to the IORInterceptor.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInterceptorOperations
+ extends InterceptorOperations
+{
+ /**
+ * A server side ORB calls this method on all registered IORInterceptor's when
+ * creating the object reference (IOR). The interceptors have the possibility
+ * to add additional tags to the IOR being created.
+ *
+ * @param info the interface class providing methods to insert additional tags
+ * into IOR being constructed. The same instan
+ */
+ public void establish_components(IORInfo info);
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/Interceptor.java b/org/omg/PortableInterceptor/Interceptor.java
new file mode 100644
index 000000000..8b0e22420
--- /dev/null
+++ b/org/omg/PortableInterceptor/Interceptor.java
@@ -0,0 +1,57 @@
+/* Interceptor.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 org.omg.PortableInterceptor;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Portable Interceptors are hooks into the ORB through which ORB services can
+ * intercept the normal flow of execution in creation of IOR, sending request,
+ * receiving request and returning the reply.
+ *
+ * See {@link org.omg.PortableInterceptor} for more details about the possible
+ * interceptors and how to register them within the ORB.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Interceptor
+ extends InterceptorOperations, Object, IDLEntity
+{
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/InterceptorOperations.java b/org/omg/PortableInterceptor/InterceptorOperations.java
new file mode 100644
index 000000000..da08c90db
--- /dev/null
+++ b/org/omg/PortableInterceptor/InterceptorOperations.java
@@ -0,0 +1,77 @@
+/* InterceptorOperations.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 org.omg.PortableInterceptor;
+
+
+/**
+ * Defines operations, applicable for all types of {@link Interceptor}.
+ * The the derived interfaces define additional operations for they
+ * specific functionality.
+ *
+ * Portable Interceptors are hooks into the ORB through which ORB services can
+ * intercept the normal flow of execution in creation of IOR, sending request,
+ * receiving request and returning the reply.
+ *
+ * See {@link org.omg.PortableInterceptor} for more details about the possible
+ * interceptors and how to register them within the ORB.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface InterceptorOperations
+{
+ /**
+ * This method is called when orb is being destroyed and destroys
+ * the interceptor. The ORB calls this method after completing all
+ * incoming requests. The method body should not invoke methods on other
+ * object, belonging to ORB being destoryed, as in this stage it is no
+ * longer capable to act as server. It is still, however, capable
+ * to act as a client, permitting remote invocations on other objects.
+ */
+ void destroy();
+
+ /**
+ * All interceptors of the same type, registered on the single ORB, must
+ * either have different names or be anonymous. The name of the anonymous
+ * interceptor is an empty string. The ORB supports multiple anonymous
+ * interceptors of the same type.
+ *
+ * @return the name of the interceptor.
+ */
+ String name();
+} \ No newline at end of file
diff --git a/vm/reference/gnu/classpath/jdwp/VMFrame.java b/vm/reference/gnu/classpath/jdwp/VMFrame.java
new file mode 100644
index 000000000..aa1f0b22e
--- /dev/null
+++ b/vm/reference/gnu/classpath/jdwp/VMFrame.java
@@ -0,0 +1,101 @@
+/* VMFrame.java -- Reference implementation of VM hooks for JDWP Frame access.
+ Copyright (C) 2005 Free Software Foundation
+
+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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+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.jdwp;
+
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Reference implementation of VM hooks for JDWP Frame access.
+ *
+ * @author aluchko
+ */
+
+public class VMFrame
+{
+ // The object this frame resides in
+ private Object obj;
+
+ // The current location of this frame
+ private Location loc;
+
+ // id of this frame
+ private long id;
+
+ /**
+ * Gets the current location of the frame.
+ */
+ public Location getLocation()
+ {
+ return loc;
+ }
+
+ /**
+ * Returns the value of the variable in the given slot.
+ *
+ * @param slot the slot containing the variable
+ */
+ public native Object getValue(int slot);
+
+ /**
+ * Assigns the given variable to the given value.
+ * @param slot The slot which contains the variable
+ * @param value The value to assign the variable to
+ */
+ public native void setValue(int slot, Object value);
+
+ /**
+ * Get the object which is represented by 'this' in the context of the frame,
+ * returns null if the method is native or static.
+ */
+ public Object getObject()
+ {
+ return obj;
+ }
+
+ /**
+ * Get the frameID
+ * @return an id which is unique within the scope of the VM
+ */
+ public long getId()
+ {
+ return id;
+ }
+
+}
diff --git a/vm/reference/java/net/VMNetworkInterface.java b/vm/reference/java/net/VMNetworkInterface.java
index af71ce294..d63de8452 100644
--- a/vm/reference/java/net/VMNetworkInterface.java
+++ b/vm/reference/java/net/VMNetworkInterface.java
@@ -61,6 +61,16 @@ final class VMNetworkInterface
System.loadLibrary("javanet");
}
+ /**
+ * Returns a Vector of InetAddresses. The returned value will be
+ * 'condensed', meaning that all elements with the same interface
+ * name will be collapesed into one InetAddress for that name
+ * containing all addresses before the returning the result to the
+ * user. This means the native method can be implemented in a naive
+ * way mapping each address/interface to a name even if that means
+ * that the Vector contains multiple InetAddresses with the same
+ * interface name.
+ */
public static native Vector getInterfaces()
throws SocketException;
}
diff --git a/vm/reference/standard.omit b/vm/reference/standard.omit
new file mode 100644
index 000000000..c0499fe05
--- /dev/null
+++ b/vm/reference/standard.omit
@@ -0,0 +1 @@
+gnu/classpath/jdwp