Beispiel #1
0
 private void handleClose(String result) {
         // get the text handler 
         Editor editor=(Editor)getJPE().getEditor();        
         if (editor!=null) {
                 // get the selected file from the text handler
                 OpenFile file=editor.getEditFile();
                 if (file!=null) {
                         if (result.equals("y")) file.saveFile();
                         file.clearDirty();
                         closeFile();
                 }
         }
 }
Beispiel #2
0
 /**
 * save selected file to disk
 */
 private void saveFile() {
         // get the text handler 
         Editor editor=(Editor)getJPE().getEditor();        
         if (editor!=null) {
                 // get the selected file from the text handler
                 OpenFile file=editor.getEditFile();
                 if (file!=null) {
                         // signal the use we are saving and save it to disk                
                         getJPE().say("Saving file "+file.getName());
                         file.saveFile();
                         getJPE().say("Saved file "+file.getName());
                 }
         }
 }
Beispiel #3
0
 /**
 * close the selected file, meaning removing it from the Opened
 * list and removing it from the auto reload on startup list
 */
 private void closeFile() {
         OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened");        
         Editor editor=(Editor)getJPE().getEditor();        
         if (editor!=null) {
                 OpenFile file=editor.getEditFile();
                 if (!file.isDirty()) {
                         ofh.removeFile(file);
                         addRecent(file.getName());
                         ofh.switchOpenFile();
                 } else {
                         getJPE().setAskMode(this,"close","File not saved, save first  (y/n) ? ",true);
                 }
         }
 }
Beispiel #4
0
 public void handleRevert(String answer) {
         if("y".equals(answer)) {
                 Editor editor=(Editor)getJPE().getEditor();        
                 if (editor!=null) {
                         // get the selected file from the text handler
                         OpenFile file=editor.getEditFile();
                         if (file!=null) {
                                 // revert the file
                                 file.loadFile();
                                 // tell editor to useFile, without saving
                                 editor.useFile(file,false);
                         }
                 }
         }
 }
Beispiel #5
0
 private void lockFile() {
         OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened");        
         Editor editor=(Editor)getJPE().getEditor();        
         if (editor!=null) {
                 OpenFile file=editor.getEditFile();
                 if (file.isLocked()) {
                         file.clearLocked();
                         getJPE().setLockState(false);
                         getJPE().say("file is now unlocked ( read / write )");
                 } else {
                         file.setLocked();
                         getJPE().setLockState(true);
                         getJPE().say("file is now locked (read only)");
                 }
                 ofh.updateProperties();
         }
 }
Beispiel #6
0
 /**
 * ask the user for a filename (using a file requester) and save
 * the current file under that name
 */
 private void saveAsFile() {
         // get openfile handlers
         OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened");        
         if (ofh!=null) {
                 // ask the user for the file name
                 String filename=getFileName(FileDialog.SAVE);
                 // get the text handler
                 Editor editor=(Editor)getJPE().getEditor();        
                 // get the selected file                                
                 OpenFile file=editor.getEditFile();
                 // remove the file from the opened list
                 ofh.removeFile(file);
                 if (file!=null) {
                         // set the new name in the file
                         file.setName(filename);
                         getJPE().say("Saving file "+file.getName());
                         // save the file under this new name
                         file.saveFile();
                         // add the file to the opened files again  (now new name)
                         ofh.addFile(file);
                         getJPE().say("Saved file "+file.getName());
                 }
         }
 }