Wait until all requested wizards are registered before showing the form

cusax-fix 4962
Ingo Bauersachs 12 years ago
parent 4cbda78cea
commit c5d05781ed

@ -34,7 +34,6 @@
*/
public class InitialAccountRegistrationFrame
extends SIPCommFrame
implements ServiceListener
{
/**
* Serial version UID.
@ -157,7 +156,7 @@ public InitialAccountRegistrationFrame()
if (scroller.getViewport().getHeight()
< Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 230)
{
this.setSize(this.getSize().width,
this.setSize(scroller.getViewport().getWidth() + 100,
scroller.getViewport().getHeight() + 150);
}
else
@ -269,9 +268,6 @@ private void initAccountWizards()
logger.error("GuiActivator : ", ex);
}
}
SimpleAccountRegistrationActivator.bundleContext
.addServiceListener(this);
}
/**
@ -503,27 +499,6 @@ public void signin() throws OperationFailedException
}
}
/**
* Handles registration of a new account wizard.
*/
public void serviceChanged(ServiceEvent event)
{
Object sService = SimpleAccountRegistrationActivator.bundleContext.
getService(event.getServiceReference());
// we don't care if the source service is not a plugin component
if (! (sService instanceof AccountRegistrationWizard))
return;
AccountRegistrationWizard wizard
= (AccountRegistrationWizard) sService;
if (event.getType() == ServiceEvent.REGISTERED)
{
this.addAccountRegistrationForm(wizard);
}
}
/**
* Adds a simple account registration form corresponding to the given
* <tt>AccountRegistrationWizard</tt>.

@ -25,7 +25,8 @@
* @author Yana Stamcheva
*/
public class SimpleAccountRegistrationActivator
implements BundleActivator
implements BundleActivator,
ServiceListener
{
private static final Logger logger
= Logger.getLogger(SimpleAccountRegistrationActivator.class);
@ -57,6 +58,10 @@ public class SimpleAccountRegistrationActivator
private static ResourceManagementService resourcesService;
private int numWizardsRegistered = 0;
private String[] protocolNames;
public void start(BundleContext bc)
throws Exception
{
@ -77,6 +82,20 @@ public void run()
init();
}
/**
* Handles registration of a new account wizard.
*/
public void serviceChanged(ServiceEvent event)
{
if (event.getType() == ServiceEvent.REGISTERED)
{
if (++numWizardsRegistered == protocolNames.length)
{
showDialog();
}
}
}
/**
* Initialize and displays the initial registration frame.
*/
@ -93,21 +112,75 @@ private void init()
&& !getConfigService().getBoolean(DISABLED_PROP, false))
{
// If no preferred wizard is specified we launch the default wizard.
InitialAccountRegistrationFrame accountRegFrame =
new InitialAccountRegistrationFrame();
String protocolOrder
= SimpleAccountRegistrationActivator.getConfigService()
.getString("plugin.simpleaccreg.PROTOCOL_ORDER");
if (protocolOrder == null)
{
return;
}
String protocolFilter = "";
protocolNames = protocolOrder.split("\\|");
for (int i = 0; i < protocolNames.length; i++)
{
if (i > 0)
{
protocolFilter = "(|" + protocolFilter;
}
protocolFilter += "(" + ProtocolProviderFactory.PROTOCOL
+ "=" + protocolNames[i] + ")";
if (i > 0)
{
protocolFilter += ")";
}
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
accountRegFrame.setLocation(screenSize.width / 2
- accountRegFrame.getWidth() / 2, screenSize.height / 2
- accountRegFrame.getHeight() / 2);
try
{
ServiceReference[] refs = bundleContext.getAllServiceReferences(
AccountRegistrationWizard.class.getName(), protocolFilter);
if (refs != null)
{
numWizardsRegistered = refs.length;
}
accountRegFrame.setVisible(true);
// not all requested wizard are available, wait for them
if (numWizardsRegistered < protocolNames.length)
{
bundleContext.addServiceListener(this, "(&(objectclass="
+ AccountRegistrationWizard.class.getName() + ")"
+ protocolFilter + ")");
}
else
{
showDialog();
}
}
catch (InvalidSyntaxException e)
{
logger.error(e);
}
}
if (logger.isInfoEnabled())
logger.info("SIMPLE ACCOUNT REGISTRATION ...[STARTED]");
}
private void showDialog()
{
InitialAccountRegistrationFrame accountRegFrame =
new InitialAccountRegistrationFrame();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
accountRegFrame.setLocation(screenSize.width / 2
- accountRegFrame.getWidth() / 2, screenSize.height / 2
- accountRegFrame.getHeight() / 2);
accountRegFrame.setVisible(true);
}
public void stop(BundleContext bc) throws Exception
{
}

Loading…
Cancel
Save