예제 #1
0
  public boolean savePathwayAs() {
    PathwayChooser pc =
        new PathwayChooser(
            "Save",
            JFileChooser.SAVE_DIALOG,
            GlobalPreference.DIR_LAST_USED_SAVE,
            GPML_FORMAT_ONLY);
    int status = pc.show();

    if (status == JFileChooser.APPROVE_OPTION) {
      File toFile = pc.getSelectedFile();
      String fn = toFile.toString();
      if (!fn.toLowerCase().endsWith(Engine.PATHWAY_FILE_EXTENSION)) {
        toFile = new File(fn + "." + Engine.PATHWAY_FILE_EXTENSION);
      }
      try {
        if (mayOverwrite(toFile)) {
          engine.savePathway(toFile);
          return true;
        }
      } catch (ConverterException e) {
        handleConverterException(e.getMessage(), null, e);
      }
    }
    return false;
  }
예제 #2
0
  public boolean importPathway() {
    PathwayChooser pc =
        new PathwayChooser(
            "Import",
            JFileChooser.OPEN_DIALOG,
            GlobalPreference.DIR_LAST_USED_IMPORT,
            engine.getPathwayImporters());
    int status = pc.show();

    if (status == JFileChooser.APPROVE_OPTION) {
      File f = pc.getSelectedFile();
      return importPathway(f);
    }
    return false;
  }
예제 #3
0
  /**
   * Opens a file chooser dialog, and opens the chosen pathway.
   *
   * @return true if a pathway was openend, false if the operation was cancelled
   */
  public boolean openPathway() {
    PathwayChooser pc =
        new PathwayChooser(
            "Open",
            JFileChooser.OPEN_DIALOG,
            GlobalPreference.DIR_LAST_USED_OPEN,
            GPML_FORMAT_ONLY);
    int status = pc.show();

    if (status == JFileChooser.APPROVE_OPTION) {
      File f = pc.getSelectedFile();
      return openPathway(f);
    }
    return false;
  }
예제 #4
0
  public boolean exportPathway() {
    PathwayChooser pc =
        new PathwayChooser(
            "Export",
            JFileChooser.SAVE_DIALOG,
            GlobalPreference.DIR_LAST_USED_EXPORT,
            engine.getPathwayExporters());
    int status = pc.show();

    if (status == JFileChooser.APPROVE_OPTION) {
      File f = pc.getSelectedFile();

      PathwayFileFilter ff = (PathwayFileFilter) pc.getFileFilter();
      if (!f.toString().toUpperCase().endsWith("." + ff.getDefaultExtension().toUpperCase())) {
        f = new File(f.toString() + "." + ff.getDefaultExtension());
      }
      return exportPathway(f);
    }
    return false;
  }