Search in sources :

Example 1 with MMDDataObject

use of com.igormaznitsa.nbmindmap.nb.editor.MMDDataObject in project netbeans-mmd-plugin by raydac.

the class MindMapLink method writeUTF8Text.

public void writeUTF8Text(final String text) throws IOException {
    final FileObject foj = getFile();
    final FileLock flock = lock(foj);
    try {
        final OutputStream out = foj.getOutputStream(flock);
        try {
            IOUtils.write(text, out, "UTF-8");
        } finally {
            IOUtils.closeQuietly(out);
        }
    } finally {
        flock.releaseLock();
    }
    final DataObject doj = DataObject.find(foj);
    if (doj != null && doj instanceof MMDDataObject) {
        LOGGER.info("Notify about change primary file");
        ((MMDDataObject) doj).firePrimaryFileChanged();
    }
}
Also used : MMDDataObject(com.igormaznitsa.nbmindmap.nb.editor.MMDDataObject) DataObject(org.openide.loaders.DataObject) OutputStream(java.io.OutputStream) FileLock(org.openide.filesystems.FileLock) FileObject(org.openide.filesystems.FileObject) MMDDataObject(com.igormaznitsa.nbmindmap.nb.editor.MMDDataObject)

Aggregations

MMDDataObject (com.igormaznitsa.nbmindmap.nb.editor.MMDDataObject)1 OutputStream (java.io.OutputStream)1 FileLock (org.openide.filesystems.FileLock)1 FileObject (org.openide.filesystems.FileObject)1 DataObject (org.openide.loaders.DataObject)1