Following the discussion in this post (thank you, Volker), this script modifies an existing node "Status::" (mind the '::' for searching) by adding date of last update and number of nodes in the map.
// @ExecutionModes({ON_SINGLE_NODE})
def lastModifiedAt = c.findAll().collect{ it.lastModifiedAt }.max() // find all nodes, collect their lastModifiedAt date and get the latest
// Total number of nodes
def NodeCountTotal = c.find{true}.size() // Count nodes, https://sourceforge.net/p/freeplane/discussion/758437/thread/eb627f4f/#3851
// Count nodes for Sub-Node: "node count (branch): " + node.find{true}.size()
def StatusNode
c.find{
it.text.contains("Status::") // full accordance: it.text == 'Status::'
}.each {
c.select (it)
it.setFolded(false)
StatusNode = it.getChildren()
}
c.selecteds.each {
it.text = "Status::\nLetzte Aktualisierung: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nAnzahl Knoten: " + NodeCountTotal // HH=24 h, hh=12 h no AM/PM, :ss allowable
it.note = "Status::\nLast Update: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nTotal Number of Nodes: " + NodeCountTotal // HH=24 h, hh=12 h no AM/PM, :ss allowable
it.style.name = "myDetail" // Style must be defined
}
If the node "Status::" doesn't exist, the information is replacing the actual node's text; this is not acceptable.
Either an error message should be shown or the script simply could add that node. In both cases, something like if ("Status::" existing) / else ("Status::" NOT existing) would be needed. Thanks for any proposal.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found a working solution now, but I'm pretty sure, that this could be improved and / or simplyfied.
This is what the script does: It checks if there is a node having "Status::" in it's text. If so this node is taken or a new one is added having text (first language =GE) and note (second language = EN, ref. here) to show the number of nodes and date of last modification.
For testing, create a new map and run it twice with some time in between.
// @ExecutionModes({ON_SINGLE_NODE})
def lastModifiedAt = c.findAll().collect{ it.lastModifiedAt }.max() // find all nodes, collect their lastModifiedAt date and get the latest
// Total number of nodes
def NodeCountTotal = c.find{true}.size() // Knoten zählen, Quelle: https://sourceforge.net/p/freeplane/discussion/758437/thread/eb627f4f/#3851
// Zahl der Knoten für Sub-Node: "node count (branch): " + node.find{true}.size()
def StatusNode = c.find{it.text.contains("Status::")} // für exakte Übereinstimmung: it.text == 'Status::'
if (StatusNode) {
c.statusInfo = "-----YES"
def StatusNode2
c.find{
it.text.contains("Status::") // für exakte Übereinstimmung: it.text == 'Status::'
}.each {
c.select (it)
it.setFolded(false)
StatusNode2 = it.getChildren()
}
c.selecteds.each {
it.text = "Status::\nLetzte Aktualisierung: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nAnzahl Knoten: " + NodeCountTotal // HH=24 h, hh=12 h ohne AM/PM, :ss kann ergänzt werden
it.note = "Status::\nLast Update: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nTotal Number of Nodes: " + NodeCountTotal // HH=24 h, hh=12 h ohne AM/PM, :ss kann ergänzt werden
it.style.name = "Detail" // Style must exist!
}
}
else {
c.statusInfo = "-----NO"
def StatusNode2 = node.map.root.createChild()
StatusNode2.text = "Status::\nLetzte Aktualisierung: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nAnzahl Knoten: " + NodeCountTotal // HH=24 h, hh=12 h ohne AM/PM, :ss kann ergänzt werden
StatusNode2.note = "Status::\nLast Update: " + format(lastModifiedAt, "dd.MM.yyyy HH:mm") + "\nTotal Number of Nodes: " + NodeCountTotal // HH=24 h, hh=12 h ohne AM/PM, :ss kann ergänzt werden
StatusNode2.style.name = "Detail" // Style must exist!
}
Last edit: michaelhe 2017-07-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Following the discussion in this post (thank you, Volker), this script modifies an existing node "Status::" (mind the '::' for searching) by adding date of last update and number of nodes in the map.
If the node "Status::" doesn't exist, the information is replacing the actual node's text; this is not acceptable.
Either an error message should be shown or the script simply could add that node. In both cases, something like if ("Status::" existing) / else ("Status::" NOT existing) would be needed. Thanks for any proposal.
I found a working solution now, but I'm pretty sure, that this could be improved and / or simplyfied.
This is what the script does: It checks if there is a node having "Status::" in it's text. If so this node is taken or a new one is added having text (first language =GE) and note (second language = EN, ref. here) to show the number of nodes and date of last modification.
For testing, create a new map and run it twice with some time in between.
Last edit: michaelhe 2017-07-27