Diamond Control Suite 3.0

diamondedge.swing
Class DsListView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by diamondedge.swing.DsListView
All Implemented Interfaces:
DsConstants, FocusListener, KeyListener, MouseListener, MouseMotionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, ScrollPaneConstants, SwingConstants

public class DsListView
extends JScrollPane
implements DsConstants, CellEditorListener, ItemSelectable, MouseListener, ListSelectionListener

DsListView displays a collection of objects such as files or folders typically showing an icon and a description label using one of four different views. The View property determines how the objects are arranged:

This is the component typically used to display files in a file browser. However, it can be used anywhere a list of objects needs to be displayed.

Each object is represented by a DsListViewItem object which holds all of the information for the object being displayed including a list of DsListCell objects for each column in the details view. The items can be created in a number of different ways. One way is to call the addItem method. Another way is to use the addItems to add an array or List of objects. If the object added implements the DsListViewObject interface then it is used to fill in the other properties of the DsListViewItem such as the icons.

The column headers can be displayed in the details view by setting the ColumnHeaderVisible property. Several properties and methods are available to manipulate the columns such as adding columns and changing the width, name, style, etc on each of the columns.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DETAILS
          ViewType laying out the items a table with one row per item showing the text of each cell in each column.
static int FIND_CELL
          Find the value in the text of each cell (row,column) of the details view table
static int FIND_DATA
          Find the value in the user data of each cell (row,column) of the details view table
static int FIND_LABEL
          Find the value in the label of each item (Note: this is the cell in column 0)
static int FIND_PARTIAL
          When finding a string it may match the first part of string found
static int FIND_WHOLE
          When finding a string make sure the whole string found matches
protected  IconList iconlist
           
static int LARGE_ICON
          ViewType laying out the items left to right and then wrapping on the next line.
static int LIST
          ViewType laying out the items a column from top to bottom.
static int SMALL_ICON
          ViewType laying out the items left to right and then wrapping on the next line.
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface diamondedge.swing.DsConstants
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DsListView()
          Creates a DsListView with the DETAILS view type.
DsListView(int viewType)
          Creates a DsListView with the specified view type.
 
Method Summary
 TableColumn addColumn()
           
 TableColumn addColumn(String columnName, String id)
           
 void addColumnClickListener(ColumnClickListener listener)
          Add a listener to the list that's notified each time a column is clicked on.
 DsListViewItem addItem()
          Appends a DsListViewItem object to the list.
 DsListViewItem addItem(int index, String key, Object text, Object largeIcon, Object smallIcon)
          Adds a DsListViewItem object to the list.
 void addItem(List values)
          Adds an item and loads the data for multiple cells into that item.
 void addItem(Object obj)
          Loads the data from an object into the ListView.
 void addItem(Object[] values)
          Adds an item and loads the data for multiple cells into that item.
 void addItemListener(ItemListener l)
          Adds an ItemListener to monitor the state of the checkbox.
 void addItems(List objects)
          Loads the data from multiple objects into the ListView.
 void addItems(Object[] objects)
          Loads the data from multiple objects into the ListView.
 void addListSelectionListener(ListSelectionListener l)
          Adds an ListSelectionListener to the JTable selection model.
 void addMouseMotionListener(MouseMotionListener listener)
           
 void clear()
          Removes all objects in the list.
protected  DsListViewItem createListItem()
          Creates a new DsListViewItem.
 void editingCanceled(ChangeEvent e)
          This tells the listeners the editor has canceled editing
 void editingStopped(ChangeEvent e)
          This tells the listeners the editor has ended editing
 void ensureVisible(int row)
          Scroll to make sure the row is visible on the screen
 DsListViewItem findItem(String str)
          Finds an item in the list and returns a reference to that item using a case insensitive string comparison.
 int findItem(String str, int col, int startRow, boolean partial)
          Finds the row index of an item in the list using a case insensitive string comparison.
 DsListViewItem findItem(String str, int where, int startRow, int matchType)
          Finds an item in the list and returns a reference to that item using a case insensitive string comparison.
protected  void fireColumnClicked(MouseEvent e)
          This method notifies the ColumnClickListeners that a column has been clicked on.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          This method notifies ListSelectionListeners that the selection model has changed.
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 int getCenterBorder()
          Returns whether to draw a border in between the InnerBorder and the OuterBorder.
 TableColumn getColumn(int index)
          Returns the specified column.
 TableColumn getColumn(String columnId)
          Returns the specified column.
 int getColumnCount()
          Determines the total number of columns.
protected  JViewport getColumnHeaderViewport()
           
 TableColumnModel getColumnModel()
          Returns the model representing the columns in the DsListView
 String getColumnName(int column)
          Returns the object used to get the text displayed in the given column header.
 DsCellProperties getColumnProperties(int col)
          Returns the default cell containing the default properties for the column.
 int getColumnWidth(int index)
          Determines the width of the specified column in pixels.
 JComponent getComponent()
          Returns the component that is inside the DsScrollPanel.
 DsListViewItem getFirstVisible()
          Retrieves a reference of the first item visible in the client area.
 int getFirstVisibleIndex()
          Retrieves the index of the first item visible in the client area.
 int getHighlightPolicy()
          Determines when the selection is highlighted.
 IconList getIconList()
          Returns the IconList object to be used for the icons displayed in the DsListView.
 int getInnerBorder()
          Returns whether to draw a border inside of the CenterBorder.
 DsListViewItem getItem(int index)
          Returns a specific item in the list by position.
 DsListViewItem getItem(Object indexOrKey)
          Returns a specific item in the list by position (Number) or by key (String).
 DsListViewItem getItem(String key)
          Returns a specific item in the list by key.
 int getItemCount()
          Returns the number of objects in the list.
 DsListViewItem getLastItemEdited()
          Returns the last DsListViewItem edited.
 Color getLineBorderColor()
          Returns the color used to draw the line border.
 int getLineBorderWidth()
          Returns the width of the line border drawn around the component.
 diamondedge.swing.DsListViewModel getModel()
          Returns the model containing the data displayed in the DsListView
 int getNumClicksToSort()
          Returns the number of clicks on the column header required to allow the user to select the column to sort on or to change the sort order.
 int getOuterBorder()
          Returns whether to draw a border on the outside of the component but inside of the outline if it exists.
 int getRowHeight()
          Returns the height of all table rows, in pixels.
 int getRowHeight(int row)
          Returns the height of a specific table row, in pixels.
 int getSelectedIndex()
          Returns the index the currently selected DsListViewItem or the first one if more than one is selected.
 DsListViewItem getSelectedItem()
          Returns a reference to the currently selected DsListViewItem object.
 Object[] getSelectedObjects()
          Returns an array (length 1) containing the last DsListViewItem edited or null.
 int getSelectionMode()
          Returns a value indicating whether a user can make multiple selections in the DsListView control and how the multiple selections can be made.
 ListSelectionModel getSelectionModel()
          Returns the model representing the selected items in the DsListView
 boolean getShowGrid()
          Returns whether the grid lines should be drawn between cells.
 int getSortColumn()
          Returns the column that is currently being used to sort the list items.
 int getSortOrder()
          Returns whether or not the ListItems will be sorted in ascending or descending order.
 String getTextAt(int row, int col)
          Returns the text (contents formatted as a string) for the cell at the given row and column.
 Object getValueAt(int row, int column)
          Returns the cell value at row and column.
 int getView()
          Returns the current view type of the DsListView control.
 boolean hasFocus()
           
 DsListViewItem hitTest(int x, int y)
          Returns a reference to the DsListViewItem object object located at the coordinates of x and y.
 boolean isColumnHeaderVisible()
          Returns whether there is a fixed row displaying a column header for each column.
 boolean isColumnReorderingAllowed()
          Returns whether a user can reorder columns in DETAILS view.
 boolean isColumnResizingAllowed()
          Returns whether a user can resize columns in DETAILS view.
 boolean isSelected(int row)
          Returns a value which determines if the item at the given row is selected.
 boolean isShowingCheckBoxes()
          Returns a value which determines if the control displays a checkbox next to each item in the list.
 boolean isSorted()
          Indicates whether the elements of a control are automatically sorted alphabetically.
 void keyPressed(KeyEvent e)
           
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
 void mouseClicked(MouseEvent e)
          MouseListener interface - Forward MouseEvents from child component
 void mouseDragged(MouseEvent e)
          MouseMotionListener interface - Forward MouseMotionEvents from child component
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void refresh()
          Reloads data from the original DsListViewObjects.
 void removeColumnClickListener(ColumnClickListener listener)
          Remove a listener from the list that's notified each time a column is clicked on.
 void removeItem(int index)
          Removes a item from the list
 void removeItemListener(ItemListener l)
          Removes an ItemListener from the checkbox.
 void removeListSelectionListener(ListSelectionListener l)
          Removes an ListSelectionListener from the JTable selection model.
 void removeMouseMotionListener(MouseMotionListener listener)
           
 void requestFocus()
           
 boolean requestFocus(boolean temporary)
           
 boolean requestFocusInWindow()
           
 void setBackground(Color c)
           
 void setCenterBorder(int val)
          Creates a border in between the InnerBorder and the OuterBorder.
 void setColumnAutoResizeMode(int resizeMode)
          Sets the resize mode for columns in DETAILS view.
 void setColumnCount(int val)
          Determines the total number of columns.
 void setColumnHeaderVisible(boolean visible)
          Sets whether there is a fixed row displaying a column header for each column.
 void setColumnHorizontalAlignment(int column, int align)
          Sets the horizontal alignment of the text in the column header.
 void setColumnName(int column, String name)
          Sets the text displayed in the column header.
 void setColumnReorderingAllowed(boolean reorderingAllowed)
          Sets whether a user can reorder columns in DETAILS view.
 void setColumnResizingAllowed(boolean resizingAllowed)
          Sets whether a user can resize columns in DETAILS view.
 void setColumnWidth(int index, int val)
          Sets the width of the specified column in pixels.
 void setColumnWidth(String columnId, int val)
          Sets the width of the specified column in pixels.
 void setComponent(JComponent c)
          Sets the component that is inside the DsScrollPanel.
 void setCursor(Cursor cursor)
           
 void setEnabled(boolean b)
           
 void setFont(Font f)
           
 void setForeground(Color c)
           
 void setHighlightPolicy(int val)
          Determines when the selection is highlighted.
 void setIconList(IconList i)
          Sets the IconList object to be used for the icons displayed in the DsListView.
 void setInnerBorder(int val)
          Creates a border on the inside of the CenterBorder.
 void setItemCount(int val)
          Sets the number of objects in the list.
 void setLabelEdit(boolean val)
          Sets a value that determines if a user can edit the label (first column in DETAILS view) of a DsListViewItem object.
 void setLineBorderColor(Color c)
          Sets the color used to draw the line border.
 void setLineBorderWidth(int lineWidth)
          Sets the width of the line border drawn around the component.
 void setModel(diamondedge.swing.DsListViewModel model)
          Set a new data model to display in the DsListView.
 void setNumClicksToSort(int numClicks)
          Allow the user to interactively select which column to sort on by clicking on the column header.
 void setOuterBorder(int val)
          Creates a border on the outside of the component but inside of the outline if it exists.
 void setRowHeight(int height)
          Sets the height of all table rows, in pixels.
 void setRowHeight(int row, int height)
          Sets the height of a specific table row, in pixels.
 void setSelected(int index, boolean sel)
          Sets a value which determines if the item at the given row is selected.
 void setSelectedIndex(int index)
          Selects the specified row.
 void setSelectedItem(DsListViewItem item)
          Selects the specified list item
 void setSelectionMode(int selectionMode)
          Set the selection mode.
 void setShowGrid(boolean showGrid)
          Sets whether the grid lines should be drawn between cells.
 void setShowingCheckBoxes(boolean val)
          Sets a value which determines if the control displays a checkbox next to each item in the list.
 void setSize(Dimension d)
           
 void setSize(int width, int height)
           
 void setSortColumn(int column)
          Sets the column that is currently being used to sort the list items.
 void setSorted(boolean sort)
          Sets whether the list items are automatically sorted alphabetically.
 void setSortIcons(Icon ascendingSortIcon, Icon descendingSortIcon)
          Set custom icons that show which direction a column is sorted These are only used if sorting by one column
 void setSortOrder(int sortOrder)
          Sets whether or not the ListItems will be sorted in ascending or descending order.
 void setValueAt(Object val, int row, int col)
          Sets the value for the cell in the model at row and column.
 void setView(int viewtype)
          Sets the current view type of the DsListView control.
 void setVisible(boolean b)
           
 void sort()
          Sorts the list items according to the current sort column and order.
 void sort(int column, int sortOrder)
          Sorts the list items by comparing values in the given column.
 void updateUI()
           
 void valueChanged(ListSelectionEvent e)
          A ListSelectionListener that forwards ListSelectionEvents from the selectionModel to the ListView ListSelectionListeners.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent,