diff options
Diffstat (limited to 'src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java')
-rw-r--r-- | src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java | 197 |
1 files changed, 134 insertions, 63 deletions
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java index 72f3ad2..34b7259 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java @@ -1,66 +1,67 @@ /* * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * + * Distributable under LGPL license. See terms of license at gnu.org. */ package net.java.sip.communicator.plugin.yahooaccregwizz; +import java.awt.*; import java.util.*; -import javax.swing.*; - -import org.osgi.framework.*; - -import net.java.sip.communicator.impl.gui.customcontrols.*; -import net.java.sip.communicator.plugin.sipaccregwizz.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; +import org.osgi.framework.*; + /** * The <tt>YahooAccountRegistrationWizard</tt> is an implementation of the * <tt>AccountRegistrationWizard</tt> for the Yahoo protocol. It should allow * the user to create and configure a new Yahoo account. - * + * * @author Yana Stamcheva */ -public class YahooAccountRegistrationWizard implements AccountRegistrationWizard { +public class YahooAccountRegistrationWizard + implements AccountRegistrationWizard +{ private FirstWizardPage firstWizardPage; - private YahooAccountRegistration registration - = new YahooAccountRegistration(); + private YahooAccountRegistration registration = + new YahooAccountRegistration(); private WizardContainer wizardContainer; private ProtocolProviderService protocolProvider; - private String propertiesPackage = "net.java.sip.communicator.plugin.yahooaccregwizz"; - + private String propertiesPackage = + "net.java.sip.communicator.plugin.yahooaccregwizz"; + private boolean isModification; /** * Creates an instance of <tt>YahooAccountRegistrationWizard</tt>. - * @param wizardContainer the wizard container, where this wizard - * is added + * + * @param wizardContainer the wizard container, where this wizard is added */ - public YahooAccountRegistrationWizard(WizardContainer wizardContainer) { + public YahooAccountRegistrationWizard(WizardContainer wizardContainer) + { this.wizardContainer = wizardContainer; } /** * Implements the <code>AccountRegistrationWizard.getIcon</code> method. * Returns the icon to be used for this wizard. + * * @return byte[] */ - public byte[] getIcon() { + public byte[] getIcon() + { return Resources.getImage(Resources.YAHOO_LOGO); } - + /** - * Implements the <code>AccountRegistrationWizard.getPageImage</code> method. - * Returns the image used to decorate the wizard page + * Implements the <code>AccountRegistrationWizard.getPageImage</code> + * method. Returns the image used to decorate the wizard page * * @return byte[] the image used to decorate the wizard page */ @@ -72,28 +73,35 @@ public class YahooAccountRegistrationWizard implements AccountRegistrationWizard /** * Implements the <code>AccountRegistrationWizard.getProtocolName</code> * method. Returns the protocol name for this wizard. + * * @return String */ - public String getProtocolName() { + public String getProtocolName() + { return Resources.getString("protocolName"); } /** * Implements the <code>AccountRegistrationWizard.getProtocolDescription - * </code> method. Returns the description of the protocol for this wizard. + * </code> + * method. Returns the description of the protocol for this wizard. + * * @return String */ - public String getProtocolDescription() { + public String getProtocolDescription() + { return Resources.getString("protocolDescription"); } /** * Returns the set of pages contained in this wizard. + * * @return Iterator */ - public Iterator getPages() { + public Iterator getPages() + { ArrayList pages = new ArrayList(); - firstWizardPage = new FirstWizardPage(registration, wizardContainer); + firstWizardPage = new FirstWizardPage(this); pages.add(firstWizardPage); @@ -102,88 +110,151 @@ public class YahooAccountRegistrationWizard implements AccountRegistrationWizard /** * Returns the set of data that user has entered through this wizard. + * * @return Iterator */ - public Iterator getSummary() { + public Iterator getSummary() + { Hashtable summaryTable = new Hashtable(); summaryTable.put("UIN", registration.getUin()); - summaryTable.put("Remember password", - new Boolean(registration.isRememberPassword())); + summaryTable.put( "Remember password", + new Boolean(registration.isRememberPassword())); return summaryTable.entrySet().iterator(); } /** * Installs the account created through this wizard. + * * @return ProtocolProviderService */ - public ProtocolProviderService finish() { + public ProtocolProviderService finish() + { firstWizardPage = null; - ProtocolProviderFactory factory - = YahooAccRegWizzActivator.getYahooProtocolProviderFactory(); + ProtocolProviderFactory factory = + YahooAccRegWizzActivator.getYahooProtocolProviderFactory(); - return this.installAccount(factory, - registration.getUin(), registration.getPassword()); + return this.installAccount( factory, + registration.getUin(), + registration.getPassword()); } /** * Creates an account for the given user and password. - * @param providerFactory the ProtocolProviderFactory which will create - * the account + * + * @param providerFactory the ProtocolProviderFactory which will create the + * account * @param user the user identifier * @param passwd the password * @return the <tt>ProtocolProviderService</tt> for the new account. */ public ProtocolProviderService installAccount( - ProtocolProviderFactory providerFactory, - String user, - String passwd) { + ProtocolProviderFactory providerFactory, String user, String passwd) + { Hashtable accountProperties = new Hashtable(); - if(registration.isRememberPassword()) { + if (registration.isRememberPassword()) + { accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd); } - if(isModification) { + if (isModification) + { providerFactory.uninstallAccount(protocolProvider.getAccountID()); this.protocolProvider = null; + this.isModification = false; } - try { - AccountID accountID = providerFactory.installAccount( - user, accountProperties); + try + { + AccountID accountID = + providerFactory.installAccount(user, accountProperties); + + ServiceReference serRef = + providerFactory.getProviderForAccount(accountID); - ServiceReference serRef = providerFactory - .getProviderForAccount(accountID); - - protocolProvider - = (ProtocolProviderService) YahooAccRegWizzActivator.bundleContext - .getService(serRef); + protocolProvider = + (ProtocolProviderService) YahooAccRegWizzActivator + .bundleContext.getService(serRef); } - catch (IllegalArgumentException e) { - new ErrorDialog(null, e.getMessage(), e).showDialog(); + catch (IllegalArgumentException e) + { + YahooAccRegWizzActivator.getUIService().getPopupDialog() + .showMessagePopupDialog(e.getMessage(), + Resources.getString("error"), + PopupDialog.ERROR_MESSAGE); + } + catch (IllegalStateException e) + { + YahooAccRegWizzActivator.getUIService().getPopupDialog() + .showMessagePopupDialog(e.getMessage(), + Resources.getString("error"), + PopupDialog.ERROR_MESSAGE); } - catch (IllegalStateException e) { - new ErrorDialog(null, e.getMessage(), e).showDialog(); - } return protocolProvider; } /** - * Fills the UIN and Password fields in this panel with the data comming + * Fills the UIN and Password fields in this panel with the data coming * from the given protocolProvider. - * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the - * data from. + * + * @param protocolProvider The <tt>ProtocolProviderService</tt> to load + * the data from. */ - public void loadAccount(ProtocolProviderService protocolProvider) { + public void loadAccount(ProtocolProviderService protocolProvider) + { + this.isModification = true; this.protocolProvider = protocolProvider; + this.registration = new YahooAccountRegistration(); + this.firstWizardPage.loadAccount(protocolProvider); - - this.isModification = true; + } + + /** + * Indicates if this wizard is opened for modification or for creating a + * new account. + * + * @return <code>true</code> if this wizard is opened for modification and + * <code>false</code> otherwise. + */ + public boolean isModification() + { + return isModification; + } + + /** + * Returns the wizard container, where all pages are added. + * + * @return the wizard container, where all pages are added + */ + public WizardContainer getWizardContainer() + { + return wizardContainer; + } + + /** + * Returns the registration object, which will store all the data through + * the wizard. + * + * @return the registration object, which will store all the data through + * the wizard + */ + public YahooAccountRegistration getRegistration() + { + return registration; + } + + /** + * Returns the size of this wizard. + * @return the size of this wizard + */ + public Dimension getSize() + { + return new Dimension(600, 500); } } |