Ejemplo n.º 1
0
 /** Update button enable/disable state according enableCheckBox. */
 private void updateButtonsState() {
   sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   fileCountField.setEnabled(enableCheckBox.isSelected());
   fileSizeField.setEnabled(enableCheckBox.isSelected());
   fileSizeLabel.setEnabled(enableCheckBox.isSelected());
   fileCountLabel.setEnabled(enableCheckBox.isSelected());
 }
Ejemplo n.º 2
0
  /**
   * Initializes the icon image.
   *
   * @param icon the icon to show on the left of the window
   */
  private void initIcon(ImageIcon icon) {
    // If an icon isn't provided set the application logo icon by default.
    if (icon == null)
      icon =
          DesktopUtilActivator.getResources().getImage("service.gui.SIP_COMMUNICATOR_LOGO_64x64");

    JLabel iconLabel = new JLabel(icon);

    iconLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    iconLabel.setAlignmentY(Component.TOP_ALIGNMENT);

    JPanel iconPanel = new TransparentPanel(new BorderLayout());
    iconPanel.add(iconLabel, BorderLayout.NORTH);

    getContentPane().add(iconPanel, BorderLayout.WEST);
  }
Ejemplo n.º 3
0
  /**
   * Initializes this authentication window.
   *
   * @param server the server
   * @param isUserNameEditable indicates if the user name is editable
   * @param icon the icon to show on the authentication window
   */
  private void init(
      String userName,
      char[] password,
      String server,
      boolean isUserNameEditable,
      ImageIcon icon,
      String errorMessage) {
    this.server = server;

    initIcon(icon);

    if (!isUserNameEditable) this.uinValue = new JLabel();
    else this.uinValue = new JTextField();

    this.init();

    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    this.enableKeyActions();

    this.setResizable(false);

    /*
     * Workaround for the following bug:
     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4446522
     * Need to pack() the window after it's opened in order to obtain the
     * correct size of our infoTextArea, otherwise window size is wrong and
     * buttons on the south are cut.
     */
    this.addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            pack();
            removeWindowListener(this);
          }
        });

    if (OSUtils.IS_MAC) getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);

    if (userName != null) {
      if (uinValue instanceof JLabel) ((JLabel) uinValue).setText(userName);
      else if (uinValue instanceof JTextField) ((JTextField) uinValue).setText(userName);
    }

    if (password != null) passwdField.setText(new String(password));

    if (errorMessage != null) {
      this.infoTextArea.setForeground(Color.RED);
      this.infoTextArea.setText(errorMessage);
    }
  }
Ejemplo n.º 4
0
  /**
   * Creates the subscribe label.
   *
   * @param linkName the link name
   * @return the newly created subscribe label
   */
  private Component createWebSignupLabel(String linkName, final String linkURL) {
    JLabel subscribeLabel =
        new JLabel("<html><a href=''>" + linkName + "</a></html>", JLabel.RIGHT);

    subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    subscribeLabel.setToolTipText(
        DesktopUtilActivator.getResources()
            .getI18NString("plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
    subscribeLabel.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            try {
              DesktopUtilActivator.getBrowserLauncher().openURL(linkURL);
            } catch (UnsupportedOperationException ex) {
              // This should not happen, because we check if the
              // operation is supported, before adding the sign
              // up.
              logger.error("The web sign up is not supported.", ex);
            }
          }
        });
    return subscribeLabel;
  }
Ejemplo n.º 5
0
  /** Constructs the <tt>LoginWindow</tt>. */
  private void init() {
    String title;

    if (windowTitle != null) title = windowTitle;
    else
      title =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server});

    String text;
    if (windowText != null) text = windowText;
    else
      text =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server});

    String uinText;
    if (usernameLabelText != null) uinText = usernameLabelText;
    else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER");

    String passText;
    if (passwordLabelText != null) passText = passwordLabelText;
    else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD");

    setTitle(title);

    infoTextArea.setEditable(false);
    infoTextArea.setOpaque(false);
    infoTextArea.setLineWrap(true);
    infoTextArea.setWrapStyleWord(true);
    infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    infoTextArea.setText(text);
    infoTextArea.setAlignmentX(0.5f);

    JLabel uinLabel = new JLabel(uinText);
    uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD));

    JLabel passwdLabel = new JLabel(passText);
    passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

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

    labelsPanel.add(uinLabel);
    labelsPanel.add(passwdLabel);

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

    textFieldsPanel.add(uinValue);
    textFieldsPanel.add(passwdField);

    JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2));

    this.rememberPassCheckBox.setOpaque(false);
    this.rememberPassCheckBox.setBorder(null);

    southFieldsPanel.add(rememberPassCheckBox);
    if (signupLink != null && signupLink.length() > 0)
      southFieldsPanel.add(
          createWebSignupLabel(
              DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"),
              signupLink));
    else southFieldsPanel.add(new JLabel());

    boolean allowRememberPassword = true;

    String allowRemPassStr =
        DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD);
    if (allowRemPassStr != null) {
      allowRememberPassword = Boolean.parseBoolean(allowRemPassStr);
    }
    allowRememberPassword =
        DesktopUtilActivator.getConfigurationService()
            .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword);

    setAllowSavePassword(allowRememberPassword);

    JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    JPanel southEastPanel = new TransparentPanel(new BorderLayout());
    southEastPanel.add(buttonPanel, BorderLayout.EAST);

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

    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));

    JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10));
    mainFieldsPanel.add(labelsPanel, BorderLayout.WEST);
    mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER);
    mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH);

    mainPanel.add(infoTextArea, BorderLayout.NORTH);
    mainPanel.add(mainFieldsPanel, BorderLayout.CENTER);
    mainPanel.add(southEastPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel, BorderLayout.EAST);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");
    if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width)
      cancelButton.setPreferredSize(loginButton.getPreferredSize());
    else loginButton.setPreferredSize(cancelButton.getPreferredSize());

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

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

    this.getRootPane().setDefaultButton(loginButton);
  }
Ejemplo n.º 6
0
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }