예제 #1
0
 /** Save the terminal text to file. */
 public void save() {
   initialise();
   String fileName =
       FileUtility.getFileName(
           this,
           Config.getString("terminal.save.title"),
           Config.getString("terminal.save.buttonText"),
           null,
           false);
   if (fileName != null) {
     File f = new File(fileName);
     if (f.exists()) {
       if (DialogManager.askQuestion(this, "error-file-exists") != 0) return;
     }
     try {
       FileWriter writer = new FileWriter(fileName);
       text.write(writer);
       writer.close();
     } catch (IOException ex) {
       DialogManager.showError(this, "error-save-file");
     }
   }
 }
예제 #2
0
  public static void setClassImage(ClassView classView, ImageClassRole gclassRole, File imageFile) {
    GClass gclass = classView.getGClass();
    File projImagesDir = gclass.getPackage().getProject().getImageDir();
    if (imageFile != null) {
      if (!imageFile.getParentFile().getAbsoluteFile().equals(projImagesDir)) {
        // An image was selected from an external dir. We need
        // to copy it into the project images directory first.
        File destFile = new File(projImagesDir, imageFile.getName());
        try {
          FileUtility.copyFile(imageFile, destFile);
          imageFile = destFile;
        } catch (IOException e) {
          Debug.reportError("Error when copying file: " + imageFile + " to: " + destFile, e);
        }
      }

      gclass.setClassProperty("image", imageFile.getName());
    } else {
      imageFile = null;
      gclass.setClassProperty("image", null);
    }
    gclassRole.changeImage();
    gclass.getPackage().getProject().getProjectProperties().save();
  }