From d97b4a5a504f05cdcb902dd20db8adfdb5ed76b2 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Thu, 22 Feb 2007 12:39:09 +0000 Subject: [PATCH] Added multichat operation set definition and Gibberish protocol implementation. Related issues: Issue #241 , Issue #244, Issue #250 fixed var names. removed all references to icq since this is a jabber wizard --- .../jabberaccregwizz/FirstWizardPage.java | 258 +++++++++++------- .../JabberAccRegWizzActivator.java | 25 +- .../JabberAccountRegistration.java | 35 ++- .../JabberAccountRegistrationWizard.java | 88 +++--- .../plugin/jabberaccregwizz/Resources.java | 37 ++- 5 files changed, 268 insertions(+), 175 deletions(-) diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java index 5f94e56d2..11874f739 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java @@ -6,10 +6,10 @@ */ package net.java.sip.communicator.plugin.jabberaccregwizz; -import java.awt.*; -import java.awt.event.*; import java.util.*; +import java.awt.*; +import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; @@ -17,44 +17,44 @@ import net.java.sip.communicator.service.protocol.*; /** - * The FirstWizardPage is the page, where user could enter the uin + * The FirstWizardPage is the page, where user could enter the user ID * and the password of the account. * * @author Yana Stamcheva * @author Damian Minkov */ -public class FirstWizardPage extends JPanel - implements WizardPage, DocumentListener { +public class FirstWizardPage + extends JPanel implements WizardPage, DocumentListener +{ public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; private static final String GOOGLE_USER_SUFFIX = "gmail.com"; private static final String GOOGLE_CONNECT_SRV = "talk.google.com"; - private JPanel uinPassPanel = new JPanel(new BorderLayout(10, 10)); + private JPanel userIDPassPanel = new JPanel(new BorderLayout(10, 10)); private JPanel labelsPanel = new JPanel(); private JPanel valuesPanel = new JPanel(); - private JLabel uinLabel = new JLabel(Resources.getString("uin")); - + private JLabel userIDLabel = new JLabel(Resources.getString("userID")); + private JLabel passLabel = new JLabel(Resources.getString("password")); private JLabel existingAccountLabel - = new JLabel(Resources.getString("existingAccount")); - + = new JLabel(Resources.getString("existingAccount")); + private JPanel emptyPanel = new JPanel(); - - private JLabel uinExampleLabel = new JLabel("Ex: johnsmith@jabber.org"); - - - private JTextField uinField = new JTextField(); + + private JLabel userIDExampleLabel = new JLabel("Ex: johnsmith@jabber.org"); + + private JTextField userIDField = new JTextField(); private JPasswordField passField = new JPasswordField(); private JCheckBox rememberPassBox = new JCheckBox( - Resources.getString("rememberPassword")); + Resources.getString("rememberPassword")); private JPanel advancedOpPanel = new JPanel(new BorderLayout(10, 10)); @@ -63,7 +63,7 @@ public class FirstWizardPage extends JPanel private JPanel valuesAdvOpPanel = new JPanel(new GridLayout(0, 1, 10, 10)); private JCheckBox sendKeepAliveBox = new JCheckBox( - Resources.getString("sendKeepAlive")); + Resources.getString("sendKeepAlive")); private JCheckBox enableAdvOpButton = new JCheckBox( Resources.getString("ovverideServerOps"), false); @@ -77,7 +77,7 @@ public class FirstWizardPage extends JPanel private JPanel mainPanel = new JPanel(); private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER; - + private JabberAccountRegistration registration; private WizardContainer wizardContainer; @@ -90,7 +90,8 @@ public class FirstWizardPage extends JPanel * be added */ public FirstWizardPage(JabberAccountRegistration registration, - WizardContainer wizardContainer) { + WizardContainer wizardContainer) + { super(new BorderLayout()); @@ -105,63 +106,73 @@ public FirstWizardPage(JabberAccountRegistration registration, this.init(); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - + this.labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS)); - + this.valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS)); } /** * Initializes all panels, buttons, etc. */ - private void init() { - this.uinField.getDocument().addDocumentListener(this); + private void init() + { + this.userIDField.getDocument().addDocumentListener(this); this.rememberPassBox.setSelected(true); this.existingAccountLabel.setForeground(Color.RED); - - this.uinExampleLabel.setForeground(Color.GRAY); - this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8)); + + this.userIDExampleLabel.setForeground(Color.GRAY); + this.userIDExampleLabel.setFont(userIDExampleLabel.getFont().deriveFont( + 8)); this.emptyPanel.setMaximumSize(new Dimension(40, 35)); - this.uinExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); - - labelsPanel.add(uinLabel); + this.userIDExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, + 8, 0)); + + labelsPanel.add(userIDLabel); labelsPanel.add(emptyPanel); labelsPanel.add(passLabel); - valuesPanel.add(uinField); - valuesPanel.add(uinExampleLabel); + valuesPanel.add(userIDField); + valuesPanel.add(userIDExampleLabel); valuesPanel.add(passField); - uinPassPanel.add(labelsPanel, BorderLayout.WEST); - uinPassPanel.add(valuesPanel, BorderLayout.CENTER); - uinPassPanel.add(rememberPassBox, BorderLayout.SOUTH); + userIDPassPanel.add(labelsPanel, BorderLayout.WEST); + userIDPassPanel.add(valuesPanel, BorderLayout.CENTER); + userIDPassPanel.add(rememberPassBox, BorderLayout.SOUTH); - uinPassPanel.setBorder(BorderFactory - .createTitledBorder(Resources.getString("uinAndPassword"))); + userIDPassPanel.setBorder(BorderFactory + .createTitledBorder(Resources.getString( + "userIDAndPassword"))); - mainPanel.add(uinPassPanel); + mainPanel.add(userIDPassPanel); serverField.setEditable(false); portField.setEditable(false); - enableAdvOpButton.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent evt) { - // Perform action - JCheckBox cb = (JCheckBox)evt.getSource(); + enableAdvOpButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + // Perform action + JCheckBox cb = (JCheckBox) evt.getSource(); - serverField.setEditable(cb.isSelected()); - portField.setEditable(cb.isSelected()); - }}); + serverField.setEditable(cb.isSelected()); + portField.setEditable(cb.isSelected()); + } + }); - portField.getDocument().addDocumentListener(new DocumentListener(){ - public void changedUpdate(DocumentEvent e){} - public void insertUpdate(DocumentEvent e) + portField.getDocument().addDocumentListener(new DocumentListener() + { + public void changedUpdate(DocumentEvent evt) + {} + + public void insertUpdate(DocumentEvent evt) { setNextButtonAccordingToPort(); } - public void removeUpdate(DocumentEvent e) + public void removeUpdate(DocumentEvent evt) { setNextButtonAccordingToPort(); } @@ -182,7 +193,8 @@ public void removeUpdate(DocumentEvent e) advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER); advancedOpPanel.setBorder(BorderFactory - .createTitledBorder(Resources.getString("advancedOptions"))); + .createTitledBorder(Resources.getString( + "advancedOptions"))); mainPanel.add(advancedOpPanel); @@ -192,62 +204,78 @@ public void removeUpdate(DocumentEvent e) /** * Implements the WizardPage.getIdentifier to return * this page identifier. + * + * @return the id of the first wizard page. */ - public Object getIdentifier() { + public Object getIdentifier() + { return FIRST_PAGE_IDENTIFIER; } /** * Implements the WizardPage.getNextPageIdentifier to return * the next page identifier - the summary page. + * + * @return the id of the next wizard page. */ - public Object getNextPageIdentifier() { + public Object getNextPageIdentifier() + { return nextPageIdentifier; } /** * Implements the WizardPage.getBackPageIdentifier to return * the next back identifier - the default page. + * + * @return the id of the default wizard page. */ - public Object getBackPageIdentifier() { + public Object getBackPageIdentifier() + { return WizardPage.DEFAULT_PAGE_IDENTIFIER; } /** * Implements the WizardPage.getWizardForm to return * this panel. + * + * @return this wizard page. */ - public Object getWizardForm() { + public Object getWizardForm() + { return this; } /** * Before this page is displayed enables or disables the "Next" wizard - * button according to whether the UIN field is empty. + * button according to whether the User ID field is empty. */ - public void pageShowing() { - this.setNextButtonAccordingToUIN(); + public void pageShowing() + { + this.setNextButtonAccordingToUserID(); } /** * Saves the user input when the "Next" wizard buttons is clicked. */ - public void pageNext() { - String uin = uinField.getText(); - - if(isExistingAccount(uin)) { + public void pageNext() + { + String userID = userIDField.getText(); + + if (isExistingAccount(userID)) + { nextPageIdentifier = FIRST_PAGE_IDENTIFIER; - uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH); + userIDPassPanel.add(existingAccountLabel, BorderLayout.NORTH); this.revalidate(); } - else { + else + { nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER; - uinPassPanel.remove(existingAccountLabel); - - registration.setUin(uinField.getText()); + userIDPassPanel.remove(existingAccountLabel); + + registration.setUserID(userIDField.getText()); registration.setPassword(new String(passField.getPassword())); registration.setRememberPassword(rememberPassBox.isSelected()); - + registration.setServerAddress(serverField.getText()); registration.setSendKeepAlive(sendKeepAliveBox.isSelected()); try @@ -261,63 +289,78 @@ public void pageNext() { /** * Enables or disables the "Next" wizard button according to whether the - * UIN field is empty. + * UserID field is empty. */ - private void setNextButtonAccordingToUIN() { - if (uinField.getText() == null || uinField.getText().equals("")) { + private void setNextButtonAccordingToUserID() + { + if (userIDField.getText() == null || userIDField.getText().equals("")) + { wizardContainer.setNextFinishButtonEnabled(false); } - else { + else + { wizardContainer.setNextFinishButtonEnabled(true); } } /** * Handles the DocumentEvent triggered when user types in the - * UIN field. Enables or disables the "Next" wizard button according to - * whether the UIN field is empty. + * UserID field. Enables or disables the "Next" wizard button according to + * whether the UserID field is empty. + * + * @param evt the document event that has triggered this method call. */ - public void insertUpdate(DocumentEvent e) { - this.setNextButtonAccordingToUIN(); - this.setServerFieldAccordingToUIN(); + public void insertUpdate(DocumentEvent evt) + { + this.setNextButtonAccordingToUserID(); + this.setServerFieldAccordingToUserID(); } /** * Handles the DocumentEvent triggered when user deletes letters - * from the UIN field. Enables or disables the "Next" wizard button - * according to whether the UIN field is empty. + * from the User ID field. Enables or disables the "Next" wizard button + * according to whether the User ID field is empty. + * + * @param evt the document event that has triggered this method call. */ - public void removeUpdate(DocumentEvent e) { - this.setNextButtonAccordingToUIN(); - this.setServerFieldAccordingToUIN(); + public void removeUpdate(DocumentEvent evt) + { + this.setNextButtonAccordingToUserID(); + this.setServerFieldAccordingToUserID(); } - public void changedUpdate(DocumentEvent e) { + public void changedUpdate(DocumentEvent evt) + { } - public void pageHiding() { + public void pageHiding() + { } - public void pageShown() { + public void pageShown() + { } - public void pageBack() { + public void pageBack() + { } /** - * Fills the UIN and Password fields in this panel with the data comming + * Fills the User ID and Password fields in this panel with the data comming * from the given protocolProvider. * @param protocolProvider The ProtocolProviderService to load the * data from. */ - public void loadAccount(ProtocolProviderService protocolProvider) { + public void loadAccount(ProtocolProviderService protocolProvider) + { AccountID accountID = protocolProvider.getAccountID(); - String password = (String)accountID.getAccountProperties() + String password = (String) accountID.getAccountProperties() .get(ProtocolProviderFactory.PASSWORD); - this.uinField.setText(accountID.getUserID()); + this.userIDField.setText(accountID.getUserID()); - if(password != null) { + if (password != null) + { this.passField.setText(password); this.rememberPassBox.setSelected(true); } @@ -327,19 +370,23 @@ public void loadAccount(ProtocolProviderService protocolProvider) { * Parse the server part from the jabber id and set it to server * as default value. If Advanced option is enabled Do nothing. */ - private void setServerFieldAccordingToUIN() + private void setServerFieldAccordingToUserID() { - if(!enableAdvOpButton.isSelected()) + if (!enableAdvOpButton.isSelected()) { - String uin = uinField.getText(); - int delimIndex = uin.indexOf("@"); + String userID = userIDField.getText(); + int delimIndex = userID.indexOf("@"); if (delimIndex != -1) { - String newServerAddr = uin.substring(delimIndex + 1); - if(newServerAddr.equals(GOOGLE_USER_SUFFIX)) + String newServerAddr = userID.substring(delimIndex + 1); + if (newServerAddr.equals(GOOGLE_USER_SUFFIX)) + { serverField.setText(GOOGLE_CONNECT_SRV); + } else + { serverField.setText(newServerAddr); + } } } } @@ -357,22 +404,25 @@ private void setNextButtonAccordingToPort() } catch (NumberFormatException ex) { - wizardContainer.setNextFinishButtonEnabled(false); + wizardContainer.setNextFinishButtonEnabled(false); } } - + private boolean isExistingAccount(String accountName) - { - ProtocolProviderFactory factory + { + ProtocolProviderFactory factory = JabberAccRegWizzActivator.getJabberProtocolProviderFactory(); - + ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for(int i = 0; i < registeredAccounts.size(); i ++) { + + for (int i = 0; i < registeredAccounts.size(); i++) + { AccountID accountID = (AccountID) registeredAccounts.get(i); - - if(accountName.equalsIgnoreCase(accountID.getUserID())) + + if (accountName.equalsIgnoreCase(accountID.getUserID())) + { return true; + } } return false; } diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java index e217a61ca..3da3338a8 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccRegWizzActivator.java @@ -17,12 +17,14 @@ * * @author Yana Stamcheva */ -public class JabberAccRegWizzActivator implements BundleActivator { +public class JabberAccRegWizzActivator + implements BundleActivator +{ public static BundleContext bundleContext; private static Logger logger = Logger.getLogger( - JabberAccRegWizzActivator.class.getName()); + JabberAccRegWizzActivator.class.getName()); private static ConfigurationService configService; @@ -31,7 +33,9 @@ public class JabberAccRegWizzActivator implements BundleActivator { * @param bc BundleContext * @throws Exception */ - public void start(BundleContext bc) throws Exception { + public void start(BundleContext bc) + throws Exception + { bundleContext = bc; @@ -50,26 +54,31 @@ public void start(BundleContext bc) throws Exception { wizardContainer.addAccountRegistrationWizard(jabberWizard); } - public void stop(BundleContext bundleContext) throws Exception { + public void stop(BundleContext bundleContext) + throws Exception + { } /** * Returns the ProtocolProviderFactory for the Jabber protocol. * @return the ProtocolProviderFactory for the Jabber protocol */ - public static ProtocolProviderFactory getJabberProtocolProviderFactory() { + public static ProtocolProviderFactory getJabberProtocolProviderFactory() + { ServiceReference[] serRefs = null; String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL - + "="+ProtocolNames.JABBER+")"; + + "=" + ProtocolNames.JABBER + ")"; - try { + try + { serRefs = bundleContext.getServiceReferences( ProtocolProviderFactory.class.getName(), osgiFilter); } - catch (InvalidSyntaxException ex){ + catch (InvalidSyntaxException ex) + { logger.error("JabberAccRegWizzActivator : " + ex); } diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java index abe178ad5..2b337d58d 100755 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java @@ -12,9 +12,10 @@ * * @author Yana Stamcheva */ -public class JabberAccountRegistration { +public class JabberAccountRegistration +{ - private String uin; + private String userID; private String password; @@ -30,7 +31,8 @@ public class JabberAccountRegistration { * Returns the password of the jabber registration account. * @return the password of the jabber registration account. */ - public String getPassword() { + public String getPassword() + { return password; } @@ -38,7 +40,8 @@ public String getPassword() { * Sets the password of the jabber registration account. * @param password the password of the jabber registration account. */ - public void setPassword(String password) { + public void setPassword(String password) + { this.password = password; } @@ -46,7 +49,8 @@ public void setPassword(String password) { * Returns TRUE if password has to remembered, FALSE otherwise. * @return TRUE if password has to remembered, FALSE otherwise */ - public boolean isRememberPassword() { + public boolean isRememberPassword() + { return rememberPassword; } @@ -55,16 +59,18 @@ public boolean isRememberPassword() { * @param rememberPassword TRUE if password has to remembered, FALSE * otherwise */ - public void setRememberPassword(boolean rememberPassword) { + public void setRememberPassword(boolean rememberPassword) + { this.rememberPassword = rememberPassword; } /** - * Returns the UIN of the jabber registration account. - * @return the UIN of the jabber registration account. + * Returns the User ID of the jabber registration account. + * @return the User ID of the jabber registration account. */ - public String getUin() { - return uin; + public String getUserID() + { + return userID; } /** @@ -95,11 +101,12 @@ public boolean isSendKeepAlive() } /** - * Sets the UIN of the jabber registration account. - * @param uin the UIN of the jabber registration account. + * Sets the User ID of the jabber registration account. + * @param userID the UIN of the jabber registration account. */ - public void setUin(String uin) { - this.uin = uin; + public void setUserID(String userID) + { + this.userID = userID; } /** diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java index fa6fd9b8c..babd9ddab 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java @@ -8,12 +8,8 @@ import java.util.*; -import javax.swing.*; - import org.osgi.framework.*; - import net.java.sip.communicator.impl.gui.customcontrols.*; -import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; @@ -24,7 +20,9 @@ * * @author Yana Stamcheva */ -public class JabberAccountRegistrationWizard implements AccountRegistrationWizard { +public class JabberAccountRegistrationWizard + implements AccountRegistrationWizard +{ private FirstWizardPage firstWizardPage; @@ -35,16 +33,18 @@ public class JabberAccountRegistrationWizard implements AccountRegistrationWizar private ProtocolProviderService protocolProvider; - private String propertiesPackage = "net.java.sip.communicator.plugin.jabberaccregwizz"; + private String propertiesPackage = + "net.java.sip.communicator.plugin.jabberaccregwizz"; private boolean isModification; - + /** * Creates an instance of JabberAccountRegistrationWizard. * @param wizardContainer the wizard container, where this wizard * is added */ - public JabberAccountRegistrationWizard(WizardContainer wizardContainer) { + public JabberAccountRegistrationWizard(WizardContainer wizardContainer) + { this.wizardContainer = wizardContainer; } @@ -53,7 +53,8 @@ public JabberAccountRegistrationWizard(WizardContainer wizardContainer) { * Returns the icon to be used for this wizard. * @return byte[] */ - public byte[] getIcon() { + public byte[] getIcon() + { return Resources.getImage(Resources.JABBER_LOGO); } @@ -62,7 +63,8 @@ public byte[] getIcon() { * method. Returns the protocol name for this wizard. * @return String */ - public String getProtocolName() { + public String getProtocolName() + { return Resources.getString("protocolName"); } @@ -71,7 +73,8 @@ public String getProtocolName() { * method. Returns the description of the protocol for this wizard. * @return String */ - public String getProtocolDescription() { + public String getProtocolDescription() + { return Resources.getString("protocolDescription"); } @@ -79,7 +82,8 @@ public String getProtocolDescription() { * 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); @@ -92,12 +96,13 @@ public Iterator getPages() { * 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("User ID", registration.getUserID()); summaryTable.put("Remember password", - new Boolean(registration.isRememberPassword())); + new Boolean(registration.isRememberPassword())); return summaryTable.entrySet().iterator(); } @@ -106,13 +111,15 @@ public Iterator getSummary() { * Installs the account created through this wizard. * @return ProtocolProviderService */ - public ProtocolProviderService finish() { + public ProtocolProviderService finish() + { firstWizardPage = null; ProtocolProviderFactory factory = JabberAccRegWizzActivator.getJabberProtocolProviderFactory(); return this.installAccount(factory, - registration.getUin(), registration.getPassword()); + registration.getUserID(), + registration.getPassword()); } /** @@ -124,63 +131,70 @@ public ProtocolProviderService finish() { * @return the ProtocolProviderService 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); } accountProperties.put(ProtocolProviderFactory.SERVER_ADDRESS, - registration.getServerAddress()); + registration.getServerAddress()); accountProperties.put(ProtocolProviderFactory.SERVER_PORT, - String.valueOf(registration.getPort())); + String.valueOf(registration.getPort())); accountProperties.put("SEND_KEEP_ALIVE", String.valueOf(registration.isSendKeepAlive())); - if(isModification) { + if (isModification) + { providerFactory.uninstallAccount(protocolProvider.getAccountID()); this.protocolProvider = null; } - try { + try + { AccountID accountID = providerFactory.installAccount( - user, accountProperties); - + user, accountProperties); + ServiceReference serRef = providerFactory .getProviderForAccount(accountID); - + protocolProvider = (ProtocolProviderService) JabberAccRegWizzActivator.bundleContext - .getService(serRef); + .getService(serRef); + } + catch (IllegalArgumentException exc) + { + new ErrorDialog(null, exc.getMessage(), exc).showDialog(); } - catch (IllegalArgumentException e) { - new ErrorDialog(null, e.getMessage(), e).showDialog(); + catch (IllegalStateException exc) + { + new ErrorDialog(null, exc.getMessage(), exc).showDialog(); } - 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 User ID and Password fields in this panel with the data comming * from the given protocolProvider. * @param protocolProvider The ProtocolProviderService to load the * data from. */ - public void loadAccount(ProtocolProviderService protocolProvider) { + public void loadAccount(ProtocolProviderService protocolProvider) + { this.protocolProvider = protocolProvider; this.firstWizardPage.loadAccount(protocolProvider); - + isModification = true; } } diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java index ade54eeaa..7076cc99f 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java @@ -11,12 +11,14 @@ import java.util.*; import net.java.sip.communicator.util.*; + /** * The Messages class manages the access to the internationalization * properties files. * @author Yana Stamcheva */ -public class Resources { +public class Resources +{ private static Logger log = Logger.getLogger(Resources.class); @@ -24,7 +26,7 @@ public class Resources { = "net.java.sip.communicator.plugin.jabberaccregwizz.resources"; private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + .getBundle(BUNDLE_NAME); public static ImageID JABBER_LOGO = new ImageID("protocolIcon"); @@ -33,11 +35,15 @@ public class Resources { * @param key The key of the string. * @return An internationalized string corresponding to the given key. */ - public static String getString(String key) { - try { + public static String getString(String key) + { + try + { return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { + } + catch (MissingResourceException e) + { return '!' + key + '!'; } @@ -48,15 +54,19 @@ public static String getString(String key) { * @param imageID The identifier of the image. * @return The image for the given identifier. */ - public static byte[] getImage(ImageID imageID) { + public static byte[] getImage(ImageID imageID) + { byte[] image = new byte[100000]; String path = Resources.getString(imageID.getId()); - try { + try + { Resources.class.getClassLoader() - .getResourceAsStream(path).read(image); + .getResourceAsStream(path).read(image); - } catch (IOException e) { + } + catch (IOException e) + { log.error("Failed to load image:" + path, e); } @@ -66,14 +76,17 @@ public static byte[] getImage(ImageID imageID) { /** * Represents the Image Identifier. */ - public static class ImageID { + public static class ImageID + { private String id; - private ImageID(String id) { + private ImageID(String id) + { this.id = id; } - public String getId() { + public String getId() + { return id; } }