Search in sources :

Example 1 with MustNotContainNull

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

the class CoggleMM2MindMapImporter method extractURLs.

@Nonnull
@MustNotContainNull
private List<String> extractURLs(@Nonnull final String mdText, @Nonnull final StringBuilder resultText) {
    final List<String> result = new ArrayList<String>();
    final Matcher matcher = MD_URL_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 2 with MustNotContainNull

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

the class Utils method findDirectChildrenForName.

/**
 * Find all direct children with defined name.
 *
 * @param element          parent element
 * @param childElementname child element name
 * @return list of found elements
 * @since 1.4.0
 */
@Nonnull
@MustNotContainNull
public static List<Element> findDirectChildrenForName(@Nonnull final Element element, @Nonnull final String childElementname) {
    final NodeList found = element.getElementsByTagName(childElementname);
    final List<Element> resultList = new ArrayList<Element>();
    for (int i = 0; i < found.getLength(); i++) {
        if (found.item(i).getParentNode().equals(element) && found.item(i) instanceof Element) {
            resultList.add((Element) found.item(i));
        }
    }
    return resultList;
}
Also used : NodeList(org.w3c.dom.NodeList) AbstractElement(com.igormaznitsa.mindmap.swing.panel.ui.AbstractElement) AbstractCollapsableElement(com.igormaznitsa.mindmap.swing.panel.ui.AbstractCollapsableElement) Element(org.w3c.dom.Element) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 3 with MustNotContainNull

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

the class RefactoringUtils method findAllMindMapsInProject.

@Nonnull
@MustNotContainNull
public static List<FileObject> findAllMindMapsInProject(@Nonnull final Project project, @Nullable final AbstractPlugin plugin) {
    final List<FileObject> result = new ArrayList<FileObject>();
    final Sources sources = ProjectUtils.getSources(project);
    final SourceGroup[] groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    for (final SourceGroup g : groups) {
        if (plugin != null && plugin.isCanceled()) {
            return result;
        }
        final FileObject gobject = g.getRootFolder();
        if (gobject != null) {
            final Enumeration<? extends FileObject> e = gobject.getChildren(true);
            while (e.hasMoreElements()) {
                if (plugin != null && plugin.isCanceled()) {
                    return result;
                }
                final FileObject nxt = e.nextElement();
                if (nxt.isData() && nxt.hasExt("mmd")) {
                    result.add(nxt);
                }
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) FileObject(org.openide.filesystems.FileObject) Sources(org.netbeans.api.project.Sources) SourceGroup(org.netbeans.api.project.SourceGroup) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 4 with MustNotContainNull

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

the class MouseSelectedArea method getAllSelectedElements.

@Nonnull
@MustNotContainNull
public List<Topic> getAllSelectedElements(@Nonnull final MindMap map) {
    final List<Topic> result = new ArrayList<Topic>();
    final Rectangle rect = asRectangle();
    addCoveredToList(result, map.getRoot(), rect.getBounds2D());
    return result;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Topic(com.igormaznitsa.mindmap.model.Topic) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 5 with MustNotContainNull

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

the class MapUtils method findTopicsRelatedToFile.

@Nonnull
@MustNotContainNull
public static List<Topic> findTopicsRelatedToFile(@Nullable final File baseFolder, @Nonnull final File file, @Nonnull final MindMap map) {
    final List<Topic> result = new ArrayList<>();
    final Path theFile = file.isAbsolute() ? file.toPath() : new File(baseFolder, file.getAbsolutePath()).toPath();
    final boolean folder = file.isDirectory();
    for (final Topic t : map) {
        final ExtraFile linkToFile = (ExtraFile) t.getExtras().get(Extra.ExtraType.FILE);
        if (linkToFile != null) {
            final MMapURI uri = linkToFile.getAsURI();
            final Path linkFile = uri.asFile(baseFolder).toPath();
            if (folder) {
                if (linkFile.startsWith(theFile)) {
                    result.add(t);
                }
            } else if (linkFile.equals(theFile)) {
                result.add(t);
            }
        }
    }
    return result;
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) Topic(com.igormaznitsa.mindmap.model.Topic) File(java.io.File) ExtraFile(com.igormaznitsa.mindmap.model.ExtraFile) MMapURI(com.igormaznitsa.mindmap.model.MMapURI) ExtraFile(com.igormaznitsa.mindmap.model.ExtraFile) 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