/** Handle a closing event under an OK condition */
  protected void closingOK() {
    StringBuffer buff = new StringBuffer();
    for (int i = 0; i < m_listModel.size(); i++) {
      SubstringLabeler.Match m = (SubstringLabeler.Match) m_listModel.elementAt(i);

      buff.append(m.toStringInternal());
      if (i < m_listModel.size() - 1) {
        buff.append("@@match-rule@@");
      }
    }

    m_labeler.setMatchDetails(buff.toString());
    m_labeler.setNominalBinary(m_nominalBinaryCheck.isSelected());
    m_labeler.setConsumeNonMatching(m_consumeNonMatchingCheck.isSelected());
    m_labeler.setMatchAttributeName(m_matchAttNameField.getText());

    if (m_modifyL != null) {
      m_modifyL.setModifiedStatus(SubstringLabelerCustomizer.this, true);
    }
  }
示例#2
0
  private boolean resetAndUpdateDatabaseLoaderIfChanged() {
    DatabaseLoader dbl = (DatabaseLoader) m_dsLoader.getLoader();
    String url = dbl.getUrl();
    String user = dbl.getUser();
    String password = dbl.getPassword();
    String query = dbl.getQuery();
    String keys = dbl.getKeys();
    File propsFile = dbl.getCustomPropsFile();

    boolean update =
        (!url.equals(m_dbaseURLText.getText())
            || !user.equals(m_userNameText.getText())
            || !password.equals(m_passwordText.getText())
            || !query.equalsIgnoreCase(m_queryText.getText())
            || !keys.equals(m_keyText.getText()));

    if (propsFile != null && m_dbProps.getText().length() > 0) {
      update = (update || !propsFile.toString().equals(m_dbProps.getText()));
    } else {
      update = (update || m_dbProps.getText().length() > 0);
    }

    if (update) {
      dbl.resetStructure();
      dbl.setUrl(m_dbaseURLText.getText());
      dbl.setUser(m_userNameText.getText());
      dbl.setPassword(new String(m_passwordText.getPassword()));
      dbl.setQuery(m_queryText.getText());
      dbl.setKeys(m_keyText.getText());
      if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) {
        dbl.setCustomPropsFile(new File(m_dbProps.getText()));
      }
    }

    return update;
  }
示例#3
0
  public void setUpFile() {
    removeAll();

    boolean currentFileIsDir = false;
    File tmp = ((FileSourcedConverter) m_dsLoader.getLoader()).retrieveFile();
    String tmpString = tmp.toString();
    if (Environment.containsEnvVariables(tmpString)) {
      try {
        tmpString = m_env.substitute(tmpString);
      } catch (Exception ex) {
        // ignore
      }
    }
    File tmp2 = new File((new File(tmpString)).getAbsolutePath());

    if (tmp2.isDirectory()) {
      m_fileChooser.setCurrentDirectory(tmp2);
      currentFileIsDir = true;
    } else {
      m_fileChooser.setSelectedFile(tmp2);
    }

    FileSourcedConverter loader = (FileSourcedConverter) m_dsLoader.getLoader();
    String[] ext = loader.getFileExtensions();
    ExtensionFileFilter firstFilter = null;
    for (int i = 0; i < ext.length; i++) {
      ExtensionFileFilter ff =
          new ExtensionFileFilter(ext[i], loader.getFileDescription() + " (*" + ext[i] + ")");
      if (i == 0) firstFilter = ff;
      m_fileChooser.addChoosableFileFilter(ff);
    }
    if (firstFilter != null) m_fileChooser.setFileFilter(firstFilter);
    JPanel about = m_LoaderEditor.getAboutPanel();
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    if (about != null) {
      northPanel.add(about, BorderLayout.NORTH);
    }
    add(northPanel, BorderLayout.NORTH);

    final EnvironmentField ef = new EnvironmentField();
    JPanel efHolder = new JPanel();
    efHolder.setLayout(new BorderLayout());

    ef.setEnvironment(m_env);
    /*int width = ef.getPreferredSize().width;
        int height = ef.getPreferredSize().height;
    //    ef.setMinimumSize(new Dimension(width * 2, height));
        ef.setPreferredSize(new Dimension(width * 2, height)); */
    m_fileText = ef;

    // only set the text on the EnvironmentField if the current file is not a directory
    if (!currentFileIsDir) {
      ef.setText(tmp.toString());
    }

    efHolder.add(ef, BorderLayout.CENTER);
    JButton browseBut = new JButton("Browse...");
    browseBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              // final JFrame jf = new JFrame("Choose file");
              final JDialog jf =
                  new JDialog(
                      (JDialog) LoaderCustomizer.this.getTopLevelAncestor(), "Choose file", true);
              jf.setLayout(new BorderLayout());
              // jf.getContentPane().setLayout(new BorderLayout());
              jf.getContentPane().add(m_fileChooser, BorderLayout.CENTER);
              m_fileChooserFrame = jf;
              jf.pack();
              jf.setVisible(true);
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    JPanel bP = new JPanel();
    bP.setLayout(new BorderLayout());
    bP.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
    bP.add(browseBut, BorderLayout.CENTER);
    efHolder.add(bP, BorderLayout.EAST);
    JPanel alignedP = new JPanel();
    alignedP.setBorder(BorderFactory.createTitledBorder("File"));
    alignedP.setLayout(new BorderLayout());
    JLabel efLab = new JLabel("Filename", SwingConstants.RIGHT);
    efLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    alignedP.add(efLab, BorderLayout.WEST);
    alignedP.add(efHolder, BorderLayout.CENTER);

    northPanel.add(alignedP, BorderLayout.SOUTH);

    JPanel butHolder = new JPanel();
    // butHolder.setLayout(new GridLayout(1,2));
    butHolder.setLayout(new FlowLayout());
    JButton OKBut = new JButton("OK");
    OKBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              ((FileSourcedConverter) m_dsLoader.getLoader()).setFile(new File(ef.getText()));
              // tell the loader that a new file has been selected so
              // that it can attempt to load the header
              // m_dsLoader.setLoader(m_dsLoader.getLoader());
              m_dsLoader.newFileSelected();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
            if (m_modifyListener != null) {
              m_modifyListener.setModifiedStatus(LoaderCustomizer.this, true);
            }
            m_parentWindow.dispose();
          }
        });

    JButton CancelBut = new JButton("Cancel");
    CancelBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (m_modifyListener != null) {
              m_modifyListener.setModifiedStatus(LoaderCustomizer.this, false);
            }

            if (m_backup != null) {
              m_dsLoader.setLoader(m_backup);
            }

            m_parentWindow.dispose();
          }
        });

    butHolder.add(OKBut);
    butHolder.add(CancelBut);

    JPanel optionsHolder = new JPanel();
    optionsHolder.setLayout(new BorderLayout());
    optionsHolder.setBorder(BorderFactory.createTitledBorder("Other options"));

    optionsHolder.add(m_LoaderEditor, BorderLayout.SOUTH);
    JScrollPane scroller = new JScrollPane(optionsHolder);

    add(scroller, BorderLayout.CENTER);

    add(butHolder, BorderLayout.SOUTH);
  }
示例#4
0
  /** Sets up a customizer window for a Database Connection */
  private void setUpDatabase() {

    removeAll();

    JPanel db = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    // db.setLayout(new GridLayout(6, 1));
    db.setLayout(gbLayout);

    JLabel urlLab = new JLabel("Database URL", SwingConstants.RIGHT);
    urlLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(urlLab, gbConstraints);
    db.add(urlLab);

    m_dbaseURLText = new EnvironmentField();
    m_dbaseURLText.setEnvironment(m_env);
    /*    int width = m_dbaseURLText.getPreferredSize().width;
    int height = m_dbaseURLText.getPreferredSize().height;
    m_dbaseURLText.setMinimumSize(new Dimension(width * 2, height));
    m_dbaseURLText.setPreferredSize(new Dimension(width * 2, height)); */
    m_dbaseURLText.setText(((DatabaseConverter) m_dsLoader.getLoader()).getUrl());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 5;
    gbLayout.setConstraints(m_dbaseURLText, gbConstraints);
    db.add(m_dbaseURLText);

    JLabel userLab = new JLabel("Username", SwingConstants.RIGHT);
    userLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(userLab, gbConstraints);
    db.add(userLab);

    m_userNameText = new EnvironmentField();
    m_userNameText.setEnvironment(m_env);
    /*    m_userNameText.setMinimumSize(new Dimension(width * 2, height));
    m_userNameText.setPreferredSize(new Dimension(width * 2, height)); */
    m_userNameText.setText(((DatabaseConverter) m_dsLoader.getLoader()).getUser());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_userNameText, gbConstraints);
    db.add(m_userNameText);

    JLabel passwordLab = new JLabel("Password ", SwingConstants.RIGHT);
    passwordLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(passwordLab, gbConstraints);
    db.add(passwordLab);

    m_passwordText = new JPasswordField();
    JPanel passwordHolder = new JPanel();
    passwordHolder.setLayout(new BorderLayout());
    passwordHolder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    //    passwordHolder.add(passwordLab, BorderLayout.WEST);
    passwordHolder.add(m_passwordText, BorderLayout.CENTER);
    /*    passwordHolder.setMinimumSize(new Dimension(width * 2, height));
    passwordHolder.setPreferredSize(new Dimension(width * 2, height)); */
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(passwordHolder, gbConstraints);
    db.add(passwordHolder);

    JLabel queryLab = new JLabel("Query", SwingConstants.RIGHT);
    queryLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(queryLab, gbConstraints);
    db.add(queryLab);

    m_queryText = new EnvironmentField();
    m_queryText.setEnvironment(m_env);
    /*    m_queryText.setMinimumSize(new Dimension(width * 2, height));
    m_queryText.setPreferredSize(new Dimension(width * 2, height)); */
    m_queryText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getQuery());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_queryText, gbConstraints);
    db.add(m_queryText);

    JLabel keyLab = new JLabel("Key columns", SwingConstants.RIGHT);
    keyLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(keyLab, gbConstraints);
    db.add(keyLab);

    m_keyText = new EnvironmentField();
    m_keyText.setEnvironment(m_env);
    /*m_keyText.setMinimumSize(new Dimension(width * 2, height));
    m_keyText.setPreferredSize(new Dimension(width * 2, height)); */
    m_keyText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getKeys());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_keyText, gbConstraints);
    db.add(m_keyText);

    JLabel propsLab = new JLabel("DB config props", SwingConstants.RIGHT);
    propsLab.setToolTipText(
        "The custom properties that the user can use to override the default ones.");
    propsLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 5;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(propsLab, gbConstraints);
    db.add(propsLab);

    m_dbProps = new FileEnvironmentField();
    m_dbProps.setEnvironment(m_env);
    m_dbProps.resetFileFilters();
    m_dbProps.addFileFilter(
        new ExtensionFileFilter(".props", "DatabaseUtils property file (*.props)"));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 5;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_dbProps, gbConstraints);
    db.add(m_dbProps);
    File toSet = ((DatabaseLoader) m_dsLoader.getLoader()).getCustomPropsFile();
    if (toSet != null) {
      m_dbProps.setText(toSet.getPath());
    }

    JButton loadPropsBut = new JButton("Load");
    loadPropsBut.setToolTipText("Load config");
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 5;
    gbConstraints.gridx = 2;
    gbLayout.setConstraints(loadPropsBut, gbConstraints);
    db.add(loadPropsBut);
    loadPropsBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) {
              String propsS = m_dbProps.getText();
              try {
                propsS = m_env.substitute(propsS);
              } catch (Exception ex) {
              }
              File propsFile = new File(propsS);
              if (propsFile.exists()) {
                ((DatabaseLoader) m_dsLoader.getLoader()).setCustomPropsFile(propsFile);
                ((DatabaseLoader) m_dsLoader.getLoader()).resetOptions();
                m_dbaseURLText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getUrl());
              }
            }
          }
        });

    JPanel buttonsP = new JPanel();
    buttonsP.setLayout(new FlowLayout());
    JButton ok, cancel;
    buttonsP.add(ok = new JButton("OK"));
    buttonsP.add(cancel = new JButton("Cancel"));
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            /*((DatabaseLoader)m_dsLoader.getLoader()).resetStructure();
            ((DatabaseConverter)m_dsLoader.getLoader()).setUrl(m_dbaseURLText.getText());
            ((DatabaseConverter)m_dsLoader.getLoader()).setUser(m_userNameText.getText());
            ((DatabaseConverter)m_dsLoader.getLoader()).setPassword(new String(m_passwordText.getPassword()));
            ((DatabaseLoader)m_dsLoader.getLoader()).setQuery(m_queryText.getText());
            ((DatabaseLoader)m_dsLoader.getLoader()).setKeys(m_keyText.getText()); */

            if (resetAndUpdateDatabaseLoaderIfChanged()) {
              try {
                // m_dsLoader.notifyStructureAvailable(((DatabaseLoader)m_dsLoader.getLoader()).getStructure());
                // database connection has been configured
                m_dsLoader.setDB(true);
              } catch (Exception ex) {
              }
            }
            if (m_parentWindow != null) {
              m_parentWindow.dispose();
            }
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (m_backup != null) {
              m_dsLoader.setLoader(m_backup);
            }

            if (m_parentWindow != null) {
              m_parentWindow.dispose();
            }
          }
        });

    JPanel holderP = new JPanel();
    holderP.setLayout(new BorderLayout());
    holderP.add(db, BorderLayout.NORTH);
    holderP.add(buttonsP, BorderLayout.SOUTH);

    // db.add(buttonsP);
    JPanel about = m_LoaderEditor.getAboutPanel();
    if (about != null) {
      add(about, BorderLayout.NORTH);
    }
    add(holderP, BorderLayout.SOUTH);
  }
示例#5
0
  /** Sets up dialog for saving instances in a file */
  public void setUpFile() {
    removeAll();

    m_fileChooser.setFileFilter(
        new FileFilter() {
          public boolean accept(File f) {
            return f.isDirectory();
          }

          public String getDescription() {
            return "Directory";
          }
        });

    m_fileChooser.setAcceptAllFileFilterUsed(false);

    try {
      if (!(((m_dsSaver.getSaver()).retrieveDir()).equals(""))) {
        String dirStr = m_dsSaver.getSaver().retrieveDir();
        if (Environment.containsEnvVariables(dirStr)) {
          try {
            dirStr = m_env.substitute(dirStr);
          } catch (Exception ex) {
            // ignore
          }
        }
        File tmp = new File(dirStr);
        tmp = new File(tmp.getAbsolutePath());
        m_fileChooser.setCurrentDirectory(tmp);
      }
    } catch (Exception ex) {
      System.out.println(ex);
    }

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BorderLayout());

    JPanel alignedP = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    alignedP.setLayout(gbLayout);

    JLabel prefixLab = new JLabel("Prefix for file name", SwingConstants.RIGHT);
    prefixLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(prefixLab, gbConstraints);
    alignedP.add(prefixLab);

    m_prefixText = new EnvironmentField();
    m_prefixText.setEnvironment(m_env);
    m_prefixText.setToolTipText(
        "Prefix for file name " + "(or filename itself if relation name is not used)");
    /*    int width = m_prefixText.getPreferredSize().width;
    int height = m_prefixText.getPreferredSize().height;
    m_prefixText.setMinimumSize(new Dimension(width * 2, height));
    m_prefixText.setPreferredSize(new Dimension(width * 2, height)); */
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_prefixText, gbConstraints);
    alignedP.add(m_prefixText);

    try {
      //      m_prefixText = new JTextField(m_dsSaver.getSaver().filePrefix(),25);

      m_prefixText.setText(m_dsSaver.getSaver().filePrefix());

      /*      final JLabel prefixLab =
      new JLabel(" Prefix for file name:", SwingConstants.LEFT); */

      JLabel relationLab = new JLabel("Relation name for filename", SwingConstants.RIGHT);
      relationLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
      gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.HORIZONTAL;
      gbConstraints.gridy = 1;
      gbConstraints.gridx = 0;
      gbLayout.setConstraints(relationLab, gbConstraints);
      alignedP.add(relationLab);

      m_relationNameForFilename = new JCheckBox();
      m_relationNameForFilename.setSelected(m_dsSaver.getRelationNameForFilename());
      m_relationNameForFilename.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (m_relationNameForFilename.isSelected()) {
                m_prefixText.setLabel("Prefix for file name");
                m_fileChooser.setApproveButtonText("Select directory and prefix");
              } else {
                m_prefixText.setLabel("File name");
                m_fileChooser.setApproveButtonText("Select directory and filename");
              }
            }
          });

      gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.HORIZONTAL;
      gbConstraints.gridy = 1;
      gbConstraints.gridx = 1;
      gbConstraints.weightx = 5;
      gbLayout.setConstraints(m_relationNameForFilename, gbConstraints);
      alignedP.add(m_relationNameForFilename);
    } catch (Exception ex) {
    }
    // innerPanel.add(m_SaverEditor, BorderLayout.SOUTH);
    JPanel about = m_SaverEditor.getAboutPanel();
    if (about != null) {
      innerPanel.add(about, BorderLayout.NORTH);
    }
    add(innerPanel, BorderLayout.NORTH);
    //    add(m_fileChooser, BorderLayout.CENTER);

    JLabel directoryLab = new JLabel("Directory", SwingConstants.RIGHT);
    directoryLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(directoryLab, gbConstraints);
    alignedP.add(directoryLab);

    m_directoryText = new EnvironmentField();
    //    m_directoryText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_directoryText.setEnvironment(m_env);
    /*    width = m_directoryText.getPreferredSize().width;
    height = m_directoryText.getPreferredSize().height;
    m_directoryText.setMinimumSize(new Dimension(width * 2, height));
    m_directoryText.setPreferredSize(new Dimension(width * 2, height)); */

    try {
      m_directoryText.setText(m_dsSaver.getSaver().retrieveDir());
    } catch (IOException ex) {
      // ignore
    }

    JButton browseBut = new JButton("Browse...");
    browseBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              final JFrame jf = new JFrame("Choose directory");
              jf.getContentPane().setLayout(new BorderLayout());
              jf.getContentPane().add(m_fileChooser, BorderLayout.CENTER);
              jf.pack();
              jf.setVisible(true);
              m_fileChooserFrame = jf;
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    JPanel efHolder = new JPanel();
    efHolder.setLayout(new BorderLayout());
    JPanel bP = new JPanel();
    bP.setLayout(new BorderLayout());
    bP.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
    bP.add(browseBut, BorderLayout.CENTER);
    efHolder.add(m_directoryText, BorderLayout.CENTER);
    efHolder.add(bP, BorderLayout.EAST);
    // efHolder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(efHolder, gbConstraints);
    alignedP.add(efHolder);

    JLabel relativeLab = new JLabel("Use relative file paths", SwingConstants.RIGHT);
    relativeLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(relativeLab, gbConstraints);
    alignedP.add(relativeLab);

    m_relativeFilePath = new JCheckBox();
    m_relativeFilePath.setSelected(
        ((FileSourcedConverter) m_dsSaver.getSaver()).getUseRelativePath());

    m_relativeFilePath.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ((FileSourcedConverter) m_dsSaver.getSaver())
                .setUseRelativePath(m_relativeFilePath.isSelected());
          }
        });
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_relativeFilePath, gbConstraints);
    alignedP.add(m_relativeFilePath);

    JButton OKBut = new JButton("OK");
    OKBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
              (m_dsSaver.getSaver()).setDir(m_directoryText.getText());
              m_dsSaver.setRelationNameForFilename(m_relationNameForFilename.isSelected());
            } catch (Exception ex) {
              ex.printStackTrace();
            }

            m_parentFrame.dispose();
          }
        });

    JButton CancelBut = new JButton("Cancel");
    CancelBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_parentFrame.dispose();
          }
        });

    JPanel butHolder = new JPanel();
    butHolder.setLayout(new FlowLayout());
    butHolder.add(OKBut);
    butHolder.add(CancelBut);
    JPanel holder2 = new JPanel();
    holder2.setLayout(new BorderLayout());
    holder2.add(alignedP, BorderLayout.NORTH);
    holder2.add(butHolder, BorderLayout.SOUTH);

    add(holder2, BorderLayout.SOUTH);
  }
示例#6
0
  /** Sets up the dialog for saving to a database */
  private void setUpDatabase() {

    removeAll();
    JPanel db = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    db.setLayout(gbLayout);

    JLabel dbaseURLLab = new JLabel(" Database URL", SwingConstants.RIGHT);
    dbaseURLLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(dbaseURLLab, gbConstraints);
    db.add(dbaseURLLab);

    m_dbaseURLText = new EnvironmentField();
    m_dbaseURLText.setEnvironment(m_env);
    /*    int width = m_dbaseURLText.getPreferredSize().width;
    int height = m_dbaseURLText.getPreferredSize().height;
    m_dbaseURLText.setMinimumSize(new Dimension(width * 2, height));
    m_dbaseURLText.setPreferredSize(new Dimension(width * 2, height)); */
    m_dbaseURLText.setText(((DatabaseConverter) m_dsSaver.getSaver()).getUrl());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 5;
    gbLayout.setConstraints(m_dbaseURLText, gbConstraints);
    db.add(m_dbaseURLText);

    JLabel userLab = new JLabel("Username", SwingConstants.RIGHT);
    userLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(userLab, gbConstraints);
    db.add(userLab);

    m_userNameText = new EnvironmentField();
    m_userNameText.setEnvironment(m_env);
    /*    m_userNameText.setMinimumSize(new Dimension(width * 2, height));
    m_userNameText.setPreferredSize(new Dimension(width * 2, height)); */
    m_userNameText.setText(((DatabaseConverter) m_dsSaver.getSaver()).getUser());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_userNameText, gbConstraints);
    db.add(m_userNameText);

    JLabel passwordLab = new JLabel("Password ", SwingConstants.RIGHT);
    passwordLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(passwordLab, gbConstraints);
    db.add(passwordLab);

    m_passwordText = new JPasswordField();
    JPanel passwordHolder = new JPanel();
    passwordHolder.setLayout(new BorderLayout());
    passwordHolder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    passwordHolder.add(m_passwordText, BorderLayout.CENTER);
    /*passwordHolder.setMinimumSize(new Dimension(width * 2, height));
    passwordHolder.setPreferredSize(new Dimension(width * 2, height)); */
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(passwordHolder, gbConstraints);
    db.add(passwordHolder);

    JLabel tableLab = new JLabel("Table Name", SwingConstants.RIGHT);
    tableLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(tableLab, gbConstraints);
    db.add(tableLab);

    m_tableText = new EnvironmentField();
    m_tableText.setEnvironment(m_env);
    /*    m_tableText.setMinimumSize(new Dimension(width * 2, height));
    m_tableText.setPreferredSize(new Dimension(width * 2, height)); */
    m_tableText.setEnabled(!((DatabaseSaver) m_dsSaver.getSaver()).getRelationForTableName());
    m_tableText.setText(((DatabaseSaver) m_dsSaver.getSaver()).getTableName());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_tableText, gbConstraints);
    db.add(m_tableText);

    JLabel tabLab = new JLabel("Use relation name", SwingConstants.RIGHT);
    tabLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(tabLab, gbConstraints);
    db.add(tabLab);

    m_tabBox = new JCheckBox();
    m_tabBox.setSelected(((DatabaseSaver) m_dsSaver.getSaver()).getRelationForTableName());
    m_tabBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_tableText.setEnabled(!m_tabBox.isSelected());
          }
        });
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_tabBox, gbConstraints);
    db.add(m_tabBox);

    JLabel idLab = new JLabel("Automatic primary key", SwingConstants.RIGHT);
    idLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 5;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(idLab, gbConstraints);
    db.add(idLab);

    m_idBox = new JCheckBox();
    m_idBox.setSelected(((DatabaseSaver) m_dsSaver.getSaver()).getAutoKeyGeneration());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 5;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_idBox, gbConstraints);
    db.add(m_idBox);

    JPanel buttonsP = new JPanel();
    buttonsP.setLayout(new FlowLayout());
    JButton ok, cancel;
    buttonsP.add(ok = new JButton("OK"));
    buttonsP.add(cancel = new JButton("Cancel"));
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            ((DatabaseSaver) m_dsSaver.getSaver()).resetStructure();
            ((DatabaseConverter) m_dsSaver.getSaver()).setUrl(m_dbaseURLText.getText());
            ((DatabaseConverter) m_dsSaver.getSaver()).setUser(m_userNameText.getText());
            ((DatabaseConverter) m_dsSaver.getSaver())
                .setPassword(new String(m_passwordText.getPassword()));
            if (!m_tabBox.isSelected()) {
              ((DatabaseSaver) m_dsSaver.getSaver()).setTableName(m_tableText.getText());
            }
            ((DatabaseSaver) m_dsSaver.getSaver()).setAutoKeyGeneration(m_idBox.isSelected());
            ((DatabaseSaver) m_dsSaver.getSaver()).setRelationForTableName(m_tabBox.isSelected());
            if (m_parentFrame != null) {
              m_parentFrame.dispose();
            }
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (m_parentFrame != null) {
              m_parentFrame.dispose();
            }
          }
        });

    JPanel holderP = new JPanel();
    holderP.setLayout(new BorderLayout());
    holderP.add(db, BorderLayout.NORTH);
    holderP.add(buttonsP, BorderLayout.SOUTH);

    //    db.add(buttonsP);
    JPanel about = m_SaverEditor.getAboutPanel();
    if (about != null) {
      add(about, BorderLayout.NORTH);
    }
    add(holderP, BorderLayout.SOUTH);
  }
示例#7
0
  public void setUpFile() {
    removeAll();

    boolean currentFileIsDir = false;
    File tmp = ((FileSourcedConverter) m_dsLoader.getLoader()).retrieveFile();
    String tmpString = tmp.toString();
    if (Environment.containsEnvVariables(tmpString)) {
      try {
        tmpString = m_env.substitute(tmpString);
      } catch (Exception ex) {
        // ignore
      }
    }
    File tmp2 = new File((new File(tmpString)).getAbsolutePath());

    if (tmp2.isDirectory()) {
      m_fileChooser.setCurrentDirectory(tmp2);
      currentFileIsDir = true;
    } else {
      m_fileChooser.setSelectedFile(tmp2);
    }

    FileSourcedConverter loader = (FileSourcedConverter) m_dsLoader.getLoader();
    String[] ext = loader.getFileExtensions();
    ExtensionFileFilter firstFilter = null;
    for (int i = 0; i < ext.length; i++) {
      ExtensionFileFilter ff =
          new ExtensionFileFilter(ext[i], loader.getFileDescription() + " (*" + ext[i] + ")");
      if (i == 0) firstFilter = ff;
      m_fileChooser.addChoosableFileFilter(ff);
    }
    if (firstFilter != null) m_fileChooser.setFileFilter(firstFilter);
    JPanel about = m_LoaderEditor.getAboutPanel();
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    if (about != null) {
      northPanel.add(about, BorderLayout.NORTH);
    }
    add(northPanel, BorderLayout.NORTH);
    final EnvironmentField ef = new EnvironmentField();
    JPanel efHolder = new JPanel();
    efHolder.setLayout(new BorderLayout());

    ef.setEnvironment(m_env);
    /*int width = ef.getPreferredSize().width;
        int height = ef.getPreferredSize().height;
    //    ef.setMinimumSize(new Dimension(width * 2, height));
        ef.setPreferredSize(new Dimension(width * 2, height)); */
    m_fileText = ef;

    // only set the text on the EnvironmentField if the current file is not a directory
    if (!currentFileIsDir) {
      ef.setText(tmp.toString());
    }

    efHolder.add(ef, BorderLayout.CENTER);
    JButton browseBut = new JButton("Browse...");
    browseBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              final JFrame jf = new JFrame("Choose file");
              jf.getContentPane().setLayout(new BorderLayout());
              jf.getContentPane().add(m_fileChooser, BorderLayout.CENTER);
              jf.pack();
              jf.setVisible(true);
              m_fileChooserFrame = jf;
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    JPanel bP = new JPanel();
    bP.setLayout(new BorderLayout());
    bP.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
    bP.add(browseBut, BorderLayout.CENTER);
    efHolder.add(bP, BorderLayout.EAST);
    JPanel alignedP = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    alignedP.setLayout(gbLayout);
    JLabel efLab = new JLabel("Filename", SwingConstants.RIGHT);
    efLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(efLab, gbConstraints);
    alignedP.add(efLab);

    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 5;
    gbLayout.setConstraints(efHolder, gbConstraints);
    alignedP.add(efHolder);

    northPanel.add(alignedP, BorderLayout.SOUTH);

    // add(m_fileChooser, BorderLayout.CENTER);

    // m_relativeFilePath = new JCheckBox("Use relative file paths");
    m_relativeFilePath = new JCheckBox();
    m_relativeFilePath.setSelected(
        ((FileSourcedConverter) m_dsLoader.getLoader()).getUseRelativePath());

    m_relativeFilePath.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ((FileSourcedConverter) m_dsLoader.getLoader())
                .setUseRelativePath(m_relativeFilePath.isSelected());
          }
        });

    JLabel relativeLab = new JLabel("Use relative file paths", SwingConstants.RIGHT);
    relativeLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(relativeLab, gbConstraints);
    alignedP.add(relativeLab);

    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_relativeFilePath, gbConstraints);
    alignedP.add(m_relativeFilePath);

    JPanel butHolder = new JPanel();
    // butHolder.setLayout(new GridLayout(1,2));
    butHolder.setLayout(new FlowLayout());
    JButton OKBut = new JButton("OK");
    OKBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              ((FileSourcedConverter) m_dsLoader.getLoader()).setFile(new File(ef.getText()));
              // tell the loader that a new file has been selected so
              // that it can attempt to load the header
              m_dsLoader.setLoader(m_dsLoader.getLoader());
              m_dsLoader.newFileSelected();
            } catch (Exception ex) {
              ex.printStackTrace();
            }

            m_parentFrame.dispose();
          }
        });

    JButton CancelBut = new JButton("Cancel");
    CancelBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_parentFrame.dispose();
          }
        });

    butHolder.add(OKBut);
    butHolder.add(CancelBut);

    add(butHolder, BorderLayout.SOUTH);
  }
示例#8
0
  /** Sets up a customizer window for a Database Connection */
  private void setUpDatabase() {

    removeAll();

    JPanel db = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    // db.setLayout(new GridLayout(6, 1));
    db.setLayout(gbLayout);

    JLabel urlLab = new JLabel("Database URL", SwingConstants.RIGHT);
    urlLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(urlLab, gbConstraints);
    db.add(urlLab);

    m_dbaseURLText = new EnvironmentField();
    m_dbaseURLText.setEnvironment(m_env);
    /*    int width = m_dbaseURLText.getPreferredSize().width;
    int height = m_dbaseURLText.getPreferredSize().height;
    m_dbaseURLText.setMinimumSize(new Dimension(width * 2, height));
    m_dbaseURLText.setPreferredSize(new Dimension(width * 2, height)); */
    m_dbaseURLText.setText(((DatabaseConverter) m_dsLoader.getLoader()).getUrl());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 5;
    gbLayout.setConstraints(m_dbaseURLText, gbConstraints);
    db.add(m_dbaseURLText);

    JLabel userLab = new JLabel("Username", SwingConstants.RIGHT);
    userLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(userLab, gbConstraints);
    db.add(userLab);

    m_userNameText = new EnvironmentField();
    m_userNameText.setEnvironment(m_env);
    /*    m_userNameText.setMinimumSize(new Dimension(width * 2, height));
    m_userNameText.setPreferredSize(new Dimension(width * 2, height)); */
    m_userNameText.setText(((DatabaseConverter) m_dsLoader.getLoader()).getUser());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 1;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_userNameText, gbConstraints);
    db.add(m_userNameText);

    JLabel passwordLab = new JLabel("Password ", SwingConstants.RIGHT);
    passwordLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(passwordLab, gbConstraints);
    db.add(passwordLab);

    m_passwordText = new JPasswordField();
    JPanel passwordHolder = new JPanel();
    passwordHolder.setLayout(new BorderLayout());
    passwordHolder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    //    passwordHolder.add(passwordLab, BorderLayout.WEST);
    passwordHolder.add(m_passwordText, BorderLayout.CENTER);
    /*    passwordHolder.setMinimumSize(new Dimension(width * 2, height));
    passwordHolder.setPreferredSize(new Dimension(width * 2, height)); */
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(passwordHolder, gbConstraints);
    db.add(passwordHolder);

    JLabel queryLab = new JLabel("Query", SwingConstants.RIGHT);
    queryLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(queryLab, gbConstraints);
    db.add(queryLab);

    m_queryText = new EnvironmentField();
    m_queryText.setEnvironment(m_env);
    /*    m_queryText.setMinimumSize(new Dimension(width * 2, height));
    m_queryText.setPreferredSize(new Dimension(width * 2, height)); */
    m_queryText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getQuery());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_queryText, gbConstraints);
    db.add(m_queryText);

    JLabel keyLab = new JLabel("Key columns", SwingConstants.RIGHT);
    keyLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(keyLab, gbConstraints);
    db.add(keyLab);

    m_keyText = new EnvironmentField();
    m_keyText.setEnvironment(m_env);
    /*m_keyText.setMinimumSize(new Dimension(width * 2, height));
    m_keyText.setPreferredSize(new Dimension(width * 2, height)); */
    m_keyText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getKeys());
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_keyText, gbConstraints);
    db.add(m_keyText);

    JPanel buttonsP = new JPanel();
    buttonsP.setLayout(new FlowLayout());
    JButton ok, cancel;
    buttonsP.add(ok = new JButton("OK"));
    buttonsP.add(cancel = new JButton("Cancel"));
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            ((DatabaseLoader) m_dsLoader.getLoader()).resetStructure();
            ((DatabaseConverter) m_dsLoader.getLoader()).setUrl(m_dbaseURLText.getText());
            ((DatabaseConverter) m_dsLoader.getLoader()).setUser(m_userNameText.getText());
            ((DatabaseConverter) m_dsLoader.getLoader())
                .setPassword(new String(m_passwordText.getPassword()));
            ((DatabaseLoader) m_dsLoader.getLoader()).setQuery(m_queryText.getText());
            ((DatabaseLoader) m_dsLoader.getLoader()).setKeys(m_keyText.getText());
            try {
              m_dsLoader.notifyStructureAvailable(
                  ((DatabaseLoader) m_dsLoader.getLoader()).getStructure());
              // database connection has been configured
              m_dsLoader.setDB(true);
            } catch (Exception ex) {
            }
            if (m_parentFrame != null) {
              m_parentFrame.dispose();
            }
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (m_parentFrame != null) {
              m_parentFrame.dispose();
            }
          }
        });

    JPanel holderP = new JPanel();
    holderP.setLayout(new BorderLayout());
    holderP.add(db, BorderLayout.NORTH);
    holderP.add(buttonsP, BorderLayout.SOUTH);

    // db.add(buttonsP);
    JPanel about = m_LoaderEditor.getAboutPanel();
    if (about != null) {
      add(about, BorderLayout.NORTH);
    }
    add(holderP, BorderLayout.SOUTH);
  }
  private void setup() {
    JPanel aboutAndControlHolder = new JPanel();
    aboutAndControlHolder.setLayout(new BorderLayout());

    JPanel controlHolder = new JPanel();
    controlHolder.setLayout(new BorderLayout());
    JPanel fieldHolder = new JPanel();
    JPanel attListP = new JPanel();
    attListP.setLayout(new BorderLayout());
    attListP.setBorder(BorderFactory.createTitledBorder("Apply to attributes"));
    m_attListField = new EnvironmentField(m_env);
    attListP.add(m_attListField, BorderLayout.CENTER);
    attListP.setToolTipText(
        "<html>Accepts a range of indexes (e.g. '1,2,6-10')<br> "
            + "or a comma-separated list of named attributes</html>");
    JPanel matchP = new JPanel();
    matchP.setLayout(new BorderLayout());
    matchP.setBorder(BorderFactory.createTitledBorder("Match"));
    m_matchField = new EnvironmentField(m_env);
    matchP.add(m_matchField, BorderLayout.CENTER);
    JPanel labelP = new JPanel();
    labelP.setLayout(new BorderLayout());
    labelP.setBorder(BorderFactory.createTitledBorder("Label"));
    m_labelField = new EnvironmentField(m_env);
    labelP.add(m_labelField, BorderLayout.CENTER);
    fieldHolder.add(attListP);
    fieldHolder.add(matchP);
    fieldHolder.add(labelP);
    controlHolder.add(fieldHolder, BorderLayout.NORTH);

    JPanel checkHolder = new JPanel();
    checkHolder.setLayout(new GridLayout(0, 2));
    JLabel attNameLab = new JLabel("Name of label attribute", SwingConstants.RIGHT);
    checkHolder.add(attNameLab);
    m_matchAttNameField = new EnvironmentField(m_env);
    m_matchAttNameField.setText(m_labeler.getMatchAttributeName());
    checkHolder.add(m_matchAttNameField);
    JLabel regexLab = new JLabel("Match using a regular expression", SwingConstants.RIGHT);
    regexLab.setToolTipText("Use a regular expression rather than literal match");
    checkHolder.add(regexLab);
    checkHolder.add(m_regexCheck);
    JLabel caseLab = new JLabel("Ignore case when matching", SwingConstants.RIGHT);
    checkHolder.add(caseLab);
    checkHolder.add(m_ignoreCaseCheck);
    JLabel nominalBinaryLab =
        new JLabel("Make binary label attribute nominal", SwingConstants.RIGHT);
    nominalBinaryLab.setToolTipText(
        "<html>If the label attribute is binary (i.e. no <br>"
            + "explicit labels have been declared) then<br>this makes the resulting "
            + "attribute nominal<br>rather than numeric.</html>");
    checkHolder.add(nominalBinaryLab);
    checkHolder.add(m_nominalBinaryCheck);
    m_nominalBinaryCheck.setSelected(m_labeler.getNominalBinary());
    JLabel consumeNonMatchLab = new JLabel("Consume non-matching instances", SwingConstants.RIGHT);
    consumeNonMatchLab.setToolTipText(
        "<html>When explicit labels have been defined, consume "
            + "<br>(rather than output with missing value) instances</html>");
    checkHolder.add(consumeNonMatchLab);
    checkHolder.add(m_consumeNonMatchingCheck);
    m_consumeNonMatchingCheck.setSelected(m_labeler.getConsumeNonMatching());

    controlHolder.add(checkHolder, BorderLayout.SOUTH);

    aboutAndControlHolder.add(controlHolder, BorderLayout.SOUTH);
    JPanel aboutP = m_tempEditor.getAboutPanel();
    aboutAndControlHolder.add(aboutP, BorderLayout.NORTH);
    add(aboutAndControlHolder, BorderLayout.NORTH);

    m_list.setVisibleRowCount(5);
    m_deleteBut.setEnabled(false);
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BorderLayout());
    JPanel butHolder = new JPanel();
    butHolder.setLayout(new GridLayout(1, 0));
    butHolder.add(m_newBut);
    butHolder.add(m_deleteBut);
    butHolder.add(m_upBut);
    butHolder.add(m_downBut);
    m_upBut.setEnabled(false);
    m_downBut.setEnabled(false);

    listPanel.add(butHolder, BorderLayout.NORTH);
    JScrollPane js = new JScrollPane(m_list);
    js.setBorder(BorderFactory.createTitledBorder("Match-list list (rows applied in order)"));
    listPanel.add(js, BorderLayout.CENTER);
    add(listPanel, BorderLayout.CENTER);

    addButtons();

    m_attListField.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent e) {
            Object m = m_list.getSelectedValue();
            if (m != null) {
              ((SubstringLabeler.Match) m).setAttsToApplyTo(m_attListField.getText());
              m_list.repaint();
            }
          }
        });

    m_matchField.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent e) {
            Object m = m_list.getSelectedValue();
            if (m != null) {
              ((SubstringLabeler.Match) m).setMatch(m_matchField.getText());
              m_list.repaint();
            }
          }
        });

    m_labelField.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent e) {
            Object m = m_list.getSelectedValue();
            if (m != null) {
              ((SubstringLabeler.Match) m).setLabel(m_labelField.getText());
              m_list.repaint();
            }
          }
        });

    m_list.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
              if (!m_deleteBut.isEnabled()) {
                m_deleteBut.setEnabled(true);
              }

              Object entry = m_list.getSelectedValue();
              if (entry != null) {
                SubstringLabeler.Match m = (SubstringLabeler.Match) entry;
                m_attListField.setText(m.getAttsToApplyTo());
                m_matchField.setText(m.getMatch());
                m_labelField.setText(m.getLabel());
                m_regexCheck.setSelected(m.getRegex());
                m_ignoreCaseCheck.setSelected(m.getIgnoreCase());
              }
            }
          }
        });

    m_newBut.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstringLabeler.Match m = new SubstringLabeler.Match();

            String atts = (m_attListField.getText() != null) ? m_attListField.getText() : "";
            m.setAttsToApplyTo(atts);
            String match = (m_matchField.getText() != null) ? m_matchField.getText() : "";
            m.setMatch(match);
            String label = (m_labelField.getText() != null) ? m_labelField.getText() : "";
            m.setLabel(label);
            m.setRegex(m_regexCheck.isSelected());
            m.setIgnoreCase(m_ignoreCaseCheck.isSelected());

            m_listModel.addElement(m);

            if (m_listModel.size() > 1) {
              m_upBut.setEnabled(true);
              m_downBut.setEnabled(true);
            }

            m_list.setSelectedIndex(m_listModel.size() - 1);
          }
        });

    m_deleteBut.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int selected = m_list.getSelectedIndex();
            if (selected >= 0) {
              m_listModel.removeElementAt(selected);

              if (m_listModel.size() <= 1) {
                m_upBut.setEnabled(false);
                m_downBut.setEnabled(false);
              }
            }
          }
        });

    m_upBut.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JListHelper.moveUp(m_list);
          }
        });

    m_downBut.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JListHelper.moveDown(m_list);
          }
        });

    m_regexCheck.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object m = m_list.getSelectedValue();
            if (m != null) {
              ((SubstringLabeler.Match) m).setRegex(m_regexCheck.isSelected());
              m_list.repaint();
            }
          }
        });

    m_ignoreCaseCheck.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object m = m_list.getSelectedValue();
            if (m != null) {
              ((SubstringLabeler.Match) m).setIgnoreCase(m_ignoreCaseCheck.isSelected());
              m_list.repaint();
            }
          }
        });
  }