Example #1
0
  /**
   * <i>Description:</i>
   *
   * <p>see <a href=https://en.wikipedia.org/wiki/Hostname>https://en.wikipedia.org
   * /wiki/Hostname</a> for valid hostname
   *
   * @return
   */
  @SuppressWarnings("unchecked")
  protected JPanel getHostEntryPanel() {
    if (pnlHostEntry == null) {
      pnlHostEntry = new JPanel(new BorderLayout(5, 5));
      pnlHostEntry.setOpaque(false);

      JPanel panel = new JPanel(new GridLayout(1, 2, 10, 5));
      panel.setOpaque(false);
      String hostNameChars = UIConstants.DIGITS + UIConstants.LETTERS + "-.";
      txtFldHostName = new SafeTextField(false, 253);
      ((SafeTextField) txtFldHostName).setValidChars(hostNameChars);
      for (DocumentListener listener : hostInfoListener.getDocumentListeners()) {
        txtFldHostName.getDocument().addDocumentListener(listener);
      }
      FieldPair<JFormattedTextField> fp =
          new FieldPair<JFormattedTextField>(STLConstants.K0051_HOST.getValue(), txtFldHostName);
      panel.add(fp);

      txtFldPortNum =
          new SafeNumberField<Integer>(new DecimalFormat("###"), 0, false, 65535, false);
      // only positive integer
      ((SafeNumberField<Integer>) txtFldPortNum).setValidChars(UIConstants.DIGITS);
      for (DocumentListener listener : hostInfoListener.getDocumentListeners()) {
        txtFldPortNum.getDocument().addDocumentListener(listener);
      }
      txtFldPortNum.setText(STLConstants.K3015_DEFAULT_PORT.getValue());
      fp =
          new FieldPair<JFormattedTextField>(
              STLConstants.K1035_CONFIGURATION_PORT.getValue(), txtFldPortNum);
      panel.add(fp);
      pnlHostEntry.add(panel, BorderLayout.CENTER);

      chkboxSecureConnect =
          ComponentFactory.getIntelCheckBox(STLConstants.K2003_SECURE_CONNECT.getValue());
      chkboxSecureConnect.setFont(UIConstants.H5_FONT.deriveFont(Font.BOLD));
      chkboxSecureConnect.setForeground(UIConstants.INTEL_DARK_GRAY);
      chkboxSecureConnect.setHorizontalAlignment(JLabel.TRAILING);
      chkboxSecureConnect.setSelected(false);
      chkboxSecureConnect.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              hostInfoListener.setDirty();
              boolean isSecureConnect = chkboxSecureConnect.isSelected();
              enableCerts(isSecureConnect);
            }
          });
      pnlHostEntry.add(chkboxSecureConnect, BorderLayout.EAST);
    }
    return pnlHostEntry;
  }