From 2e83c45aa27145fe587fceae1dfa3f1ac2f77046 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Sat, 20 Dec 2008 00:08:53 +0000 Subject: - Delays the creation of the Options dialog and the loading of the ConfigurationForm implementations (which get listed in the Options dialog). - Spares a couple of ImageIcon allocations. - Removes unused fields and fixes raw-type warnings in the files touched by the other changes. --- .../sip/communicator/impl/gui/UIServiceImpl.java | 10 +- .../impl/gui/customcontrols/FramedImage.java | 61 +-- .../main/account/AccountsConfigurationForm.java | 65 --- .../impl/gui/main/call/ReceivedCallDialog.java | 6 +- .../main/chat/toolBars/ExtendedMainToolBar.java | 5 +- .../impl/gui/main/chat/toolBars/MainToolBar.java | 8 +- .../gui/main/configforms/ConfigFormDescriptor.java | 20 +- .../impl/gui/main/configforms/ConfigFormList.java | 5 +- .../gui/main/configforms/ConfigurationFrame.java | 98 +---- .../impl/gui/main/contactlist/ActionMenuPanel.java | 5 +- .../impl/gui/main/menus/ExtendedQuickMenu.java | 51 +-- .../impl/gui/main/menus/ToolsMenu.java | 10 +- .../communicator/impl/gui/utils/ImageLoader.java | 25 +- .../communicator/impl/media/MediaActivator.java | 7 +- .../impl/media/MediaConfigurationForm.java | 33 -- .../impl/media/codec/EncodingConfiguration.java | 2 +- .../impl/notification/NotificationActivator.java | 17 +- .../impl/notification/NotificationServiceImpl.java | 99 ++--- .../impl/protocol/ssh/SSHContactInfo.java | 20 +- .../impl/systray/jdic/TrayMenuFactory.java | 6 +- .../plugin/accountinfo/AccountInfoActivator.java | 31 +- .../plugin/accountinfo/AccountInfoForm.java | 158 ------- .../plugin/accountinfo/AccountInfoPanel.java | 103 +++++ .../plugin/autoaway/AutoAwayActivator.java | 15 +- .../plugin/autoaway/AutoAwayConfigForm.java | 196 --------- .../autoaway/AutoAwayConfigurationPanel.java | 156 +++++++ .../contactinfo/ContactInfoDetailsPanel.java | 9 +- .../GeneralConfigPluginActivator.java | 14 +- .../generalconfig/GeneralConfigurationForm.java | 457 --------------------- .../generalconfig/GeneralConfigurationPanel.java | 435 ++++++++++++++++++++ .../KeybindingChooserActivator.java | 10 +- .../keybindingchooser/KeybindingsConfigForm.java | 45 -- .../plugin/mailbox/MailboxActivator.java | 15 +- .../plugin/mailbox/MailboxConfigurationForm.java | 255 ------------ .../plugin/mailbox/MailboxConfigurationPanel.java | 222 ++++++++++ .../NotificationConfigurationActivator.java | 13 +- .../NotificationConfigurationForm.java | 57 --- .../NotificationConfigurationPanel.java | 2 - .../pluginmanager/PluginManagerActivator.java | 12 +- .../pluginmanager/PluginManagerConfigForm.java | 46 --- .../InitialAccountRegistrationFrame.java | 98 ++--- .../service/gui/AbstractConfigurationForm.java | 45 -- .../communicator/service/gui/ExportedWindow.java | 3 - .../service/gui/LazyConfigurationForm.java | 114 +++++ .../sip/communicator/service/gui/UIService.java | 2 + .../sip/communicator/service/gui/gui.manifest.mf | 3 + .../service/gui/internal/GuiServiceActivator.java | 33 ++ src/net/java/sip/communicator/util/ImageUtils.java | 50 ++- 48 files changed, 1340 insertions(+), 1812 deletions(-) delete mode 100644 src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationForm.java delete mode 100644 src/net/java/sip/communicator/impl/media/MediaConfigurationForm.java delete mode 100644 src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java create mode 100644 src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java delete mode 100644 src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigForm.java create mode 100644 src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigurationPanel.java delete mode 100644 src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java create mode 100644 src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java delete mode 100644 src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigForm.java delete mode 100644 src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationForm.java create mode 100644 src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationPanel.java delete mode 100644 src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationForm.java delete mode 100644 src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerConfigForm.java delete mode 100644 src/net/java/sip/communicator/service/gui/AbstractConfigurationForm.java create mode 100644 src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java create mode 100644 src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java (limited to 'src/net') diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index fa88287..cd4d0d0 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -130,8 +130,6 @@ public class UIServiceImpl this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame); - this.configurationFrame = new ConfigurationFrame(mainFrame); - if (ConfigurationManager.isTransparentWindowEnabled()) { try @@ -385,7 +383,6 @@ public class UIServiceImpl */ public void initExportedWindows() { - registerExportedWindow(configurationFrame); registerExportedWindow(new AddContactWizardExportedWindow(mainFrame)); } @@ -984,4 +981,11 @@ public class UIServiceImpl } } } + + public void setConfigurationWindowVisible(boolean visible) + { + if (configurationFrame == null) + configurationFrame = new ConfigurationFrame(mainFrame); + configurationFrame.setVisible(visible); + } } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/FramedImage.java b/src/net/java/sip/communicator/impl/gui/customcontrols/FramedImage.java index b9f5a30..ddce652 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/FramedImage.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/FramedImage.java @@ -22,15 +22,15 @@ import net.java.sip.communicator.util.*; public class FramedImage extends JComponent { - private ImageIcon shadowIcon; + private final Image shadowImage; - private ImageIcon frameIcon; + private final Image frameImage; - private ImageIcon imageIcon; + private Image image; - private int width; + private final int width; - private int height; + private final int height; /** * Creates a ContactPhotoLabel by specifying the width and the height of the @@ -42,27 +42,17 @@ public class FramedImage */ public FramedImage(ImageIcon imageIcon, int width, int height) { - super(); - this.width = width; - this.height = height; this.setPreferredSize(new Dimension(width, height)); - Image photoFrameImage - = ImageLoader.getImage(ImageLoader.USER_PHOTO_FRAME); - - this.frameIcon - = ImageUtils.scaleIconWithinBounds( photoFrameImage, - width, - height); - - this.shadowIcon - = ImageUtils.scaleIconWithinBounds( - ImageLoader.getImage(ImageLoader.USER_PHOTO_SHADOW), - width, - height); + this.frameImage = + ImageUtils.scaleImageWithinBounds(ImageLoader + .getImage(ImageLoader.USER_PHOTO_FRAME), width, height); + this.shadowImage = + ImageUtils.scaleImageWithinBounds(ImageLoader + .getImage(ImageLoader.USER_PHOTO_SHADOW), width, height); if (imageIcon != null) { @@ -75,34 +65,25 @@ public class FramedImage this(null, width, height); } - public ImageIcon getImageIcon() - { - return imageIcon; - } - public void setImageIcon(ImageIcon imageIcon) { - this.imageIcon - = ImageUtils.getScaledRoundedImage( imageIcon.getImage(), - width - 2, - height - 2); + this.image = + ImageUtils.getScaledRoundedImage(imageIcon.getImage(), width - 2, + height - 2); } - /** + /* * Overrides {@link JComponent#paintComponent(Graphics)}. */ public void paintComponent(Graphics g) { - g.drawImage(imageIcon.getImage(), - width/2 - imageIcon.getIconWidth()/2, - height/2 - imageIcon.getIconHeight()/2, null); + g.drawImage(image, width / 2 - image.getWidth(null) / 2, height / 2 + - image.getHeight(null) / 2, null); - g.drawImage(frameIcon.getImage(), - width/2 - frameIcon.getIconWidth()/2, - height/2 - frameIcon.getIconHeight()/2, null); + g.drawImage(frameImage, width / 2 - frameImage.getWidth(null) / 2, + height / 2 - frameImage.getHeight(null) / 2, null); - g.drawImage(shadowIcon.getImage(), - width/2 - shadowIcon.getIconWidth()/2, - 1, null); + g.drawImage(shadowImage, width / 2 - shadowImage.getWidth(null) / 2, 1, + null); } } 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 deleted file mode 100644 index 4cfaaa1..0000000 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationForm.java +++ /dev/null @@ -1,65 +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.account; - -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.gui.*; - -/** - * The AccountsConfigurationForm is the form where the user could - * create, modify or delete an account. - * - * @author Yana Stamcheva - */ -public class AccountsConfigurationForm - extends AbstractConfigurationForm -{ - private Object form; - - /** - * Returns the form of this configuration form. - * - * @return the form of this configuration form. - */ - public Object getForm() - { - if (form == null) - form = super.getForm(); - return form; - } - - protected String getFormClassName() - { - return "net.java.sip.communicator.impl.gui.main.account.AccountsConfigurationPanel"; - } - - /** - * Returns the icon of this configuration form. - * - * @return the icon of this configuration form. - */ - public byte[] getIcon() - { - return ImageLoader.getImageInBytes(ImageLoader.ACCOUNT_ICON); - } - - public int getIndex() - { - return 1; - } - - /** - * Returns the title of this configuration form. - * - * @return the title of this configuration form. - */ - public String getTitle() - { - return GuiActivator.getResources() - .getI18NString("service.gui.ACCOUNTS"); - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java index 5ceb010..7e0c18c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/ReceivedCallDialog.java @@ -129,9 +129,9 @@ public class ReceivedCallDialog boolean hasMoreParticipants = false; String text = ""; - ImageIcon imageIcon = ImageUtils.getScaledRoundedImage( - ImageLoader.getImage(ImageLoader.DEFAULT_USER_PHOTO), - 40, 45); + ImageIcon imageIcon = + ImageUtils.getScaledRoundedIcon(ImageLoader + .getImage(ImageLoader.DEFAULT_USER_PHOTO), 40, 45); while (participantsIter.hasNext()) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java index 22a053f..524c5d3 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java @@ -492,10 +492,7 @@ public class ExtendedMainToolBar } else if (buttonText.equalsIgnoreCase("settings")) { - ExportedWindow configDialog = GuiActivator.getUIService() - .getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); - - configDialog.setVisible(true); + GuiActivator.getUIService().setConfigurationWindowVisible(true); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 614236b..2634e67 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -20,7 +20,6 @@ import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; -import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; @@ -58,8 +57,6 @@ public class MainToolBar private ChatWindow messageWindow; - private Contact currentChatContact = null; - /** * Empty constructor to be used from inheritors. */ @@ -192,10 +189,7 @@ public class MainToolBar } else if (buttonText.equals("options")) { - ExportedWindow optionsDialog = GuiActivator.getUIService() - .getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); - - optionsDialog.setVisible(true); + GuiActivator.getUIService().setConfigurationWindowVisible(true); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java index 795d067..88d7506 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java @@ -29,7 +29,9 @@ public class ConfigFormDescriptor private final ConfigurationForm configForm; private ImageIcon configFormIcon; - + + private Component configFormPanel; + private String configFormTitle; /** @@ -76,14 +78,18 @@ public class ConfigFormDescriptor */ public Component getConfigFormPanel() { - Object form = configForm.getForm(); - if ((form instanceof Component) == false) + if (configFormPanel == null) { - throw new ClassCastException("ConfigurationFrame :" - + form.getClass() - + " is not a class supported by this ui implementation"); + Object form = configForm.getForm(); + if ((form instanceof Component) == false) + { + throw new ClassCastException("ConfigurationFrame :" + + form.getClass() + + " is not a class supported by this ui implementation"); + } + configFormPanel = (Component) form; } - return (Component) form; + return configFormPanel; } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java index fa7e6ea..aefcbaf 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java @@ -4,7 +4,6 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.impl.gui.main.configforms; import javax.swing.*; @@ -22,9 +21,9 @@ public class ConfigFormList extends JList implements ListSelectionListener { - private DefaultListModel listModel = new DefaultListModel(); + private final DefaultListModel listModel = new DefaultListModel(); - private ConfigurationFrame configFrame; + private final ConfigurationFrame configFrame; /** * Creates an instance of ConfigFormList 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 96c375f..3f6f5b9 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 @@ -12,7 +12,6 @@ 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.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.*; @@ -27,24 +26,16 @@ import org.osgi.framework.*; */ public class ConfigurationFrame extends SIPCommDialog - implements ExportedWindow, ServiceListener + implements ServiceListener { - private Logger logger = Logger.getLogger(ConfigurationFrame.class); + private final Logger logger = Logger.getLogger(ConfigurationFrame.class); - private ConfigFormList configList; + private final ConfigFormList configList; - private SCScrollPane configScrollList; + private final TitlePanel titlePanel = new TitlePanel(); - private TitlePanel titlePanel = new TitlePanel(); - - private TransparentPanel mainPanel - = new TransparentPanel(new BorderLayout(5, 5)); - - private TransparentPanel centerPanel - = new TransparentPanel(new BorderLayout(5, 5)); - - private TransparentPanel buttonsPanel - = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); + private final JPanel centerPanel = + new TransparentPanel(new BorderLayout(5, 5)); /** * Creates an instance of ConfigurationManagerImpl. @@ -55,14 +46,18 @@ public class ConfigurationFrame { super(mainFrame); + JPanel mainPanel = new TransparentPanel(new BorderLayout(5, 5)); + JPanel buttonsPanel = + new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); + this.configList = new ConfigFormList(this); - this.configScrollList = new SCScrollPane(); + SCScrollPane configScrollList = new SCScrollPane(); - this.configScrollList.setHorizontalScrollBarPolicy( + configScrollList.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - this.configScrollList.setViewportView(configList); + configScrollList.setViewportView(configList); this.setTitle(GuiActivator.getResources() .getI18NString("service.gui.SETTINGS")); @@ -71,16 +66,16 @@ public class ConfigurationFrame this.addDefaultForms(); - this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - this.mainPanel.add(centerPanel, BorderLayout.CENTER); + mainPanel.add(centerPanel, BorderLayout.CENTER); - this.mainPanel.add(configScrollList, BorderLayout.WEST); + mainPanel.add(configScrollList, BorderLayout.WEST); buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Constants.BORDER_COLOR)); - this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); + mainPanel.add(buttonsPanel, BorderLayout.SOUTH); this.getContentPane().add(mainPanel); @@ -116,7 +111,11 @@ public class ConfigurationFrame */ public void addDefaultForms() { - this.addConfigurationForm(new AccountsConfigurationForm()); + this + .addConfigurationForm(new LazyConfigurationForm( + "net.java.sip.communicator.impl.gui.main.account.AccountsConfigurationPanel", + getClass().getClassLoader(), "service.gui.icons.ACCOUNT_ICON", + "service.gui.ACCOUNTS", 1)); } /** @@ -162,24 +161,6 @@ public class ConfigurationFrame } /** - * Implements ApplicationWindow.minimizeWindow method. - * - * @see net.java.sip.communicator.service.gui.ExportedWindow#minimize() - */ - public void minimize() - { - } - - /** - * Implements ApplicationWindow.maximizeWindow method. - * - * @see net.java.sip.communicator.service.gui.ExportedWindow#maximize() - */ - public void maximize() - { - } - - /** * Implements SIPCommFrame.close() method. Performs a click on * the close button. * @@ -191,36 +172,6 @@ public class ConfigurationFrame } /** - * Returns the identifier of this ExportedWindow. - * - * @return a reference to the WindowID instance representing this - * frame. - */ - public WindowID getIdentifier() - { - return ExportedWindow.CONFIGURATION_WINDOW; - } - - /** - * Implements the ExportedWindow.bringToFront method. Brings this - * window to front. - */ - public void bringToFront() - { - this.toFront(); - } - - /** - * The source of the window - * - * @return the source of the window - */ - public Object getSource() - { - return this; - } - - /** * Handles registration of a new configuration form. */ public void serviceChanged(ServiceEvent event) @@ -289,9 +240,4 @@ public class ConfigurationFrame { this.configList.removeConfigForm(configForm); } - - /** - * Implementation of {@link ExportedWindow#setParams(Object[])}. - */ - public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java index 03a2715..ac403e0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java @@ -202,10 +202,7 @@ public class ActionMenuPanel } else if (buttonName.equals("options")) { - ExportedWindow optionsDialog = GuiActivator.getUIService() - .getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); - - optionsDialog.setVisible(true); + GuiActivator.getUIService().setConfigurationWindowVisible(true); } else if (buttonName.equals("showOffline")) { diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java index 98f6259..a67c031 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java @@ -92,15 +92,13 @@ public class ExtendedQuickMenu private MoreButton moreButton = new MoreButton(); - private ExportedWindow configDialog; - private MainFrame mainFrame; - private int movedDownButtons = 0; - - private Hashtable pluginsTable = new Hashtable(); + private final Map pluginsTable = + new Hashtable(); - private LinkedList components = new LinkedList(); + private final java.util.List components = + new LinkedList(); /** * Create an instance of the QuickMenu. @@ -273,17 +271,7 @@ public class ExtendedQuickMenu wizard.setVisible(true); } } - - private class ConfigAction extends AbstractAction - { - public void actionPerformed(ActionEvent arg0) - { - configDialog = GuiActivator.getUIService() - .getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); - configDialog.setVisible(true); - } - } /** * Handles the ActionEvent triggered when user clicks on one of * the buttons in this toolbar. @@ -379,14 +367,14 @@ public class ExtendedQuickMenu */ public void componentMoved(ComponentEvent e) { - int compCount = this.components.size(); - int maxWidth = this.toolBar.getWidth(); int width = 0; - for (int i = 0; i < compCount; i ++) + for (Component component : components) { - JComponent c = (JComponent) this.components.get(i); + if (!(component instanceof JComponent)) + continue; + JComponent c = (JComponent) component; width += c.getWidth() + 10; @@ -420,12 +408,8 @@ public class ExtendedQuickMenu { if((e.getFirstIndex() != -1 || e.getLastIndex() != -1)) { - Enumeration plugins = pluginsTable.keys(); - - while (plugins.hasMoreElements()) + for (PluginComponent plugin : pluginsTable.keySet()) { - PluginComponent plugin = (PluginComponent) plugins.nextElement(); - Object selectedValue = mainFrame.getContactListPanel() .getContactList().getSelectedValue(); @@ -457,8 +441,6 @@ public class ExtendedQuickMenu private class ToolBarButton extends JLabel { - private Image iconImage; - private boolean isMouseOver = false; private boolean isMousePressed = false; @@ -554,10 +536,7 @@ public class ExtendedQuickMenu } else if (buttonName.equals("config")) { - configDialog = GuiActivator.getUIService() - .getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); - - configDialog.setVisible(true); + GuiActivator.getUIService().setConfigurationWindowVisible(true); } else if (buttonName.equals("search")) { @@ -635,12 +614,12 @@ public class ExtendedQuickMenu (MetaContact) selectedValue; OperationSetWebContactInfo wContactInfo = null; - - Iterator protocolContacts = selectedMetaContact.getContacts(); - - while(protocolContacts.hasNext()) + + Iterator protocolContacts = selectedMetaContact.getContacts(); + + while (protocolContacts.hasNext()) { - Contact protoContact = (Contact) protocolContacts.next(); + Contact protoContact = protocolContacts.next(); wContactInfo = mainFrame.getWebContactInfoOpSet( protoContact.getProtocolProvider()); diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java index 6190ecb..50741fd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java @@ -35,10 +35,6 @@ public class ToolsMenu { private final Logger logger = Logger.getLogger(ToolsMenu.class); - private MainFrame parentWindow; - - private ExportedWindow configDialog; - /** * Creates an instance of FileMenu. * @param parentWindow The parent ChatWindow. @@ -114,11 +110,7 @@ public class ToolsMenu void configActionPerformed() { - ExportedWindow configDialog = - GuiActivator.getUIService().getExportedWindow( - ExportedWindow.CONFIGURATION_WINDOW); - - configDialog.setVisible(true); + GuiActivator.getUIService().setConfigurationWindowVisible(true); } public void pluginComponentAdded(PluginComponentEvent event) diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index 17cea7c..ab7ae5e 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -28,12 +28,13 @@ import net.java.sip.communicator.util.*; */ public class ImageLoader { - private static Logger log = Logger.getLogger(ImageLoader.class); + private static final Logger log = Logger.getLogger(ImageLoader.class); /** * Stores all already loaded images. */ - private static Hashtable loadedImages = new Hashtable(); + private static final Map loadedImages = + new Hashtable(); /** * The SIP Communicator logo 16x16 icon. @@ -194,12 +195,6 @@ public class ImageLoader { /** * The icon on the "Add contact" button in the QuickMenu. */ - public static final ImageID ACCOUNT_ICON - = new ImageID("service.gui.icons.ACCOUNT_ICON"); - - /** - * The icon on the "Add contact" button in the QuickMenu. - */ public static final ImageID QUICK_MENU_ADD_ICON = new ImageID("service.gui.icons.QUICK_MENU_ADD_ICON"); @@ -1088,7 +1083,7 @@ public class ImageLoader { if (loadedImages.containsKey(imageID)) { - image = (BufferedImage) loadedImages.get(imageID); + image = loadedImages.get(imageID); } else { @@ -1192,9 +1187,7 @@ public class ImageLoader { */ public static BufferedImage[] getAnimatedImage(byte[] animatedImage) { - Iterator readers = ImageIO.getImageReadersBySuffix("gif"); - - ImageReader reader = (ImageReader) readers.next(); + ImageReader reader = ImageIO.getImageReadersBySuffix("gif").next(); ImageInputStream iis; @@ -1234,14 +1227,10 @@ public class ImageLoader { */ public static String getImagePath(Image image) { - Iterator i = ImageLoader.loadedImages.entrySet().iterator(); - - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - + for (Map.Entry entry : loadedImages.entrySet()) { if (entry.getValue().equals(image)) { - String imageID = ((ImageID) entry.getKey()).getId(); + String imageID = entry.getKey().getId(); try { diff --git a/src/net/java/sip/communicator/impl/media/MediaActivator.java b/src/net/java/sip/communicator/impl/media/MediaActivator.java index 3599aa3..8cdee40 100644 --- a/src/net/java/sip/communicator/impl/media/MediaActivator.java +++ b/src/net/java/sip/communicator/impl/media/MediaActivator.java @@ -8,7 +8,7 @@ package net.java.sip.communicator.impl.media; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.fileaccess.*; -import net.java.sip.communicator.service.gui.ConfigurationForm; +import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.media.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.resources.*; @@ -67,7 +67,10 @@ public class MediaActivator // MediaConfigurationForm context.registerService(ConfigurationForm.class.getName(), - new MediaConfigurationForm(), null); + new LazyConfigurationForm( + "net.java.sip.communicator.impl.media.MediaConfigurationPanel", + getClass().getClassLoader(), "plugin.mediaconfig.PLUGIN_ICON", + "impl.media.configform.TITLE"), null); } /** diff --git a/src/net/java/sip/communicator/impl/media/MediaConfigurationForm.java b/src/net/java/sip/communicator/impl/media/MediaConfigurationForm.java deleted file mode 100644 index b2ce67e..0000000 --- a/src/net/java/sip/communicator/impl/media/MediaConfigurationForm.java +++ /dev/null @@ -1,33 +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.media; - -import net.java.sip.communicator.service.gui.*; - -/** - * @author Lubomir Marinov - */ -public class MediaConfigurationForm - extends AbstractConfigurationForm -{ - protected String getFormClassName() - { - return "net.java.sip.communicator.impl.media.MediaConfigurationPanel"; - } - - public byte[] getIcon() - { - return MediaActivator.getResources().getImageInBytes( - "plugin.mediaconfig.PLUGIN_ICON"); - } - - public String getTitle() - { - return MediaActivator.getResources().getI18NString( - "impl.media.configform.TITLE"); - } -} diff --git a/src/net/java/sip/communicator/impl/media/codec/EncodingConfiguration.java b/src/net/java/sip/communicator/impl/media/codec/EncodingConfiguration.java index f7cc5b5..b2582d1 100644 --- a/src/net/java/sip/communicator/impl/media/codec/EncodingConfiguration.java +++ b/src/net/java/sip/communicator/impl/media/codec/EncodingConfiguration.java @@ -300,7 +300,7 @@ public class EncodingConfiguration .getSupportedOutputFormats(null), PlugInManager.CODEC); logger.debug("Codec : " + className - + " is succsefully registered : " + result); + + " is successfully registered : " + result); } catch (Throwable ex) { diff --git a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java index 45095ae..a98ca6b 100644 --- a/src/net/java/sip/communicator/impl/notification/NotificationActivator.java +++ b/src/net/java/sip/communicator/impl/notification/NotificationActivator.java @@ -23,13 +23,11 @@ import org.osgi.framework.*; public class NotificationActivator implements BundleActivator { - private Logger logger = Logger.getLogger(NotificationActivator.class); - + private final Logger logger = Logger.getLogger(NotificationActivator.class); + private static BundleContext bundleContext; private static ConfigurationService configService; - - private NotificationServiceImpl notificationService; private static AudioNotifierService audioNotifierService; @@ -41,15 +39,14 @@ public class NotificationActivator try { // Create the notification service implementation - this.notificationService = new NotificationServiceImpl(); + NotificationService notificationService = + new NotificationServiceImpl(); logger.info("Notification Service...[ STARTED ]"); - bundleContext.registerService( - NotificationService.class.getName(), - this.notificationService, - null); - + bundleContext.registerService(NotificationService.class.getName(), + notificationService, null); + logger.info("Notification Service ...[REGISTERED]"); logger.logEntry(); diff --git a/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java b/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java index d968cf7..d93e387 100644 --- a/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/notification/NotificationServiceImpl.java @@ -25,7 +25,7 @@ public class NotificationServiceImpl private final Logger logger = Logger.getLogger(NotificationServiceImpl.class); - private static String NOTIFICATIONS_PREFIX = + private static final String NOTIFICATIONS_PREFIX = "net.java.sip.communicator.impl.notifications"; /** @@ -37,23 +37,24 @@ public class NotificationServiceImpl /** * A set of all registered event notifications. */ - private Hashtable defaultNotificationsTable = new Hashtable(); + private final Map defaultNotificationsTable = + new Hashtable(); /** * A list of all registered NotificationChangeListeners. */ - private Vector changeListeners = new Vector(); - - private ConfigurationService configService = null; + private final List changeListeners = + new Vector(); + private final ConfigurationService configService = + NotificationActivator.getConfigurationService(); + /** * Creates an instance of NotificationServiceImpl by loading all * previously saved notifications. */ public NotificationServiceImpl() { - configService = NotificationActivator.getConfigurationService(); - // Load all previously saved notifications. this.loadNotifications(); } @@ -753,13 +754,9 @@ public class NotificationServiceImpl NotificationEventTypeEvent event = new NotificationEventTypeEvent(this, eventType, sourceEventType); - - NotificationChangeListener listener; - - for (int i = 0 ; i < changeListeners.size(); i ++) + + for (NotificationChangeListener listener : changeListeners) { - listener = (NotificationChangeListener) changeListeners.get(i); - if (eventType.equals(NotificationEventTypeEvent.EVENT_TYPE_ADDED)) { listener.eventTypeAdded(event); @@ -911,29 +908,17 @@ public class NotificationServiceImpl // We fire the appropriate event depending on whether this is an // already existing actionType or a new one. - if (!isNew) - { - fireNotificationActionTypeEvent( - NotificationActionTypeEvent.ACTION_CHANGED, - eventType, - actionType, - handler); - } - else - { - fireNotificationActionTypeEvent( - NotificationActionTypeEvent.ACTION_ADDED, - eventType, - actionType, - handler); - } + fireNotificationActionTypeEvent( + isNew ? NotificationActionTypeEvent.ACTION_ADDED + : NotificationActionTypeEvent.ACTION_CHANGED, eventType, + actionType, handler); } // now store this default events if we want to retore them EventNotification notification = null; if(defaultNotificationsTable.containsKey(eventType)) - notification = (EventNotification) defaultNotificationsTable.get(eventType); + notification = defaultNotificationsTable.get(eventType); else { notification = new EventNotification(eventType); @@ -1016,29 +1001,17 @@ public class NotificationServiceImpl // We fire the appropriate event depending on whether this is an // already existing actionType or a new one. - if (!isNew) - { - fireNotificationActionTypeEvent( - NotificationActionTypeEvent.ACTION_CHANGED, - eventType, - actionType, - handler); - } - else - { - fireNotificationActionTypeEvent( - NotificationActionTypeEvent.ACTION_ADDED, - eventType, - actionType, - handler); - } + fireNotificationActionTypeEvent( + isNew ? NotificationActionTypeEvent.ACTION_ADDED + : NotificationActionTypeEvent.ACTION_CHANGED, eventType, + actionType, handler); } - // now store this default events if we want to retore them + // now store this default events if we want to restore them EventNotification notification = null; if(defaultNotificationsTable.containsKey(eventType)) - notification = (EventNotification) defaultNotificationsTable.get(eventType); + notification = defaultNotificationsTable.get(eventType); else { notification = new EventNotification(eventType); @@ -1075,16 +1048,14 @@ public class NotificationServiceImpl */ public void restoreDefaults() { - Iterator iter = - ((Hashtable)notificationsTable.clone()).keySet().iterator(); - - while (iter.hasNext()) + Set eventTypes = + ((Hashtable) notificationsTable.clone()) + .keySet(); + + for (String eventType : eventTypes) { - String eventType = (String)iter.next(); - - EventNotification notification - = (EventNotification) notificationsTable.get(eventType); - + EventNotification notification = notificationsTable.get(eventType); + Vector actionsToRemove = new Vector(notification.getActions().keySet()); Iterator actionIter = actionsToRemove.iterator(); while (actionIter.hasNext()) @@ -1096,16 +1067,12 @@ public class NotificationServiceImpl removeEventNotification(eventType); } - - iter = defaultNotificationsTable.keySet().iterator(); - - while (iter.hasNext()) + + for (Map.Entry entry : defaultNotificationsTable.entrySet()) { - String eventType = (String)iter.next(); - - EventNotification notification - = (EventNotification) defaultNotificationsTable.get(eventType); - + String eventType = entry.getKey(); + EventNotification notification = entry.getValue(); + Iterator actionIter = notification.getActions().keySet().iterator(); while (actionIter.hasNext()) { diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java index 7fcd1b1..0e38a3a 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHContactInfo.java @@ -18,15 +18,12 @@ import java.text.ParseException; import javax.swing.*; import javax.swing.text.*; -import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.util.swing.*; /** - * * @author Shobhit Jindal */ -class SSHContactInfo extends SIPCommDialog - implements ConfigurationForm { +class SSHContactInfo extends SIPCommDialog { private ContactSSH sshContact; private JPanel mainPanel = new TransparentPanel(); @@ -210,15 +207,7 @@ class SSHContactInfo extends SIPCommDialog public byte[] getIcon() { return Resources.getImage(Resources.SSH_LOGO); } - - /** - * Return the main panel - * - * @return the main panel - */ - public Object getForm() { - return mainPanel; - } + // // public void setContactGroup(ContactGroup contactGroup) // { @@ -338,11 +327,6 @@ class SSHContactInfo extends SIPCommDialog this.portField.setText(port); } - public int getIndex() - { - return -1; - } - protected void close(boolean isEscaped) { } diff --git a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java index 94b7ce1..249cbea 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java @@ -47,11 +47,7 @@ public final class TrayMenuFactory if (itemName.equals("settings")) { - ExportedWindow configWindow = - SystrayActivator.getUIService().getExportedWindow( - ExportedWindow.CONFIGURATION_WINDOW); - - configWindow.setVisible(true); + SystrayActivator.getUIService().setConfigurationWindowVisible(true); } else if (itemName.equals("service.gui.CLOSE")) { diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java index 814f727..acb2ed0 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java +++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java @@ -4,16 +4,13 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.accountinfo; -import java.util.Hashtable; -import java.util.Map; +import java.util.*; import net.java.sip.communicator.service.browserlauncher.*; -import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.util.Logger; +import net.java.sip.communicator.util.*; import org.osgi.framework.*; @@ -25,27 +22,21 @@ import org.osgi.framework.*; public class AccountInfoActivator implements BundleActivator { - private static Logger logger = - Logger.getLogger(AccountInfoActivator.class.getName()); + private static final Logger logger = + Logger.getLogger(AccountInfoActivator.class); public static BundleContext bundleContext; - private static Map providerFactoriesMap = new Hashtable(); - private static BrowserLauncherService browserLauncherService; public void start(BundleContext bc) throws Exception { AccountInfoActivator.bundleContext = bc; - ServiceReference uiServiceRef = - bc.getServiceReference(UIService.class.getName()); - - UIService uiService = (UIService) bc.getService(uiServiceRef); - - ExportedWindow configWindow - = uiService.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW); -// configWindow.addConfigurationForm(new AccountInfoForm()); +// new LazyConfigurationForm( +// "net.java.sip.communicator.plugin.accountinfo.AccountInfoPanel", +// getClass().getClassLoader(), "plugin.accountinfo.PLUGIN_ICON", +// "plugin.accountinfo.TITLE"); } public void stop(BundleContext bc) throws Exception @@ -59,8 +50,10 @@ public class AccountInfoActivator * @return all ProtocolProviderFactorys obtained from the bundle * context */ - public static Map getProtocolProviderFactories() + public static Map getProtocolProviderFactories() { + Map providerFactoriesMap = + new Hashtable(); ServiceReference[] serRefs = null; try @@ -105,4 +98,4 @@ public class AccountInfoActivator return browserLauncherService; } -} \ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java deleted file mode 100644 index 8b0bee9..0000000 --- a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java +++ /dev/null @@ -1,158 +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.plugin.accountinfo; - -import java.awt.*; -import java.util.*; - -import javax.swing.*; - -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.swing.*; - -import org.osgi.framework.*; - -/** - * A GUI plug-in for SIP Communicator that will allow users to set cross - * protocol account information. - * - * @author Adam Goldstein - */ -public class AccountInfoForm - extends TransparentPanel - implements ConfigurationForm -{ - /** - * The right side of the AccountInfo frame that contains protocol specific - * account details. - */ - private AccountDetailsPanel detailsPanel; - - private JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false); - - private Hashtable - accountsTable = new Hashtable(); - - /** - * Constructs a frame with an AccuontInfoAccountPanel to display all - * registered accounts on the left, and an information interface, - * AccountDetailsPanel, on the right. - * - * @param metaContact - */ - public AccountInfoForm() - { - super(new BorderLayout()); - - Set set = AccountInfoActivator.getProtocolProviderFactories().entrySet(); - Iterator iter = set.iterator(); - - boolean hasRegisteredAccounts = false; - - 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 - .getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; - - if(!isHidden) - hasRegisteredAccounts = true; - - serRef = providerFactory.getProviderForAccount(accountID); - - protocolProvider = (ProtocolProviderService) AccountInfoActivator - .bundleContext.getService(serRef); - - detailsPanel = new AccountDetailsPanel(protocolProvider); - - accountsTable.put(protocolProvider, detailsPanel); - - protocolProvider.addRegistrationStateChangeListener( - new RegistrationStateChangeListenerImpl()); - - this.accountsTabbedPane.addTab( - accountID.getUserID(), detailsPanel); - } - } - - this.add(accountsTabbedPane, BorderLayout.CENTER); - } - - /** - * Returns the title of this configuration form. - * - * @return the icon of this configuration form. - */ - public String getTitle() - { - return Resources.getString("plugin.accountinfo.TITLE"); - } - - /** - * Returns the icon of this configuration form. - * - * @return the icon of this configuration form. - */ - public byte[] getIcon() - { - return Resources.getImageInBytes("plugin.accountinfo.PLUGIN_ICON"); - } - - /** - * Returns the form of this configuration form. - * - * @return the form of this configuration form. - */ - public Object getForm() - { - return this; - } - - private class RegistrationStateChangeListenerImpl - implements RegistrationStateChangeListener - { - public void registrationStateChanged(RegistrationStateChangeEvent evt) - { - ProtocolProviderService protocolProvider = evt.getProvider(); - - if (protocolProvider.getOperationSet( - OperationSetServerStoredAccountInfo.class) != null - && evt.getNewState() == RegistrationState.REGISTERED) - { - if (accountsTable.containsKey(protocolProvider)) - { - AccountDetailsPanel detailsPanel - = accountsTable.get(protocolProvider); - - if(!detailsPanel.isDataLoaded()) - detailsPanel.loadDetails(); - } - } - } - } - - public int getIndex() - { - return -1; - } -} \ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java new file mode 100644 index 0000000..02e4b0a --- /dev/null +++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java @@ -0,0 +1,103 @@ +/* + * 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.plugin.accountinfo; + +import java.awt.*; +import java.util.*; + +import javax.swing.*; + +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.event.*; +import net.java.sip.communicator.util.swing.*; + +import org.osgi.framework.*; + +/** + * A GUI plug-in for SIP Communicator that will allow users to set cross + * protocol account information. + * + * @author Adam Goldstein + */ +public class AccountInfoPanel + extends TransparentPanel +{ + /** + * The right side of the AccountInfo frame that contains protocol specific + * account details. + */ + private AccountDetailsPanel detailsPanel; + + private final Map accountsTable = + new Hashtable(); + + /** + * Constructs a frame with an AccuontInfoAccountPanel to display all + * registered accounts on the left, and an information interface, + * AccountDetailsPanel, on the right. + * + * @param metaContact + */ + public AccountInfoPanel() + { + super(new BorderLayout()); + + JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false); + + for (ProtocolProviderFactory providerFactory : AccountInfoActivator + .getProtocolProviderFactories().values()) + { + ArrayList accountsList = + providerFactory.getRegisteredAccounts(); + + ServiceReference serRef; + ProtocolProviderService protocolProvider; + + for (AccountID accountID : accountsList) + { + serRef = providerFactory.getProviderForAccount(accountID); + + protocolProvider = (ProtocolProviderService) AccountInfoActivator + .bundleContext.getService(serRef); + + detailsPanel = new AccountDetailsPanel(protocolProvider); + + accountsTable.put(protocolProvider, detailsPanel); + + protocolProvider.addRegistrationStateChangeListener( + new RegistrationStateChangeListenerImpl()); + + accountsTabbedPane.addTab( + accountID.getUserID(), detailsPanel); + } + } + + this.add(accountsTabbedPane, BorderLayout.CENTER); + } + + private class RegistrationStateChangeListenerImpl + implements RegistrationStateChangeListener + { + public void registrationStateChanged(RegistrationStateChangeEvent evt) + { + ProtocolProviderService protocolProvider = evt.getProvider(); + + if (protocolProvider.getOperationSet( + OperationSetServerStoredAccountInfo.class) != null + && evt.getNewState() == RegistrationState.REGISTERED) + { + if (accountsTable.containsKey(protocolProvider)) + { + AccountDetailsPanel detailsPanel + = accountsTable.get(protocolProvider); + + if(!detailsPanel.isDataLoaded()) + detailsPanel.loadDetails(); + } + } + } + } +} diff --git a/src/net/java/sip/communicator/plugin/autoaway/AutoAwayActivator.java b/src/net/java/sip/communicator/plugin/autoaway/AutoAwayActivator.java index 0fb670b..721acb8 100644 --- a/src/net/java/sip/communicator/plugin/autoaway/AutoAwayActivator.java +++ b/src/net/java/sip/communicator/plugin/autoaway/AutoAwayActivator.java @@ -44,15 +44,16 @@ public class AutoAwayActivator implements BundleActivator public void start(BundleContext bc) throws Exception { bundleContext = bc; - - // Set config form - AutoAwayConfigForm statusCF = new AutoAwayConfigForm(); - bundleContext.registerService(ConfigurationForm.class.getName(), - statusCF, - null); - + bundleContext + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.autoaway.AutoAwayConfigurationPanel", + getClass().getClassLoader(), "plugin.autoaway.PLUGIN_ICON", + "plugin.autoaway.AUTO_STATUS"), null); + new Thread(new Runnable() { diff --git a/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigForm.java b/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigForm.java deleted file mode 100644 index ff0ce14..0000000 --- a/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigForm.java +++ /dev/null @@ -1,196 +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.plugin.autoaway; - -import java.awt.*; -import java.awt.Container; -import java.awt.event.*; - -import javax.swing.*; -import javax.swing.event.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.swing.*; - -/** - * The ConfigurationForm that would be added in the user interface - * configuration window. - * - * @author Damien Roth - */ -public class AutoAwayConfigForm - extends TransparentPanel - implements ConfigurationForm -{ - private JCheckBox enable; - private JSpinner timer; - - /** - * Create an instance of StatusConfigForm - */ - public AutoAwayConfigForm() - { - super(new BorderLayout(10, 10)); - - Component mainPanel = init(); - initValues(); - - this.add(mainPanel); - } - - /** - * Init the widgets - */ - private Component init() - { - JPanel autoStatusPanel = new TransparentPanel(new BorderLayout()); - - // Title : automatic status - JLabel autoStatusLabel - = new JLabel(AutoAwayActivator.getResources() - .getI18NString("plugin.autoaway.AUTO_STATUS")); - - - Font bold = autoStatusLabel.getFont().deriveFont(Font.BOLD); - autoStatusLabel.setFont(bold); - - JPanel fieldsPanel = new TransparentPanel(new BorderLayout(5, 5)); - fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 30, 0, 0)); - - enable = new SIPCommCheckBox(AutoAwayActivator.getResources() - .getI18NString("plugin.autoaway.ENABLE_CHANGE_STATUS")); - - fieldsPanel.add(enable, BorderLayout.NORTH); - enable.addActionListener(new ActionListener() - { - - public void actionPerformed(ActionEvent e) - { - timer.setEnabled(enable.isSelected()); - saveData(); - } - }); - - - JPanel timerPanel = - new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); - // Texte - timerPanel.add(new JLabel( - AutoAwayActivator.getResources() - .getI18NString("plugin.autoaway.AWAY_MINUTES"))); - // Spinner - timer = new JSpinner(new SpinnerNumberModel(15, 1, 180, 1)); - timerPanel.add(timer); - timer.addChangeListener(new ChangeListener() - { - - public void stateChanged(ChangeEvent e) - { - saveData(); - } - }); - - fieldsPanel.add(timerPanel, BorderLayout.WEST); - autoStatusPanel.add(autoStatusLabel, BorderLayout.NORTH); - autoStatusPanel.add(fieldsPanel, BorderLayout.CENTER); - - Container mainPanel = new TransparentPanel(new BorderLayout()); - mainPanel.add(autoStatusPanel, BorderLayout.NORTH); - return mainPanel; - } - - /** - * Init the values of the widgets - */ - private void initValues() - { - ConfigurationService configService - = AutoAwayActivator.getConfigService(); - - String e = (String) configService.getProperty(Preferences.ENABLE); - if (e != null) - { - try - { - this.enable.setSelected(Boolean.parseBoolean(e)); - this.timer.setEnabled(Boolean.parseBoolean(e)); - } catch (NumberFormatException ex) - { - this.enable.setSelected(false); - this.timer.setEnabled(false); - } - } else - { - this.enable.setSelected(false); - this.timer.setEnabled(false); - } - - String t = (String) configService.getString(Preferences.TIMER); - if (t != null) - { - try - { - this.timer.setValue(Integer.parseInt(t)); - } catch (NumberFormatException ex) - { - } - } - } - - /** - * Save data in the configuration file - */ - private void saveData() - { - ConfigurationService configService - = AutoAwayActivator.getConfigService(); - - configService.setProperty(Preferences.ENABLE, - Boolean.toString(enable.isSelected())); - Integer interval = (Integer) timer.getValue(); - configService.setProperty(Preferences.TIMER, interval); - } - - /** - * Implements the ConfigurationForm.getForm() method. Returns the - * component corresponding to this configuration form. - */ - public Object getForm() - { - return this; - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public byte[] getIcon() - { - return AutoAwayActivator.getResources() - .getImageInBytes("plugin.autoaway.PLUGIN_ICON"); - } - - /** - * Implements the ConfigurationForm.getIndex() method. - */ - public int getIndex() - { - return -1; - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public String getTitle() - { - return AutoAwayActivator.getResources() - .getI18NString("plugin.autoaway.AUTO_STATUS"); - } - -} diff --git a/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigurationPanel.java b/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigurationPanel.java new file mode 100644 index 0000000..591de6f --- /dev/null +++ b/src/net/java/sip/communicator/plugin/autoaway/AutoAwayConfigurationPanel.java @@ -0,0 +1,156 @@ +/* + * 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.plugin.autoaway; + +import java.awt.*; +import java.awt.Container; +import java.awt.event.*; + +import javax.swing.*; +import javax.swing.event.*; + +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.util.swing.*; + +/** + * The ConfigurationForm that would be added in the user interface + * configuration window. + * + * @author Damien Roth + */ +public class AutoAwayConfigurationPanel + extends TransparentPanel +{ + private JCheckBox enable; + private JSpinner timer; + + /** + * Create an instance of StatusConfigForm + */ + public AutoAwayConfigurationPanel() + { + super(new BorderLayout(10, 10)); + + Component mainPanel = init(); + initValues(); + + this.add(mainPanel); + } + + /** + * Init the widgets + */ + private Component init() + { + JPanel autoStatusPanel = new TransparentPanel(new BorderLayout()); + + // Title : automatic status + JLabel autoStatusLabel + = new JLabel(AutoAwayActivator.getResources() + .getI18NString("plugin.autoaway.AUTO_STATUS")); + + + Font bold = autoStatusLabel.getFont().deriveFont(Font.BOLD); + autoStatusLabel.setFont(bold); + + JPanel fieldsPanel = new TransparentPanel(new BorderLayout(5, 5)); + fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 30, 0, 0)); + + enable = new SIPCommCheckBox(AutoAwayActivator.getResources() + .getI18NString("plugin.autoaway.ENABLE_CHANGE_STATUS")); + + fieldsPanel.add(enable, BorderLayout.NORTH); + enable.addActionListener(new ActionListener() + { + + public void actionPerformed(ActionEvent e) + { + timer.setEnabled(enable.isSelected()); + saveData(); + } + }); + + + JPanel timerPanel = + new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); + // Texte + timerPanel.add(new JLabel( + AutoAwayActivator.getResources() + .getI18NString("plugin.autoaway.AWAY_MINUTES"))); + // Spinner + timer = new JSpinner(new SpinnerNumberModel(15, 1, 180, 1)); + timerPanel.add(timer); + timer.addChangeListener(new ChangeListener() + { + + public void stateChanged(ChangeEvent e) + { + saveData(); + } + }); + + fieldsPanel.add(timerPanel, BorderLayout.WEST); + autoStatusPanel.add(autoStatusLabel, BorderLayout.NORTH); + autoStatusPanel.add(fieldsPanel, BorderLayout.CENTER); + + Container mainPanel = new TransparentPanel(new BorderLayout()); + mainPanel.add(autoStatusPanel, BorderLayout.NORTH); + return mainPanel; + } + + /** + * Init the values of the widgets + */ + private void initValues() + { + ConfigurationService configService + = AutoAwayActivator.getConfigService(); + + String e = (String) configService.getProperty(Preferences.ENABLE); + if (e != null) + { + try + { + this.enable.setSelected(Boolean.parseBoolean(e)); + this.timer.setEnabled(Boolean.parseBoolean(e)); + } catch (NumberFormatException ex) + { + this.enable.setSelected(false); + this.timer.setEnabled(false); + } + } else + { + this.enable.setSelected(false); + this.timer.setEnabled(false); + } + + String t = (String) configService.getString(Preferences.TIMER); + if (t != null) + { + try + { + this.timer.setValue(Integer.parseInt(t)); + } catch (NumberFormatException ex) + { + } + } + } + + /** + * Save data in the configuration file + */ + private void saveData() + { + ConfigurationService configService + = AutoAwayActivator.getConfigService(); + + configService.setProperty(Preferences.ENABLE, + Boolean.toString(enable.isSelected())); + Integer interval = (Integer) timer.getValue(); + configService.setProperty(Preferences.TIMER, interval); + } +} diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java index 02f3dcf..ad71846 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java @@ -191,11 +191,10 @@ public class ContactInfoDetailsPanel ); } else - scaledImage = ImageUtils.getScaledRoundedImage( - Resources.getImage("service.gui.DEFAULT_USER_PHOTO"), - AVATAR_AREA_WIDTH, - AVATAR_AREA_HEIGHT - ); + scaledImage = + ImageUtils.getScaledRoundedIcon(Resources + .getImage("service.gui.DEFAULT_USER_PHOTO"), + AVATAR_AREA_WIDTH, AVATAR_AREA_HEIGHT); JLabel label = new JLabel(scaledImage); label.setVerticalAlignment(JLabel.CENTER); diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java index 1eeea2d..94f870a 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java @@ -33,12 +33,14 @@ public class GeneralConfigPluginActivator implements BundleActivator ConfigurationManager.loadGuiConfigurations(); - GeneralConfigurationForm preferencesForm - = new GeneralConfigurationForm(); - - bundleContext.registerService( ConfigurationForm.class.getName(), - preferencesForm, - null); + bundleContext + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.generalconfig.GeneralConfigurationPanel", + getClass().getClassLoader(), + "plugin.generalconfig.PLUGIN_ICON", "service.gui.GENERAL", + 0), null); logger.info("PREFERENCES PLUGIN... [REGISTERED]"); } diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java deleted file mode 100644 index 0519d78..0000000 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java +++ /dev/null @@ -1,457 +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.plugin.generalconfig; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; - -import javax.swing.*; -import javax.swing.event.*; - -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.swing.*; - -import com.izforge.izpack.util.os.*; - -/** - * @author Yana Stamcheva - */ -public class GeneralConfigurationForm - extends javax.swing.JPanel - implements ConfigurationForm, - ActionListener -{ - private Logger logger = Logger.getLogger(GeneralConfigurationForm.class); - - private JPanel mainPanel; - private JCheckBox bringToFrontCheckBox; - private JCheckBox autoStartCheckBox; - private JCheckBox groupMessagesCheckBox; - private JCheckBox logHistoryCheckBox; - private JPanel sendMessagePanel; - private JLabel sendMessageLabel; - private JComboBox sendMessageComboBox; - private JLabel historySizeLabel; - private JSpinner historySizeSpinner; - private JCheckBox enableTypingNotifiCheckBox; - private JCheckBox showHistoryCheckBox; - private JPanel logHistoryPanel; - - public GeneralConfigurationForm() - { - super(); - initGUI(); - initDefaults(); - } - - private void initGUI() - { - BorderLayout borderLayout = new BorderLayout(); - - this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); - this.setLayout(borderLayout); - setPreferredSize(new Dimension(500, 300)); - { - mainPanel = new JPanel(); - this.setOpaque(false); - this.mainPanel.setOpaque(false); - - BoxLayout boxLayout = new BoxLayout( - mainPanel, javax.swing.BoxLayout.Y_AXIS); - mainPanel.setLayout(boxLayout); - this.add(mainPanel, BorderLayout.NORTH); - - String osName = System.getProperty("os.name"); - if (osName.startsWith("Windows")) - { - autoStartCheckBox = new SIPCommCheckBox(); - mainPanel.add(autoStartCheckBox); - mainPanel.add(Box.createVerticalStrut(10)); - - autoStartCheckBox.setText( - Resources.getString( - "plugin.generalconfig.AUTO_START", - new String[]{getApplicationName()})); - - initAutoStartCheckBox(); - autoStartCheckBox.addActionListener(this); - } - { - groupMessagesCheckBox = new SIPCommCheckBox(); - mainPanel.add(groupMessagesCheckBox); - mainPanel.add(Box.createVerticalStrut(10)); - groupMessagesCheckBox.setText( - Resources.getString( - "plugin.generalconfig.GROUP_CHAT_MESSAGES")); - groupMessagesCheckBox.addActionListener(this); - } - { - logHistoryPanel = new JPanel(); - logHistoryPanel.setOpaque(false); - - mainPanel.add(logHistoryPanel); - mainPanel.add(Box.createVerticalStrut(10)); - logHistoryPanel.setLayout(null); - logHistoryPanel.setPreferredSize( - new java.awt.Dimension(380, 57)); - logHistoryPanel.setAlignmentX(0.0f); - { - logHistoryCheckBox = new SIPCommCheckBox(); - logHistoryPanel.add(logHistoryCheckBox); - logHistoryCheckBox.setText( - Resources.getString("plugin.generalconfig.LOG_HISTORY")); - logHistoryCheckBox.setBounds(0, 0, 200, 19); - logHistoryCheckBox.addActionListener(this); - logHistoryCheckBox.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - showHistoryCheckBox.setEnabled( - logHistoryCheckBox.isSelected()); - historySizeSpinner.setEnabled( - logHistoryCheckBox.isSelected()); - } - }); - } - { - showHistoryCheckBox = new SIPCommCheckBox(); - logHistoryPanel.add(showHistoryCheckBox); - showHistoryCheckBox.setText( - Resources.getString("plugin.generalconfig.SHOW_HISTORY")); - showHistoryCheckBox.setBounds(17, 25, 140, 19); - showHistoryCheckBox.addActionListener(this); - showHistoryCheckBox.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - historySizeSpinner.setEnabled( - showHistoryCheckBox.isSelected()); - } - }); - } - { - SpinnerNumberModel historySizeSpinnerModel = - new SpinnerNumberModel(0, 0, 100, 1); - historySizeSpinner = new JSpinner(); - logHistoryPanel.add(historySizeSpinner); - historySizeSpinner.setModel(historySizeSpinnerModel); - historySizeSpinner.setBounds(150, 23, 47, 22); - historySizeSpinnerModel.addChangeListener( - new ChangeListener() - { - public void stateChanged(ChangeEvent e) - { - ConfigurationManager.setChatHistorySize( - ((Integer) historySizeSpinner - .getValue()).intValue()); - } - }); - } - { - historySizeLabel = new JLabel(); - logHistoryPanel.add(historySizeLabel); - historySizeLabel.setText( - Resources.getString("plugin.generalconfig.HISTORY_SIZE")); - historySizeLabel.setBounds(205, 27, 220, 15); - } - } - { - sendMessagePanel = new JPanel(); - sendMessagePanel.setOpaque(false); - - BorderLayout sendMessagePanelLayout - = new BorderLayout(10, 10); - sendMessagePanel.setLayout(sendMessagePanelLayout); - mainPanel.add(sendMessagePanel); - mainPanel.add(Box.createVerticalStrut(10)); - sendMessagePanel.setAlignmentX(0.0f); - sendMessagePanel.setPreferredSize( - new java.awt.Dimension(380, 22)); - { - sendMessageLabel = new JLabel(); - sendMessagePanel.add( - sendMessageLabel, BorderLayout.WEST); - sendMessageLabel.setText( - Resources.getString("plugin.generalconfig.SEND_MESSAGES_WITH")); - } - { - ComboBoxModel sendMessageComboBoxModel = - new DefaultComboBoxModel( - new String[] { - ConfigurationManager.ENTER_COMMAND, - ConfigurationManager.CTRL_ENTER_COMMAND }); - sendMessageComboBox = new JComboBox(); - sendMessagePanel.add( - sendMessageComboBox, BorderLayout.CENTER); - sendMessageComboBox.setModel(sendMessageComboBoxModel); - sendMessageComboBox.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent arg0) - { - ConfigurationManager.setSendMessageCommand( - (String)sendMessageComboBox.getSelectedItem()); - } - }); - } - } - { - enableTypingNotifiCheckBox = new SIPCommCheckBox(); - enableTypingNotifiCheckBox.setLayout(null); - mainPanel.add(enableTypingNotifiCheckBox); - mainPanel.add(Box.createVerticalStrut(10)); - enableTypingNotifiCheckBox.setText( - Resources.getString("service.gui.ENABLE_TYPING_NOTIFICATIONS")); - enableTypingNotifiCheckBox.setPreferredSize( - new java.awt.Dimension(253, 20)); - enableTypingNotifiCheckBox.setAlignmentY(0.0f); - enableTypingNotifiCheckBox.addActionListener(this); - } - { - bringToFrontCheckBox = new SIPCommCheckBox(); - mainPanel.add(bringToFrontCheckBox); - mainPanel.add(Box.createVerticalStrut(10)); - bringToFrontCheckBox.setText( - Resources.getString("plugin.generalconfig.BRING_WINDOW_TO_FRONT")); - bringToFrontCheckBox.addActionListener(this); - } -// { -// JPanel transparencyPanel = new JPanel(); -// BorderLayout transparencyPanelLayout -// = new BorderLayout(10, 10); -// transparencyPanel.setLayout(transparencyPanelLayout); -// mainPanel.add(transparencyPanel); -// mainPanel.add(Box.createVerticalStrut(10)); -// transparencyPanel.setAlignmentX(0.0f); -// transparencyPanel.setPreferredSize( -// new java.awt.Dimension(380, 60)); -// { -// final JCheckBox enableTransparencyCheckBox -// = new JCheckBox( -// Resources.getString("plugin.generalconfig.ENABLE_TRANSPARENCY"), -// ConfigurationManager.isTransparentWindowEnabled()); -// transparencyPanel.add( -// enableTransparencyCheckBox, BorderLayout.NORTH); -// -// enableTransparencyCheckBox.addChangeListener( -// new ChangeListener() -// { -// public void stateChanged(ChangeEvent e) -// { -// ConfigurationManager.setTransparentWindowEnabled( -// enableTransparencyCheckBox.isSelected()); -// } -// }); -// -// } -// { -// JLabel transparencyLabel = new JLabel( -// Resources.getString("plugin.generalconfig.TRANSPARENCY")); -// -// transparencyPanel.add( transparencyLabel, -// BorderLayout.WEST); -// } -// { -// final JSlider transparencySlider -// = new JSlider(0, 255, -// ConfigurationManager.getWindowTransparency()); -// -// transparencyPanel.add( transparencySlider, -// BorderLayout.CENTER); -// -// transparencySlider.addChangeListener(new ChangeListener() -// { -// public void stateChanged(ChangeEvent e) -// { -// int value = transparencySlider.getValue(); -// ConfigurationManager.setWindowTransparency(value); -// } -// }); -// } -// } - } - } - - private void initDefaults() - { - groupMessagesCheckBox.setSelected( - ConfigurationManager.isMultiChatWindowEnabled()); - - logHistoryCheckBox.setSelected( - ConfigurationManager.isHistoryLoggingEnabled()); - - showHistoryCheckBox.setSelected( - ConfigurationManager.isHistoryShown()); - - historySizeSpinner.setValue( - ConfigurationManager.getChatHistorySize()); - - if (!ConfigurationManager.isHistoryLoggingEnabled()) - { - showHistoryCheckBox.setEnabled(false); - historySizeSpinner.setEnabled(false); - } - - if (!ConfigurationManager.isHistoryShown()) - { - historySizeSpinner.setEnabled(false); - } - - sendMessageComboBox.setSelectedItem( - ConfigurationManager.getSendMessageCommand()); - - enableTypingNotifiCheckBox.setSelected( - ConfigurationManager.isSendTypingNotifications()); - - bringToFrontCheckBox.setSelected( - ConfigurationManager.isAutoPopupNewMessage()); - } - - private String getApplicationName() - { - return Resources.getSettingsString("service.gui.APPLICATION_NAME"); - } - - public Object getForm() - { - return this; - } - - public byte[] getIcon() - { - return Resources.getImage("plugin.generalconfig.PLUGIN_ICON"); - } - - public String getTitle() - { - return Resources.getString("service.gui.GENERAL"); - } - - public int getIndex() - { - return 0; - } - - public void actionPerformed(ActionEvent event) - { - Object sourceObject = event.getSource(); - - if (sourceObject.equals(autoStartCheckBox)) - { - try - { - String workingDir = new File(".").getCanonicalPath(); - - String appName = getApplicationName(); - - ShellLink shortcut = new ShellLink(ShellLink.STARTUP, appName); - shortcut.setUserType(ShellLink.CURRENT_USER); - shortcut.setDescription( - "This starts " + appName + " Application"); - shortcut.setIconLocation( - workingDir + File.separator + "sc-logo.ico", 0); - shortcut.setShowCommand(ShellLink.MINNOACTIVE); - shortcut.setTargetPath(workingDir + File.separator + "run.exe"); - shortcut.setWorkingDirectory(workingDir); - - String f1 = shortcut.getcurrentUserLinkPath() + - File.separator + appName + ".lnk"; - - String f2 = f1.replaceAll( - System.getProperty("user.name"), - "All Users"); - - if(autoStartCheckBox.isSelected()) - { - if(!new File(f1).exists() && - !new File(f2).exists()) - shortcut.save(); - } - else - { - boolean isFileDeleted = false; - try { - isFileDeleted = new File(f1).delete(); - } catch (Exception e) {} - - try { - new File(f2).delete(); - } catch (Exception e) - { - if(!isFileDeleted) - GeneralConfigPluginActivator.getUIService(). - getPopupDialog().showMessagePopupDialog( - e.getMessage(), - Resources.getString( - "plugin.generalconfig.ERROR_PERMISSION"), - PopupDialog.ERROR_MESSAGE); - // cannot delete no permissions - } - } - } catch (Exception e) - { - logger.error("Cannot create/delete startup shortcut", e); - } - } - if (sourceObject.equals(groupMessagesCheckBox)) - { - ConfigurationManager.setMultiChatWindowEnabled( - groupMessagesCheckBox.isSelected()); - } - else if (sourceObject.equals(logHistoryCheckBox)) - { - ConfigurationManager.setHistoryLoggingEnabled( - logHistoryCheckBox.isSelected()); - } - else if (sourceObject.equals(showHistoryCheckBox)) - { - ConfigurationManager.setHistoryShown( - showHistoryCheckBox.isSelected()); - } - else if (sourceObject.equals(enableTypingNotifiCheckBox)) - { - ConfigurationManager.setSendTypingNotifications( - enableTypingNotifiCheckBox.isSelected()); - } - else if (sourceObject.equals(bringToFrontCheckBox)) - { - ConfigurationManager.setAutoPopupNewMessage( - bringToFrontCheckBox.isSelected()); - } - } - - private void initAutoStartCheckBox() - { - try - { - String appName = getApplicationName(); - - ShellLink shortcut = - new ShellLink( - ShellLink.STARTUP, - appName); - shortcut.setUserType(ShellLink.CURRENT_USER); - - String f1 = shortcut.getcurrentUserLinkPath() + - File.separator + appName + ".lnk"; - - String f2 = f1.replaceAll( - System.getProperty("user.name"), - "All Users"); - - if(new File(f1).exists() || new File(f2).exists()) - autoStartCheckBox.setSelected(true); - else - autoStartCheckBox.setSelected(false); - } - catch (Exception e) - { - logger.error(e); - } - } -} diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java new file mode 100644 index 0000000..31c4e10 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java @@ -0,0 +1,435 @@ +/* + * 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.plugin.generalconfig; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; + +import javax.swing.*; +import javax.swing.event.*; + +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; + +import com.izforge.izpack.util.os.*; + +/** + * @author Yana Stamcheva + */ +public class GeneralConfigurationPanel + extends JPanel + implements ActionListener +{ + private final Logger logger = Logger.getLogger(GeneralConfigurationPanel.class); + + private JPanel mainPanel; + private JCheckBox bringToFrontCheckBox; + private JCheckBox autoStartCheckBox; + private JCheckBox groupMessagesCheckBox; + private JCheckBox logHistoryCheckBox; + private JPanel sendMessagePanel; + private JLabel sendMessageLabel; + private JComboBox sendMessageComboBox; + private JLabel historySizeLabel; + private JSpinner historySizeSpinner; + private JCheckBox enableTypingNotifiCheckBox; + private JCheckBox showHistoryCheckBox; + private JPanel logHistoryPanel; + + public GeneralConfigurationPanel() + { + initGUI(); + initDefaults(); + } + + private void initGUI() + { + BorderLayout borderLayout = new BorderLayout(); + + this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + this.setLayout(borderLayout); + setPreferredSize(new Dimension(500, 300)); + { + mainPanel = new JPanel(); + this.setOpaque(false); + this.mainPanel.setOpaque(false); + + BoxLayout boxLayout = new BoxLayout( + mainPanel, javax.swing.BoxLayout.Y_AXIS); + mainPanel.setLayout(boxLayout); + this.add(mainPanel, BorderLayout.NORTH); + + String osName = System.getProperty("os.name"); + if (osName.startsWith("Windows")) + { + autoStartCheckBox = new SIPCommCheckBox(); + mainPanel.add(autoStartCheckBox); + mainPanel.add(Box.createVerticalStrut(10)); + + autoStartCheckBox.setText( + Resources.getString( + "plugin.generalconfig.AUTO_START", + new String[]{getApplicationName()})); + + initAutoStartCheckBox(); + autoStartCheckBox.addActionListener(this); + } + { + groupMessagesCheckBox = new SIPCommCheckBox(); + mainPanel.add(groupMessagesCheckBox); + mainPanel.add(Box.createVerticalStrut(10)); + groupMessagesCheckBox.setText( + Resources.getString( + "plugin.generalconfig.GROUP_CHAT_MESSAGES")); + groupMessagesCheckBox.addActionListener(this); + } + { + logHistoryPanel = new JPanel(); + logHistoryPanel.setOpaque(false); + + mainPanel.add(logHistoryPanel); + mainPanel.add(Box.createVerticalStrut(10)); + logHistoryPanel.setLayout(null); + logHistoryPanel.setPreferredSize( + new java.awt.Dimension(380, 57)); + logHistoryPanel.setAlignmentX(0.0f); + { + logHistoryCheckBox = new SIPCommCheckBox(); + logHistoryPanel.add(logHistoryCheckBox); + logHistoryCheckBox.setText( + Resources.getString("plugin.generalconfig.LOG_HISTORY")); + logHistoryCheckBox.setBounds(0, 0, 200, 19); + logHistoryCheckBox.addActionListener(this); + logHistoryCheckBox.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent e) + { + showHistoryCheckBox.setEnabled( + logHistoryCheckBox.isSelected()); + historySizeSpinner.setEnabled( + logHistoryCheckBox.isSelected()); + } + }); + } + { + showHistoryCheckBox = new SIPCommCheckBox(); + logHistoryPanel.add(showHistoryCheckBox); + showHistoryCheckBox.setText( + Resources.getString("plugin.generalconfig.SHOW_HISTORY")); + showHistoryCheckBox.setBounds(17, 25, 140, 19); + showHistoryCheckBox.addActionListener(this); + showHistoryCheckBox.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent e) + { + historySizeSpinner.setEnabled( + showHistoryCheckBox.isSelected()); + } + }); + } + { + SpinnerNumberModel historySizeSpinnerModel = + new SpinnerNumberModel(0, 0, 100, 1); + historySizeSpinner = new JSpinner(); + logHistoryPanel.add(historySizeSpinner); + historySizeSpinner.setModel(historySizeSpinnerModel); + historySizeSpinner.setBounds(150, 23, 47, 22); + historySizeSpinnerModel.addChangeListener( + new ChangeListener() + { + public void stateChanged(ChangeEvent e) + { + ConfigurationManager.setChatHistorySize( + ((Integer) historySizeSpinner + .getValue()).intValue()); + } + }); + } + { + historySizeLabel = new JLabel(); + logHistoryPanel.add(historySizeLabel); + historySizeLabel.setText( + Resources.getString("plugin.generalconfig.HISTORY_SIZE")); + historySizeLabel.setBounds(205, 27, 220, 15); + } + } + { + sendMessagePanel = new JPanel(); + sendMessagePanel.setOpaque(false); + + BorderLayout sendMessagePanelLayout + = new BorderLayout(10, 10); + sendMessagePanel.setLayout(sendMessagePanelLayout); + mainPanel.add(sendMessagePanel); + mainPanel.add(Box.createVerticalStrut(10)); + sendMessagePanel.setAlignmentX(0.0f); + sendMessagePanel.setPreferredSize( + new java.awt.Dimension(380, 22)); + { + sendMessageLabel = new JLabel(); + sendMessagePanel.add( + sendMessageLabel, BorderLayout.WEST); + sendMessageLabel.setText( + Resources.getString("plugin.generalconfig.SEND_MESSAGES_WITH")); + } + { + ComboBoxModel sendMessageComboBoxModel = + new DefaultComboBoxModel( + new String[] { + ConfigurationManager.ENTER_COMMAND, + ConfigurationManager.CTRL_ENTER_COMMAND }); + sendMessageComboBox = new JComboBox(); + sendMessagePanel.add( + sendMessageComboBox, BorderLayout.CENTER); + sendMessageComboBox.setModel(sendMessageComboBoxModel); + sendMessageComboBox.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent arg0) + { + ConfigurationManager.setSendMessageCommand( + (String)sendMessageComboBox.getSelectedItem()); + } + }); + } + } + { + enableTypingNotifiCheckBox = new SIPCommCheckBox(); + enableTypingNotifiCheckBox.setLayout(null); + mainPanel.add(enableTypingNotifiCheckBox); + mainPanel.add(Box.createVerticalStrut(10)); + enableTypingNotifiCheckBox.setText( + Resources.getString("service.gui.ENABLE_TYPING_NOTIFICATIONS")); + enableTypingNotifiCheckBox.setPreferredSize( + new java.awt.Dimension(253, 20)); + enableTypingNotifiCheckBox.setAlignmentY(0.0f); + enableTypingNotifiCheckBox.addActionListener(this); + } + { + bringToFrontCheckBox = new SIPCommCheckBox(); + mainPanel.add(bringToFrontCheckBox); + mainPanel.add(Box.createVerticalStrut(10)); + bringToFrontCheckBox.setText( + Resources.getString("plugin.generalconfig.BRING_WINDOW_TO_FRONT")); + bringToFrontCheckBox.addActionListener(this); + } +// { +// JPanel transparencyPanel = new JPanel(); +// BorderLayout transparencyPanelLayout +// = new BorderLayout(10, 10); +// transparencyPanel.setLayout(transparencyPanelLayout); +// mainPanel.add(transparencyPanel); +// mainPanel.add(Box.createVerticalStrut(10)); +// transparencyPanel.setAlignmentX(0.0f); +// transparencyPanel.setPreferredSize( +// new java.awt.Dimension(380, 60)); +// { +// final JCheckBox enableTransparencyCheckBox +// = new JCheckBox( +// Resources.getString("plugin.generalconfig.ENABLE_TRANSPARENCY"), +// ConfigurationManager.isTransparentWindowEnabled()); +// transparencyPanel.add( +// enableTransparencyCheckBox, BorderLayout.NORTH); +// +// enableTransparencyCheckBox.addChangeListener( +// new ChangeListener() +// { +// public void stateChanged(ChangeEvent e) +// { +// ConfigurationManager.setTransparentWindowEnabled( +// enableTransparencyCheckBox.isSelected()); +// } +// }); +// +// } +// { +// JLabel transparencyLabel = new JLabel( +// Resources.getString("plugin.generalconfig.TRANSPARENCY")); +// +// transparencyPanel.add( transparencyLabel, +// BorderLayout.WEST); +// } +// { +// final JSlider transparencySlider +// = new JSlider(0, 255, +// ConfigurationManager.getWindowTransparency()); +// +// transparencyPanel.add( transparencySlider, +// BorderLayout.CENTER); +// +// transparencySlider.addChangeListener(new ChangeListener() +// { +// public void stateChanged(ChangeEvent e) +// { +// int value = transparencySlider.getValue(); +// ConfigurationManager.setWindowTransparency(value); +// } +// }); +// } +// } + } + } + + private void initDefaults() + { + groupMessagesCheckBox.setSelected( + ConfigurationManager.isMultiChatWindowEnabled()); + + logHistoryCheckBox.setSelected( + ConfigurationManager.isHistoryLoggingEnabled()); + + showHistoryCheckBox.setSelected( + ConfigurationManager.isHistoryShown()); + + historySizeSpinner.setValue( + ConfigurationManager.getChatHistorySize()); + + if (!ConfigurationManager.isHistoryLoggingEnabled()) + { + showHistoryCheckBox.setEnabled(false); + historySizeSpinner.setEnabled(false); + } + + if (!ConfigurationManager.isHistoryShown()) + { + historySizeSpinner.setEnabled(false); + } + + sendMessageComboBox.setSelectedItem( + ConfigurationManager.getSendMessageCommand()); + + enableTypingNotifiCheckBox.setSelected( + ConfigurationManager.isSendTypingNotifications()); + + bringToFrontCheckBox.setSelected( + ConfigurationManager.isAutoPopupNewMessage()); + } + + private String getApplicationName() + { + return Resources.getSettingsString("service.gui.APPLICATION_NAME"); + } + + public void actionPerformed(ActionEvent event) + { + Object sourceObject = event.getSource(); + + if (sourceObject.equals(autoStartCheckBox)) + { + try + { + String workingDir = new File(".").getCanonicalPath(); + + String appName = getApplicationName(); + + ShellLink shortcut = new ShellLink(ShellLink.STARTUP, appName); + shortcut.setUserType(ShellLink.CURRENT_USER); + shortcut.setDescription( + "This starts " + appName + " Application"); + shortcut.setIconLocation( + workingDir + File.separator + "sc-logo.ico", 0); + shortcut.setShowCommand(ShellLink.MINNOACTIVE); + shortcut.setTargetPath(workingDir + File.separator + "run.exe"); + shortcut.setWorkingDirectory(workingDir); + + String f1 = shortcut.getcurrentUserLinkPath() + + File.separator + appName + ".lnk"; + + String f2 = f1.replaceAll( + System.getProperty("user.name"), + "All Users"); + + if(autoStartCheckBox.isSelected()) + { + if(!new File(f1).exists() && + !new File(f2).exists()) + shortcut.save(); + } + else + { + boolean isFileDeleted = false; + try { + isFileDeleted = new File(f1).delete(); + } catch (Exception e) {} + + try { + new File(f2).delete(); + } catch (Exception e) + { + if(!isFileDeleted) + GeneralConfigPluginActivator.getUIService(). + getPopupDialog().showMessagePopupDialog( + e.getMessage(), + Resources.getString( + "plugin.generalconfig.ERROR_PERMISSION"), + PopupDialog.ERROR_MESSAGE); + // cannot delete no permissions + } + } + } catch (Exception e) + { + logger.error("Cannot create/delete startup shortcut", e); + } + } + if (sourceObject.equals(groupMessagesCheckBox)) + { + ConfigurationManager.setMultiChatWindowEnabled( + groupMessagesCheckBox.isSelected()); + } + else if (sourceObject.equals(logHistoryCheckBox)) + { + ConfigurationManager.setHistoryLoggingEnabled( + logHistoryCheckBox.isSelected()); + } + else if (sourceObject.equals(showHistoryCheckBox)) + { + ConfigurationManager.setHistoryShown( + showHistoryCheckBox.isSelected()); + } + else if (sourceObject.equals(enableTypingNotifiCheckBox)) + { + ConfigurationManager.setSendTypingNotifications( + enableTypingNotifiCheckBox.isSelected()); + } + else if (sourceObject.equals(bringToFrontCheckBox)) + { + ConfigurationManager.setAutoPopupNewMessage( + bringToFrontCheckBox.isSelected()); + } + } + + private void initAutoStartCheckBox() + { + try + { + String appName = getApplicationName(); + + ShellLink shortcut = + new ShellLink( + ShellLink.STARTUP, + appName); + shortcut.setUserType(ShellLink.CURRENT_USER); + + String f1 = shortcut.getcurrentUserLinkPath() + + File.separator + appName + ".lnk"; + + String f2 = f1.replaceAll( + System.getProperty("user.name"), + "All Users"); + + if(new File(f1).exists() || new File(f2).exists()) + autoStartCheckBox.setSelected(true); + else + autoStartCheckBox.setSelected(false); + } + catch (Exception e) + { + logger.error(e); + } + } +} diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java index d22c29b..778fa9f 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java @@ -38,8 +38,14 @@ public class KeybindingChooserActivator logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]"); - context.registerService(ConfigurationForm.class.getName(), - new KeybindingsConfigForm(), null); + context + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.keybindingchooser.KeybindingsConfigPanel", + getClass().getClassLoader(), + "plugin.keybinding.PLUGIN_ICON", + "plugin.keybindings.PLUGIN_NAME"), null); } /** diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigForm.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigForm.java deleted file mode 100644 index 323f88e..0000000 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigForm.java +++ /dev/null @@ -1,45 +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.plugin.keybindingchooser; - -import net.java.sip.communicator.service.gui.*; - -/** - * The ConfigurationForm that would be added to the settings - * configuration to configure the application keybindings. - * - * @author Damian Johnson - * @author Lubomir Marinov - */ -public class KeybindingsConfigForm - extends AbstractConfigurationForm -{ - /** - * Implements the ConfigurationForm.getTitle() method. Returns the - * title of this configuration form. - */ - public String getTitle() - { - return KeybindingChooserActivator.getResources().getI18NString( - "plugin.keybindings.PLUGIN_NAME"); - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public byte[] getIcon() - { - return KeybindingChooserActivator.getResources().getImageInBytes( - "plugin.keybinding.PLUGIN_ICON"); - } - - protected String getFormClassName() - { - return "net.java.sip.communicator.plugin.keybindingchooser.KeybindingsConfigPanel"; - } -} diff --git a/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java b/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java index 2903215..9834916 100644 --- a/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java +++ b/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java @@ -23,7 +23,7 @@ import net.java.sip.communicator.util.*; public class MailboxActivator implements BundleActivator { - private static Logger logger = + private static final Logger logger = Logger.getLogger(BundleActivator.class); /** @@ -74,12 +74,13 @@ public class MailboxActivator mailbox = new Mailbox(); mailbox.start(bundleContext); - MailboxConfigurationForm mailboxForm - = new MailboxConfigurationForm(); - - bundleContext.registerService( ConfigurationForm.class.getName(), - mailboxForm, - null); + bundleContext + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.mailbox.MailboxConfigurationPanel", + getClass().getClassLoader(), "plugin.mailbox.PLUGIN_ICON", + "plugin.mailbox.MAILBOX"), null); logger.info("Mailbox plug-in...[STARTED]"); } diff --git a/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationForm.java b/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationForm.java deleted file mode 100644 index bfdd83c..0000000 --- a/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationForm.java +++ /dev/null @@ -1,255 +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.plugin.mailbox; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; - -import javax.swing.*; - -import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.gui.*; - -import net.java.sip.communicator.util.swing.*; - -/** - * The ConfigurationForm that would be added in the user interface - * configuration window. It allows the user to change parameters in the - * mailbox configuration - * @author Ryan Ricard - */ -public class MailboxConfigurationForm - extends TransparentPanel - implements ConfigurationForm, ActionListener -{ - private JLabel jlblOutgoingMessage - = new JLabel(Resources.getString("plugin.mailbox.OUTGOING")); - - private JFileChooser jfcOutgoingMessage = new JFileChooser(); - - private JButton jbtnOutgoingMessage - = new JButton(Resources.getString("plugin.mailbox.BROWSE")); - - private JTextField jtfOutgoingMessage = new JTextField(); - - private JPanel jpOutgoingMessage - = new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); - - private JLabel jlblIncomingMessage - = new JLabel(Resources.getString("plugin.mailbox.INCOMING")); - - private JFileChooser jfcIncomingMessage = new JFileChooser(); - - private JButton jbtnIncomingMessage - = new JButton(Resources.getString("plugin.mailbox.BROWSE")); - - private JTextField jtfIncomingMessage = new JTextField(); - - private JPanel jpIncomingMessage - = new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); - - private JLabel jlblWaitTime - = new JLabel(Resources.getString("plugin.mailbox.WAIT_TIME")); - - private JSpinner jsWaitTime = new JSpinner(new SpinnerNumberModel( - new Integer(10000), - new Integer(0), - null, - new Integer(1000))); - - private JPanel jpWaitTime = - new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); - - private JLabel jlblMaxMessageTime - = new JLabel(Resources.getString("plugin.mailbox.MAX_MESSAGE_TIME")); - - private JSpinner jsMaxMessageTime = new JSpinner(new SpinnerNumberModel( - new Integer(10000), - new Integer(0), - null, - new Integer(1000))); - - private JPanel jpMaxMessageTime = new TransparentPanel( - new FlowLayout(FlowLayout.LEFT)); - - private JButton jbtnConfirm - = new JButton(Resources.getString("plugin.mailbox.CONFIRM")); - private JButton jbtnDefault - = new JButton(Resources.getString("plugin.mailbox.DEFAULTS")); - - private JPanel jpConfirmDefault = new TransparentPanel(); - ConfigurationService config; - - public MailboxConfigurationForm() - { - - super(new GridLayout(5,1)); - config = MailboxActivator.getConfigurationService(); - //get our outgoing file panel set up - jtfOutgoingMessage.setText(Mailbox.getOutgoingMessageFileLocation() - .toString()); - jpOutgoingMessage.add(jlblOutgoingMessage); - jpOutgoingMessage.add(jtfOutgoingMessage); - jpOutgoingMessage.add(jbtnOutgoingMessage); - - //get our incoming file panel set up - jtfIncomingMessage.setText(Mailbox.getIncomingMessageDirectory() - .toString()); - jfcIncomingMessage.setFileSelectionMode( - JFileChooser.DIRECTORIES_ONLY); - jpIncomingMessage.add(jlblIncomingMessage); - jpIncomingMessage.add(jtfIncomingMessage); - jpIncomingMessage.add(jbtnIncomingMessage); - - //get our wait time panel set up - jsWaitTime.setValue(new Integer(Mailbox.getWaitTime())); - jpWaitTime.add(jlblWaitTime); - jpWaitTime.add(jsWaitTime); - - //get our max message time panel set up - jsMaxMessageTime.setValue(new Integer( - Mailbox.getMaxMessageDuration())); - jpMaxMessageTime.add(jlblMaxMessageTime); - jpMaxMessageTime.add(jsMaxMessageTime); - - //get our buttons panel set up - jpConfirmDefault.add(jbtnConfirm); - jpConfirmDefault.add(jbtnDefault); - - //add all the sub-panels - this.add(jpOutgoingMessage); - this.add(jpIncomingMessage); - this.add(jpWaitTime); - this.add(jpMaxMessageTime); - this.add(jpConfirmDefault); - - //add action listeners - jbtnIncomingMessage.addActionListener(this); - jbtnOutgoingMessage.addActionListener(this); - jbtnConfirm.addActionListener(this); - jbtnDefault.addActionListener(this); - - //a little resizing - jtfIncomingMessage.setColumns(20); - jtfOutgoingMessage.setColumns(20); - ((JSpinner.DefaultEditor)jsWaitTime.getEditor()) - .getTextField().setColumns(6); - ((JSpinner.DefaultEditor)jsMaxMessageTime.getEditor()) - .getTextField().setColumns(6); - } - - public void actionPerformed(ActionEvent e) - { - - if (e.getSource() == jbtnIncomingMessage) - { - jfcIncomingMessage.setCurrentDirectory( - Mailbox.getIncomingMessageDirectory()); - int returnVal = jfcIncomingMessage.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) - { - File file = jfcIncomingMessage.getSelectedFile(); - jtfIncomingMessage.setText(file.toString()); - } - } - else if (e.getSource() == jbtnOutgoingMessage) - { - jfcOutgoingMessage.setCurrentDirectory( - Mailbox.getOutgoingMessageFileLocation()); - int returnVal = jfcOutgoingMessage.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) - { - File file = jfcOutgoingMessage.getSelectedFile(); - jtfIncomingMessage.setText(file.toString()); - } - - } - else if (e.getSource() == jbtnConfirm) - { - config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, - (Integer)jsMaxMessageTime.getValue()); - config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, - (Integer)jsWaitTime.getValue()); - config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, - jtfIncomingMessage.getText()); - config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, - jtfOutgoingMessage.getText()); - JOptionPane.showMessageDialog(this, "Values Set!"); - } - else if (e.getSource() == jbtnDefault) - { - int choice = JOptionPane.showConfirmDialog(this, - "OK to reset all values to default?", - "Set Defaults?", JOptionPane.YES_NO_OPTION); - if (choice == JOptionPane.YES_OPTION) - { - //reset all values to null and then let Mailbox plug in the defaults - config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, - null); - config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, - null); - config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, - null); - config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, - null); - config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, - new Integer(Mailbox.getMaxMessageDuration())); - config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, - new Integer(Mailbox.getWaitTime())); - config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, - Mailbox.getIncomingMessageDirectory()); - config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, - Mailbox.getOutgoingMessageFileLocation()); - - //now reset all the GUI elements to the defaults - jtfIncomingMessage.setText(Mailbox - .getIncomingMessageDirectory() - .toString()); - jtfOutgoingMessage.setText(Mailbox - .getOutgoingMessageFileLocation() - .toString()); - jsWaitTime.setValue(new Integer(Mailbox.getWaitTime())); - jsMaxMessageTime.setValue(new Integer( - Mailbox.getMaxMessageDuration())); - } - } - - } - - /** - * Implements the ConfigurationForm.getTitle() method. Returns the - * title of this configuration form. - */ - public String getTitle() - { - return Resources.getString("plugin.mailbox.MAILBOX"); - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public byte[] getIcon() - { - return Resources.getImageInBytes("plugin.mailbox.PLUGIN_ICON"); - } - - /** - * Implements the ConfigurationForm.getForm() method. Returns the - * component corresponding to this configuration form. - */ - public Object getForm() - { - return this; - } - - public int getIndex() - { - return -1; - } -} \ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationPanel.java b/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationPanel.java new file mode 100644 index 0000000..48aeaa7 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/mailbox/MailboxConfigurationPanel.java @@ -0,0 +1,222 @@ +/* + * 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.plugin.mailbox; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; + +import javax.swing.*; + +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.util.swing.*; + +/** + * The ConfigurationForm that would be added in the user interface + * configuration window. It allows the user to change parameters in the mailbox + * configuration + * + * @author Ryan Ricard + */ +public class MailboxConfigurationPanel + extends TransparentPanel + implements ActionListener +{ + private JLabel jlblOutgoingMessage + = new JLabel(Resources.getString("plugin.mailbox.OUTGOING")); + + private JFileChooser jfcOutgoingMessage = new JFileChooser(); + + private JButton jbtnOutgoingMessage + = new JButton(Resources.getString("plugin.mailbox.BROWSE")); + + private JTextField jtfOutgoingMessage = new JTextField(); + + private JPanel jpOutgoingMessage + = new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); + + private JLabel jlblIncomingMessage + = new JLabel(Resources.getString("plugin.mailbox.INCOMING")); + + private JFileChooser jfcIncomingMessage = new JFileChooser(); + + private JButton jbtnIncomingMessage + = new JButton(Resources.getString("plugin.mailbox.BROWSE")); + + private JTextField jtfIncomingMessage = new JTextField(); + + private JPanel jpIncomingMessage + = new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); + + private JLabel jlblWaitTime + = new JLabel(Resources.getString("plugin.mailbox.WAIT_TIME")); + + private JSpinner jsWaitTime = new JSpinner(new SpinnerNumberModel( + new Integer(10000), + new Integer(0), + null, + new Integer(1000))); + + private JPanel jpWaitTime = + new TransparentPanel(new FlowLayout(FlowLayout.LEFT)); + + private JLabel jlblMaxMessageTime + = new JLabel(Resources.getString("plugin.mailbox.MAX_MESSAGE_TIME")); + + private JSpinner jsMaxMessageTime = new JSpinner(new SpinnerNumberModel( + new Integer(10000), + new Integer(0), + null, + new Integer(1000))); + + private JPanel jpMaxMessageTime = new TransparentPanel( + new FlowLayout(FlowLayout.LEFT)); + + private JButton jbtnConfirm + = new JButton(Resources.getString("plugin.mailbox.CONFIRM")); + private JButton jbtnDefault + = new JButton(Resources.getString("plugin.mailbox.DEFAULTS")); + + private JPanel jpConfirmDefault = new TransparentPanel(); + ConfigurationService config; + + public MailboxConfigurationPanel() + { + super(new GridLayout(5,1)); + + config = MailboxActivator.getConfigurationService(); + //get our outgoing file panel set up + jtfOutgoingMessage.setText(Mailbox.getOutgoingMessageFileLocation() + .toString()); + jpOutgoingMessage.add(jlblOutgoingMessage); + jpOutgoingMessage.add(jtfOutgoingMessage); + jpOutgoingMessage.add(jbtnOutgoingMessage); + + //get our incoming file panel set up + jtfIncomingMessage.setText(Mailbox.getIncomingMessageDirectory() + .toString()); + jfcIncomingMessage.setFileSelectionMode( + JFileChooser.DIRECTORIES_ONLY); + jpIncomingMessage.add(jlblIncomingMessage); + jpIncomingMessage.add(jtfIncomingMessage); + jpIncomingMessage.add(jbtnIncomingMessage); + + //get our wait time panel set up + jsWaitTime.setValue(new Integer(Mailbox.getWaitTime())); + jpWaitTime.add(jlblWaitTime); + jpWaitTime.add(jsWaitTime); + + //get our max message time panel set up + jsMaxMessageTime.setValue(new Integer( + Mailbox.getMaxMessageDuration())); + jpMaxMessageTime.add(jlblMaxMessageTime); + jpMaxMessageTime.add(jsMaxMessageTime); + + //get our buttons panel set up + jpConfirmDefault.add(jbtnConfirm); + jpConfirmDefault.add(jbtnDefault); + + //add all the sub-panels + this.add(jpOutgoingMessage); + this.add(jpIncomingMessage); + this.add(jpWaitTime); + this.add(jpMaxMessageTime); + this.add(jpConfirmDefault); + + //add action listeners + jbtnIncomingMessage.addActionListener(this); + jbtnOutgoingMessage.addActionListener(this); + jbtnConfirm.addActionListener(this); + jbtnDefault.addActionListener(this); + + //a little resizing + jtfIncomingMessage.setColumns(20); + jtfOutgoingMessage.setColumns(20); + ((JSpinner.DefaultEditor)jsWaitTime.getEditor()) + .getTextField().setColumns(6); + ((JSpinner.DefaultEditor)jsMaxMessageTime.getEditor()) + .getTextField().setColumns(6); + } + + public void actionPerformed(ActionEvent e) + { + + if (e.getSource() == jbtnIncomingMessage) + { + jfcIncomingMessage.setCurrentDirectory( + Mailbox.getIncomingMessageDirectory()); + int returnVal = jfcIncomingMessage.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) + { + File file = jfcIncomingMessage.getSelectedFile(); + jtfIncomingMessage.setText(file.toString()); + } + } + else if (e.getSource() == jbtnOutgoingMessage) + { + jfcOutgoingMessage.setCurrentDirectory( + Mailbox.getOutgoingMessageFileLocation()); + int returnVal = jfcOutgoingMessage.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) + { + File file = jfcOutgoingMessage.getSelectedFile(); + jtfIncomingMessage.setText(file.toString()); + } + + } + else if (e.getSource() == jbtnConfirm) + { + config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, + (Integer)jsMaxMessageTime.getValue()); + config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, + (Integer)jsWaitTime.getValue()); + config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, + jtfIncomingMessage.getText()); + config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, + jtfOutgoingMessage.getText()); + JOptionPane.showMessageDialog(this, "Values Set!"); + } + else if (e.getSource() == jbtnDefault) + { + int choice = JOptionPane.showConfirmDialog(this, + "OK to reset all values to default?", + "Set Defaults?", JOptionPane.YES_NO_OPTION); + if (choice == JOptionPane.YES_OPTION) + { + //reset all values to null and then let Mailbox plug in the defaults + config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, + null); + config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, + null); + config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, + null); + config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, + null); + config.setProperty(Mailbox.MAX_MSG_DURATION_PROPERTY_NAME, + new Integer(Mailbox.getMaxMessageDuration())); + config.setProperty(Mailbox.WAIT_TIME_PROPERTY_NAME, + new Integer(Mailbox.getWaitTime())); + config.setProperty(Mailbox.INCOMING_MESSAGE_PROPERTY_NAME, + Mailbox.getIncomingMessageDirectory()); + config.setProperty(Mailbox.OUTGOING_MESSAGE_PROPERTY_NAME, + Mailbox.getOutgoingMessageFileLocation()); + + //now reset all the GUI elements to the defaults + jtfIncomingMessage.setText(Mailbox + .getIncomingMessageDirectory() + .toString()); + jtfOutgoingMessage.setText(Mailbox + .getOutgoingMessageFileLocation() + .toString()); + jsWaitTime.setValue(new Integer(Mailbox.getWaitTime())); + jsMaxMessageTime.setValue(new Integer( + Mailbox.getMaxMessageDuration())); + } + } + + } +} diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java index 8bdd004..05f468a 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationActivator.java @@ -7,8 +7,8 @@ package net.java.sip.communicator.plugin.notificationconfiguration; import net.java.sip.communicator.service.audionotifier.*; -import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.notification.*; import net.java.sip.communicator.util.*; import org.osgi.framework.*; @@ -35,9 +35,14 @@ public class NotificationConfigurationActivator implements BundleActivator { bundleContext = bc; - bundleContext.registerService( ConfigurationForm.class.getName(), - new NotificationConfigurationForm(), - null); + bundleContext + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.notificationconfiguration.NotificationConfigurationPanel", + getClass().getClassLoader(), + "plugin.notificationconfig.PLUGIN_ICON", + "service.gui.NOTIFICATIONS"), null); logger.trace("Notification Configuration: [ STARTED ]"); } diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationForm.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationForm.java deleted file mode 100644 index fae6a07..0000000 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationForm.java +++ /dev/null @@ -1,57 +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.plugin.notificationconfiguration; - -import net.java.sip.communicator.service.gui.*; - -/** - * Implements the ConfigurationForm interface in order to allow - * integrating the UI of this plug-in into the configuration UI. - *

- * The interface implementation in question is separated from the very UI - * implementation in order to allow the ConfigurationForm to be - * loaded at startup without creating and loading the very UI implementation. - *

- * - * @author Lubomir Marinov - */ -public class NotificationConfigurationForm - implements ConfigurationForm -{ - - /** - * Implements the ConfigurationForm.getForm() method. Returns the - * component corresponding to this configuration form. - */ - public Object getForm() - { - return new NotificationConfigurationPanel(); - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public byte[] getIcon() - { - return Resources.getImageInBytes("plugin.notificationconfig.PLUGIN_ICON"); - } - - public int getIndex() - { - return -1; - } - - /** - * Implements the ConfigurationForm.getTitle() method. Returns the - * title of this configuration form. - */ - public String getTitle() - { - return Resources.getString("service.gui.NOTIFICATIONS"); - } -} \ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java index 72d93a4..c4e01b6 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java @@ -82,8 +82,6 @@ public class NotificationConfigurationPanel public NotificationConfigurationPanel() { - super(); - JPanel actions = new TransparentPanel(); GridBagLayout actionsLayout = new GridBagLayout(); JPanel applyPanel = new TransparentPanel(); diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java b/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java index 8b41029..af2d081 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerActivator.java @@ -33,10 +33,14 @@ public class PluginManagerActivator { bundleContext = bc; - PluginManagerConfigForm pluginManager = new PluginManagerConfigForm(); - - bundleContext.registerService(ConfigurationForm.class.getName(), - pluginManager, null); + bundleContext + .registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + "net.java.sip.communicator.plugin.pluginmanager.PluginManagerPanel", + getClass().getClassLoader(), + "plugin.pluginmanager.PLUGIN_ICON", + "plugin.pluginmanager.PLUGINS"), null); } /** diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerConfigForm.java b/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerConfigForm.java deleted file mode 100644 index 56ee79d..0000000 --- a/src/net/java/sip/communicator/plugin/pluginmanager/PluginManagerConfigForm.java +++ /dev/null @@ -1,46 +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.plugin.pluginmanager; - -import net.java.sip.communicator.service.gui.*; - -/** - * The ConfigurationForm that would be added in the user interface - * configuration window. It contains a list of all installed plug-ins. Allows - * installing new plugins and managing the existing ones. - * - * @author Yana Stamcheva - * @author Lubomir Marinov - */ -public class PluginManagerConfigForm - extends AbstractConfigurationForm -{ - - /** - * Implements the ConfigurationForm.getTitle() method. Returns the - * title of this configuration form. - */ - public String getTitle() - { - return Resources.getString("plugin.pluginmanager.PLUGINS"); - } - - /** - * Implements the ConfigurationForm.getIcon() method. Returns the - * icon of this configuration form. - */ - public byte[] getIcon() - { - return Resources.getResources().getImageInBytes( - "plugin.pluginmanager.PLUGIN_ICON"); - } - - protected String getFormClassName() - { - return "net.java.sip.communicator.plugin.pluginmanager.PluginManagerPanel"; - } -} diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java index afe47ec..29afc33 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java @@ -29,6 +29,7 @@ import org.osgi.framework.*; * accounts are found. * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class InitialAccountRegistrationFrame extends JFrame @@ -179,10 +180,9 @@ public class InitialAccountRegistrationFrame } } - private class AccountRegistrationPanel extends JPanel + private class AccountRegistrationPanel + extends JPanel { - private JLabel protocolLabel = new JLabel(); - private JLabel usernameLabel = new JLabel(Resources.getString("service.gui.LOGIN")); @@ -204,20 +204,8 @@ public class InitialAccountRegistrationFrame private JPanel iconDescriptionPanel = new JPanel(new BorderLayout()); - private JPanel inputRegisterPanel = new JPanel(new BorderLayout()); - private JTextArea descriptionArea = new JTextArea(); - private JLabel signupLabel - = new JLabel("" - + Resources.getString("plugin.simpleaccregwizz.SIGNUP") - + "", JLabel.RIGHT); - - private JLabel specialSignupLabel - = new JLabel("" - + Resources.getString("plugin.simpleaccregwizz.SPECIAL_SIGNUP") - + "", JLabel.RIGHT); - private final AccountRegistrationWizard wizard; public AccountRegistrationPanel( @@ -228,6 +216,9 @@ public class InitialAccountRegistrationFrame this.wizard = accountWizard; + JLabel protocolLabel = new JLabel(); + JPanel inputRegisterPanel = new JPanel(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.setPreferredSize(new Dimension(230, 150)); @@ -238,71 +229,54 @@ public class InitialAccountRegistrationFrame this.labelsPanel.setOpaque(false); this.fieldsPanel.setOpaque(false); this.emptyPanel.setOpaque(false); - this.inputRegisterPanel.setOpaque(false); + inputRegisterPanel.setOpaque(false); this.iconDescriptionPanel.setOpaque(false); this.add(inputRegisterPanel, BorderLayout.CENTER); - this.inputRegisterPanel.add(inputPanel, BorderLayout.NORTH); + inputRegisterPanel.add(inputPanel, BorderLayout.NORTH); if (wizard.isWebSignupSupported()) { - if (isPreferredWizard) + String textKey = + isPreferredWizard ? "plugin.simpleaccregwizz.SPECIAL_SIGNUP" + : "plugin.simpleaccregwizz.SIGNUP"; + JLabel signupLabel = + new JLabel("" + + Resources.getString(textKey) + "", + JLabel.RIGHT); + + signupLabel.setFont(signupLabel.getFont().deriveFont(10f)); + signupLabel.addMouseListener(new MouseAdapter() { - this.inputRegisterPanel.add( - specialSignupLabel, BorderLayout.SOUTH); - } - else - { - this.inputRegisterPanel.add( - signupLabel, BorderLayout.SOUTH); - } - } - - this.inputPanel.add(labelsPanel, BorderLayout.WEST); - - this.inputPanel.add(fieldsPanel, BorderLayout.CENTER); - - this.iconDescriptionPanel.add( - protocolLabel, BorderLayout.NORTH); - - this.signupLabel.setFont(signupLabel.getFont().deriveFont(10f)); - this.signupLabel.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent arg0) + public void mousePressed(MouseEvent e) { try { wizard.webSignup(); } - catch (UnsupportedOperationException e) + catch (UnsupportedOperationException ex) { // This should not happen, because we check if the - // operation is supported, before adding the sign up. - logger.error("The web sign up is not supported.", e); + // operation is supported, before adding the sign + // up. + logger.error("The web sign up is not supported.", + ex); } } }); - this.specialSignupLabel.setFont(signupLabel.getFont().deriveFont(10f)); - this.specialSignupLabel.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent arg0) - { - try - { - wizard.webSignup(); - } - catch (UnsupportedOperationException e) - { - // This should not happen, because we check if the - // operation is supported, before adding the sign up. - logger.error("The web sign up is not supported.", e); - } - } - }); + inputRegisterPanel.add(signupLabel, BorderLayout.SOUTH); + } + + this.inputPanel.add(labelsPanel, BorderLayout.WEST); + + this.inputPanel.add(fieldsPanel, BorderLayout.CENTER); + + this.iconDescriptionPanel.add( + protocolLabel, BorderLayout.NORTH); - this.protocolLabel.setFont( + protocolLabel.setFont( protocolLabel.getFont().deriveFont(Font.BOLD, 14f)); this.usernameExampleLabel.setForeground(Color.DARK_GRAY); this.usernameExampleLabel.setFont( @@ -319,7 +293,7 @@ public class InitialAccountRegistrationFrame this.usernameExampleLabel.setText(wizard.getUserNameExample()); - this.protocolLabel.setText(wizard.getProtocolName()); + protocolLabel.setText(wizard.getProtocolName()); Image image = null; try @@ -418,7 +392,7 @@ public class InitialAccountRegistrationFrame if (event.getType() == ServiceEvent.REGISTERED) { - this.addAccountRegistrationForm(wizard); + this.addAccountRegistrationForm(wizard); } } diff --git a/src/net/java/sip/communicator/service/gui/AbstractConfigurationForm.java b/src/net/java/sip/communicator/service/gui/AbstractConfigurationForm.java deleted file mode 100644 index d4213d6..0000000 --- a/src/net/java/sip/communicator/service/gui/AbstractConfigurationForm.java +++ /dev/null @@ -1,45 +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.service.gui; - -import java.lang.reflect.*; - -/** - * @author Lubomir Marinov - */ -public abstract class AbstractConfigurationForm - implements ConfigurationForm -{ - public Object getForm() - { - Exception exception; - try - { - return Class.forName(getFormClassName(), true, - getClass().getClassLoader()).newInstance(); - } - catch (ClassNotFoundException ex) - { - exception = ex; - } - catch (IllegalAccessException ex) - { - exception = ex; - } - catch (InstantiationException ex) - { - exception = ex; - } - throw new UndeclaredThrowableException(exception); - } - - protected abstract String getFormClassName(); - - public int getIndex() - { - return -1; - } -} diff --git a/src/net/java/sip/communicator/service/gui/ExportedWindow.java b/src/net/java/sip/communicator/service/gui/ExportedWindow.java index c2a4080..87b9168 100644 --- a/src/net/java/sip/communicator/service/gui/ExportedWindow.java +++ b/src/net/java/sip/communicator/service/gui/ExportedWindow.java @@ -27,9 +27,6 @@ public interface ExportedWindow public static final WindowID CHAT_WINDOW = new WindowID("ChatWindow"); - public static final WindowID CONFIGURATION_WINDOW - = new WindowID("ConfigurationWindow"); - public static final WindowID AUTHENTICATION_WINDOW = new WindowID("AuthenticationWindow"); diff --git a/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java new file mode 100644 index 0000000..86ba615 --- /dev/null +++ b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java @@ -0,0 +1,114 @@ +/* + * 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.service.gui; + +import java.lang.reflect.*; + +import net.java.sip.communicator.service.gui.internal.*; +import net.java.sip.communicator.service.resources.*; + +/** + * @author Lubomir Marinov + */ +public class LazyConfigurationForm + implements ConfigurationForm +{ + private static ResourceManagementService resources; + + private static ResourceManagementService getResources() + { + if (resources == null) + resources = + ResourceManagementServiceUtils.getService(GuiServiceActivator + .getBundleContext()); + return resources; + } + + private final ClassLoader formClassLoader; + + private final String formClassName; + + private final String iconID; + + private final int index; + + private final String titleID; + + public LazyConfigurationForm(String formClassName, + ClassLoader formClassLoader, String iconID, String titleID) + { + this(formClassName, formClassLoader, iconID, titleID, -1); + } + + public LazyConfigurationForm(String formClassName, + ClassLoader formClassLoader, String iconID, String titleID, int index) + { + this.formClassName = formClassName; + this.formClassLoader = formClassLoader; + this.iconID = iconID; + this.titleID = titleID; + this.index = index; + } + + public Object getForm() + { + Exception exception; + try + { + return Class + .forName(getFormClassName(), true, getFormClassLoader()) + .newInstance(); + } + catch (ClassNotFoundException ex) + { + exception = ex; + } + catch (IllegalAccessException ex) + { + exception = ex; + } + catch (InstantiationException ex) + { + exception = ex; + } + throw new UndeclaredThrowableException(exception); + } + + protected ClassLoader getFormClassLoader() + { + return formClassLoader; + } + + protected String getFormClassName() + { + return formClassName; + } + + public byte[] getIcon() + { + return getResources().getImageInBytes(getIconID()); + } + + protected String getIconID() + { + return iconID; + } + + public int getIndex() + { + return index; + } + + public String getTitle() + { + return getResources().getI18NString(getTitleID()); + } + + protected String getTitleID() + { + return titleID; + } +} diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index 4120012..01ea702 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -333,4 +333,6 @@ public interface UIService public boolean useMacOSXScreenMenuBar(); public void beginShutdown(); + + public void setConfigurationWindowVisible(boolean visible); } diff --git a/src/net/java/sip/communicator/service/gui/gui.manifest.mf b/src/net/java/sip/communicator/service/gui/gui.manifest.mf index 798546d..2ee336a 100644 --- a/src/net/java/sip/communicator/service/gui/gui.manifest.mf +++ b/src/net/java/sip/communicator/service/gui/gui.manifest.mf @@ -1,7 +1,10 @@ +Bundle-Activator: net.java.sip.communicator.service.gui.internal.GuiServiceActivator Bundle-Name: UI Service Bundle-Description: The User Interface Service. Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes +Import-Package: org.osgi.framework, + net.java.sip.communicator.service.resources Export-Package: net.java.sip.communicator.service.gui, net.java.sip.communicator.service.gui.event diff --git a/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java b/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java new file mode 100644 index 0000000..e9d9fe0 --- /dev/null +++ b/src/net/java/sip/communicator/service/gui/internal/GuiServiceActivator.java @@ -0,0 +1,33 @@ +/* + * 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.service.gui.internal; + +import org.osgi.framework.*; + +/** + * @author Lubomir Marinov + */ +public class GuiServiceActivator + implements BundleActivator +{ + private static BundleContext bundleContext; + + public static BundleContext getBundleContext() + { + return bundleContext; + } + + public void start(BundleContext bundleContext) + { + GuiServiceActivator.bundleContext = bundleContext; + } + + public void stop(BundleContext bundleContext) + { + if (GuiServiceActivator.bundleContext == bundleContext) + GuiServiceActivator.bundleContext = null; + } +} diff --git a/src/net/java/sip/communicator/util/ImageUtils.java b/src/net/java/sip/communicator/util/ImageUtils.java index 0424ba1..ca75768 100644 --- a/src/net/java/sip/communicator/util/ImageUtils.java +++ b/src/net/java/sip/communicator/util/ImageUtils.java @@ -20,22 +20,23 @@ import net.java.sip.communicator.util.swing.*; * * @author Sebastien Mazy * @author Yana Stamcheva + * @author Lubomir Marinov */ public class ImageUtils { private static final Logger logger = Logger.getLogger(ImageUtils.class); /** - * Returns a scaled image fitting within the given bounds - * while keeping the aspect ratio. - * + * Returns a scaled image fitting within the given bounds while keeping the + * aspect ratio. + * * @param image the image to scale * @param width maximum width of the scaled image * @param height maximum height of the scaled image * @return the scaled image */ - public static ImageIcon - scaleIconWithinBounds(Image image, int width, int height) + public static Image scaleImageWithinBounds(Image image, int width, + int height) { Image scaledImage; int scaleHint = Image.SCALE_SMOOTH; @@ -51,8 +52,13 @@ public class ImageUtils { scaledImage = image.getScaledInstance(-1, height, scaleHint); } + return scaledImage; + } - return new ImageIcon(scaledImage); + public static ImageIcon scaleIconWithinBounds(Image image, int width, + int height) + { + return new ImageIcon(scaleImageWithinBounds(image, width, height)); } /** @@ -62,20 +68,16 @@ public class ImageUtils * * @return The rounded corner image. */ - public static ImageIcon getScaledRoundedImage( Image image, - int width, - int height) + public static Image getScaledRoundedImage(Image image, int width, int height) { - BufferedImage destImage = null; - - ImageIcon scaledImage = ImageUtils.scaleIconWithinBounds( image, - width, - height); + ImageIcon scaledImage = + ImageUtils.scaleIconWithinBounds(image, width, height); + int scaledImageWidth = scaledImage.getIconWidth(); + int scaledImageHeight = scaledImage.getIconHeight(); - destImage - = new BufferedImage(scaledImage.getImage().getWidth(null), - scaledImage.getImage().getHeight(null), - BufferedImage.TYPE_INT_ARGB); + BufferedImage destImage = + new BufferedImage(scaledImageWidth, scaledImageHeight, + BufferedImage.TYPE_INT_ARGB); Graphics2D g = destImage.createGraphics(); @@ -84,8 +86,7 @@ public class ImageUtils AntialiasingManager.activateAntialiasing(g); g.setColor(Color.WHITE); - g.fillRoundRect(0, 0, scaledImage.getIconWidth(), scaledImage - .getIconHeight(), 10, 10); + g.fillRoundRect(0, 0, scaledImageWidth, scaledImageHeight, 10, 10); g.setComposite(AlphaComposite.SrcIn); g.drawImage(scaledImage.getImage(), 0, 0, null); @@ -94,8 +95,13 @@ public class ImageUtils { g.dispose(); } + return destImage; + } - return new ImageIcon(destImage); + public static ImageIcon getScaledRoundedIcon(Image image, int width, + int height) + { + return new ImageIcon(getScaledRoundedImage(image, width, height)); } /** @@ -121,7 +127,7 @@ public class ImageUtils InputStream in = new ByteArrayInputStream(imageBytes); BufferedImage image = ImageIO.read(in); - imageIcon = getScaledRoundedImage(image, width, height); + imageIcon = getScaledRoundedIcon(image, width, height); } catch (Exception e) { -- cgit v1.1