Example #1
4
  /**
   * Called to indicate that sending typing notification has failed.
   *
   * @param evt a <tt>TypingNotificationEvent</tt> containing the sender of the notification and its
   *     type.
   */
  public void typingNotificationDeliveryFailed(TypingNotificationEvent evt) {
    if (typingTimer.isRunning()) typingTimer.stop();

    String notificationMsg = "";

    MetaContact metaContact =
        GuiActivator.getContactListService().findMetaContactByContact(evt.getSourceContact());
    String contactName = metaContact.getDisplayName();

    if (contactName.equals("")) {
      contactName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN") + " ";
    }

    ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false);

    notificationMsg =
        GuiActivator.getResources()
            .getI18NString("service.gui.CONTACT_TYPING_SEND_FAILED", new String[] {contactName});

    // Proactive typing notification
    if (!chatWindowManager.isChatOpenedFor(metaContact)) {
      return;
    }

    if (chatPanel != null) chatPanel.addErrorSendingTypingNotification(notificationMsg);

    typingTimer.setMetaContact(metaContact);
    typingTimer.start();
  }
  /** Initializes the <tt>RenameContactDialog</tt> by adding the buttons, fields, etc. */
  private void init() {
    this.setTitle(GuiActivator.getResources().getI18NString("service.gui.RENAME_CONTACT"));

    this.getRootPane().setDefaultButton(renameButton);
    this.renameButton.setName("rename");
    this.cancelButton.setName("cancel");

    this.renameButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.RENAME"));
    this.cancelButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.renameButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.buttonsPanel.add(renameButton);
    this.buttonsPanel.add(cancelButton);

    this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));

    this.mainPanel.add(renameContactPanel, BorderLayout.NORTH);
    this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel);
  }
Example #3
0
  /**
   * Creates an instance of <tt>FileMenu</tt>.
   *
   * @param parentWindow The parent <tt>ChatWindow</tt>.
   */
  public FileMenu(ChatWindow parentWindow) {
    super(GuiActivator.getResources().getI18NString("service.gui.FILE"));

    this.setOpaque(false);

    this.parentWindow = parentWindow;

    this.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.FILE"));

    this.add(myChatRoomsItem);
    this.add(historyItem);

    this.addSeparator();

    this.add(closeMenuItem);

    this.myChatRoomsItem.setName("myChatRooms");
    this.historyItem.setName("history");
    this.closeMenuItem.setName("close");

    this.myChatRoomsItem.addActionListener(this);
    this.historyItem.addActionListener(this);
    this.closeMenuItem.addActionListener(this);

    this.myChatRoomsItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.MY_CHAT_ROOMS"));
    this.historyItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.HISTORY"));
    this.closeMenuItem.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CLOSE"));
  }
Example #4
0
  /** Reloads button resources. */
  public void loadSkin() {
    addButton.setIcon(
        GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON"));
    callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON"));

    if (smsButton != null)
      smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));
  }
  /** Constructs the <tt>AuthenticationWindow</tt>. */
  private void init() {
    this.idValue =
        new JTextField(
            chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID());

    this.infoTextArea.setOpaque(false);
    this.infoTextArea.setLineWrap(true);
    this.infoTextArea.setWrapStyleWord(true);
    this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    this.infoTextArea.setEditable(false);
    this.infoTextArea.setText(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.CHAT_ROOM_REQUIRES_PASSWORD",
                new String[] {chatRoom.getChatRoomName()}));

    this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD));
    this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    this.labelsPanel.add(idLabel);
    this.labelsPanel.add(passwdLabel);

    this.textFieldsPanel.add(idValue);
    this.textFieldsPanel.add(passwdField);

    this.buttonsPanel.add(loginButton);
    this.buttonsPanel.add(cancelButton);

    this.mainPanel.add(infoTextArea, BorderLayout.NORTH);
    this.mainPanel.add(labelsPanel, BorderLayout.WEST);
    this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
    this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");

    this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);

    this.setTransparent(true);
  }
Example #6
0
  /** Initializes the call button. */
  private void initCallButton() {
    List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders();

    if (telephonyProviders != null && telephonyProviders.size() > 0) {
      if (callButton.getParent() != null) return;

      callButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

      callButton.setMnemonic(
          GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT"));

      buttonPanel.add(callButton);

      callButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String searchText = parentWindow.getCurrentSearchText();

              if (searchText == null) return;

              CallManager.createCall(searchText, callButton);
            }
          });
    } else {
      buttonPanel.remove(callButton);
    }
  }
Example #7
0
  /**
   * Creates the buttons panel.
   *
   * @return the buttons panel
   */
  private Component createButtonsPanel() {
    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));

    JButton okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selectedDevice = (MediaDevice) deviceComboBox.getSelectedItem();

            dispose();
          }
        });

    buttonsPanel.add(okButton);

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selectedDevice = null;
            dispose();
          }
        });

    buttonsPanel.add(cancelButton);

    return buttonsPanel;
  }
  /**
   * Creates an instance of the <tt>LoginWindow</tt>.
   *
   * @param chatRoom the chat room for which we're authenticating
   */
  public ChatRoomAuthenticationWindow(ChatRoomWrapper chatRoom) {
    this.chatRoom = chatRoom;

    ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage());

    backgroundPanel = new LoginWindowBackground(logoImage);

    this.backgroundPanel.setPreferredSize(new Dimension(420, 230));

    this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    this.backgroundPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));

    this.getContentPane().setLayout(new BorderLayout());

    this.init();

    this.getContentPane().add(backgroundPanel, BorderLayout.CENTER);

    this.setResizable(false);

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    this.setTitle(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.AUTHENTICATION_WINDOW_TITLE",
                new String[] {chatRoom.getParentProvider().getName()}));

    this.enableKeyActions();
  }
  private String getNickname() {
    String nickName = null;
    ChatOperationReasonDialog reasonDialog =
        new ChatOperationReasonDialog(
            GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"),
            GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL"));

    reasonDialog.setReasonFieldText("");

    int result = reasonDialog.showDialog();

    if (result == MessageDialog.OK_RETURN_CODE) {
      nickName = reasonDialog.getReason().trim();
    }

    return nickName;
  }
Example #10
0
  /**
   * Informs the user what is the typing state of his chat contacts.
   *
   * @param evt the event containing details on the typing notification
   */
  public void typingNotificationReceived(TypingNotificationEvent evt) {
    if (typingTimer.isRunning()) typingTimer.stop();

    String notificationMsg = "";

    MetaContact metaContact =
        GuiActivator.getContactListService().findMetaContactByContact(evt.getSourceContact());
    String contactName = metaContact.getDisplayName() + " ";

    if (contactName.equals("")) {
      contactName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN") + " ";
    }

    int typingState = evt.getTypingState();

    ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false);

    if (typingState == OperationSetTypingNotifications.STATE_TYPING) {
      notificationMsg =
          GuiActivator.getResources()
              .getI18NString("service.gui.CONTACT_TYPING", new String[] {contactName});

      // Proactive typing notification
      if (!chatWindowManager.isChatOpenedFor(metaContact)) {
        return;
      }

      if (chatPanel != null) chatPanel.addTypingNotification(notificationMsg);

      typingTimer.setMetaContact(metaContact);
      typingTimer.start();
    } else if (typingState == OperationSetTypingNotifications.STATE_PAUSED) {
      notificationMsg =
          GuiActivator.getResources()
              .getI18NString("service.gui.CONTACT_PAUSED_TYPING", new String[] {contactName});

      if (chatPanel != null) chatPanel.addTypingNotification(notificationMsg);

      typingTimer.setMetaContact(metaContact);
      typingTimer.start();
    } else {
      if (chatPanel != null) chatPanel.removeTypingNotification();
    }
  }
  /** Loads all images and colors. */
  public void loadSkin() {
    openedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.OPENED_GROUP_ICON));

    closedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.CLOSED_GROUP_ICON));

    callButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL));
    callButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_ROLLOVER));
    callButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_PRESSED));

    chatButton.setIconImage(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL));
    chatButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_ROLLOVER));
    chatButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_PRESSED));

    msgReceivedImage = ImageLoader.getImage(ImageLoader.MESSAGE_RECEIVED_ICON);

    int groupForegroundProperty =
        GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_GROUP_FOREGROUND");

    if (groupForegroundProperty > -1) groupForegroundColor = new Color(groupForegroundProperty);

    int contactForegroundProperty =
        GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_CONTACT_FOREGROUND");

    if (contactForegroundProperty > -1)
      contactForegroundColor = new Color(contactForegroundProperty);

    callVideoButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL));
    callVideoButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_ROLLOVER));
    callVideoButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_PRESSED));

    desktopSharingButton.setIconImage(ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL));
    desktopSharingButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_ROLLOVER));
    desktopSharingButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_PRESSED));

    addContactButton.setIconImage(ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL));
    addContactButton.setRolloverIcon(
        ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_ROLLOVER));
    addContactButton.setPressedIcon(
        ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_PRESSED));
  }
Example #12
0
  /** Sets the names of the call buttons depending on the chat session type. */
  private void setCallButtonsName() {
    if (chatSession instanceof ConferenceChatSession) {
      callButton.setName("createConference");
      callVideoButton.setName("createConference");
      this.callButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE"));

      this.callVideoButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE"));
    } else {
      callButton.setName("call");
      callVideoButton.setName("callVideo");
      this.callButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

      this.callVideoButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    }
  }
Example #13
0
  /**
   * Updates the text area to take into account the new search text.
   *
   * @param searchText the search text to update
   */
  private void updateTextArea(String searchText) {
    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'}));

      this.revalidate();
      this.repaint();
    }
  }
Example #14
0
  /**
   * The handler for the security event received. The security event for starting establish a secure
   * connection.
   *
   * @param evt the security started event received
   */
  public void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent evt) {
    if (Boolean.parseBoolean(
        GuiActivator.getResources().getSettingsString("impl.gui.PARANOIA_UI"))) {
      SrtpControl srtpControl = null;
      if (callPeer instanceof MediaAwareCallPeer) srtpControl = evt.getSecurityController();

      securityPanel = new ParanoiaTimerSecurityPanel<SrtpControl>(srtpControl);

      setSecurityPanelVisible(true);
    }
  }
Example #15
0
  /** Initializes the call button. */
  private void initSMSButton() {
    if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return;

    smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS"));

    smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));

    buttonPanel.add(smsButton);

    smsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final String searchText = parentWindow.getCurrentSearchText();

            if (searchText == null) return;

            SMSManager.sendSMS(smsButton, searchText);
          }
        });
  }
Example #16
0
  /** Constructs the <tt>SearchPanel</tt>. */
  private void init() {
    String searchString = GuiActivator.getResources().getI18NString("service.gui.SEARCH");
    JLabel searchLabel = new JLabel(searchString + ": ");

    searchButton =
        new JButton(searchString, new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));

    this.searchTextField.getDocument().addDocumentListener(this);

    this.add(searchLabel, BorderLayout.WEST);
    this.add(searchTextField, BorderLayout.CENTER);

    searchButton.setName("search");
    searchButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.SEARCH"));

    searchButton.addActionListener(this);

    this.historyWindow.getRootPane().setDefaultButton(searchButton);

    this.add(searchButton, BorderLayout.EAST);
  }
Example #17
0
  /**
   * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window.
   *
   * @param window the parent window
   */
  public UnknownContactPanel(MainFrame window) {
    super(new BorderLayout());

    this.parentWindow = window;

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());

    this.add(mainPanel, BorderLayout.NORTH);

    if (!ConfigurationUtils.isAddContactDisabled()) {
      initAddContactButton();
    }

    initCallButton();

    initSMSButton();

    initTextArea();
    mainPanel.add(textArea, BorderLayout.CENTER);

    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND",
                  new String[] {'"' + parentWindow.getCurrentSearchText() + '"'}));
    } else {
      textArea.setText(
          GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT"));
    }

    if (buttonPanel.getComponentCount() > 0) {
      TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(buttonPanel);

      mainPanel.add(southPanel, BorderLayout.SOUTH);
    }

    loadSkin();
  }
  /**
   * Creates an instance of <tt>ChatRoomConfigurationWindow</tt> and initializes the configuration
   * form.
   *
   * @param chatRoomName the name of the room
   * @param configForm the configuration form to load in this configuration window
   */
  public ChatRoomConfigurationWindow(String chatRoomName, ChatRoomConfigurationForm configForm) {
    super(false);

    this.configForm = configForm;

    this.setTitle(
        GuiActivator.getResources()
            .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION", new String[] {chatRoomName}));

    titlePanel.setTitleText(
        GuiActivator.getResources().getI18NString("service.gui.CHAT_ROOM_OPTIONS"));

    this.generalScrollPane.setPreferredSize(new Dimension(820, 520));
    this.generalScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    this.generalScrollPane.setOpaque(false);
    this.generalScrollPane.getViewport().setOpaque(false);

    this.mainPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));

    this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    this.saveButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.buttonsPanel.add(saveButton);
    this.buttonsPanel.add(cancelButton);

    this.generalScrollPane.getViewport().add(mainPanel);

    this.getContentPane().add(titlePanel, BorderLayout.NORTH);
    this.getContentPane().add(generalScrollPane, BorderLayout.CENTER);
    this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);

    titlePanel.setOpaque(false);
    buttonsPanel.setOpaque(false);
    mainPanel.setOpaque(false);
    generalScrollPane.setOpaque(false);

    this.loadConfigurationForm();
  }
Example #19
0
  private void initSmiliesSelectorBox() {
    this.smileysBox = new SmileysSelectorBox();

    this.smileysBox.setName("smiley");
    this.smileysBox.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M");

    SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar();
    smileyMenuBar.setOpaque(false);
    smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
    smileyMenuBar.add(smileysBox);

    this.add(smileyMenuBar);
  }
  /** Inializes button tool tips. */
  private void initButtonToolTips() {
    callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL"));
    desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP"));
    chatButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE"));
    addContactButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT"));

    // We need to explicitly remove the buttons from the tooltip manager,
    // because we're going to manager the tooltip ourselves in the
    // DefaultTreeContactList class. We need to do this in order to have
    // a different tooltip for every button and for non button area.
    ToolTipManager ttManager = ToolTipManager.sharedInstance();
    ttManager.unregisterComponent(callButton);
    ttManager.unregisterComponent(callVideoButton);
    ttManager.unregisterComponent(desktopSharingButton);
    ttManager.unregisterComponent(chatButton);
    ttManager.unregisterComponent(addContactButton);
  }
  /**
   * Creates a new <tt>JMenuItem</tt> and adds it to this <tt>JPopupMenu</tt>.
   *
   * @param textKey the key of the internationalized string in the resources of the application
   *     which represents the text of the new <tt>JMenuItem</tt>
   * @param iconID the <tt>ImageID</tt> of the image in the resources of the application which
   *     represents the icon of the new <tt>JMenuItem</tt>
   * @param name the name of the new <tt>JMenuItem</tt>
   * @return a new <tt>JMenuItem</tt> instance which has been added to this <tt>JPopupMenu</tt>
   */
  private JMenuItem createMenuItem(String textKey, ImageID iconID, String name) {
    ResourceManagementService resources = GuiActivator.getResources();
    JMenuItem menuItem =
        new JMenuItem(
            resources.getI18NString(textKey), new ImageIcon(ImageLoader.getImage(iconID)));

    menuItem.setMnemonic(resources.getI18nMnemonic(textKey));
    menuItem.setName(name);

    menuItem.addActionListener(this);

    add(menuItem);

    return menuItem;
  }
Example #22
0
  /** Reloads icons. */
  public void loadSkin() {
    boolean fullScreen = this.callContainer.isFullScreen();

    setIconImage(
        ImageLoader.getImage(
            fullScreen
                ? ImageLoader.EXIT_FULL_SCREEN_BUTTON
                : ImageLoader.ENTER_FULL_SCREEN_BUTTON));
    setPreferredSize(new Dimension(44, 38));
    setToolTipText(
        GuiActivator.getResources()
            .getI18NString(
                fullScreen
                    ? "service.gui.EXIT_FULL_SCREEN_TOOL_TIP"
                    : "service.gui.ENTER_FULL_SCREEN_TOOL_TIP"));
  }
Example #23
0
  private void initAddContactButton() {
    addButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

    addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT"));

    buttonPanel.add(addButton);

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AddContactDialog dialog = new AddContactDialog(parentWindow);

            dialog.setContactAddress(parentWindow.getCurrentSearchText());
            dialog.setVisible(true);
          }
        });
  }
Example #24
0
  /**
   * Shows a warning message to the user when message delivery has failed.
   *
   * @param evt the event containing details on the message delivery failure
   */
  public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) {
    logger.error(evt.getReason());

    String errorMsg = null;

    Message sourceMessage = (Message) evt.getSource();

    Contact sourceContact = evt.getDestinationContact();

    MetaContact metaContact =
        GuiActivator.getContactListService().findMetaContactByContact(sourceContact);

    if (evt.getErrorCode() == MessageDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED) {
      errorMsg =
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.MSG_DELIVERY_NOT_SUPPORTED",
                  new String[] {sourceContact.getDisplayName()});
    } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.NETWORK_FAILURE) {
      errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_NOT_DELIVERED");
    } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.PROVIDER_NOT_REGISTERED) {
      errorMsg =
          GuiActivator.getResources().getI18NString("service.gui.MSG_SEND_CONNECTION_PROBLEM");
    } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.INTERNAL_ERROR) {
      errorMsg =
          GuiActivator.getResources().getI18NString("service.gui.MSG_DELIVERY_INTERNAL_ERROR");
    } else {
      errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_DELIVERY_ERROR");
    }

    String reason = evt.getReason();
    if (reason != null)
      errorMsg +=
          " "
              + GuiActivator.getResources()
                  .getI18NString("service.gui.ERROR_WAS", new String[] {reason});

    ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, sourceContact);

    chatPanel.addMessage(
        sourceContact.getAddress(),
        metaContact.getDisplayName(),
        new Date(),
        Chat.OUTGOING_MESSAGE,
        sourceMessage.getContent(),
        sourceMessage.getContentType(),
        sourceMessage.getMessageUID(),
        evt.getCorrectedMessageUID());

    chatPanel.addErrorMessage(metaContact.getDisplayName(), errorMsg);

    chatWindowManager.openChat(chatPanel, false);
  }
Example #25
0
  /**
   * When a sent message is delivered shows it in the chat conversation panel.
   *
   * @param evt the event containing details on the message delivery
   */
  public void messageDelivered(MessageDeliveredEvent evt) {
    Contact contact = evt.getDestinationContact();
    MetaContact metaContact =
        GuiActivator.getContactListService().findMetaContactByContact(contact);

    if (logger.isTraceEnabled())
      logger.trace("MESSAGE DELIVERED to contact: " + contact.getAddress());

    ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false);

    if (chatPanel != null) {
      Message msg = evt.getSourceMessage();
      ProtocolProviderService protocolProvider = contact.getProtocolProvider();

      if (logger.isTraceEnabled())
        logger.trace(
            "MESSAGE DELIVERED: process message to chat for contact: "
                + contact.getAddress()
                + " MESSAGE: "
                + msg.getContent());

      chatPanel.addMessage(
          this.mainFrame.getAccountAddress(protocolProvider),
          this.mainFrame.getAccountDisplayName(protocolProvider),
          evt.getTimestamp(),
          Chat.OUTGOING_MESSAGE,
          msg.getContent(),
          msg.getContentType(),
          msg.getMessageUID(),
          evt.getCorrectedMessageUID());

      if (evt.isSmsMessage() && !ConfigurationUtils.isSmsNotifyTextDisabled()) {
        chatPanel.addMessage(
            contact.getDisplayName(),
            new Date(),
            Chat.ACTION_MESSAGE,
            GuiActivator.getResources().getI18NString("service.gui.SMS_SUCCESSFULLY_SENT"),
            "text");
      }
    }
  }
  /**
   * Shows the appropriate user interface that would allow the user to add the given
   * <tt>SourceUIContact</tt> to their contact list.
   *
   * @param contact the contact to add
   */
  private void addContact(SourceUIContact contact) {
    SourceContact sourceContact = (SourceContact) contact.getDescriptor();

    List<ContactDetail> details =
        sourceContact.getContactDetails(OperationSetPersistentPresence.class);
    int detailsCount = details.size();

    if (detailsCount > 1) {
      JMenuItem addContactMenu =
          TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor());

      JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();

      // Add a title label.
      JLabel infoLabel = new JLabel();
      infoLabel.setText(
          "<html><b>"
              + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")
              + "</b></html>");

      popupMenu.insert(infoLabel, 0);
      popupMenu.insert(new Separator(), 1);

      popupMenu.setFocusable(true);
      popupMenu.setInvoker(treeContactList);

      Point location =
          new Point(
              addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight());

      SwingUtilities.convertPointToScreen(location, treeContactList);

      location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;

      popupMenu.setLocation(location.x + 8, location.y - 8);
      popupMenu.setVisible(true);
    } else if (details.size() == 1) {
      TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName());
    }
  }
Example #27
0
  /**
   * Creates an instance of <tt>ShowPreviewDialog</tt>
   *
   * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog.
   */
  ShowPreviewDialog(final ChatConversationPanel chatPanel) {
    this.chatPanel = chatPanel;

    this.setTitle(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE"));
    okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));
    cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));

    JPanel mainPanel = new TransparentPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    // mainPanel.setPreferredSize(new Dimension(200, 150));
    this.getContentPane().add(mainPanel);

    JTextPane descriptionMsg = new JTextPane();
    descriptionMsg.setEditable(false);
    descriptionMsg.setOpaque(false);
    descriptionMsg.setText(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION"));

    Icon warningIcon = null;
    try {
      warningIcon =
          new ImageIcon(
              ImageIO.read(
                  GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON")));
    } catch (IOException e) {
      logger.debug("failed to load the warning icon");
    }
    JLabel warningSign = new JLabel(warningIcon);

    JPanel warningPanel = new TransparentPanel();
    warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS));
    warningPanel.add(warningSign);
    warningPanel.add(Box.createHorizontalStrut(10));
    warningPanel.add(descriptionMsg);

    enableReplacement =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS"));
    enableReplacement.setOpaque(false);
    enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
    enableReplacementProposal =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL"));
    enableReplacementProposal.setOpaque(false);

    JPanel checkBoxPanel = new TransparentPanel();
    checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
    checkBoxPanel.add(enableReplacement);
    checkBoxPanel.add(enableReplacementProposal);

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    mainPanel.add(warningPanel);
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(checkBoxPanel);
    mainPanel.add(buttonsPanel);

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    this.setPreferredSize(new Dimension(390, 230));
  }
/**
 * The <tt>ChatRoomAuthenticationWindow</tt> is the the authentication window for chat rooms that
 * require password.
 *
 * @author Yana Stamcheva
 * @author Adam Netocny
 */
public class ChatRoomAuthenticationWindow extends SIPCommFrame
    implements ActionListener, Skinnable {
  private JTextArea infoTextArea = new JTextArea();

  private JLabel idLabel =
      new JLabel(GuiActivator.getResources().getI18NString("service.gui.IDENTIFIER"));

  private JLabel passwdLabel =
      new JLabel(GuiActivator.getResources().getI18NString("service.gui.PASSWORD"));

  private JTextField idValue;

  private JPasswordField passwdField = new JPasswordField(15);

  private JButton loginButton =
      new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));

  private JButton cancelButton =
      new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));

  private JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

  private JPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

  private JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));

  private JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

  private LoginWindowBackground backgroundPanel;

  private ChatRoomWrapper chatRoom;

  /**
   * Creates an instance of the <tt>LoginWindow</tt>.
   *
   * @param chatRoom the chat room for which we're authenticating
   */
  public ChatRoomAuthenticationWindow(ChatRoomWrapper chatRoom) {
    this.chatRoom = chatRoom;

    ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage());

    backgroundPanel = new LoginWindowBackground(logoImage);

    this.backgroundPanel.setPreferredSize(new Dimension(420, 230));

    this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    this.backgroundPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));

    this.getContentPane().setLayout(new BorderLayout());

    this.init();

    this.getContentPane().add(backgroundPanel, BorderLayout.CENTER);

    this.setResizable(false);

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    this.setTitle(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.AUTHENTICATION_WINDOW_TITLE",
                new String[] {chatRoom.getParentProvider().getName()}));

    this.enableKeyActions();
  }

  /** Constructs the <tt>AuthenticationWindow</tt>. */
  private void init() {
    this.idValue =
        new JTextField(
            chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID());

    this.infoTextArea.setOpaque(false);
    this.infoTextArea.setLineWrap(true);
    this.infoTextArea.setWrapStyleWord(true);
    this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    this.infoTextArea.setEditable(false);
    this.infoTextArea.setText(
        GuiActivator.getResources()
            .getI18NString(
                "service.gui.CHAT_ROOM_REQUIRES_PASSWORD",
                new String[] {chatRoom.getChatRoomName()}));

    this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD));
    this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    this.labelsPanel.add(idLabel);
    this.labelsPanel.add(passwdLabel);

    this.textFieldsPanel.add(idValue);
    this.textFieldsPanel.add(passwdField);

    this.buttonsPanel.add(loginButton);
    this.buttonsPanel.add(cancelButton);

    this.mainPanel.add(infoTextArea, BorderLayout.NORTH);
    this.mainPanel.add(labelsPanel, BorderLayout.WEST);
    this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
    this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

    this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");

    this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);

    this.setTransparent(true);
  }

  /**
   * Sets transparent background to all components in the login window, because of the nonwhite
   * background.
   *
   * @param transparent <code>true</code> to set a transparent background, <code>false</code>
   *     otherwise.
   */
  private void setTransparent(boolean transparent) {
    this.mainPanel.setOpaque(!transparent);
    this.labelsPanel.setOpaque(!transparent);
    this.textFieldsPanel.setOpaque(!transparent);
    this.buttonsPanel.setOpaque(!transparent);
  }

  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is choosen installs a new account from the user input and logs in.
   *
   * @param evt the action event that has just occurred.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("ok")) {
      GuiActivator.getUIService()
          .getConferenceChatManager()
          .joinChatRoom(
              chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes());
    }

    this.dispose();
  }

  /**
   * The <tt>LoginWindowBackground</tt> is a <tt>JPanel</tt> that overrides the <code>paintComponent
   * </code> method to provide a custom background image for this window.
   */
  private static class LoginWindowBackground extends JPanel {
    private ImageIcon bgImage;

    public LoginWindowBackground(ImageIcon bgImage) {
      this.bgImage = bgImage;
    }

    /**
     * Sets background image.
     *
     * @param bgImage Background image.
     */
    public void setBgImage(ImageIcon bgImage) {
      this.bgImage = bgImage;
    }

    @Override
    protected void paintComponent(Graphics g) {
      super.paintComponent(g);

      g = g.create();
      try {
        AntialiasingManager.activateAntialiasing(g);

        Graphics2D g2 = (Graphics2D) g;

        if (bgImage != null) g2.drawImage(bgImage.getImage(), 30, 30, null);

        g2.drawImage(
            ImageLoader.getImage(ImageLoader.AUTH_WINDOW_BACKGROUND),
            0,
            0,
            this.getWidth(),
            this.getHeight(),
            null);
      } finally {
        g.dispose();
      }
    }
  }

  /** Enables the actions when a key is pressed, for now closes the window when esc is pressed. */
  private void enableKeyActions() {

    UIAction act =
        new UIAction() {
          public void actionPerformed(ActionEvent e) {
            ChatRoomAuthenticationWindow.this.setVisible(false);
          }
        };

    getRootPane().getActionMap().put("close", act);

    InputMap imap = this.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
  }

  @Override
  protected void close(boolean isEscaped) {
    this.cancelButton.doClick();
  }

  /**
   * Shows this modal dialog.
   *
   * @param isVisible specifies whether we should be showing or hiding the window.
   */
  @Override
  public void setVisible(boolean isVisible) {
    this.pack();

    super.setVisible(isVisible);

    if (isVisible) {
      this.passwdField.requestFocus();
    }
  }

  /** Reloads logo image. */
  public void loadSkin() {
    ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage());

    backgroundPanel.setBgImage(logoImage);
  }
}
Example #29
0
  /** Initializes this component. */
  protected void init() {
    this.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    this.setOpaque(false);

    this.add(inviteButton);

    // if we leave a chat room when we close the window
    // there is no need for this button
    if (!ConfigurationUtils.isLeaveChatRoomOnWindowCloseEnabled()) this.add(leaveChatRoomButton);

    this.add(callButton);
    this.add(callVideoButton);
    this.add(desktopSharingButton);
    this.add(sendFileButton);

    ChatPanel chatPanel = chatContainer.getCurrentChat();
    if (chatPanel == null || !(chatPanel.getChatSession() instanceof MetaContactChatSession))
      sendFileButton.setEnabled(false);

    this.addSeparator();

    this.add(historyButton);
    this.add(previousButton);
    this.add(nextButton);

    // We only add the options button if the property SHOW_OPTIONS_WINDOW
    // specifies so or if it's not set.
    Boolean showOptionsProp =
        GuiActivator.getConfigurationService()
            .getBoolean(ConfigurationFrame.SHOW_OPTIONS_WINDOW_PROPERTY, false);

    if (showOptionsProp.booleanValue()) {
      this.add(optionsButton);
    }

    this.addSeparator();

    if (ConfigurationUtils.isFontSupportEnabled()) {
      this.add(fontButton);
      fontButton.setName("font");
      fontButton.setToolTipText(
          GuiActivator.getResources().getI18NString("service.gui.CHANGE_FONT"));
      fontButton.addActionListener(this);
    }

    initSmiliesSelectorBox();

    this.addSeparator();

    this.inviteButton.setName("invite");
    this.inviteButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.INVITE"));

    this.leaveChatRoomButton.setName("leave");
    this.leaveChatRoomButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.LEAVE"));

    this.callButton.setName("call");
    this.callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

    this.callVideoButton.setName("callVideo");
    this.callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));

    this.desktopSharingButton.setName("desktop");
    this.desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP_WITH_CONTACT"));

    this.historyButton.setName("history");
    this.historyButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.HISTORY") + " Ctrl-H");

    optionsButton.setName("options");
    optionsButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.OPTIONS"));

    this.sendFileButton.setName("sendFile");
    this.sendFileButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_FILE"));

    this.previousButton.setName("previous");
    this.previousButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.PREVIOUS"));

    this.nextButton.setName("next");
    this.nextButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.NEXT"));

    inviteButton.addActionListener(this);
    leaveChatRoomButton.addActionListener(this);
    callButton.addActionListener(this);
    callVideoButton.addActionListener(this);
    desktopSharingButton.addActionListener(this);
    historyButton.addActionListener(this);
    optionsButton.addActionListener(this);
    sendFileButton.addActionListener(this);
    previousButton.addActionListener(this);
    nextButton.addActionListener(this);
  }
  /** Initializes the <tt>NewStatusMessageDialog</tt> by adding the buttons, fields, etc. */
  private void init() {
    JLabel messageLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    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"));

    this.getRootPane().setDefaultButton(okButton);

    this.setPreferredSize(new Dimension(500, 200));

    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    infoArea.setWrapStyleWord(true);
    infoArea.setOpaque(false);

    dataPanel.add(messageLabel, BorderLayout.WEST);

    messageTextField.setText(presenceOpSet.getCurrentStatusMessage());
    dataPanel.add(messageTextField, BorderLayout.CENTER);

    infoTitleLabel.setHorizontalAlignment(JLabel.CENTER);
    infoTitleLabel.setFont(infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f));

    labelsPanel.add(infoTitleLabel);
    labelsPanel.add(infoArea);
    labelsPanel.add(dataPanel);

    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(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON)),
        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);

    okButton.setName("ok");
    cancelButton.setName("cancel");

    okButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    cancelButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    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);
  }