Exemple #1
0
  /** Returns false if Exception is thrown. */
  private boolean setDirectory() {
    String pathStr = dirTF.getText().trim();
    if (pathStr.equals("")) pathStr = System.getProperty("user.dir");
    try {
      File dirPath = new File(pathStr);
      if (!dirPath.isDirectory()) {
        if (!dirPath.exists()) {
          if (recursiveCheckBox.isSelected())
            throw new NotDirectoryException(dirPath.getAbsolutePath());
          else throw new NotFileException(dirPath.getAbsolutePath());
        } else {
          convertSet.setFile(dirPath);
          convertSet.setDestinationPath(dirPath.getParentFile());
        }
      } else {
        // Set the descriptors
        setMatchingFileNames();

        FlexFilter flexFilter = new FlexFilter();
        flexFilter.addDescriptors(descriptors);
        flexFilter.setFilesOnly(!recursiveCheckBox.isSelected());

        convertSet.setSourcePath(dirPath, flexFilter);
        convertSet.setDestinationPath(dirPath);
      }
    } catch (NotDirectoryException e1) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1");

      MessageFormat formatter;
      String info_msg;
      if (pathStr.equals("")) {
        info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5");
      } else {
        formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0"));
        info_msg = formatter.format(new Object[] {pathStr});
      }
      final String info = info_msg;

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    } catch (NotFileException e2) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1"));
      final String info = formatter.format(new Object[] {pathStr});

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true; // no exception thrown
  }
Exemple #2
0
  private void showAboutDialog() {
    final String aboutCaption = ResourceHandler.getMessage("about_dialog.caption");

    // Version string
    final String version = System.getProperty("java.version");

    MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("about_dialog.info"));
    final String aboutInfo = formatter.format(new Object[] {version});

    JOptionPane.showMessageDialog(this, aboutInfo, aboutCaption, JOptionPane.INFORMATION_MESSAGE);
  }
Exemple #3
0
  /** Displayed when the template file is not found in the classpath or the working directory. */
  private void showNoTemplateDialog() {
    final String caption = ResourceHandler.getMessage("notemplate_dialog.caption");
    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("notemplate_dialog.info"));
    final String info =
        formatter.format(new Object[] {PluginConverter.getDefaultTemplateFileName()});

    JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);

    System.exit(0);
  }
Exemple #4
0
  /** Set the template file path. */
  private boolean setTemplateFile(String pathStr) {
    File templateFile = new File(templateCh.getSelectedPath(pathStr));

    if (!templateFile.getName().toLowerCase().endsWith(".tpl")) {
      final String templateCaption = ResourceHandler.getMessage("nottemplatefile_dialog.caption");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("nottemplatefile_dialog.info0"));
      final String errorMessage = formatter.format(new Object[] {templateFile.getName()});

      String defaultTemplateName = PluginConverter.getDefaultTemplateFileName();
      JOptionPane.showMessageDialog(this, errorMessage, templateCaption, JOptionPane.ERROR_MESSAGE);

      templateCh.select(templateCh.getPreviousSelection());
      return false;
    }

    try {
      converter.setTemplateFilePath(templateCh.getSelectedPath(pathStr));
    } catch (FileNotFoundException e) {
      // TO-DO:  found it, but it's not a file.
      // TO-DO:  Throw up a Dialog -- "Not a valid file, resetting to default file"

      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0");

      MessageFormat formatter;
      String info_msg;
      if (pathStr.equals("")) {
        info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5");
      } else {
        formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1"));
        info_msg = formatter.format(new Object[] {pathStr});
      }
      final String info = info_msg;

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true;
  }
Exemple #5
0
  /**
   * Pop-up a Dialog if the source and backup fields are the same. Returns true if the source and
   * backup remain the same.
   */
  private boolean testSourceVsBackup() {
    if (dirTF.getText().equals(backupTF.getText())) {
      final String caption = ResourceHandler.getMessage("caption.warning");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("warning_dialog.info"));
      final String info = formatter.format(new Object[] {backupTF.getText()});

      int n = JOptionPane.showConfirmDialog(this, info, caption, JOptionPane.WARNING_MESSAGE);

      if (n == JOptionPane.YES_OPTION) {
        backupTF.setText(backupTF.getText() + "_BAK");

        return false;
      } else if (n == JOptionPane.NO_OPTION) return true;
    }

    return false;
  }