Dear Freemind Forum.
I would like to link OneNote and Freemind and therefore plan to refer to Freemind nodes via their IDs. Is there a way to copy the selected node's ID to the clipboard via shortcut or groovey script to achieve this? I tried node.id or node.getId() in Groovey but they do not work. The "manual" way of creating a local link to the target node, open the link window via Ctrl+K and copy the ID from their, is too time consuming. I would love to reduce this to one shortcut.
Eventually I would then like to add the second step, which is by using a different shortcut/script to navigate to the node that is referred to by its ID in the clipboard. If anyone can help me to achieve this, that would be great.
Many thanks
Kai
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all,
if anyone else has a similar problem, please find the following code as example. It works fine for me when added as groovey script file and integrated via shortcut (1) to Freemind to work in all scripts.
(1): integrate via (description for Windows) for general acccess via shortcut Ctrl+Shift+h:
copying the above code as freemind script copySelectedNodeId.groovy in the .freemind folder in your users directory.
AND adding the following segment to the file ScriptingEngine.xml in the "Plugins" subfolder of your Freemind installation.
<plugin_actionname="copySelectedNodeId"documentation="Copy the selected node's ID to the clipboard."label="plugins/copySelectedNodeId"key_stroke="control shift H"base="freemind.extensions.ModeControllerHookAdapter"class_name="plugins.script.ScriptingEngine"><plugin_modeclass_name="freemind.modes.mindmapmode"/><plugin_menulocation="menu_bar/extras/first/scripting/copySelectedNodeId"/><!-- change the following entry to your user name vvvvvvvvv here! --><plugin_propertyname="ScriptLocation"value="/Users/Kai/.freemind/freemind script copySelectedNodeId.groovy"/></plugin_action>
Regards,
Kai
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And this is step 2 for the initially described use case, also as groovey script to the best way I could find in the Freemind sources without being involved in the development project:
/* Script by Kai B., 2018, provided as-is without warranty of any kind. * This groovy script was designed for use with Freemind 1.0.1. * The script is acquiring a node ID from the clipboard and than navigates * the focus to this id. * It takes no action on any error. */java.awt.datatransfer.Transferablet=null;freemind.modes.ModeControllermc=null;freemind.modes.NodeAdapterna=null;freemind.view.mindmapview.NodeViewnv=null;freemind.modes.MindMapNoden=null;try{t=c.getClipboardContents();if(!t.isDataFlavorSupported(java.awt.datatransfer.DataFlavor.stringFlavor)){t=null;return;}java.lang.StringcbId=t.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor).toString();cbId=cbId.trim();if(!cbId.startsWith("ID_"))cbId="ID_"+cbId;mc=c.getModeController();na=mc.getNodeFromID(cbId);// First of all unfold all parents:n=na;// NodeAdapter implements MindMapNodewhile((n!=null)&&(n.getNodeLevel()>=2)&&(n.hasFoldedParents())){n=n.getParentNode();c.setFolded(n,false);// works better than n.setFolded(false);}n=null;// As n does no longer hold the reference to the node itself, kill it right away// Now get the viewer and select+focus the node:if(na.getViewers().size()>0){nv=na.getViewers().peek();//nv.requestFocus(); // does not seem to have many impactmc.select(nv);c.obtainFocusForSelected();}else{// println("No viewer found."); // DEBUGt=null;mc=null;na=null;nv=null;n=null;return;}}catch(Exceptionex){// println("Exception caught"); // DEBUG}t=null;mc=null;na=null;nv=null;n=null;
and the according ScriptingEngine.xml lines for adding as shortcut Ctrl+Shift+j:
<plugin_actionname="goToClipboardRefNodeId"documentation="Select and focus the node referred to by its ID in the clipboard."label="plugins/goToClipboardRefNodeId"key_stroke="control shift J"base="freemind.extensions.ModeControllerHookAdapter"class_name="plugins.script.ScriptingEngine"><plugin_modeclass_name="freemind.modes.mindmapmode"/><plugin_menulocation="menu_bar/extras/first/scripting/goToClipboardRefNodeId"/><!-- change the following entry to your user name vvvvvvvvv here! --><plugin_propertyname="ScriptLocation"value="/Users/Kai/.freemind/freemind script goToClipboardRefNodeId.groovy"/></plugin_action>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So if anyone is having issues this might be the solution.
Hi Kay,
When I came across your post it was the solution that I was looking for, but unfortunetly it did not work for me.
I am using version 1.0.1, and I followed all your steps. I can find the scripts inside of Freemind but the IDs don't get copied to my clipboard. could you help me out??
Thanks :)
Last edit: Rodrigo 2020-06-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey Rodrigo, glad you figured it out. As long as the real file name is the same as how you refer to it in the XML file you are fine. If you omitted the 'freemind script' part in the filename, then you had to do the same as described.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sometimes Java blocks the Clipboard interaction between Freemind and the rest of my Win10 OS. Therefore I have added this little modification as separate macro to enter the target node ID via a small input-box rather than the Clipboard. You can load this file the same way as described above as separte macro (and recommended to assign a different shortcut):
/* Script by Kai B., 2021, provided as-is without warranty of any kind. * This groovy script was designed for use with Freemind 1.0.1. * The script is acquiring a node ID from an inputbox and than navigates * the focus to this id. The node ID may be pre-fixed with the filename + #. * It takes no action on any error. */freemind.modes.ModeControllermc=null;freemind.modes.NodeAdapterna=null;freemind.view.mindmapview.NodeViewnv=null;freemind.modes.MindMapNoden=null;freemind.view.mindmapview.MapViewmv=null;try{java.lang.StringcbId=javax.swing.JOptionPane.showInputDialog(null,"Please enter the Node ID:","Kai-Freemind",javax.swing.JOptionPane.QUESTION_MESSAGE)cbId=cbId.trim();if((cbId==null)||(cbId==""))return;// Get the filename of the map:java.lang.StringcurFn="";try{curFn=c.getMindMapMapModel().toString()}catch(Exceptionex){curFn=null;}// Check on link contains filename pre-fix:if(curFn!=null)if(cbId.startsWith(curFn+"#"))cbId=cbId.substring(curFn.length()+1);if(!cbId.startsWith("ID_"))cbId="ID_"+cbId;mc=c.getModeController();mv=mc.getView();na=mc.getNodeFromID(cbId);// First of all unfold all parents:n=na;// NodeAdapter implements MindMapNodewhile((n!=null)&&(n.getNodeLevel()>=2)&&(n.hasFoldedParents())){n=n.getParentNode();c.setFolded(n,false);// works better than n.setFolded(false);}n=null;// As n does no longer hold the reference to the node itself, kill it right away// Now get the viewer and select+focus the node:if(na.getViewers().size()>0){nv=na.getViewers().peek();//nv.requestFocus(); // does not seem to have many impactmc.select(nv);c.obtainFocusForSelected();mv.centerNode(nv);// optional - this command centers the jumped to node}else{// println("No viewer found."); // DEBUGmc=null;mv=null;na=null;nv=null;n=null;return;}}catch(Exceptionex){javax.swing.JOptionPane.showMessageDialog(null,"Error / Node-Id not found.");}mc=null;na=null;nv=null;mv=null;n=null;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Freemind Forum.
I would like to link OneNote and Freemind and therefore plan to refer to Freemind nodes via their IDs. Is there a way to copy the selected node's ID to the clipboard via shortcut or groovey script to achieve this? I tried node.id or node.getId() in Groovey but they do not work. The "manual" way of creating a local link to the target node, open the link window via Ctrl+K and copy the ID from their, is too time consuming. I would love to reduce this to one shortcut.
Eventually I would then like to add the second step, which is by using a different shortcut/script to navigate to the node that is referred to by its ID in the clipboard. If anyone can help me to achieve this, that would be great.
Many thanks
Kai
Dear all,
if anyone else has a similar problem, please find the following code as example. It works fine for me when added as groovey script file and integrated via shortcut (1) to Freemind to work in all scripts.
(1): integrate via (description for Windows) for general acccess via shortcut Ctrl+Shift+h:
copying the above code as freemind script copySelectedNodeId.groovy in the .freemind folder in your users directory.
AND adding the following segment to the file ScriptingEngine.xml in the "Plugins" subfolder of your Freemind installation.
Regards,
Kai
And this is step 2 for the initially described use case, also as groovey script to the best way I could find in the Freemind sources without being involved in the development project:
File: "freemind script goToClipboardRefNodeId.groovy":
and the according ScriptingEngine.xml lines for adding as shortcut Ctrl+Shift+j:
[Solved]
I just removed the
"/Users/-----/.freemind/'freemind script' goToClipboardRefNodeId.groovy"
and it worked.
So if anyone is having issues this might be the solution.
Hi Kay,
When I came across your post it was the solution that I was looking for, but unfortunetly it did not work for me.
I am using version 1.0.1, and I followed all your steps. I can find the scripts inside of Freemind but the IDs don't get copied to my clipboard. could you help me out??
Thanks :)
Last edit: Rodrigo 2020-06-10
Hey Rodrigo, glad you figured it out. As long as the real file name is the same as how you refer to it in the XML file you are fine. If you omitted the 'freemind script' part in the filename, then you had to do the same as described.
Sometimes Java blocks the Clipboard interaction between Freemind and the rest of my Win10 OS. Therefore I have added this little modification as separate macro to enter the target node ID via a small input-box rather than the Clipboard. You can load this file the same way as described above as separte macro (and recommended to assign a different shortcut):