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 3bc5994c1..9b8a1f053 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 @@ -19,7 +19,7 @@ /** * The NewStatusMessageDialog is the dialog containing the form for - * changing the status message. + * changing the status message for a protocol provider. * * @author Yana Stamcheva */ @@ -27,35 +27,26 @@ public class NewStatusMessageDialog extends SIPCommDialog implements ActionListener { - private Logger logger = Logger.getLogger(NewStatusMessageDialog.class); - - private JLabel messageLabel = new JLabel( - GuiActivator.getResources().getI18NString( - "service.gui.NEW_STATUS_MESSAGE")); - - private JTextField messageTextField = new JTextField(); - - private JPanel dataPanel = new TransparentPanel(new BorderLayout(5, 5)); - - private JTextArea infoArea = new JTextArea( - GuiActivator.getResources().getI18NString( - "service.gui.STATUS_MESSAGE_INFO")); - - private JLabel infoTitleLabel = new JLabel( - GuiActivator.getResources().getI18NString( - "service.gui.NEW_STATUS_MESSAGE")); - - private JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); + /** + * The Object used for logging. + */ + private final Logger logger = Logger.getLogger(NewStatusMessageDialog.class); - private JButton okButton - = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); + /** + * The field, containing the status message. + */ + private final JTextField messageTextField = new JTextField(); - private JButton cancelButton = new JButton( + /** + * The button, used to cancel this dialog. + */ + private final JButton cancelButton = new JButton( GuiActivator.getResources().getI18NString("service.gui.CANCEL")); - private JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); - - private ProtocolProviderService protocolProvider; + /** + * The presence operation set through which we change the status message. + */ + private final OperationSetPresence presenceOpSet; /** * Creates an instance of NewStatusMessageDialog. @@ -64,18 +55,45 @@ public class NewStatusMessageDialog */ public NewStatusMessageDialog (ProtocolProviderService protocolProvider) { - this.protocolProvider = protocolProvider; + presenceOpSet + = (OperationSetPersistentPresence) protocolProvider + .getOperationSet(OperationSetPresence.class); this.init(); pack(); } - + /** * Initializes the NewStatusMessageDialog by adding the buttons, * fields, etc. */ private void init() { + JLabel messageLabel = new JLabel( + GuiActivator.getResources().getI18NString( + "service.gui.NEW_STATUS_MESSAGE")); + + JTextField messageTextField = new JTextField(); + + JPanel dataPanel + = new TransparentPanel(new BorderLayout(5, 5)); + + JTextArea infoArea = new JTextArea( + GuiActivator.getResources().getI18NString( + "service.gui.STATUS_MESSAGE_INFO")); + + JLabel infoTitleLabel = new JLabel( + GuiActivator.getResources().getI18NString( + "service.gui.NEW_STATUS_MESSAGE")); + + JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); + + JButton okButton = new JButton(GuiActivator.getResources() + .getI18NString("service.gui.OK")); + + JPanel buttonsPanel + = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); + this.setTitle(GuiActivator.getResources() .getI18NString("service.gui.NEW_STATUS_MESSAGE")); @@ -83,22 +101,23 @@ private void init() this.setPreferredSize(new Dimension(500, 200)); - this.infoArea.setEditable(false); - this.infoArea.setLineWrap(true); - this.infoArea.setWrapStyleWord(true); - this.infoArea.setOpaque(false); + infoArea.setEditable(false); + infoArea.setLineWrap(true); + infoArea.setWrapStyleWord(true); + infoArea.setOpaque(false); - this.dataPanel.add(messageLabel, BorderLayout.WEST); + dataPanel.add(messageLabel, BorderLayout.WEST); - this.dataPanel.add(messageTextField, BorderLayout.CENTER); + messageTextField.setText(presenceOpSet.getCurrentStatusMessage()); + dataPanel.add(messageTextField, BorderLayout.CENTER); - this.infoTitleLabel.setHorizontalAlignment(JLabel.CENTER); - this.infoTitleLabel.setFont( + infoTitleLabel.setHorizontalAlignment(JLabel.CENTER); + infoTitleLabel.setFont( infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f)); - this.labelsPanel.add(infoTitleLabel); - this.labelsPanel.add(infoArea); - this.labelsPanel.add(dataPanel); + labelsPanel.add(infoTitleLabel); + labelsPanel.add(infoArea); + labelsPanel.add(dataPanel); JPanel messagePanel = new TransparentPanel(new GridBagLayout()); GridBagConstraints messagePanelConstraints = new GridBagConstraints(); @@ -113,6 +132,7 @@ private void init() .add(new ImageCanvas(ImageLoader .getImage(ImageLoader.RENAME_DIALOG_ICON)), messagePanelConstraints); + messagePanelConstraints.anchor = GridBagConstraints.NORTH; messagePanelConstraints.fill = GridBagConstraints.HORIZONTAL; messagePanelConstraints.gridx = 1; @@ -120,19 +140,19 @@ private void init() messagePanelConstraints.weightx = 1; messagePanel.add(labelsPanel, messagePanelConstraints); - this.okButton.setName("ok"); - this.cancelButton.setName("cancel"); + okButton.setName("ok"); + cancelButton.setName("cancel"); - this.okButton.setMnemonic( + okButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.OK")); - this.cancelButton.setMnemonic( + cancelButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); - this.okButton.addActionListener(this); - this.cancelButton.addActionListener(this); + okButton.addActionListener(this); + cancelButton.addActionListener(this); - this.buttonsPanel.add(okButton); - this.buttonsPanel.add(cancelButton); + buttonsPanel.add(okButton); + buttonsPanel.add(cancelButton); JPanel mainPanel = new TransparentPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10)); @@ -145,6 +165,7 @@ private void init() mainPanelConstraints.weightx = 1; mainPanelConstraints.weighty = 1; mainPanel.add(messagePanel, mainPanelConstraints); + mainPanelConstraints.anchor = GridBagConstraints.SOUTHEAST; mainPanelConstraints.fill = GridBagConstraints.NONE; mainPanelConstraints.gridy = 1; @@ -158,6 +179,7 @@ private void init() /** * Handles the ActionEvent. In order to change the status message * with the new one calls the PublishStatusMessageThread. + * @param e the event that notified us of the action */ public void actionPerformed(ActionEvent e) { @@ -176,7 +198,7 @@ public void actionPerformed(ActionEvent e) * Requests the focus in the text field contained in this * dialog. */ - public void requestFocusInFiled() + public void requestFocusInField() { this.messageTextField.requestFocus(); } @@ -190,16 +212,10 @@ private class PublishStatusMessageThread extends Thread private PresenceStatus currentStatus; - private OperationSetPresence presenceOpSet; - public PublishStatusMessageThread(String message) { this.message = message; - presenceOpSet - = (OperationSetPersistentPresence) protocolProvider - .getOperationSet(OperationSetPresence.class); - this.currentStatus = presenceOpSet.getPresenceStatus(); } @@ -252,8 +268,13 @@ else if (e1.getErrorCode() } } + /** + * Artificially clicks the cancel button when this panel is escaped. + * @param isEscaped indicates if this dialog is closed by the Esc shortcut + */ protected void close(boolean isEscaped) { - cancelButton.doClick(); + if (isEscaped) + cancelButton.doClick(); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/message/StatusMessageMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/message/StatusMessageMenu.java index 76905c83e..6a0721743 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/message/StatusMessageMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/message/StatusMessageMenu.java @@ -93,7 +93,7 @@ public void actionPerformed(ActionEvent e) dialog.setVisible(true); - dialog.requestFocusInFiled(); + dialog.requestFocusInField(); } else if (menuItem.equals(busyMessageItem)) { diff --git a/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java b/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java index a99cb9f62..525a9bb79 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java @@ -29,6 +29,8 @@ public class ExtendedTooltip private final JPanel linesPanel = new JPanel(); + private final JLabel bottomLabel = new JLabel(); + private int textWidth = 0; private int textHeight = 0; @@ -46,7 +48,7 @@ public ExtendedTooltip(boolean isListViewEnabled) this.setLayout(new BorderLayout()); - JPanel mainPanel = new JPanel(new BorderLayout(5, 5)); + JPanel mainPanel = new JPanel(new BorderLayout(5, 0)); JPanel centerPanel = new JPanel(new BorderLayout()); mainPanel.setOpaque(false); @@ -73,6 +75,9 @@ public ExtendedTooltip(boolean isListViewEnabled) mainPanel.add(titleLabel, BorderLayout.NORTH); } + bottomLabel.setFont(bottomLabel.getFont().deriveFont(10f)); + mainPanel.add(bottomLabel, BorderLayout.SOUTH); + this.add(mainPanel); } @@ -135,6 +140,15 @@ public void addLine(ImageIcon icon, textHeight += textRowHeight; } + /** + * Sets the text that would appear on the bottom of the tooltip. + * @param text the text to set + */ + public void setBottomText(String text) + { + this.bottomLabel.setText(text); + } + /** * Customized UI for this MetaContactTooltip. */ @@ -180,6 +194,10 @@ public Dimension getPreferredSize(JComponent c) else height = imageHeight + textHeight; + if (bottomLabel.getText() != null + && bottomLabel.getText().length() > 0) + height += textRowHeight; + return new Dimension(width, height); } }