Esempio n. 1
0
  /**
   * Make sure the sketch hasn't been moved or deleted by some nefarious user. If they did, try to
   * re-create it and save. Only checks to see if the main folder is still around, but not its
   * contents.
   */
  private void ensureExistence() {
    if (sketch.getFolder().exists()) return;

    Base.showWarning(
        tr("Sketch Disappeared"),
        tr(
            "The sketch folder has disappeared.\n "
                + "Will attempt to re-save in the same location,\n"
                + "but anything besides the code will be lost."),
        null);
    try {
      sketch.getFolder().mkdirs();

      for (SketchFile file : sketch.getFiles()) {
        file.save(); // this will force a save
      }
      calcModified();

    } catch (Exception e) {
      Base.showWarning(
          tr("Could not re-save sketch"),
          tr(
              "Could not properly re-save the sketch. "
                  + "You may be in trouble at this point,\n"
                  + "and it might be time to copy and paste "
                  + "your code to another text editor."),
          e);
    }
  }