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;
}
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;
}
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;
}
}
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()]);
}
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;
}
Aggregations