Search in sources :

Example 11 with MustNotContainNull

use of com.igormaznitsa.meta.annotation.MustNotContainNull in project netbeans-mmd-plugin by raydac.

the class NodeProject method replaceAllLinksToFile.

@Nonnull
@MustNotContainNull
public List<File> replaceAllLinksToFile(@Nonnull @MustNotContainNull final List<File> listOfFilesToProcess, @Nonnull final File oldFile, @Nonnull final File newFile) {
    final List<File> affectedFiles = new ArrayList<>();
    final File baseFolder = makeFileForNode();
    final MMapURI oldFileURI = new MMapURI(baseFolder, oldFile, null);
    final MMapURI newFileURI = new MMapURI(baseFolder, newFile, null);
    for (final File file : listOfFilesToProcess) {
        if (file.isFile()) {
            try {
                // NOI18N
                final MindMap map = new MindMap(null, new StringReader(FileUtils.readFileToString(file, "UTF-8")));
                if (map.replaceAllLinksToFile(baseFolder, oldFileURI, newFileURI)) {
                    SystemUtils.saveUTFText(file, map.packToString());
                    affectedFiles.add(file);
                }
            } catch (IOException ex) {
                // NOI18N
                LOGGER.error("Can't process mind map file", ex);
            }
        }
    }
    return affectedFiles;
}
Also used : MindMap(com.igormaznitsa.mindmap.model.MindMap) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) IOException(java.io.IOException) File(java.io.File) MMapURI(com.igormaznitsa.mindmap.model.MMapURI) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 12 with MustNotContainNull

use of com.igormaznitsa.meta.annotation.MustNotContainNull in project netbeans-mmd-plugin by raydac.

the class NbUtils method findAllSourceGroups.

@Nonnull
@MustNotContainNull
public static Collection<SourceGroup> findAllSourceGroups(@Nonnull final Project project) {
    final Sources sources = ProjectUtils.getSources(project);
    final Set<SourceGroup> result = new HashSet<SourceGroup>();
    for (final String scopeType : ALL_KNOWN_SCOPE_TYPES) {
        for (final SourceGroup s : sources.getSourceGroups(scopeType)) {
            result.add(s);
        }
    }
    if (result.isEmpty() && !project.getClass().getName().equals("org.netbeans.modules.maven.NbMavenProjectImpl")) {
        for (final SourceGroup s : sources.getSourceGroups(Sources.TYPE_GENERIC)) {
            result.add(s);
        }
    }
    return result;
}
Also used : Sources(org.netbeans.api.project.Sources) MMKnowledgeSources(com.igormaznitsa.nbmindmap.nb.explorer.MMKnowledgeSources) SourceGroup(org.netbeans.api.project.SourceGroup) HashSet(java.util.HashSet) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 13 with MustNotContainNull

use of com.igormaznitsa.meta.annotation.MustNotContainNull in project netbeans-mmd-plugin by raydac.

the class CoggleMM2MindMapImporter method extractImageURLs.

@Nonnull
@MustNotContainNull
private List<String> extractImageURLs(@Nonnull final String mdText, @Nonnull final StringBuilder resultText) {
    final List<String> result = new ArrayList<String>();
    final Matcher matcher = MD_IMAGE_LINK.matcher(mdText);
    int lastFoundEnd = 0;
    while (matcher.find()) {
        final String text = matcher.group(1);
        result.add(matcher.group(2));
        resultText.append(mdText, lastFoundEnd, matcher.start()).append(text);
        lastFoundEnd = matcher.end();
    }
    if (lastFoundEnd < mdText.length()) {
        resultText.append(mdText, lastFoundEnd, mdText.length());
    }
    return result;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 14 with MustNotContainNull

use of com.igormaznitsa.meta.annotation.MustNotContainNull in project netbeans-mmd-plugin by raydac.

the class Freemind2MindMapImporter method extractRichContent.

@Nonnull
@MustNotContainNull
private static List<RichContent> extractRichContent(@Nonnull final Element richContentElement) {
    final List<Element> richContents = Utils.findDirectChildrenForName(richContentElement, "richcontent");
    final List<RichContent> result = new ArrayList<RichContent>();
    final List<String> foundImageUrls = new ArrayList<String>();
    for (final Element e : richContents) {
        final String textType = e.getAttribute("TYPE");
        try {
            foundImageUrls.clear();
            final RichContentType type = RichContentType.valueOf(textType);
            final String text = extractTextFromHtmlElement(e, new StringBuilder(), foundImageUrls).toString().replace("\r", "");
            result.add(new RichContent(type, text, foundImageUrls));
        } catch (IllegalArgumentException ex) {
            LOGGER.warn("Unknown node type : " + textType);
        }
    }
    return result;
}
Also used : AbstractCollapsableElement(com.igormaznitsa.mindmap.swing.panel.ui.AbstractCollapsableElement) Element(org.w3c.dom.Element) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Aggregations

MustNotContainNull (com.igormaznitsa.meta.annotation.MustNotContainNull)14 Nonnull (javax.annotation.Nonnull)14 ArrayList (java.util.ArrayList)9 File (java.io.File)4 MMapURI (com.igormaznitsa.mindmap.model.MMapURI)3 MindMap (com.igormaznitsa.mindmap.model.MindMap)3 Topic (com.igormaznitsa.mindmap.model.Topic)3 IOException (java.io.IOException)3 StringReader (java.io.StringReader)3 AbstractCollapsableElement (com.igormaznitsa.mindmap.swing.panel.ui.AbstractCollapsableElement)2 Matcher (java.util.regex.Matcher)2 SourceGroup (org.netbeans.api.project.SourceGroup)2 Sources (org.netbeans.api.project.Sources)2 Element (org.w3c.dom.Element)2 ExtraFile (com.igormaznitsa.mindmap.model.ExtraFile)1 MindMapPlugin (com.igormaznitsa.mindmap.plugins.api.MindMapPlugin)1 PopUpMenuItemPlugin (com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin)1 AbstractElement (com.igormaznitsa.mindmap.swing.panel.ui.AbstractElement)1 MMKnowledgeSources (com.igormaznitsa.nbmindmap.nb.explorer.MMKnowledgeSources)1 Rectangle (java.awt.Rectangle)1