/**
   * Initialises and sets up the dialog.
   *
   * @param parent the parent frame for this dialog.
   * @param projects a list of the current database project names.
   * @param sMySQLName the username to use when connecting to MySQL to create the new database.
   * @param sMySQLPassword the password to use when connecting to MySQL to create the new database.
   * @param sMySQLIP the ip address or hostname to use when connecting to the database to create the
   *     new project.
   */
  public UINewDatabaseDialog(
      JFrame parent, Vector projects, String sMySQLName, String sMySQLPassword, String sMySQLIP) {

    super(parent, true);
    if (!ProjectCompendium.APP.projectsExist() && SystemProperties.createDefaultProject) {
      drawSimpleForm = true;
    } else {
      drawSimpleForm = false;
    }

    if (!drawSimpleForm) {
      this.setTitle(
          LanguageProperties.getString(
              LanguageProperties.DIALOGS_BUNDLE,
              "UINewDatabaseDialog.createNewProjectTitle")); //$NON-NLS-1$
    } else {
      this.setTitle(
          LanguageProperties.getString(
              LanguageProperties.DIALOGS_BUNDLE,
              "UINewDatabaseDialog.compendiumSetupTitle")); //$NON-NLS-1$
    }

    // this.setTitle(LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE,
    // "UINewDatabaseDialog.createNewProjectTitle")); //$NON-NLS-1$

    CSH.setHelpIDString(this, "basic.databases"); // $NON-NLS-1$

    oParent = parent;
    manager = this;

    this.sDatabaseLogin = sMySQLName;
    this.sDatabasePassword = sMySQLPassword;
    if (sMySQLIP != null && !sMySQLIP.equals("")) { // $NON-NLS-1$
      this.sDatabaseIP = sMySQLIP;
    }

    vtProjects = projects;

    oContentPane = getContentPane();
    JPanel oMainPanel = new JPanel(new BorderLayout());
    oMainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    oContentPane.setLayout(new BorderLayout());
    oContentPane.add(oMainPanel);

    oDetailsPanel = new JPanel();
    oDetailsPanel.setBorder(new EmptyBorder(10, 10, 5, 10));
    grid = new GridBagLayout();
    oDetailsPanel.setLayout(grid);

    GridBagConstraints gc = new GridBagConstraints();
    gc.insets = new Insets(5, 5, 5, 5);
    gc.anchor = GridBagConstraints.WEST;

    if (!drawSimpleForm) {
      oNameLabel =
          new JLabel(
              LanguageProperties.getString(
                      LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.projectName")
                  + ": * "); //$NON-NLS-1$
      grid.setConstraints(oNameLabel, gc);

      oNameField = new JTextField();
      oNameField.setColumns(25);
      oNameLabel.setLabelFor(oNameField);
      gc.gridwidth = GridBagConstraints.REMAINDER;
      grid.setConstraints(oNameField, gc);

      oDetailsPanel.add(oNameLabel);
      oDetailsPanel.add(oNameField);

      oDefaultDatabase =
          new JCheckBox(
              LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE,
                  "UINewDatabaseDialog.setAsDefault")); //$NON-NLS-1$
      oDefaultDatabase.addItemListener(this);
      grid.setConstraints(oDefaultDatabase, gc);
      oDetailsPanel.add(oDefaultDatabase);

      // oDefaultUser = new
      // JCheckBox(LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE,
      // "UINewDatabaseDialog.defaultUser")); //$NON-NLS-1$
      // oDefaultUser.addItemListener(this);
      // grid.setConstraints(oDefaultUser, gc);
      // oDetailsPanel.add(oDefaultUser);

      // JLabel label = new JLabel(LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE,
      // "UINewDatabaseDialog.administrator")); //$NON-NLS-1$
      // grid.setConstraints(label, gc);
      // oDetailsPanel.add(label);
    }

    oButtonPanel = new UIButtonPanel();

    pbCreate =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UINewDatabaseDialog.createButton")); //$NON-NLS-1$
    pbCreate.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.createButtonMnemonic")
            .charAt(0)); // $NON-NLS-1$
    pbCreate.addActionListener(this);
    getRootPane().setDefaultButton(pbCreate);
    oButtonPanel.addButton(pbCreate);

    if (!drawSimpleForm) {
      pbCancel =
          new UIButton(
              LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE,
                  "UINewDatabaseDialog.cancelButton")); //$NON-NLS-1$
      pbCancel.setMnemonic(
          LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.cancelButtonMnemonic")
              .charAt(0)); // $NON-NLS-1$
      pbCancel.addActionListener(this);
      oButtonPanel.addButton(pbCancel);

      pbHelp =
          new UIButton(
              LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE,
                  "UINewDatabaseDialog.helpButton")); //$NON-NLS-1$
      pbHelp.setMnemonic(
          LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.helpButtonMnemonic")
              .charAt(0)); // $NON-NLS-1$
      ProjectCompendium.APP.mainHB.enableHelpOnButton(
          pbHelp, "basics.databasescreate", ProjectCompendium.APP.mainHS); // $NON-NLS-1$
      oButtonPanel.addHelpButton(pbHelp);
    }

    JPanel oHoldingPanel = new JPanel(new BorderLayout());
    userPanel = new UINewUserPanel(true);
    userPanel.setBorder(
        new TitledBorder(
            new BevelBorder(BevelBorder.LOWERED),
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UINewDatabaseDialog.administrator")));
    oHoldingPanel.add(userPanel, BorderLayout.CENTER);

    if (!drawSimpleForm) {
      oDefaultUser =
          new JCheckBox(
              LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE,
                  "UINewDatabaseDialog.defaultUser")); //$NON-NLS-1$
      oDefaultUser.addItemListener(this);
      oDefaultUser.setSelected(true);
      grid.setConstraints(oDefaultUser, gc);
      oHoldingPanel.add(oDefaultUser, BorderLayout.SOUTH);
    }

    oMainPanel.add(oDetailsPanel, BorderLayout.NORTH);
    oMainPanel.add(oHoldingPanel, BorderLayout.CENTER);
    oMainPanel.add(oButtonPanel, BorderLayout.SOUTH);

    oProgressBar = new JProgressBar();
    oProgressBar.setMinimum(0);
    oProgressBar.setMaximum(100);

    pack();

    setResizable(false);
  }
  /** Draw the contents of the dialog. */
  private void drawDialog() {

    JPanel oCenterPanel = new JPanel();

    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints gc = new GridBagConstraints();
    gc.anchor = GridBagConstraints.WEST;
    oCenterPanel.setLayout(gb);
    gc.insets = new Insets(5, 5, 5, 5);

    int y = 0;

    cbIncludeKeywords =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importKeywordData")); //$NON-NLS-1$
    cbIncludeKeywords.setSelected(true);
    cbIncludeKeywords.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeKeywords, gc);
    oCenterPanel.add(cbIncludeKeywords);

    cbIncludePlayList =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importPlayListData")); //$NON-NLS-1$
    cbIncludePlayList.setSelected(true);
    cbIncludePlayList.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludePlayList, gc);
    oCenterPanel.add(cbIncludePlayList);

    cbIncludeURLs =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importURLData")); //$NON-NLS-1$
    cbIncludeURLs.setSelected(true);
    cbIncludeURLs.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeURLs, gc);
    oCenterPanel.add(cbIncludeURLs);

    cbIncludeAttendees =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importAttendeeData")); //$NON-NLS-1$
    cbIncludeAttendees.setSelected(true);
    cbIncludeAttendees.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeAttendees, gc);
    oCenterPanel.add(cbIncludeAttendees);

    cbIncludeChats =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.imortChatData")); //$NON-NLS-1$
    cbIncludeChats.setSelected(true);
    cbIncludeChats.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeChats, gc);
    oCenterPanel.add(cbIncludeChats);

    cbIncludeWhiteboard =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importWhiteBoardData")); //$NON-NLS-1$
    cbIncludeWhiteboard.setSelected(true);
    cbIncludeWhiteboard.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeWhiteboard, gc);
    oCenterPanel.add(cbIncludeWhiteboard);

    cbIncludeAnnotations =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importAnnotationData")); //$NON-NLS-1$
    cbIncludeAnnotations.setSelected(true);
    cbIncludeAnnotations.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeAnnotations, gc);
    oCenterPanel.add(cbIncludeAnnotations);

    cbIncludeFileData =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importFileData")); //$NON-NLS-1$
    cbIncludeFileData.setSelected(true);
    cbIncludeFileData.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeFileData, gc);
    oCenterPanel.add(cbIncludeFileData);

    cbIncludeVotes =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importVotingData")); //$NON-NLS-1$
    cbIncludeVotes.setSelected(true);
    cbIncludeVotes.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbIncludeVotes, gc);
    oCenterPanel.add(cbIncludeVotes);

    // Add spacer label
    JLabel spacer = new JLabel(" "); // $NON-NLS-1$
    gc.gridy = y;
    y++;
    gb.setConstraints(spacer, gc);
    oCenterPanel.add(spacer);

    // flag to mark seen/unseen on import
    cbMarkSeen =
        new JCheckBox(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.markSeen")); //$NON-NLS-1$
    cbMarkSeen.setSelected(true);
    cbMarkSeen.addActionListener(this);
    gc.gridy = y;
    y++;
    gb.setConstraints(cbMarkSeen, gc);
    oCenterPanel.add(cbMarkSeen);

    // Add spacer label
    spacer = new JLabel(" "); // $NON-NLS-1$
    gc.gridy = y;
    y++;
    gb.setConstraints(spacer, gc);
    oCenterPanel.add(spacer);

    gc.gridwidth = 1;

    UIButtonPanel oButtonPanel = new UIButtonPanel();

    pbImport =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importMainButton")); //$NON-NLS-1$
    pbImport.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.importMainButtonMnemonic")
            .charAt(0));
    pbImport.addActionListener(this);
    getRootPane().setDefaultButton(pbImport);
    oButtonPanel.addButton(pbImport);

    pbClose =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.cancelButton")); //$NON-NLS-1$
    pbClose.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.cancelButtonMnemonic")
            .charAt(0));
    pbClose.addActionListener(this);
    oButtonPanel.addButton(pbClose);

    pbHelp =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.helpButton")); //$NON-NLS-1$
    pbHelp.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIImportFlashMeetingXMLDialog.helpButtonMnemonic")
            .charAt(0));
    ProjectCompendium.APP.mainHB.enableHelpOnButton(
        pbHelp, "io.import_flashmeeting_xml", ProjectCompendium.APP.mainHS); // $NON-NLS-1$
    oButtonPanel.addHelpButton(pbHelp);

    // other initializations
    oContentPane.setLayout(new BorderLayout());
    oContentPane.add(oCenterPanel, BorderLayout.CENTER);
    oContentPane.add(oButtonPanel, BorderLayout.SOUTH);

    pack();
    setResizable(false);
    return;
  }