/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* An extensible implementation of {@code ListUI}.
* <p>
* {@code BasicListUI} instances cannot be shared between multiple
* lists.
*
* @author Hans Muller
* @author Philip Milne
* @author Shannon Hickey (drag and drop)
*/
{
new StringBuilder("List.baselineComponent");
// Listeners that this UI attaches to the JList
/**
* Height of the list. When asked to paint, if the current size of
* the list differs, this will update the layout state.
*/
private int listHeight;
/**
* Width of the list. When asked to paint, if the current size of
* the list differs, this will update the layout state.
*/
private int listWidth;
/**
* The layout orientation of the list.
*/
private int layoutOrientation;
// Following ivars are used if the list is laying out horizontally
/**
* Number of columns to create.
*/
private int columnCount;
/**
* Preferred height to make the list, this is only used if the
* the list is layed out horizontally.
*/
private int preferredHeight;
/**
* Number of rows per column. This is only used if the row height is
* fixed.
*/
private int rowsPerColumn;
/**
* The time factor to treate the series of typed alphanumeric key
* as prefix for first letter navigation.
*/
/**
* Local cache of JList's client property "List.isFileList"
*/
private boolean isFileList = false;
/**
* Local cache of JList's component orientation property
*/
private boolean isLeftToRight = true;
/* The bits below define JList property changes that affect layout.
* When one of these properties changes we set a bit in
* updateLayoutStateNeeded. The change is dealt with lazily, see
* maybeUpdateLayoutState. Changes to the JLists model, e.g. the
* models length changed, are handled similarly, see DataListener.
*/
}
/**
* Paint one List cell: compute the relevant state, get the "rubber stamp"
* cell renderer component, and then use the CellRendererPane to paint it.
* Subclasses may want to override this method rather than paint().
*
* @see #paint
*/
protected void paintCell(
Graphics g,
int row,
int leadIndex)
{
if (isFileList) {
// Shrink renderer to preferred size. This is mostly used on Windows
// where selection is only shown around the file name, instead of
// across the whole list cell.
if (!isLeftToRight) {
}
cw = w;
}
}
/**
* Paint the rows that intersect the Graphics objects clipRect. This
* method calls paintCell as necessary. Subclasses
* may want to override these methods.
*
* @see #paintCell
*/
paintImpl(g, c);
paintDropLine(g);
}
{
switch (layoutOrientation) {
case JList.VERTICAL_WRAP:
redrawList();
}
break;
case JList.HORIZONTAL_WRAP:
redrawList();
}
break;
default:
break;
}
int size;
return;
}
// Determine how many columns we need to paint
int startColumn, endColumn;
if (c.getComponentOrientation().isLeftToRight()) {
paintBounds.y);
paintBounds.y);
} else {
paintBounds.y);
paintBounds.y);
}
columnCount : 1;
colCounter++) {
// And then how many rows in this columnn
// Not valid, bail!
return;
}
index += rowIncrement;
row++;
}
}
// Empty out the renderer pane, allowing renderers to be gc'ed.
}
return;
}
if (c != null) {
g.setColor(c);
}
}
if (size == 0) {
if (isLeftToRight) {
} else {
}
} else {
}
}
boolean decr = false;
decr = true;
if (isLeftToRight) {
p.x, p.y)
p.x, p.y);
} else {
p.x, p.y)
p.x, p.y);
}
}
if (decr) {
index--;
if (isLeftToRight) {
} else {
rect.x -= DROP_LINE_THICKNESS;
}
} else {
if (!isLeftToRight) {
}
}
} else if (rect.x < 0) {
rect.x = 0;
}
index--;
p.x, p.y)
me.y,
p.x, p.y)) {
index--;
} else {
}
} else {
}
}
} else {
index--;
} else {
}
}
}
return rect;
}
/**
* Returns the baseline.
*
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
"List.cellRenderer");
// fix for 6711072 some LAFs like Nimbus do not provide this
// UIManager key and we should not through a NPE here because of it
lcr = new DefaultListCellRenderer();
}
}
// JList actually has much more complex behavior here.
// If rowHeight != -1 the rowHeight is either the max of all cell
// heights (layout orientation != VERTICAL), or is variable depending
// upon the cell. We assume a default size.
// We could theoretically query the real renderer, but that would
// not work for an empty model and the results may vary with
// the content.
if (rowHeight == -1) {
}
}
/**
* Returns an enum indicating how the baseline of the component
* changes as the size changes.
*
* @throws NullPointerException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
JComponent c) {
super.getBaselineResizeBehavior(c);
}
/**
* The preferredSize of the list depends upon the layout orientation.
* <table summary="Describes the preferred size for each layout orientation">
* <tr><th>Layout Orientation</th><th>Preferred Size</th></tr>
* <tr>
* <td>JList.VERTICAL
* <td>The preferredSize of the list is total height of the rows
* and the maximum width of the cells. If JList.fixedCellHeight
* is specified then the total height of the rows is just
* (cellVerticalMargins + fixedCellHeight) * model.getSize() where
* rowVerticalMargins is the space we allocate for drawing
* the yellow focus outline. Similarly if fixedCellWidth is
* specified then we just use that.
* </td>
* <tr>
* <td>JList.VERTICAL_WRAP
* <td>If the visible row count is greater than zero, the preferredHeight
* is the maximum cell height * visibleRowCount. If the visible row
* count is <= 0, the preferred height is either the current height
* of the list, or the maximum cell height, whichever is
* bigger. The preferred width is than the maximum cell width *
* number of columns needed. Where the number of columns needs is
* list.height / max cell height. Max cell height is either the fixed
* cell height, or is determined by iterating through all the cells
* to find the maximum height from the ListCellRenderer.
* <tr>
* <td>JList.HORIZONTAL_WRAP
* <td>If the visible row count is greater than zero, the preferredHeight
* is the maximum cell height * adjustedRowCount. Where
* visibleRowCount is used to determine the number of columns.
* Because this lays out horizontally the number of rows is
* then determined from the column count. For example, lets say
* you have a model with 10 items and the visible row count is 8.
* The number of columns needed to display this is 2, but you no
* longer need 8 rows to display this, you only need 5, thus
* the adjustedRowCount is 5.
* <p>If the visible row
* count is <= 0, the preferred height is dictated by the
* number of columns, which will be as many as can fit in the width
* of the <code>JList</code> (width / max cell width), with at
* least one column. The preferred height then becomes the
* model size / number of columns * maximum cell height.
* Max cell height is either the fixed
* cell height, or is determined by iterating through all the cells
* to find the maximum height from the ListCellRenderer.
* </table>
* The above specifies the raw preferred width and height. The resulting
* preferred width is the above width + insets.left + insets.right and
* the resulting preferred height is the above height + insets.top +
* insets.bottom. Where the <code>Insets</code> are determined from
* <code>list.getInsets()</code>.
*
* @param c The JList component.
* @return The total size of the list.
*/
if (lastRow < 0) {
}
int height;
}
else {
}
else {
height = 0;
}
}
}
/**
* Selected the previous row and force it to be visible.
*
* @see JList#ensureIndexIsVisible
*/
protected void selectPreviousIndex() {
int s = list.getSelectedIndex();
if(s > 0) {
s -= 1;
list.setSelectedIndex(s);
}
}
/**
* Selected the previous row and force it to be visible.
*
* @see JList#ensureIndexIsVisible
*/
protected void selectNextIndex()
{
int s = list.getSelectedIndex();
s += 1;
list.setSelectedIndex(s);
}
}
/**
* Registers the keyboard bindings on the <code>JList</code> that the
* <code>BasicListUI</code> is associated with. This method is called at
* installUI() time.
*
* @see #installUI
*/
protected void installKeyboardActions() {
inputMap);
"List.actionMap");
}
list, this, "List.focusInputMap");
if (isLeftToRight ||
"List.focusInputMap.RightToLeft")) == null)) {
return keyMap;
} else {
return rtlKeyMap;
}
}
return null;
}
/**
* Unregisters keyboard actions installed from
* <code>installKeyboardActions</code>.
* This method is called at uninstallUI() time - subclassess should
* ensure that all of the keyboard actions registered at installUI
* time are removed here.
*
* @see #installUI
*/
protected void uninstallKeyboardActions() {
}
/**
* Creates and installs the listeners for the JList, its model, and its
* selectionModel. This method is called at installUI() time.
*
* @see #installUI
* @see #uninstallListeners
*/
protected void installListeners()
{
// default TransferHandler doesn't support drop
// so we don't want drop handling
}
}
}
if (selectionModel != null) {
}
}
/**
* Removes the listeners from the JList, its model, and its
* selectionModel. All of the listener fields, are reset to
* null here. This method is called at uninstallUI() time,
* it should be kept in sync with installListeners.
*
* @see #uninstallUI
* @see #installListeners
*/
protected void uninstallListeners()
{
}
if (selectionModel != null) {
}
}
/**
* Initializes list properties such as font, foreground, and background,
* and adds the CellRendererPane. The font, foreground, and background
* properties are only set if their current value is either null
* or a UIResource, other properties are set if the current
* value is null.
*
* @see #uninstallDefaults
* @see #installUI
* @see CellRendererPane
*/
protected void installDefaults()
{
}
}
}
}
private void updateIsFileList() {
if (b != isFileList) {
isFileList = b;
}
}
}
}
/**
* Sets the list properties that have not been explicitly overridden to
* {@code null}. A property is considered overridden if its current value
* is not a {@code UIResource}.
*
* @see #installDefaults
* @see #uninstallUI
* @see CellRendererPane
*/
protected void uninstallDefaults()
{
}
}
}
}
}
}
}
}
/**
* Initializes <code>this.list</code> by calling <code>installDefaults()</code>,
* <code>installListeners()</code>, and <code>installKeyboardActions()</code>
* in order.
*
* @see #installDefaults
* @see #installListeners
* @see #installKeyboardActions
*/
{
rendererPane = new CellRendererPane();
columnCount = 1;
}
/**
* Uninitializes <code>this.list</code> by calling <code>uninstallListeners()</code>,
* <code>uninstallKeyboardActions()</code>, and <code>uninstallDefaults()</code>
* in order. Sets this.list to null.
*
* @see #uninstallListeners
* @see #uninstallKeyboardActions
* @see #uninstallDefaults
*/
{
cellHeights = null;
rendererPane = null;
}
/**
* Returns a new instance of BasicListUI. BasicListUI delegates are
* allocated one per JList.
*
* @return A new ListUI implementation for the Windows look and feel.
*/
return new BasicListUI();
}
/**
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
return null;
}
/**
* {@inheritDoc}
*/
return null;
}
return null;
}
return minBounds;
}
minBounds.x = 0;
}
}
// Different columns
minBounds.y = 0;
}
}
return minBounds;
}
/**
* Gets the bounds of the specified model index, returning the resulting
* bounds, or null if <code>index</code> is not valid.
*/
return null;
}
int x;
int w = cellWidth;
int h;
switch (layoutOrientation) {
case JList.VERTICAL_WRAP:
case JList.HORIZONTAL_WRAP:
if (isLeftToRight) {
} else {
}
y += cellHeight * row;
h = cellHeight;
break;
default:
if (cellHeights == null) {
y += (cellHeight * row);
}
y = 0;
}
else {
for(int i = 0; i < row; i++) {
y += cellHeights[i];
}
}
h = getRowHeight(index);
break;
}
return new Rectangle(x, y, w, h);
}
/**
* Returns the height of the specified row based on the current layout.
*
* @return The specified row height or -1 if row isn't valid.
* @see #convertYToRow
* @see #convertRowToY
* @see #updateLayoutState
*/
{
}
/**
* Convert the JList relative coordinate to the row that contains it,
* based on the current layout. If y0 doesn't fall within any row,
* return -1.
*
* @return The row that contains y0, or -1.
* @see #getRowHeight
* @see #updateLayoutState
*/
{
}
/**
* Return the JList relative Y coordinate of the origin of the specified
* row or -1 if row isn't valid.
*
* @return The Y coordinate of the origin of row, or -1.
* @see #getRowHeight
* @see #updateLayoutState
*/
{
return -1;
}
return bounds.y;
}
/**
* Returns the height of the cell at the passed in location.
*/
return -1;
}
return cellHeight;
}
return -1;
}
}
/**
* Returns the row at location x/y.
*
* @param closest If true and the location doesn't exactly match a
* particular location, this will return the closest row.
*/
if (size <= 0) {
return -1;
}
if (cellHeights == null) {
if (closest) {
if (row < 0) {
row = 0;
}
}
}
return row;
}
return -1;
}
else {
int row = 0;
return 0;
}
int i;
for (i = 0; i < size; i++) {
return row;
}
y += cellHeights[i];
row += 1;
}
return i - 1;
}
}
/**
* Returns the closest row that starts at the specified y-location
* in the passed in column.
*/
int x = 0;
if (isLeftToRight) {
} else {
}
}
return convertLocationToRow(x, y, true);
}
/**
* Returns the closest location to the model index of the passed in
* location.
*/
private int convertLocationToModel(int x, int y) {
int row = convertLocationToRow(x, y, true);
int column = convertLocationToColumn(x, y);
}
return -1;
}
/**
* Returns the number of rows in the given column.
*/
return -1;
}
}
if (column >= columnCount) {
return -1;
}
return rowsPerColumn;
}
}
// JList.HORIZONTAL_WRAP
}
return rowsPerColumn;
}
/**
* Returns the model index for the specified display location.
* If <code>column</code>x<code>row</code> is beyond the length of the
* model, this will return the model size - 1.
*/
switch (layoutOrientation) {
case JList.VERTICAL_WRAP:
case JList.HORIZONTAL_WRAP:
column);
default:
return row;
}
}
/**
* Returns the closest column to the passed in location.
*/
private int convertLocationToColumn(int x, int y) {
if (cellWidth > 0) {
return 0;
}
int col;
if (isLeftToRight) {
} else {
}
if (col < 0) {
return 0;
}
else if (col >= columnCount) {
return columnCount - 1;
}
return col;
}
return 0;
}
/**
* Returns the row that the model index <code>index</code> will be
* displayed in..
*/
return -1;
}
rowsPerColumn > 0) {
return index % rowsPerColumn;
}
return index / columnCount;
}
return index;
}
/**
* Returns the column that the model index <code>index</code> will be
* displayed in.
*/
return -1;
}
columnCount > 1) {
return index / rowsPerColumn;
}
return index % columnCount;
}
return 0;
}
/**
* If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset
* updateLayoutStateNeeded. This method should be called by methods
* before doing any computation based on the geometry of the list.
* For example it's the first call in paint() and getPreferredSize().
*
* @see #updateLayoutState
*/
protected void maybeUpdateLayoutState()
{
if (updateLayoutStateNeeded != 0) {
}
}
/**
* Recompute the value of cellHeight or cellHeights based
* and cellWidth, based on the current font and the current
* values of fixedCellWidth, fixedCellHeight, and prototypeCellValue.
*
* @see #maybeUpdateLayoutState
*/
protected void updateLayoutState()
{
/* If both JList fixedCellWidth and fixedCellHeight have been
* set, then initialize cellWidth and cellHeight, and set
* cellHeights to null.
*/
if (fixedCellHeight != -1) {
cellHeights = null;
}
else {
cellHeight = -1;
}
/* If either of JList fixedCellWidth and fixedCellHeight haven't
* been set, then initialize cellWidth and cellHeights by
* scanning through the entire model. Note: if the renderer is
* null, we just set cellWidth and cellHeights[*] to zero,
* if they're not set already.
*/
rendererPane.add(c);
if (fixedCellWidth == -1) {
}
if (fixedCellHeight == -1) {
}
}
}
else {
if (cellWidth == -1) {
cellWidth = 0;
}
if (cellHeights == null) {
cellHeights = new int[dataModelSize];
}
}
}
}
columnCount = 1;
}
}
/**
* Invoked when the list is layed out horizontally to determine how
* many columns to create.
* <p>
* This updates the <code>rowsPerColumn, </code><code>columnCount</code>,
* <code>preferredHeight</code> and potentially <code>cellHeight</code>
* instance variables.
*/
int fixedCellHeight) {
if (dataModelSize == 0) {
return;
}
int height;
if (fixedCellHeight != -1) {
}
else {
// Determine the max of the renderer heights.
int maxHeight = 0;
}
}
cellHeights = null;
}
// The number of rows is either determined by the visible row
// count, or by the height of the list.
if (visRows > 0) {
columnCount++;
}
// Because HORIZONTAL_WRAP flows differently, the
// rowsPerColumn needs to be adjusted.
}
}
}
columnCount++;
}
}
listWidth > 0) {
}
}
}
}
return handler;
}
/**
* Mouse input, and focus handling for JList. An instance of this
* class is added to the appropriate java.awt.Component lists
* at installUI() time. Note keyboard input is handled with JComponent
* KeyboardActions, see installKeyboardActions().
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see #createMouseInputListener
* @see #installKeyboardActions
* @see #installUI
*/
{
getHandler().mouseClicked(e);
}
getHandler().mouseEntered(e);
}
getHandler().mouseExited(e);
}
getHandler().mousePressed(e);
}
getHandler().mouseDragged(e);
}
getHandler().mouseMoved(e);
}
getHandler().mouseReleased(e);
}
}
/**
* Creates a delegate that implements MouseInputListener.
* The delegate is added to the corresponding java.awt.Component listener
* lists at installUI() time. Subclasses can override this method to return
* a custom MouseInputListener, e.g.
* <pre>
* class MyListUI extends BasicListUI {
* protected MouseInputListener <b>createMouseInputListener</b>() {
* return new MyMouseInputHandler();
* }
* public class MyMouseInputHandler extends MouseInputHandler {
* public void mouseMoved(MouseEvent e) {
* // do some extra work when the mouse moves
* super.mouseMoved(e);
* }
* }
* }
* </pre>
*
* @see MouseInputHandler
* @see #installUI
*/
return getHandler();
}
/**
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of {@code BasicListUI}.
*/
{
protected void repaintCellFocus()
{
}
/* The focusGained() focusLost() methods run when the JList
* focus changes.
*/
getHandler().focusGained(e);
}
getHandler().focusLost(e);
}
}
return getHandler();
}
/**
* The ListSelectionListener that's added to the JLists selection
* model at installUI time, and whenever the JList.selectionModel property
* changes. When the selection changes we repaint the affected rows.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see #createListSelectionListener
* @see #getCellBounds
* @see #installUI
*/
{
{
getHandler().valueChanged(e);
}
}
/**
* Creates an instance of ListSelectionHandler that's added to
* the JLists by selectionModel as needed. Subclasses can override
* this method to return a custom ListSelectionListener, e.g.
* <pre>
* class MyListUI extends BasicListUI {
* protected ListSelectionListener <b>createListSelectionListener</b>() {
* return new MySelectionListener();
* }
* public class MySelectionListener extends ListSelectionHandler {
* public void valueChanged(ListSelectionEvent e) {
* // do some extra work when the selection changes
* super.valueChange(e);
* }
* }
* }
* </pre>
*
* @see ListSelectionHandler
* @see #installUI
*/
return getHandler();
}
private void redrawList() {
list.revalidate();
}
/**
* The ListDataListener that's added to the JLists model at
* installUI time, and whenever the JList.model property changes.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see JList#getModel
* @see #maybeUpdateLayoutState
* @see #createListDataListener
* @see #installUI
*/
{
getHandler().intervalAdded(e);
}
{
getHandler().intervalRemoved(e);
}
getHandler().contentsChanged(e);
}
}
/**
* Creates an instance of ListDataListener that's added to
* the JLists by model as needed. Subclasses can override
* this method to return a custom ListDataListener, e.g.
* <pre>
* class MyListUI extends BasicListUI {
* protected ListDataListener <b>createListDataListener</b>() {
* return new MyListDataListener();
* }
* public class MyListDataListener extends ListDataHandler {
* public void contentsChanged(ListDataEvent e) {
* // do some extra work when the models contents change
* super.contentsChange(e);
* }
* }
* }
* </pre>
*
* @see ListDataListener
* @see JList#getModel
* @see #installUI
*/
return getHandler();
}
/**
* The PropertyChangeListener that's added to the JList at
* installUI time. When the value of a JList property that
* affects layout changes, we set a bit in updateLayoutStateNeeded.
* If the JLists model changes we additionally remove our listeners
* from the old model. Likewise for the JList selectionModel.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see #maybeUpdateLayoutState
* @see #createPropertyChangeListener
* @see #installUI
*/
{
{
getHandler().propertyChange(e);
}
}
/**
* Creates an instance of PropertyChangeHandler that's added to
* the JList by installUI(). Subclasses can override this method
* to return a custom PropertyChangeListener, e.g.
* <pre>
* class MyListUI extends BasicListUI {
* protected PropertyChangeListener <b>createPropertyChangeListener</b>() {
* return new MyPropertyChangeListener();
* }
* public class MyPropertyChangeListener extends PropertyChangeHandler {
* public void propertyChange(PropertyChangeEvent e) {
* if (e.getPropertyName().equals("model")) {
* // do some extra work when the model changes
* }
* super.propertyChange(e);
* }
* }
* }
* </pre>
*
* @see PropertyChangeListener
* @see #installUI
*/
return getHandler();
}
/** Used by IncrementLeadSelectionAction. Indicates the action should
* change the lead, and not select it. */
/** Used by IncrementLeadSelectionAction. Indicates the action should
* change the selection and lead. */
/** Used by IncrementLeadSelectionAction. Indicates the action should
* extend the selection from the anchor to the next index. */
"selectPreviousColumn";
"selectPreviousColumnExtendSelection";
"selectPreviousColumnChangeLead";
"selectNextColumnExtendSelection";
"selectNextColumnChangeLead";
"selectPreviousRowExtendSelection";
"selectPreviousRowChangeLead";
"selectNextRowExtendSelection";
"selectNextRowChangeLead";
"selectFirstRowExtendSelection";
"selectFirstRowChangeLead";
"selectLastRowExtendSelection";
"selectLastRowChangeLead";
"scrollUpExtendSelection";
"scrollUpChangeLead";
"scrollDownExtendSelection";
"scrollDownChangeLead";
// add the lead item to the selection without changing lead or anchor
// toggle the selected state of the lead item and move the anchor to it
// extend the selection to the lead item
// move the anchor to the lead and ensure only that item is selected
super(name);
}
if (name == SELECT_PREVIOUS_COLUMN) {
}
else if (name == SELECT_PREVIOUS_COLUMN_EXTEND) {
}
else if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD) {
}
else if (name == SELECT_NEXT_COLUMN) {
}
else if (name == SELECT_NEXT_COLUMN_EXTEND) {
}
else if (name == SELECT_NEXT_COLUMN_CHANGE_LEAD) {
}
else if (name == SELECT_PREVIOUS_ROW) {
}
else if (name == SELECT_PREVIOUS_ROW_EXTEND) {
}
else if (name == SELECT_PREVIOUS_ROW_CHANGE_LEAD) {
}
else if (name == SELECT_NEXT_ROW) {
}
else if (name == SELECT_NEXT_ROW_EXTEND) {
}
else if (name == SELECT_NEXT_ROW_CHANGE_LEAD) {
}
else if (name == SELECT_FIRST_ROW) {
}
else if (name == SELECT_FIRST_ROW_EXTEND) {
}
else if (name == SELECT_FIRST_ROW_CHANGE_LEAD) {
}
else if (name == SELECT_LAST_ROW) {
}
else if (name == SELECT_LAST_ROW_EXTEND) {
}
else if (name == SELECT_LAST_ROW_CHANGE_LEAD) {
}
}
else if (name == SCROLL_UP_EXTEND) {
}
else if (name == SCROLL_UP_CHANGE_LEAD) {
}
else if (name == SCROLL_DOWN) {
}
else if (name == SCROLL_DOWN_EXTEND) {
}
else if (name == SCROLL_DOWN_CHANGE_LEAD) {
}
else if (name == SELECT_ALL) {
}
else if (name == CLEAR_SELECTION) {
}
else if (name == ADD_TO_SELECTION) {
int index = adjustIndex(
list.setValueIsAdjusting(true);
list.setValueIsAdjusting(false);
}
}
else if (name == TOGGLE_AND_ANCHOR) {
int index = adjustIndex(
} else {
}
}
0);
}
else if (name == MOVE_SELECTION_TO) {
0);
}
}
if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD ||
name == SCROLL_UP_CHANGE_LEAD ||
name == SCROLL_DOWN_CHANGE_LEAD) {
// discontinuous selection actions are only enabled for
// DefaultListSelectionModel
instanceof DefaultListSelectionModel;
}
return true;
}
}
if (size > 0) {
if (lead == -1) {
}
} else {
list.setValueIsAdjusting(true);
// this is done to restore the anchor and lead
list.setValueIsAdjusting(false);
}
}
}
return -1;
}
int index = -1;
}
// apply for horizontal scrolling: the step for next
// page index is number of visible columns
if (direction < 0) {
// left
p.x = cellBounds.x - 1;
}
// this is necessary for right-to-left orientation only
if (cellBounds.y != leadRect.y) {
}
}
else {
// right
}
if (cellBounds.y != leadRect.y) {
p.x = cellBounds.x - 1;
}
}
}
else {
if (direction < 0) {
// up
// go to the first visible cell
// if lead is the first visible cell (or above it)
// adjust the visible rect up
p.y = visRect.y;
// go one cell down if first visible cell doesn't fit
// into adjasted visible rectangle
if (cellBounds.y < visRect.y) {
}
// if index isn't less then lead
// try to go to cell previous to lead
if (cellBounds.y >= leadRect.y) {
p.y = leadRect.y - 1;
}
}
}
else {
// down
// go to the last completely visible cell
// go up one cell if last visible cell doesn't fit
// into visible rectangle
p.y = cellBounds.y - 1;
}
// if lead is the last completely visible index
// (or below it) adjust the visible rect down
// go one cell up if last visible cell doesn't fit
// into adjasted visible rectangle
p.y = cellBounds.y - 1;
}
// if index isn't greater then lead
// try to go to cell next after lead
if (cellBounds.y <= leadRect.y) {
}
}
}
}
return index;
}
// CHANGE_LEAD is only valid with multiple interval selection
if (type == CHANGE_LEAD &&
}
// IMPORTANT - This needs to happen before the index is changed.
// This is because JFileChooser, which uses JList, also scrolls
// the selected item into view. If that happens first, then
// this method becomes a no-op.
if (type == EXTEND_SELECTION) {
if (anchor == -1) {
anchor = 0;
}
}
else if (type == CHANGE_SELECTION) {
}
else {
// casting should be safe since the action is only enabled
// for DefaultListSelectionModel
}
}
}
/**
* When scroll down makes selected index the last completely visible
* index. When scroll up makes selected index the first visible index.
* Adjust visible rectangle respect to list's component orientation.
*/
int direction) {
if (direction == 0) {
return;
}
// horizontal
if (direction > 0) {
// right for left-to-right
int startIndex =
}
}
}
else {
if (direction > 0) {
// left for right-to-left
int rightIndex =
rightRect.x > cellBounds.x) {
}
}
else {
// adjust width to fit into visible rectangle
}
}
}
else {
// vertical
if (direction > 0 &&
(cellBounds.y < visRect.y ||
//down
int startIndex =
}
}
else {
// adjust height to fit into visible rectangle
}
}
}
}
int amount) {
if (index == -1) {
return 0;
} else if (size == 1) {
// there's only one item so we should select it
return 0;
return -1;
}
// No wrapping.
return -1;
}
if (row >= maxRowCount) {
return -1;
}
}
// Won't change the selection.
return -1;
}
if (index == -1) {
if (size > 0) {
if (amount > 0) {
index = 0;
}
else {
}
}
} else if (size == 1) {
// there's only one item so we should select it
index = 0;
}
} else {
}
return index;
}
}
//
// KeyListener
//
/**
* Invoked when a key has been typed.
*
* Moves the keyboard focus to the first element whose prefix matches the
* sequence of alphanumeric keys pressed by the user with delay less
* than value of <code>timeFactor</code> property (or 1000 milliseconds
* if it is not defined). Subsequent same key presses move the keyboard
* focus to the next object that starts with the same letter until another
* key is pressed, then it is treated as the prefix with appropriate number
* of the same letters followed by first typed another letter.
*/
isNavigationKey(e)) {
// Nothing to select
return;
}
boolean startingFromSelection = true;
char c = e.getKeyChar();
typedString += c;
// Subsequent same key presses move the keyboard focus to the next
// object that starts with the same letter.
startIndex++;
} else {
}
} else {
startIndex++;
typedString = "" + c;
}
startingFromSelection = false;
startIndex = 0;
}
if (index >= 0) {
} else if (startingFromSelection) { // wrap
if (index >= 0) {
}
}
}
/**
* Invoked when a key has been pressed.
*
* Checks to see if the key event is a navigation key to prevent
* dispatching these keys for the first letter navigation.
*/
if ( isNavigationKey(e) ) {
prefix = "";
typedString = "";
lastTime = 0L;
}
}
/**
* Invoked when a key has been released.
* See the class description for {@link KeyEvent} for a definition of
* a key released event.
*/
}
/**
* Returns whether or not the supplied key event maps to a key that is used for
* navigation. This is used for optimizing key input by only passing non-
* navigation keys to the first letter navigation mechanism.
*/
return true;
}
return false;
}
//
// PropertyChangeListener
//
/* If the JList.model property changes, remove our listener,
* listDataListener from the old model and add it to the new one.
*/
if (propertyName == "model") {
}
}
redrawList();
}
/* If the JList.selectionModel property changes, remove our listener,
* listSelectionListener from the old selectionModel and add it to the new one.
*/
else if (propertyName == "selectionModel") {
}
}
redrawList();
}
else if (propertyName == "cellRenderer") {
redrawList();
}
else if (propertyName == "font") {
redrawList();
}
else if (propertyName == "prototypeCellValue") {
redrawList();
}
else if (propertyName == "fixedCellHeight") {
redrawList();
}
else if (propertyName == "fixedCellWidth") {
redrawList();
}
else if (propertyName == "selectionForeground") {
}
else if (propertyName == "selectionBackground") {
}
else if ("layoutOrientation" == propertyName) {
redrawList();
}
else if ("visibleRowCount" == propertyName) {
redrawList();
}
}
else if ("componentOrientation" == propertyName) {
redrawList();
inputMap);
} else if ("List.isFileList" == propertyName) {
redrawList();
} else if ("dropLocation" == propertyName) {
}
}
return;
}
Rectangle r;
r = getDropLineRect(loc);
} else {
}
if (r != null) {
}
}
//
// ListDataListener
//
/* Sync the SelectionModel with the DataModel.
*/
}
/* Repaint the entire list, from the origin of
* the first added cell, to the bottom of the
* component.
*/
redrawList();
}
{
/* Sync the SelectionModel with the DataModel.
*/
}
/* Repaint the entire list, from the origin of
* the first removed cell, to the bottom of the
* component.
*/
redrawList();
}
redrawList();
}
//
// ListSelectionListener
//
}
}
//
// MouseListener
//
}
}
}
// Whether or not the mouse press (which is being considered as part
// of a drag sequence) also caused the selection change to be fully
// processed.
private boolean dragPressDidSelection;
return;
}
boolean grabFocus = true;
// different behavior if drag is enabled
if (dragEnabled) {
// if we have a valid row and this is a drag initiating event
dragPressDidSelection = false;
if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// do nothing for control - will be handled on release
// or when drag starts
return;
// clicking on something that's already selected
// and need to make it the lead now
return;
}
// could be a drag initiating event - don't grab focus
grabFocus = false;
dragPressDidSelection = true;
}
} else {
// When drag is enabled mouse drags won't change the selection
// in the list, so we only set the isAdjusting flag when it's
// not enabled
list.setValueIsAdjusting(true);
}
if (grabFocus) {
}
adjustSelection(e);
}
if (row < 0) {
// If shift is down in multi-select, we should do nothing.
// For single select or non-shift-click, clear the selection
if (isFileList &&
(!e.isShiftDown() ||
}
}
else {
boolean anchorSelected;
if (anchorIndex == -1) {
anchorIndex = 0;
anchorSelected = false;
} else {
}
if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
if (e.isShiftDown()) {
if (anchorSelected) {
} else {
if (isFileList) {
}
}
} else {
}
} else if (e.isShiftDown()) {
} else {
}
}
}
}
}
return;
}
if (list.getDragEnabled()) {
DragRecognitionSupport.mouseDragged(e, this);
return;
}
return;
}
if (row != -1) {
// 4835633. Dragging onto a File should not select it.
if (isFileList) {
return;
}
if (cellBounds != null) {
}
}
}
}
return;
}
if (list.getDragEnabled()) {
if (!dragPressDidSelection) {
}
}
} else {
list.setValueIsAdjusting(false);
}
}
//
// FocusListener
//
protected void repaintCellFocus()
{
if (leadIndex != -1) {
if (r != null) {
}
}
}
/* The focusGained() focusLost() methods run when the JList
* focus changes.
*/
}
}
}
}
/**
* Create a Transferable to use as the source for a data transfer.
*
* @param c The component holding the data to be transfered. This
* argument is provided to enable sharing of TransferHandlers by
* multiple components.
* @return The representation of the data to be transfered.
*
*/
if (c instanceof JList) {
return null;
}
}
// remove the last newline
}
return null;
}
return COPY;
}
}
}