/** * Fire button event with id. The only event that doesn't take a button name as parameter is the {@link * ButtonEvent#CLEAR_DEFAULT_BUTTON} event. * * @param id */ public void fireButtonEvent(int id) { fireButtonEvent(id, null, null); }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof AbstractDialogPage) { AbstractDialogPage page = (AbstractDialogPage) value; return super.getListCellRendererComponent(list, page.getTitle(), index, isSelected, cellHasFocus); } else { return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } } }
/** * Sets the title of the page. * * @param title the new title */ public void setTitle(String title) { String old = _title; _title = title; firePropertyChange(TITLE_PROPERTY, old, _title); }
/** * Gets the full title. It is basically a concat of the titles of all its parent with "." in between. * * @return the full qualified title */ public String getFullTitle() { StringBuffer buffer = new StringBuffer(getTitle()); AbstractDialogPage page = this; while (page.getParentPage() != null) { AbstractDialogPage parent = page.getParentPage(); buffer.insert(0, "."); buffer.insert(0, parent.getTitle()); page = parent; } return new String(buffer); }
private JideButton addPage(int i, final ButtonGroup group, final ButtonPanel buttonsPanel) { AbstractDialogPage optionsPanel = _pageList.getPage(i); final JideButton button = createIconButton(optionsPanel.getTitle(), optionsPanel.getIcon()); button.addActionListener(new AbstractAction(optionsPanel.getTitle(), optionsPanel.getIcon()) { private static final long serialVersionUID = -2375074433514421417L; public void actionPerformed(ActionEvent e) { group.setSelected(button.getModel(), true); setCurrentPage(_pageList.getPageByFullTitle(e.getActionCommand()), buttonsPanel); } }); buttonsPanel.addButton(button, i); group.add(button); return button; }
for (int i = 0; i < _pageList.getPageCount(); i++) { AbstractDialogPage page = _pageList.getPage(i); page.addButtonListener(getButtonPanel()); _tabbedPane.addTab(page.getTitle(), page.getIcon(), page, page.getDescription()); _tabbedPane.setEnabledAt(i, page.isPageEnabled()); final int index = i; page.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.PROPERTY_PAGE_ENABLED.equals(evt.getPropertyName())) { page.addButtonListener(getButtonPanel()); page.setName(page.getFullTitle()); page.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.TITLE_PROPERTY.equals(evt.getPropertyName())) { pagesPanel.add(page, page.getFullTitle());
for (int i = 0; i < _pageList.getPageCount(); i++) { final AbstractDialogPage optionsPanel = _pageList.getPage(i); final JideButton button = createIconButton(optionsPanel.getTitle(), optionsPanel.getIcon()); button.setToolTipText(optionsPanel.getDescription()); button.setEnabled(optionsPanel.isPageEnabled()); button.addActionListener(new AbstractAction() { private static final long serialVersionUID = -8913013217983540816L; optionsPanel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.PROPERTY_PAGE_ENABLED.equals(evt.getPropertyName())) {
((MutableTreeNodeEx) treeNode).setEnabled(dialogPage.isPageEnabled()); if (dialogPage.getParentPage() == null) { _titleNodeMap.put(dialogPage.getFullTitle(), treeNode); root.add(treeNode); if (fireEvent) { _titleNodeMap.put(dialogPage.getFullTitle(), treeNode); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) _titleNodeMap.get(dialogPage.getParentPage().getFullTitle()); if (parentNode != null) { parentNode.add(treeNode); dialogPage.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.ICON_PROPERTY.equals(evt.getPropertyName()) && treeNode instanceof MutableTreeNodeEx) {
public void intervalAdded(ListDataEvent e) { for (int i = e.getIndex0(); i <= e.getIndex1(); i++) { AbstractDialogPage page = _pageList.getPage(i); _tabbedPane.insertTab(page.getTitle(), page.getIcon(), page, page.getDescription(), i); } }
protected boolean setCurrentPage(AbstractDialogPage page, Object source) { AbstractDialogPage oldPage = getCurrentPage(); if (oldPage != null && !oldPage.equals(page)) { oldPage.setAllowClosing(true); oldPage.firePageEvent(source, PageEvent.PAGE_CLOSING); if (!oldPage.allowClosing()) { return false; } oldPage.firePageEvent(source, PageEvent.PAGE_CLOSED); } if (!JideSwingUtilities.equals(oldPage, page)) { setSelectedItem(page); AbstractDialogPage newPage = getCurrentPage(); if (newPage != null) { newPage.firePageEvent(source, PageEvent.PAGE_OPENED); } } return true; } }
/** * Displays the current page. If it is TAB_STYLE, this method will simply select the tab that has the current page. * If it is any of the other styles, this method will show the page that is already added in a CardLayout in * createPagePanel method. * * @param currentPage */ protected void showCurrentPage(AbstractDialogPage currentPage) { if (currentPage != null) { if (getStyle() == TAB_STYLE) { _tabbedPane.setSelectedComponent(currentPage); } else { _cardLayout.show(_pagesPanel, currentPage.getFullTitle()); } currentPage.focusDefaultFocusComponent(); } }
/** * Focus the default focus component if not null. */ public void focusDefaultFocusComponent() { final Component focusComponent = getDefaultFocusComponent(); if (focusComponent != null) { Runnable runnable = new Runnable() { public void run() { if (focusComponent != null) { focusComponent.requestFocusInWindow(); } } }; SwingUtilities.invokeLater(runnable); } } }
for (int i = 0; i < _pageList.getPageCount(); i++) { AbstractDialogPage page = _pageList.getPage(i); page.addButtonListener(getButtonPanel()); _tabbedPane.addTab(page.getTitle(), page.getIcon(), page, page.getDescription()); _tabbedPane.setEnabledAt(i, page.isPageEnabled()); final int index = i; page.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.PROPERTY_PAGE_ENABLED.equals(evt.getPropertyName())) { page.addButtonListener(getButtonPanel()); page.setName(page.getFullTitle()); page.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.TITLE_PROPERTY.equals(evt.getPropertyName())) { pagesPanel.add(page, page.getFullTitle());
for (int i = 0; i < _pageList.getPageCount(); i++) { final AbstractDialogPage optionsPanel = _pageList.getPage(i); final JideButton button = createIconButton(optionsPanel.getTitle(), optionsPanel.getIcon()); button.setToolTipText(optionsPanel.getDescription()); button.setEnabled(optionsPanel.isPageEnabled()); button.addActionListener(new AbstractAction() { private static final long serialVersionUID = 4451059166068761678L; optionsPanel.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.PROPERTY_PAGE_ENABLED.equals(evt.getPropertyName())) { group.add(button); if (_pageList.getPageCount() > 0) { if (getInitialPageTitle() != null && getInitialPageTitle().equals(optionsPanel.getFullTitle())) { group.setSelected(button.getModel(), true);
((MutableTreeNodeEx) treeNode).setEnabled(dialogPage.isPageEnabled()); if (dialogPage.getParentPage() == null) { _titleNodeMap.put(dialogPage.getFullTitle(), treeNode); root.add(treeNode); if (fireEvent) { _titleNodeMap.put(dialogPage.getFullTitle(), treeNode); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) _titleNodeMap.get(dialogPage.getParentPage().getFullTitle()); if (parentNode != null) { parentNode.add(treeNode); dialogPage.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractDialogPage.ICON_PROPERTY.equals(evt.getPropertyName()) && treeNode instanceof MutableTreeNodeEx) {
public void intervalAdded(ListDataEvent e) { for (int i = e.getIndex0(); i <= e.getIndex1(); i++) { AbstractDialogPage page = _pageList.getPage(i); _tabbedPane.insertTab(page.getTitle(), page.getIcon(), page, page.getDescription(), i); } }
private JideButton addPage(int i, final ButtonGroup group, final ButtonPanel buttonsPanel) { AbstractDialogPage optionsPanel = _pageList.getPage(i); final JideButton button = createIconButton(optionsPanel.getTitle(), optionsPanel.getIcon()); button.addActionListener(new AbstractAction(optionsPanel.getTitle(), optionsPanel.getIcon()) { private static final long serialVersionUID = 5987367362274303556L; public void actionPerformed(ActionEvent e) { group.setSelected(button.getModel(), true); setCurrentPage(_pageList.getPageByFullTitle(e.getActionCommand()), buttonsPanel); } }); buttonsPanel.addButton(button, i); group.add(button); return button; }
/** * Displays the current page. If it is TAB_STYLE, this method will simply select the tab that has the current page. * If it is any of the other styles, this method will show the page that is already added in a CardLayout in * createPagePanel method. * * @param currentPage the current page */ protected void showCurrentPage(AbstractDialogPage currentPage) { if (currentPage != null) { if (getStyle() == TAB_STYLE) { _tabbedPane.setSelectedComponent(currentPage); } else { _cardLayout.show(_pagesPanel, currentPage.getFullTitle()); } currentPage.focusDefaultFocusComponent(); } }
/** * Gets the all page titles as vector. * * @return the vector which has all the page titles. */ public List<String> getPageTitlesAsList() { List<String> list = new ArrayList<String>(); for (int i = 0; i < getPageCount(); i++) { AbstractDialogPage page = getPage(i); list.add(page.getTitle()); } return list; }
/** * Fire button event with id and button name. * * @param id * @param buttonName */ public void fireButtonEvent(int id, String buttonName) { fireButtonEvent(id, buttonName, null); }