diff options
author | Yana Stamcheva <yana@jitsi.org> | 2008-06-23 10:13:09 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2008-06-23 10:13:09 +0000 |
commit | b04e3f61cbae18446baa86cb291a5c66405a06d4 (patch) | |
tree | 009794ddbcb83b718894e10ff45da35e99555c26 /src/net/java/sip/communicator/impl | |
parent | ec05a7a407851d8994abbe087008041c7293452e (diff) | |
download | jitsi-b04e3f61cbae18446baa86cb291a5c66405a06d4.zip jitsi-b04e3f61cbae18446baa86cb291a5c66405a06d4.tar.gz jitsi-b04e3f61cbae18446baa86cb291a5c66405a06d4.tar.bz2 |
New Account configuration forms.
Diffstat (limited to 'src/net/java/sip/communicator/impl')
18 files changed, 707 insertions, 539 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java index a33e682..07a5aab 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommDialog.java @@ -30,7 +30,7 @@ public abstract class SIPCommDialog extends JDialog this.addWindowListener(new DialogWindowAdapter()); - this.initInputMap(); + this.initInputMap(); } public SIPCommDialog(Frame owner) diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java index c19b47f..d4e652b 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/wizard/WizardController.java @@ -74,7 +74,7 @@ public class WizardController implements ActionListener { try { - page.pageNext(); + page.commitPage(); } catch (Exception ex) { diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegFirstPage.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegFirstPage.java index 198bd8b..12a96af 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegFirstPage.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegFirstPage.java @@ -6,14 +6,12 @@ */ package net.java.sip.communicator.impl.gui.main.account; +import java.awt.*; +import java.awt.event.*; import java.io.*; import java.util.*; import javax.imageio.*; - -import java.awt.*; -import java.awt.event.*; - import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; @@ -22,7 +20,6 @@ import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.util.*; /** @@ -33,8 +30,7 @@ import net.java.sip.communicator.util.*; * @author Yana Stamcheva */ public class AccountRegFirstPage extends JPanel - implements AccountRegistrationListener, - WizardPage, + implements WizardPage, ListSelectionListener, MouseListener { @@ -141,11 +137,9 @@ public class AccountRegFirstPage extends JPanel * <tt>AccountRegistrationWizardContainer</tt> adds a line for this * wizard in the table. */ - public void accountRegistrationAdded(AccountRegistrationEvent event) { - - final AccountRegistrationWizard wizard - = (AccountRegistrationWizard)event.getSource(); - + public void addAccountRegistrationWizard( + final AccountRegistrationWizard wizard) + { String pName = wizard.getProtocolName(); Image protocolImage = null; @@ -179,10 +173,8 @@ public class AccountRegFirstPage extends JPanel * <tt>AccountRegistrationWizardContainer</tt> removes the corresponding * line from the table. */ - public void accountRegistrationRemoved(AccountRegistrationEvent event) { - AccountRegistrationWizard wizard - = (AccountRegistrationWizard)event.getSource(); - + public void removeAccountRegistrationWizard(AccountRegistrationWizard wizard) + { tableModel.removeRow(tableModel.rowIndexOf(wizard)); } @@ -267,7 +259,7 @@ public class AccountRegFirstPage extends JPanel * the choosen wizard and register all the pages contained in this wizard * in our wizard container. */ - public void pageNext() + public void commitPage() { AccountRegistrationWizard wizard = (AccountRegistrationWizard)tableModel diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java index d49bc1e..25770ff 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java @@ -145,7 +145,7 @@ public class AccountRegSummaryPage * from the wizard container when user clicks the "Next" button. We invoke * here the wizard finish method. */ - public void pageNext() + public void commitPage() { AccountRegistrationWizard wizard = this.wizardContainer.getCurrentWizard(); diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java index 3585a51..cc9fc1a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java @@ -18,7 +18,6 @@ import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -47,12 +46,6 @@ public class AccountRegWizardContainerImpl private Hashtable registeredWizards = new Hashtable(); - /** - * Listeners interested in events dispatched upon modifications in the - * account registrations list. - */ - private Vector accountRegListeners = new Vector(); - public AccountRegWizardContainerImpl(MainFrame mainFrame) { super(mainFrame); @@ -68,8 +61,6 @@ public class AccountRegWizardContainerImpl this.registerWizardPage(summaryPage.getIdentifier(), summaryPage); - this.addAccountRegistrationListener(defaultPage); - ServiceReference[] accountWizardRefs = null; try { @@ -148,8 +139,7 @@ public class AccountRegWizardContainerImpl } } - this.fireAccountRegistrationEvent(wizard, - AccountRegistrationEvent.REGISTRATION_ADDED); + defaultPage.addAccountRegistrationWizard(wizard); } /** @@ -165,75 +155,7 @@ public class AccountRegWizardContainerImpl registeredWizards.remove(wizard.getClass().getName()); } - this.fireAccountRegistrationEvent(wizard, - AccountRegistrationEvent.REGISTRATION_REMOVED); - } - - /** - * Adds a listener for <tt>AccountRegistrationEvent</tt>s. - * - * @param l the listener to add - */ - public void addAccountRegistrationListener(AccountRegistrationListener l) - { - synchronized (accountRegListeners) - { - this.accountRegListeners.add(l); - } - } - - /** - * Removes a listener for <tt>AccountRegistrationEvent</tt>s. - * - * @param l the listener to remove - */ - public void removeAccountRegistrationListener(AccountRegistrationListener l) - { - synchronized (accountRegListeners) - { - this.accountRegListeners.remove(l); - } - } - - /** - * Creates the corresponding <tt>AccountRegistrationEvent</tt> instance - * and notifies all <tt>AccountRegistrationListener</tt>s that an account - * registration wizard has been added or removed from this container. - * - * @param wizard The wizard that has caused the event. - * @param eventID one of the REGISTRATION_XXX static fields indicating the - * nature of the event. - */ - private void fireAccountRegistrationEvent(AccountRegistrationWizard wizard, - int eventID) - { - AccountRegistrationEvent evt = - new AccountRegistrationEvent(wizard, eventID); - - logger.trace("Will dispatch the following mcl event: " + evt); - - synchronized (accountRegListeners) - { - Iterator listeners = this.accountRegListeners.iterator(); - - while (listeners.hasNext()) - { - AccountRegistrationListener l = - (AccountRegistrationListener) listeners.next(); - - switch (evt.getEventID()) - { - case AccountRegistrationEvent.REGISTRATION_ADDED: - l.accountRegistrationAdded(evt); - break; - case AccountRegistrationEvent.REGISTRATION_REMOVED: - l.accountRegistrationRemoved(evt); - break; - default: - logger.error("Unknown event type " + evt.getEventID()); - } - } - } + defaultPage.removeAccountRegistrationWizard(wizard); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationForm.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationForm.java new file mode 100644 index 0000000..478d248 --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationForm.java @@ -0,0 +1,449 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. See terms of license at gnu.org. + */ + +package net.java.sip.communicator.impl.gui.main.account; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; +import java.util.List; + +import javax.imageio.*; +import javax.swing.*; + +import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.i18n.*; +import net.java.sip.communicator.impl.gui.main.*; +import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +import org.osgi.framework.*; + +/** + * The <tt>AccountsConfigurationForm</tt> is the form where the user could + * create, modify or delete an account. + * + * @author Yana Stamcheva + */ +public class AccountsConfigurationForm + extends JPanel + implements ConfigurationForm, + ActionListener, + ServiceListener +{ + private Logger logger = + Logger.getLogger(AccountsConfigurationForm.class.getName()); + + private JScrollPane scrollPane = new JScrollPane(); + + private JPanel wrapAccountsPanel = new JPanel(new BorderLayout()); + + private JPanel accountsPanel = new JPanel(); + + private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + private I18NString newString = Messages.getI18NString("newAccount"); + + private JButton newButton = new JButton(newString.getText()); + + private I18NString saveString = Messages.getI18NString("save"); + + private JButton saveButton = new JButton(saveString.getText()); + + private MainFrame mainFrame; + + private Hashtable accounts = new Hashtable(); + + /** + * Creates an instance of <tt>AccountsConfigurationForm</tt>. + * + * @param mainFrame the main application window + */ + public AccountsConfigurationForm(MainFrame mainFrame) + { + super(new BorderLayout()); + + this.mainFrame = mainFrame; + + GuiActivator.bundleContext.addServiceListener(this); + + this.add(scrollPane, BorderLayout.CENTER); + this.add(buttonsPanel, BorderLayout.SOUTH); + + this.newButton.addActionListener(this); + this.saveButton.addActionListener(this); + + this.newButton.setMnemonic(newString.getMnemonic()); + this.saveButton.setMnemonic(saveString.getMnemonic()); + + this.buttonsPanel.add(newButton); + this.buttonsPanel.add(saveButton); + + this.scrollPane.getViewport().add(wrapAccountsPanel); + + this.wrapAccountsPanel.add(accountsPanel, BorderLayout.NORTH); + + this.accountsInit(); + + this.setPreferredSize(new Dimension(500, 400)); + } + + /** + * Initializes the accounts table. + */ + private void accountsInit() + { + this.accountsPanel.setLayout(new BoxLayout(accountsPanel, + BoxLayout.Y_AXIS)); + + Set set = GuiActivator.getProtocolProviderFactories().entrySet(); + Iterator iter = set.iterator(); + + while (iter.hasNext()) + { + Map.Entry entry = (Map.Entry) iter.next(); + + ProtocolProviderFactory providerFactory = + (ProtocolProviderFactory) entry.getValue(); + + ArrayList accountsList = providerFactory.getRegisteredAccounts(); + + AccountID accountID; + ServiceReference serRef; + ProtocolProviderService protocolProvider; + + for (int i = 0; i < accountsList.size(); i++) + { + accountID = (AccountID) accountsList.get(i); + + boolean isHidden = + (accountID.getAccountProperties().get("HIDDEN_PROTOCOL") + != null); + + if (isHidden) + continue; + + serRef = providerFactory.getProviderForAccount(accountID); + + protocolProvider = + (ProtocolProviderService) GuiActivator.bundleContext + .getService(serRef); + + AccountPanel accountPanel = new AccountPanel(protocolProvider); + + accountsPanel.add(accountPanel); + accounts.put(protocolProvider, accountPanel); + } + } + } + + /** + * + */ + private class AccountPanel + extends JPanel + implements ActionListener + { + private JLabel protocolLabel = new JLabel(); + + private JLabel accountLabel = new JLabel(); + + private JPasswordField passwordField = new JPasswordField(); + + private I18NString modifyString = Messages.getI18NString("settings"); + + private I18NString removeString = Messages.getI18NString("remove"); + + private JButton modifyButton = new JButton(modifyString.getText()); + + private JButton removeButton = new JButton(removeString.getText()); + + private GridBagConstraints constraints = new GridBagConstraints(); + + private Image protocolImage; + + private ProtocolProviderService protocolProvider; + + public AccountPanel(ProtocolProviderService protocolProvider) + { + super(new GridBagLayout()); + + this.protocolProvider = protocolProvider; + + this.setPreferredSize(new Dimension(400, 80)); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, + Color.GRAY)); + + try + { + protocolImage = + ImageIO.read(new ByteArrayInputStream(protocolProvider + .getProtocolIcon() + .getIcon(ProtocolIcon.ICON_SIZE_16x16))); + } + catch (IOException e) + { + logger.error("Could not read image.", e); + } + protocolLabel.setIcon(new ImageIcon(protocolImage)); + constraints.insets = new Insets(0, 5, 0, 5); + constraints.weightx = 0; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.anchor = GridBagConstraints.FIRST_LINE_START; + this.add(protocolLabel, constraints); + + this.accountLabel.setText(protocolProvider.getAccountID() + .getUserID()); + constraints.insets = new Insets(0, 0, 0, 0); + constraints.gridx = 1; + constraints.gridy = 0; + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.anchor = GridBagConstraints.FIRST_LINE_START; + constraints.weightx = 1.0; + this.add(accountLabel, constraints); + + String passwordRequiredProperty = (String) protocolProvider + .getAccountID().getAccountProperties().get( + ProtocolProviderFactory.NO_PASSWORD_REQUIRED); + + boolean isPasswordRequired = true; + if (passwordRequiredProperty != null + && passwordRequiredProperty != "") + { + isPasswordRequired + = !(new Boolean(passwordRequiredProperty).booleanValue()); + } + + if (isPasswordRequired) + { + String password = + (String) protocolProvider.getAccountID() + .getAccountProperties() + .get(ProtocolProviderFactory.PASSWORD); + + passwordField.setText(password); + constraints.gridx = 1; + constraints.gridy = 1; + constraints.anchor = GridBagConstraints.FIRST_LINE_START; + this.add(passwordField, constraints); + } + + constraints.gridx = 2; + constraints.gridy = 0; + constraints.weightx = 0; + this.add(modifyButton, constraints); + this.modifyButton.addActionListener(this); + + constraints.gridx = 2; + constraints.gridy = 1; + constraints.weightx = 0; + this.add(removeButton, constraints); + this.removeButton.addActionListener(this); + } + + public void save() + { + ProtocolProviderFactory providerFactory = + GuiActivator.getProtocolProviderFactory(protocolProvider); + + Map accountProperties + = protocolProvider.getAccountID().getAccountProperties(); + + String password = new String(passwordField.getPassword()); + + if (!password.equals( + accountProperties.get(ProtocolProviderFactory.PASSWORD))) + { + accountProperties.put(ProtocolProviderFactory.PASSWORD, + new String(passwordField.getPassword())); + } + + providerFactory.modifyAccount(protocolProvider, accountProperties); + } + + public void actionPerformed(ActionEvent e) + { + JButton sourceButton = (JButton) e.getSource(); + + if (sourceButton.equals(removeButton)) + { + ProtocolProviderFactory providerFactory = + GuiActivator.getProtocolProviderFactory(protocolProvider); + + if (providerFactory != null) + { + int result = + JOptionPane.showConfirmDialog(this, Messages + .getI18NString("removeAccountMessage").getText(), + Messages.getI18NString("removeAccount").getText(), + JOptionPane.YES_NO_CANCEL_OPTION); + + if (result == JOptionPane.YES_OPTION) + { + ConfigurationService configService = + GuiActivator.getConfigurationService(); + + String prefix = + "net.java.sip.communicator.impl.gui.accounts"; + + List accounts = + configService + .getPropertyNamesByPrefix(prefix, true); + + Iterator accountsIter = accounts.iterator(); + + while (accountsIter.hasNext()) + { + String accountRootPropName = + (String) accountsIter.next(); + + String accountUID = + configService.getString(accountRootPropName); + + if (accountUID.equals(protocolProvider + .getAccountID().getAccountUniqueID())) + { + + configService.setProperty(accountRootPropName, + null); + break; + } + } + providerFactory.uninstallAccount(protocolProvider + .getAccountID()); + } + } + } + else if (sourceButton.equals(modifyButton)) + { + AccountRegWizardContainerImpl wizard = + (AccountRegWizardContainerImpl) GuiActivator.getUIService() + .getAccountRegWizardContainer(); + + wizard.setTitle(Messages.getI18NString( + "accountRegistrationWizard").getText()); + + wizard.modifyAccount(protocolProvider); + wizard.showDialog(false); + } + } + } + + /** + * Returns the title of this configuration form. + * + * @return the title of this configuration form. + */ + public String getTitle() + { + return Messages.getI18NString("accounts").getText(); + } + + /** + * Returns the icon of this configuration form. + * + * @return the icon of this configuration form. + */ + public byte[] getIcon() + { + return ImageLoader.getImageInBytes(ImageLoader.ACCOUNT_ICON); + } + + /** + * Returns the form of this configuration form. + * + * @return the form of this configuration form. + */ + public Object getForm() + { + return this; + } + + /** + * Handles the <tt>ActionEvent</tt> triggered when user clicks on on the + * buttons. Shows the account registration wizard when user clicks on "New". + * + * @param evt the action event that has just occurred. + */ + public void actionPerformed(ActionEvent evt) + { + JButton sourceButton = (JButton) evt.getSource(); + + if (sourceButton.equals(newButton)) + { + NewAccountDialog newAccountDialog = new NewAccountDialog(); + + newAccountDialog.pack(); + newAccountDialog.setVisible(true); + } + else if (sourceButton.equals(saveButton)) + { + Enumeration accountPanels = accounts.elements(); + + while (accountPanels.hasMoreElements()) + { + AccountPanel accountPanel + = (AccountPanel) accountPanels.nextElement(); + + accountPanel.save(); + } + } + } + + /** + * Implements the <tt>ServiceListener</tt> method. Verifies whether the + * passed event concerns a <tt>ProtocolProviderService</tt> and adds the + * corresponding UI controls. + * + * @param event The <tt>ServiceEvent</tt> object. + */ + public void serviceChanged(ServiceEvent event) + { + // if the event is caused by a bundle being stopped, we don't want to + // know + if (event.getServiceReference().getBundle().getState() == Bundle.STOPPING) + { + return; + } + Object sourceService = + GuiActivator.bundleContext.getService(event.getServiceReference()); + + // we don't care if the source service is not a protocol provider + if (!(sourceService instanceof ProtocolProviderService)) + { + return; + } + + ProtocolProviderService pps = (ProtocolProviderService) sourceService; + + if (event.getType() == ServiceEvent.REGISTERED) + { + AccountPanel accountPanel = new AccountPanel(pps); + + this.accountsPanel.add(accountPanel); + this.accountsPanel.revalidate(); + this.accountsPanel.repaint(); + + this.accounts.put(pps, accountPanel); + } + else if (event.getType() == ServiceEvent.UNREGISTERING) + { + this.accountsPanel.remove((JPanel) accounts.get(pps)); + this.accountsPanel.revalidate(); + this.accountsPanel.repaint(); + } + } + + public int getIndex() + { + return 1; + } +} diff --git a/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java new file mode 100644 index 0000000..da40327 --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java @@ -0,0 +1,232 @@ +package net.java.sip.communicator.impl.gui.main.account; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + +import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.i18n.*; +import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.util.*; + +import org.osgi.framework.*; + +public class NewAccountDialog + extends SIPCommDialog + implements ActionListener +{ + private Logger logger = Logger.getLogger(NewAccountDialog.class); + + private JPanel mainPanel = new JPanel(new BorderLayout(5, 5)); + + private JPanel accountPanel = new JPanel(new BorderLayout()); + + private JPanel networkPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + + private JLabel networkLabel = new JLabel( + Messages.getI18NString("network").getText()); + + private JComboBox networkComboBox = new JComboBox(); + + private JButton advancedButton = new JButton( + Messages.getI18NString("advanced").getText()); + + private JButton addAccountButton = new JButton( + Messages.getI18NString("newAccount").getText()); + + private JButton cancelButton = new JButton( + Messages.getI18NString("cancel").getText()); + + private JPanel rightButtonPanel + = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + + private JPanel buttonPanel = new JPanel(new BorderLayout()); + + private String preferredWizardName; + + public NewAccountDialog() + { + super(GuiActivator.getUIService().getMainFrame()); + + this.setTitle(Messages.getI18NString("newAccount").getText()); + + this.getContentPane().add(mainPanel); + + this.mainPanel.setBorder( + BorderFactory.createEmptyBorder(15, 15, 15, 15)); + + this.mainPanel.add(buttonPanel, BorderLayout.SOUTH); + this.buttonPanel.add(advancedButton, BorderLayout.WEST); + this.buttonPanel.add(rightButtonPanel, BorderLayout.EAST); + this.advancedButton.addActionListener(this); + + this.rightButtonPanel.add(addAccountButton); + this.rightButtonPanel.add(cancelButton); + this.addAccountButton.addActionListener(this); + this.cancelButton.addActionListener(this); + + this.mainPanel.add(networkPanel, BorderLayout.NORTH); + this.networkPanel.add(networkLabel, BorderLayout.WEST); + this.networkPanel.add(networkComboBox, BorderLayout.CENTER); + + this.getRootPane().setDefaultButton(addAccountButton); + + this.networkComboBox.setRenderer(new NetworkListCellRenderer()); + this.networkComboBox.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + AccountRegistrationWizard wizard + = (AccountRegistrationWizard) networkComboBox + .getSelectedItem(); + + loadSelectedWizard(wizard); + } + }); + + this.mainPanel.add(accountPanel, BorderLayout.CENTER); + + this.initNetworkList(); + } + + private void initNetworkList() + { + // check for preferred wizard + String prefWName = LoginProperties.getProperty("preferredAccountWizard"); + if(prefWName != null && prefWName.length() > 0) + preferredWizardName = prefWName; + + ServiceReference[] accountWizardRefs = null; + try + { + accountWizardRefs = GuiActivator.bundleContext + .getServiceReferences( + AccountRegistrationWizard.class.getName(), + null); + } + catch (InvalidSyntaxException ex) + { + // this shouldn't happen since we're providing no parameter string + // but let's log just in case. + logger.error( + "Error while retrieving service refs", ex); + return; + } + + // in case we found any, add them in this container. + if (accountWizardRefs != null) + { + logger.debug("Found " + + accountWizardRefs.length + + " already installed providers."); + for (int i = 0; i < accountWizardRefs.length; i++) + { + AccountRegistrationWizard wizard + = (AccountRegistrationWizard) GuiActivator.bundleContext + .getService(accountWizardRefs[i]); + + networkComboBox.addItem(wizard); + + // if we have preferred wizard insert it at first position + if(preferredWizardName != null + && wizard.getClass().getName().equals(preferredWizardName)) + networkComboBox.setSelectedItem(wizard); + } + } + } + + private class NetworkListCellRenderer + extends JLabel + implements ListCellRenderer + { + public NetworkListCellRenderer() + { + this.setOpaque(true); + } + + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) + { + AccountRegistrationWizard wizard + = (AccountRegistrationWizard) value; + + if (isSelected) + { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } + else + { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + + this.setText(wizard.getProtocolName()); + this.setIcon(new ImageIcon( + ImageLoader.getBytesInImage(wizard.getIcon()))); + + return this; + } + } + + private void loadSelectedWizard(AccountRegistrationWizard wizard) + { + accountPanel.removeAll(); + + JPanel fixedWidthPanel = new JPanel(); + this.accountPanel.add(fixedWidthPanel, BorderLayout.SOUTH); + fixedWidthPanel.setPreferredSize(new Dimension(430, 3)); + fixedWidthPanel.setMinimumSize(new Dimension(430, 3)); + fixedWidthPanel.setMaximumSize(new Dimension(430, 3)); + + accountPanel.add((Component) wizard.getSimpleForm(), BorderLayout.NORTH); + accountPanel.revalidate(); + accountPanel.repaint(); + this.pack(); + } + + @Override + protected void close(boolean isEscaped) + { + } + + /** + * + */ + public void actionPerformed(ActionEvent event) + { + JButton sourceButton = (JButton) event.getSource(); + + AccountRegistrationWizard wizard + = (AccountRegistrationWizard) networkComboBox.getSelectedItem(); + + if (sourceButton.equals(advancedButton)) + { + wizard.setModification(false); + + AccountRegWizardContainerImpl wizardContainer + = ((AccountRegWizardContainerImpl) GuiActivator.getUIService() + .getAccountRegWizardContainer()); + + wizardContainer.setTitle(Messages.getI18NString( + "accountRegistrationWizard").getText()); + + wizardContainer.setCurrentWizard(wizard); + + wizardContainer.showDialog(false); + } + else if (sourceButton.equals(addAccountButton)) + { + wizard.signin(); + + this.dispose(); + } + else if (sourceButton.equals(cancelButton)) + { + this.dispose(); + } + } +} diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage1.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage1.java index afa97fb..709a197 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage1.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage1.java @@ -131,7 +131,7 @@ public class CreateChatRoomWizardPage1 { } - public void pageNext() + public void commitPage() { selectAccountPanel.setSelectedAccount(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage2.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage2.java index 7aabc2d..69f5b25 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage2.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/CreateChatRoomWizardPage2.java @@ -99,7 +99,7 @@ public class CreateChatRoomWizardPage2 namePanel.setNextFinishButtonAccordingToUIN(); } - public void pageNext() + public void commitPage() { } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage1.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage1.java index e1c6038..0cb1a4e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage1.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage1.java @@ -146,7 +146,7 @@ public class JoinChatRoomWizardPage1 /** * Saves the selected account before going to the next page. */ - public void pageNext() + public void commitPage() { selectAccountPanel.setSelectedAccount(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java index ff89800..dc96b43 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomWizardPage2.java @@ -121,7 +121,7 @@ public class JoinChatRoomWizardPage2 { } - public void pageNext() + public void commitPage() { } diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java b/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java deleted file mode 100644 index 8a45a34..0000000 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package net.java.sip.communicator.impl.gui.main.configforms; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; -import java.util.List; - -import javax.imageio.*; -import javax.swing.*; -import javax.swing.table.*; - -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; -import net.java.sip.communicator.impl.gui.i18n.*; -import net.java.sip.communicator.impl.gui.main.*; -import net.java.sip.communicator.impl.gui.main.account.*; -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; - -/** - * The <tt>AccountsConfigurationForm</tt> is the form where the user - * could create, modify or delete an account. - * - * @author Yana Stamcheva - */ -public class AccountsConfigurationForm extends JPanel - implements ConfigurationForm, - ActionListener, - ServiceListener { - - private Logger logger = Logger.getLogger( - AccountsConfigurationForm.class.getName()); - - private JScrollPane tablePane = new JScrollPane(); - - private JTable accountsTable = new JTable(); - - private JPanel rightPanel = new JPanel(new BorderLayout()); - - private JPanel buttonsPanel = new JPanel(new GridLayout(0, 1, 8, 8)); - - private I18NString newString = Messages.getI18NString("new"); - - private I18NString modifyString = Messages.getI18NString("modify"); - - private I18NString removeString = Messages.getI18NString("remove"); - - private JButton newButton = new JButton(newString.getText()); - - private JButton modifyButton = new JButton(modifyString.getText()); - - private JButton removeButton = new JButton(removeString.getText()); - - private ExtendedTableModel tableModel = new ExtendedTableModel(); - - private MainFrame mainFrame; - - /** - * Creates an instance of <tt>AccountsConfigurationForm</tt>. - * - * @param mainFrame the main application window - */ - public AccountsConfigurationForm(MainFrame mainFrame) { - super(new BorderLayout()); - - this.mainFrame = mainFrame; - - GuiActivator.bundleContext.addServiceListener(this); - - this.tableInit(); - - this.buttonsPanelInit(); - - this.add(tablePane, BorderLayout.CENTER); - this.add(rightPanel, BorderLayout.EAST); - - this.setPreferredSize(new Dimension(500, 400)); - } - - /** - * Initializes the buttons panel. - */ - private void buttonsPanelInit() { - this.newButton.addActionListener(this); - this.modifyButton.addActionListener(this); - this.removeButton.addActionListener(this); - - this.newButton.setMnemonic(newString.getMnemonic()); - this.modifyButton.setMnemonic(modifyString.getMnemonic()); - this.removeButton.setMnemonic(removeString.getMnemonic()); - - this.buttonsPanel.add(newButton); - this.buttonsPanel.add(modifyButton); - this.buttonsPanel.add(removeButton); - - this.rightPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - this.rightPanel.add(buttonsPanel, BorderLayout.NORTH); - } - - /** - * Initializes the accounts table. - */ - private void tableInit() { - - accountsTable.setRowHeight(22); - accountsTable.setSelectionMode( - - ListSelectionModel.SINGLE_SELECTION); - - accountsTable.setShowHorizontalLines(false); - accountsTable.setShowVerticalLines(false); - accountsTable.setModel(tableModel); - accountsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); - - tableModel.addColumn("id"); - tableModel.addColumn(Messages.getI18NString("protocol").getText()); - tableModel.addColumn(Messages.getI18NString("account").getText()); - - TableColumnModel columnModel = accountsTable.getColumnModel(); - columnModel.removeColumn(columnModel.getColumn(0)); - columnModel.getColumn(0) - .setCellRenderer(new LabelTableCellRenderer()); - columnModel.getColumn(1) - .setCellRenderer(new LabelTableCellRenderer()); - - columnModel.getColumn(0).setPreferredWidth(100); - columnModel.getColumn(1).setPreferredWidth(361); - - this.initializeAccountsTable(); - - this.tablePane.getViewport().add(accountsTable); - } - - /** - * From all protocol provider factories obtains all already registered - * accounts and adds them to the table. - */ - private void initializeAccountsTable() { - Set set = GuiActivator.getProtocolProviderFactories().entrySet(); - Iterator iter = set.iterator(); - - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - - ProtocolProviderFactory providerFactory - = (ProtocolProviderFactory) entry.getValue(); - - ArrayList accountsList - = providerFactory.getRegisteredAccounts(); - - AccountID accountID; - ServiceReference serRef; - ProtocolProviderService protocolProvider; - - for (int i = 0; i < accountsList.size(); i ++) { - accountID = (AccountID) accountsList.get(i); - - boolean isHidden = - accountID.getAccountProperties(). - get("HIDDEN_PROTOCOL") != null; - - if(isHidden) - continue; - - serRef = providerFactory - .getProviderForAccount(accountID); - - protocolProvider - = (ProtocolProviderService) GuiActivator.bundleContext - .getService(serRef); - - String pName = protocolProvider.getProtocolDisplayName(); - - Image protocolImage = null; - try - { - protocolImage - = ImageIO.read(new ByteArrayInputStream( - protocolProvider.getProtocolIcon() - .getIcon(ProtocolIcon.ICON_SIZE_16x16))); - } - catch (IOException e) - { - logger.error("Could not read image.", e); - } - - JLabel protocolLabel = new JLabel(); - protocolLabel.setText(pName); - protocolLabel.setIcon(new ImageIcon(protocolImage)); - - tableModel.addRow(new Object[]{protocolProvider, protocolLabel, - accountID.getUserID()}); - } - } - } - - /** - * Returns the title of this configuration form. - * @return the title of this configuration form. - */ - public String getTitle() { - return Messages.getI18NString("accounts").getText(); - } - - /** - * Returns the icon of this configuration form. - * @return the icon of this configuration form. - */ - public byte[] getIcon() { - return ImageLoader.getImageInBytes( - ImageLoader.ACCOUNT_ICON); - } - - /** - * Returns the form of this configuration form. - * @return the form of this configuration form. - */ - public Object getForm() { - return this; - } - - /** - * Handles the <tt>ActionEvent</tt> triggered when user clicks on - * on the buttons. Shows the account registration wizard when user - * clicks on "New". - * - * @param evt the action event that has just occurred. - */ - public void actionPerformed(ActionEvent evt) { - JButton sourceButton = (JButton)evt.getSource(); - - if (sourceButton.equals(newButton)) { - AccountRegWizardContainerImpl wizard - = (AccountRegWizardContainerImpl)GuiActivator.getUIService() - .getAccountRegWizardContainer(); - - wizard.setTitle( - Messages.getI18NString("accountRegistrationWizard").getText()); - - wizard.newAccount(); - - wizard.showDialog(false); - } - else if (sourceButton.equals(modifyButton)) { - - if(accountsTable.getSelectedRow() != -1) { - AccountRegWizardContainerImpl wizard - = (AccountRegWizardContainerImpl)GuiActivator.getUIService() - .getAccountRegWizardContainer(); - - wizard.setTitle( - Messages.getI18NString("accountRegistrationWizard") - .getText()); - - ProtocolProviderService protocolProvider - = (ProtocolProviderService)tableModel.getValueAt( - accountsTable.getSelectedRow(), 0); - - wizard.modifyAccount(protocolProvider); - wizard.showDialog(false); - } - } - else if(sourceButton.equals(removeButton)){ - - if(accountsTable.getSelectedRow() != -1) { - mainFrame.getLoginManager().setManuallyDisconnected(true); - - ProtocolProviderService protocolProvider - = (ProtocolProviderService)tableModel.getValueAt( - accountsTable.getSelectedRow(), 0); - - ProtocolProviderFactory providerFactory - = GuiActivator.getProtocolProviderFactory(protocolProvider); - - if(providerFactory != null) { - int result = JOptionPane.showConfirmDialog(this, - Messages.getI18NString("removeAccountMessage").getText(), - Messages.getI18NString("removeAccount").getText(), - JOptionPane.YES_NO_CANCEL_OPTION); - - if(result == JOptionPane.YES_OPTION) { - ConfigurationService configService - = GuiActivator.getConfigurationService(); - - String prefix - = "net.java.sip.communicator.impl.gui.accounts"; - - List accounts = configService - .getPropertyNamesByPrefix(prefix, true); - - Iterator accountsIter = accounts.iterator(); - - while(accountsIter.hasNext()) { - - String accountRootPropName - = (String) accountsIter.next(); - - String accountUID - = configService.getString(accountRootPropName); - - if(accountUID.equals(protocolProvider - .getAccountID().getAccountUniqueID())) { - - configService.setProperty( - accountRootPropName, - null); - break; - } - } - providerFactory.uninstallAccount( - protocolProvider.getAccountID()); - } - } - } - } - } - - - /** - * Implements the <tt>ServiceListener</tt> method. Verifies whether the - * passed event concerns a <tt>ProtocolProviderService</tt> and adds the - * corresponding UI controls. - * - * @param event The <tt>ServiceEvent</tt> object. - */ - public void serviceChanged(ServiceEvent event) - { - //if the event is caused by a bundle being stopped, we don't want to - //know - if(event.getServiceReference().getBundle().getState() - == Bundle.STOPPING) - { - return; - } - Object sourceService = GuiActivator.bundleContext - .getService(event.getServiceReference()); - - // we don't care if the source service is not a protocol provider - if (! (sourceService instanceof ProtocolProviderService)) { - return; - } - - ProtocolProviderService pps = (ProtocolProviderService) sourceService; - - if (event.getType() == ServiceEvent.REGISTERED) - { - String pName = pps.getProtocolDisplayName(); - - Image protocolImage = null; - try - { - protocolImage = ImageIO.read( - new ByteArrayInputStream(pps.getProtocolIcon() - .getIcon(ProtocolIcon.ICON_SIZE_16x16))); - } - catch (IOException e) - { - logger.error("Could not read image.", e); - } - - JLabel protocolLabel = new JLabel(); - protocolLabel.setText(pName); - protocolLabel.setIcon(new ImageIcon(protocolImage)); - - tableModel.addRow(new Object[]{pps, protocolLabel, - pps.getAccountID().getUserID()}); - } - else if (event.getType() == ServiceEvent.UNREGISTERING) - { - ProtocolProviderFactory sourceFactory = null; - - ServiceReference[] allBundleServices - = event.getServiceReference().getBundle() - .getRegisteredServices(); - - for (int i = 0; i < allBundleServices.length; i++) - { - Object service = GuiActivator.bundleContext - .getService(allBundleServices[i]); - - if(service instanceof ProtocolProviderFactory) - { - sourceFactory = (ProtocolProviderFactory) service; - break; - } - } - - tableModel.removeRow(tableModel.rowIndexOf(pps)); - } - } - - public int getIndex() - { - return 1; - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java index 6fc4017..9b31bca 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java @@ -15,6 +15,7 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; +import net.java.sip.communicator.impl.gui.main.account.*; import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.*; @@ -42,10 +43,6 @@ public class ConfigurationFrame private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - private I18NString closeString = Messages.getI18NString("close"); - - private JButton closeButton = new JButton(closeString.getText()); - private MainFrame mainFrame; /** @@ -73,18 +70,6 @@ public class ConfigurationFrame this.mainPanel.add(configList, BorderLayout.WEST); - this.buttonsPanel.add(closeButton); - - this.closeButton.setMnemonic(closeString.getMnemonic()); - - this.closeButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Constants.BORDER_COLOR)); @@ -140,8 +125,6 @@ public class ConfigurationFrame this.configList.setSelectedIndex(0); super.setVisible(true); - - this.closeButton.requestFocus(); } else super.setVisible(false); @@ -174,7 +157,6 @@ public class ConfigurationFrame */ protected void close(boolean isEscaped) { - this.closeButton.doClick(); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage1.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage1.java index 4891d77..bc0c360 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage1.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage1.java @@ -105,7 +105,7 @@ public class AddContactWizardPage1 public void pageShown() { } - public void pageNext() { + public void commitPage() { selectAccountPanel.setSelectedAccounts(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage2.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage2.java index c4623a1..671dd82 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage2.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage2.java @@ -116,7 +116,7 @@ public class AddContactWizardPage2 { } - public void pageNext() + public void commitPage() { this.newContact.setGroup(selectGroupPanel.getSelectedGroup()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage3.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage3.java index 7f2f9e8..9fe6230 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage3.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardPage3.java @@ -75,7 +75,7 @@ public class AddContactWizardPage3 implements WizardPage { this.addContactPanel.setNextFinishButtonAccordingToUIN(); } - public void pageNext() { + public void commitPage() { } public void pageBack() { diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java index 5dda889..8b19522 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java @@ -228,10 +228,10 @@ public class ProtocolProviderServiceIrcImpl } if(accountProperties - .get(ProtocolProviderFactory.PASSWORD_REQUIRED) != null) + .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED) != null) { - passwordRequired = new Boolean((String)accountProperties - .get(ProtocolProviderFactory.PASSWORD_REQUIRED)) + passwordRequired = new Boolean((String) accountProperties + .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED)) .booleanValue(); } diff --git a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java index 0b6c941..672f1ca 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java @@ -526,7 +526,7 @@ public class SystrayServiceJdicImpl try { if(toChangeDockIcon != null) - { + { Dock.setDockTileImage(toChangeDockIcon); } else |