/** 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);
    }
  }
Exemple #2
0
  /**
   * Handles the <tt>ActionEvent</tt> which occurred when user clicks the Search button.
   *
   * @param e the <tt>ActionEvent</tt> that notified us of the button click
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    String buttonName = button.getName();

    if (buttonName.equalsIgnoreCase("search")) {
      historyWindow.showHistoryByKeyword(searchTextField.getText());
    }
  }
  /** 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"));
  }
  /**
   * Handles the <tt>ActionEvent</tt>. In order to change the status message with the new one calls
   * the <tt>PublishStatusMessageThread</tt>.
   *
   * @param e the event that notified us of the action
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    String name = button.getName();

    if (name.equals("ok")) {
      new PublishStatusMessageThread(messageTextField.getText()).start();
    }

    this.dispose();
  }
  /**
   * 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();
  }
  /**
   * Calls the given treeNode.
   *
   * @param treeNode the <tt>TreeNode</tt> to call
   */
  private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) {
    if (!(treeNode instanceof ContactNode)) return;

    UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor();

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

    SwingUtilities.convertPointToScreen(location, treeContactList);

    location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;
    location.x += 8;
    location.y -= 8;

    CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location);
  }
  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);
          }
        });
  }
  /**
   * 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();
    }
  }
Exemple #9
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);
  }
  /** 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);
          }
        });
  }
  /**
   * Resets the rollover state of all rollover components in the current cell except the component
   * given as a parameter.
   *
   * @param excludeComponent the component to exclude from the reset
   */
  public void resetRolloverState(Component excludeComponent) {
    if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false);

    if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false);

    if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false);

    if (!desktopSharingButton.equals(excludeComponent))
      desktopSharingButton.getModel().setRollover(false);

    if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false);

    if (customActionButtons != null) {
      Iterator<JButton> buttonsIter = customActionButtons.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }

    if (customActionButtonsUIGroup != null) {
      Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }
  }
  /**
   * Handles buttons action events.
   *
   * @param evt the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent evt) {
    JButton sourceButton = (JButton) evt.getSource();

    if (sourceButton.equals(openFileButton)) {
      this.openFile(downloadFile);
    } else if (sourceButton.equals(openFolderButton)) {
      try {
        File downloadDir = GuiActivator.getFileAccessService().getDefaultDownloadDirectory();

        GuiActivator.getDesktopService().open(downloadDir);
      } catch (IllegalArgumentException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (NullPointerException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (UnsupportedOperationException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FILE_OPEN_NOT_SUPPORTED"));
      } catch (SecurityException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_PERMISSION"));
      } catch (IOException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_APPLICATION"));
      } catch (Exception e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open file.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_FAILED"));
      }
    } else if (sourceButton.equals(cancelButton)) {
      if (fileTransfer != null) fileTransfer.cancel();
    }
  }
  /** Resets the rollover state of all rollover components in the current cell. */
  public void resetRolloverState() {
    chatButton.getModel().setRollover(false);
    callButton.getModel().setRollover(false);
    callVideoButton.getModel().setRollover(false);
    desktopSharingButton.getModel().setRollover(false);
    addContactButton.getModel().setRollover(false);

    if (customActionButtons != null) {
      Iterator<JButton> buttonsIter = customActionButtons.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();
        button.getModel().setRollover(false);
      }
    }

    if (customActionButtonsUIGroup != null) {
      Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();
        button.getModel().setRollover(false);
      }
    }
  }
  /**
   * 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();
  }
Exemple #15
0
 /** Reloads search button icon. */
 public void loadSkin() {
   searchButton.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));
 }
  /** 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);
  }
 /**
  * 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) {
   if (isEscaped) cancelButton.doClick();
 }
 /** Clicks the call contact button in order to call the unknown contact. */
 public void startCall() {
   callButton.doClick();
 }
 /** Clicks the add contact button in order to add the unknown contact to the contact list. */
 public void addUnknownContact() {
   addButton.doClick();
 }