|
|
|
|
@ -14,6 +14,7 @@
|
|
|
|
|
import net.java.sip.communicator.plugin.desktoputil.*;
|
|
|
|
|
import net.java.sip.communicator.service.protocol.*;
|
|
|
|
|
import net.java.sip.communicator.service.protocol.event.*;
|
|
|
|
|
import net.java.sip.communicator.plugin.accountinfo.AccountInfoMenuItemComponent.*;
|
|
|
|
|
|
|
|
|
|
import org.osgi.framework.*;
|
|
|
|
|
|
|
|
|
|
@ -26,7 +27,8 @@
|
|
|
|
|
*/
|
|
|
|
|
public class AccountInfoPanel
|
|
|
|
|
extends TransparentPanel
|
|
|
|
|
implements ServiceListener
|
|
|
|
|
implements ServiceListener,
|
|
|
|
|
RegistrationStateChangeListener
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Serial version UID.
|
|
|
|
|
@ -58,13 +60,20 @@ public class AccountInfoPanel
|
|
|
|
|
accountsTable =
|
|
|
|
|
new HashMap<AccountID, AccountDetailsPanel>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The parent dialog.
|
|
|
|
|
*/
|
|
|
|
|
private AccountInfoDialog dialog;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance of <tt>AccountInfoPanel</tt> that contains combo box
|
|
|
|
|
* component with active user accounts and <tt>AccountDetailsPanel</tt> to
|
|
|
|
|
* display and edit account information.
|
|
|
|
|
*/
|
|
|
|
|
public AccountInfoPanel()
|
|
|
|
|
public AccountInfoPanel(AccountInfoDialog dialog)
|
|
|
|
|
{
|
|
|
|
|
this.dialog = dialog;
|
|
|
|
|
|
|
|
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
|
|
|
|
|
|
|
|
|
accountsComboBox = new JComboBox();
|
|
|
|
|
@ -112,8 +121,13 @@ public void itemStateChanged(ItemEvent e)
|
|
|
|
|
add(centerPanel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialize.
|
|
|
|
|
*/
|
|
|
|
|
private void init()
|
|
|
|
|
{
|
|
|
|
|
AccountInfoActivator.bundleContext.addServiceListener(this);
|
|
|
|
|
|
|
|
|
|
for (ProtocolProviderFactory providerFactory : AccountInfoActivator
|
|
|
|
|
.getProtocolProviderFactories().values())
|
|
|
|
|
{
|
|
|
|
|
@ -130,19 +144,34 @@ private void init()
|
|
|
|
|
protocolProvider = (ProtocolProviderService)AccountInfoActivator
|
|
|
|
|
.bundleContext.getService(serRef);
|
|
|
|
|
|
|
|
|
|
currentDetailsPanel = new AccountDetailsPanel(protocolProvider);
|
|
|
|
|
currentDetailsPanel = new AccountDetailsPanel(
|
|
|
|
|
dialog,
|
|
|
|
|
protocolProvider);
|
|
|
|
|
|
|
|
|
|
accountsTable.put(
|
|
|
|
|
protocolProvider.getAccountID(), currentDetailsPanel);
|
|
|
|
|
|
|
|
|
|
accountsComboBox.addItem(currentDetailsPanel);
|
|
|
|
|
|
|
|
|
|
protocolProvider.addRegistrationStateChangeListener(
|
|
|
|
|
new RegistrationStateChangeListenerImpl());
|
|
|
|
|
protocolProvider.addRegistrationStateChangeListener(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clears all listeners.
|
|
|
|
|
*/
|
|
|
|
|
public void dispose()
|
|
|
|
|
{
|
|
|
|
|
AccountInfoActivator.bundleContext.removeServiceListener(this);
|
|
|
|
|
|
|
|
|
|
for(AccountDetailsPanel pan : accountsTable.values())
|
|
|
|
|
{
|
|
|
|
|
pan.getProtocolProvider()
|
|
|
|
|
.removeRegistrationStateChangeListener(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A custom renderer to display properly <tt>AccountDetailsPanel</tt>
|
|
|
|
|
* in a combo box.
|
|
|
|
|
@ -179,57 +208,52 @@ public Component getListCellRendererComponent(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class RegistrationStateChangeListenerImpl
|
|
|
|
|
implements RegistrationStateChangeListener
|
|
|
|
|
public void registrationStateChanged(final RegistrationStateChangeEvent evt)
|
|
|
|
|
{
|
|
|
|
|
public void registrationStateChanged(
|
|
|
|
|
final RegistrationStateChangeEvent evt)
|
|
|
|
|
if(!SwingUtilities.isEventDispatchThread())
|
|
|
|
|
{
|
|
|
|
|
if(!SwingUtilities.isEventDispatchThread())
|
|
|
|
|
SwingUtilities.invokeLater(new Runnable()
|
|
|
|
|
{
|
|
|
|
|
SwingUtilities.invokeLater(new Runnable()
|
|
|
|
|
public void run()
|
|
|
|
|
{
|
|
|
|
|
public void run()
|
|
|
|
|
{
|
|
|
|
|
registrationStateChanged(evt);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
registrationStateChanged(evt);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProtocolProviderService protocolProvider = evt.getProvider();
|
|
|
|
|
ProtocolProviderService protocolProvider = evt.getProvider();
|
|
|
|
|
|
|
|
|
|
if (evt.getNewState() == RegistrationState.REGISTERED)
|
|
|
|
|
if (evt.getNewState() == RegistrationState.REGISTERED)
|
|
|
|
|
{
|
|
|
|
|
if (accountsTable.containsKey(protocolProvider.getAccountID()))
|
|
|
|
|
{
|
|
|
|
|
if (accountsTable.containsKey(protocolProvider.getAccountID()))
|
|
|
|
|
{
|
|
|
|
|
AccountDetailsPanel detailsPanel
|
|
|
|
|
= accountsTable.get(protocolProvider.getAccountID());
|
|
|
|
|
detailsPanel.loadDetails();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AccountDetailsPanel panel =
|
|
|
|
|
new AccountDetailsPanel(protocolProvider);
|
|
|
|
|
accountsTable.put(protocolProvider.getAccountID(), panel);
|
|
|
|
|
accountsComboBox.addItem(panel);
|
|
|
|
|
}
|
|
|
|
|
AccountDetailsPanel detailsPanel
|
|
|
|
|
= accountsTable.get(protocolProvider.getAccountID());
|
|
|
|
|
detailsPanel.loadDetails();
|
|
|
|
|
}
|
|
|
|
|
else if (evt.getNewState() == RegistrationState.UNREGISTERING)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AccountDetailsPanel panel
|
|
|
|
|
= accountsTable.get(protocolProvider.getAccountID());
|
|
|
|
|
if (panel != null)
|
|
|
|
|
AccountDetailsPanel panel =
|
|
|
|
|
new AccountDetailsPanel(dialog, protocolProvider);
|
|
|
|
|
accountsTable.put(protocolProvider.getAccountID(), panel);
|
|
|
|
|
accountsComboBox.addItem(panel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (evt.getNewState() == RegistrationState.UNREGISTERING)
|
|
|
|
|
{
|
|
|
|
|
AccountDetailsPanel panel
|
|
|
|
|
= accountsTable.get(protocolProvider.getAccountID());
|
|
|
|
|
if (panel != null)
|
|
|
|
|
{
|
|
|
|
|
accountsTable.remove(protocolProvider.getAccountID());
|
|
|
|
|
accountsComboBox.removeItem(panel);
|
|
|
|
|
if (currentDetailsPanel == panel)
|
|
|
|
|
{
|
|
|
|
|
accountsTable.remove(protocolProvider.getAccountID());
|
|
|
|
|
accountsComboBox.removeItem(panel);
|
|
|
|
|
if (currentDetailsPanel == panel)
|
|
|
|
|
{
|
|
|
|
|
currentDetailsPanel = null;
|
|
|
|
|
centerPanel.removeAll();
|
|
|
|
|
centerPanel.revalidate();
|
|
|
|
|
centerPanel.repaint();
|
|
|
|
|
}
|
|
|
|
|
currentDetailsPanel = null;
|
|
|
|
|
centerPanel.removeAll();
|
|
|
|
|
centerPanel.revalidate();
|
|
|
|
|
centerPanel.repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -276,11 +300,10 @@ public void run()
|
|
|
|
|
if (accountsTable.get(protocolProvider.getAccountID()) == null)
|
|
|
|
|
{
|
|
|
|
|
AccountDetailsPanel panel =
|
|
|
|
|
new AccountDetailsPanel(protocolProvider);
|
|
|
|
|
new AccountDetailsPanel(dialog, protocolProvider);
|
|
|
|
|
accountsTable.put(protocolProvider.getAccountID(), panel);
|
|
|
|
|
accountsComboBox.addItem(panel);
|
|
|
|
|
protocolProvider.addRegistrationStateChangeListener(
|
|
|
|
|
new RegistrationStateChangeListenerImpl());
|
|
|
|
|
protocolProvider.addRegistrationStateChangeListener(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If the protocol provider is being unregistered we have to remove
|
|
|
|
|
|