|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
edu.rice.cs.util.swing.ScrollableListSelectionDialog
public class ScrollableListSelectionDialog
The ScrollableListSelectionDialog is a popup dialog with a message and a scrollable list of items. Each item may be either selected or unselected. A ScrollableListSelectionDialog should be used when an operation needs to act on a variable number of items, for example, when saving modified files.
The message (also know as the leader text) is displayed above the items with an optional icon. The items are displayed in a scrollable table. A column of checkboxes allows selection of the items. Buttons are added below the list of items.
This dialog is somewhat styled after
JOptionPane and uses the message-type constants
from JOptionPane.
| Nested Class Summary | |
|---|---|
private class |
ScrollableListSelectionDialog.SelectAllNoneActionListener
An ActionListener that handles the "Select All" and "Select None" buttons. |
static class |
ScrollableListSelectionDialog.SelectionState
A enumeration of the various selection states. |
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
Window.AccessibleAWTWindow |
| 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 | |
|---|---|
private static int |
CHECKBOXES_COLUMN_INDEX
The column index of the checkboxes column. |
protected Vector<String> |
dataAsStrings
The items in the table. |
private static int |
DEFAULT_HEIGHT
The default height for this dialog. |
private static int |
DEFAULT_WIDTH
The default width for this dialog. |
private static double |
HEIGHT_RATIO
The ratio of the screen height to use by default. |
private static int |
NUM_COLUMNS
The number of columns in the table. |
protected Vector<Boolean> |
selectedItems
The selected items in the table. |
private static int |
STRINGS_COLUMN_INDEX
The column index of the strings column. |
protected JTable |
table
The table displaying the items. |
protected AbstractTableModel |
tableModel
The AbstractTableModel backing the table. |
private static double |
WIDTH_RATIO
The ratio of the screen width to use by default. |
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Dialog |
|---|
DEFAULT_MODALITY_TYPE |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription)
Creates a new ScrollableListSelectionDialog with the given title, leader text, and items. |
|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, and message type. |
|
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType,
int width,
int height,
Icon icon)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. |
private |
ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType,
int width,
int height,
Icon icon,
boolean fitToScreen)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. |
| Method Summary | |
|---|---|
protected void |
_addButtons(JPanel buttonPanel)
Adds buttons to the bottom of the dialog. |
private void |
_addSelectButtons(JPanel selectButtonsPanel)
Adds the "Select All" and "Select None" buttons to the given panel. |
private Icon |
_getIcon(int messageType)
Lookup the icon associated with the given messageType. |
private boolean |
_isknownMessageType(int messageType)
A method to check if they given message type is a know message type. |
protected void |
closeDialog()
Should be called when the dialog should be closed. |
static void |
main(String[] args)
A simple main method for testing purposes. |
List<String> |
selectedItems()
Returns the string representation of those items that are currently selected. |
void |
showDialog()
Shows the dialog. |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final int DEFAULT_WIDTH
private static final int DEFAULT_HEIGHT
private static final double WIDTH_RATIO
private static final double HEIGHT_RATIO
protected final JTable table
protected final AbstractTableModel tableModel
private static final int NUM_COLUMNS
private static final int CHECKBOXES_COLUMN_INDEX
private static final int STRINGS_COLUMN_INDEX
protected final Vector<String> dataAsStrings
protected final Vector<Boolean> selectedItems
| Constructor Detail |
|---|
public ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription)
Creates a new ScrollableListSelectionDialog with the given title, leader text, and items. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The default sizing, message type, and icon are used. All the items are selected by default.
owner - The frame that owns this dialog. May be null.dialogTitle - The text to use as the dialog title.leaderText - Text to display before the list of items.listItems - The items to display in the list.itemDescription - A textual description of the items. This is used as the column heading for the items.
IllegalArgumentException - if listItems is null.
public ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, and message type. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The message type must be one of the message types from
JOptionPane. The message type controlls which
default icon is used.
The default sizing and icon are used.
owner - The frame that owns this dialog. May be null.dialogTitle - The text to use as the dialog title.leaderText - Text to display before the list of items.listItems - The items to display in the list.itemDescription - A textual description of the items. This is used as the column heading for the items.defaultSelection - The default selection state (selected or unselected) for the items.messageType - The type of dialog message.
IllegalArgumentException - if listItems is null.
IllegalArgumentException - if the message type is unknown or listItems is null.
public ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType,
int width,
int height,
Icon icon)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The message type must be one of the message types from
JOptionPane. The message type controlls which
default icon is used. If icon is non-null, it is used
instead of the default icon.
owner - The frame that owns this dialog. May be null.dialogTitle - The text to use as the dialog title.leaderText - Text to display before the list of items.listItems - The items to display in the list.itemDescription - A textual description of the items. This is used as the column heading for the items.defaultSelection - The default selection state (selected or unselected) for the items.messageType - The type of dialog message.width - The width of the dialog box.height - The height of the dialog box.icon - The icon to display. May be null.
IllegalArgumentException - if listItems is null.
IllegalArgumentException - if the message type is unknown or listItems is null.
private ScrollableListSelectionDialog(Frame owner,
String dialogTitle,
String leaderText,
Collection<?> listItems,
String itemDescription,
ScrollableListSelectionDialog.SelectionState defaultSelection,
int messageType,
int width,
int height,
Icon icon,
boolean fitToScreen)
Creates a new ScrollableListSelectionDialog with the given title, leader text, items, message type, width, height, and icon. The list of items is used to construct an internal string list that is not backed by the original list. Changes made to the list or items after dialog construction will not be reflected in the dialog.
The message type must be one of the message types from
JOptionPane. The message type controlls which
default icon is used. If icon is non-null, it is used
instead of the default icon.
owner - The frame that owns this dialog. May be null.dialogTitle - The text to use as the dialog title.leaderText - Text to display before the list of items.listItems - The items to display in the list.itemDescription - A textual description of the items. This is used as the column heading for the items.defaultSelection - The default selection state (selected or unselected) for the items.messageType - The type of dialog message.width - The width of the dialog box.height - The height of the dialog box.icon - The icon to display. May be null.fitToScreen - If true, the width and height of the dialog will be calculated using the screen
dimensions, WIDTH_RATIO, and HEIGHT_RATIO. If false, the provided width and
height will be used.
IllegalArgumentException - if listItems is null.
IllegalArgumentException - if the message type is unknown or listItems is null.| Method Detail |
|---|
private boolean _isknownMessageType(int messageType)
messageType - The message type to check
true if the message type is known, false otherwiseprivate Icon _getIcon(int messageType)
JOptionPane.
messageType - The message for which the icon is requested.
null is no icon was found.private void _addSelectButtons(JPanel selectButtonsPanel)
selectButtonsPanel - The panel that should contain the buttons.protected void _addButtons(JPanel buttonPanel)
closeDialog(). It
is also set as the dialog's default button.
Inheritors should feel free the change settings of the panel such
as the layout manager. However, no guarantees are made that every
change will work with every version of this class.
buttonPanel - The JPanel that should contain the buttons.public void showDialog()
protected void closeDialog()
public List<String> selectedItems()
public static void main(String[] args)
args - Not used.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||