public static void close() { try { getDataObject().getCookie(CloseCookie.class).close(); opened = false; // TODO: check for correct close on debug close Disassembly dis = getCurrent(); if (dis != null) { dis.debugger.registerDisassembly(null); } } catch (Exception e) { // #238339 if (e instanceof NullPointerException) { DataObject dObj = getDataObject(); LOG.log(Level.INFO, "dObj={0}; cookie={1}", new Object[]{dObj, dObj.getCookie(CloseCookie.class)}); } Exceptions.printStackTrace(e); } }
public static void closeMemoryBasedDocument(Document doc) { if (doc != null && doc.getProperty(CsmMacroExpansion.MACRO_EXPANSION_VIEW_DOCUMENT) != null) { DataObject dob = (DataObject) doc.getProperty(Document.StreamDescriptionProperty); if (dob != null) { CloseCookie closeCookie = dob.getLookup().lookup(CloseCookie.class); if (closeCookie != null) { closeCookie.close(); } FileObject primaryFile = dob.getPrimaryFile(); if (primaryFile != null && primaryFile.isValid() && !primaryFile.isLocked()) { assert primaryFile.equals(doc.getProperty(FileObject.class)); try { primaryFile.delete(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } } } /**
CloseCookie cc = (CloseCookie)javaDataObject.getCookie(CloseCookie.class); if (cc != null) { cc.close();