Exemplo n.º 1
0
 /**
  * This method initializes txtLicense
  *
  * @return javax.swing.JTextPane
  */
 private JTextPane getTxtLicense() {
   if (txtLicense == null) {
     txtLicense = new JTextPane();
     txtLicense.setName("txtLicense");
     txtLicense.setEditable(false);
   }
   return txtLicense;
 }
Exemplo n.º 2
0
  /**
   * Creates and initializes the components
   *
   * @param userName The name of the user.
   * @param hostName The default hostName.
   */
  private void initialize(String userName, String hostName) {
    components = new ArrayList<JComponent>();
    // status update.
    currentTask = new JLabel();
    Font newFont = currentTask.getFont().deriveFont(8);
    currentTask.setFont(newFont);
    currentTask.setForeground(ScreenLogin.TEXT_COLOR);
    progressBar = new JProgressBar();
    progressBar.setVisible(false);
    progressBar.setStringPainted(false);
    progressBar.setFont(newFont);

    originalName = userName;
    user = new JTextField();
    user.setName("username field");
    user.setText(userName);
    user.setToolTipText("Enter your username.");
    user.setColumns(TEXT_COLUMN);
    pass = new JPasswordField();
    pass.setName("password field");
    pass.setToolTipText("Enter your password.");
    pass.setColumns(TEXT_COLUMN);
    Map<String, String> servers = editor.getServers();
    if (CommonsLangUtils.isNotBlank(hostName)) {
      serverName = hostName;
      // if user did point to another server
      if (servers != null && servers.size() > 0) {
        int n = servers.size() - 1;
        Iterator<String> i = servers.keySet().iterator();
        int k = 0;
        String value;
        while (i.hasNext()) {
          serverName = i.next();
          if (k == n) {
            value = servers.get(serverName);
            if (value != null) {
              try {
                selectedPort = Integer.parseInt(value);
              } catch (Exception e) {
              }
            }
          }
          k++;
        }
      } else {
        editor.removeLastRow();
        editor.addRow(hostName);
      }
    } else {
      if (servers == null || servers.size() == 0) serverName = hostName;
      else {
        int n = servers.size() - 1;
        Iterator<String> i = servers.keySet().iterator();
        int k = 0;
        String value;
        while (i.hasNext()) {
          serverName = i.next();
          if (k == n) {
            value = servers.get(serverName);
            if (value != null) {
              try {
                selectedPort = Integer.parseInt(value);
              } catch (Exception e) {
              }
            }
          }
          k++;
        }
      }
    }
    if (serverName.length() == 0) serverName = DEFAULT_SERVER;
    if (!DEFAULT_SERVER.equals(serverName)) originalServerName = serverName;
    connectionSpeedText = new JLabel(getConnectionSpeed());
    connectionSpeedText.setForeground(TEXT_COLOR);
    connectionSpeedText.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
    serverText = UIUtilities.buildTextPane(serverName, TEXT_COLOR);
    serverText.setName("server name text pane");

    serverTextPane = UIUtilities.buildComponentPanelRight(serverText, false);
    serverTextPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

    initializeGroups();
    ref = new ArrayList<JComponent>();
    login = new JButton("Login");
    login.setName("login button");
    defaultForeground = login.getForeground();
    login.setMnemonic('L');
    login.setToolTipText("Login");
    setButtonDefault(login);
    login.setEnabled(false);
    // UIUtilities.enterPressesWhenFocused(login);
    UIUtilities.opacityCheck(login);
    cancel = new JButton("Quit");
    cancel.setMnemonic('Q');
    cancel.setToolTipText("Cancel Login.");
    setButtonDefault(cancel);
    UIUtilities.opacityCheck(cancel);
    configButton = new JButton();
    configButton.setName("config server button");
    configButton.setMnemonic('X');
    configButton.setToolTipText("Enter the server's address.");
    configButton.setBorderPainted(false);
    configButton.setBorder(null);
    // configButton.setMargin(new Insets(1, 1, 1, 1));
    configButton.setFocusPainted(false);
    configButton.setContentAreaFilled(false);
    IconManager icons = IconManager.getInstance();
    configButton.setIcon(icons.getIcon(IconManager.CONFIG_24));
    // configButton.setPressedIcon(icons.getIcon(
    //		IconManager.CONFIG_PRESSED_24));

    encrypted = !isEncrypted();
    encryptedButton = new JButton();
    List<String> tips = new ArrayList<String>();
    tips.add("The connection to the server is always encrypted.");
    tips.add(
        "If selected, the data transfer (e.g. annotations, images) " + "will also be encrypted.");
    tips.add("But the transfer will be much slower.");

    encryptedButton.setToolTipText(UIUtilities.formatToolTipText(tips));
    encryptedButton.setBorderPainted(false);
    encryptedButton.setBorder(null);
    encryptedButton.setFocusPainted(false);
    encryptedButton.setContentAreaFilled(false);
    if (encrypted) encryptedButton.setIcon(icons.getIcon(IconManager.ENCRYPTED_24));
    else encryptedButton.setIcon(icons.getIcon(IconManager.DECRYPTED_24));
    getRootPane().setDefaultButton(login);
    enableControls();
  }