home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 May / PCO_5_97.ISO / FilesBBS / OS2 / CSIME.ARJ / CSIME.ZIP / csime / mug / app / SaveCommand.class (.txt) < prev   
Encoding:
Java Class File  |  1997-02-09  |  1.4 KB  |  49 lines

  1. package mug.app;
  2.  
  3. import java.awt.Window;
  4. import java.io.File;
  5. import mug.ui.Callback;
  6. import mug.ui.QuestionDialog;
  7.  
  8. public class SaveCommand extends Command implements Callback {
  9.    private ApplicationFrame _app;
  10.    private boolean _saveAs;
  11.    private File _file;
  12.  
  13.    public SaveCommand(ApplicationFrame var1, boolean var2) {
  14.       this._app = var1;
  15.       this._saveAs = var2;
  16.    }
  17.  
  18.    public void execute() {
  19.       Document var1 = this._app.getDocument();
  20.       if (this._saveAs || (this._file = var1.getFile()) == null) {
  21.          if ((this._file = this._app.showSaveFileDialog()) == null) {
  22.             return;
  23.          }
  24.  
  25.          if (this._file.exists()) {
  26.             String[] var2 = new String[]{"Ok", "Cancel"};
  27.             QuestionDialog var3 = new QuestionDialog(this._app, this._saveAs ? "Save As" : "Save", true, this._app.overwriteMessage(), var2, this);
  28.             ((Window)var3).show();
  29.             return;
  30.          }
  31.       }
  32.  
  33.       if (var1.save(this._file)) {
  34.          ((Command)this).executeNext();
  35.       }
  36.  
  37.    }
  38.  
  39.    public void execute(Object var1, Object var2) {
  40.       if (((String)var2).equals("Ok")) {
  41.          Document var3 = this._app.getDocument();
  42.          if (var3.save(this._file)) {
  43.             ((Command)this).executeNext();
  44.          }
  45.       }
  46.  
  47.    }
  48. }
  49.