|
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.JPanel com.jidesoft.dialog.StandardDialogPane com.jidesoft.dialog.MultiplePageDialogPane
public class MultiplePageDialogPane
MultiplePageDialogPane is a StandardDialogPane which can have multiple AbstractDialogPages. You can choose one from four predefined styles of how to change the page visibility. Those four styles are TAB_STYLE, ICON_STYLE, LIST_STYLE and TREE_STYLE.
To use this class, just create a PageList of AbstractDialogPage and call setPageList() to set to this dialog. Based on the style, the class will automatically layout those pages correctly and hook up actions to switch based on user selection. As AbstractDialogPage extends AbstractPage, so you can always use PageListener to decide what to do when page is opened, closing, closed, activated or deactivated. We automatically create a button panel which have three button - OK, Cancel and Apply. The ButtonPanel listens to ButtonEvent from all the pages. You can simply fireButtonEvent in the page to change the state of those buttons. Or if you want to create your own button panel, just override createButtonPanel() method. If you choose LIST_STYLE and TREE_STYLE, you can set your own ListCellRenderer and TreeCellRenderer. Just call setListCellRenderer() and setTreeCellRenderer(). The value passed in the renderer is an instance of AbstractDialogPage associated with that list row or tree node.MultiplePageDialogPane
has lazy loading feature. So when you are done setup the page list, you need to
call StandardDialogPane.initComponents()
to initialize everything. This method will be called automatically if the dialog pane
is added to StandardDialog.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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 | |
---|---|
JTree |
_tree
|
static int |
ICON_STYLE
Predefined style of multiple page dialog. |
static int |
LIST_STYLE
Predefined style of multiple page dialog. |
static int |
TAB_STYLE
Predefined style of multiple page dialog. |
static int |
TREE_STYLE
Predefined style of multiple page dialog. |
Fields inherited from class com.jidesoft.dialog.StandardDialogPane |
---|
_bannerPanel, _buttonPanel, _contentPanel, PROPERTY_CANCEL_ACTION, PROPERTY_DEFAULT_ACTION |
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 com.jidesoft.dialog.ButtonNames |
---|
APPLY, BACK, BROWSE, CANCEL, CLEAR, CLOSE, DETAILS, EDIT, EXIT, FIND, FIND_NEXT, FINISH, FORWARD, HELP, NEW, NEXT, NO, OK, OPEN, PRINT, REPLACE, RESET, RETRY, RUN, SAVE, SAVE_AS, STOP, YES |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
MultiplePageDialogPane()
Creates a non-modal MultiplePageDialog without a title and without a specified Frame owner. |
|
MultiplePageDialogPane(int style)
Creates a modal or non-modal MultiplePageDialog with the specified style, the specified title and the specified owner Frame . |
Method Summary | |
---|---|
protected void |
configureTree(JTree tree)
Configure the JTree used in TREE_STYLE dialog. |
JComponent |
createBannerPanel()
Implements the method in StandardDialog. |
ButtonPanel |
createButtonPanel()
Creates the button panel. |
JComponent |
createContentPanel()
Implements the method in StandardDialog. |
protected JideButton |
createIconButton(String title,
Icon icon)
Creates the button for each icon. |
protected ButtonPanel |
createIconButtonPanel()
Creates the ButtonPanel used by IconPanel. |
protected JComponent |
createIconPanel()
Creates the panel that contains several icons. |
JComponent |
createIndexPanel()
Creates the index panel based on the style. |
protected JList |
createList(DefaultListModel listModel)
Creates list that is used in LIST_STYLE dialog's index panel. |
protected ListCellRenderer |
createListCellRenderer()
Creates a list cell renderer used by list in LIST_STYLE dialog's index panel. |
protected JComponent |
createPagesPanel()
Creates the pages panel. |
protected JTabbedPane |
createTabbedPane()
Creates the JTabbedPane used by TAB_STYLE dialog. |
protected JTree |
createTree(DefaultMutableTreeNode root)
Creates tree that is used in TREE_STYLE dialog's index panel. |
protected TreeCellRenderer |
createTreeCellRenderer()
Creates the tree cell renderer used by tree in TREE_STYLE dialog's index panel. |
protected MutableTreeNode |
createTreeNode(AbstractDialogPage dialogPage)
Create tree node for TREE_STYLE pages. |
JButton |
getApplyButton()
Gets the apply button. |
AbstractAction |
getCancelAction()
Gets the cancel action. |
JButton |
getCancelButton()
Gets the cancel button. |
AbstractDialogPage |
getCurrentPage()
Gets the current selected page. |
JComponent |
getIndexPanel()
Gets the index panel. |
String |
getInitialPageTitle()
Gets the initial page title. |
protected ListCellRenderer |
getListCellRenderer()
Gets the cell renderer used by the list. |
AbstractAction |
getOKAction()
Gets the OK action. |
JButton |
getOkButton()
Gets the OK Button only if you didn't override the createButtonPanel() and remove the OK button. |
PageList |
getPageList()
Gets the page list of this dialog. |
JComponent |
getPagesPanel()
Gets the pages panel. |
int |
getStyle()
Gets the style of this dialog. |
protected TreeCellRenderer |
getTreeCellRenderer()
Gets the cell renderer used by the tree. |
void |
setCancelAction(AbstractAction cancelAction)
Changes the default cancel action. |
protected void |
setCurrentPage(AbstractDialogPage currentPage)
|
protected void |
setCurrentPage(AbstractDialogPage currentPage,
Object source)
|
protected void |
setCurrentPage(String pageTitle)
|
void |
setInitialPageTitle(String initialPageTitle)
Sets the initial page title. |
void |
setListCellRenderer(ListCellRenderer listCellRenderer)
Sets the list cell renderer that will be used by JList when the style is LIST_STYLE. |
void |
setOKAction(AbstractAction okAction)
Changes the default OK action. |
void |
setPageList(PageList pageList)
Sets the page list of this dialog. |
void |
setStyle(int style)
Sets the style of this dialog. |
void |
setTreeCellRenderer(TreeCellRenderer treeCellRenderer)
Sets the tree cell renderer that will be used by JTree when the style is TREE_STYLE. |
protected JComponent |
setupContentPanel(JComponent indexPanel,
JComponent pagesPanel)
Setups the content panel. |
protected void |
showCurrentPage(AbstractDialogPage currentPage)
Displays the current page. |
Methods inherited from class com.jidesoft.dialog.StandardDialogPane |
---|
getBannerPanel, getButtonPanel, getContentPanel, getDefaultAction, getDefaultCancelAction, getInitFocusedComponent, initComponents, layoutComponents, setDefaultAction, setDefaultCancelAction, setInitFocusedComponent |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TAB_STYLE
public static final int TREE_STYLE
public static final int LIST_STYLE
public static final int ICON_STYLE
public JTree _tree
Constructor Detail |
---|
public MultiplePageDialogPane() throws HeadlessException
Frame
owner. A
shared, hidden frame will be set as the owner of the dialog. By default TAB_STYLE is used.
HeadlessException
public MultiplePageDialogPane(int style)
Frame
. If owner
is null
, a shared, hidden frame will be set as the
owner of this dialog. All constructors defer to this one.
style
- the style. It must be one of the following: TAB_STYLE, ICON_STYLE, LIST_STYLE or TREE_STYLE.
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()
,
JComponent.getDefaultLocale()
Method Detail |
---|
public JComponent createBannerPanel()
createBannerPanel
in class StandardDialogPane
public JComponent createContentPanel()
createContentPanel
in class StandardDialogPane
protected JComponent setupContentPanel(JComponent indexPanel, JComponent pagesPanel)
indexPanel
- the index panel. It has the navigation control to control which page to show.pagesPanel
- the pages panel. It contains all the pages of this dialog.
public ButtonPanel createButtonPanel()
createButtonPanel
in class StandardDialogPane
ButtonPanel
public JButton getOkButton()
public JButton getCancelButton()
public JButton getApplyButton()
public void setCancelAction(AbstractAction cancelAction)
cancelAction
- public AbstractAction getCancelAction()
public void setOKAction(AbstractAction okAction)
okAction
- public AbstractAction getOKAction()
protected JComponent createPagesPanel()
protected JTabbedPane createTabbedPane()
public JComponent createIndexPanel()
public void setPageList(PageList pageList)
pageList
- public PageList getPageList()
public AbstractDialogPage getCurrentPage()
protected void setCurrentPage(String pageTitle)
protected void setCurrentPage(AbstractDialogPage currentPage)
protected void setCurrentPage(AbstractDialogPage currentPage, Object source)
protected void showCurrentPage(AbstractDialogPage currentPage)
currentPage
- protected MutableTreeNode createTreeNode(AbstractDialogPage dialogPage)
dialogPage
- the corresponding dialog page.
protected JTree createTree(DefaultMutableTreeNode root)
setTreeCellRenderer(javax.swing.tree.TreeCellRenderer)
to
set a new one.
UIManager.put("Tree.hash", Color.white);
return new JTree(root);
root
-
protected void configureTree(JTree tree)
tree.setToggleClickCount(1);
tree.setCellRenderer(createTreeCellRenderer());
tree.setRootVisible(false);
tree.setShowsRootHandles(false);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (tree.getSelectionPath() == null) {
return;
}
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)
tree.getSelectionPath().getLastPathComponent();
// comment this while block if you want the parent page shows its own page instead
of
showing its first child page.
while (!treeNode.isLeaf()) {
final DefaultMutableTreeNode tn = treeNode;
Runnable runnable = new Runnable() {
public void run() {
tree.expandPath(new TreePath(tn.getPath()));
}
};
SwingUtilities.invokeLater(runnable);
treeNode = (DefaultMutableTreeNode) treeNode.getChildAt(0);
}
if (treeNode != null) {
Object userObject = treeNode.getUserObject();
if (userObject instanceof AbstractDialogPage) {
setCurrentPage((AbstractDialogPage) userObject, tree);
}
}
}
});
tree
- protected JList createList(DefaultListModel listModel)
setListCellRenderer(javax.swing.ListCellRenderer)
to set a
new one.
JList list = new JList(listModel);
list.setCellRenderer(createListCellRenderer());
return list;
listModel
-
protected JComponent createIconPanel()
protected ButtonPanel createIconButtonPanel()
new
ScrollableButtonPanel(SwingConstants.TOP, ButtonPanel.SAME_SIZE)
.
protected JideButton createIconButton(String title, Icon icon)
title
- icon
-
public int getStyle()
public void setStyle(int style)
style
- It must be one of the following: TAB_STYLE, ICON_STYLE, LIST_STYLE or TREE_STYLE.public JComponent getIndexPanel()
public JComponent getPagesPanel()
protected TreeCellRenderer getTreeCellRenderer()
public void setTreeCellRenderer(TreeCellRenderer treeCellRenderer)
treeCellRenderer
- protected ListCellRenderer getListCellRenderer()
public void setListCellRenderer(ListCellRenderer listCellRenderer)
listCellRenderer
- protected ListCellRenderer createListCellRenderer()
protected TreeCellRenderer createTreeCellRenderer()
public String getInitialPageTitle()
public void setInitialPageTitle(String initialPageTitle)
initialPageTitle
-
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |