1 19 20 package org.netbeans.modules.lexer.editorbridge.calc; 21 22 import java.io.IOException ; 23 import org.openide.cookies.EditorCookie; 24 import org.openide.cookies.EditCookie; 25 import org.openide.cookies.OpenCookie; 26 import org.openide.cookies.PrintCookie; 27 import org.openide.cookies.SaveCookie; 28 import org.openide.loaders.DataObject; 29 import org.openide.text.DataEditorSupport; 30 31 37 38 class CalcDataEditorSupport extends DataEditorSupport 39 implements OpenCookie, EditCookie, EditorCookie, PrintCookie { 40 41 private final Save save; 43 CalcDataEditorSupport(DataObject obj) { 44 super(obj, new DataEditorSupportEnv(obj)); 45 46 save = new Save(); 47 setMIMEType(CalcDataLoader.CALC_MIME_TYPE); 48 } 49 50 protected boolean notifyModified () { 51 if (!super.notifyModified ()) { 52 return false; 53 } else { 54 ((CalcDataObject)getDataObject()).enableSave(save); 55 return true; 56 } 57 } 58 59 protected void notifyUnmodified () { 60 super.notifyUnmodified (); 61 ((CalcDataObject)getDataObject()).disableSave(save); 62 } 63 64 private class Save implements SaveCookie { 65 66 public void save() throws IOException { 67 saveDocument(); 68 getDataObject().setModified(false); 69 } 70 71 } 72 73 } 74 | Popular Tags |