From: <ls...@us...> - 2007-07-07 12:37:31
|
Revision: 3353 http://jnode.svn.sourceforge.net/jnode/?rev=3353&view=rev Author: lsantha Date: 2007-07-07 05:37:26 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Openjdk integration. Modified Paths: -------------- trunk/core/src/classpath/javax/javax/swing/JComponent.java trunk/core/src/classpath/javax/javax/swing/JDesktopPane.java trunk/core/src/classpath/javax/javax/swing/JEditorPane.java trunk/core/src/classpath/javax/javax/swing/JInternalFrame.java trunk/core/src/classpath/javax/javax/swing/JList.java trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java trunk/core/src/classpath/javax/javax/swing/JTable.java trunk/core/src/classpath/javax/javax/swing/JTree.java trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java trunk/core/src/classpath/javax/javax/swing/TransferHandler.java trunk/core/src/classpath/javax/javax/swing/UIDefaults.java trunk/core/src/classpath/javax/javax/swing/border/AbstractBorder.java trunk/core/src/classpath/javax/javax/swing/plaf/ComponentUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicComboBoxUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicComboPopup.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicDirectoryModel.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicGraphicsUtils.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicListUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicLookAndFeel.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicScrollBarUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicScrollPaneUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicSliderUI.java trunk/core/src/classpath/javax/javax/swing/plaf/basic/BasicSplitPaneUI.java trunk/core/src/classpath/javax/javax/swing/text/DefaultCaret.java trunk/core/src/classpath/javax/javax/swing/text/DefaultEditorKit.java trunk/core/src/classpath/javax/javax/swing/text/JTextComponent.java Modified: trunk/core/src/classpath/javax/javax/swing/JComponent.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JComponent.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JComponent.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -3796,4 +3796,169 @@ + propertyName); } } + + //jnode openjdk + /** + * Calculates a custom drop location for this type of component, + * representing where a drop at the given point should insert data. + * <code>null</code> is returned if this component doesn't calculate + * custom drop locations. In this case, <code>TransferHandler</code> + * will provide a default <code>DropLocation</code> containing just + * the point. + * + * @param p the point to calculate a drop location for + * @return the drop location, or <code>null</code> + */ + TransferHandler.DropLocation dropLocationForPoint(Point p) { + return null; + } + + /** + * Returns <code>true</code> if the current painting operation on this + * component is part of a <code>print</code> operation. This method is + * useful when you want to customize what you print versus what you show + * on the screen. + * <p> + * You can detect changes in the value of this property by listening for + * property change events on this component with name + * <code>"paintingForPrint"</code>. + * <p> + * Note: This method provides complimentary functionality to that provided + * by other high level Swing printing APIs. However, it deals strictly with + * painting and should not be confused as providing information on higher + * level print processes. For example, a {@link javax.swing.JTable#print()} + * operation doesn't necessarily result in a continuous rendering of the + * full component, and the return value of this method can change multiple + * times during that operation. It is even possible for the component to be + * painted to the screen while the printing process is ongoing. In such a + * case, the return value of this method is <code>true</code> when, and only + * when, the table is being painted as part of the printing process. + * + * @return true if the current painting operation on this component + * is part of a print operation + * @see #print + * @since 1.6 + */ + public final boolean isPaintingForPrint() { + return getFlag(IS_PRINTING); + } + private void setFlag(int aFlag, boolean aValue) { + if(aValue) { + flags |= (1 << aFlag); + } else { + flags &= ~(1 << aFlag); + } + } + private boolean getFlag(int aFlag) { + int mask = (1 << aFlag); + return ((flags & mask) == mask); + } + private int flags; + + /** Private flags **/ + private static final int IS_DOUBLE_BUFFERED = 0; + private static final int ANCESTOR_USING_BUFFER = 1; + private static final int IS_PAINTING_TILE = 2; + private static final int IS_OPAQUE = 3; + private static final int KEY_EVENTS_ENABLED = 4; + private static final int FOCUS_INPUTMAP_CREATED = 5; + private static final int ANCESTOR_INPUTMAP_CREATED = 6; + private static final int WIF_INPUTMAP_CREATED = 7; + private static final int ACTIONMAP_CREATED = 8; + private static final int CREATED_DOUBLE_BUFFER = 9; + // bit 10 is free + private static final int IS_PRINTING = 11; + private static final int IS_PRINTING_ALL = 12; + private static final int IS_REPAINTING = 13; + /** Bits 14-21 are used to handle nested writeObject calls. **/ + private static final int WRITE_OBJ_COUNTER_FIRST = 14; + private static final int RESERVED_1 = 15; + private static final int RESERVED_2 = 16; + private static final int RESERVED_3 = 17; + private static final int RESERVED_4 = 18; + private static final int RESERVED_5 = 19; + private static final int RESERVED_6 = 20; + private static final int WRITE_OBJ_COUNTER_LAST = 21; + + private static final int REQUEST_FOCUS_DISABLED = 22; + private static final int INHERITS_POPUP_MENU = 23; + private static final int OPAQUE_SET = 24; + private static final int AUTOSCROLLS_SET = 25; + private static final int FOCUS_TRAVERSAL_KEYS_FORWARD_SET = 26; + private static final int FOCUS_TRAVERSAL_KEYS_BACKWARD_SET = 27; + private static final int REVALIDATE_RUNNABLE_SCHEDULED = 28; + + /** + * Returns the baseline. The baseline is measured from the top of + * the component. This method is primarily meant for + * <code>LayoutManager</code>s to align components along their + * baseline. A return value less than 0 indicates this component + * does not have a reasonable baseline and that + * <code>LayoutManager</code>s should not align this component on + * its baseline. + * <p> + * This method calls into the <code>ComponentUI</code> method of the + * same name. If this component does not have a <code>ComponentUI</code> + * -1 will be returned. If a value >= 0 is + * returned, then the component has a valid baseline for any + * size >= the minimum size and <code>getBaselineResizeBehavior</code> + * can be used to determine how the baseline changes with size. + * + * @throws IllegalArgumentException {@inheritDoc} + * @see #getBaselineResizeBehavior + * @see java.awt.FontMetrics + * @since 1.6 + */ + public int getBaseline(int width, int height) { + // check size. + super.getBaseline(width, height); + if (ui != null) { + return ui.getBaseline(this, width, height); + } + return -1; + } + + /** + * Returns the preferred location to display the popup menu in this + * component's coordinate system. It is up to the look and feel to + * honor this property, some may choose to ignore it. + * If {@code null}, the look and feel will choose a suitable location. + * + * @param event the {@code MouseEvent} that triggered the popup to be + * shown, or {@code null} if the popup is not being shown as the + * result of a mouse event + * @return location to display the {@code JPopupMenu}, or {@code null} + * @since 1.5 + */ + public Point getPopupLocation(MouseEvent event) { + return null; + } + + /** + * Returns an enum indicating how the baseline of the component + * changes as the size changes. This method is primarily meant for + * layout managers and GUI builders. + * <p> + * This method calls into the <code>ComponentUI</code> method of + * the same name. If this component does not have a + * <code>ComponentUI</code> + * <code>BaselineResizeBehavior.OTHER</code> will be + * returned. Subclasses should + * never return <code>null</code>; if the baseline can not be + * calculated return <code>BaselineResizeBehavior.OTHER</code>. Callers + * should first ask for the baseline using + * <code>getBaseline</code> and if a value >= 0 is returned use + * this method. It is acceptable for this method to return a + * value other than <code>BaselineResizeBehavior.OTHER</code> even if + * <code>getBaseline</code> returns a value less than 0. + * + * @see #getBaseline(int, int) + * @since 1.6 + */ + public BaselineResizeBehavior getBaselineResizeBehavior() { + if (ui != null) { + return ui.getBaselineResizeBehavior(this); + } + return BaselineResizeBehavior.OTHER; + } } Modified: trunk/core/src/classpath/javax/javax/swing/JDesktopPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JDesktopPane.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JDesktopPane.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -381,4 +381,50 @@ super.setUIProperty(propertyName, value); } } + + //jnode openjdk + /** + * Selects the next <code>JInternalFrame</code> in this desktop pane. + * + * @param forward a boolean indicating which direction to select in; + * <code>true</code> for forward, <code>false</code> for + * backward + * @return the JInternalFrame that was selected or <code>null</code> + * if nothing was selected + * @since 1.6 + */ + public JInternalFrame selectFrame(boolean forward) { + JInternalFrame selectedFrame = getSelectedFrame(); + JInternalFrame frameToSelect = getNextFrame(selectedFrame, forward); + if (frameToSelect == null) { + return null; + } + // Maintain navigation traversal order until an + // external stack change, such as a click on a frame. + setComponentOrderCheckingEnabled(false); + if (forward && selectedFrame != null) { + selectedFrame.moveToBack(); // For Windows MDI fidelity. + } + try { frameToSelect.setSelected(true); + } catch (PropertyVetoException pve) {} + setComponentOrderCheckingEnabled(true); + return frameToSelect; + } + + /* + * Sets whether component order checking is enabled. + * @param enable a boolean value, where <code>true</code> means + * a change in component order will cause a change in the keyboard + * navigation order. + * @since 1.6 + */ + void setComponentOrderCheckingEnabled(boolean enable) { + componentOrderCheckingEnabled = enable; + } + private boolean componentOrderCheckingEnabled = true; + + private JInternalFrame getNextFrame(JInternalFrame f, boolean forward) { + return null; + } + } Modified: trunk/core/src/classpath/javax/javax/swing/JEditorPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JEditorPane.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JEditorPane.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -1219,4 +1219,32 @@ { return (HyperlinkListener[]) getListeners(HyperlinkListener.class); } + + //jnode openjdk + /** + * Key for a client property used to indicate whether + * the default font and foreground color from the component are + * used if a font or foreground color is not specified in the styled + * text. + * <p> + * The default varies based on the look and feel; + * to enable it set the client {@link #putClientProperty property} with + * this name to <code>Boolean.TRUE</code>. + * + * @since 1.5 + */ + public static final String HONOR_DISPLAY_PROPERTIES = "JEditorPane.honorDisplayProperties"; + + /** + * Key for a client property used to indicate whether + * <a href="http://www.w3.org/TR/CSS21/syndata.html#length-units"> + * w3c compliant</a> length units are used for html rendering. + * <p> + * By default this is not enabled; to enable + * it set the client {@link #putClientProperty property} with this name + * to <code>Boolean.TRUE</code>. + * + * @since 1.5 + */ + public static final String W3C_LENGTH_UNITS = "JEditorPane.w3cLengthUnits"; } Modified: trunk/core/src/classpath/javax/javax/swing/JInternalFrame.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JInternalFrame.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JInternalFrame.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -38,14 +38,7 @@ package javax.swing; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Graphics; -import java.awt.IllegalComponentStateException; -import java.awt.KeyboardFocusManager; -import java.awt.LayoutManager; -import java.awt.Rectangle; +import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; @@ -1817,4 +1810,18 @@ { super.fireVetoableChange(name, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); } + + /** + * Returns the last <code>Cursor</code> that was set by the + * <code>setCursor</code> method that is not a resizable + * <code>Cursor</code>. + * + * @return the last non-resizable <code>Cursor</code> + * @since 1.6 + */ + public Cursor getLastCursor() { + return lastCursor; + } + + private Cursor lastCursor; } Modified: trunk/core/src/classpath/javax/javax/swing/JList.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JList.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JList.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -120,7 +120,106 @@ public class JList extends JComponent implements Accessible, Scrollable { + //jnode openjdk + /** + * A subclass of <code>TransferHandler.DropLocation</code> representing + * a drop location for a <code>JList</code>. + * + * @see #getDropLocation + * @since 1.6 + */ + public static final class DropLocation extends TransferHandler.DropLocation { + private final int index; + private final boolean isInsert; + private DropLocation(Point p, int index, boolean isInsert) { + super(p); + this.index = index; + this.isInsert = isInsert; + } + + /** + * Returns the index where dropped data should be placed in the + * list. Interpretation of the value depends on the drop mode set on + * the associated component. If the drop mode is either + * <code>DropMode.USE_SELECTION</code> or <code>DropMode.ON</code>, + * the return value is an index of a row in the list. If the drop mode is + * <code>DropMode.INSERT</code>, the return value refers to the index + * where the data should be inserted. If the drop mode is + * <code>DropMode.ON_OR_INSERT</code>, the value of + * <code>isInsert()</code> indicates whether the index is an index + * of a row, or an insert index. + * <p> + * <code>-1</code> indicates that the drop occurred over empty space, + * and no index could be calculated. + * + * @return the drop index + */ + public int getIndex() { + return index; + } + + /** + * Returns whether or not this location represents an insert + * location. + * + * @return whether or not this is an insert location + */ + public boolean isInsert() { + return isInsert; + } + + /** + * Returns a string representation of this drop location. + * This method is intended to be used for debugging purposes, + * and the content and format of the returned string may vary + * between implementations. + * + * @return a string representation of this drop location + */ + public String toString() { + return getClass().getName() + + "[dropPoint=" + getDropPoint() + "," + + "index=" + index + "," + + "insert=" + isInsert + "]"; + } + } + + /** + * Returns the location that this component should visually indicate + * as the drop location during a DnD operation over the component, + * or {@code null} if no location is to currently be shown. + * <p> + * This method is not meant for querying the drop location + * from a {@code TransferHandler}, as the drop location is only + * set after the {@code TransferHandler}'s <code>canImport</code> + * has returned and has allowed for the location to be shown. + * <p> + * When this property changes, a property change event with + * name "dropLocation" is fired by the component. + * <p> + * By default, responsibility for listening for changes to this property + * and indicating the drop location visually lies with the list's + * {@code ListUI}, which may paint it directly and/or install a cell + * renderer to do so. Developers wishing to implement custom drop location + * painting and/or replace the default cell renderer, may need to honor + * this property. + * + * @return the drop location + * @see #setDropMode + * @see TransferHandler#canImport(TransferHandler.TransferSupport) + * @since 1.6 + */ + public final DropLocation getDropLocation() { + return dropLocation; + } + + /** + * The drop location. + */ + private transient DropLocation dropLocation; + + /** * Provides accessibility support for <code>JList</code>. */ Modified: trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -1723,4 +1723,87 @@ return accessibleContext; } + + //jnode openjdk + /** + * Returns the tab component at <code>index</code>. + * + * @param index the index of the item being queried + * @return the tab component at <code>index</code> + * @exception IndexOutOfBoundsException if index is out of range + * (index < 0 || index >= tab count) + * + * @see #setTabComponentAt + * @since 1.6 + */ + public Component getTabComponentAt(int index) { + //return pages.get(index).tabComponent; + return null; + } + + /** + * Returns the index of the tab for the specified tab component. + * Returns -1 if there is no tab for this tab component. + * + * @param tabComponent the tab component for the tab + * @return the first tab which matches this tab component, or -1 + * if there is no tab for this tab component + * @see #setTabComponentAt + * @see #getTabComponentAt + * @since 1.6 + */ + public int indexOfTabComponent(Component tabComponent) { + for(int i = 0; i < getTabCount(); i++) { + Component c = getTabComponentAt(i); + if (c == tabComponent) { + return i; + } + } + return -1; + } + + /** + * Sets the component that is responsible for rendering the + * title for the specified tab. A null value means + * <code>JTabbedPane</code> will render the title and/or icon for + * the specified tab. A non-null value means the component will + * render the title and <code>JTabbedPane</code> will not render + * the title and/or icon. + * <p> + * Note: The component must not be one that the developer has + * already added to the tabbed pane. + * + * @param index the tab index where the component should be set + * @param component the component to render the title for the + * specified tab + * @exception IndexOutOfBoundsException if index is out of range + * (index < 0 || index >= tab count) + * @exception IllegalArgumentException if component has already been + * added to this <code>JTabbedPane</code> + * + * @see #getTabComponentAt + * @beaninfo + * preferred: true + * attribute: visualUpdate true + * description: The tab component at the specified tab index. + * @since 1.6 + */ + public void setTabComponentAt(int index, Component component) { + /* + if (component != null && indexOfComponent(component) != -1) { + throw new IllegalArgumentException("Component is already added to this JTabbedPane"); + } + Component oldValue = getTabComponentAt(index); + if (component != oldValue) { + int tabComponentIndex = indexOfTabComponent(component); + if (tabComponentIndex != -1) { + setTabComponentAt(tabComponentIndex, null); + } + pages.get(index).tabComponent = component; + firePropertyChange("indexForTabComponent", -1, index); + } + */ + } + + } Modified: trunk/core/src/classpath/javax/javax/swing/JTable.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JTable.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JTable.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -75,6 +75,7 @@ import javax.swing.event.TableColumnModelListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; +import javax.swing.event.RowSorterEvent; import javax.swing.plaf.TableUI; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableColumnModel; @@ -85,6 +86,7 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; +import sun.swing.SwingUtilities2; /** * The table component, displaying information, organized in rows and columns. @@ -100,6 +102,104 @@ implements TableModelListener, Scrollable, TableColumnModelListener, ListSelectionListener, CellEditorListener, Accessible { + //jnode openjdk + /** + * A subclass of <code>TransferHandler.DropLocation</code> representing + * a drop location for a <code>JTable</code>. + * + * @see #getDropLocation + * @since 1.6 + */ + public static final class DropLocation extends TransferHandler.DropLocation { + private final int row; + private final int col; + private final boolean isInsertRow; + private final boolean isInsertCol; + + private DropLocation(Point p, int row, int col, + boolean isInsertRow, boolean isInsertCol) { + + super(p); + this.row = row; + this.col = col; + this.isInsertRow = isInsertRow; + this.isInsertCol = isInsertCol; + } + + /** + * Returns the row index where a dropped item should be placed in the + * table. Interpretation of the value depends on the return of + * <code>isInsertRow()</code>. If that method returns + * <code>true</code> this value indicates the index where a new + * row should be inserted. Otherwise, it represents the value + * of an existing row on which the data was dropped. This index is + * in terms of the view. + * <p> + * <code>-1</code> indicates that the drop occurred over empty space, + * and no row could be calculated. + * + * @return the drop row + */ + public int getRow() { + return row; + } + + /** + * Returns the column index where a dropped item should be placed in the + * table. Interpretation of the value depends on the return of + * <code>isInsertColumn()</code>. If that method returns + * <code>true</code> this value indicates the index where a new + * column should be inserted. Otherwise, it represents the value + * of an existing column on which the data was dropped. This index is + * in terms of the view. + * <p> + * <code>-1</code> indicates that the drop occurred over empty space, + * and no column could be calculated. + * + * @return the drop row + */ + public int getColumn() { + return col; + } + + /** + * Returns whether or not this location represents an insert + * of a row. + * + * @return whether or not this is an insert row + */ + public boolean isInsertRow() { + return isInsertRow; + } + + /** + * Returns whether or not this location represents an insert + * of a column. + * + * @return whether or not this is an insert column + */ + public boolean isInsertColumn() { + return isInsertCol; + } + + /** + * Returns a string representation of this drop location. + * This method is intended to be used for debugging purposes, + * and the content and format of the returned string may vary + * between implementations. + * + * @return a string representation of this drop location + */ + public String toString() { + return getClass().getName() + + "[dropPoint=" + getDropPoint() + "," + + "row=" + row + "," + + "column=" + col + "," + + "insertRow=" + isInsertRow + "," + + "insertColumn=" + isInsertCol + "]"; + } + } + /** * Provides accessibility support for <code>JTable</code>. * @@ -5154,4 +5254,79 @@ super.setUIProperty(propertyName, value); } } -} + + //jnode openjdk + /** + * Returns the object responsible for sorting. + * + * @return the object responsible for sorting + * @since 1.6 + */ + public RowSorter<? extends TableModel> getRowSorter() { + //return (sortManager != null) ? sortManager.sorter : null; + return null; + } + /** + * Information used in sorting. + */ + //private transient SortManager sortManager; + + /** + * Sets the <code>RowSorter</code>. <code>RowSorter</code> is used + * to provide sorting and filtering to a <code>JTable</code>. + * <p> + * This method clears the selection and resets any variable row heights. + * <p> + * If the underlying model of the <code>RowSorter</code> differs from + * that of this <code>JTable</code> undefined behavior will result. + * + * @param sorter the <code>RowSorter</code>; <code>null</code> turns + * sorting off + * @see javax.swing.table.TableRowSorter + * @since 1.6 + */ + public void setRowSorter(RowSorter<? extends TableModel> sorter) { + /* + RowSorter<? extends TableModel> oldRowSorter = null; + if (sortManager != null) { + oldRowSorter = sortManager.sorter; + sortManager.dispose(); + sortManager = null; + } + rowModel = null; + clearSelectionAndLeadAnchor(); + if (sorter != null) { + sortManager = new SortManager(sorter); + } + resizeAndRepaint(); + firePropertyChange("sorter", oldRowSorter, sorter); + */ + } + + /** + * Returns the location that this component should visually indicate + * as the drop location during a DnD operation over the component, + * or {@code null} if no location is to currently be shown. + * <p> + * This method is not meant for querying the drop location + * from a {@code TransferHandler}, as the drop location is only + * set after the {@code TransferHandler}'s <code>canImport</code> + * has returned and has allowed for the location to be shown. + * <p> + * When this property changes, a property change event with + * name "dropLocation" is fired by the component. + * + * @return the drop location + * @see #setDropMode + * @see TransferHandler#canImport(TransferHandler.TransferSupport) + * @since 1.6 + */ + public final DropLocation getDropLocation() { + return dropLocation; + } + /** + * The drop location. + */ + private transient DropLocation dropLocation; + +} \ No newline at end of file Modified: trunk/core/src/classpath/javax/javax/swing/JTree.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JTree.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/JTree.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -86,6 +86,106 @@ public class JTree extends JComponent implements Scrollable, Accessible { + //jnode openjdk + /** + * A subclass of <code>TransferHandler.DropLocation</code> representing + * a drop location for a <code>JTree</code>. + * + * @see #getDropLocation + * @since 1.6 + */ + public static final class DropLocation extends TransferHandler.DropLocation { + private final TreePath path; + private final int index; + + private DropLocation(Point p, TreePath path, int index) { + super(p); + this.path = path; + this.index = index; + } + + /** + * Returns the index where the dropped data should be inserted + * with respect to the path returned by <code>getPath()</code>. + * <p> + * For drop modes <code>DropMode.USE_SELECTION</code> and + * <code>DropMode.ON</code>, this index is unimportant (and it will + * always be <code>-1</code>) as the only interesting data is the + * path over which the drop operation occurred. + * <p> + * For drop mode <code>DropMode.INSERT</code>, this index + * indicates the index at which the data should be inserted into + * the parent path represented by <code>getPath()</code>. + * <code>-1</code> indicates that the drop occurred over the + * parent itself, and in most cases should be treated as inserting + * into either the beginning or the end of the parent's list of + * children. + * <p> + * For <code>DropMode.ON_OR_INSERT</code>, this value will be + * an insert index, as described above, or <code>-1</code> if + * the drop occurred over the path itself. + * + * @return the child index + * @see #getPath + */ + public int getChildIndex() { + return index; + } + + /** + * Returns the path where dropped data should be placed in the + * tree. + * <p> + * Interpretation of this value depends on the drop mode set on the + * component. If the drop mode is <code>DropMode.USE_SELECTION</code> + * or <code>DropMode.ON</code>, the return value is the path in the + * tree over which the data has been (or will be) dropped. + * <code>null</code> indicates that the drop is over empty space, + * not associated with a particular path. + * <p> + * If the drop mode is <code>DropMode.INSERT</code>, the return value + * refers to the path that should become the parent of the new data, + * in which case <code>getChildIndex()</code> indicates where the + * new item should be inserted into this parent path. A + * <code>null</code> path indicates that no parent path has been + * determined, which can happen for multiple reasons: + * <ul> + * <li>The tree has no model + * <li>There is no root in the tree + * <li>The root is collapsed + * <li>The root is a leaf node + * </ul> + * It is up to the developer to decide if and how they wish to handle + * the <code>null</code> case. + * <p> + * If the drop mode is <code>DropMode.ON_OR_INSERT</code>, + * <code>getChildIndex</code> can be used to determine whether the + * drop is on top of the path itself (<code>-1</code>) or the index + * at which it should be inserted into the path (values other than + * <code>-1</code>). + * + * @return the drop path + * @see #getChildIndex + */ + public TreePath getPath() { + return path; + } + + /** + * Returns a string representation of this drop location. + * This method is intended to be used for debugging purposes, + * and the content and format of the returned string may vary + * between implementations. + * + * @return a string representation of this drop location + */ + public String toString() { + return getClass().getName() + + "[dropPoint=" + getDropPoint() + "," + + "path=" + path + "," + + "childIndex=" + index + "]"; + } + } /** * This class implements accessibility support for the JTree class. It * provides an implementation of the Java Accessibility API appropriate @@ -3183,4 +3283,31 @@ super.setUIProperty(propertyName, value); } } + //jnode openjdk + /** + * Returns the location that this component should visually indicate + * as the drop location during a DnD operation over the component, + * or {@code null} if no location is to currently be shown. + * <p> + * This method is not meant for querying the drop location + * from a {@code TransferHandler}, as the drop location is only + * set after the {@code TransferHandler}'s <code>canImport</code> + * has returned and has allowed for the location to be shown. + * <p> + * When this property changes, a property change event with + * name "dropLocation" is fired by the component. + * + * @return the drop location + * @see #setDropMode + * @see TransferHandler#canImport(TransferHandler.TransferSupport) + * @since 1.6 + */ + public final DropLocation getDropLocation() { + return dropLocation; + } + /** + * The drop location. + */ + private transient DropLocation dropLocation; + } Modified: trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -51,6 +51,8 @@ import javax.swing.plaf.UIResource; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.text.JTextComponent; +import sun.swing.DefaultLayoutStyle; +import sun.swing.ImageIconUIResource; /** * A <i>look-and-feel</i> controls most aspects of the appearance and @@ -430,4 +432,73 @@ { c.setUIProperty(propertyName, value); } + + //jnode openjdk + /** + * Returns the <code>LayoutStyle</code> for this look + * and feel. This never returns {@code null}. + * <p> + * You generally don't use the <code>LayoutStyle</code> from + * the look and feel, instead use the <code>LayoutStyle</code> + * method <code>getInstance</code>. + * + * @see LayoutStyle#getInstance + * @return the <code>LayoutStyle</code> for this look and feel + * @since 1.6 + */ + public LayoutStyle getLayoutStyle() { + return DefaultLayoutStyle.getInstance(); + } + /** + * Returns an <code>Icon</code> with a disabled appearance. + * This method is used to generate a disabled <code>Icon</code> when + * one has not been specified. For example, if you create a + * <code>JButton</code> and only specify an <code>Icon</code> via + * <code>setIcon</code> this method will be called to generate the + * disabled <code>Icon</code>. If {@code null} is passed as + * <code>icon</code> this method returns {@code null}. + * <p> + * Some look and feels might not render the disabled {@code Icon}, in which + * case they will ignore this. + * + * @param component {@code JComponent} that will display the {@code Icon}, + * may be {@code null} + * @param icon {@code Icon} to generate the disabled icon from + * @return disabled {@code Icon}, or {@code null} if a suitable + * {@code Icon} can not be generated + * @since 1.5 + */ + public Icon getDisabledIcon(JComponent component, Icon icon) { + if (icon instanceof ImageIcon) { + return new ImageIconUIResource(GrayFilter. + createDisabledImage(((ImageIcon)icon).getImage())); + } + return null; + } + + /** + * Returns an <code>Icon</code> for use by disabled + * components that are also selected. This method is used to generate an + * <code>Icon</code> for components that are in both the disabled and + * selected states but do not have a specific <code>Icon</code> for this + * state. For example, if you create a <code>JButton</code> and only + * specify an <code>Icon</code> via <code>setIcon</code> this method + * will be called to generate the disabled and selected + * <code>Icon</code>. If {@code null} is passed as <code>icon</code> this + * methods returns {@code null}. + * <p> + * Some look and feels might not render the disabled and selected + * {@code Icon}, in which case they will ignore this. + * + * @param component {@code JComponent} that will display the {@code Icon}, + * may be {@code null} + * @param icon {@code Icon} to generate disabled and selected icon from + * @return disabled and selected icon, or {@code null} if a suitable + * {@code Icon} can not be generated. + * @since 1.5 + */ + public Icon getDisabledSelectedIcon(JComponent component, Icon icon) { + return getDisabledIcon(component, icon); + } + } Modified: trunk/core/src/classpath/javax/javax/swing/TransferHandler.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/TransferHandler.java 2007-07-06 11:09:17 UTC (rev 3352) +++ trunk/core/src/classpath/javax/javax/swing/TransferHandler.java 2007-07-07 12:37:26 UTC (rev 3353) @@ -40,7 +40,11 @@ import gnu.classpath.NotImplementedException; -import java.awt.Toolkit; +import java.awt.*; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DnDConstants; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; @@ -54,10 +58,511 @@ import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Method; +import javax.swing.text.JTextComponent; +import sun.reflect.misc.MethodUtil; +import sun.swing.SwingUtilities2; +import sun.awt.AppContext; +import sun.swing.*; + public class TransferHandler implements Serializable { + //jnode openjdk + /** + * Represents a location where dropped data should be inserted. + * This is a base class that only encapsulates a point. + * Components supporting drop may provide subclasses of this + * containing more information. + * <p> + * Developers typically shouldn't create instances of, or extend, this + * class. Instead, these are something provided by the DnD + * implementation by <code>TransferSupport</code> instances and by + * components with a <code>getDropLocation()</code> method. + * + * @see javax.swing.TransferHandler.TransferSupport#getDropLocation + * @since 1.6 + */ + public static class DropLocation { + private final Point dropPoint; + /** + * Constructs a drop location for the given point. + * + * @param dropPoint the drop point, representing the mouse's + * current location within the component. + * @throws IllegalArgumentException if the point + * is <code>null</code> + */ + protected DropLocation(Point dropPoint) { + if (dropPoint == null) { + throw new IllegalArgumentException("Point cannot be null"); + } + + this.dropPoint = new Point(dropPoint); + } + + /** + * Returns the drop point, representing the mouse's + * current location within the component. + * + * @return the drop point. + */ + public final Point getDropPoint() { + return new Point(dropPoint); + } + + /** + * Returns a string representation of this drop location. + * This method is intended to be used for debugging purposes, + * and the content and format of the returned string may vary + * between implementations. + * + * @return a string representation of this drop location + */ + public String toString() { + return getClass().getName() + "[dropPoint=" + dropPoint + "]"; + } + }; + /** + * This class encapsulates all relevant details of a clipboard + * or drag and drop transfer, and also allows for customizing + * aspects of the drag and drop experience. + * <p> + * The main purpose of this class is to provide the information + * needed by a developer to determine the suitability of a + * transfer or to import the data contained within. But it also + * doubles as a controller for customizing properties during drag + * and drop, such as whether or not to show the drop location, + * and which drop action to use. + * <p> + * Developers typically need not create instances of this + * class. Instead, they are something provided by the DnD + * implementation to certain methods in <code>TransferHandler</code>. + * + * @see #canImport(TransferHandler.TransferSupport) + * @see #importData(TransferHandler.TransferSupport) + * @since 1.6 + */ + public final static class TransferSupport { + private boolean isDrop; + private Component component; + + private boolean showDropLocationIsSet; + private boolean showDropLocation; + + private int dropAction = -1; + + /** + * The source is a {@code DropTargetDragEvent} or + * {@code DropTargetDropEvent} for drops, + * and a {@code Transferable} otherwise + */ + private Object source; + + private DropLocation dropLocation; + + /** + * Create a <code>TransferSupport</code> with <code>isDrop()</code> + * <code>true</code> for the given component, event, and index. + * + * @param component the target component + * @param event a <code>DropTargetEvent</code> + */ + private TransferSupport(Component component, + DropTargetEvent event) { + + isDrop = true; + setDNDVariables(component, event); + } + + /** + * Create a <code>TransferSupport</code> with <code>isDrop()</code> + * <code>false</code> for the given component and + * <code>Transferable</code>. + * + * @param component the target component + * @param transferable the transferable + * @throws NullPointerException if either parameter + * is <code>null</code> + */ + public TransferSupport(Component component, Transferable transferable) { + if (component == null) { + throw new NullPointerException("component is null"); + } + + if (transferable == null) { + throw new NullPointerException("transferable is null"); + } + + isDrop = false; + this.component = component; + this.source = transferable; + } + + /** + * Allows for a single instance to be reused during DnD. + * + * @param component the target component + * @param event a <code>DropTargetEvent</code> + */ + private void setDNDVariables(Component component, + DropTargetEvent event) { + + assert isDrop; + + this.component = component; + this.source = event; + dropLocation = null; + dropAction = -1; + showDropLocationIsSet = false; + + if (source == null) { + return; + } + + assert source instanceof DropTargetDragEvent || + source instanceof DropTargetDropEvent; + + Point p = source instanceof DropTargetDragEvent + ? ((DropTargetDragEvent)source).getLocation() + : ((DropTargetDropEvent)source).getLocation(); + + if (component instanceof JTextComponent) { + try { + AccessibleMethod method + = new AccessibleMethod(JTextComponent.class, + "dropLocationForPoint", + Point.class); + + dropLocation = + (DropLocation)method.invokeNoChecked(component, p); + } catch (NoSuchMethodException e) { + throw new AssertionError( + "Couldn't locate method JTextComponent.dropLocationForPoint"); + } + } else if (component instanceof JComponent) { + dropLocation = ((JComponent)component).dropLocationForPoint(p); + } + + /* + * The drop location may be null at this point if the component + * doesn't return custom drop locations. In this case, a point-only + * drop location will be created lazily when requested. + */ + } + + /** + * Returns whether or not this <code>TransferSupport</code> + * represents a drop operation. + * + * @return <code>true</code> if this is a drop operation, + * <code>false</code> otherwise. + */ + public boolean isDrop() { + return isDrop; + } + + /** + * Returns the target component of this transfer. + * + * @return the target component + */ + public Component getComponent() { + return component; + } + + /** + * Checks that this is a drop and throws an + * {@code IllegalStateException} if it isn't. + * + * @throws IllegalStateException if {@code isDrop} is false. + */ + private void assureIsDrop() { + if (!isDrop) { + throw new IllegalStateException("Not a drop"); + } + } + + /** + * Returns the current (non-{@code null}) drop location for the component, + * when this {@code TransferSupport} represents a drop. + * <p> + * Note: For components with built-in drop support, this location + * will be a subclass of {@code DropLocation} of the same type + * returned by that component's {@code getDropLocation} method. + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @return the drop location + * @throws IllegalStateException if this is not a drop + * @see #isDrop + */ + public DropLocation getDropLocation() { + assureIsDrop(); + + if (dropLocation == null) { + /* + * component didn't give us a custom drop location, + * so lazily create a point-only location + */ + Point p = source instanceof DropTargetDragEvent + ? ((DropTargetDragEvent)source).getLocation() + : ((DropTargetDropEvent)source).getLocation(); + + dropLocation = new DropLocation(p); + } + + return dropLocation; + } + + /** + * Sets whether or not the drop location should be visually indicated + * for the transfer - which must represent a drop. This is applicable to + * those components that automatically + * show the drop location when appropriate during a drag and drop + * operation). By default, the drop location is shown only when the + * {@code TransferHandler} has said it can accept the import represented + * by this {@code TransferSupport}. With this method you can force the + * drop location to always be shown, or always not be shown. + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @param showDropLocation whether or not to indicate the drop location + * @throws IllegalStateException if this is not a drop + * @see #isDrop + */ + public void setShowDropLocation(boolean showDropLocation) { + assureIsDrop(); + + this.showDropLocation = showDropLocation; + this.showDropLocationIsSet = true; + } + + /** + * Sets the drop action for the transfer - which must represent a drop + * - to the given action, + * instead of the default user drop action. The action must be + * supported by the source's drop actions, and must be one + * of {@code COPY}, {@code MOVE} or {@code LINK}. + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @param dropAction the drop action + * @throws IllegalStateException if this is not a drop + * @throws IllegalArgumentException if an invalid action is specified + * @see #getDropAction + * @see #getUserDropAction + * @see #getSourceDropActions + * @see #isDrop + */ + public void setDropAction(int dropAction) { + assureIsDrop(); + + int action = dropAction & getSourceDropActions(); + + if (!(action == COPY || action == MOVE || action == LINK)) { + throw new IllegalArgumentException("unsupported drop action: " + dropAction); + } + + this.dropAction = dropAction; + } + + /** + * Returns the action chosen for the drop, when this + * {@code TransferSupport} represents a drop. + * <p> + * Unless explicitly chosen by way of {@code setDropAction}, + * this returns the user drop action provided by + * {@code getUserDropAction}. + * <p> + * You may wish to query this in {@code TransferHandler}'s + * {@code importData} method to customize processing based + * on the action. + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @return the action chosen for the drop + * @throws IllegalStateException if this is not a drop + * @see #setDropAction + * @see #getUserDropAction + * @see #isDrop + */ + public int getDropAction() { + return dropAction == -1 ? getUserDropAction() : dropAction; + } + + /** + * Returns the user drop action for the drop, when this + * {@code TransferSupport} represents a drop. + * <p> + * The user drop action is chosen for a drop as described in the + * documentation for {@link java.awt.dnd.DropTargetDragEvent} and + * {@link java.awt.dnd.DropTargetDropEvent}. A different action + * may be chosen as the drop action by way of the {@code setDropAction} + * method. + * <p> + * You may wish to query this in {@code TransferHandler}'s + * {@code canImport} method when determining the suitability of a + * drop or when deciding on a drop action to explicitly choose. + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @return the user drop action + * @throws IllegalStateException if this is not a drop + * @see #setDropAction + * @see #getDropAction + * @see #isDrop + */ + public int getUserDropAction() { + assureIsDrop(); + + return (source instanceof DropTargetDragEvent) + ? ((DropTargetDragEvent)source).getDropAction() + : ((DropTargetDropEvent)source).getDropAction(); + } + + /** + * Returns the drag source's supported drop actions, when this + * {@code TransferSupport} represents a drop. + * <p> + * The source actions represent the set of actions supported by the + * source of this transfer, and are represented as some bitwise-OR + * combination of {@code COPY}, {@code MOVE} and {@code LINK}. + * You may wish to query this in {@code TransferHandler}'s + * {@code canImport} method when determining the suitability of a drop + * or when deciding on a drop action to explicitly choose. To determine + * if a particular action is supported by the source, bitwise-AND + * the action with the source drop actions, and then compare the result + * against the original action. For example: + * <pre> + * boolean copySupported = (COPY & getSourceDropActions()) == COPY; + * </pre> + * <p> + * This method is only for use with drag and drop transfers. + * Calling it when {@code isDrop()} is {@code false} results + * in an {@code IllegalStateException}. + * + * @return the drag source's supported drop actions + * @throws IllegalStateException if this is not a drop + * @see #isDrop + */ + public int getSourceDropActions() { + assureIsDrop(); + + return (source instanceof DropTargetDragEvent) + ? ((DropTargetDragEvent)source).getSourceActions() + : ((DropTargetDropEvent)source).getSourceActions(); + } + + /** + * Returns the data flavors for this transfer. + * + * @return the data flavors for this transfer + */ + public DataFlavor[] getDataFlavors() { + if (isDrop) { + if (source instanceof DropTargetDragEvent) { + return ((DropTargetDragEvent)source).getCurrentDataFlavors(); + } else { + return ((DropTargetDropEvent)source).getCurrentDataFlavors(); + } + } + + return ((Transferable)source).getTransferDataFlavors(); + } + + /** + * Returns whether or not the given data flavor is supported. + * + * @param df the <code>DataFlavor</code> to test + * @return whether or not the given flavor is supported. + */ + public boolean isDataFlavorSupported(DataFlavor df) { + if (isDrop) { + if (source instanceof DropTargetDragEvent) { + return ((DropTargetDragEvent)source).isDataFlavorSupported(df); + } else { + return ((DropTargetDropEvent)source).isDataFlavorSupported(df); + } + } + + return ((Transferable)source).isDataFlavorSupported(df); + } + + /** + * Returns the <code>Transferable</code> associated with this transfer. + * <p> + * Note: Unless it is necessary to fetch the <code>Transferable</code> + * directly, use one of the other methods on this class to inquire about + * the transfer. This may perform better than fetching the + * <code>Transferable</code> and asking it directly. + * + * @return the <code>Transferable</code> associated with this transfer + */ + public Transferable getTransferable() { + if (isDrop) { + if (source instanceof DropTargetDragEvent) { + return ((DropTargetDragEvent)source).getTransferable(); + } else { + return ((DropTargetDropEvent)source).getTransferable(); + } + } + + return (Transferable)source; + } + } + + /** + * An <code>int</code> representing a "link" transfer action. + * This value is used to specify that data should be linked in a drag + * and drop operation. + * + * @see java.awt.dnd.DnDConstants#ACTION_LINK + * @since 1.6 + */ + public static final int LINK = DnDConstants.ACTION_LINK; + + /** + * Causes a transfer to occur from a clipboard or a drag and + * drop operation. The <code>Transferable</code> to be + * imported and the component to transfer to are contained + * within the <code>TransferSupport</code>. + * <p> + * While the drag and drop implementation calls {@code canImport} + * to determine the suitability of a transfer before calling this + * method, the implementation of paste does not. As such, it cannot + * be assumed that the transfer is acceptable upon a call to + * this method for paste. It is recommended that {@code canImport} be + * explicitly called to cover this case. + * <p> + * Note: The <code>TransferSupport</code> object passed to this method... [truncated message content] |