|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JToolBar com.jidesoft.paging.PageNavigationBar
public class PageNavigationBar
PageNavigationBar
provides a quick way to paginate a JTable, a TableScrollPane or a JList. All you need
to do is to call new PageNavigationBar(table) or new PageNavigationBar(list) and add the PageNavigationBar below or
above the table or the list. PageNavigationBar will automatically paginate the table or the list. PageNavigationBar
provides a page index field and buttons to navigate the pages. If the table or the list doesn't have a model that
implementing PageNavigationSupport
, it will automatically create a DefaultPageTableModel
or DefaultPageListModel
to provide the paging support. Otherwise it will use the existing mode that implements
PageNavigationSupport.
PageNavigationBar
uses methods provided by PageNavigationSupport
to navigate the pages. It
has four buttons and one field. The four buttons are for the first page, the previous page, the next page and the
last page. The field displays the current page index and the total page count. It also allows user to type in the
page index in it and press enter to jump to that page. It has a context menu where allows user to switch from the
default page index mode to the row index mode. In the row index mode, instead of displaying the current page, it
displays the current row index and the total row count. Typing the row index and enter will jump to the row. User can
also press UP, DOWN, PAGE_UP, PAGE_DOWN, CTRL + PAGE_UP, CTRL + PAGE_DOWN, CTRL + HOME, and CTRL + END to navigate
the pages when the focus is in the field. It will also beep when users try to navigate to a page that is not
available. For example user presses page up when it is already on the first page, or try to jump to 100 page when
there are only 99 pages.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JToolBar |
---|
JToolBar.AccessibleJToolBar, JToolBar.Separator |
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 | |
---|---|
protected PageNavigationField |
_pageNavigationField
|
protected PageNavigationSupport |
_pageNavigationSupport
|
String |
CLIENT_PROPERTY_ALWAYS_DISABLED
|
static String |
COMMAND_FIRST
|
static String |
COMMAND_GOTO
|
static String |
COMMAND_LAST
|
static String |
COMMAND_NEXT
|
static String |
COMMAND_PREVIOUS
|
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 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 java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
protected |
PageNavigationBar()
|
|
PageNavigationBar(JList list)
The constructor to install a PageNavigationBar over a JList. |
|
PageNavigationBar(JTable table)
The constructor to install a PageNavigationBar over a JTable. |
|
PageNavigationBar(TableScrollPane pane)
The constructor to install a PageNavigationBar over a TableScrollPane. |
Method Summary | |
---|---|
protected void |
changeCurrentPage(int newPageIndex)
|
protected AbstractButton |
createButton(Action action)
Creates the button. |
protected ChangeListener |
createChangeListener()
Creates a ChangeListener that will be added to the NavigationField. |
protected FocusListener |
createFocusListener()
Creates a FocusListener that will be added to the NavigationField. |
protected MouseWheelListener |
createMouseWheelListener()
Creates a MouseWheelListener that will be added to the table or the list. |
protected PageNavigationField |
createNavigationField()
Creates the navigation field. |
protected PageNavigationListener |
createPageNavigationListener()
Creates a PageNavigationListener that will be added to the PageNavigationSupport. |
protected PageNavigationSupport |
createPageTableModel(TableModel model,
int pageSize)
Creates the page table model. |
protected ListSelectionListener |
createSelectionListener()
Creates a ListSelectionListener that will be added to the table or the list. |
void |
firstPage()
Navigates to the first page. |
void |
firstRecord()
Navigates to the first record/row. |
void |
firstRecordInPage()
Navigates to the first record/row in the current page. |
int |
getCurrentRecord()
Gets the current record. |
PageNavigationField |
getNavigationField()
Gets the navigation field. |
PageNavigationSupport |
getPageNavigationSupport()
Gets the PageNavigationSupport used by this PageNavigationBar. |
protected int |
getPageSize()
Gets the page size to change the current record while previous or next page is requested. |
protected int |
getRecordCountInPage()
Gets the record/row count in the current page. |
protected String |
getResourceString(String key)
Gets the localized string from resource bundle. |
protected int |
getSelectedRecordIndex()
Gets the selected record/row index. |
protected void |
gotoPage()
Navigates to the page as shown in the PageNavigationField. |
void |
gotoPage(int page)
Navigates to the specified page. |
protected void |
gotoRecord()
Navigates to the record/row as shown in the PageNavigationField. |
int |
gotoRecord(int record)
Navigates to the specified record/row. |
protected void |
initComponents()
|
protected boolean |
isAtFirstPage()
Checks if right now it's the first possible page. |
protected boolean |
isAtLastPage()
Checks if right now it's the last possible page. |
boolean |
isButtonEnabled(String command)
Checks if the button is always disabled. |
boolean |
isButtonVisible(String command)
Checks if the button is visible. |
boolean |
isSelectViewIndex()
Gets the flag indicating if PageNavigationBar will automatically select the same view index as previous page while changing pages. |
void |
lastPage()
Navigates to the last page. |
void |
lastRecord()
Navigates to the last record/row. |
void |
lastRecordInPage()
Navigates to the last record/row in the current page. |
void |
nextPage()
Navigates to the next page. |
void |
nextRecord()
Navigates to the next record/row, changes the current page if necessary. |
protected void |
notifyUser()
|
void |
previousPage()
Navigates to the previous page. |
void |
previousRecord()
Navigates to the previous record/row, changes the current page if necessary. |
void |
propertyChange(PropertyChangeEvent evt)
The property change listener to handle the model change of JList/JTable/TableScrollPane. |
protected void |
registerKeyboardActions(JComponent component)
Registers the navigation keystrokes. |
void |
selectRecord(int record)
Navigates to and select the specified record/row. |
void |
setButtonEnabled(String command,
boolean enabled)
Sets the button to always disabled. |
void |
setButtonVisible(String command,
boolean visible)
Sets the button visible or invisible. |
void |
setEnabled(boolean enabled)
|
void |
setListModel(ListModel model)
Sets the list model of the page navigation bar if the wrapped component is a JList. |
protected void |
setSelectedRecordIndex(int row)
Sets the selected record/row. |
void |
setSelectViewIndex(boolean selectViewIndex)
Sets the flag indicating if PageNavigationBar will automatically select the same view index as previous page while changing pages. |
void |
setTableModel(TableModel model)
Sets the table model of the page navigation bar if the wrapped component is a JTable. |
protected void |
updateButtonPanel()
|
protected void |
updateNavigationField()
Updates the navigation field. |
protected void |
updateTooltipText(String key,
Action action)
Update the tooltip text of navigation buttons according to the navigation type |
Methods inherited from class javax.swing.JToolBar |
---|
add, addImpl, addSeparator, addSeparator, createActionChangeListener, createActionComponent, getAccessibleContext, getComponentAtIndex, getComponentIndex, getMargin, getOrientation, getUI, getUIClassID, isBorderPainted, isFloatable, isRollover, paintBorder, paramString, setBorderPainted, setFloatable, setLayout, setMargin, setOrientation, setRollover, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected PageNavigationSupport _pageNavigationSupport
public static final String COMMAND_FIRST
public static final String COMMAND_PREVIOUS
public static final String COMMAND_NEXT
public static final String COMMAND_LAST
public static final String COMMAND_GOTO
public final String CLIENT_PROPERTY_ALWAYS_DISABLED
protected PageNavigationField _pageNavigationField
Constructor Detail |
---|
protected PageNavigationBar()
public PageNavigationBar(TableScrollPane pane)
pane
- the table scroll panepublic PageNavigationBar(JTable table)
table
- the tablepublic PageNavigationBar(JList list)
list
- the listMethod Detail |
---|
protected PageNavigationSupport createPageTableModel(TableModel model, int pageSize)
model
- the target table's modelpageSize
- the row size of each page
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
evt
- the property change eventprotected void initComponents()
protected ChangeListener createChangeListener()
protected void updateTooltipText(String key, Action action)
key
- action
- protected FocusListener createFocusListener()
protected PageNavigationListener createPageNavigationListener()
protected ListSelectionListener createSelectionListener()
protected MouseWheelListener createMouseWheelListener()
protected void registerKeyboardActions(JComponent component)
component
- the component to register actionspublic int getCurrentRecord()
public void setTableModel(TableModel model)
model
- the original table modelpublic void setListModel(ListModel model)
model
- the original list modelprotected PageNavigationField createNavigationField()
public PageNavigationField getNavigationField()
protected void updateNavigationField()
protected AbstractButton createButton(Action action)
protected AbstractButton createButton(Action action) {
AbstractButton button = new JideButton(action);
button.setName("" + action.getValue(Action.ACTION_COMMAND_KEY));
button.setDisabledIcon((Icon) action.getValue("disabledIcon"));
button.setRequestFocusEnabled(false);
AutoRepeatButtonUtils.install(button, 50, 200);
return button;
}
action
- the action for the button.
protected String getResourceString(String key)
key
- the key
public boolean isSelectViewIndex()
setSelectViewIndex(boolean)
public void setSelectViewIndex(boolean selectViewIndex)
selectViewIndex
- the flagpublic void firstPage()
public void lastPage()
protected int getPageSize()
public void previousPage()
public void nextPage()
public void firstRecord()
public void lastRecord()
public void firstRecordInPage()
public void lastRecordInPage()
public void previousRecord()
public void nextRecord()
protected void gotoPage()
protected void gotoRecord()
protected int getRecordCountInPage()
protected int getSelectedRecordIndex()
protected void setSelectedRecordIndex(int row)
row
- the new selected record/row index.public void gotoPage(int page)
page
- the new page index.protected void changeCurrentPage(int newPageIndex)
public int gotoRecord(int record)
record
- the new record/row index.
public void selectRecord(int record)
record
- the new record/row index.protected void notifyUser()
protected void updateButtonPanel()
protected boolean isAtLastPage()
protected boolean isAtFirstPage()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public void setButtonVisible(String command, boolean visible)
command
- the name defined in DualList. They are constants starting with "COMMAND_" such as COMMAND_FIRST.visible
- true to show the button and false to hide.public boolean isButtonVisible(String command)
command
- the name defined in DualList. They are constants starting with "COMMAND_" such as COMMAND_FIRST.
public void setButtonEnabled(String command, boolean enabled)
command
- the name defined in DualList. They are constants starting with "COMMAND_" such as COMMAND_FIRST.enabled
- false to always disable the button.public boolean isButtonEnabled(String command)
command
- the name defined in DualList. They are constants starting with "COMMAND_" such as COMMAND_FIRST.
public PageNavigationSupport getPageNavigationSupport()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |