UI Service Documentation
Create account registration wizard
An account registration wizard is a wizard which will guide the user through a protocol account registration. For different protocols the process of creating an account is different - although that the username and password are always present, there are additional configurations specific for each protocol. For this reason an account registration wizard should be created for a specific protocol and added to the UI like a plugin.
How to create an account registration wizard
To create an account registration wizard you need to implement two interfaces - the AccountRegistrationWizard and the WizardPage interface.
The AccountRegistrationWizard interface is meant to provide a set of pages, an icon, the name and the description of the corresponding protocol. Each of the pages provided by the wizard should implement the WizardPage interface.
Note that the AccountRegistrationWizard is NOT a real wizard, it doesn’t handle wizard events. It’s the UI Service implementation that provide its own wizard ui control, which should manage all the events, panels, buttons, etc.
If you want to implement the UIService: Implement the AccountRegistrationWizard Container interface to provide a mechanism for adding and removing account registration wizards in the GUI. Example: Look at the swing implementation of the UIService.
AccountRegistrationWizard interface
WizardPage interface
How to add the account registration wizard in the UI
Once created, your AccountRegistrationWizard should be added to the UI. In the UIService interface you have a method called: getAccountRegWizardContainer. This method will return you the AccountRegistrationWizardContainer interface, which is implemented by the UI implementation and is charged to manage all account registration wizards. You could add then your wizard by invoking: addAccountRegistrationWizard.
Example: An implementation of the AccountRegistrationWizard for the ICQ protocol.
...
/**
* Returns the set of pages contained in this wizard.
*/
public Iterator getPages() {
ArrayList pages = new ArrayList();
firstWizardPage = new FirstWizardPage(registration, wizardContainer);
pages.add(firstWizardPage);
return pages.iterator();
}
/**
* Returns a set of the data that user has entered through this wizard.
*/
public Iterator getSummary() {
Hashtable summaryTable = new Hashtable();
summaryTable.put("UIN", registration.getUin());
summaryTable.put("Remember password",
new Boolean(registration.isRememberPassword()));
return summaryTable.entrySet().iterator();
}
/**
* Installs the account created through this wizard.
*/
public ProtocolProviderService finish() {
firstWizardPage = null;
ProtocolProviderFactory factory
= IcqAccRegWizzActivator.getIcqProtocolProviderFactory();
return this.installAccount(factory,
registration.getUin(), registration.getPassword());
}
...
}
public class FirstWizardPage extends JPanel
implements WizardPage {
/**
* Implements the <code>WizardPage.getIdentifier</code> to return
* this page identifier.
*/
public Object getIdentifier() {
return FIRST_PAGE_IDENTIFIER;
}
/**
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
* the next page identifier - the summary page.
*/
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
}
/**
* Implements the <code>WizardPage.getBackPageIdentifier</code> to return
* the next back identifier - the default page.
*/
public Object getBackPageIdentifier() {
return WizardPage.DEFAULT_PAGE_IDENTIFIER;
}
/**
* Implements the <code>WizardPage.getWizardForm</code> to return
* this panel.
*/
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.
*/
public void pageShowing() {
this.setNextButtonAccordingToUIN();
}
/**
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void pageNext() {
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
}
....
}
You could find the source code of this example in the plugin.icqaccregwizz package.
author: Yana Stamcheva