Some space added between the icon and the text.

cusax-fix
Yana Stamcheva 16 years ago
parent ef671f022d
commit 3e7d4e3f80

@ -24,108 +24,109 @@
*/
public class AuthorizationRequestedDialog
extends SIPCommDialog
implements ActionListener {
implements ActionListener
{
public static final int ACCEPT_CODE = 0;
public static final int REJECT_CODE = 1;
public static final int IGNORE_CODE = 2;
public static final int ERROR_CODE = -1;
private JTextArea infoTextArea = new JTextArea();
private JEditorPane requestPane = new JEditorPane();
private JPanel buttonsPanel =
new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
private JPanel northPanel = new TransparentPanel(new BorderLayout());
private JPanel northPanel = new TransparentPanel(new BorderLayout(10, 0));
private JPanel titlePanel = new TransparentPanel(new GridLayout(0, 1));
private JLabel titleLabel = new JLabel();
private JLabel iconLabel = new JLabel(new ImageIcon(
ImageLoader.getImage(ImageLoader.AUTHORIZATION_ICON)));
private JButton acceptButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.ACCEPT"));
private JButton rejectButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.REJECT"));
private JButton ignoreButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.IGNORE"));
private JScrollPane requestScrollPane = new JScrollPane();
private JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel reasonsPanel =
new TransparentPanel(new GridLayout(0, 1, 5, 5));
private String title
= GuiActivator.getResources()
.getI18NString("service.gui.AUTHORIZATION_REQUESTED");
private Object lock = new Object();
private int result;
/**
* Constructs the <tt>RequestAuthorisationDialog</tt>.
*
*
* @param mainFrame the main application window
* @param contact The <tt>Contact</tt>, which requires authorisation.
* @param request The <tt>AuthorizationRequest</tt> that will be sent.
*/
public AuthorizationRequestedDialog(MainFrame mainFrame, Contact contact,
AuthorizationRequest request) {
AuthorizationRequest request)
{
super(mainFrame);
this.setModal(false);
this.setTitle(title);
titleLabel.setHorizontalAlignment(JLabel.CENTER);
titleLabel.setText(title);
Font font = titleLabel.getFont();
titleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize2D() + 6));
infoTextArea.setText(
GuiActivator.getResources().getI18NString(
"service.gui.AUTHORIZATION_REQUESTED_INFO",
new String[]{contact.getDisplayName()}));
this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
this.infoTextArea.setLineWrap(true);
this.infoTextArea.setWrapStyleWord(true);
this.infoTextArea.setOpaque(false);
this.infoTextArea.setEditable(false);
this.titlePanel.add(titleLabel);
this.titlePanel.add(infoTextArea);
this.northPanel.add(iconLabel, BorderLayout.WEST);
this.northPanel.add(titlePanel, BorderLayout.CENTER);
if(request.getReason() != null && !request.getReason().equals(""))
{
this.requestScrollPane.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3, 3, 3, 3),
SIPCommBorders.getBoldRoundBorder()));
this.requestPane.setEditable(false);
this.requestPane.setOpaque(false);
this.requestPane.setText(request.getReason());
this.requestScrollPane.getViewport().add(requestPane);
this.reasonsPanel.add(requestScrollPane);
this.mainPanel.setPreferredSize(new Dimension(550, 300));
}
else {
@ -167,7 +168,7 @@ public AuthorizationRequestedDialog(MainFrame mainFrame, Contact contact,
public int showDialog()
{
this.setVisible(true);
synchronized (lock)
{
try
@ -179,38 +180,52 @@ public int showDialog()
e.printStackTrace();
}
}
return result;
}
/**
* Handles the <tt>ActionEvent</tt> triggered when one user clicks
* on one of the buttons.
*
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
String name = button.getName();
if (name.equals("service.gui.ACCEPT")) {
if (name.equals("service.gui.ACCEPT"))
{
this.result = ACCEPT_CODE;
}
else if (name.equals("reject")) {
else if (name.equals("reject"))
{
this.result = REJECT_CODE;
}
else if (name.equals("ignore")) {
else if (name.equals("ignore"))
{
this.result = IGNORE_CODE;
}
else {
else
{
this.result = ERROR_CODE;
}
synchronized (lock) {
}
synchronized (lock)
{
lock.notify();
}
this.dispose();
}
/**
* Invoked when the window is closed.
*
* @param isEscaped indicates if the window was closed by pressing the Esc
* key
*/
protected void close(boolean isEscaped)
{
this.ignoreButton.doClick();

@ -19,11 +19,18 @@
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
public class AuthorizationResponseDialog extends SIPCommDialog
implements ActionListener {
/**
* The <tt>AuthorizationResponseDialog</tt> is the dialog shown when we receive
* a reply for an authorization request.
*
* @author Yana Stamcheva
*/
public class AuthorizationResponseDialog
extends SIPCommDialog
implements ActionListener
{
private JTextArea infoTextArea = new JTextArea();
private JTextArea responseArea = new JTextArea();
private JPanel buttonsPanel =
@ -31,120 +38,136 @@ public class AuthorizationResponseDialog extends SIPCommDialog
private JButton okButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.OK"));
private JScrollPane responseScrollPane = new JScrollPane();
private JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel northPanel = new TransparentPanel(new BorderLayout());
private JPanel northPanel = new TransparentPanel(new BorderLayout(10, 0));
private JLabel iconLabel = new JLabel(new ImageIcon(
ImageLoader.getImage(ImageLoader.AUTHORIZATION_ICON)));
private JPanel titlePanel = new TransparentPanel(new GridLayout(0, 1));
private JLabel titleLabel = new JLabel();
private String title
= GuiActivator.getResources()
.getI18NString("service.gui.AUTHORIZATION_RESPONSE");
/**
* Constructs the <tt>RequestAuthorisationDialog</tt>.
*
*
* @param mainFrame the main application window
* @param contact The <tt>Contact</tt>, which requires authorisation.
* @param response The <tt>AuthorizationResponse</tt> that has been
* received.
*/
public AuthorizationResponseDialog(MainFrame mainFrame, Contact contact,
AuthorizationResponse response) {
public AuthorizationResponseDialog( MainFrame mainFrame,
Contact contact,
AuthorizationResponse response)
{
super(mainFrame);
this.setModal(false);
this.setTitle(title);
titleLabel.setHorizontalAlignment(JLabel.CENTER);
titleLabel.setText(title);
Font font = titleLabel.getFont();
titleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize2D() + 6));
this.mainPanel.setPreferredSize(new Dimension(400, 250));
AuthorizationResponse.AuthorizationResponseCode responseCode
= response.getResponseCode();
if(responseCode.equals(AuthorizationResponse.ACCEPT)) {
if(responseCode.equals(AuthorizationResponse.ACCEPT))
{
infoTextArea.setText(contact.getDisplayName() + " "
+ GuiActivator.getResources().getI18NString(
"service.gui.AUTHORIZATION_ACCEPTED"));
}
else if(responseCode.equals(AuthorizationResponse.REJECT)) {
else if(responseCode.equals(AuthorizationResponse.REJECT))
{
infoTextArea.setText(contact.getDisplayName() + " "
+ GuiActivator.getResources()
.getI18NString("service.gui.AUTHENTICATION_REJECTED"));
}
if(response.getReason() != null && !response.getReason().equals("")) {
this.responseScrollPane.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3, 3, 3, 3),
SIPCommBorders.getBoldRoundBorder()));
if(response.getReason() != null && !response.getReason().equals(""))
{
this.responseScrollPane.setBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3, 3, 3, 3),
SIPCommBorders.getBoldRoundBorder()));
this.responseArea.setText(response.getReason());
this.responseArea.setLineWrap(true);
this.responseArea.setWrapStyleWord(true);
this.responseArea.setEditable(false);
this.responseArea.setOpaque(false);
this.responseScrollPane.getViewport().add(responseArea);
this.mainPanel.add(responseScrollPane, BorderLayout.CENTER);
this.mainPanel.setPreferredSize(new Dimension(400, 250));
}
else {
else
{
this.mainPanel.setPreferredSize(new Dimension(400, 180));
}
this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
this.infoTextArea.setLineWrap(true);
this.infoTextArea.setWrapStyleWord(true);
this.infoTextArea.setEditable(false);
this.infoTextArea.setOpaque(false);
this.titlePanel.add(titleLabel);
this.titlePanel.add(infoTextArea);
this.northPanel.add(iconLabel, BorderLayout.WEST);
this.northPanel.add(titlePanel, BorderLayout.CENTER);
this.okButton.requestFocus();
this.okButton.setName("ok");
this.okButton.setMnemonic(
GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
this.getRootPane().setDefaultButton(okButton);
this.okButton.addActionListener(this);
this.buttonsPanel.add(okButton);
this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.mainPanel.add(northPanel, BorderLayout.NORTH);
this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
this.getContentPane().add(mainPanel);
}
/**
* Handles the <tt>ActionEvent</tt> triggered when one user clicks
* on one of the buttons.
*
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e)
{
this.dispose();
}
/**
* Invoked when the window is closed.
*
* @param isEscaped indicates if the window was closed by pressing the Esc
* key
*/
protected void close(boolean isEscaped)
{
this.dispose();

@ -29,15 +29,15 @@ public class RequestAuthorizationDialog
implements ActionListener
{
public static final int OK_RETURN_CODE = 1;
public static final int CANCEL_RETURN_CODE = 0;
private JTextArea infoTextArea = new JTextArea();
private JLabel requestLabel = new JLabel(
GuiActivator.getResources()
.getI18NString("service.gui.TYPE_YOUR_REQUEST") + ": ");
private JTextField requestField = new JTextField();
private JPanel requestPanel = new TransparentPanel(new BorderLayout());
@ -47,142 +47,153 @@ public class RequestAuthorizationDialog
private String cancelString
= GuiActivator.getResources().getI18NString("service.gui.CANCEL");
private JButton requestButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.REQUEST"));
private JButton cancelButton = new JButton(cancelString);
private JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
private JPanel northPanel = new TransparentPanel(new BorderLayout());
private JPanel northPanel = new TransparentPanel(new BorderLayout(10, 0));
private JPanel titlePanel = new TransparentPanel(new GridLayout(0, 1));
private JLabel iconLabel = new JLabel(new ImageIcon(
ImageLoader.getImage(ImageLoader.AUTHORIZATION_ICON)));
private JLabel titleLabel = new JLabel();
private String title = GuiActivator.getResources()
.getI18NString("service.gui.REQUEST_AUTHORIZATION");
private Object lock = new Object();
private int returnCode;
/**
* Constructs the <tt>RequestAuthorisationDialog</tt>.
*
*
* @param mainFrame the main application window
* @param contact The <tt>Contact</tt>, which requires authorisation.
* @param request The <tt>AuthorizationRequest</tt> that will be sent.
*/
public RequestAuthorizationDialog(MainFrame mainFrame, Contact contact,
AuthorizationRequest request)
public RequestAuthorizationDialog( MainFrame mainFrame,
Contact contact,
AuthorizationRequest request)
{
super(mainFrame);
this.setModal(false);
this.setTitle(title);
titleLabel.setHorizontalAlignment(JLabel.CENTER);
titleLabel.setText(title);
Font font = titleLabel.getFont();
titleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize2D() + 6));
this.mainPanel.setPreferredSize(new Dimension(400, 230));
infoTextArea.setText(GuiActivator.getResources().getI18NString(
"service.gui.REQUEST_AUTHORIZATION_MSG",
new String[]{contact.getDisplayName()}));
this.infoTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD, 12f));
this.infoTextArea.setLineWrap(true);
this.infoTextArea.setOpaque(false);
this.infoTextArea.setWrapStyleWord(true);
this.infoTextArea.setEditable(false);
this.titlePanel.add(titleLabel);
this.titlePanel.add(infoTextArea);
this.northPanel.add(iconLabel, BorderLayout.WEST);
this.northPanel.add(titlePanel, BorderLayout.CENTER);
this.requestPanel.add(requestLabel, BorderLayout.WEST);
this.requestPanel.add(requestField, BorderLayout.CENTER);
this.requestButton.setName("request");
this.cancelButton.setName("cancel");
this.requestButton.addActionListener(this);
this.cancelButton.addActionListener(this);
this.buttonsPanel.add(requestButton);
this.buttonsPanel.add(cancelButton);
this.getRootPane().setDefaultButton(requestButton);
this.requestButton.setMnemonic(
GuiActivator.getResources().getI18nMnemonic("service.gui.REQUEST"));
this.cancelButton.setMnemonic(
GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));
this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.mainPanel.add(northPanel, BorderLayout.NORTH);
this.mainPanel.add(requestPanel, BorderLayout.CENTER);
this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
this.getContentPane().add(mainPanel);
}
/**
* Shows this modal dialog and returns the result of the user choice.
*
* @return if the "Request" button was pressed returns OK_RETURN_CODE,
* otherwise CANCEL_RETURN_CODE is returned
*/
public int showDialog()
{
this.setVisible(true);
this.requestField.requestFocus();
synchronized (lock) {
try {
synchronized (lock)
{
try
{
lock.wait();
}
catch (InterruptedException e) {
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return returnCode;
}
/**
* Handles the <tt>ActionEvent</tt> triggered when one user clicks
* on one of the buttons.
*
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
String name = button.getName();
if(name.equals("request")) {
if(name.equals("request"))
{
returnCode = OK_RETURN_CODE;
}
else if(name.equals("cancel")) {
else if(name.equals("cancel"))
{
returnCode = CANCEL_RETURN_CODE;
}
synchronized (lock) {
synchronized (lock)
{
lock.notify();
}
this.dispose();
}
/**
* The text entered as a resuest reason.
* @return the text entered as a resuest reason
@ -192,8 +203,14 @@ public String getRequestReason()
return requestField.getText();
}
/**
* Invoked when the window is closed.
*
* @param isEscaped indicates if the window was closed by pressing the Esc
* key
*/
protected void close(boolean isEscaped)
{
this.cancelButton.doClick();
}
}
}

Loading…
Cancel
Save