From d438d334d73235e7c18172df353646b27b4f00ab Mon Sep 17 00:00:00 2001 From: Alan Kelly Date: Fri, 6 Feb 2009 19:33:34 +0000 Subject: [PATCH] Resolve Issue 519 and minor cosmetic changes to NewStatusMessageDialog --- resources/languages/resources.properties | 1 + .../message/NewStatusMessageDialog.java | 1 + .../impl/systray/NewStatusMessageDialog.java | 105 +++++++++++------- .../impl/systray/SystrayActivator.java | 34 +++++- 4 files changed, 99 insertions(+), 42 deletions(-) diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index a52e0ca83..f6426c96b 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -206,6 +206,7 @@ service.gui.NEW=&New service.gui.NEW_ACCOUNT=Add &new account service.gui.NEW_MESSAGE=New message service.gui.NEW_NAME=New name +service.gui.NEW_STATUS_MESSAGE=New status message service.gui.NO=No service.gui.NO_AVAILABLE_ROOMS=The list of rooms for this server is currently not available. service.gui.NO_MESSAGE=No message diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/message/NewStatusMessageDialog.java b/src/net/java/sip/communicator/impl/gui/main/presence/message/NewStatusMessageDialog.java index 277c1f91e..3bc5994c1 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/message/NewStatusMessageDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/message/NewStatusMessageDialog.java @@ -86,6 +86,7 @@ private void init() this.infoArea.setEditable(false); this.infoArea.setLineWrap(true); this.infoArea.setWrapStyleWord(true); + this.infoArea.setOpaque(false); this.dataPanel.add(messageLabel, BorderLayout.WEST); diff --git a/src/net/java/sip/communicator/impl/systray/NewStatusMessageDialog.java b/src/net/java/sip/communicator/impl/systray/NewStatusMessageDialog.java index 59fda0503..801b7babd 100644 --- a/src/net/java/sip/communicator/impl/systray/NewStatusMessageDialog.java +++ b/src/net/java/sip/communicator/impl/systray/NewStatusMessageDialog.java @@ -27,37 +27,31 @@ public class NewStatusMessageDialog { private Logger logger = Logger.getLogger(NewStatusMessageDialog.class); - private JPanel messagePanel = new TransparentPanel(new BorderLayout()); - private JLabel messageLabel = new JLabel( - Resources.getString("service.gui.NEW_STATUS_MESSAGE")); + SystrayActivator.getResources().getI18NString( + "service.gui.NEW_STATUS_MESSAGE")); private JTextField messageTextField = new JTextField(); private JPanel dataPanel = new TransparentPanel(new BorderLayout(5, 5)); - private JTextArea infoLabel = new JTextArea( - Resources.getString("service.gui.STATUS_MESSAGE_INFO")); + private JTextArea infoArea = new JTextArea( + SystrayActivator.getResources().getI18NString( + "service.gui.STATUS_MESSAGE_INFO")); private JLabel infoTitleLabel = new JLabel( - Resources.getString("service.gui.NEW_STATUS_MESSAGE")); - - private JLabel iconLabel = new JLabel( - Resources.getImage("newStatusMessageIcon")); + SystrayActivator.getResources().getI18NString( + "service.gui.NEW_STATUS_MESSAGE")); private JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); - private JPanel rightPanel = new TransparentPanel(new BorderLayout()); - - private JButton okButton = new JButton(Resources.getString("service.gui.OK")); + private JButton okButton + = new JButton(SystrayActivator.getResources().getI18NString("service.gui.OK")); private JButton cancelButton = new JButton( - Resources.getString("service.gui.CANCEL")); + SystrayActivator.getResources().getI18NString("service.gui.CANCEL")); - private JPanel buttonsPanel = - new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); - - private JPanel mainPanel = new TransparentPanel(new BorderLayout()); + private JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); private ProtocolProviderService protocolProvider; @@ -70,9 +64,8 @@ public NewStatusMessageDialog (ProtocolProviderService protocolProvider) { this.protocolProvider = protocolProvider; - this.setSize(new Dimension(520, 270)); - this.init(); + pack(); } /** @@ -81,15 +74,17 @@ public NewStatusMessageDialog (ProtocolProviderService protocolProvider) */ private void init() { - this.setTitle(Resources.getString("service.gui.NEW_STATUS_MESSAGE")); + this.setTitle(SystrayActivator.getResources() + .getI18NString("service.gui.NEW_STATUS_MESSAGE")); this.getRootPane().setDefaultButton(okButton); this.setPreferredSize(new Dimension(500, 200)); - this.iconLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); - - this.infoLabel.setEditable(false); + this.infoArea.setEditable(false); + this.infoArea.setLineWrap(true); + this.infoArea.setWrapStyleWord(true); + this.infoArea.setOpaque(false); this.dataPanel.add(messageLabel, BorderLayout.WEST); @@ -100,19 +95,36 @@ private void init() infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f)); this.labelsPanel.add(infoTitleLabel); - this.labelsPanel.add(infoLabel); + this.labelsPanel.add(infoArea); this.labelsPanel.add(dataPanel); - this.rightPanel.add(labelsPanel, BorderLayout.NORTH); - - this.messagePanel.add(iconLabel, BorderLayout.WEST); - this.messagePanel.add(rightPanel, BorderLayout.CENTER); + JPanel messagePanel = new TransparentPanel(new GridBagLayout()); + GridBagConstraints messagePanelConstraints = new GridBagConstraints(); + messagePanelConstraints.anchor = GridBagConstraints.NORTHWEST; + messagePanelConstraints.fill = GridBagConstraints.NONE; + messagePanelConstraints.gridx = 0; + messagePanelConstraints.gridy = 0; + messagePanelConstraints.insets = new Insets(5, 0, 5, 10); + messagePanelConstraints.weightx = 0; + messagePanelConstraints.weighty = 0; + messagePanel + .add(new ImageCanvas(Resources + .getImage("service.gui.icons.RENAME_DIALOG_ICON").getImage()), + messagePanelConstraints); + messagePanelConstraints.anchor = GridBagConstraints.NORTH; + messagePanelConstraints.fill = GridBagConstraints.HORIZONTAL; + messagePanelConstraints.gridx = 1; + messagePanelConstraints.insets = new Insets(0, 0, 0, 0); + messagePanelConstraints.weightx = 1; + messagePanel.add(labelsPanel, messagePanelConstraints); this.okButton.setName("ok"); this.cancelButton.setName("cancel"); - this.okButton.setMnemonic(Resources.getMnemonic("service.gui.OK")); - this.cancelButton.setMnemonic(Resources.getMnemonic("cancel")); + this.okButton.setMnemonic( + SystrayActivator.getResources().getI18nMnemonic("service.gui.OK")); + this.cancelButton.setMnemonic( + SystrayActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); this.okButton.addActionListener(this); this.cancelButton.addActionListener(this); @@ -120,10 +132,23 @@ private void init() this.buttonsPanel.add(okButton); this.buttonsPanel.add(cancelButton); - this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10)); - - this.mainPanel.add(messagePanel, BorderLayout.NORTH); - this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); + JPanel mainPanel = new TransparentPanel(new GridBagLayout()); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10)); + + GridBagConstraints mainPanelConstraints = new GridBagConstraints(); + mainPanelConstraints.anchor = GridBagConstraints.NORTH; + mainPanelConstraints.fill = GridBagConstraints.BOTH; + mainPanelConstraints.gridx = 0; + mainPanelConstraints.gridy = 0; + mainPanelConstraints.weightx = 1; + mainPanelConstraints.weighty = 1; + mainPanel.add(messagePanel, mainPanelConstraints); + mainPanelConstraints.anchor = GridBagConstraints.SOUTHEAST; + mainPanelConstraints.fill = GridBagConstraints.NONE; + mainPanelConstraints.gridy = 1; + mainPanelConstraints.weightx = 0; + mainPanelConstraints.weighty = 0; + mainPanel.add(buttonsPanel, mainPanelConstraints); this.getContentPane().add(mainPanel); } @@ -154,13 +179,8 @@ public void requestFocusInFiled() this.messageTextField.requestFocus(); } - protected void close(boolean isEscaped) - { - cancelButton.doClick(); - } - /** - * This class allow to use a thread to change the presence status. + * This class allow to use a thread to change the presence status message. */ private class PublishStatusMessageThread extends Thread { @@ -229,4 +249,9 @@ else if (e1.getErrorCode() } } } + + protected void close(boolean isEscaped) + { + cancelButton.doClick(); + } } diff --git a/src/net/java/sip/communicator/impl/systray/SystrayActivator.java b/src/net/java/sip/communicator/impl/systray/SystrayActivator.java index f9e77dbd0..6704f7ebb 100644 --- a/src/net/java/sip/communicator/impl/systray/SystrayActivator.java +++ b/src/net/java/sip/communicator/impl/systray/SystrayActivator.java @@ -9,6 +9,7 @@ import net.java.sip.communicator.impl.systray.jdic.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.systray.*; import net.java.sip.communicator.util.*; @@ -31,6 +32,8 @@ public class SystrayActivator private static ConfigurationService configService; + private static ResourceManagementService resourcesService; + private static final Logger logger = Logger.getLogger(SystrayActivator.class); @@ -40,7 +43,8 @@ public class SystrayActivator * @param bc The execution context of the bundle being started. * @throws Exception If */ - public void start(BundleContext bc) throws Exception + public void start(BundleContext bc) + throws Exception { bundleContext = bc; @@ -74,7 +78,9 @@ public void start(BundleContext bc) throws Exception * listeners, unregister all services registered by the bundle, and * release all services used by the bundle. */ - public void stop(BundleContext bc) throws Exception { + public void stop(BundleContext bc) + throws Exception + { } @@ -116,4 +122,28 @@ public static UIService getUIService() return uiService; } + + /** + * Returns the ResourceManagementService, through which we will + * access all resources. + * + * @return the ResourceManagementService, through which we will + * access all resources. + */ + public static ResourceManagementService getResources() + { + if (resourcesService == null) + { + ServiceReference serviceReference = bundleContext + .getServiceReference(ResourceManagementService.class.getName()); + + if(serviceReference == null) + return null; + + resourcesService = (ResourceManagementService) bundleContext + .getService(serviceReference); + } + + return resourcesService; + } }