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, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iconlist

protected IconList iconlist

LARGE_ICON

public static final int LARGE_ICON
ViewType laying out the items left to right and then wrapping on the next line. The large icon is displayed above the label.

See Also:
Constant Field Values

SMALL_ICON

public static final int SMALL_ICON
ViewType laying out the items left to right and then wrapping on the next line. The small icon is displayed to the left of the label.

See Also:
Constant Field Values

LIST

public static final int LIST
ViewType laying out the items a column from top to bottom. The small icon is displayed to the left of the label.

See Also:
Constant Field Values

DETAILS

public static final int DETAILS
ViewType laying out the items a table with one row per item showing the text of each cell in each column. The small icon is displayed to the left of the label.

See Also:
Constant Field Values

FIND_LABEL

public static final int FIND_LABEL
Find the value in the label of each item (Note: this is the cell in column 0)

See Also:
Constant Field Values

FIND_CELL

public static final int FIND_CELL
Find the value in the text of each cell (row,column) of the details view table

See Also:
Constant Field Values

FIND_DATA

public static final int FIND_DATA
Find the value in the user data of each cell (row,column) of the details view table

See Also:
Constant Field Values

FIND_WHOLE

public static final int FIND_WHOLE
When finding a string make sure the whole string found matches

See Also:
Constant Field Values

FIND_PARTIAL

public static final int FIND_PARTIAL
When finding a string it may match the first part of string found

See Also:
Constant Field Values
Constructor Detail

DsListView

public DsListView()
Creates a DsListView with the DETAILS view type.


DsListView

public DsListView(int viewType)
Creates a DsListView with the specified view type.

Parameters:
viewType - One of: LARGE_ICON, SMALL_ICON, LIST, DETAILS
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JScrollPane

getModel

public diamondedge.swing.DsListViewModel getModel()
Returns the model containing the data displayed in the DsListView


setModel

public void setModel(diamondedge.swing.DsListViewModel model)
Set a new data model to display in the DsListView. Note: this resets most properties back to the default values so if you change the model you should do it before setting any properties


getColumnModel

public TableColumnModel getColumnModel()
Returns the model representing the columns in the DsListView


getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the model representing the selected items in the DsListView


getView

public int getView()
Returns the current view type of the DsListView control.


setView

public void setView(int viewtype)
Sets the current view type of the DsListView control.

Parameters:
viewtype - One of: LARGE_ICON, SMALL_ICON, LIST, DETAILS

getIconList

public IconList getIconList()
Returns the IconList object to be used for the icons displayed in the DsListView.

See Also:
DsListItem.getSmallIcon(IconList), DsListViewItem.getLargeIcon(IconList)

setIconList

public void setIconList(IconList i)
Sets the IconList object to be used for the icons displayed in the DsListView. This allow an index or key to be stored in the DsListViewItem which then is used to get the icon out of this IconList based on that index/key.

See Also:
DsListItem.getSmallIcon(IconList), DsListViewItem.getLargeIcon(IconList)

setLabelEdit

public 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.


getValueAt

public Object getValueAt(int row,
                         int column)
Returns the cell value at row and column.

Note: The column is specified in the model's column order.

Returns:
the Object at the specified row and column

setValueAt

public void setValueAt(Object val,
                       int row,
                       int col)
Sets the value for the cell in the model at row and column.

Note: The column is specified in the model's column order.


getTextAt

public String getTextAt(int row,
                        int col)
Returns the text (contents formatted as a string) for the cell at the given row and column.


getHighlightPolicy

public int getHighlightPolicy()
Determines when the selection is highlighted.


setHighlightPolicy

public void setHighlightPolicy(int val)
Determines when the selection is highlighted. Valid values are:


getSelectionMode

public 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.


setSelectionMode

public void setSelectionMode(int selectionMode)
Set the selection mode. The following selectionMode values are allowed:


isSelected

public boolean isSelected(int row)
Returns a value which determines if the item at the given row is selected.


setSelected

public void setSelected(int index,
                        boolean sel)
Sets a value which determines if the item at the given row is selected.


getSelectedIndex

public int getSelectedIndex()
Returns the index the currently selected DsListViewItem or the first one if more than one is selected. Returns -1 if none are selected.


setSelectedIndex

public void setSelectedIndex(int index)
Selects the specified row. An index of -1 removes the selection.


getSelectedItem

public DsListViewItem getSelectedItem()
Returns a reference to the currently selected DsListViewItem object.


setSelectedItem

public void setSelectedItem(DsListViewItem item)
Selects the specified list item


isSorted

public boolean isSorted()
Indicates whether the elements of a control are automatically sorted alphabetically.


setSorted

public void setSorted(boolean sort)
Sets whether the list items are automatically sorted alphabetically.


getSortColumn

public int getSortColumn()
Returns the column that is currently being used to sort the list items.


setSortColumn

public void setSortColumn(int column)
Sets the column that is currently being used to sort the list items.


getSortOrder

public int getSortOrder()
Returns whether or not the ListItems will be sorted in ascending or descending order.


setSortOrder

public void setSortOrder(int sortOrder)
Sets whether or not the ListItems will be sorted in ascending or descending order.

Parameters:
sortOrder - One of: ASCENDING, DESCENDING, ASCENDING_CASE, DESCENDING_CASE

sort

public void sort()
Sorts the list items according to the current sort column and order. Normally, you would only call this if automatic sorting is off ie. Sorted property is false and the SortColumn and SortOrder properties are set.

See Also:
setSorted(boolean), setSortColumn(int), setSortOrder(int)

sort

public void sort(int column,
                 int sortOrder)
Sorts the list items by comparing values in the given column. Normally, you would only call this if automatic sorting is off ie. Sorted property is false.

Parameters:
column - column to be sorted
sortOrder - One of: DsListView.ASCENDING, DsListView.DESCENDING, DsConstants.ASCENDING_CASE, DsConstants.DESCENDING_CASE

setSortIcons

public 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


getNumClicksToSort

public 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. change the sorting interactively.

See Also:
setNumClicksToSort(int), setSorted(boolean)

setNumClicksToSort

public void setNumClicksToSort(int numClicks)
Allow the user to interactively select which column to sort on by clicking on the column header. Clicking again on the same column will reverse the sort order. The Sorted property must be also be set. A value of 0 means the user cannot change the sorting interactively.

Parameters:
numClicks - number of clicks required (either 0, 1, or 2).
See Also:
setSorted(boolean)

findItem

public DsListViewItem findItem(String str)
                        throws Exception
Finds an item in the list and returns a reference to that item using a case insensitive string comparison. Only the label of each item will be searched and it must match the entire label.

Parameters:
str - String to find in the ListView
Throws:
Exception

findItem

public DsListViewItem findItem(String str,
                               int where,
                               int startRow,
                               int matchType)
                        throws Exception
Finds an item in the list and returns a reference to that item using a case insensitive string comparison.

Parameters:
str - String to find in the ListView
where - One of: FIND_LABEL, FIND_CELL, FIND_DATA
startRow - starting item to begin searching
matchType - One of: FIND_WHOLE, FIND_PARTIAL
Throws:
Exception

findItem

public 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.

Parameters:
str - String to find in the List
col - which column to search
startRow - starting item to begin searching
partial - match the beginning of the string or the whole string

hitTest

public DsListViewItem hitTest(int x,
                              int y)
Returns a reference to the DsListViewItem object object located at the coordinates of x and y.


ensureVisible

public void ensureVisible(int row)
Scroll to make sure the row is visible on the screen


getFirstVisible

public DsListViewItem getFirstVisible()
Retrieves a reference of the first item visible in the client area.


getFirstVisibleIndex

public int getFirstVisibleIndex()
Retrieves the index of the first item visible in the client area.


setBackground

public void setBackground(Color c)

getItemCount

public int getItemCount()
Returns the number of objects in the list.


setItemCount

public void setItemCount(int val)
Sets the number of objects in the list.


addItem

public DsListViewItem addItem()
Appends a DsListViewItem object to the list.


addItem

public DsListViewItem addItem(int index,
                              String key,
                              Object text,
                              Object largeIcon,
                              Object smallIcon)
Adds a DsListViewItem object to the list.

Parameters:
index - Row position to add the item
key - Unique string that can be used to locate this item
text - String that will displayed as the label and column 0
largeIcon - index (Integer) or key (String) of an icon in the associated IconList control. Can also be an Icon or Image. Used in LARGE_ICON view.
smallIcon - index (Integer) or key (String) of an icon in the associated IconList control. Can also be an Icon or Image. Used in all views except LARGE_ICON view.
See Also:
setIconList(diamondedge.swing.IconList)

addItem

public void addItem(Object obj)
Loads the data from an object into the ListView. If the object is an instanceof DsListViewObject then all columns, icons, etc are also loaded.


addItem

public void addItem(Object[] values)
Adds an item and loads the data for multiple cells into that item.


addItem

public void addItem(List values)
Adds an item and loads the data for multiple cells into that item.


removeItem

public void removeItem(int index)
Removes a item from the list

Parameters:
index - Row position of item to remove

createListItem

protected DsListViewItem createListItem()
Creates a new DsListViewItem. Subclasses can override this to return an instance of a subclass of DsListViewItem


getItem

public DsListViewItem getItem(int index)
Returns a specific item in the list by position.

Parameters:
index - Row position of item to remove

getItem

public DsListViewItem getItem(String key)
Returns a specific item in the list by key.


getItem

public DsListViewItem getItem(Object indexOrKey)
Returns a specific item in the list by position (Number) or by key (String).


clear

public void clear()
Removes all objects in the list.


addItems

public void addItems(Object[] objects)
Loads the data from multiple objects into the ListView. If the object is an instanceof DsListViewObject then all columns, icons, etc are also loaded. Otherwise, the return from toString() for each object will be displayed in the list. The object is stored in the Data property for the DsListViewItem.


addItems

public void addItems(List objects)
Loads the data from multiple objects into the ListView. If the object is an instanceof DsListViewObject then all columns, icons, etc are also loaded. Otherwise, the return from toString() for each object will be displayed in the list. The object is stored in the Data property for the DsListViewItem.


refresh

public void refresh()
Reloads data from the original DsListViewObjects. Useful if you know that the data has changed and you want to update the display.


getShowGrid

public boolean getShowGrid()
Returns whether the grid lines should be drawn between cells.


setShowGrid

public void setShowGrid(boolean showGrid)
Sets whether the grid lines should be drawn between cells.


getColumnHeaderViewport

protected JViewport getColumnHeaderViewport()

isColumnHeaderVisible

public boolean isColumnHeaderVisible()
Returns whether there is a fixed row displaying a column header for each column.


setColumnHeaderVisible

public void setColumnHeaderVisible(boolean visible)
Sets whether there is a fixed row displaying a column header for each column.


getColumnCount

public int getColumnCount()
Determines the total number of columns.


setColumnCount

public void setColumnCount(int val)
Determines the total number of columns.


getColumnProperties

public DsCellProperties getColumnProperties(int col)
Returns the default cell containing the default properties for the column.


setColumnHorizontalAlignment

public void setColumnHorizontalAlignment(int column,
                                         int align)
Sets the horizontal alignment of the text in the column header. Also sets the default horizontal alignment of text in the cells for the column. Valid values are:


getColumn

public TableColumn getColumn(int index)
Returns the specified column.


getColumn

public TableColumn getColumn(String columnId)
Returns the specified column.


getColumnName

public String getColumnName(int column)
Returns the object used to get the text displayed in the given column header.


setColumnName

public void setColumnName(int column,
                          String name)
Sets the text displayed in the column header.


getColumnWidth

public int getColumnWidth(int index)
Determines the width of the specified column in pixels.


setColumnWidth

public void setColumnWidth(int index,
                           int val)
Sets the width of the specified column in pixels.


setColumnWidth

public void setColumnWidth(String columnId,
                           int val)
Sets the width of the specified column in pixels.


addColumn

public TableColumn addColumn()

addColumn

public TableColumn addColumn(String columnName,
                             String id)

isColumnReorderingAllowed

public boolean isColumnReorderingAllowed()
Returns whether a user can reorder columns in DETAILS view.


setColumnReorderingAllowed

public void setColumnReorderingAllowed(boolean reorderingAllowed)
Sets whether a user can reorder columns in DETAILS view.


isColumnResizingAllowed

public boolean isColumnResizingAllowed()
Returns whether a user can resize columns in DETAILS view.


setColumnResizingAllowed

public void setColumnResizingAllowed(boolean resizingAllowed)
Sets whether a user can resize columns in DETAILS view.


setColumnAutoResizeMode

public void setColumnAutoResizeMode(int resizeMode)
Sets the resize mode for columns in DETAILS view.

See Also:
JTable.setAutoResizeMode(int)

getRowHeight

public int getRowHeight()
Returns the height of all table rows, in pixels. The default row height is 16.


setRowHeight

public void setRowHeight(int height)
Sets the height of all table rows, in pixels. The default row height is 16. This removes any specific row heights for individual rows

See Also:
setRowHeight(int,int)

getRowHeight

public int getRowHeight(int row)
Returns the height of a specific table row, in pixels. The default row height is 16.


setRowHeight

public void setRowHeight(int row,
                         int height)
Sets the height of a specific table row, in pixels. The default row height is 16.


isShowingCheckBoxes

public boolean isShowingCheckBoxes()
Returns a value which determines if the control displays a checkbox next to each item in the list.


setShowingCheckBoxes

public void setShowingCheckBoxes(boolean val)
Sets a value which determines if the control displays a checkbox next to each item in the list.


getLastItemEdited

public DsListViewItem getLastItemEdited()
Returns the last DsListViewItem edited.


editingCanceled

public void editingCanceled(ChangeEvent e)
This tells the listeners the editor has canceled editing

Specified by:
editingCanceled in interface CellEditorListener

editingStopped

public void editingStopped(ChangeEvent e)
This tells the listeners the editor has ended editing

Specified by:
editingStopped in interface CellEditorListener

addItemListener

public void addItemListener(ItemListener l)
Adds an ItemListener to monitor the state of the checkbox. An ItemEvent is sent to the listener when the state of the checkbox has changed.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
l - the ItemListener to be added

removeItemListener

public void removeItemListener(ItemListener l)
Removes an ItemListener from the checkbox.

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
l - the ItemListener to be removed

addListSelectionListener

public void addListSelectionListener(ListSelectionListener l)
Adds an ListSelectionListener to the JTable selection model.

Parameters:
l - the ListSelectionListener to be added

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener l)
Removes an ListSelectionListener from the JTable selection model.

Parameters:
l - the ListSelectionListener to be removed

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
This method notifies ListSelectionListeners that the selection model has changed. It's used to forward ListSelectionEvents from the selectionModel to the ListSelectionListeners added directly to the ListView.

See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), removeListSelectionListener(javax.swing.event.ListSelectionListener)

valueChanged

public void valueChanged(ListSelectionEvent e)
A ListSelectionListener that forwards ListSelectionEvents from the selectionModel to the ListView ListSelectionListeners. The forwarded events only differ from the originals in that their source is the ListView instead of the selectionModel itself.

Specified by:
valueChanged in interface ListSelectionListener

getSelectedObjects

public Object[] getSelectedObjects()
Returns an array (length 1) containing the last DsListViewItem edited or null.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
an array containing 1 Object: the last DsListViewItem edited, if the item was edited; otherwise null

fireColumnClicked

protected void fireColumnClicked(MouseEvent e)
This method notifies the ColumnClickListeners that a column has been clicked on.


addColumnClickListener

public void addColumnClickListener(ColumnClickListener listener)
Add a listener to the list that's notified each time a column is clicked on.

Parameters:
listener - The ColumnClickListener to add.

removeColumnClickListener

public void removeColumnClickListener(ColumnClickListener listener)
Remove a listener from the list that's notified each time a column is clicked on.

Parameters:
listener - The ColumnClickListener to remove.

mouseClicked

public void mouseClicked(MouseEvent e)
MouseListener interface - Forward MouseEvents from child component

Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

getComponent

public JComponent getComponent()
Returns the component that is inside the DsScrollPanel.


setComponent

public void setComponent(JComponent c)
Sets the component that is inside the DsScrollPanel.


getLineBorderColor

public Color getLineBorderColor()
Returns the color used to draw the line border. Can be null.


setLineBorderColor

public void setLineBorderColor(Color c)
Sets the color used to draw the line border. Can be null which means it will use black for the outline and the background color for all other borders.


getLineBorderWidth

public int getLineBorderWidth()
Returns the width of the line border drawn around the component.


setLineBorderWidth

public void setLineBorderWidth(int lineWidth)
Sets the width of the line border drawn around the component. Set to 0 to turn it off.


getOuterBorder

public int getOuterBorder()
Returns whether to draw a border on the outside of the component but inside of the outline if it exists.


setOuterBorder

public void setOuterBorder(int val)
Creates a border on the outside of the component but inside of the outline if it exists.

Parameters:
val - One of: NONE, RAISED, LOWERED, ETCHED_RAISED, ETCHED, SOLID

getCenterBorder

public int getCenterBorder()
Returns whether to draw a border in between the InnerBorder and the OuterBorder.


setCenterBorder

public void setCenterBorder(int val)
Creates a border in between the InnerBorder and the OuterBorder.

Parameters:
val - One of: RAISED, LOWERED, ETCHED_RAISED, ETCHED, SOLID

getInnerBorder

public int getInnerBorder()
Returns whether to draw a border inside of the CenterBorder.


setInnerBorder

public void setInnerBorder(int val)
Creates a border on the inside of the CenterBorder.

Parameters:
val - One of: NONE, RAISED, LOWERED, ETCHED_RAISED, ETCHED, SOLID

hasFocus

public boolean hasFocus()
Overrides:
hasFocus in class Component

requestFocus

public boolean requestFocus(boolean temporary)
Overrides:
requestFocus in class JComponent

requestFocus

public void requestFocus()
Overrides:
requestFocus in class JComponent

requestFocusInWindow

public boolean requestFocusInWindow()
Overrides:
requestFocusInWindow in class JComponent

setCursor

public void setCursor(Cursor cursor)
Overrides:
setCursor in class Component

setEnabled

public void setEnabled(boolean b)
Overrides:
setEnabled in class JComponent

setFont

public void setFont(Font f)
Overrides:
setFont in class JComponent

setForeground

public void setForeground(Color c)
Overrides:
setForeground in class JComponent

setSize

public void setSize(Dimension d)
Overrides:
setSize in class Component

setSize

public void setSize(int width,
                    int height)
Overrides:
setSize in class Component

setVisible

public void setVisible(boolean b)
Overrides:
setVisible in class JComponent

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener listener)
Overrides:
addMouseMotionListener in class Component

removeMouseMotionListener

public void removeMouseMotionListener(MouseMotionListener listener)
Overrides:
removeMouseMotionListener in class Component

mouseDragged

public void mouseDragged(MouseEvent e)
MouseMotionListener interface - Forward MouseMotionEvents from child component

Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

keyPressed

public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.