Exemple #1
0
  protected String getFiles(List<InfrastructureFileDescriptor> files) {
    StringBuilder sb = new StringBuilder();
    Set<Map.Entry<String, Setting<String>>> defs = Defaults.getDefaults().entrySet();
    Collections.sort(
        files,
        new Comparator<InfrastructureFileDescriptor>() {

          @Override
          public int compare(InfrastructureFileDescriptor o1, InfrastructureFileDescriptor o2) {
            return o1.toString().compareTo(o2.toString());
          }
        });
    for (InfrastructureFileDescriptor f : files) {
      String path = expandVariables ? f.getFullPath() : f.toString();
      String modified = "";
      String fGetFullPath = removeFileProtocol(f.getFullPath());
      String fGetDefaultFullPath = removeFileProtocol(f.getDefaultFullPath());
      if (!fGetFullPath.equals(fGetDefaultFullPath) && expandVariables) {
        modified = getFormatter().getBold("[" + Translator.R("BUTmodified") + "] ");
      }
      String controlledBy = "";
      for (Map.Entry<String, Setting<String>> entry : defs) {
        if (matchSttingsValueWithInfrastrucutreFile(entry.getValue(), f)) {
          controlledBy =
              " " + Translator.R("BUTControlledBy", getFormatter().getBold(entry.getKey()));

          break;
        }
      }
      sb.append(getFormatter().getOption(path, modified + f.getDescription() + controlledBy));
    }
    return formatter.wrapParagraph(sb.toString());
  }
 public String clean(String s) {
   s = s.replace(Translator.R("MACDisabledMessage"), "");
   s = s.replace(Translator.R("MACCheckSkipped", ".*", ".*"), "");
   s = s.replace(JNLPFile.TITLE_NOT_FOUND, "");
   s = s.replaceAll("Fontconfig warning.*", "");
   return s.replaceAll("\\s*" + JNLPFile.TITLE_NOT_FOUND + "\\s*", "").trim();
 }
Exemple #3
0
 public String getAuthors() {
   if (forceTitles) {
     return getFormatter().getTitle(ManFormatter.KnownSections.AUTHOR)
         + getFormatter()
             .wrapParagraph(
                 getFormatter().process(Translator.R("ITWTBdebug")) + getFormatter().getNewLine());
   } else {
     return getFormatter()
         .wrapParagraph(
             getFormatter().process(Translator.R("ITWTBdebug")) + getFormatter().getNewLine());
   }
 }
  protected void addComponents() {

    // Top label
    String topLabelText =
        "While support for verifying signed code"
            + " has not been implemented yet, some applets will not run "
            + "properly under the default restricted security level.";
    String bottomLabelText =
        "Do you want to run this applet under the "
            + "restricted security level? (clicking No will run this applet "
            + "without any security checking, and should only be done if you "
            + "trust the applet!)";

    JLabel topLabel = new JLabel(htmlWrap(topLabelText));
    topLabel.setFont(new Font(topLabel.getFont().toString(), Font.BOLD, 12));
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBackground(Color.WHITE);
    topPanel.add(topLabel, BorderLayout.CENTER);
    topPanel.setPreferredSize(new Dimension(400, 80));
    topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JLabel bottomLabel = new JLabel(htmlWrap(bottomLabelText));
    JPanel infoPanel = new JPanel(new BorderLayout());
    infoPanel.add(bottomLabel, BorderLayout.CENTER);
    infoPanel.setPreferredSize(new Dimension(400, 80));
    infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // run and cancel buttons
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    JButton yes = new JButton(Translator.R("ButYes"));
    JButton no = new JButton(Translator.R("ButNo"));
    JButton cancel = new JButton(Translator.R("ButCancel"));
    yes.addActionListener(SetValueHandler.createSetValueListener(parent, YesNoCancel.yes()));
    no.addActionListener(SetValueHandler.createSetValueListener(parent, YesNoCancel.no()));
    cancel.addActionListener(SetValueHandler.createSetValueListener(parent, YesNoCancel.cancel()));
    initialFocusComponent = cancel;
    buttonPanel.add(yes);
    buttonPanel.add(no);
    buttonPanel.add(cancel);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // all of the above
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(topPanel);
    add(infoPanel);
    add(buttonPanel);
  }
Exemple #5
0
 protected String getFilesAppendix() {
   if (!expandVariables) {
     return getFormatter().wrapParagraph(Translator.R("ITWTBdirs"));
   } else {
     return "";
   }
 }
  /**
   * Make the button panel.
   *
   * @return the button panel created
   * @see JPanel
   */
  private JPanel createButtonPanel() {
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));

    List<JButton> buttons = new ArrayList<JButton>();

    JButton okButton = new JButton(Translator.R("ButOk"));
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < fields.length; i++) config.setProperty(properties[i], fields[i]);

            parent.dispose();
          }
        });
    buttons.add(okButton);

    JButton cancelButton = new JButton(Translator.R("ButCancel"));
    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            parent.dispose();
          }
        });
    buttons.add(cancelButton);

    int maxWidth = 0;
    int maxHeight = 0;
    for (JButton button : buttons) {
      maxWidth = Math.max(button.getMinimumSize().width, maxWidth);
      maxHeight = Math.max(button.getMinimumSize().height, maxHeight);
    }

    int wantedWidth = maxWidth + 10;
    int wantedHeight = maxHeight;
    for (JButton button : buttons) {
      button.setPreferredSize(new Dimension(wantedWidth, wantedHeight));
      buttonPanel.add(button);
    }

    return buttonPanel;
  }
Exemple #7
0
  public String getBugs() {

    StringBuilder sb = new StringBuilder();
    sb.append(getFormatter().process(Translator.R("ITWTBbugs") + ":"));
    sb.append(getFormatter().getNewLine());
    sb.append(getFormatter().getUrl(ITW_BUGS));
    sb.append(getFormatter().getNewLine());
    sb.append(getFormatter().getUrl(ITW_BUGZILLAHOME));
    sb.append(getFormatter().getNewLine());
    sb.append(getFormatter().getNewLine());
    sb.append(getFormatter().process(Translator.R("ITWTBdebug")));
    sb.append(getFormatter().getNewLine());
    if (forceTitles) {
      return getFormatter().getTitle(ManFormatter.KnownSections.BUGS)
          + getFormatter().wrapParagraph(sb.toString());
    } else {
      return getFormatter().wrapParagraph(sb.toString());
    }
  }
 @Test
 public void testJREversionDontMatchRemoval() {
   Assert.assertTrue(
       removeJreVersionWarning(Translator.R("JREversionDontMatch", "1.8.0-pre.whatever", "{0}"))
           .isEmpty());
   Assert.assertTrue(
       removeJreVersionWarning(Translator.R("JREversionDontMatch", "{0}", "{1}")).isEmpty());
   Assert.assertTrue(
       removeJreVersionWarning(
               Translator.R("JREversionDontMatch", "1.3.0-pre-pac", "1.8.0-pre.whatever}"))
           .isEmpty());
   Assert.assertTrue(
       removeJreVersionWarning(Translator.R("JREversionDontMatch", "", "")).isEmpty());
   Assert.assertTrue(
       removeJreVersionWarning(Translator.R("JREversionDontMatch", " - - - - ", " - - - "))
           .isEmpty());
   Assert.assertFalse(
       removeJreVersionWarning(
               "AA\n" + Translator.R("JREversionDontMatch", "1.3+", "1.7") + "\nBB")
           .equals("AA\nBB"));
 }
public class RemoteApplicationSettings {

  public static final String mustEmpty = "must be empty, was not";
  public static final String stdout = "Stdout";
  public static final String stderr = "Stderr";
  public static final String stdoutEmpty = stdout + " " + mustEmpty;
  public static final String stderrEmpty = stderr + " " + mustEmpty;

  public static URL createCatchedUrl(String r) {
    try {
      return new URL(r);
    } catch (MalformedURLException mex) {
      throw new RuntimeException(mex);
    }
  }

  public interface RemoteApplicationTestcaseSettings {

    public URL getUrl();

    public void evaluate(ProcessResult pr);

    public List<String> modifyParams(List<String> global);
  }

  public abstract static class StringBasedURL implements RemoteApplicationTestcaseSettings {

    URL u;

    public String clean(String s) {
      s = s.replace(Translator.R("MACDisabledMessage"), "");
      s = s.replace(Translator.R("MACCheckSkipped", ".*", ".*"), "");
      s = s.replace(JNLPFile.TITLE_NOT_FOUND, "");
      s = s.replaceAll("Fontconfig warning.*", "");
      return s.replaceAll("\\s*" + JNLPFile.TITLE_NOT_FOUND + "\\s*", "").trim();
    }

    @Override
    public URL getUrl() {
      return u;
    }

    public StringBasedURL(String r) {
      this.u = createCatchedUrl(r);
    }

    @Override
    public List<String> modifyParams(List<String> global) {
      return global;
    }
  }

  public static class FourierTransform extends StringBasedURL {

    public FourierTransform() {
      super(
          "http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/fft1DApp/1d_fast_fourier_transform_java_jnlp.jnlp");
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, clean(pr.stdout).length() == 0);
      Assert.assertTrue(
          clean(pr.stderr).length() == 0
              || pr.stderr.contains(IllegalStateException.class.getName()));
    }
  }

  public static class OrawebCernCh extends StringBasedURL {

    public OrawebCernCh() {
      super("https://oraweb.cern.ch/pls/atlasintegration/docs/EMDH_atlas.jnlp");
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, clean(pr.stdout).length() == 0);
      Assert.assertTrue(
          clean(pr.stderr).length() == 0
              || pr.stderr.contains(
                  "Cannot grant permissions to unsigned jars. Application requested security permissions, but jars are not signed"));
    }

    @Override
    public List<String> modifyParams(List<String> global) {
      List l = new ArrayList(global);
      l.add("-J-Dhttps.protocols=TLSv1,SSLv3,SSLv2Hello");
      return l;
    }
  }

  public static class GnattProject extends StringBasedURL {

    public GnattProject() {
      super(
          "http://ganttproject.googlecode.com/svn/webstart/ganttproject-2.0.10/ganttproject-2.0.10.jnlp");
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdout, clean(pr.stdout).length() == 0);
      Assert.assertTrue(pr.stderr.contains("Splash closed"));
      Assert.assertFalse(pr.stderr.contains("Exception"));
    }
  }

  public static class GeoGebra extends StringBasedURL {

    public GeoGebra() {
      super("http://www.geogebra.org/webstart/geogebra.jnlp");
    }

    @Override
    public void evaluate(ProcessResult pr) {
      // some debug coords are appearing
      Assert.assertTrue(pr.stdout.toLowerCase().contains("geogebra"));
      Assert.assertFalse(pr.stderr.toLowerCase().contains("exception"));
    }
  }

  public abstract static class NoOutputs extends StringBasedURL {

    public NoOutputs(String r) {
      super(r);
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, pr.stdout.length() == 0);
      Assert.assertTrue(stderrEmpty, pr.stderr.length() == 0);
    }
  }

  public abstract static class NearlyNoOutputs extends StringBasedURL {

    public NearlyNoOutputs(String r) {
      super(r);
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, clean(pr.stdout).length() == 0);
      Assert.assertTrue(stderrEmpty, clean(pr.stderr).length() == 0);
    }
  }

  public abstract static class NearlyNoOutputsOnWrongJRE extends NearlyNoOutputs {

    public NearlyNoOutputsOnWrongJRE(String r) {
      super(r);
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, removeJreVersionWarning(clean(pr.stdout)).length() == 0);
      Assert.assertTrue(stderrEmpty, removeJreVersionWarning(clean(pr.stderr)).length() == 0);
    }
  }

  private static final String pattern =
      ".*" + Translator.R("JREversionDontMatch", ".*", ".*") + ".*";

  private static String removeJreVersionWarning(String clean) {
    return clean.replaceAll(pattern, "");
  }

  @Test
  public void testJREversionDontMatchRemoval() {
    Assert.assertTrue(
        removeJreVersionWarning(Translator.R("JREversionDontMatch", "1.8.0-pre.whatever", "{0}"))
            .isEmpty());
    Assert.assertTrue(
        removeJreVersionWarning(Translator.R("JREversionDontMatch", "{0}", "{1}")).isEmpty());
    Assert.assertTrue(
        removeJreVersionWarning(
                Translator.R("JREversionDontMatch", "1.3.0-pre-pac", "1.8.0-pre.whatever}"))
            .isEmpty());
    Assert.assertTrue(
        removeJreVersionWarning(Translator.R("JREversionDontMatch", "", "")).isEmpty());
    Assert.assertTrue(
        removeJreVersionWarning(Translator.R("JREversionDontMatch", " - - - - ", " - - - "))
            .isEmpty());
    Assert.assertFalse(
        removeJreVersionWarning(
                "AA\n" + Translator.R("JREversionDontMatch", "1.3+", "1.7") + "\nBB")
            .equals("AA\nBB"));
  }

  public static class Arbores extends NearlyNoOutputsOnWrongJRE {

    public Arbores() {
      super("http://www.arbores.ca/AnnuityCalc.jnlp");
    }
  }

  public static class PhetSims extends NearlyNoOutputs {

    public PhetSims() {
      super(
          "http://phetsims.colorado.edu/sims/circuit-construction-kit/circuit-construction-kit-dc_en.jnlp");
    }
  }

  public static class TopCoder extends NearlyNoOutputs {

    public TopCoder() {
      super("http://www.topcoder.com/contest/arena/ContestAppletProd.jnlp");
    }
  }

  public static class SunSwingDemo extends StringBasedURL {

    public SunSwingDemo() throws MalformedURLException {
      super(
          "https://docs.oracle.com/javase/tutorialJWS/samples/uiswing/ComponentEventDemoProject/ComponentEventDemo.jnlp");
    }

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertFalse(pr.stdout.contains("Exception"));
      Assert.assertFalse(pr.stdout.contains("Error"));
      Assert.assertFalse(pr.stderr.contains("Exception"));
      Assert.assertFalse(pr.stderr.contains("Error"));
    }
  }

  public static class ArboresDeposit extends NearlyNoOutputsOnWrongJRE {

    public ArboresDeposit() throws MalformedURLException {
      super("http://www.arbores.ca/Deposit.jnlp");
    }
  }

  public static class AviationWeather extends StringBasedURL {

    @Override
    public void evaluate(ProcessResult pr) {
      Assert.assertTrue(stdoutEmpty, clean(pr.stdout).length() == 0);
      Assert.assertTrue(
          clean(pr.stderr).length() == 0
              || (clean(pr.stderr).contains("Cannot read File Manager history data file,")
                  && pr.stderr.contains("FileMgr will be initialized with default options")));
    }

    public AviationWeather() {
      super("http://aviationweather.gov/static/adds/java/fpt/fpt.jnlp");
    }
  }

  public static class FuseSwing extends NearlyNoOutputs {

    public FuseSwing() {
      super("http://www.progx.org/users/Gfx/apps/fuse-swing-demo.jnlp");
    }
  }

  @Test
  public void remoteApplicationSettingsAreWorking() throws Exception {
    RemoteApplicationTestcaseSettings s5 = new FourierTransform();
    Assert.assertNotNull(s5.getUrl());
    RemoteApplicationTestcaseSettings s4 = new Arbores();
    Assert.assertNotNull(s4.getUrl());
    RemoteApplicationTestcaseSettings s3 = new PhetSims();
    Assert.assertNotNull(s3.getUrl());
    RemoteApplicationTestcaseSettings s2 = new TopCoder();
    Assert.assertNotNull(s2.getUrl());
    RemoteApplicationTestcaseSettings s1 = new SunSwingDemo();
    Assert.assertNotNull(s1.getUrl());
    RemoteApplicationTestcaseSettings s6 = new ArboresDeposit();
    Assert.assertNotNull(s6.getUrl());
    RemoteApplicationTestcaseSettings s7 = new OrawebCernCh();
    Assert.assertNotNull(s7.getUrl());
    RemoteApplicationTestcaseSettings s8 = new AviationWeather();
    Assert.assertNotNull(s8.getUrl());
    RemoteApplicationTestcaseSettings s9 = new FuseSwing();
    Assert.assertNotNull(s9.getUrl());
    RemoteApplicationTestcaseSettings s10 = new GnattProject();
    Assert.assertNotNull(s10.getUrl());
    RemoteApplicationTestcaseSettings s11 = new GeoGebra();
    Assert.assertNotNull(s11.getUrl());
  }
}
  /** Add the components to the panel. */
  private void addComponents() {
    JPanel topPanel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    JPanel servers = new NamedBorderPanel(Translator.R("APSServersPanel"));
    servers.setLayout(new GridBagLayout());

    JLabel type = new JLabel(Translator.R("APSProxyTypeLabel"));
    JLabel proxyAddress = new JLabel(Translator.R("APSProxyAddressLabel"));
    JLabel port = new JLabel(Translator.R("APSProxyPortLabel"));

    // This addresses the HTTP proxy settings.
    JLabel http = new JLabel(Translator.R("APSLabelHTTP") + ":");
    final JTextField httpAddressField = new JTextField(fields[0]);
    final JTextField httpPortField = new JTextField();
    httpPortField.setDocument(NetworkSettingsPanel.getPortNumberDocument());
    httpAddressField.getDocument().addDocumentListener(new DocumentAdapter(fields, 0));
    httpPortField.getDocument().addDocumentListener(new DocumentAdapter(fields, 1));
    httpPortField.setText(fields[1]);

    // This addresses the HTTPS proxy settings.
    JLabel secure = new JLabel(Translator.R("APSLabelSecure") + ":");
    final JTextField secureAddressField = new JTextField(fields[2]);
    final JTextField securePortField = new JTextField();
    securePortField.setDocument(NetworkSettingsPanel.getPortNumberDocument());
    secureAddressField.getDocument().addDocumentListener(new DocumentAdapter(fields, 2));
    securePortField.getDocument().addDocumentListener(new DocumentAdapter(fields, 3));
    securePortField.setText(fields[3]);

    // This addresses the FTP proxy settings.
    JLabel ftp = new JLabel(Translator.R("APSLabelFTP") + ":");
    final JTextField ftpAddressField = new JTextField(fields[4]);
    final JTextField ftpPortField = new JTextField();
    ftpPortField.setDocument(NetworkSettingsPanel.getPortNumberDocument());
    ftpAddressField.getDocument().addDocumentListener(new DocumentAdapter(fields, 4));
    ftpPortField.getDocument().addDocumentListener(new DocumentAdapter(fields, 5));
    ftpPortField.setText(fields[5]);

    // This addresses the Socks proxy settings.
    JLabel socks = new JLabel(Translator.R("APSLabelSocks") + ":");
    final JTextField socksAddressField = new JTextField(fields[6]);
    final JTextField socksPortField = new JTextField();
    socksPortField.setDocument(NetworkSettingsPanel.getPortNumberDocument());
    socksAddressField.getDocument().addDocumentListener(new DocumentAdapter(fields, 6));
    socksPortField.getDocument().addDocumentListener(new DocumentAdapter(fields, 7));
    socksPortField.setText(fields[7]);

    JCheckBox sameProxyForAll =
        new JCheckBox(Translator.R("APSSameProxyForAllProtocols"), Boolean.parseBoolean(fields[8]));
    sameProxyForAll.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            fields[8] = String.valueOf(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    JPanel p = new JPanel();
    BoxLayout bl = new BoxLayout(p, BoxLayout.Y_AXIS);
    p.setLayout(bl);
    p.add(sameProxyForAll);

    c.fill = GridBagConstraints.BOTH;
    c.gridheight = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 0;
    c.gridx = 0;
    servers.add(type, c);
    c.gridwidth = 2;
    c.weightx = 1;
    c.gridx = 1;
    servers.add(proxyAddress, c);
    c.gridwidth = 1;
    c.weightx = 1;
    c.gridx = 4;
    servers.add(port, c);

    plant(1, http, httpAddressField, httpPortField, servers, c);
    plant(2, secure, secureAddressField, securePortField, servers, c);
    plant(3, ftp, ftpAddressField, ftpPortField, servers, c);
    plant(4, socks, socksAddressField, socksPortField, servers, c);
    c.gridwidth = 5;
    c.gridx = 0;
    c.gridy = 5;
    servers.add(p, c);

    JPanel exceptions = new NamedBorderPanel(Translator.R("APSExceptionsLabel"));
    exceptions.setLayout(new BorderLayout());
    JLabel exceptionDescription = new JLabel(Translator.R("APSExceptionsDescription"));
    final JTextArea exceptionListArea = new JTextArea();
    exceptionListArea.setLineWrap(true);
    exceptionListArea.setText(fields[9]);
    exceptionListArea.getDocument().addDocumentListener(new DocumentAdapter(fields, 9));

    JLabel exceptionFormat = new JLabel(Translator.R("APSExceptionInstruction"));
    JScrollPane exceptionScroll =
        new JScrollPane(
            exceptionListArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    exceptions.add(exceptionDescription, BorderLayout.NORTH);
    exceptions.add(exceptionScroll, BorderLayout.CENTER);
    exceptions.add(exceptionFormat, BorderLayout.SOUTH);

    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridy = 0;
    topPanel.add(servers, c);
    c.weighty = 1;
    c.gridy = 1;
    topPanel.add(exceptions, c);

    this.add(topPanel);
    this.add(createButtonPanel(), BorderLayout.SOUTH);
  }
/**
 * This dialog provides a means for user to edit more of the proxy settings.
 *
 * @author Andrew Su &lt;[email protected], [email protected]&gt;
 */
public class AdvancedProxySettingsDialog extends JDialog {

  private boolean initialized = false;
  private static final String dialogTitle = Translator.R("APSDialogTitle");
  private final DeploymentConfiguration
      config; // Configuration file which contains all the settings.

  AdvancedProxySettingsPane topPanel;

  /**
   * Creates a new instance of the proxy settings dialog.
   *
   * @param config Loaded DeploymentConfiguration file.
   */
  public AdvancedProxySettingsDialog(DeploymentConfiguration config) {
    super((Frame) null, dialogTitle, true); // Don't need a parent.
    setIconImages(ImageResources.INSTANCE.getApplicationImages());

    this.config = config;

    /* Prepare for adding components to dialog box */
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    setMinimumSize(new Dimension(456, 404));
    setPreferredSize(new Dimension(456, 404));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 0;
    topPanel = new AdvancedProxySettingsPane(this, this.config);
    contentPane.add(topPanel, c);

    pack();

    /* Set focus to default button when first activated */
    WindowAdapter adapter =
        new WindowAdapter() {
          private boolean gotFocus = false;

          @Override
          public void windowGainedFocus(WindowEvent we) {
            // Once window gets focus, set initial focus
            if (!gotFocus) {
              topPanel.focusOnDefaultButton();
              gotFocus = true;
            }
          }
        };
    addWindowFocusListener(adapter);

    initialized = true;
  }

  /**
   * Check whether the dialog has finished being created.
   *
   * @return True if dialog is ready to be displayed.
   */
  public boolean isInitialized() {
    return initialized;
  }

  /** Center the dialog box. */
  private void centerDialog() {
    ScreenFinder.centerWindowsToCurrentScreen(this);
  }

  /**
   * Display the Proxy Settings Dialog.
   *
   * @param config A loaded DeploymentConfiguration file.
   */
  public static void showAdvancedProxySettingsDialog(final DeploymentConfiguration config) {
    AdvancedProxySettingsDialog psd = new AdvancedProxySettingsDialog(config);
    psd.setResizable(false);
    psd.centerDialog();
    psd.setVisible(true);
    psd.dispose();
  }
}