I have created script for comparing file/folder structure of nodes imported by in-built function File --> Import --> Import folders, for those, who use Freeplane for project managing. Description, issues, limitations and installation is included in comments in the script below.
I have also two questions:
Is there some option, how to compare nodes in node hierarchy? If you check attached script, there is issue of node comparation solved by dusty trick ("flatten" original node hierarchy into one-column list). I am unsatisfied, that I dont found any way, how to compare nodes in dependency of their original hierarchy. My point is to create similar node hierarchy of output nodes, as in secondary list, but only with changed nodes. I tried getPathToRoot() with some indexing tricks, also findAll(), but anyone of them didnt provide expected results. I commonly stuck on node indexing (which doesnt respect depth - the X coordinate), or unability to compare two paths to root node. Can somebody target me on some study material on it? Or to Freeplane reference (I already studied this source, but maybe I am blind)?
Is in Freeplane some option, how to create "horizontal node structure"? I mean - for example if you import folders hierarchy (the same issue is present also in my Calendar script - see https://sourceforge.net/p/freeplane/discussion/758437/thread/d55a3447/ ), it create vertical list of subnodes. I think, because most of us use some kind of laptops, which has their monitors wider, than their height is, could be "horizontal node structure" much better for general overview of map. On monitor should be able to put much more information (= nodes) ...
And here is the script. Comments and improvements are welcome :)
And my appologise to authors of Freeplane - I have not access to Script Incubator, therefore I posted things here ...
//ChangedFiles-"Show what is more between two file folder branches"//====================================================================////Showsdifferencebetweentwonodes,containingthesameimportedfolderstructure,but//indifferenttime.Usefulfortrackingchangesinselectedfolder,e.g.forthose,who//useFreeplaneforprojectmanaging.////Ifyouimportfolderintoselectednodebybuiltinimport(File-->Import-->Import//folders),youwillgetnodestructure,whichrespectsubfoldersandfilesstructureon//yourdisc.Thisisreferencefolderstructure,laterusedfortrackingchanges.Youcan//describefilecontent,tagyourfiles,etc.//Then,duringtime,thisfolderwillcontainnewfiles,dependsonyourworkflow.You//canloadthemintoFreeplaneinthesameway,asreferencefolderstructure,butyou//willgetonlybiggernodestructure-andnotonlychangesagainstprevious//(reference)state.Soyoumaximallycandroponeofnodestructures,ortrackchanges//manually,whatisnotveryconvenient.Butthisscriptitchanges:)////Usage:ImportfolderstructurebycommonFreeplanefunction(File-->Import-->Import//folders).Thiswillcreatenewnodecontainsnodessimilartofolderandfiles//structureondisc.Thisisreferencenode.Then,whenyouaddnewfiles/foldersto//trackedfolderyouwillneedtotrackchanges-whatfileswasaddedsincelastimport//ofreferencefolder.SoyouimportthesamefolderstructurebycommonFreeplane//function,asitwasdoneforreferencenode.Thiswillcreateanothernodewithsimilar//folderstructure,asatreferencenode,butcontainingnewnodesfornewfiles.To//trackchangesyouselectbothnodes-referencenodefirst!!-andrunthisscriptas//usual.Itcreatesnewnodewithlistoffiles,whicharenotpresentinreferencenode//structure.Eachofnodewithchangescontainslinktosecond(tracked)nodestructure//tooriginalfile.Thenyouknow,whichnodes(files)arenewandyoucanaddit//manuallytoreferencenodeforfurtherprocessing(taggingetc.).Andsoon.////Knownissues://-Newnodewithtrackedchangesbetweenreferencenodeandlaternodeto//comparationdoesntrespectfolderstructure-isjustflatlistwithchanges.Iwasnt//abletofindmoreelegantway,howtofigureitout.//-Orderofselectingnodesforcomparationismandatory!Firstselectednodeshould//ALWAYSbeareferencenode!//-ScriptassumesonlyADDINGfiles.Thatmeans,scriptassumes,thatsecondaryselected//nodeisalwaysBIGGERthanreferencenode.Itdoesnttrackdeletedfiles!Iftherewas//somedeletedfiles,itisveryprobable,thatthisscriptwillbegivestrangeresults//(becauseof"algorithm").//-Ifscriptisrunfromscriptfolder,alwaysraiseupainformationmessage"I can//compareonlytwonodes!", whenever two nodes are selected, or not.//-ScriptassumessimilarillySORTEDnodestructure-butthisisnotanissueatall,//becauseimportoffolderstructuresortincludednodesalphabeticallyinallcases.////Downloadthisscripttoseparatefile,e.g."ChangedFiles.groovy"(thisextensionis//mandatory),copyittoFreeplaneprogramfoldertosubfolder"scripts"andrestart//Freeplane.ScriptwillbeavailableinmenuTools-->Scripts.////ScriptwastestedonFreeplane1.6.2beta.////Createdby:(c)FerdinandMravenec,2017//Version:170628//Getselectednodesdefselected_nodes=c.getSelecteds()//Checkfortheirproperamount(shouldbe2)if(selected_nodes.size()!=2){ui.informationMessage("I can compare only two nodes!")return}//Getallchildnodesinbothbranches(expectinglexicalorder!-shouldbebydefault)//Itgenerates"flat"listofcontainednodes.Overtypetolistisneccessary(forlaterinserting)deffn0=selected_nodes[0].findAllDepthFirst().toList()defsn0=selected_nodes[1].findAllDepthFirst().toList()//Variableforstorageresultswithreferencetooriginalobjectdefoutnodes=[]//Mainloop//-1isinconditionbecausewewantnottotakeaschangethetheoreticallydifferentnames//ofselectednodes(whichareplacedonendofsn0/fn0lists)for(i=0;i<sn0.size()-1;i++){if(sn0[i].text!=fn0[i].text){//Iftextoncorrespondingplacesdoesntmatch,itschangeoutnodes.add(sn0[i])//Addreferencetooutputlistfn0.add(i,null)//Alignmembersofreferencenodetoproperindex-thatsdothetrick}}//Createoutputnodedefcurdat=newDate().format('yyyy-MM-dd hh:mm:ss')//Createdatetimeindexdefoutnode=node.map.root.createChild("New items\n["+curdat+"]")//Putnametogether//Loopforassemblyresultsfor(i=0;i<outnodes.size();i++){defchildnode=outnode.createChild(outnodes[i].text)//Namethenodechildnode.link.node=outnodes[i]//Refertochangednodeincomparedbranch}c.select(outnode)
Last edit: Ferdinand Mravenec 2017-06-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody,
I have created script for comparing file/folder structure of nodes imported by in-built function File --> Import --> Import folders, for those, who use Freeplane for project managing. Description, issues, limitations and installation is included in comments in the script below.
I have also two questions:
Is there some option, how to compare nodes in node hierarchy? If you check attached script, there is issue of node comparation solved by dusty trick ("flatten" original node hierarchy into one-column list). I am unsatisfied, that I dont found any way, how to compare nodes in dependency of their original hierarchy. My point is to create similar node hierarchy of output nodes, as in secondary list, but only with changed nodes. I tried getPathToRoot() with some indexing tricks, also findAll(), but anyone of them didnt provide expected results. I commonly stuck on node indexing (which doesnt respect depth - the X coordinate), or unability to compare two paths to root node. Can somebody target me on some study material on it? Or to Freeplane reference (I already studied this source, but maybe I am blind)?
Is in Freeplane some option, how to create "horizontal node structure"? I mean - for example if you import folders hierarchy (the same issue is present also in my Calendar script - see https://sourceforge.net/p/freeplane/discussion/758437/thread/d55a3447/ ), it create vertical list of subnodes. I think, because most of us use some kind of laptops, which has their monitors wider, than their height is, could be "horizontal node structure" much better for general overview of map. On monitor should be able to put much more information (= nodes) ...
And here is the script. Comments and improvements are welcome :)
And my appologise to authors of Freeplane - I have not access to Script Incubator, therefore I posted things here ...
Last edit: Ferdinand Mravenec 2017-06-29