From 8e99fb4f70a03741b3be630a290932c4de63ce23 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 22 Jul 2004 15:36:05 +0000 Subject: [multiple changes] 2004-07-21 Michael Koch * javax/swing/JTextArea.java (setLineWrap): Fire property change event after new value is set. (setTabSize): Likewise. 2004-07-21 Michael Koch * javax/swing/JTable.java (autoCreateColumnsFromModel): New field. (autoResizeMode): Likewise. (cellEditor): Likewise. (cellSelectionEnabled): Likewise. (columnModel): Likewise. (dataModel): Likewise. (defaultEditorsByColumnClass): Likewise. (defaultRenderersByColumnClass): Likewise. (editingColumn): Likewise. (editingRow): Likewise. (gridColor): Likewise. (preferredViewportSize): Likewise. (rowHeight): Likewise. (rowMargin): Likewise. (rowSelectionAllowed): Likewise. (selectionBackground): Likewise. (selectionForeground): Likewise. (selectionModel): Likewise. (showHorizontalLines): Likewise. (showVerticalLines): Likewise. (tableHeader): Likewise. (JTable): Implemented. (getColumnModel): Likewise. (getSelectedRow): Likewise. (getSelectionModel): Likewise. (setModel): Likewise. (setSelectionModel): Likewise. (createScrollPaneForTable): New method. (createDefaultDataModel): Likewise. (createDefaultListSelectionModel): Likewise. (getModel): Likewise. (getTableHeader): Likewise. (setTableHeader): Likewise. (getColumnSelectionAllowed): Likewise. (setColumnSelectionAllowed): Likewise. (getRowSelectionAllowed): Likewise. (setRowSelectionAllowed): Likewise. (getAutoResizeMode): Likewise. (setAutoResizeMode): Likewise. (getColumnCount): Likewise. (getRowCount): Likewise. (getCellRenderer): Likewise. * javax/swing/JTree.java (cellRenderer): New field. (editable): Likewise. (rootVisible): Likewise. (showsRootHandles): Likewise. (getModel): New method. (setModel): Likewise. (isEditable): Likewise. (setEditable): Likewise. (isRootVisbile): Likewise. (setRootVisible): Likewise. (getShowsRootHandles): Likewise. (setShowRootHandles): Likewise. (getCellRenderer): Likewise. (setCellRenderer): Likewise. 2004-07-21 Michael Koch * javax/swing/JFormattedTextField.java (setDocument): Implemented. * javax/swing/JRootPane.java: Fixed javadocs. * javax/swing/JTable.java (getDefaultRenderer): New method. * javax/swing/JTextField.java (setFont): Likewise. (getPreferredSize): Likewise. * javax/swing/JToggleButton.java (getAccessibleContext): Fix javadoc. * javax/swing/JTree.java: Add some javadocs. * javax/swing/JViewport.java: Likewise. 2004-07-21 David Jee * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java: Collect all native method declaration at the top. (create): Set the filename filter if necessary. (setDirectory): Call nativeSetDirectory(). (setFilenameFilter): Implement. (filenameFilterCallback): New method. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (create): Configure dialog to show hidden files. (filenameFilterCallback): New function. (nativeSetFilenameFilter): New function. (nativeSetDirectory): New function. 2004-07-21 Kim Ho * javax/swing/plaf/basic/BasicSliderUI.java: Ran Jalopy. (paintTrack): Fill the track before painting the borders. 2004-07-21 Graydon Hoare patch from Roman Kennke * javax/swing/Spring.java: New file. * javax/swing/SpringLayout.java: New file. * Makefile.am: Add new files. * Makefile.in: Regenerate. 2004-07-21 Graydon Hoare * javax/swing/plaf/basic/BasicSplitPaneUI.java: Minor layout fixes. * javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise. * javax/swing/ScrollPaneLayout.java: Likewise. 2004-07-21 Kim Ho * javax/swing/DefaultDesktopManager.java: (findMinimum): Removed. (resizeFrame): Trust the UI to pass valid bounds. * javax/swing/JOptionPane.java: Implemented showInternalXXXDialog methods. (startModal): New method. * javax/swing/plaf/basic/BasicInternalFrameUI.java: (BorderListener::mouseDragged): Verify that the new bounds are valid before passing them to the DesktopManager. (preferredLayoutSize): Delegate to getSize. (minimumLayoutSize): Ditto. (getSize): New method. (GlassPaneDispatcher): Reimplemented by copying a stripped down LightweightDispatcher from Container. (getMinimumSize): Call minimumLayoutSize. * javax/swing/plaf/basic/BasicOptionPaneUI.java: Ran Jalopy. (mousePressed): Add ability to properly close JInternalFrames. * javax/swing/plaf/basic/BasicToolBarUI.java: (DragWindow): Set owner for DragWindow. 2004-07-21 Jerry Quinn * java/awt/image/ShortLookupTable.java: New file. * java/awt/image/ByteLookupTable.java: New file. * Makefile.am: Added new files. * Makefile.in: Regenerated. 2004-07-21 David Jee * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java (create(GtkContainerPeer)): New native method. (create()): Call native create(), passing in the parent frame as the paramter. Natively set the current file and directory. (setFile): Construct an absolute filename before passing it to the native peer. (nativeGetDirectory): New method. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (window_closed): Removed. (ok_clicked): Likewise. (cancel_clicked): Likewise. (handle_response): New method. (create): Use GtkFileChooserDialog. (connectSignals): Connect to handle_response. (nativeGetDirectory): New method. (nativeSetFile): Use GtkFileChooserDialog. 2004-07-21 Jerry Quinn * java/awt/image/LookupTable.java: New file. * Makefile.am: Added new file. * Makefile.in: Regenerated. 2004-07-21 Jerry Quinn * java/awt/image/Kernel.java: New file. * Makefile.am: Added new file. * Makefile.in: Regenerated. 2004-07-21 Olga Rodimina * javax/swing/JCheckBoxMenuItem.java: Fixed Javadocs. * javax/swing/JMenu.java: Likewise. * javax/swing/JMenuBar.java: Likewise. (MARGIN_CHANGED_PROPERTY): New property. (setMargin): Implemented. * javax/swing/JMenuItem.java: Fixed javadocs. * javax/swing/JPopupMenuUI.java: Fixed javadocs. (LABEL_CHANGED_PROPERTY): New property. (add): changed to use createActionComponent. (createActionComponent): Implemented. (setLabel): Fire PropertyChangeEvent if label property changes. * javax/swing/JRadioButtonMenuItem.java: Fixed javadocs. * javax/swing/plaf/basic/BasicMenuBarUI.java: Likewise. (ContainerHandler): Repaint if margin property has changed. * javax/swing/plaf/basic/BasicMenuItemUI.java: (installUI): Call installComponents(). (uninstallUI): Call uinstallComponents(). * javax/swing/plaf/basic/BasicMenuUI.java: Fixed javadocs. * javax/swing/plaf/basic/BasicPopupMenuUI.java: Likewise. 2004-07-21 Kim Ho * javax/swing/plaf/basic/BasicToolBarUI.java: (DragWindow): Use the right constructor. 2004-07-21 Kim Ho * javax/swing/JToolBar.java: (layoutContainer): Use getComponents. * javax/swing/plaf/basic/BasicToolBarUI.java: (DragWindow): Don't use SwingUtilities' getOwnerFrame (ToolBarDialog): ditto. 2004-07-21 Kim Ho * javax/swing/JRootPane.java: Ran jalopy. (layoutContainer): Set the glasspane's size to be the same as the content pane. (createGlassPane): Set opaque property to false. 2004-07-21 Thomas Fitzsimmons * java/awt/Component.java (requestFocus()): Don't handle Panels specially. (requestFocus(boolean)): Likewise. (requestFocusInWindow(boolean)): Likewise. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c (create): Set GTK_CAN_FOCUS flag. 2004-07-21 Kim Ho * Makefile.am: Added new file. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * javax/swing/AbstractButton.java: Add rollOverEnabled property. (setRolloverEnabled): Use new property. (isRolloverEnabled): Use new property. * javax/swing/JTabbedPane.java: (setComponent): Remove useless JTabbedPane.this. * javax/swing/JToolBar.java: Finish implementation. * javax/swing/plaf/basic/BasicArrowButton.java: (paint): Moved border painting to a border. * javax/swing/plaf/basic/BasicLookAndFeel.java: Change JToolBar look and feel defaults. * javax/swing/plaf/basic/BasicOptionPaneUI.java (actionPerformed): Return Integer index instead of name. (addButtonComponents): Check to see if component is JButton last. (createMessageArea): Don't use components that are not completed yet. (getIconForType): Use temporary icons. * javax/swing/plaf/basic/BasicSliderUI.java: (mousePressed): Do not return if it's on thumb. (paintMinorTickForHorizSlider): Use BLACK to paint ticks. (paintMinorTickForVertSlider): ditto. (paintMajorTickForHorizSlider): ditto. (paintMajorTickForVertSlider): ditto. * javax/swing/plaf/basic/BasicSplitPaneDivider.java: Add a border around the SplitPaneDivider. * javax/swing/plaf/basic/BasicSplitPaneUI.java: Remove comments. * javax/swing/plaf/basic/BasicToolBarSeparatorUI.java: New file. Implemented. * javax/swing/plaf/basic/BasicToolBarUI.java: Implemented. * testsuite/Makefile.in: Regenerated. 2004-07-21 Graydon Hoare * javax/swing/Timer.java (run): Queue events each time cycle. 2004-07-21 David Jee * gnu/java/awt/peer/gtk/GtkImagePainter.java (imageComplete): Call image.imageComplete(). * java/awt/image/MemoryImageSource.java: Reimplement consumers as a Vector instead of a Hashtable. This is because enumeration on a Hashtable is not thread-safe. (addConsumer): Adapt to Vector consumers. (isConsumer): Adapt to Vector consumers. (removeConsumer): Adapt to Vector consumers. (startProduction): Adapt to Vector consumers. Call imageComplete() with STATICIMAGEDONE flag instead of SINGLEFRAME flag. (newPixels): Adapt to Vector consumers. (sendPicture): Set the color model of the image consumer. (newPixels(IIII)): Adapt to Vector consumers. (newPixels(IIIIB)): Adapt to Vector consumers. 2004-07-21 Thomas Fitzsimmons * java/awt/Component.java (deliverEvent): Implement. (postEvent): Implement. (handleEvent): Implement. (translateEvent): New method. (dispatchEventImpl): Document. Add AWT 1.0 event handling. * java/awt/Container.java (deliverEvent): Implement. * java/awt/Event.java (paramString): Fix formatting. * java/awt/Font.java (toString): Likewise. * java/awt/Window.java (postEvent): Implement. 2004-07-21 Thomas Fitzsimmons * java/awt/DefaultKeyboardFocusManager.java (dispatchEvent): Set window's focus owner upon receiving a FOCUS_LOST event. * java/awt/Window.java (Window()): Refocus the previously focused component within the window when the window regains the top-level focus. (setFocusOwner): New method. * java/awt/Component.java (requestFocus): Add FIXME. * libgcj.pc.in: Remove library flags. 2004-07-21 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GtkPanelPeer.java (handleEvent): Handle MOUSE_PRESSED event. * java/awt/Component.java (requestFocus()): Handle Panel specially. Post FOCUS_LOST event on opposite component. (requestFocus(boolean)): Likewise. (requestFocusInWindow(boolean)): Likewise. (paramString): Reorder dimension fields. * java/awt/Container.java (paramString): Fix string format. * java/awt/DefaultKeyboardFocusManager.java (dispatchEvent): Handle FOCUS_LOST events. Don't handle Windows specially. Only process key events if the focus owner is non-null. (dispatchKeyEvent): Likewise. * java/awt/Frame.java (paramString): Fix formatting. (generateName): New method. (getUniqueLong): Likewise. * java/awt/KeyboardFocusManager.java (getFocusOwner): Check if the temporary focus owner is null. If so, return the permanent focus owner. * java/awt/Panel.java (generateName): New method. (getUniqueLong): Likewise. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: Rework signal handling to make callbacks more specific. 2004-07-21 Michael Koch * javax/swing/text/Position.java (Bias): Implemented. 2004-07-21 Michael Koch * javax/swing/LookAndFeel.java (provideErrorFeedback): New method. 2004-07-21 Michael Koch * javax/swing/JTextArea.java (tabSize): New field. (getTabSize): New method. (setTabSize): Likewise. 2004-07-21 Michael Koch * javax/swing/ActionMap.java: Fixed javadocs all over. (serialVersionUID): Made private. (parent): Don't explicitely initialize with default value. (get): SImplified. (keys): Reimplemented. (allKeys): Likewise. (convertSet): Removed. * javax/swing/ComponentInputMap.java: Fixed javadocs all over. (ComponentInputMap): Implemented. (put): Likewise. (clear): Likewise. (remove): Likewise. (SetParent): Likewise. (getComponent): Likewise. * javax/swing/InputMap.java: Fixed javadocs all over. (serialVersionUID): Made private. (parent): Don't explicitely initialize with default value. (get): SImplified. (keys): Reimplemented. (allKeys): Likewise. (convertSet): Removed. 2004-07-21 Michael Koch * javax/swing/ActionMap.java, javax/swing/ComponentInputMap.java, javax/swing/InputMap.java, javax/swing/table/DefaultTableColumnModel.java, javax/swing/table/TableColumn.java, javax/swing/table/TableColumnModel.java, javax/swing/table/TableModel.java, javax/swing/text/AbstractDocument.java, javax/swing/text/TextAction.java: Reformated. 2004-07-21 Graydon Hoare * gnu/java/awt/peer/gtk/GtkToolkit.java (bufferedImageOrError): Make method non-static. * javax/swing/AbstractButton.java: Rename fields to match property names where possible. (iconTextGap): New property. * javax/swing/JCheckBox.java: Match AbstractButton changes. (init) New method, call from after various constructors. * javax/swing/JComponent.java (revalidate): Invalidate before queueing repair. * javax/swing/JList.java (getPreferredScrollableViewportSize): Reimplement in terms of visibleRowCount property. * javax/swing/JMenuButton.java: Match AbstractButton changes. * javax/swing/JScrollPane.java (createScrollListener): Remove tracing chatter. * javax/swing/JToggleButton.java: Match AbstractButton changes. * javax/swing/RepaintManager.java (addInvalidComponent): Don't invalidate. * javax/swing/ScrollPaneLayout.java: Various corrections to layout calculations. * javax/swing/SwingUtilities.java (layoutCompoundLabel): Mimic sun behavior on top left/right positioning. * javax/swing/ViewportLayout.java (preferredLayoutSize): Remove mistaken use of preferredScrollableViewportSize here. (layoutContainer): Use view's preferred size as basis. * javax/swing/plaf/basic/BasicButtonUI.java: Set, get, and use textIconGap property. (paint) Paint text returned from layout (with ellipsis). * javax/swing/plaf/basic/BasicListUI.java: Remove tracing chatter, correct various minor calculations. (getCellBounds): Update layout state before calculating. * javax/swing/plaf/basic/BasicLookAndFeel.java (Button.Margin): Use margin default similar to sun's. * javax/swing/plaf/basic/BasicScrollBarUI.java (ArrowIcon): (createIncreaseIcon): Center icon, minimize margins. (createDecreaseIcon): Likewise. * javax/swing/plaf/basic/BasicScrollPaneUI.java (installDefaults): Implement. (installUI): Call it. (uninstallDefaults): Implement. (uninstallUI): Call it. * javax/swing/plaf/basic/BasicToolBarUI.java (DragWindow): Call existing Window constructor. * javax/swing/plaf/basic/BasicViewportUI.java (paint): Set clip before painting. 2004-07-21 Olga Rodimina * javax/swing/JMenuItem.java: (processMouseEvent): Reimplemented to deal with mouse drag events. (createMenuDragMouseEvent): New private helper method. Creates MenuDragMouseEvent. * javax/swing/MenuSelectionManager.java (componentForPoint): Implemented. (isComponentPartOfCurrentMenu): Made public. (processMouseEvent): Reimplemented to deal with mouse drag events. (setSelectedPath): Corrected small mistake that caused path to be set incorrectly. (getPath): If given component is JMenu then also add this menu's popup menu to the selected path. * javax/swing/plaf/basic/BasicMenuItemUI.java: (getPath): Ditto. (getPreferredSize): Call getPreferredMenuItemSize(). (getPreferredItemSize): Moved code from getPreferredSize to here. (installListeners): Install MouseMotionListeners. (MouseInputHandler): Pass mouse release event to MenuSelectionManager if mouse wasn't released in the bounds of this menu item. (MenuDragMouseHandler): Implemented. * javax/swing/plaf/basic/BasicMenuUI.java: (installListeners): Install MouseMotionListener and MenuDrageMouseListener. (MenuDragMouseHandler): Implemented. * javax/swing/plaf/basic/BasicPopupMenuUI.java: (uninstallListeners): Implemented. 2004-07-21 Michael Koch * javax/swing/JCheckBox.java: Reformated. (JCheckBox): Fixed all constructors. (isBorderPaintedFlat): New method. (setBorderPaintedFlat): New method. * javax/swing/JEditorPane.java (createEditorKitForContentType): Made public. (scrollToReference): Likewise. * javax/swing/JTextArea.java (setLineWrap): Fire property change. * javax/swing/JToggleButton.java (JToggleButton): New constructor. (JToggleButton): Simplified. * javax/swing/text/AttributeSet.java (FontAttribute): Renamed from FontCharacterAttribute. * javax/swing/text/JTextComponent.java (KeyBinBinding): Added javadoc. (JTextComponent): Likewise. (getAccessibleContext): Fixed javadoc. * javax/swing/text/View.java (View): Added javadoc. * javax/swing/text/TabableView.java: New file. * Makefile.am: Added javax/swing/text/TabableView.java. * Makefile.in: Regenerated. 2004-07-21 Graydon Hoare * java/awt/image/BufferedImage.java (getSource): Remove tracing chatter. * gnu/java/awt/peer/gtk/GtkToolkit.java (GtkErrorImage): New helper class. (bufferedImageOrError): New helper method. (createImage): Use it. 2004-07-21 David Jee * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c (setCaretPosition): Scroll the text view so the new caret position is visible on screen. 2004-07-21 David Jee * gnu/java/awt/peer/gtk/GtkContainerPeer.java (setBounds): Do not validate awtComponent here. * gnu/java/awt/peer/gtk/GtkScrollPanePeer.java (getPreferredSize): New method. * java/awt/ScrollPane.java (ScrollPane): Set default size to 100x100. (addNotify): If child is not a Panel, wrap it with a new Panel. (paramString): Implement. 2004-07-21 Olga Rodimina * javax/swing/JMenu.java: (setSelected): Display popup menu only if this menu is showing on the screen. * javax/swing/JPopupMenu.java: (processMouseEvent): Added comment. (processKeyEvent): Likewise. * javax/swing/MenuSelectionManager.java: (clearSelectedPath): Only fireStateChanged() after selected path was changed, not before. (setSelectedPath): Likewise. * javax/swing/plaf/basic/BasicMenuItemUI.java: (paintMenuItem): Corrected position of menu item's icon. * javax/swing/plaf/basic/BasicPopupMenuUI.java: (installUI): Correct setDefaultLightWeightPopupEnabled call. (popupMenuCanceled): Reimplemented. (popupMenuWillBecomeVisible): Select first menu item by default when displaying free floating popup menus. (TopWindowListener): Reimplemented. 2004-07-21 Thomas Fitzsimmons * java/awt/Panel.java (dispatchEventImpl): Override to prevent Panel from being painted twice when it is first shown. 2004-07-21 Olga Rodimina * java/awt/Window.java: Reverted changes from my previous patch for creating window without an owner. * javax/swing/SwingUtilities.java: (SwingUtilities.OwnerFrame): made static. (OwnerFrame.setVisible): New method. Overridden with empty implementation. (OwnerFrame.isShowing): New method. Ovverridden to return always true. 2004-07-21 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GtkComponentPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (GtkComponentPeer): Remove temporary try/catch block. (setVisible): Call show and hide. (show): Make native. (hide): Likewise. (getArgs): Don't add "visible" argument. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (property_notify_predicate): Return Bool instead of int. (find_layout): New function. (connectJObject): Call find_layout. (connectSignals): Likewise. (moveLayout): Likewise. (gtkLayoutSetVisible): Likewise. 2004-07-21 Mark Wielaard * java/awt/event/InvocationEvent.java (dispatch): Synchronize on notifier object before calling notifyAll(). 2004-07-21 Olga Rodimina * java/awt/Window.java: Changed constructors to use new method that is described below. Constructors call this methods only if newly created window should have an owner. (setWindowOwner): New method. Implementation for this method is moved from this(owner,configuration). * javax/swing/JWindow.java: (JWindow): Reimplement to use SwingUtilities.ownerFrame instead of owner. * javax/swing/SwingUtilities.java: (ownerFrame): Change type of this field to OwnerFrame. (getOwnerFrame): Changed to return object of type OwnerFrame. (SwingUtilities.OwnerFrame): New class. Represents owner of a Window that is not provided with one. 2004-07-21 Olga Rodimina * javax/swing/AbstractButton.java: (configurePropertiesFromAction): Set action command to button's text by default if action command is not explicitely specified. * javax/swing/JMenu.java: Remove unnecessary listener and methods relevant to it. (setSelected): Reimplemented. (menuSelectionChanged): Moved most part of implementation to setSelected() and call it instead. * javax/swing/JMenuItem.java: (init): Comment out statement that sets paint_border to false. (configurePropertiesFromAction): Do not set accelerator for JMenu. (menuSelectionChanged): Change selected index in the selection model of menu item's parent. * javax/swing/JPopupMenu.java: (remove): Set constraints.fill field to GridBagConstraints.BOTH instead of GridBagConstraints.HORIZONTAL. (insert): Likewise. (createActionChangeListener): Implemented. (setVisible): Correct location of HeavyWeightMenu and don't firePopupMenuCanceled(). (menuSelectionChanged): Implemented. (ActionChangeListener): New Listener. Implemented. * javax/swing/plaf/basic/BasicMenuBarUI.java: (BasicMenuBarUI.ContainerHandler): Implemented. * javax/swing/plaf/basic/BasicMenuItemUI.java: (paintMenuItem): Uncommented out code that paints icon, now that icons are working properly. (PropertyChangeListener): Implemented. * javax/swing/plaf/basic/BasicPopupMenuUI.java: Added javadocs. (topWindowListener): New field. (Constructor): initialize topWindowListener. (BasicPopupMenuUI.TopWindowListener): Implemented. (BasicPopupMenuUI.PopupMenuHandler): Implemented. (BasicPopupMenuUI.TopWindowListener): New ComponentListener. Implemented. 2004-07-21 Michael Koch * javax/swing/plaf/basic/BasicButtonUI.java (paintFocus): Fixed method signature. (paintButtonPressed): Likewise. (paintButtonNormal): Likewise. (paintText): New method. * javax/swing/plaf/basic/BasicLabelUI.java (paint): Re-indented. * javax/swing/plaf/basic/BasicTextUI.java (installUI): Set parent textComponent to opaque. * javax/swing/text/DefaultHighlighter.java (checkPositions): New helper method. (addHighlight): Throws BadLocationException, check positions. (changeHighlight): Likewise. * javax/swing/text/EditorKit.java (EditorKit): Implements Serializable. * javax/swing/text/JTextComponent.java (getUI): Added javadoc. (setUI): Likewise. (upadteUI): Added javadoc, don't revalidate and repaint. 2004-07-21 David Jee * java/awt/GridBagLayout.java (ArrangeGrid): Use PREFERREDSIZE instead of MINSIZE. * javax/swing/AbstractButton.java (setText): Reindent. * javax/swing/RepaintManager.java (addInvalidComponent): Find the first ancestor that isValidateRoot(). 2004-07-21 Michael Koch * javax/swing/JFormattedTextField.java (value): New field. (JFormattedTextField): Implemented. (getValue): Likewise. (setValue): Likewise. * javax/swing/LookAndFeel.java (getSupportsWindowDecorations): New method. * javax/swing/UIDefaults.java: Use java.beans.PropertyChangeSupport instead of doing all ourself. (addPropertyChangeListener): Made public. (addResourceBundle): Likewise. (removeResourceBundle): Likewise. (setDefaultLocale): Likewise. * javax/swing/plaf/basic/BasicRootPaneUI.java (BasicRootPaneUI): Implements PropertyChangeListener. (propertyChange): New method. * javax/swing/plaf/basic/BasicTextUI.java (BasicHighlighter): New inner class. (createHighlighter): New method. * javax/swing/plaf/basic/BasicToolBarUI.java (DragWindow): Extends java.awt.Window. * javax/swing/text/JTextComponent.java (getDocument): Removed debug output. * javax/swing/plaf/basic/BasicTextFieldUI.java, javax/swing/text/DefaultHighlighter.java, javax/swing/text/FieldView.java, javax/swing/text/PlainView.java: New files. * Makefile.am: Added new files. * Makefile.in: Regenerated. 2004-07-21 Michael Koch * javax/swing/JEditorPane.java (createDefaultEditorKit): Use javax.swing.text.DefaultEditorKit. (createEditorKitForContentType): Likewise. * javax/swing/text/DefaultEditorKit.java (serialVersionUID): Added constant field. (EndOfLineStringPropery): Fixed typo. (DefaultEditorKit): New constructor. * javax/swing/text/Segment.java: Import java.text.CharacterIterator. * javax/swing/text/CharacterIterator.java, javax/swing/text/PlainEditorKit.java: Removed. * Makefile.am: Removed javax/swing/text/CharacterIterator.java and javax/swing/text/PlainEditorKit.java. * Makefile.in: Regenerated. 2004-07-21 Michael Koch * javax/swing/JButton.java, javax/swing/text/DefaultEditorKit.java, javax/swing/text/EditorKit.java, javax/swing/text/Segment.java, javax/swing/text/StyledEditorKit.java: Reformatted. 2004-07-21 Michael Koch * javax/swing/ImageIcon.java (file): Removed. (description): Renamed from descr. (ImageIcon): Added missing constructors. (setParent): Removed. (setImageObserver): New method. (getImageObserver): New method. (paintIcon): Handle observer = null. * javax/swing/JButton.java (removeNotify): Fixed javadoc. (updateUI): Simplified. * javax/swing/JRootPane.java (serialVersionUID): New constant field. * javax/swing/UIManager.java: Fixed javadocs all over. (setLookAndFeel): Throws UnsupportedLookAndFeelException. * javax/swing/text/AbstractDocument.java (createPosition): Throws BadLocationException. (getText): Likewise. (remove): Likewise. * javax/swing/text/ComponentView.java (modelToView): Likewise. * javax/swing/text/DefaultEditorKit.java: Made all public methods public. (read): Throws BadLocationException and IOException. (write): Likewise. * javax/swing/text/EditorKit.java: Made all public methods public. (serialVersionUID): New constant field. (clone): New method. (read): Throws BadLocationException and IOException. (write): Likewise. * javax/swing/text/Segment.java (array): Made public. (count): Likewise. (offset): Likewise. (Segment): New constructors. (clone): Reimplemented. * javax/swing/text/StyledEditorKit.java (serialVersionUID): New constant field. 2004-07-21 Graydon Hoare * java/awt/image/BufferedImage.java (getSource): Implement. * javax/swing/ImageIcon.java (ImageIcon): Implement ctor. * javax/swing/ScrollPaneLayout.java (preferredLayoutSize): Be more careful about nulls. 2004-07-21 Michael Koch * javax/swing/text/AttributeSet.java (CharacterAttribute): New interface (ColorAttribute): Likewise. (FontCharacterAttribute): Likewise. (ParagraphAttribute): Likewise. * javax/swing/text/DefaultCaret.java (moveCaret): New method. (positionCaret): Likewise. (repaint): Made protected. * javax/swing/text/JTextComponent.java (KeyBinding): Made it static. * javax/swing/text/View.java (getContainer): Honor parent == null. 2004-07-21 Michael Koch * javax/swing/text/AbstractDocument.java: Reformatted. 2004-07-21 Michael Koch * javax/swing/plaf/basic/BasicRootPaneUI.java: Import javax.swing.UIManager explicitely. * javax/swing/plaf/basic/BasicTabbedPaneUI.java (ScrollingButton): Made it static. 2004-07-21 Michael Koch * javax/swing/UIDefaults.java (ActiveValue): Made public. (LazyValue): Likewise. * javax/swing/plaf/basic/BasicTextUI.java (RootView): Reintroduced. (view): Removed. (rootView): New field. (installUI): Create document if needed, initialize rootView. (uninstallUI): Hanle rootView. (paint): Likewise. (getRootView): Likewise. (setView): Likewise. * javax/swing/text/DefaultCaret.java: Renamed all "evt" variables to "event". 2004-07-21 Thomas Fitzsimmons * libgcj.spec.in: Add -l-java-util-logging. 2004-07-21 Andreas Tobler * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c (init_dpi_conversion_factor): Check for int_dpi < 0 in case gtk-xft-dpi can no calculate the right value. (dpi_changed_cb): Mark *pspec as unsused. 2004-07-21 David Jee * java/awt/Component.java (move): Delegate to setBounds(). (resize): Likewise. (reshape): Fix so it repaints parent and self only when necessary. 2004-07-21 David Jee * gnu/java/awt/peer/gtk/GtkComponentPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (GtkComponentPeer): Revert previous patch from 2004-06-22. (setVisible): Likewise. (show): Likewise. (hide): Likewise. (getArgs): Likewise. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (property_notify_predicate): Likewise. (find_layout): Likewise. (connectJObject): Likewise. (connectSignals): Likewise. (moveLayout): Likewise. (gtkLayoutSetVisible): Likewise. 2004-07-21 Graydon Hoare * Makefile.am (jv_convert_LDADD): (gij_LDADD): (rmic_LDADD): (rmiregistry_LDADD): Add lib-java-util-logging.la * Makefile.in: Regenerate. 2004-07-21 Michael Koch * javax/swing/text/AbstractDocument.java (replace): Dont use protected method of java.util.Vector directly. 2004-07-21 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (installUI): Call specialized install methods. (installDefaults): New method. (installListeners): Likewise. (installKeyboardActions): Likewise. (uninstallUI): Likewise. (uninstallDefaults): New method. (uninstallListeners): Likewise. (uninstallKeyboardActions): Likewise. (getPropertyPrefix): New abstract method. (paint): Made final, just call paintSafely(). (paintSavely): New method. (paintBackground): Likewise. (getVisibleEditorRect): Likewise. * javax/swing/text/LayeredHighlighter.java, javax/swing/text/TabExpander.java: New files. * Makefile.am: Added javax/swing/text/LayeredHighlighter.java and javax/swing/text/TabExpander.java. * Makefile.in: Regenerated. 2004-07-21 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (BasicTextUI): Made abstract. (BasicCaret): New inner class. (view): Don't explicitely initialize with "null". (textComponent): New field. (textColor): Removed. (disabledTextColor): Removed. (normalBackgroundColor): Removed. (RootView): Removed commented out inner class. (createUI): Removed. (createCaret): New method. (getComponent): Likewise. (installUI): Initialize textComponent only. (getPreferredSize): Use installed JTextComponent. (setView): New method. (create): Likewise. * javax/swing/text/JTextComponent.java (highlighter): New field. (caretColor): Likewise. (disabledTextColor): Likewise. (seletedTextColor): Likewise. (selectionColor): Likewise. (setUI): New method. (getCaretColor): Likewise. (setCaretColor): Likewise. (getDisabledColor): Likewise. (setDisabledColor): Likewise. (getSelectedTextColor): Likewise. (setSelectedTextColor): Likewise. (getSelectionColor): Likewise. (setSelectionColor): Likewise. (getHighlighter): Likewise. (setHighlighter): Likewise. (replaceSelection): Likewise. 2004-07-21 Michael Koch * javax/swing/plaf/basic/BasicScrollPaneUI.java (BasicScrollPaneUI): Implements ScrollPaneConstants. * javax/swing/plaf/basic/BasicToolBarUI.java (BasicToolBarUI): Implements SwingConstants. 2004-07-21 Michael Koch * javax/swing/JPopupMenu.java: Removed CVS tags. * javax/swing/UIDefaults.java: Reformatted. * javax/swing/plaf/basic/BasicRootPaneUI.java: Explicitely import used classes. 2004-07-21 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GtkComponentPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (GtkComponentPeer): Remove temporary try/catch block. (setVisible): Call show and hide. (show): Make native. (hide): Likewise. (getArgs): Don't add "visible" argument. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (property_notify_predicate): Return Bool instead of int. (find_layout): New function. (connectJObject): Call find_layout. (connectSignals): Likewise. (moveLayout): Likewise. (gtkLayoutSetVisible): Likewise. 2004-07-21 Olga Rodimina * javax/swing/AbstractButton.java: (setDisplayedMnemonicIndex): Check if button text is not null before checking its length. * javax/swing/JMenuItem.java: (processMouseEvent): Disarm menu item if mouse has exited it. * javax/swing/plaf/basic/BasicMenuUI.java: (MouseInputHandler.mouseEntered): Do not raise popup menu if this menu is already selected. (MouseInputHandler.mousePressed): Do not fire MenuEvents. (MenuHandler): Implemented. 2004-07-21 Olga Rodimina * javax/swing/JCheckBoxMenuItem.java: Added Javadoc. (getSelectedObjects): Implemented. * javax/swing/JRadioButtonMenuItem.java: Added Javadoc. * javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java: Added javadoc for few methods. (processMouseEvent): Made public. * javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java (processMouseEvent): Likewise. 2004-07-21 Olga Rodimina * javax/swing/AbstractButton.java: (init): Set display mnemonic index to -1. (setMnemonic(char)): Use setMnemonic(int). (setMnemonic(int)): Set display mnemonic index. (getDisplayedMnemonicIndex): Change method signature by removing 'index' parameter. * javax/swing/plaf/basic/BasicLookAndFeel.java: Added default for Menu.selectionBackground. * javax/swing/plaf/basic/BasicMenuItemUI.java: (paintMenuItem): Change background color of the selected menu item. (paintText): Paint differently when menu item is disabled. Also paint mnemonic if it appears in the menu item's label. (paintAccelerator): Paint accelerator differently if menu item is disabled. * javax/swing/plaf/basic/BasicMenuUI.java: (installDefaults): Install defaults for selectionForeground and selectionBackground. (uninstallDefaults): Uninstall defauls for selectionForeground and selectionBackground. 2004-07-21 Michael Koch * javax/swing/text/AbstractDocument.java (BranchElement): Implemented. (LeafElement): Implemented. * javax/swing/text/DefaultCaret.java: Import used classes. (serialVersionUID): New constant. * javax/swing/text/JTextComponent.java (AccessibleJTextComponent): Removed dead declaration. (caretPos): Removed. (setCaret): New method. * javax/swing/text/PlainDocument.java (rootElement): New field. (PlainDocument): Initialize rootElement. (createDefaultRoot): New method. (getDefaultRootElement): Implemented. * javax/swing/text/View.java: Reformatted. * javax/swing/text/ViewFactory.java (create): Added javadoc. 2004-07-21 Michael Koch * javax/swing/ToolTipManager.java: Reformatted. 2004-07-21 Rodimina Olga * javax/swing/AbstractButton.java (changeEvent): New field. (fireItemStateChanged): Change source of the event to 'this' before firing it to button listeners. (fireActionPerformed): Likewise. (fireStateChanged): Likewise. (createActionListener): Do not set source of the event to AbstractButton. * javax/swing/plaf/basic/BasicMenuBarUI.java: (ContainerHandler.componentAdded): Removed print out statement. (ContainerHandler.componentRemoved): Likewise. 2004-07-21 Michael Koch * javax/swing/text/Highlighter.java: New file. * Makefile.am: Added javax/swing/text/Highlighter.java. * Makefile.in: Regenerated. 2004-07-21 Michael Koch * javax/swing/ToolTipManager.java (stillInsideTimerAction): Fixed constructor arguments. (outsideTimerAction): Likewise. (insideTimerAction): Likewise. 2004-07-21 Michael Koch * javax/swing/JButton.java: Reformatted. * javax/swing/JFormattedTextField.java (getUIClassID): Implemented. * javax/swing/JRootPane.java (serialVersionUID): New constant. * javax/swing/JTextField.java (align): New field. (JTextField): Simplified. (getUIClassID): New method. (getActionListeners): Added @since tag. (setColumns): Invalidate layout and repaint. (getHorizontalAlignment): New method. (setHorizontalAlignment): New method. (selectAll): Removed. * javax/swing/SwingUtilities.java (getAncestorOfClass): Removed redundant @see tag. (isLeftMouseButton): Fixed implementation. (isMiddleMouseButton): Likewise. (isRightMouseButton): Likewise. * javax/swing/text/AbstractDocument.java (AttributeContext.addAttribute): New method. (AttributeContext.addAttributes): New method. (AttributeContext.getEmptySet): New method. (AttributeContext.reclaim): New method. (AttributeContext.removeAttribute): New method. (AttributeContext.removeAttributes): New method. * javax/swing/text/Document.java (createPosition): Throws BadLocationException. (getText): Likewise. (remove): Likewise. * javax/swing/text/JTextComponent.java (getText): Return null if no document is set. Catch BadLocationException. (getUI): Return ui. (updateUI): Simplified. 2004-07-21 Michael Koch * javax/swing/JButton.java (removeNotify): Fixed javadoc. (updateUI): Simplified. 2004-07-21 David Jee * gnu/java/awt/image/ImageDecoder.java (startProduction): Only add consumer if it's not added yet. * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java (GdkPixbufDecoder): Don't call initState() here. (produce): Call initState() here, to ensure area_prepared and area_updated signals are properly connected. * gnu/java/awt/peer/gtk/GtkImage.java (setColorModel): Use equals() to compare ColorModel objects. (setPixels): Likewise. * java/awt/image/ColorModel.java (equals): Fix typo. Use Arrays.equals() to compare int arrays. * java/awt/image/RGBImageFilter.java (setColorModel): Set consumer's color model. (setPixels): Use equals() to compare ColorModel objects. From-SVN: r85051 --- libjava/javax/swing/text/AbstractDocument.java | 557 +++++++++++++---------- libjava/javax/swing/text/AttributeSet.java | 16 + libjava/javax/swing/text/CharacterIterator.java | 53 --- libjava/javax/swing/text/ComponentView.java | 1 + libjava/javax/swing/text/DefaultCaret.java | 32 +- libjava/javax/swing/text/DefaultEditorKit.java | 55 ++- libjava/javax/swing/text/DefaultHighlighter.java | 150 ++++++ libjava/javax/swing/text/Document.java | 12 +- libjava/javax/swing/text/EditorKit.java | 52 ++- libjava/javax/swing/text/FieldView.java | 97 ++++ libjava/javax/swing/text/Highlighter.java | 80 ++++ libjava/javax/swing/text/JTextComponent.java | 162 ++++++- libjava/javax/swing/text/LayeredHighlighter.java | 61 +++ libjava/javax/swing/text/PlainDocument.java | 14 +- libjava/javax/swing/text/PlainEditorKit.java | 103 ----- libjava/javax/swing/text/PlainView.java | 122 +++++ libjava/javax/swing/text/Position.java | 16 +- libjava/javax/swing/text/Segment.java | 38 +- libjava/javax/swing/text/StyledEditorKit.java | 411 ++++++----------- libjava/javax/swing/text/TabExpander.java | 43 ++ libjava/javax/swing/text/TabableView.java | 44 ++ libjava/javax/swing/text/TextAction.java | 45 +- libjava/javax/swing/text/View.java | 114 +++-- libjava/javax/swing/text/ViewFactory.java | 9 +- 24 files changed, 1488 insertions(+), 799 deletions(-) delete mode 100644 libjava/javax/swing/text/CharacterIterator.java create mode 100644 libjava/javax/swing/text/DefaultHighlighter.java create mode 100644 libjava/javax/swing/text/FieldView.java create mode 100644 libjava/javax/swing/text/Highlighter.java create mode 100644 libjava/javax/swing/text/LayeredHighlighter.java delete mode 100644 libjava/javax/swing/text/PlainEditorKit.java create mode 100644 libjava/javax/swing/text/PlainView.java create mode 100644 libjava/javax/swing/text/TabExpander.java create mode 100644 libjava/javax/swing/text/TabableView.java (limited to 'libjava/javax/swing/text') diff --git a/libjava/javax/swing/text/AbstractDocument.java b/libjava/javax/swing/text/AbstractDocument.java index 5612fc9..c1ea098 100644 --- a/libjava/javax/swing/text/AbstractDocument.java +++ b/libjava/javax/swing/text/AbstractDocument.java @@ -42,7 +42,6 @@ import java.util.Dictionary; import java.util.Enumeration; import java.util.EventListener; import java.util.Vector; - import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.EventListenerList; @@ -57,232 +56,15 @@ import javax.swing.undo.UndoableEdit; public abstract class AbstractDocument implements Document, Serializable { - public abstract class AbstractElement - implements Element, TreeNode, Serializable - { - private static final long serialVersionUID = 1265312733007397733L; - - int count; - int offset; - AttributeSet attr; - Vector elts = new Vector(); - String name; - Element parent; - Vector kids = new Vector(); - TreeNode tree_parent; - - public AbstractElement(Element p, AttributeSet s) - { - parent = p; - attr = s; - } - - public Enumeration children() - { - return kids.elements(); - } - - public boolean getAllowsChildren() - { - return true; - } - - public TreeNode getChildAt(int index) - { - return (TreeNode) kids.elementAt(index); - } - - public int getChildCount() - { - return kids.size(); - } - - public int getIndex(TreeNode node) - { - return kids.indexOf(node); - } - - public TreeNode getParent() - { - return tree_parent; - } - - public AttributeSet getAttributes() - { - return attr; - } - - public Document getDocument() - { - return AbstractDocument.this; - } - - public Element getElement(int index) - { - return (Element) elts.elementAt(index); - } - - public String getName() - { - return name; - } - - public Element getParentElement() - { - return parent; - } - - public abstract boolean isLeaf(); - - public abstract int getEndOffset(); - - public abstract int getElementCount(); - - public abstract int getElementIndex(int offset); - - public abstract int getStartOffset(); - } - - public interface AttributeContext - { - } - - public class BranchElement extends AbstractElement - { - private static final long serialVersionUID = -8595176318868717313L; - - public BranchElement(Element e, AttributeSet a, int s, int end) - { - super(e, a); - } - - public boolean isLeaf() - { - return false; - } - - public int getEndOffset() - { - return 0; - } - - public int getElementCount() - { - return 0; - } - - public int getElementIndex(int offset) - { - return 0; - } - - public int getStartOffset() - { - return 0; - } - } - - public interface Content - { - Position createPosition(int offset) throws BadLocationException; - - int length(); - - UndoableEdit insertString(int where, String str) - throws BadLocationException; - - UndoableEdit remove(int where, int nitems) throws BadLocationException; - - String getString(int where, int len) throws BadLocationException; - - void getChars(int where, int len, Segment txt) throws BadLocationException; - } - - public class DefaultDocumentEvent extends CompoundEdit - implements DocumentEvent - { - private static final long serialVersionUID = -7406103236022413522L; - - public int len; - public int off; - - public Document getDocument() - { - return AbstractDocument.this; - } - - public int getLength() - { - return len; - } - - public int getOffset() - { - return off; - } - - public DocumentEvent.EventType getType() - { - return null; - } - - public DocumentEvent.ElementChange getChange(Element elem) - { - return null; - } - } - - public static class ElementEdit extends AbstractUndoableEdit - { - private static final long serialVersionUID = -1216620962142928304L; - } - - public class LeafElement extends AbstractElement - { - private static final long serialVersionUID = 5115368706941283802L; - - public LeafElement(Element e, AttributeSet a, int s, int end) - { - super(e, a); - } - - public boolean isLeaf() - { - return true; - } - - public int getEndOffset() - { - return 0; - } - - public int getElementCount() - { - return 0; - } - - public int getElementIndex(int offset) - { - return 0; - } - - public int getStartOffset() - { - return 0; - } - } - private static final long serialVersionUID = -116069779446114664L; - protected static final String BAD_LOCATION = "document location failure"; - public static final String BidiElementName = "bidi level"; public static final String ContentElementName = "content"; public static final String ParagraphElementName = "paragraph"; public static final String SectionElementName = "section"; public static final String ElementNameAttribute = "$ename"; - Content content; + protected EventListenerList listenerList = new EventListenerList(); protected AbstractDocument(Content doc) { @@ -294,8 +76,6 @@ public abstract class AbstractDocument content = doc; } - protected EventListenerList listenerList = new EventListenerList(); - // these still need to be implemented by a derived class: public abstract Element getParagraphElement(int pos); @@ -312,14 +92,16 @@ public abstract class AbstractDocument return new LeafElement(parent, a, p0, p1 - p0); } - public Position createPosition(int offs) + public Position createPosition(final int offset) throws BadLocationException { - final int a = offs; + if (offset < 0 || offset > getLength()) + throw new BadLocationException(getText(0, getLength()), offset); + return new Position() { public int getOffset() { - return a; + return offset; } }; } @@ -416,21 +198,13 @@ public abstract class AbstractDocument return null; } - public String getText(int offset, int length) - { - try + public String getText(int offset, int length) throws BadLocationException { return content.getString(offset, length); } - catch (Exception e) - { - System.out.println("Hmmm, fail to getText: " + offset + " -> " - + length); - return null; - } - } public void getText(int offset, int length, Segment txt) + throws BadLocationException { String a = getText(offset, length); @@ -439,6 +213,7 @@ public abstract class AbstractDocument txt.offset = 0; txt.count = 0; txt.array = new char[0]; + return; } @@ -478,7 +253,7 @@ public abstract class AbstractDocument { } - public void remove(int offs, int len) + public void remove(int offset, int length) throws BadLocationException { } @@ -565,4 +340,316 @@ public abstract class AbstractDocument protected void writeUnlock() { } + + public interface AttributeContext + { + AttributeSet addAttribute(AttributeSet old, Object name, Object value); + + AttributeSet addAttributes(AttributeSet old, AttributeSet attributes); + + AttributeSet getEmptySet(); + + void reclaim(AttributeSet attributes); + + AttributeSet removeAttribute(AttributeSet old, Object name); + + AttributeSet removeAttributes(AttributeSet old, AttributeSet attributes); + + AttributeSet removeAttributes(AttributeSet old, Enumeration names); + } + + public interface Content + { + Position createPosition(int offset) throws BadLocationException; + + int length(); + + UndoableEdit insertString(int where, String str) + throws BadLocationException; + + UndoableEdit remove(int where, int nitems) throws BadLocationException; + + String getString(int where, int len) throws BadLocationException; + + void getChars(int where, int len, Segment txt) throws BadLocationException; + } + + public abstract class AbstractElement + implements Element, TreeNode, Serializable + { + private static final long serialVersionUID = 1265312733007397733L; + int count; + int offset; + AttributeSet attr; + Vector elts = new Vector(); + String name; + Element parent; + Vector kids = new Vector(); + TreeNode tree_parent; + + public AbstractElement(Element p, AttributeSet s) + { + parent = p; + attr = s; + } + + public Enumeration children() + { + return kids.elements(); + } + + public boolean getAllowsChildren() + { + return true; + } + + public TreeNode getChildAt(int index) + { + return (TreeNode) kids.elementAt(index); + } + + public int getChildCount() + { + return kids.size(); + } + + public int getIndex(TreeNode node) + { + return kids.indexOf(node); + } + + public TreeNode getParent() + { + return tree_parent; + } + + public AttributeSet getAttributes() + { + return attr; + } + + public Document getDocument() + { + return AbstractDocument.this; + } + + public Element getElement(int index) + { + return (Element) elts.elementAt(index); + } + + public String getName() + { + return name; + } + + public Element getParentElement() + { + return parent; + } + + public abstract boolean isLeaf(); + + public abstract int getEndOffset(); + + public abstract int getElementCount(); + + public abstract int getElementIndex(int offset); + + public abstract int getStartOffset(); + } + + public class BranchElement extends AbstractElement + { + private static final long serialVersionUID = -8595176318868717313L; + private int start; + private int end; + private Vector children = new Vector(); + + public BranchElement(Element parent, AttributeSet attributes, int start, + int end) + { + super(parent, attributes); + this.start = start; + this.end = end; + } + + public Enumeration children() + { + return children.elements(); + } + + public boolean getAllowsChildren() + { + return true; + } + + public Element getElement(int index) + { + return (Element) children.get(index); + } + + public int getElementCount() + { + return children.size(); + } + + public int getElementIndex(int offset) + { + return children.indexOf(positionToElement(offset)); + } + + public int getEndOffset() + { + return end; + } + + public String getName() + { + return "AbstractDocument.BranchElement"; + } + + public int getStartOffset() + { + return start; + } + + public boolean isLeaf() + { + return false; + } + + public Element positionToElement(int position) + { + // XXX: There is surely a better algorithm + // as beginning from first element each time. + for (int index = 0; index < children.size(); ++index) + { + Element elem = (Element) children.get(index); + + if ((elem.getStartOffset() <= position) + && (position < elem.getEndOffset())) + return elem; + } + + return null; + } + + public void replace(int offset, int length, Element[] elems) + { + for (int index = 0; index < length; ++index) + children.removeElementAt(offset); + + for (int index = 0; index < elems.length; ++index) + children.add(offset + index, elems[index]); + } + + public String toString() + { + return getName() + ": " + "content"; + } + } + + public class DefaultDocumentEvent extends CompoundEdit + implements DocumentEvent + { + private static final long serialVersionUID = -7406103236022413522L; + public int len; + public int off; + + public Document getDocument() + { + return AbstractDocument.this; + } + + public int getLength() + { + return len; + } + + public int getOffset() + { + return off; + } + + public DocumentEvent.EventType getType() + { + return null; + } + + public DocumentEvent.ElementChange getChange(Element elem) + { + return null; + } + } + + public static class ElementEdit extends AbstractUndoableEdit + { + private static final long serialVersionUID = -1216620962142928304L; + } + + public class LeafElement extends AbstractElement + { + private static final long serialVersionUID = 5115368706941283802L; + private int start; + private int end; + + public LeafElement(Element parent, AttributeSet attributes, int start, + int end) + { + super(parent, attributes); + this.start = start; + this.end = end; + } + + public Enumeration children() + { + return null; + } + + public boolean getAllowsChildren() + { + return false; + } + + public Element getElement() + { + return null; + } + + public int getElementCount() + { + return 0; + } + + public int getElementIndex(int offset) + { + return -1; + } + + public int getEndOffset() + { + return end; + } + + public String getName() + { + return "AbstractDocument.LeafElement"; + } + + public int getStartOffset() + { + return start; + } + + public boolean isLeaf() + { + return true; + } + + public String toString() + { + return getName() + ": " + "content"; + } + } } diff --git a/libjava/javax/swing/text/AttributeSet.java b/libjava/javax/swing/text/AttributeSet.java index 5c08a04..3c31767 100644 --- a/libjava/javax/swing/text/AttributeSet.java +++ b/libjava/javax/swing/text/AttributeSet.java @@ -41,6 +41,22 @@ import java.util.Enumeration; public interface AttributeSet { + static interface CharacterAttribute + { + } + + static interface ColorAttribute + { + } + + static interface FontAttribute + { + } + + static interface ParagraphAttribute + { + } + boolean containsAttribute(Object name, Object value); boolean containsAttributes(AttributeSet attributes); AttributeSet copyAttributes(); diff --git a/libjava/javax/swing/text/CharacterIterator.java b/libjava/javax/swing/text/CharacterIterator.java deleted file mode 100644 index 71c8d66..0000000 --- a/libjava/javax/swing/text/CharacterIterator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* CharacterIterator.java -- - Copyright (C) 2002 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 javax.swing.text; - - -public interface CharacterIterator extends Cloneable -{ - Object clone(); - char current(); - char first(); - int getBeginIndex(); - int getEndIndex(); - int getIndex(); - char last(); - char next(); - char previous(); - char setIndex(int position); -} diff --git a/libjava/javax/swing/text/ComponentView.java b/libjava/javax/swing/text/ComponentView.java index bd509b8..0305a71 100644 --- a/libjava/javax/swing/text/ComponentView.java +++ b/libjava/javax/swing/text/ComponentView.java @@ -79,6 +79,7 @@ public class ComponentView extends View } public Shape modelToView(int pos, Shape a, Position.Bias b) + throws BadLocationException { return null; } diff --git a/libjava/javax/swing/text/DefaultCaret.java b/libjava/javax/swing/text/DefaultCaret.java index 8a17a36..968bf1f 100644 --- a/libjava/javax/swing/text/DefaultCaret.java +++ b/libjava/javax/swing/text/DefaultCaret.java @@ -41,7 +41,9 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Point; import java.awt.Rectangle; +import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.EventListener; @@ -54,6 +56,8 @@ import javax.swing.event.EventListenerList; public class DefaultCaret extends Rectangle implements Caret, FocusListener, MouseListener, MouseMotionListener { + private static final long serialVersionUID = 228155774675466193L; + protected ChangeEvent changeEvent = new ChangeEvent(this); protected EventListenerList listenerList = new EventListenerList(); @@ -67,39 +71,47 @@ public class DefaultCaret extends Rectangle boolean vis = true; - public void mouseDragged(java.awt.event.MouseEvent evt) + public void mouseDragged(MouseEvent event) + { + } + + public void mouseMoved(MouseEvent event) + { + } + + public void mouseClicked(MouseEvent event) { } - public void mouseMoved(java.awt.event.MouseEvent evt) + public void mouseEntered(MouseEvent event) { } - public void mouseClicked(java.awt.event.MouseEvent evt) + public void mouseExited(MouseEvent event) { } - public void mouseEntered(java.awt.event.MouseEvent evt) + public void mousePressed(MouseEvent event) { } - public void mouseExited(java.awt.event.MouseEvent evt) + public void mouseReleased(MouseEvent event) { } - public void mousePressed(java.awt.event.MouseEvent evt) + public void focusGained(FocusEvent event) { } - public void mouseReleased(java.awt.event.MouseEvent evt) + public void focusLost(FocusEvent event) { } - public void focusGained(java.awt.event.FocusEvent evt) + protected void moveCaret(MouseEvent event) { } - public void focusLost(java.awt.event.FocusEvent evt) + protected void positionCaret(MouseEvent event) { } @@ -144,7 +156,7 @@ public class DefaultCaret extends Rectangle return vis_sel; } - private void repaint() + protected final void repaint() { if (parent != null) parent.repaint(); diff --git a/libjava/javax/swing/text/DefaultEditorKit.java b/libjava/javax/swing/text/DefaultEditorKit.java index 037ca91..8611de5 100644 --- a/libjava/javax/swing/text/DefaultEditorKit.java +++ b/libjava/javax/swing/text/DefaultEditorKit.java @@ -38,14 +38,17 @@ exception statement from your version. */ package javax.swing.text; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import javax.swing.Action; import javax.swing.JEditorPane; + public class DefaultEditorKit extends EditorKit { + private static final long serialVersionUID = 9017245433028523428L; public static final String backwardAction = "caret-backward"; public static final String beepAction = "beep"; public static final String beginAction = "caret-begin"; @@ -60,7 +63,7 @@ public class DefaultEditorKit extends EditorKit public static final String downAction = "caret-down"; public static final String endAction = "caret-end"; public static final String endLineAction = "caret-end-line"; - public static final String endOfLineStringProperty = "__EndOfLine__"; + public static final String EndOfLineStringProperty = "__EndOfLine__"; public static final String endParagraphAction = "caret-end-paragraph"; public static final String endWordAction = "caret-end-word"; public static final String forwardAction = "caret-forward"; @@ -77,16 +80,19 @@ public class DefaultEditorKit extends EditorKit public static final String selectionBackwardAction = "selection-backward"; public static final String selectionBeginAction = "selection-begin"; public static final String selectionBeginLineAction = "selection-begin-line"; - public static final String selectionBeginParagraphAction = "selection-begin-paragraph"; + public static final String selectionBeginParagraphAction = + "selection-begin-paragraph"; public static final String selectionBeginWordAction = "selection-begin-word"; public static final String selectionDownAction = "selection-down"; public static final String selectionEndAction = "selection-end"; public static final String selectionEndLineAction = "selection-end-line"; - public static final String selectionEndParagraphAction = "selection-end-paragraph"; + public static final String selectionEndParagraphAction = + "selection-end-paragraph"; public static final String selectionEndWordAction = "selection-end-word"; public static final String selectionForwardAction = "selection-forward"; public static final String selectionNextWordAction = "selection-next-word"; - public static final String selectionPreviousWordAction = "selection-previous-word"; + public static final String selectionPreviousWordAction = + "selection-previous-word"; public static final String selectionUpAction = "selection-up"; public static final String selectLineAction = "select-line"; public static final String selectParagraphAction = "select-paragraph"; @@ -94,48 +100,63 @@ public class DefaultEditorKit extends EditorKit public static final String upAction = "caret-up"; public static final String writableAction = "set-writable"; - void deinstall(JEditorPane c) + public DefaultEditorKit() + { + } + + /** + * Called when the kit is being removed from the JEditorPane. + */ + public void deinstall(JEditorPane c) { - // Called when the kit is being removed from the JEditorPane. } - void install(JEditorPane c) + + public void install(JEditorPane c) { } - Caret createCaret() + public Caret createCaret() { return null; } - Document createDefaultDocument() + + public Document createDefaultDocument() { return new PlainDocument(); } - Action[] getActions() + public Action[] getActions() { return null; } - String getContentType() + public String getContentType() { return "text/plain"; } - ViewFactory getViewFactory() + public ViewFactory getViewFactory() { return null; } - void read(InputStream in, Document doc, int pos) + + public void read(InputStream in, Document doc, int pos) + throws BadLocationException, IOException { } - void read(Reader in, Document doc, int pos) + + public void read(Reader in, Document doc, int pos) + throws BadLocationException, IOException { } - void write(OutputStream out, Document doc, int pos, int len) + + public void write(OutputStream out, Document doc, int pos, int len) + throws BadLocationException, IOException { } - void write(Writer out, Document doc, int pos, int len) + + public void write(Writer out, Document doc, int pos, int len) + throws BadLocationException, IOException { } } - diff --git a/libjava/javax/swing/text/DefaultHighlighter.java b/libjava/javax/swing/text/DefaultHighlighter.java new file mode 100644 index 0000000..003d17d --- /dev/null +++ b/libjava/javax/swing/text/DefaultHighlighter.java @@ -0,0 +1,150 @@ +/* DefaultHighlighter.java -- + Copyright (C) 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., 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 javax.swing.text; + +import java.awt.Graphics; +import java.awt.Shape; +import java.util.Vector; + +import javax.swing.text.JTextComponent; +import javax.swing.text.View; + + +public class DefaultHighlighter extends LayeredHighlighter +{ + private class HighlightEntry + { + int p0; + int p1; + Highlighter.HighlightPainter painter; + + public HighlightEntry(int p0, int p1, Highlighter.HighlightPainter painter) + { + this.p0 = p0; + this.p1 = p1; + this.painter = painter; + } + + public int getStartPosition() + { + return p0; + } + + public int getEndPosition() + { + return p1; + } + + public Highlighter.HighlightPainter getPainter() + { + return painter; + } + } + + private JTextComponent textComponent; + private Vector highlights = new Vector(); + + public DefaultHighlighter() + { + } + + private void checkPositions(int p0, int p1) + throws BadLocationException + { + if (p0 < 0) + throw new BadLocationException("DefaultHighlighter", p0); + + if (p1 < p0) + throw new BadLocationException("DefaultHighlighter", p1); + } + + public void install(JTextComponent c) + { + textComponent = c; + removeAllHighlights(); + } + + public void deinstall(JTextComponent c) + { + textComponent = null; + } + + public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter painter) + throws BadLocationException + { + checkPositions(p0, p1); + HighlightEntry entry = new HighlightEntry(p0, p1, painter); + highlights.add(entry); + return entry; + } + + public void removeHighlight(Object tag) + { + highlights.remove(tag); + } + + public void removeAllHighlights() + { + highlights.clear(); + } + + public Highlighter.Highlight[] getHighlights() + { + return null; + } + + public void changeHighlight(Object tag, int p0, int p1) + throws BadLocationException + { + checkPositions(p0, p1); + HighlightEntry entry = (HighlightEntry) tag; + entry.p0 = p0; + entry.p1 = p1; + } + + public void paintLayeredHighlights(Graphics g, int p0, int p1, + Shape viewBounds, JTextComponent editor, + View view) + { + } + + public void paint(Graphics g) + { + } +} diff --git a/libjava/javax/swing/text/Document.java b/libjava/javax/swing/text/Document.java index 6ecb7ca..d197924 100644 --- a/libjava/javax/swing/text/Document.java +++ b/libjava/javax/swing/text/Document.java @@ -50,7 +50,8 @@ public interface Document void addUndoableEditListener(UndoableEditListener listener); - Position createPosition(int offs); + Position createPosition(int offs) + throws BadLocationException; Element getDefaultRootElement(); @@ -64,16 +65,19 @@ public interface Document Position getStartPosition(); - String getText(int offset, int length); + String getText(int offset, int length) + throws BadLocationException; - void getText(int offset, int length, Segment txt); + void getText(int offset, int length, Segment txt) + throws BadLocationException; void insertString(int offset, String str, AttributeSet a) throws BadLocationException; void putProperty(Object key, Object value); - void remove(int offs, int len); + void remove(int offs, int len) + throws BadLocationException; void removeDocumentListener(DocumentListener listener); diff --git a/libjava/javax/swing/text/EditorKit.java b/libjava/javax/swing/text/EditorKit.java index acc21c1..0609332 100644 --- a/libjava/javax/swing/text/EditorKit.java +++ b/libjava/javax/swing/text/EditorKit.java @@ -38,38 +38,58 @@ exception statement from your version. */ package javax.swing.text; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.io.Reader; +import java.io.Serializable; import java.io.Writer; import javax.swing.Action; import javax.swing.JEditorPane; -public abstract class EditorKit implements Cloneable + +public abstract class EditorKit + implements Cloneable, Serializable { - EditorKit() + private static final long serialVersionUID = -5044124649345887822L; + + public EditorKit() { } - EditorKit(EditorKit kit) + public Object clone() { + try + { + return super.clone(); } - - void deinstall(JEditorPane c) + catch (CloneNotSupportedException e) { - // Called when the kit is being removed from the JEditorPane. + return null; } - void install(JEditorPane c) + } + + /** + * Called when the kit is being removed from the JEditorPane. + */ + public void deinstall(JEditorPane c) { } - abstract Caret createCaret(); - abstract Document createDefaultDocument(); - abstract Action[] getActions(); - abstract String getContentType(); - abstract ViewFactory getViewFactory(); - abstract void read(InputStream in, Document doc, int pos); - abstract void read(Reader in, Document doc, int pos); - abstract void write(OutputStream out, Document doc, int pos, int len); - abstract void write(Writer out, Document doc, int pos, int len); + public void install(JEditorPane c) + { } + public abstract Caret createCaret(); + public abstract Document createDefaultDocument(); + public abstract Action[] getActions(); + public abstract String getContentType(); + public abstract ViewFactory getViewFactory(); + public abstract void read(InputStream in, Document doc, int pos) + throws BadLocationException, IOException; + public abstract void read(Reader in, Document doc, int pos) + throws BadLocationException, IOException; + public abstract void write(OutputStream out, Document doc, int pos, int len) + throws BadLocationException, IOException; + public abstract void write(Writer out, Document doc, int pos, int len) + throws BadLocationException, IOException; +} diff --git a/libjava/javax/swing/text/FieldView.java b/libjava/javax/swing/text/FieldView.java new file mode 100644 index 0000000..29a00ac --- /dev/null +++ b/libjava/javax/swing/text/FieldView.java @@ -0,0 +1,97 @@ +/* FieldView.java -- + Copyright (C) 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., 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 javax.swing.text; + +import java.awt.Component; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Shape; + + +public class FieldView extends PlainView +{ + public FieldView(Element elem) + { + super(elem); + } + + protected FontMetrics getFontMetrics() + { + Component container = getContainer(); + return container.getFontMetrics(container.getFont()); + } + + public float getPreferredSpan(int axis) + { + if (axis != X_AXIS && axis != Y_AXIS) + throw new IllegalArgumentException(); + + FontMetrics fm = getFontMetrics(); + + if (axis == Y_AXIS) + return fm.getHeight(); + + String text; + Element elem = getElement(); + + try + { + text = elem.getDocument().getText(elem.getStartOffset(), + elem.getEndOffset()); + } + catch (BadLocationException e) + { + // This should never happen. + text = ""; + System.out.println("Michael: FieldView.getPreferredSpan: Error"); + } + + return fm.stringWidth(text); + } + + public int getResizeWeight(int axis) + { + return axis = axis == X_AXIS ? 1 : 0; + } + + public void paint(Graphics g, Shape s) + { + drawLine(0, g, 0, 0); + } +} diff --git a/libjava/javax/swing/text/Highlighter.java b/libjava/javax/swing/text/Highlighter.java new file mode 100644 index 0000000..77471d1 --- /dev/null +++ b/libjava/javax/swing/text/Highlighter.java @@ -0,0 +1,80 @@ +/* Highlighter.java -- + Copyright (C) 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., 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 javax.swing.text; + +import java.awt.Graphics; +import java.awt.Shape; + + +public interface Highlighter +{ + public interface Highlight + { + int getEndOffset(); + + int getStartOffset(); + + HighlightPainter getPainter(); + } + + public interface HighlightPainter + { + public void paint(Graphics g, int p0, int p1, Shape bounds, + JTextComponent c); + } + + void install(JTextComponent c); + + void deinstall(JTextComponent c); + + Object addHighlight(int p0, int p1, HighlightPainter p) + throws BadLocationException; + + void removeAllHighlights(); + + void removeHighlight(Object tag); + + void changeHighlight(Object tag, int p0, int p1) + throws BadLocationException; + + Highlight[] getHighlights(); + + void paint(Graphics g); +} + diff --git a/libjava/javax/swing/text/JTextComponent.java b/libjava/javax/swing/text/JTextComponent.java index d5227d0..e44c529 100644 --- a/libjava/javax/swing/text/JTextComponent.java +++ b/libjava/javax/swing/text/JTextComponent.java @@ -38,6 +38,7 @@ exception statement from your version. */ package javax.swing.text; import java.awt.AWTEvent; +import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Image; @@ -67,12 +68,6 @@ import javax.swing.plaf.TextUI; public abstract class JTextComponent extends JComponent implements Scrollable, Accessible { -// public class AccessibleJTextComponent extends AccessibleJComponent -// implements AccessibleText, CaretListener, DocumentListener, -// AccessibleAction, AccessibleEditableText -// { -// } - /** * AccessibleJTextComponent */ @@ -82,11 +77,6 @@ public abstract class JTextComponent extends JComponent private static final long serialVersionUID = 7664188944091413696L; /** - * caretPos - */ - int caretPos; - - /** * Constructor AccessibleJTextComponent * @param component TODO */ @@ -280,6 +270,12 @@ public abstract class JTextComponent extends JComponent public KeyStroke key; public String actionName; + /** + * Creates a new KeyBinding instance. + * + * @param key a KeyStroke value + * @param actionName a String value + */ public KeyBinding(KeyStroke key, String actionName) { this.key = key; @@ -294,8 +290,16 @@ public abstract class JTextComponent extends JComponent private Document doc; private Caret caret; + private Highlighter highlighter; + private Color caretColor; + private Color disabledTextColor; + private Color selectedTextColor; + private Color selectionColor; private boolean editable; + /** + * Creates a new JTextComponent instance. + */ public JTextComponent() { enableEvents(AWTEvent.KEY_EVENT_MASK); @@ -311,13 +315,13 @@ public abstract class JTextComponent extends JComponent public Document getDocument() { - if (doc == null) - System.out.println("doc == null !!!"); return doc; } /** - * Get the AccessibleContext of this object + * Get the AccessibleContext of this object. + * + * @return an AccessibleContext object */ public AccessibleContext getAccessibleContext() { @@ -351,7 +355,18 @@ public abstract class JTextComponent extends JComponent */ public String getText() { - return getDocument().getText(0, getDocument().getLength()); + if (doc == null) + return null; + + try + { + return doc.getText(0, doc.getLength()); + } + catch (BadLocationException e) + { + // This should never happen. + return ""; + } } /** @@ -389,14 +404,33 @@ public abstract class JTextComponent extends JComponent return "JTextComponent"; } + /** + * This method returns the label's UI delegate. + * + * @return The label's UI delegate. + */ public TextUI getUI() { - return (TextUI) UIManager.getUI(this); + return (TextUI) ui; + } + + /** + * This method sets the label's UI delegate. + * + * @param ui The label's UI delegate. + */ + public void setUI(TextUI newUI) + { + super.setUI(newUI); } + /** + * This method resets the label's UI delegate to the default UI for the + * current look and feel. + */ public void updateUI() { - setUI(getUI()); + setUI((TextUI) UIManager.getUI(this)); } public Dimension getPreferredScrollableViewportSize() @@ -448,6 +482,61 @@ public abstract class JTextComponent extends JComponent } /** + * Sets a new Caret for this text component. + * + * @param newCaret the new Caret to set + */ + public void setCaret(Caret newCaret) + { + firePropertyChange("caret", caret, newCaret); + caret = newCaret; + } + + public Color getCaretColor() + { + return caretColor; + } + + public void setCaretColor(Color newColor) + { + firePropertyChange("caretColor", caretColor, newColor); + caretColor = newColor; + } + + public Color getDisabledTextColor() + { + return disabledTextColor; + } + + public void setDisabledTextColor(Color newColor) + { + firePropertyChange("disabledTextColor", caretColor, newColor); + disabledTextColor = newColor; + } + + public Color getSelectedTextColor() + { + return selectedTextColor; + } + + public void setSelectedTextColor(Color newColor) + { + firePropertyChange("selectedTextColor", caretColor, newColor); + selectedTextColor = newColor; + } + + public Color getSelectionColor() + { + return selectionColor; + } + + public void setSelectionColor(Color newColor) + { + firePropertyChange("selectionColor", caretColor, newColor); + selectionColor = newColor; + } + + /** * Retrisves the current caret position. * * @return the current position @@ -488,6 +577,17 @@ public abstract class JTextComponent extends JComponent caret.moveDot(position); } + public Highlighter getHighlighter() + { + return highlighter; + } + + public void setHighlighter(Highlighter newHighlighter) + { + firePropertyChange("highlighter", highlighter, newHighlighter); + highlighter = newHighlighter; + } + /** * Returns the start postion of the currently selected text. * @@ -556,6 +656,34 @@ public abstract class JTextComponent extends JComponent select(0, doc.getLength()); } + public synchronized void replaceSelection(String content) + { + int dot = caret.getDot(); + int mark = caret.getMark(); + + // If content is empty delete selection. + if (content == null) + { + caret.setDot(dot); + return; + } + + try + { + // Remove selected text. + if (dot != mark) + doc.remove(Math.min(dot, mark), Math.max(dot, mark)); + + // Insert new text. + doc.insertString(Math.min(dot, mark), content, null); + } + catch (BadLocationException e) + { + // This should never happen. + System.out.println("Michael: JTextComponent.replaceSelection: Error"); + } + } + public boolean getScrollableTracksViewportHeight() { if (getParent() instanceof JViewport) diff --git a/libjava/javax/swing/text/LayeredHighlighter.java b/libjava/javax/swing/text/LayeredHighlighter.java new file mode 100644 index 0000000..4593221 --- /dev/null +++ b/libjava/javax/swing/text/LayeredHighlighter.java @@ -0,0 +1,61 @@ +/* LayeredHighlighter.java -- + Copyright (C) 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., 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 javax.swing.text; + +import java.awt.Graphics; +import java.awt.Shape; + +import javax.swing.text.JTextComponent; +import javax.swing.text.View; + + +public abstract class LayeredHighlighter + implements Highlighter +{ + public abstract static class LayerPainter + implements Highlighter.HighlightPainter + { + public abstract Shape paintLayer(Graphics g, int p0, int p1, + Shape viewBounds, JTextComponent editor, + View view); + } + + public abstract void paintLayeredHighlights(Graphics g, int p0, int p1, + Shape viewBounds, + JTextComponent editor, View view); +} diff --git a/libjava/javax/swing/text/PlainDocument.java b/libjava/javax/swing/text/PlainDocument.java index 930e5d3..4a8adfc 100644 --- a/libjava/javax/swing/text/PlainDocument.java +++ b/libjava/javax/swing/text/PlainDocument.java @@ -44,6 +44,7 @@ public class PlainDocument extends AbstractDocument public static final String lineLimitAttribute = "lineLimit"; public static final String tabSizeAttribute = "tabSize"; + private Element rootElement; private int tabSize; public PlainDocument() @@ -55,11 +56,22 @@ public class PlainDocument extends AbstractDocument { super(content); tabSize = 8; + rootElement = createDefaultRoot(); + } + + protected AbstractDocument.AbstractElement createDefaultRoot() + { + BranchElement rootElement = + (BranchElement) createBranchElement(null, null); + Element[] lines = new Element[1]; + lines[0] = createLeafElement(rootElement, null, 0, 1); + rootElement.replace(0, 0, lines); + return rootElement; } public Element getDefaultRootElement() { - return null; + return rootElement; } public Element getParagraphElement(int pos) diff --git a/libjava/javax/swing/text/PlainEditorKit.java b/libjava/javax/swing/text/PlainEditorKit.java deleted file mode 100644 index 1c8c5de..0000000 --- a/libjava/javax/swing/text/PlainEditorKit.java +++ /dev/null @@ -1,103 +0,0 @@ -/* PlainEditorKit.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., 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 javax.swing.text; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import javax.swing.Action; -import javax.swing.JEditorPane; - -public class PlainEditorKit extends EditorKit -{ - public PlainEditorKit() - { - } - - public PlainEditorKit(PlainEditorKit kit) - { - super(kit); - } - - protected Object clone() - { - return new PlainEditorKit(this); - } - void deinstall(JEditorPane c) - { - // Called when the kit is being removed from the JEditorPane. - } - void install(JEditorPane c) - { - } - - Caret createCaret() - { - return null; - } - Document createDefaultDocument() - { - return null; - } - Action[] getActions() - { - return null; - } - String getContentType() - { - return null; - } - ViewFactory getViewFactory() - { - return null; - } - void read(InputStream in, Document doc, int pos) - { - } - void read(Reader in, Document doc, int pos) - { - } - void write(OutputStream out, Document doc, int pos, int len) - { - } - void write(Writer out, Document doc, int pos, int len) - { - } -} - diff --git a/libjava/javax/swing/text/PlainView.java b/libjava/javax/swing/text/PlainView.java new file mode 100644 index 0000000..229c7e1 --- /dev/null +++ b/libjava/javax/swing/text/PlainView.java @@ -0,0 +1,122 @@ +/* PlainView.java -- + Copyright (C) 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., 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 javax.swing.text; + +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.Shape; + + +public class PlainView extends View + implements TabExpander +{ + protected FontMetrics metrics; + + public PlainView(Element elem) + { + super(elem); + } + + public void drawLine(int lineIndex, Graphics g, int x, int y) + { + try + { + metrics = g.getFontMetrics(); + // FIXME: Selected text are not drawn yet. + drawUnselectedText(g, x, y, 0, getDocument().getLength()); + //drawSelectedText(g, , , , ); + } + catch (BadLocationException e) + { + // This should never happen. + } + } + + public int drawSelectedText(Graphics g, int x, int y, int p0, int p1) + throws BadLocationException + { + String text = getDocument().getText(p0, p1); + g.setColor(Color.WHITE); + g.drawString(text, x, y); + return metrics.stringWidth(text); + } + + public int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) + throws BadLocationException + { + String text = getDocument().getText(p0, p1); + g.setColor(Color.BLACK); + g.drawString(text, x, y); + return metrics.stringWidth(text); + } + + public void paint(Graphics g, Shape s) + { + System.out.println("Michael: PlainView.paint"); + + Rectangle rect = s.getBounds(); + + g.setColor(Color.WHITE); + g.fillRect(rect.x, rect.y, rect.width, rect.height); + + // FIXME: Text may be scrolled. + drawLine(0, g, rect.x, rect.y); + } + + public int getTabSize() + { + return 8; + } + + public float nextTabStop(float x, int tabStop) + { + System.out.println("Michael: PlainView.nextTabpStop: missing implementation"); + return x; + } + + public float getPreferredSpan(int axis) + { + if (axis != X_AXIS && axis != Y_AXIS) + throw new IllegalArgumentException(); + + return 10; + } +} \ No newline at end of file diff --git a/libjava/javax/swing/text/Position.java b/libjava/javax/swing/text/Position.java index be54060..64a91f2 100644 --- a/libjava/javax/swing/text/Position.java +++ b/libjava/javax/swing/text/Position.java @@ -1,5 +1,5 @@ /* Position.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,6 +42,20 @@ public interface Position { static class Bias { + public static final Bias Backward = new Bias("backward"); + public static final Bias Forward = new Bias("forward"); + + private String name; + + private Bias(String n) + { + name = n; + } + + public String toString() + { + return name; + } } int getOffset(); diff --git a/libjava/javax/swing/text/Segment.java b/libjava/javax/swing/text/Segment.java index 8934b45..69e2fec 100644 --- a/libjava/javax/swing/text/Segment.java +++ b/libjava/javax/swing/text/Segment.java @@ -37,22 +37,38 @@ exception statement from your version. */ package javax.swing.text; -public class Segment implements Cloneable, CharacterIterator +import java.text.CharacterIterator; + + +public class Segment + implements Cloneable, CharacterIterator { - char[] array; - int count; - int offset; + public char[] array; + public int count; + public int offset; + + public Segment() + { + } + + public Segment(char[] array, int offset, int count) + { + this.array = array; + this.offset = offset; + this.count = count; + } public Object clone() { - try { + try + { return super.clone(); - } catch (Exception e) { - System.err.println("Huuuhhh, this class implements cloneable !!!!!!"); - System.err.println("I think there is a bug in this JVM somewhere"); } + catch (CloneNotSupportedException e) + { return null; } + } public char current() { @@ -74,25 +90,30 @@ public class Segment implements Cloneable, CharacterIterator { return offset + count; } + public int getIndex() { return offset; } + public char last() { offset = getEndIndex() - 1; return array[offset]; } + public char next() { offset++; return array[offset]; } + public char previous() { offset--; return array[offset]; } + public char setIndex(int position) { offset = position; @@ -104,4 +125,3 @@ public class Segment implements Cloneable, CharacterIterator return new String(array, offset, count); } } - diff --git a/libjava/javax/swing/text/StyledEditorKit.java b/libjava/javax/swing/text/StyledEditorKit.java index f237247..d3db03e 100644 --- a/libjava/javax/swing/text/StyledEditorKit.java +++ b/libjava/javax/swing/text/StyledEditorKit.java @@ -42,335 +42,241 @@ import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; - import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; + /** * StyledEditorKit + * * @author Andrew Selkirk - * @version 1.0 */ public class StyledEditorKit extends DefaultEditorKit { - static final long serialVersionUID = 7002391892985555948L; - - //------------------------------------------------------------- - // Classes ---------------------------------------------------- - //------------------------------------------------------------- + private static final long serialVersionUID = 7002391892985555948L; /** * UnderlineAction */ - public static class UnderlineAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + public static class UnderlineAction extends StyledEditorKit.StyledTextAction + { /** * Constructor UnderlineAction */ - public UnderlineAction() { + public UnderlineAction() + { super("TODO"); // TODO - } // UnderlineAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // UnderlineAction + } + } /** * ItalicAction */ - public static class ItalicAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + public static class ItalicAction extends StyledEditorKit.StyledTextAction + { /** * Constructor ItalicAction */ - public ItalicAction() { + public ItalicAction() + { super("TODO"); // TODO - } // ItalicAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // ItalicAction + } + } /** * BoldAction */ - public static class BoldAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + public static class BoldAction extends StyledEditorKit.StyledTextAction + { /** * Constructor BoldAction */ - public BoldAction() { + public BoldAction() + { super("TODO"); // TODO - } // BoldAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // BoldAction + } + } /** * AlignmentAction */ - public static class AlignmentAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - + public static class AlignmentAction extends StyledEditorKit.StyledTextAction + { /** * a */ private int a; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor AlignmentAction * @param nm TODO * @param a TODO */ - public AlignmentAction(String nm, int a) { + public AlignmentAction(String nm, int a) + { super("TODO"); // TODO - } // AlignmentAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // AlignmentAction + } + } /** * ForegroundAction */ - public static class ForegroundAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - + public static class ForegroundAction extends StyledEditorKit.StyledTextAction + { /** * fg */ private Color fg; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor ForegroundAction * @param nm TODO * @param fg TODO */ - public ForegroundAction(String nm, Color fg) { + public ForegroundAction(String nm, Color fg) + { super("TODO"); // TODO - } // ForegroundAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // ForegroundAction + } + } /** * FontSizeAction */ - public static class FontSizeAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - + public static class FontSizeAction extends StyledEditorKit.StyledTextAction + { /** * size */ private int size; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor FontSizeAction * @param nm TODO * @param size TODO */ - public FontSizeAction(String nm, int size) { + public FontSizeAction(String nm, int size) + { super("TODO"); // TODO - } // FontSizeAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // FontSizeAction + } + } /** * FontFamilyAction */ - public static class FontFamilyAction extends StyledEditorKit.StyledTextAction { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - + public static class FontFamilyAction extends StyledEditorKit.StyledTextAction + { /** * family */ private String family; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor FontFamilyAction * @param nm TODO * @param family TODO */ - public FontFamilyAction(String nm, String family) { + public FontFamilyAction(String nm, String family) + { super("TODO"); // TODO - } // FontFamilyAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * actionPerformed * @param event TODO */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(ActionEvent event) + { // TODO - } // actionPerformed() - - - } // FontFamilyAction + } + } /** * StyledTextAction */ - public abstract static class StyledTextAction extends TextAction { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + public abstract static class StyledTextAction extends TextAction + { /** * Constructor StyledTextAction * @param nm TODO */ - public StyledTextAction(String nm) { + public StyledTextAction(String nm) + { super(nm); // TODO - } // StyledTextAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * getEditor * @param event TODO * @returns JEditorPane */ - protected final JEditorPane getEditor(ActionEvent event) { + protected final JEditorPane getEditor(ActionEvent event) + { return null; // TODO - } // getEditor() + } /** * setCharacterAttributes @@ -378,27 +284,32 @@ public class StyledEditorKit extends DefaultEditorKit * @param value1 TODO * @param value2 TODO */ - protected final void setCharacterAttributes(JEditorPane value0, AttributeSet value1, boolean value2) { + protected final void setCharacterAttributes(JEditorPane value0, + AttributeSet value1, + boolean value2) + { // TODO - } // setCharacterAttributes() + } /** * getStyledDocument * @param value0 TODO * @returns StyledDocument */ - protected final StyledDocument getStyledDocument(JEditorPane value0) { + protected final StyledDocument getStyledDocument(JEditorPane value0) + { return null; // TODO - } // getStyledDocument() + } /** * getStyledEditorKit * @param value0 TODO * @returns StyledEditorKit */ - protected final StyledEditorKit getStyledEditorKit(JEditorPane value0) { + protected final StyledEditorKit getStyledEditorKit(JEditorPane value0) + { return null; // TODO - } // getStyledEditorKit() + } /** * setParagraphAttributes @@ -406,72 +317,53 @@ public class StyledEditorKit extends DefaultEditorKit * @param value1 TODO * @param value2 TODO */ - protected final void setParagraphAttributes(JEditorPane value0, AttributeSet value1, boolean value2) { + protected final void setParagraphAttributes(JEditorPane value0, + AttributeSet value1, + boolean value2) + { // TODO - } // setParagraphAttributes() - - - } // StyledTextAction + } + } /** * StyledViewFactory */ - static class StyledViewFactory implements ViewFactory { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + static class StyledViewFactory + implements ViewFactory + { /** * Constructor StyledViewFactory */ - StyledViewFactory() { + StyledViewFactory() + { // TODO - } // StyledViewFactory() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * create * @param value0 TODO * @returns View */ - public View create(Element value0) { + public View create(Element value0) + { return null; // TODO - } // create() - - - } // StyledViewFactory + } + } /** * AttributeTracker */ - class AttributeTracker implements CaretListener, PropertyChangeListener, Serializable { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + class AttributeTracker + implements CaretListener, PropertyChangeListener, Serializable + { /** * Constructor AttributeTracker * @param value0 TODO */ - AttributeTracker(StyledEditorKit value0) { + AttributeTracker(StyledEditorKit value0) + { // TODO - } // AttributeTracker() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * updateInputAttributes @@ -479,33 +371,29 @@ public class StyledEditorKit extends DefaultEditorKit * @param value1 TODO * @param value2 TODO */ - void updateInputAttributes(int value0, int value1, JTextComponent value2) { + void updateInputAttributes(int value0, int value1, JTextComponent value2) + { // TODO - } // updateInputAttributes() + } /** * propertyChange * @param value0 TODO */ - public void propertyChange(PropertyChangeEvent value0) { + public void propertyChange(PropertyChangeEvent value0) + { // TODO - } // propertyChange() + } /** * caretUpdate * @param value0 TODO */ - public void caretUpdate(CaretEvent value0) { + public void caretUpdate(CaretEvent value0) + { // TODO - } // caretUpdate() - - - } // AttributeTracker - - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- + } + } /** * currentRun @@ -522,96 +410,93 @@ public class StyledEditorKit extends DefaultEditorKit */ MutableAttributeSet inputAttributes; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor StyledEditorKit */ - public StyledEditorKit() { + public StyledEditorKit() + { // TODO - } // StyledEditorKit() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * clone * @returns Object */ - public Object clone() { + public Object clone() + { return null; // TODO - } // clone() + } /** * getActions * @returns Action[] */ - public Action[] getActions() { + public Action[] getActions() + { return null; // TODO - } // getActions() + } /** * getInputAttributes * @returns MutableAttributeSet */ - public MutableAttributeSet getInputAttributes() { + public MutableAttributeSet getInputAttributes() + { return null; // TODO - } // getInputAttributes() + } /** * getCharacterAttributeRun * @returns Element */ - public Element getCharacterAttributeRun() { + public Element getCharacterAttributeRun() + { return null; // TODO - } // getCharacterAttributeRun() + } /** * createDefaultDocument * @returns Document */ - public Document createDefaultDocument() { + public Document createDefaultDocument() + { return null; // TODO - } // createDefaultDocument() + } /** * install * @param component TODO */ - public void install(JEditorPane component) { + public void install(JEditorPane component) + { // TODO - } // install() + } /** * deinstall * @param component TODO */ - public void deinstall(JEditorPane component) { + public void deinstall(JEditorPane component) + { // TODO - } // deinstall() + } /** * getViewFactory * @returns ViewFactory */ - public ViewFactory getViewFactory() { + public ViewFactory getViewFactory() + { return null; // TODO - } // getViewFactory() + } /** * createInputAttributes * @param element TODO * @param set TODO */ - protected void createInputAttributes(Element element, - MutableAttributeSet set) { + protected void createInputAttributes(Element element, MutableAttributeSet set) + { // TODO - } // createInputAttributes() - - -} // StyledEditorKit + } +} diff --git a/libjava/javax/swing/text/TabExpander.java b/libjava/javax/swing/text/TabExpander.java new file mode 100644 index 0000000..56940f5 --- /dev/null +++ b/libjava/javax/swing/text/TabExpander.java @@ -0,0 +1,43 @@ +/* TabExpander.java -- + Copyright (C) 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., 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 javax.swing.text; + +public interface TabExpander +{ + float nextTabStop(float x, int tabOffset); +} \ No newline at end of file diff --git a/libjava/javax/swing/text/TabableView.java b/libjava/javax/swing/text/TabableView.java new file mode 100644 index 0000000..9d244be --- /dev/null +++ b/libjava/javax/swing/text/TabableView.java @@ -0,0 +1,44 @@ +/* TabableView.java -- + Copyright (C) 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., 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 javax.swing.text; + +public interface TabableView +{ + float getPartialSpan(int p0, int p1); + float getTabbedSpan(float x, TabExpander expander); +} diff --git a/libjava/javax/swing/text/TextAction.java b/libjava/javax/swing/text/TextAction.java index 55c04c1..5fee0e8 100644 --- a/libjava/javax/swing/text/TextAction.java +++ b/libjava/javax/swing/text/TextAction.java @@ -41,56 +41,49 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; + /** * TextAction * @author Andrew Selkirk - * @version 1.0 */ -public abstract class TextAction extends AbstractAction { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - +public abstract class TextAction extends AbstractAction +{ /** * Constructor TextAction * @param name TODO */ - public TextAction(String name) { + public TextAction(String name) + { // TODO - } // TextAction() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + } /** * getTextComponent * @param event TODO - * @returns JTextComponent + * @return JTextComponent */ - protected final JTextComponent getTextComponent(ActionEvent event) { + protected final JTextComponent getTextComponent(ActionEvent event) + { return null; // TODO - } // getTextComponent() + } /** * augmentList * @param list1 TODO * @param list2 TODO - * @returns Action[] + * @return Action[] */ - public static final Action[] augmentList(Action[] list1, Action[] list2) { + public static final Action[] augmentList(Action[] list1, Action[] list2) + { return null; // TODO - } // augmentList() + } /** * getFocusedComponent - * @returns JTextComponent + * @return JTextComponent */ - protected final JTextComponent getFocusedComponent() { + protected final JTextComponent getFocusedComponent() + { return null; // TODO - } // getFocusedComponent() - - -} // TextAction + } +} diff --git a/libjava/javax/swing/text/View.java b/libjava/javax/swing/text/View.java index 46d2b35..6c5a9c2 100644 --- a/libjava/javax/swing/text/View.java +++ b/libjava/javax/swing/text/View.java @@ -37,6 +37,7 @@ exception statement from your version. */ package javax.swing.text; +import java.awt.Container; import java.awt.Graphics; import java.awt.Shape; import java.util.Vector; @@ -44,97 +45,124 @@ import javax.swing.SwingConstants; public abstract class View implements SwingConstants { - static int BadBreakWeight; - static int ExcellentBreakWeight; - static int ForcedBreakWeight; - static int GoodBreakWeight; + public static final int BadBreakWeight = 0; + public static final int ExcellentBreakWeight = 2000; + public static final int ForcedBreakWeight = 3000; + public static final int GoodBreakWeight = 1000; - public final static int X_AXIS = 0; - public final static int Y_AXIS = 1; + public static final int X_AXIS = 0; + public static final int Y_AXIS = 1; - float width, height; - Element elt; - View parent; + private float width, height; + private Element elt; + private View parent; /** - * this vector contains the views ordered at offsets... + * Creates a new View instance. + * + * @param elem an Element value */ - Vector v = new Vector(); - - public View(Element elem) { elt = elem; } - public int getViewCount() + public abstract void paint(Graphics g, Shape s); + + public void setParent(View a) { - return v.size(); + parent = a; } - public View getView(int a) + public View getParent() { - return (View) v.get(a); + return parent; } - public void remove(int i) + public void setSize(int w, int h) { - v.removeElementAt(i); + width = w; + height = h; } - public void insert(int off, View view) + public Container getContainer() { - v.insertElementAt(view, off); + return parent != null ? parent.getContainer() : null; } - public void append(View view) + public Document getDocument() { - v.addElement(view); + return getElement().getDocument(); } - public void paint(Graphics g, Shape allocation) + public Element getElement() { - System.out.println("view.paint() !!!!"); + return elt; } - public void setParent(View a) + public abstract float getPreferredSpan(int axis); + + public float getAlignment(int axis) { - parent = a; + return 0.5f; } - public View getParent() + public AttributeSet getAttributes() { - return parent; + return elt.getAttributes(); } - public void setSize(int w, int h) + public boolean isVisible() { - width = w; - height = h; + return true; } - public Document getDocument() + public int getViewCount() { - return getElement().getDocument(); + return 0; } - public Element getElement() + public View getView(int index) { - return elt; + return null; } - public float getPreferredSpan(int a) + public ViewFactory getViewFactory() { - switch (a) + return parent != null ? parent.getViewFactory() : null; + } + + public void replace(int offset, int length, View[] views) { - case X_AXIS: return width; - case Y_AXIS: return height; - default: + // Default implementation does nothing. + } + + public void insert(int offset, View view) { - System.err.println("I sure wish Java had enums !!! "); - return 0; + View[] array = { view }; + replace(offset, 1, array); } + + public void append(View view) + { + View[] array = { view }; + replace(getViewCount(), 1, array); + } + + public void removeAll() + { + replace(0, getViewCount(), null); } + + public void remove(int index) + { + replace(index, 1, null); + } + + public View createFragment(int p0, int p1) + { + // The default implementation doesnt support fragmentation. + return this; } } diff --git a/libjava/javax/swing/text/ViewFactory.java b/libjava/javax/swing/text/ViewFactory.java index 1fef6bc..52be67b 100644 --- a/libjava/javax/swing/text/ViewFactory.java +++ b/libjava/javax/swing/text/ViewFactory.java @@ -1,5 +1,5 @@ /* ViewFactory.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,5 +39,12 @@ package javax.swing.text; public interface ViewFactory { + /** + * Creates a view for a given element. + * + * @param elem them element to create view for + * + * @return a new created view + */ View create (Element elem); } -- cgit v1.1