Example #1
0
 public void newFile() {
   if (buf.getModified()) {
     if (DialogManager.handleModifiedBuffer(
         true, StringResources.getInstance().getString("untitled"), this)) {
       newBuffer();
     } else {
       return;
     }
   } else {
     newBuffer();
   }
 }
Example #2
0
  public void openFile() {
    boolean modified = buf.getModified();
    String filename = null;
    if (modified) {
      if (DialogManager.handleModifiedBuffer(
          true, StringResources.getInstance().getString("untitled"), this)) {
        filename = DialogManager.showOpenDialog(OpenInputFileDialog.getInstance());
      } else {
        return;
      }
    } else {
      filename = DialogManager.showOpenDialog(OpenInputFileDialog.getInstance());
    }

    if (filename != null) {
      newBufferFromFile(new File(filename));
    }
  }
Example #3
0
  public boolean saveFile(boolean saveAs) {

    String filename =
        DialogManager.showSaveDialog(
            SaveInputFileDialog.getInstance(),
            null,
            StringResources.getInstance().getString("untitled"));
    if (filename != null) {
      File target = new File(filename);
      try {
        BufferedWriter out = new BufferedWriter(new FileWriter(target));
        out.write(buf.getText());
        out.flush();
        out.close();
        buf.setModified(false);
        return true;
      } catch (IOException e) {
        return false;
      }
    } else {
      return false;
    }
  }