|
|
|
|
@ -17,12 +17,12 @@
|
|
|
|
|
* The model for the Wizard component, which tracks the text, icons, and
|
|
|
|
|
* enabled state of each of the buttons, as well as the current panel that
|
|
|
|
|
* is displayed. Note that the model, in its current form, is not intended
|
|
|
|
|
* to be subclassed.
|
|
|
|
|
* to be sub-classed.
|
|
|
|
|
*
|
|
|
|
|
* @author Yana Stamcheva
|
|
|
|
|
*/
|
|
|
|
|
public class WizardModel {
|
|
|
|
|
|
|
|
|
|
public class WizardModel
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Identification string for the current panel.
|
|
|
|
|
*/
|
|
|
|
|
@ -96,7 +96,8 @@ public class WizardModel {
|
|
|
|
|
/**
|
|
|
|
|
* Default constructor.
|
|
|
|
|
*/
|
|
|
|
|
public WizardModel() {
|
|
|
|
|
public WizardModel()
|
|
|
|
|
{
|
|
|
|
|
propertyChangeSupport = new PropertyChangeSupport(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -104,51 +105,56 @@ public WizardModel() {
|
|
|
|
|
* Returns the currently displayed WizardPage.
|
|
|
|
|
* @return The currently displayed WizardPage
|
|
|
|
|
*/
|
|
|
|
|
WizardPage getCurrentWizardPage() {
|
|
|
|
|
WizardPage getCurrentWizardPage()
|
|
|
|
|
{
|
|
|
|
|
return currentPanel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers the WizardPage in the model using the
|
|
|
|
|
* Object-identifier specified.
|
|
|
|
|
* @param id Object-based identifier
|
|
|
|
|
* @param page WizardPage that describes the panel
|
|
|
|
|
*/
|
|
|
|
|
void registerPage(Object id, WizardPage page) {
|
|
|
|
|
void registerPage(Object id, WizardPage page)
|
|
|
|
|
{
|
|
|
|
|
panelHashmap.put(id, page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregisters the <tt>WizardPage</tt> corresponding to the given id.
|
|
|
|
|
*
|
|
|
|
|
* @param id The id of the <tt>WizardPage</tt>.
|
|
|
|
|
*/
|
|
|
|
|
void unregisterPage(Object id) {
|
|
|
|
|
void unregisterPage(Object id)
|
|
|
|
|
{
|
|
|
|
|
panelHashmap.remove(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the <tt>WizardPage</tt> corresponding to the given identifier.
|
|
|
|
|
* @param id The identifier of the page.
|
|
|
|
|
* @return the <tt>WizardPage</tt> corresponding to the given identifier.
|
|
|
|
|
*/
|
|
|
|
|
WizardPage getWizardPage(Object id) {
|
|
|
|
|
WizardPage getWizardPage(Object id)
|
|
|
|
|
{
|
|
|
|
|
return panelHashmap.get(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Iterator<Map.Entry<Object, WizardPage>> getAllPages() {
|
|
|
|
|
|
|
|
|
|
Iterator<Map.Entry<Object, WizardPage>> getAllPages()
|
|
|
|
|
{
|
|
|
|
|
return panelHashmap.entrySet().iterator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the current panel to that identified by the Object passed in.
|
|
|
|
|
* @param id Object-based panel identifier
|
|
|
|
|
* @return boolean indicating success or failure
|
|
|
|
|
*/
|
|
|
|
|
boolean setCurrentPanel(Object id) {
|
|
|
|
|
boolean setCurrentPanel(Object id)
|
|
|
|
|
{
|
|
|
|
|
// First, get the hashtable reference to the panel that should
|
|
|
|
|
// be displayed.
|
|
|
|
|
|
|
|
|
|
WizardPage nextPanel = panelHashmap.get(id);
|
|
|
|
|
|
|
|
|
|
// If we couldn't find the panel that should be displayed, return
|
|
|
|
|
@ -158,30 +164,32 @@ boolean setCurrentPanel(Object id) {
|
|
|
|
|
|
|
|
|
|
WizardPage oldPanel = currentPanel;
|
|
|
|
|
currentPanel = nextPanel;
|
|
|
|
|
|
|
|
|
|
if (oldPanel != currentPanel) {
|
|
|
|
|
|
|
|
|
|
if (oldPanel != currentPanel)
|
|
|
|
|
{
|
|
|
|
|
firePropertyChange(CURRENT_PAGE_PROPERTY,
|
|
|
|
|
oldPanel, currentPanel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the text for the Back button.
|
|
|
|
|
* @return the text for the Back button.
|
|
|
|
|
*/
|
|
|
|
|
Object getBackButtonText() {
|
|
|
|
|
Object getBackButtonText()
|
|
|
|
|
{
|
|
|
|
|
return buttonTextHashmap.get(BACK_BUTTON_TEXT_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the text for the back button.
|
|
|
|
|
* @param newText The text to set.
|
|
|
|
|
*/
|
|
|
|
|
void setBackButtonText(Object newText) {
|
|
|
|
|
|
|
|
|
|
Object oldText = getBackButtonText();
|
|
|
|
|
void setBackButtonText(Object newText)
|
|
|
|
|
{
|
|
|
|
|
Object oldText = getBackButtonText();
|
|
|
|
|
if (!newText.equals(oldText)) {
|
|
|
|
|
buttonTextHashmap.put(BACK_BUTTON_TEXT_PROPERTY, newText);
|
|
|
|
|
firePropertyChange(BACK_BUTTON_TEXT_PROPERTY, oldText, newText);
|
|
|
|
|
@ -192,14 +200,16 @@ void setBackButtonText(Object newText) {
|
|
|
|
|
* Returns the text for the Next/Finish button.
|
|
|
|
|
* @return the text for the Next/Finish button.
|
|
|
|
|
*/
|
|
|
|
|
Object getNextFinishButtonText() {
|
|
|
|
|
Object getNextFinishButtonText()
|
|
|
|
|
{
|
|
|
|
|
return buttonTextHashmap.get(NEXT_FINISH_BUTTON_TEXT_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setNextFinishButtonText(Object newText) {
|
|
|
|
|
|
|
|
|
|
Object oldText = getNextFinishButtonText();
|
|
|
|
|
if (!newText.equals(oldText)) {
|
|
|
|
|
|
|
|
|
|
void setNextFinishButtonText(Object newText)
|
|
|
|
|
{
|
|
|
|
|
Object oldText = getNextFinishButtonText();
|
|
|
|
|
if (!newText.equals(oldText))
|
|
|
|
|
{
|
|
|
|
|
buttonTextHashmap.put(NEXT_FINISH_BUTTON_TEXT_PROPERTY, newText);
|
|
|
|
|
firePropertyChange(NEXT_FINISH_BUTTON_TEXT_PROPERTY,
|
|
|
|
|
oldText, newText);
|
|
|
|
|
@ -210,39 +220,42 @@ void setNextFinishButtonText(Object newText) {
|
|
|
|
|
* Returns the text for the Cancel button.
|
|
|
|
|
* @return the text for the Cancel button.
|
|
|
|
|
*/
|
|
|
|
|
Object getCancelButtonText() {
|
|
|
|
|
Object getCancelButtonText()
|
|
|
|
|
{
|
|
|
|
|
return buttonTextHashmap.get(CANCEL_BUTTON_TEXT_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the text for the Cancel button.
|
|
|
|
|
* @param newText The text to set.
|
|
|
|
|
*/
|
|
|
|
|
void setCancelButtonText(Object newText) {
|
|
|
|
|
|
|
|
|
|
Object oldText = getCancelButtonText();
|
|
|
|
|
void setCancelButtonText(Object newText)
|
|
|
|
|
{
|
|
|
|
|
Object oldText = getCancelButtonText();
|
|
|
|
|
if (!newText.equals(oldText)) {
|
|
|
|
|
buttonTextHashmap.put(CANCEL_BUTTON_TEXT_PROPERTY, newText);
|
|
|
|
|
firePropertyChange(CANCEL_BUTTON_TEXT_PROPERTY, oldText, newText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the icon for the Back button.
|
|
|
|
|
* @return the icon for the Back button.
|
|
|
|
|
*/
|
|
|
|
|
Icon getBackButtonIcon() {
|
|
|
|
|
Icon getBackButtonIcon()
|
|
|
|
|
{
|
|
|
|
|
return buttonIconHashmap.get(BACK_BUTTON_ICON_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the icon for the Back button.
|
|
|
|
|
* @param newIcon The new icon to set.
|
|
|
|
|
*/
|
|
|
|
|
void setBackButtonIcon(Icon newIcon) {
|
|
|
|
|
|
|
|
|
|
Object oldIcon = getBackButtonIcon();
|
|
|
|
|
if (!newIcon.equals(oldIcon)) {
|
|
|
|
|
void setBackButtonIcon(Icon newIcon)
|
|
|
|
|
{
|
|
|
|
|
Object oldIcon = getBackButtonIcon();
|
|
|
|
|
if (!newIcon.equals(oldIcon))
|
|
|
|
|
{
|
|
|
|
|
buttonIconHashmap.put(BACK_BUTTON_ICON_PROPERTY, newIcon);
|
|
|
|
|
firePropertyChange(BACK_BUTTON_ICON_PROPERTY, oldIcon, newIcon);
|
|
|
|
|
}
|
|
|
|
|
@ -252,17 +265,18 @@ void setBackButtonIcon(Icon newIcon) {
|
|
|
|
|
* Returns the icon for the Next/Finish button.
|
|
|
|
|
* @return the icon for the Next/Finish button.
|
|
|
|
|
*/
|
|
|
|
|
Icon getNextFinishButtonIcon() {
|
|
|
|
|
Icon getNextFinishButtonIcon()
|
|
|
|
|
{
|
|
|
|
|
return buttonIconHashmap.get(NEXT_FINISH_BUTTON_ICON_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the icon for the Next/Finish button.
|
|
|
|
|
* @param newIcon The new icon to set.
|
|
|
|
|
*/
|
|
|
|
|
public void setNextFinishButtonIcon(Icon newIcon) {
|
|
|
|
|
|
|
|
|
|
Object oldIcon = getNextFinishButtonIcon();
|
|
|
|
|
public void setNextFinishButtonIcon(Icon newIcon)
|
|
|
|
|
{
|
|
|
|
|
Object oldIcon = getNextFinishButtonIcon();
|
|
|
|
|
if (!newIcon.equals(oldIcon)) {
|
|
|
|
|
buttonIconHashmap.put(NEXT_FINISH_BUTTON_ICON_PROPERTY, newIcon);
|
|
|
|
|
firePropertyChange(NEXT_FINISH_BUTTON_ICON_PROPERTY,
|
|
|
|
|
@ -274,31 +288,34 @@ public void setNextFinishButtonIcon(Icon newIcon) {
|
|
|
|
|
* Returns the icon for the Cancel button.
|
|
|
|
|
* @return the icon for the Cancel button.
|
|
|
|
|
*/
|
|
|
|
|
Icon getCancelButtonIcon() {
|
|
|
|
|
Icon getCancelButtonIcon()
|
|
|
|
|
{
|
|
|
|
|
return buttonIconHashmap.get(CANCEL_BUTTON_ICON_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the icon for the Cancel button.
|
|
|
|
|
* @param newIcon The new icon to set.
|
|
|
|
|
*/
|
|
|
|
|
void setCancelButtonIcon(Icon newIcon) {
|
|
|
|
|
Icon oldIcon = getCancelButtonIcon();
|
|
|
|
|
void setCancelButtonIcon(Icon newIcon)
|
|
|
|
|
{
|
|
|
|
|
Icon oldIcon = getCancelButtonIcon();
|
|
|
|
|
if (!newIcon.equals(oldIcon)) {
|
|
|
|
|
buttonIconHashmap.put(CANCEL_BUTTON_ICON_PROPERTY, newIcon);
|
|
|
|
|
firePropertyChange(CANCEL_BUTTON_ICON_PROPERTY, oldIcon, newIcon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if the Back button is enabled.
|
|
|
|
|
* @return <code>true</code> if the Back button is enabled,
|
|
|
|
|
* <code>false</code> otherwise.
|
|
|
|
|
*/
|
|
|
|
|
Boolean getBackButtonEnabled() {
|
|
|
|
|
Boolean getBackButtonEnabled()
|
|
|
|
|
{
|
|
|
|
|
return buttonEnabledHashmap.get(BACK_BUTTON_ENABLED_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables or disables the Back button.
|
|
|
|
|
* @param newValue <code>true</code> to enable the Back button,
|
|
|
|
|
@ -307,7 +324,7 @@ Boolean getBackButtonEnabled() {
|
|
|
|
|
void setBackButtonEnabled(boolean enabled)
|
|
|
|
|
{
|
|
|
|
|
Boolean newValue = enabled;
|
|
|
|
|
Boolean oldValue = getBackButtonEnabled();
|
|
|
|
|
Boolean oldValue = getBackButtonEnabled();
|
|
|
|
|
if (!newValue.equals(oldValue))
|
|
|
|
|
{
|
|
|
|
|
buttonEnabledHashmap.put(BACK_BUTTON_ENABLED_PROPERTY, newValue);
|
|
|
|
|
@ -321,10 +338,11 @@ void setBackButtonEnabled(boolean enabled)
|
|
|
|
|
* @return <code>true</code> if the Next/Finish button is enabled,
|
|
|
|
|
* <code>false</code> otherwise.
|
|
|
|
|
*/
|
|
|
|
|
Boolean getNextFinishButtonEnabled() {
|
|
|
|
|
Boolean getNextFinishButtonEnabled()
|
|
|
|
|
{
|
|
|
|
|
return buttonEnabledHashmap.get(NEXT_FINISH_BUTTON_ENABLED_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables or disables the Next/Finish button.
|
|
|
|
|
* @param newValue <code>true</code> to enable the Next/Finish button,
|
|
|
|
|
@ -333,7 +351,7 @@ Boolean getNextFinishButtonEnabled() {
|
|
|
|
|
void setNextFinishButtonEnabled(boolean enabled)
|
|
|
|
|
{
|
|
|
|
|
Boolean newValue = enabled;
|
|
|
|
|
Boolean oldValue = getNextFinishButtonEnabled();
|
|
|
|
|
Boolean oldValue = getNextFinishButtonEnabled();
|
|
|
|
|
if (!newValue.equals(oldValue))
|
|
|
|
|
{
|
|
|
|
|
buttonEnabledHashmap.put(
|
|
|
|
|
@ -348,10 +366,11 @@ void setNextFinishButtonEnabled(boolean enabled)
|
|
|
|
|
* @return <code>true</code> if the Cancel button is enabled,
|
|
|
|
|
* <code>false</code> otherwise.
|
|
|
|
|
*/
|
|
|
|
|
Boolean getCancelButtonEnabled() {
|
|
|
|
|
Boolean getCancelButtonEnabled()
|
|
|
|
|
{
|
|
|
|
|
return buttonEnabledHashmap.get(CANCEL_BUTTON_ENABLED_PROPERTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables or disables the Cancel button.
|
|
|
|
|
* @param newValue <code>true</code> to enable the Cancel button,
|
|
|
|
|
@ -360,31 +379,33 @@ Boolean getCancelButtonEnabled() {
|
|
|
|
|
void setCancelButtonEnabled(boolean enabled)
|
|
|
|
|
{
|
|
|
|
|
Boolean newValue = enabled;
|
|
|
|
|
Boolean oldValue = getCancelButtonEnabled();
|
|
|
|
|
Boolean oldValue = getCancelButtonEnabled();
|
|
|
|
|
if (!newValue.equals(oldValue))
|
|
|
|
|
{
|
|
|
|
|
buttonEnabledHashmap.put(CANCEL_BUTTON_ENABLED_PROPERTY, newValue);
|
|
|
|
|
firePropertyChange(CANCEL_BUTTON_ENABLED_PROPERTY,
|
|
|
|
|
oldValue, newValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a <tt>PropertyChangeListener</tt>
|
|
|
|
|
* @param p The <tt>PropertyChangeListener</tt> to add.
|
|
|
|
|
*/
|
|
|
|
|
public void addPropertyChangeListener(PropertyChangeListener p) {
|
|
|
|
|
public void addPropertyChangeListener(PropertyChangeListener p)
|
|
|
|
|
{
|
|
|
|
|
propertyChangeSupport.addPropertyChangeListener(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes a <tt>PropertyChangeListener</tt>
|
|
|
|
|
* @param p The <tt>PropertyChangeListener</tt> to remove.
|
|
|
|
|
*/
|
|
|
|
|
public void removePropertyChangeListener(PropertyChangeListener p) {
|
|
|
|
|
public void removePropertyChangeListener(PropertyChangeListener p)
|
|
|
|
|
{
|
|
|
|
|
propertyChangeSupport.removePropertyChangeListener(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Informs all<tt>PropertyChangeListener</tt>s that the a given property
|
|
|
|
|
* has changed.
|
|
|
|
|
@ -393,7 +414,8 @@ public void removePropertyChangeListener(PropertyChangeListener p) {
|
|
|
|
|
* @param newValue The new property value.
|
|
|
|
|
*/
|
|
|
|
|
protected void firePropertyChange(String propertyName,
|
|
|
|
|
Object oldValue, Object newValue) {
|
|
|
|
|
Object oldValue, Object newValue)
|
|
|
|
|
{
|
|
|
|
|
propertyChangeSupport.firePropertyChange(propertyName,
|
|
|
|
|
oldValue, newValue);
|
|
|
|
|
}
|
|
|
|
|
|