Skip to content

Commit

Permalink
release 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
raydac committed Sep 11, 2022
1 parent 7aaf190 commit 5789831
Show file tree
Hide file tree
Showing 19 changed files with 2,402 additions and 147 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Initially I developed plugin for NetBeans IDE but because in companies, where I

# Changelog

__1.5.2 (SNAPSHOT)__
__1.5.2 (11-sep-2022)__
- SR: added way to set PlantUML security profile through preferences
- SR: added FlatLaf themes [#104](https://github.com/raydac/netbeans-mmd-plugin/issues/104)
- SR: updated PlantUML to 1.2022.7
Expand Down
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__1.5.2 (SNAPSHOT)__
__1.5.2 (11-sep-2022)__

- SR: added way to set PlantUML security profile through preferences
- SR: added FlatLaf themes [#104](https://github.com/raydac/netbeans-mmd-plugin/issues/104)
Expand Down
6 changes: 3 additions & 3 deletions mind-map/idea-mindmap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
mavenLocal()
}

version = project.hasProperty('mm_plugin_version') ? project.getProperty('mm_plugin_version') : "1.5.2-SNAPSHOT"
version = project.hasProperty('mm_plugin_version') ? project.getProperty('mm_plugin_version') : "1.5.2"

intellij {
version 'IC-181.5684.4'
Expand All @@ -18,13 +18,13 @@ intellij {
updateSinceUntilBuild false
}

def mindMapModelVersion = project.hasProperty('mm_model_version') ? project.getProperty('mm_model_version') : "1.5.2-SNAPSHOT"
def mindMapModelVersion = project.hasProperty('mm_model_version') ? project.getProperty('mm_model_version') : "1.5.2"
def mindMapCommonVersion = project.hasProperty('mm_ide_common_version') ? project.getProperty('mm_ide_common_version') : project.version
def mindMapPanelVersion = project.hasProperty('mm_panel_version') ? project.getProperty('mm_panel_version') : project.version
def commonsIoVersion = project.hasProperty('commonsio_version') ? project.getProperty('commonsio_version') : "2.11.0"
def commonsLangVersion = project.hasProperty('commonslang_version') ? project.getProperty('commonslang_version') : "3.12.0"
def iharderVersion = project.hasProperty('iharder_version') ? project.getProperty('iharder_version') : "2.3.9"
def jsoupVersion = project.hasProperty('jsoup_version') ? project.getProperty('jsoup_version') : "1.11.3"
def jsoupVersion = project.hasProperty('jsoup_version') ? project.getProperty('jsoup_version') : "1.15.3"
def jsonVersion = project.hasProperty('json_version') ? project.getProperty('json_version') : "20180813"

sourceCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion mind-map/idea-mindmap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.igormaznitsa</groupId>
<artifactId>mind-map</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.5.2</version>
</parent>

<artifactId>idea-mindmap</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions mind-map/idea-mindmap/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
]]></description>

<change-notes><![CDATA[
<p>1.5.2 (11-sep-2022)</p>
<ul>
<li>fixed use of Insert key as shortcut</li>
<li>minor refactoring</li>
</ul>
<p>1.5.1 (15-apr-2022)</p>
<ul>
<li>fixed wrong decimal separator in SVG exporter</li>
Expand Down
2 changes: 1 addition & 1 deletion mind-map/mind-map-ide-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.igormaznitsa</groupId>
<artifactId>mind-map</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.5.2</version>
</parent>

<artifactId>mind-map-ide-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mind-map/mind-map-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.igormaznitsa</groupId>
<artifactId>mind-map</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.5.2</version>
</parent>

<artifactId>mind-map-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mind-map/mind-map-swing-panel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.igormaznitsa</groupId>
<artifactId>mind-map</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.5.2</version>
</parent>

<artifactId>mind-map-swing-panel</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.igormaznitsa.mindmap.swing.panel.StandardTopicAttribute.ATTR_FILL_COLOR;
import static com.igormaznitsa.mindmap.swing.panel.StandardTopicAttribute.ATTR_TEXT_COLOR;


import com.igormaznitsa.meta.annotation.MustNotContainNull;
import com.igormaznitsa.meta.annotation.ReturnsOriginal;
import com.igormaznitsa.meta.common.utils.Assertions;
Expand All @@ -42,6 +41,7 @@
import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
Expand All @@ -54,9 +54,12 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.swing.Icon;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.jsoup.parser.Parser;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand All @@ -66,19 +69,24 @@

public class Freemind2MindMapImporter extends AbstractImporter {

private static final Icon ICO = ImageIconServiceProvider.findInstance().getIconForId(IconID.POPUP_EXPORT_FREEMIND);
private static final Icon ICO =
ImageIconServiceProvider.findInstance().getIconForId(IconID.POPUP_EXPORT_FREEMIND);

private static final Logger LOGGER = LoggerFactory.getLogger(Freemind2MindMapImporter.class);

private static final Set<String> TOKEN_NEEDS_NEXT_LINE = new HashSet<>(Arrays.asList("br", "div", "p", "li"));
private static final Set<String> TOKEN_NEEDS_NEXT_LINE =
new HashSet<>(Arrays.asList("br", "div", "p", "li"));

@Nonnull
private static String findArrowlinkDestination(@Nonnull final Element element) {
final List<Element> arrows = Utils.findDirectChildrenForName(element, "arrowlink");
return arrows.isEmpty() ? "" : findAttribute(arrows.get(0), "destination");
}

private static void processImageLinkForTopic(@Nonnull final File rootFolder, @Nonnull final Topic topic, @Nonnull @MustNotContainNull final String[] imageUrls) {
private static void processImageLinkForTopic(@Nonnull final File rootFolder,
@Nonnull final Topic topic,
@Nonnull @MustNotContainNull
final String[] imageUrls) {
for (final String s : imageUrls) {
try {
URI imageUri = URI.create(s);
Expand All @@ -91,7 +99,8 @@ private static void processImageLinkForTopic(@Nonnull final File rootFolder, @No
}

if (file.isFile()) {
topic.setAttribute(ImageVisualAttributePlugin.ATTR_KEY, Utils.rescaleImageAndEncodeAsBase64(file, -1));
topic.setAttribute(ImageVisualAttributePlugin.ATTR_KEY,
Utils.rescaleImageAndEncodeAsBase64(file, -1));
break;
}
} catch (Exception ex) {
Expand All @@ -102,7 +111,10 @@ private static void processImageLinkForTopic(@Nonnull final File rootFolder, @No

@Nonnull
@ReturnsOriginal
private static StringBuilder processHtmlElement(@Nonnull final NodeList list, @Nonnull final StringBuilder builder, @Nonnull @MustNotContainNull final List<String> imageURLs) {
private static StringBuilder processHtmlElement(@Nonnull final NodeList list,
@Nonnull final StringBuilder builder,
@Nonnull @MustNotContainNull
final List<String> imageURLs) {
for (int i = 0; i < list.getLength(); i++) {
final Node n = list.item(i);
switch (n.getNodeType()) {
Expand Down Expand Up @@ -136,15 +148,19 @@ private static StringBuilder processHtmlElement(@Nonnull final NodeList list, @N

@Nonnull
@ReturnsOriginal
private static StringBuilder extractTextFromHtmlElement(@Nonnull final Element element, @Nonnull final StringBuilder buffer, @Nonnull @MustNotContainNull final List<String> imageURLs) {
private static StringBuilder extractTextFromHtmlElement(@Nonnull final Element element,
@Nonnull final StringBuilder buffer,
@Nonnull @MustNotContainNull
final List<String> imageURLs) {
processHtmlElement(element.getChildNodes(), buffer, imageURLs);
return buffer;
}

@Nonnull
@MustNotContainNull
private static List<RichContent> extractRichContent(@Nonnull final Element richContentElement) {
final List<Element> richContents = Utils.findDirectChildrenForName(richContentElement, "richcontent");
final List<Element> richContents =
Utils.findDirectChildrenForName(richContentElement, "richcontent");

final List<RichContent> result = new ArrayList<>();

Expand All @@ -155,7 +171,9 @@ private static List<RichContent> extractRichContent(@Nonnull final Element richC
try {
foundImageUrls.clear();
final RichContentType type = RichContentType.valueOf(textType);
final String text = extractTextFromHtmlElement(e, new StringBuilder(), foundImageUrls).toString().replace("\r", "");
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);
Expand All @@ -166,7 +184,8 @@ private static List<RichContent> extractRichContent(@Nonnull final Element richC
}

@Nonnull
private static String findAttribute(@Nonnull final Element element, @Nonnull final String attribute) {
private static String findAttribute(@Nonnull final Element element,
@Nonnull final String attribute) {
final NamedNodeMap map = element.getAttributes();
for (int i = 0; i < map.getLength(); i++) {
final Attr attr = (Attr) map.item(i);
Expand All @@ -180,15 +199,29 @@ private static String findAttribute(@Nonnull final Element element, @Nonnull fin
@Override
@Nullable
public MindMap doImport(@Nonnull final PluginContext context) throws Exception {
final File file = this.selectFileForExtension(context, Texts.getString("MMDImporters.Freemind2MindMap.openDialogTitle"), null, "mm", "Freemind files (.MM)", Texts.getString("MMDImporters.ApproveImport"));
final File file = this.selectFileForExtension(context,
Texts.getString("MMDImporters.Freemind2MindMap.openDialogTitle"), null, "mm",
"Freemind files (.MM)", Texts.getString("MMDImporters.ApproveImport"));

if (file == null) {
return null;
}

final Document document = Utils.loadHtmlDocument(new FileInputStream(file), "UTF-8", true);
try (final FileInputStream in = new FileInputStream(file)) {
final File rootFolder = file.getParentFile();
return extractTopics(rootFolder == null ? file : rootFolder, in);
}
}

@Nonnull
public MindMap extractTopics(@Nonnull final File rootFolder,
@Nonnull final FileInputStream inputStream)
throws ParserConfigurationException, IOException, XPathExpressionException {
final Document document = Utils.load(inputStream, "UTF-8", Parser.xmlParser(), true);

final XPath xpath = XPathFactory.newInstance().newXPath();
final Element rootElement = (Element) xpath.evaluate("/html/body/map", document, XPathConstants.NODE);
final Element rootElement =
(Element) xpath.evaluate("/map", document, XPathConstants.NODE);

if (rootElement == null) {
throw new IllegalArgumentException("Can't parse freemind file as xhtml");
Expand All @@ -203,7 +236,8 @@ public MindMap doImport(@Nonnull final PluginContext context) throws Exception {
if (list.isEmpty()) {
Assertions.assertNotNull(resultedMap.getRoot()).setText("Empty");
} else {
parseTopic(file.getParentFile(), resultedMap, null, resultedMap.getRoot(), list.get(0), idTopicMap, linksMap);
parseTopic(rootFolder, resultedMap, null, resultedMap.getRoot(), list.get(0), idTopicMap,
linksMap);
}

for (final Map.Entry<String, String> l : linksMap.entrySet()) {
Expand All @@ -217,7 +251,10 @@ public MindMap doImport(@Nonnull final PluginContext context) throws Exception {
return resultedMap;
}

private void parseTopic(@Nonnull final File rootFolder, @Nonnull final MindMap map, @Nullable Topic parent, @Nullable Topic preGeneratedTopic, @Nonnull Element element, @Nonnull final Map<String, Topic> idTopicMap, @Nonnull final Map<String, String> linksMap) {
private void parseTopic(@Nonnull final File rootFolder, @Nonnull final MindMap map,
@Nullable Topic parent, @Nullable Topic preGeneratedTopic,
@Nonnull Element element, @Nonnull final Map<String, Topic> idTopicMap,
@Nonnull final Map<String, String> linksMap) {

final String text = findAttribute(element, "text");
final String id = findAttribute(element, "id");
Expand Down Expand Up @@ -246,14 +283,17 @@ private void parseTopic(@Nonnull final File rootFolder, @Nonnull final MindMap m
final Color backgroundColorConverted = Utils.html2color(backgroundColor, false);

if (colorConverted != null) {
topicToProcess.setAttribute(ATTR_TEXT_COLOR.getText(), Utils.color2html(colorConverted, false));
topicToProcess.setAttribute(ATTR_TEXT_COLOR.getText(),
Utils.color2html(colorConverted, false));
}

if (backgroundColorConverted != null) {
topicToProcess.setAttribute(ATTR_FILL_COLOR.getText(), Utils.color2html(backgroundColorConverted, false));
topicToProcess.setAttribute(ATTR_FILL_COLOR.getText(),
Utils.color2html(backgroundColorConverted, false));
} else {
if (colorConverted != null) {
topicToProcess.setAttribute(ATTR_FILL_COLOR.getText(), Utils.color2html(Utils.makeContrastColor(colorConverted), false));
topicToProcess.setAttribute(ATTR_FILL_COLOR.getText(),
Utils.color2html(Utils.makeContrastColor(colorConverted), false));
}
}
}
Expand Down Expand Up @@ -348,7 +388,8 @@ private static final class RichContent {
private final String text;
private final String[] imageUrls;

private RichContent(@Nonnull final RichContentType type, @Nonnull final String text, @Nonnull @MustNotContainNull final List<String> foundImageUrls) {
private RichContent(@Nonnull final RichContentType type, @Nonnull final String text,
@Nonnull @MustNotContainNull final List<String> foundImageUrls) {
this.type = type;
this.text = text;
this.imageUrls = foundImageUrls.toArray(new String[0]);
Expand Down
Loading

0 comments on commit 5789831

Please sign in to comment.