diff options
Diffstat (limited to 'src/net/java/sip/communicator/plugin/gibberishaccregwizz')
4 files changed, 95 insertions, 25 deletions
diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java index 5a22d90..7365c97 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java @@ -55,28 +55,20 @@ public class FirstWizardPage private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER; - private GibberishAccountRegistration registration = null; - - private WizardContainer wizardContainer; + private GibberishAccountRegistrationWizard wizard; /** * Creates an instance of <tt>FirstWizardPage</tt>. * @param registration the <tt>GibberishAccountRegistration</tt>, where * all data through the wizard are stored - * @param wizardContainer the wizardContainer, where this page will - * be added + * @param wizard the parent wizard */ - public FirstWizardPage(GibberishAccountRegistration registration, - WizardContainer wizardContainer) + public FirstWizardPage(GibberishAccountRegistrationWizard wizard) { super(new BorderLayout()); - this.wizardContainer = wizardContainer; - - this.registration = registration; - - this.setPreferredSize(new Dimension(300, 150)); + this.wizard = wizard; mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); @@ -185,7 +177,7 @@ public class FirstWizardPage { String userID = userIDField.getText(); - if (isExistingAccount(userID)) + if (!wizard.isModification() && isExistingAccount(userID)) { nextPageIdentifier = FIRST_PAGE_IDENTIFIER; userPassPanel.add(existingAccountLabel, BorderLayout.NORTH); @@ -196,8 +188,14 @@ public class FirstWizardPage nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER; userPassPanel.remove(existingAccountLabel); + GibberishAccountRegistration registration + = wizard.getRegistration(); + registration.setUserID(userIDField.getText()); - registration.setPassword(new String(passField.getPassword())); + + if (passField.getPassword() != null) + registration.setPassword(new String(passField.getPassword())); + registration.setRememberPassword(rememberPassBox.isSelected()); } } @@ -210,11 +208,11 @@ public class FirstWizardPage { if (userIDField.getText() == null || userIDField.getText().equals("")) { - wizardContainer.setNextFinishButtonEnabled(false); + wizard.getWizardContainer().setNextFinishButtonEnabled(false); } else { - wizardContainer.setNextFinishButtonEnabled(true); + wizard.getWizardContainer().setNextFinishButtonEnabled(true); } } @@ -270,6 +268,7 @@ public class FirstWizardPage String password = (String) accountID.getAccountProperties() .get(ProtocolProviderFactory.PASSWORD); + this.userIDField.setEnabled(false); this.userIDField.setText(accountID.getUserID()); if (password != null) diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccRegWizzActivator.java index 19a659a..496092e 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccRegWizzActivator.java @@ -38,6 +38,8 @@ public class GibberishAccRegWizzActivator private static GibberishAccountRegistrationWizard gibberishWizard; + private static UIService uiService; + /** * Starts this bundle. * @param bc the currently valid <tt>BundleContext</tt>. @@ -51,7 +53,7 @@ public class GibberishAccRegWizzActivator ServiceReference uiServiceRef = bundleContext .getServiceReference(UIService.class.getName()); - UIService uiService = (UIService) bundleContext.getService(uiServiceRef); + uiService = (UIService) bundleContext.getService(uiServiceRef); wizardContainer = uiService.getAccountRegWizardContainer(); @@ -109,4 +111,14 @@ public class GibberishAccRegWizzActivator { return bundleContext; } + + /** + * Returns the <tt>UIService</tt>. + * + * @return the <tt>UIService</tt> + */ + public static UIService getUIService() + { + return uiService; + } } diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java index 4b7d717..d33dfc1 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java @@ -6,10 +6,11 @@ */ package net.java.sip.communicator.plugin.gibberishaccregwizz; +import java.awt.*; import java.util.*; import org.osgi.framework.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; + import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; @@ -103,7 +104,7 @@ public class GibberishAccountRegistrationWizard public Iterator getPages() { ArrayList pages = new ArrayList(); - firstWizardPage = new FirstWizardPage(registration, wizardContainer); + firstWizardPage = new FirstWizardPage(this); pages.add(firstWizardPage); @@ -153,8 +154,15 @@ public class GibberishAccountRegistrationWizard if (registration.isRememberPassword()) { - accountProperties.put(ProtocolProviderFactory.PASSWORD - , registration.getPassword()); + accountProperties.put( ProtocolProviderFactory.PASSWORD, + registration.getPassword()); + } + + if (isModification) + { + providerFactory.uninstallAccount(protocolProvider.getAccountID()); + this.protocolProvider = null; + this.isModification = false; } try @@ -171,11 +179,17 @@ public class GibberishAccountRegistrationWizard } catch (IllegalArgumentException exc) { - new ErrorDialog(null, exc.getMessage(), exc).showDialog(); + GibberishAccRegWizzActivator.getUIService().getPopupDialog() + .showMessagePopupDialog(exc.getMessage(), + Resources.getString("error"), + PopupDialog.ERROR_MESSAGE); } catch (IllegalStateException exc) { - new ErrorDialog(null, exc.getMessage(), exc).showDialog(); + GibberishAccRegWizzActivator.getUIService().getPopupDialog() + .showMessagePopupDialog(exc.getMessage(), + Resources.getString("error"), + PopupDialog.ERROR_MESSAGE); } return protocolProvider; @@ -189,11 +203,55 @@ public class GibberishAccountRegistrationWizard */ public void loadAccount(ProtocolProviderService protocolProvider) { + this.isModification = true; this.protocolProvider = protocolProvider; + this.registration = new GibberishAccountRegistration(); + this.firstWizardPage.loadAccount(protocolProvider); + } + + /** + * 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 GibberishAccountRegistration getRegistration() + { + return registration; + } - isModification = true; - } + /** + * Returns the size of this wizard. + * @return the size of this wizard + */ + public Dimension getSize() + { + return new Dimension(600, 500); + } } diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/resources.properties b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/resources.properties index 0852e0d..eb5f920 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/resources.properties +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/resources.properties @@ -5,6 +5,7 @@ password=Password: rememberPassword=Remember password userAndPassword=Identification existingAccount=* The account you entered is already installed. +error=Error protocolIcon=resources/images/gibberish/gibberish-online.png pageImage=resources/images/gibberish/gibberish64x64.png |