Search in sources :

Example 6 with MustNotContainNull

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

the class NodeProject method findAffectedFiles.

@Nonnull
@MustNotContainNull
public List<File> findAffectedFiles(@Nonnull final File changedFile) {
    final File baseFolder = makeFileForNode();
    final boolean folder = changedFile.isDirectory();
    final List<File> result = new ArrayList<>();
    for (final File mindMapFile : FileUtils.listFiles(baseFolder, new String[] { "mmd", "MMD" }, true)) {
        // NOI18N
        try {
            // NOI18N
            final MindMap map = new MindMap(null, new StringReader(FileUtils.readFileToString(mindMapFile, "UTF-8")));
            if (!MapUtils.findTopicsRelatedToFile(baseFolder, changedFile, map).isEmpty()) {
                result.add(mindMapFile);
            }
        } catch (IOException ex) {
            // NOI18N
            LOGGER.error("Can't process mind map file", ex);
        }
    }
    return result;
}
Also used : MindMap(com.igormaznitsa.mindmap.model.MindMap) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) IOException(java.io.IOException) File(java.io.File) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 7 with MustNotContainNull

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

the class NodeProject method deleteAllLinksToFile.

@Nonnull
@MustNotContainNull
public List<File> deleteAllLinksToFile(@Nonnull @MustNotContainNull final List<File> listOfFilesToProcess, @Nonnull final File fileToRemove) {
    final List<File> affectedFiles = new ArrayList<>();
    final File baseFolder = makeFileForNode();
    final MMapURI fileURI = new MMapURI(baseFolder, fileToRemove, 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.deleteAllLinksToFile(baseFolder, fileURI)) {
                    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 8 with MustNotContainNull

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

the class MindMapPluginRegistry method findFor.

@Nonnull
@MustNotContainNull
public <T extends MindMapPlugin> List<T> findFor(@Nullable final Class<T> klazz) {
    synchronized (FIND_CACHE) {
        List<T> result = (List<T>) FIND_CACHE.get(klazz);
        if (result == null) {
            result = new ArrayList<T>();
            if (klazz != null) {
                for (final MindMapPlugin p : this.pluginList) {
                    if (klazz.isInstance(p)) {
                        result.add(klazz.cast(p));
                    }
                }
            }
            result = Collections.unmodifiableList(result);
            FIND_CACHE.put(klazz, result);
        }
        return result;
    }
}
Also used : MindMapPlugin(com.igormaznitsa.mindmap.plugins.api.MindMapPlugin) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 9 with MustNotContainNull

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

the class MindMapUtils method removeSuccessorsAndDuplications.

/**
 * Remove duplications and successors for presented topics in array.
 * @param topics array to be processed
 * @return resulted array
 * @since 1.3.1
 */
@Nonnull
@MustNotContainNull
public static Topic[] removeSuccessorsAndDuplications(@Nonnull @MustNotContainNull final Topic... topics) {
    final List<Topic> result = new ArrayList<Topic>();
    for (final Topic t : topics) {
        final Iterator<Topic> iterator = result.iterator();
        while (iterator.hasNext()) {
            final Topic listed = iterator.next();
            if (listed == t || listed.hasAncestor(t)) {
                iterator.remove();
            }
        }
        result.add(t);
    }
    return result.toArray(new Topic[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) Topic(com.igormaznitsa.mindmap.model.Topic) Nonnull(javax.annotation.Nonnull) MustNotContainNull(com.igormaznitsa.meta.annotation.MustNotContainNull)

Example 10 with MustNotContainNull

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

the class Utils method findPopupMenuItems.

@Nonnull
@MustNotContainNull
private static List<JMenuItem> findPopupMenuItems(@Nonnull final MindMapPanel panel, @Nonnull final PopUpSection section, final boolean fullScreenModeActive, @Nonnull @MayContainNull final List<JMenuItem> list, @Nonnull DialogProvider dialogProvider, @Nullable final Topic topicUnderMouse, @Nonnull @MustNotContainNull final Topic[] selectedTopics, @Nonnull @MustNotContainNull final List<PopUpMenuItemPlugin> pluginMenuItems, @Nonnull Map<Class<? extends PopUpMenuItemPlugin>, CustomJob> customProcessors) {
    list.clear();
    for (final PopUpMenuItemPlugin p : pluginMenuItems) {
        if (fullScreenModeActive && !p.isCompatibleWithFullScreenMode()) {
            continue;
        }
        if (p.getSection() == section) {
            if (!(p.needsTopicUnderMouse() || p.needsSelectedTopics()) || (p.needsTopicUnderMouse() && topicUnderMouse != null) || (p.needsSelectedTopics() && selectedTopics.length > 0)) {
                final JMenuItem item = p.makeMenuItem(panel, dialogProvider, topicUnderMouse, selectedTopics, customProcessors.get(p.getClass()));
                if (item != null) {
                    item.setEnabled(p.isEnabled(panel, topicUnderMouse, selectedTopics));
                    list.add(item);
                }
            }
        }
    }
    return list;
}
Also used : PopUpMenuItemPlugin(com.igormaznitsa.mindmap.plugins.api.PopUpMenuItemPlugin) 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