Commits

Lynn Rees committed f2eb9e8

- check

Comments (0)

Files changed (27)

 	<classpathentry combineaccessrules="false" kind="src" path="/JOrtho_0.4_freeplane"/>
 	<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
 	<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
+	<classpathentry kind="lib" path="guava-14.0-rc1.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
 syntax: glob
 .tox/*
 syntax: regexp
-^stuff$
+^stuff$
+syntax: regexp
+^guava-14\.0-rc1$
+syntax: regexp
+^guava$

scripts/capitalize.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-import org.apache.commons.lang.StringUtils as SU
 
-c.selecteds.every {	it.text = SU.capitalize(SU.lowerCase(it.plainText)) }
+import org.hardknots.wikd.wikdnode.WikdNode
+
+WikdNode.capitalizePlain()

scripts/capitalizeAll.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-import org.apache.commons.lang.WordUtils as WU
 
-c.selecteds.every {	it.text = WU.capitalizeFully(it.plainText.toLowerCase()) }
+import org.hardknots.wikd.wikdnode.WikdNode
+
+WikdNode.capitalizeAllPlain()

scripts/deleteFirstChars.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
+
 import java.util.regex.Pattern
-import org.apache.commons.lang.StringUtils as SU
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
 def mark = ui.showInputDialog(
 	node.delegate, 'Enter characters to delete from text start...', ''
 )
 
-if (mark != null) {
-   c.selecteds.every {
-	   it.text = SU.trim(it.plainText.replaceFirst('^{1}' + Pattern.quote(mark), ''))
-   }
-}
+if (mark) {
+	WikdNode.stripPlain('^{1}' + Pattern.quote(mark))
+}

scripts/deleteFirstRegex.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-import java.util.regex.Pattern
-import org.apache.commons.lang.StringUtils as SU
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
 def mark = ui.showInputDialog(
 	node.delegate, 'Enter regular expression used to delete characters from text start...', ''
 )
 
-if (mark != null) {
-   c.selecteds.every {
-	   it.text = SU.trim( it.plainText.replaceFirst('^{1}' + mark, ''))
-   }
+if (mark) {
+	WikdNode.stripPlain('^{1}' + mark)
 }

scripts/deleteLastChars.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
+
 import java.util.regex.Pattern
-import org.apache.commons.lang.StringUtils as SU
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
 def mark = ui.showInputDialog(
 	node.delegate, 'Enter characters to delete from text end:', ''
 )
 
-if (mark != null) {
-   c.selecteds.every {
-	   it.text = SU.trim( it.plainText.replaceFirst(Pattern.quote(mark) + '{1}$', ''))
-   }
+if (mark) {
+	WikdNode.stripPlain(Pattern.quote(mark) + '{1}$')
 }

scripts/deleteLastRegex.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-import java.util.regex.Pattern
-import org.apache.commons.lang.StringUtils as SU
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
 def mark = ui.showInputDialog(
 	node.delegate, 'Enter regular expression used to delete characters from text end:', ''
 )
 
-if (mark != null) {
-   c.selecteds.every {
-	   it.text = SU.trim( it.plainText.replaceFirst(mark + '{1}$', ''))
-   }
-}
+if (mark) {
+	WikdNode.stripPlain(mark + '{1}$')
+}

scripts/deleteLinks.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-c.selecteds.each { it.link.text = null }
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
+WikdNode.deleteLinks()

scripts/joinChars.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().joinPlainText(ui.showInputDialog(
+WikdNode.joinPlain(ui.showInputDialog(
 	node.delegate, 'Enter characters to join nodes with...', ''
 ))

scripts/joinComma.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().joinPlainText(', ')
+WikdNode.joinPlain(', ')

scripts/joinPeriod.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().joinPlainText('. ')
+WikdNode.joinPlain('. ')

scripts/joinSpace.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().joinPlainText(' ')
+WikdNode.joinPlain(' ')

scripts/lowerCase.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-c.selecteds.every { it.text = it.plainText.toLowerCase() }
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
+WikdNode.lowerPlain()

scripts/org/hardknots/wikd/wikdnode/WikdNode.java

 package org.hardknots.wikd.wikdnode;
 
+import java.net.URI;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.WordUtils;
 import org.freeplane.core.resources.ResourceController;
-import org.freeplane.core.ui.components.UITools;
 import org.freeplane.core.util.HtmlUtils;
+import org.freeplane.features.link.LinkController;
+import org.freeplane.features.link.mindmapmode.MLinkController;
 import org.freeplane.features.map.NodeModel;
 import org.freeplane.features.map.mindmapmode.MMapController;
 import org.freeplane.features.mode.Controller;
 import org.freeplane.features.text.mindmapmode.MTextController;
 
+import com.google.common.collect.ImmutableList;
+
 public class WikdNode {
 
-	public static void joinPlainText(String mark) {
-		if (mark != null) {
-			List<String> collect = new LinkedList<String>();
-			final Controller c = Controller.getCurrentController();
-			final List<NodeModel> selected = c.getSelection()
-					.getOrderedSelection();
-			final NodeModel selectedNode = c.getSelection().getSelected();
-			for (final NodeModel n : selected) {
-				collect.add(StringUtils.trim(HtmlUtils.htmlToPlain(n.getText())));
+	private static Boolean firstSplit = ResourceController
+			.getResourceController().getBooleanProperty("wikd_first_split");
+
+	private static Controller getCurrentControl() {
+		return Controller.getCurrentController();
+	}
+
+	private static MMapController getMMControl() {
+		return (MMapController) Controller.getCurrentModeController()
+				.getMapController();
+	}
+
+	private static MTextController getMTextControl() {
+		return MTextController.getController();
+	}
+
+	private static List<NodeModel> getSelecteds(Controller c) {
+		return c.getSelection().getOrderedSelection();
+	}
+
+	private static String getPlain(NodeModel node) {
+		return HtmlUtils.htmlToPlain(node.getText());
+	}
+
+	private static String trim(String text) {
+		return StringUtils.trim(text);
+	}
+
+	public static void capitalizePlain() {
+		final MTextController mtext = getMTextControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			mtext.setNodeText(n, StringUtils.capitalize(getPlain(n).toLowerCase()));
+		}
+	}
+
+	public static void stripPlain(String mark) {
+		final MTextController mtext = getMTextControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			mtext.setNodeText(n, trim(getPlain(n).replaceFirst(mark, "")));
+		}
+	}
+
+	public static void capitalizeAllPlain() {
+		final MTextController mtext = getMTextControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			mtext.setNodeText(n,
+					WordUtils.capitalizeFully(getPlain(n).toLowerCase()));
+		}
+	}
+
+	public static void joinPlain(String mark) {
+		List<String> collect = new LinkedList<String>();
+		final Controller c = getCurrentControl();
+		final MMapController m = getMMControl();
+		final NodeModel selected = c.getSelection().getSelected();
+		for (final NodeModel n : ImmutableList.copyOf(getSelecteds(c))) {
+			collect.add(trim(getPlain(n)));
+			if (n != selected) {
+				m.deleteNode(n);
 			}
-			c.getSelection().selectAsTheOnlyOneSelected(selectedNode);
-			// modification
-			MTextController.getController().setNodeText(selectedNode,
-					StringUtils.join(collect.toArray(), mark));
-			final int size = selected.size();
-			for (int i = 0; i < size; i++) {
-				final NodeModel n = selected.get(i);
-				if (n != selectedNode) {
-					if (n != null) {
-						final MMapController m = (MMapController) Controller
-								.getCurrentModeController().getMapController();
-						// modification
-						m.deleteNode(n);
+		}
+		getMTextControl().setNodeText(selected,
+				StringUtils.join(collect.toArray(), mark));
+		c.getSelection().selectAsTheOnlyOneSelected(selected);
+	}
+
+	public static void deleteLinks() {
+		MLinkController m = (MLinkController) LinkController.getController();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			m.setLink(n, (URI) null, false);
+		}
+	}
+
+	public static void lowerPlain() {
+		final MTextController mtext = getMTextControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			mtext.setNodeText(n, getPlain(n).toLowerCase());
+		}
+	}
+
+	public static void splitPlain(String mark) {
+		final MTextController mtext = getMTextControl();
+		final MMapController m = getMMControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			Boolean flag = true;
+			for (String txt : getPlain(n).split(mark)) {
+				if (flag) {
+					if (!firstSplit) {
+						m.insertNode(new NodeModel(txt, n.getMap()), n);
 					}
+					// modification
+					mtext.setNodeText(n, txt);
+					flag = false;
+				} else {
+					m.insertNode(new NodeModel(txt, n.getMap()), n);
 				}
 			}
 		}
 	}
 
-	public static void splitPlainText(String mark) {
-		if (mark != null) {
-			final Boolean firstSplit = ResourceController
-					.getResourceController().getBooleanProperty(
-							"wikd_first_split");
-			final Controller c = Controller.getCurrentController();
-			final MTextController mtext = MTextController.getController();
-			final MMapController m = (MMapController) Controller
-					.getCurrentModeController().getMapController();
-			final List<NodeModel> selected = c.getSelection()
-					.getOrderedSelection();
-			for (NodeModel n : selected) {
-				int idx = 0;
-				final String[] textSplit = HtmlUtils.htmlToPlain(n.getText())
-						.split(mark);
-				for (String txt : textSplit) {
-					if (idx == 0) {
-						if (firstSplit == false) {
-							// modification
-							final NodeModel node = new NodeModel(txt,
-									n.getMap());
-							m.insertNode(node, n);
-						}
-						// modification
-						mtext.setNodeText(n, txt);
-						idx++;
-					} else {
-						// modification
-						final NodeModel node = new NodeModel(txt, n.getMap());
-						m.insertNode(node, n);
-					}
-				}
-			}
+	public static void upperPlain() {
+		final MTextController mtext = getMTextControl();
+		for (NodeModel n : getSelecteds(getCurrentControl())) {
+			mtext.setNodeText(n, getPlain(n).toUpperCase());
 		}
 	}
 
-}
+}

scripts/splitAfterChars.groovy

 )
 
 if (mark) {
-	new WikdNode().splitPlainText('(?<=' + Pattern.quote(mark ? mark : '') + ')')
+	WikdNode.splitPlain('(?<=' + Pattern.quote(mark ? mark : '') + ')')
 }

scripts/splitAfterRegex.groovy

 )
 
 if (mark) {
-	new WikdNode().splitPlainText('(?<=' + (mark ? mark : '') + ')')
+	WikdNode.splitPlain('(?<=' + (mark ? mark : '') + ')')
 }

scripts/splitBeforeChars.groovy

 )
 
 if (mark) {
-	new WikdNode().splitPlainText('(?=' + Pattern.quote(mark ? mark : '') + ')')
+	WikdNode.splitPlain('(?=' + Pattern.quote(mark ? mark : '') + ')')
 }

scripts/splitBeforeRegex.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-ui.showInputDialog(
+def mark = ui.showInputDialog(
 	node.delegate, 'Enter regular expression to split node text before...', ''
 )
 
 if (mark) {
-	new WikdNode().splitPlainText('(?=' + (mark ? mark : '') + ')')
+	WikdNode.splitPlain('(?=' + (mark ? mark : '') + ')')
 }

scripts/splitChars.groovy

 )
 
 if (mark) {
-	new WikdNode().splitPlainText(Pattern.quote(mark ? mark : ''))
+	WikdNode.splitPlain(Pattern.quote(mark ? mark : ''))
 }

scripts/splitComma.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().splitPlainText(',')
+WikdNode.splitPlain(',')

scripts/splitPeriod.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().splitPlainText('\\.')
+WikdNode.splitPlain('\\.')

scripts/splitRegex.groovy

 )
 
 if (mark) {
-	new WikdNode().splitPlainText((mark ? mark : ''))
+	WikdNode.splitPlain(mark ? mark : '')
 }

scripts/splitSpace.groovy

 
 import org.hardknots.wikd.wikdnode.WikdNode
 
-new WikdNode().splitPlainText(' ')
+WikdNode.splitPlain(' ')

scripts/upperCase.groovy

 // @CacheScriptContent(true)
 // @ExecutionModes({ON_SINGLE_NODE})
-c.selecteds.every {	it.text = it.plainText.toUpperCase() }
+
+import org.hardknots.wikd.wikdnode.WikdNode
+
+WikdNode.upperPlain()
         </sealing>
     </manifest>
     <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
+        <folder path="/jWikdNode/com"/>
         <javaElement handleIdentifier="=jWikdNode/scripts&lt;org.hardknots.wikd.wikdnode"/>
     </selectedElements>
 </jardesc>
 <map version="freeplane 1.2.0">
 <!--To view this file, download free mind mapping software Freeplane from http://freeplane.sourceforge.net -->
-<node TEXT="wikdNode" FOLDED="false" ID="ID_1723255651" CREATED="1283093380553" MODIFIED="1359881580012" BACKGROUND_COLOR="#97c7dc" LINK="https://bitbucket.org/lcrees/wikdnode/">
+<node TEXT="wikdNode" FOLDED="false" ID="ID_1723255651" CREATED="1283093380553" MODIFIED="1359922647447" BACKGROUND_COLOR="#97c7dc" LINK="https://bitbucket.org/lcrees/wikdnode/">
 <font SIZE="16" BOLD="true" ITALIC="true"/>
 <hook NAME="MapStyle">
     <properties show_icon_for_attributes="true" show_note_icons="true"/>
 <hook NAME="AutomaticEdgeColor" COUNTER="6"/>
 <attribute_layout NAME_WIDTH="103" VALUE_WIDTH="103"/>
 <attribute NAME="name" VALUE="wikdNode"/>
-<attribute NAME="version" VALUE="v0.6.9" OBJECT="org.freeplane.features.format.FormattedObject|v0.6.9|number:decimal:#0.####"/>
+<attribute NAME="version" VALUE="v0.6.8" OBJECT="org.freeplane.features.format.FormattedObject|v0.6.8|number:decimal:#0.####"/>
 <attribute NAME="author" VALUE="L. C. Rees"/>
 <attribute NAME="freeplaneVersionFrom" VALUE="1.2.15"/>
 <attribute NAME="freeplaneVersionTo" VALUE=""/>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.