Search in sources :

Example 1 with MapVersionInterpreter

use of org.freeplane.features.url.MapVersionInterpreter in project freeplane by freeplane.

the class SummaryNodeMapUpdater method onCreate.

@Override
public void onCreate(MapModel map) {
    final MapVersionInterpreter mapXmlVersionInterpreter = map.getExtension(MapVersionInterpreter.class);
    if (mapXmlVersionInterpreter == null || mapXmlVersionInterpreter.version < 6) {
        modeController.deactivateUndo((MMapModel) map);
        updateSummaryNodes(map.getRootNode());
    }
}
Also used : MapVersionInterpreter(org.freeplane.features.url.MapVersionInterpreter)

Example 2 with MapVersionInterpreter

use of org.freeplane.features.url.MapVersionInterpreter in project freeplane by freeplane.

the class MFileManager method loadTreeImpl.

private NodeModel loadTreeImpl(final MapModel map, final File f) throws FileNotFoundException, IOException, XMLException, MapConversionException {
    final BufferedInputStream file = new BufferedInputStream(new FileInputStream(f));
    int versionInfoLength = 1000;
    final byte[] buffer = new byte[versionInfoLength];
    final int readCount = file.read(buffer);
    final String mapStart = new String(buffer, FileUtils.defaultCharset().name());
    final ByteArrayInputStream readBytes = new ByteArrayInputStream(buffer, 0, readCount);
    final InputStream sequencedInput = new SequenceInputStream(readBytes, file);
    Reader reader = null;
    MapVersionInterpreter versionInterpreter = MapVersionInterpreter.getVersionInterpreter(mapStart);
    map.addExtension(versionInterpreter);
    if (versionInterpreter.anotherDialect) {
        String message = versionInterpreter.getDialectInfo(f.getAbsolutePath());
        UITools.showMessage(message, JOptionPane.WARNING_MESSAGE);
    }
    if (versionInterpreter.needsConversion) {
        final int showResult = OptionalDontShowMeAgainDialog.show("really_convert_to_current_version", "confirmation", MMapController.RESOURCES_CONVERT_TO_CURRENT_VERSION, OptionalDontShowMeAgainDialog.ONLY_OK_SELECTION_IS_STORED);
        IMapInputStreamConverter isConverter = versionInterpreter.getMapInputStreamConverter();
        if (showResult != JOptionPane.OK_OPTION || isConverter == null) {
            reader = new XsltPipeReaderFactory().getActualReader(sequencedInput);
        } else {
            sequencedInput.close();
            // reader = UrlManager.getUpdateReader(f, FREEPLANE_VERSION_UPDATER_XSLT);
            reader = isConverter.getConvertedStream(f);
        }
    } else
        reader = new XsltPipeReaderFactory().getActualReader(sequencedInput);
    try {
        return Controller.getCurrentModeController().getMapController().getMapReader().createNodeTreeFromXml(map, reader, Mode.FILE);
    } finally {
        FileUtils.silentlyClose(reader);
    }
}
Also used : SequenceInputStream(java.io.SequenceInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInputStream(java.io.SequenceInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) XsltPipeReaderFactory(org.freeplane.core.util.XsltPipeReaderFactory) FileInputStream(java.io.FileInputStream) MapVersionInterpreter(org.freeplane.features.url.MapVersionInterpreter) IMapInputStreamConverter(org.freeplane.features.url.IMapInputStreamConverter)

Aggregations

MapVersionInterpreter (org.freeplane.features.url.MapVersionInterpreter)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 SequenceInputStream (java.io.SequenceInputStream)1 XsltPipeReaderFactory (org.freeplane.core.util.XsltPipeReaderFactory)1 IMapInputStreamConverter (org.freeplane.features.url.IMapInputStreamConverter)1