diff options
4 files changed, 218 insertions, 125 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java index a47096d..06a2df8 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/Wizard.java @@ -76,25 +76,19 @@ public class Wizard /** * The i18n text used for the buttons. Loaded from a property resource file. */ - static String BACK_TEXT; + ResourceManagementService resources = GuiActivator.getResources(); - static String NEXT_TEXT; + private String backButtonDefaultText + = resources.getI18NString("service.gui.PREVIOUS"); - static String FINISH_TEXT; + private String nextButtonDefaultText + = resources.getI18NString("service.gui.NEXT"); - static String CANCEL_TEXT; + private String finishButtonDefaultText + = resources.getI18NString("service.gui.FINISH"); - /** - * The image icons used for the buttons. Filenames are loaded from a - * property resource file. - */ - static Icon BACK_ICON; - - static Icon NEXT_ICON; - - static Icon FINISH_ICON; - - static Icon CANCEL_ICON; + private String cancelButtonDefaultText + = resources.getI18NString("service.gui.CANCEL"); private final WizardModel wizardModel = new WizardModel(); @@ -480,21 +474,11 @@ public class Wizard * * @param e The event passed in from AWT. */ - public void windowClosing(WindowEvent e) { this.close(Wizard.CANCEL_RETURN_CODE); } - static { - ResourceManagementService resources = GuiActivator.getResources(); - - BACK_TEXT = resources.getI18NString("service.gui.PREVIOUS"); - NEXT_TEXT = resources.getI18NString("service.gui.NEXT"); - CANCEL_TEXT = resources.getI18NString("service.gui.CANCEL"); - FINISH_TEXT = resources.getI18NString("service.gui.FINISH"); - } - public void setWizzardIcon(BufferedImage wizardIcon) { wizardIconLabel = new JLabel(); @@ -552,51 +536,134 @@ public class Wizard this.close(Wizard.CANCEL_RETURN_CODE); } - public void windowActivated(WindowEvent e) + public void windowActivated(WindowEvent e) {} + + public void windowClosed(WindowEvent e) {} + + public void windowDeactivated(WindowEvent e) {} + + public void windowDeiconified(WindowEvent e) {} + + public void windowIconified(WindowEvent e) {} + + public void windowOpened(WindowEvent e) {} + + /** + * Returns the next wizard button. + * + * @return the next wizard button + */ + public JButton getNextButton() + { + return this.nextButton; + } + + /** + * Returns the back wizard button. + * + * @return the back wizard button + */ + public JButton getBackButton() + { + return this.backButton; + } + + /** + * Refreshes this wizard dialog. + */ + public void refresh() { + this.pack(); + this.repaint(); } - public void windowClosed(WindowEvent e) + /** + * Returns the default text of the back wizard button. + * + * @return the default text of the back wizard button + */ + public String getBackButtonDefaultText() { + return backButtonDefaultText; } - public void windowDeactivated(WindowEvent e) + /** + * Sets the back button default text. + * + * @param backButtonDefaultText the text to set + */ + void setBackButtonDefaultText(String backButtonDefaultText) { + this.backButtonDefaultText = backButtonDefaultText; } - public void windowDeiconified(WindowEvent e) + /** + * Returns the default text of the next wizard button. + * + * @return the default text of the next wizard button. + */ + public String getNextButtonDefaultText() { + return nextButtonDefaultText; } - public void windowIconified(WindowEvent e) + /** + * Sets the next button default text. + * + * @param nextButtonDefaultText the text to set + */ + void setNextButtonDefaultText(String nextButtonDefaultText) { + this.nextButtonDefaultText = nextButtonDefaultText; } - public void windowOpened(WindowEvent e) + /** + * Returns the default text of the finish wizard button. + * + * @return the default text of the finish wizard button. + */ + public String getFinishButtonDefaultText() { + return finishButtonDefaultText; } - public JButton getNextButton() + /** + * Sets the finish button default text. + * + * @param finishButtonDefaultText the text to set + */ + void setFinishButtonDefaultText(String finishButtonDefaultText) { - return this.nextButton; + this.finishButtonDefaultText = finishButtonDefaultText; } - public JButton getBackButton() + /** + * Returns the default text of the cancel wizard button. + * + * @return the default text of the cancel wizard button. + */ + public String getCancelButtonDefaultText() { - return this.backButton; + return cancelButtonDefaultText; } - public void refresh() + /** + * Sets the cancel button default text. + * + * @param cancelButtonDefaultText the text to set + */ + void setCancelButtonDefaultText(String cancelButtonDefaultText) { - this.pack(); - this.repaint(); + this.cancelButtonDefaultText = cancelButtonDefaultText; } /** - * Implements the <tt>WizardContainer.setFinishButtonText()</tt> method. + * Sets the text label of the "Finish" wizard button. + * + * @param text the new label of the button */ public void setFinishButtonText(String text) { - FINISH_TEXT = text; + this.setFinishButtonDefaultText(text); } } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java index 3889ff1..3d79852 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java @@ -18,9 +18,11 @@ import net.java.sip.communicator.service.gui.*; * of the three buttons, 'Next', 'Previous', and 'Cancel.' Based on what * button is pressed, the controller will update the model to show a new panel * and reset the state of the buttons as necessary. + * + * @author Yana Stamcheva */ -public class WizardController implements ActionListener { - +public class WizardController implements ActionListener +{ private Wizard wizard; /** @@ -120,7 +122,7 @@ public class WizardController implements ActionListener { /** * Resets the buttons to support the original panel rules, including * whether the next or back buttons are enabled or disabled, or if - * the panel is finishable. If the panel in question has another panel + * the panel is finish-able. If the panel in question has another panel * behind it, enables the back button. Otherwise, disables it. If the * panel in question has one or more panels in front of it, enables the * next button. Otherwise, disables it. @@ -130,22 +132,22 @@ public class WizardController implements ActionListener { WizardModel model = wizard.getModel(); WizardPage page = model.getCurrentWizardPage(); - model.setCancelButtonText(Wizard.CANCEL_TEXT); + model.setCancelButtonText(wizard.getCancelButtonDefaultText()); Object backPageIdentifier = page.getBackPageIdentifier(); model.setBackButtonEnabled( (backPageIdentifier != null) && !WizardPage.DEFAULT_PAGE_IDENTIFIER.equals(backPageIdentifier)); - model.setBackButtonText(Wizard.BACK_TEXT); + model.setBackButtonText(wizard.getBackButtonDefaultText()); model.setNextFinishButtonEnabled(page.getNextPageIdentifier() != null); if (page.getNextPageIdentifier().equals( WizardPage.FINISH_PAGE_IDENTIFIER)) { - model.setNextFinishButtonText(Wizard.FINISH_TEXT); + model.setNextFinishButtonText(wizard.getFinishButtonDefaultText()); } else { - model.setNextFinishButtonText(Wizard.NEXT_TEXT); + model.setNextFinishButtonText(wizard.getNextButtonDefaultText()); } } } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardModel.java b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardModel.java index b9696d9..feb2128 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardModel.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardModel.java @@ -17,12 +17,12 @@ import net.java.sip.communicator.service.gui.*; * 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 class 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 @@ public class WizardModel { 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 @@ public class WizardModel { * 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 @@ public class WizardModel { * 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 @@ public class WizardModel { * 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 class WizardModel { * 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 @@ public class WizardModel { 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 @@ public class WizardModel { * @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 @@ public class WizardModel { void setNextFinishButtonEnabled(boolean enabled) { Boolean newValue = enabled; - Boolean oldValue = getNextFinishButtonEnabled(); + Boolean oldValue = getNextFinishButtonEnabled(); if (!newValue.equals(oldValue)) { buttonEnabledHashmap.put( @@ -348,10 +366,11 @@ public class WizardModel { * @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 @@ public class WizardModel { 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 class WizardModel { * @param newValue The new property value. */ protected void firePropertyChange(String propertyName, - Object oldValue, Object newValue) { + Object oldValue, Object newValue) + { propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java index 544b56c..a8cc066 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java @@ -103,20 +103,21 @@ public class AddContactWizard { this(mainFrame); newContact.addProtocolProvider(protocolProvider); - + this.setCurrentPage(AddContactWizardPage2.IDENTIFIER); - + page3.setUIN(newContactAddress); } /** * Creates a new meta contact in a separate thread. */ - private class CreateContact extends Thread { + private class CreateContact extends Thread + { ProtocolProviderService pps; MetaContactGroup group; NewContact newContact; - + CreateContact(ProtocolProviderService pps, NewContact newContact) { @@ -181,12 +182,13 @@ public class AddContactWizard public void wizardFinished(WizardEvent e) { - if(e.getEventCode() == WizardEvent.SUCCESS) { - + if(e.getEventCode() == WizardEvent.SUCCESS) + { ArrayList<ProtocolProviderService> ppList = newContact.getProtocolProviders(); - - for(int i = 0; i < ppList.size(); i ++) { + + for(int i = 0; i < ppList.size(); i ++) + { ProtocolProviderService pps = ppList.get(i); new CreateContact(pps, newContact).start(); |