Skip to content

Commit

Permalink
FIX: #50 Merged the lists properly
Browse files Browse the repository at this point in the history
NEW: Remove redundant items from waitfor
Bumped version to v1.8.2
  • Loading branch information
gpapp committed Mar 17, 2016
1 parent 8ea2b87 commit 1e7dba9
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 90 deletions.
4 changes: 2 additions & 2 deletions src/freeplaneGTD.addon.mm
@@ -1,6 +1,6 @@
<map version="freeplane 1.3.0">
<!--To view this file, download free mind mapping software Freeplane from http://freeplane.sourceforge.net -->
<node TEXT="Freeplane|GTD+" ID="ID_1723255651" CREATED="1283093380553" MODIFIED="1458161295676" BACKGROUND_COLOR="#97c7dc" LINK="http://www.itworks.hu/freeplanegtd-release/">
<node TEXT="Freeplane|GTD+" ID="ID_1723255651" CREATED="1283093380553" MODIFIED="1458242798754" BACKGROUND_COLOR="#97c7dc" LINK="http://www.itworks.hu/freeplanegtd-release/">
<font SIZE="16" BOLD="true" ITALIC="true"/>
<hook NAME="MapStyle">
<properties show_icon_for_attributes="true" show_note_icons="true"/>
Expand Down Expand Up @@ -54,7 +54,7 @@
</hook>
<attribute_layout NAME_WIDTH="133" VALUE_WIDTH="319"/>
<attribute NAME="name" VALUE="freeplaneGTD"/>
<attribute NAME="version" VALUE="v1.8.1"/>
<attribute NAME="version" VALUE="v1.8.2"/>
<attribute NAME="author" VALUE="Gergely Papp"/>
<attribute NAME="freeplaneVersionFrom" VALUE="1.3.10"/>
<attribute NAME="freeplaneVersionTo" VALUE=""/>
Expand Down
146 changes: 75 additions & 71 deletions src/scripts/GTDActionEditor.groovy
Expand Up @@ -21,9 +21,9 @@
import freeplaneGTD.DateUtil
import freeplaneGTD.GTDMapReader
import groovy.swing.SwingBuilder
import org.freeplane.plugin.script.proxy.Proxy
import org.freeplane.core.util.TextUtils
import org.freeplane.core.ui.components.UITools
import org.freeplane.core.util.TextUtils
import org.freeplane.plugin.script.proxy.Proxy

import javax.swing.*
import java.awt.*
Expand All @@ -44,23 +44,23 @@ class ActionEditorModel {
Proxy.Node node

boolean setNode(Proxy.Node node) {
this.node=node
this.node = node
GTDMapReader mapReader = GTDMapReader.instance
mapReader.findIcons(node.map.root)
mapReader.internalConvertShorthand(node)
if(!node.icons.contains(mapReader.iconNextAction)){
if (!node.icons.contains(mapReader.iconNextAction)) {
UITools.errorMessage('Selected node is not a task')
return false
}
action=node.text
action = node.text
delegate = node.attributes['Who']?.replaceAll(',', ', ')
context = node.attributes['Where']?.replaceAll(',', ', ')
today=node.icons.contains(GTDMapReader.instance.iconToday)
when=node.attributes['When']
priority=node.attributes['Priority']
waitFor=node.attributes['WaitFor']
waitUntil=node.attributes['WaitUntil']
done=node.icons.contains(GTDMapReader.instance.iconDone)
today = node.icons.contains(GTDMapReader.instance.iconToday)
when = node.attributes['When']
priority = node.attributes['Priority']
waitFor = node.attributes['WaitFor']
waitUntil = node.attributes['WaitUntil']
done = node.icons.contains(GTDMapReader.instance.iconDone)
return true
}

Expand All @@ -76,23 +76,27 @@ class ActionEditorModel {
!context ? node.attributes.removeAll('Where') : false
!when ? node.attributes.removeAll('When') : false
!priority ? node.attributes.removeAll('Priority') : false
!waitFor?node.attributes.removeAll('WaitFor'):node.attributes.set('WaitFor',waitFor)
if (waitUntil){
Date waitUntilDate = DateUtil.normalizeDate(waitUntil)
node.attributes.set('WaitUntil',waitUntilDate)
if (waitFor) {
node.attributes.set('WaitFor', waitFor.split(',')*.trim().unique({ a, b -> a.toLowerCase() <=> b.toLowerCase() }).join(','))
} else
node.attributes.removeAll('WaitFor')

if (waitUntil) {
def waitUntilDate = DateUtil.normalizeDate(waitUntil)
node.attributes.set('WaitUntil', waitUntilDate)
} else
node.attributes.removeAll('WaitUntil')

GTDMapReader mapReader = GTDMapReader.instance
if (node.icons.contains(mapReader.iconToday)!=today) {
if(!today){
if (node.icons.contains(mapReader.iconToday) != today) {
if (!today) {
node.icons.remove(mapReader.iconToday)
} else {
node.icons.add(mapReader.iconToday)
node.icons.add(mapReader.iconToday)
}
}
if (node.icons.contains(mapReader.iconDone)!=done) {
if(!done){
if (node.icons.contains(mapReader.iconDone) != done) {
if (!done) {
node.icons.remove(mapReader.iconDone)
} else {
node.icons.add(mapReader.iconDone)
Expand Down Expand Up @@ -124,10 +128,10 @@ class ActionEditor {
JTextField actionField
JTextField delegateField
JTextField contextField
JCheckBox todayField
JCheckBox todayField
JTextField whenField
JTextField priorityField
JCheckBox doneField
JCheckBox doneField
JTextField waitForField
JTextField waitUntilField
JButton doneButton
Expand All @@ -140,48 +144,48 @@ class ActionEditor {
show: false,
modal: true) {
boxLayout(axis: BoxLayout.Y_AXIS)
panel(border:BorderFactory.createEmptyBorder(10,10,10,10)) {
panel(border: BorderFactory.createEmptyBorder(10, 10, 10, 10)) {
gridBagLayout()

label(text: TextUtils.getText("freeplaneGTD.actioneditor.action"),
constraints: gbc(gridx:0,gridy:0,ipadx:5,fill:HORIZONTAL))
actionField = textField(preferredSize:new Dimension(400,25),
constraints:gbc(gridx:1,gridy:0,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 0, ipadx: 5, fill: HORIZONTAL))
actionField = textField(preferredSize: new Dimension(400, 25),
constraints: gbc(gridx: 1, gridy: 0, gridwidth: REMAINDER, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.delegate"),
constraints: gbc(gridx:0,gridy:1,ipadx:5,fill:HORIZONTAL))
delegateField = textField(preferredSize:new Dimension(300,25),
constraints:gbc(gridx:1,gridy:1,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 1, ipadx: 5, fill: HORIZONTAL))
delegateField = textField(preferredSize: new Dimension(300, 25),
constraints: gbc(gridx: 1, gridy: 1, gridwidth: REMAINDER, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.context"),
constraints: gbc(gridx:0,gridy:2,ipadx:5,fill:HORIZONTAL))
contextField = textField(preferredSize:new Dimension(300,25),
constraints:gbc(gridx:1,gridy:2,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 2, ipadx: 5, fill: HORIZONTAL))
contextField = textField(preferredSize: new Dimension(300, 25),
constraints: gbc(gridx: 1, gridy: 2, gridwidth: REMAINDER, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.when"),
constraints: gbc(gridx:0,gridy:3,ipadx:5,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 3, ipadx: 5, fill: HORIZONTAL))
todayField = checkBox(text: TextUtils.getText("freeplaneGTD.actioneditor.today"),
preferredSize:new Dimension(50,25),
constraints:gbc(gridx:1,gridy:3,ipadx:5))
whenField = textField(preferredSize:new Dimension(250,25),
constraints:gbc(gridx:2,gridy:3,fill:HORIZONTAL))
preferredSize: new Dimension(50, 25),
constraints: gbc(gridx: 1, gridy: 3, ipadx: 5))
whenField = textField(preferredSize: new Dimension(250, 25),
constraints: gbc(gridx: 2, gridy: 3, fill: HORIZONTAL))
doneField = checkBox(text: TextUtils.getText("freeplaneGTD.actioneditor.done"),
constraints:gbc(gridx:3,gridy:3,fill:HORIZONTAL))
constraints: gbc(gridx: 3, gridy: 3, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.waitFor"),
constraints: gbc(gridx:0,gridy:4,ipadx:5,fill:HORIZONTAL))
waitForField = textField(preferredSize:new Dimension(250,25),
constraints:gbc(gridx:1,gridy:4,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 4, ipadx: 5, fill: HORIZONTAL))
waitForField = textField(preferredSize: new Dimension(250, 25),
constraints: gbc(gridx: 1, gridy: 4, gridwidth: REMAINDER, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.waitUntil"),
constraints: gbc(gridx:0,gridy:5,ipadx:5,fill:HORIZONTAL))
waitUntilField = textField(preferredSize:new Dimension(250,25),
constraints:gbc(gridx:1,gridy:5,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 5, ipadx: 5, fill: HORIZONTAL))
waitUntilField = textField(preferredSize: new Dimension(250, 25),
constraints: gbc(gridx: 1, gridy: 5, gridwidth: REMAINDER, fill: HORIZONTAL))

label(text: TextUtils.getText("freeplaneGTD.actioneditor.priority"),
constraints: gbc(gridx:0,gridy:6,ipadx:5,fill:HORIZONTAL))
priorityField = textField(preferredSize:new Dimension(20,25),
constraints:gbc(gridx:1,gridy:6,gridwidth:REMAINDER,fill:HORIZONTAL))
constraints: gbc(gridx: 0, gridy: 6, ipadx: 5, fill: HORIZONTAL))
priorityField = textField(preferredSize: new Dimension(20, 25),
constraints: gbc(gridx: 1, gridy: 6, gridwidth: REMAINDER, fill: HORIZONTAL))

}

Expand All @@ -194,15 +198,15 @@ class ActionEditor {
})
doneButton = button(id: 'doneButton', text: TextUtils.getText("freeplaneGTD.button.done"),
actionPerformed: {
model.action=actionField.text
model.delegate=delegateField.text
model.context=contextField.text
model.today=todayField.selected
model.when=whenField.text
model.priority=priorityField.text
model.waitFor=waitForField.text
model.waitUntil=waitUntilField.text
model.done=doneField.selected
model.action = actionField.text
model.delegate = delegateField.text
model.context = contextField.text
model.today = todayField.selected
model.when = whenField.text
model.priority = priorityField.text
model.waitFor = waitForField.text
model.waitUntil = waitUntilField.text
model.done = doneField.selected
model.updateNode()
mainFrame.setVisible(false)
mainFrame.dispose()
Expand All @@ -215,27 +219,27 @@ class ActionEditor {
mainFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), TextUtils.getText("freeplaneGTD.button.cancel"));
mainFrame.getRootPane().getActionMap().put(TextUtils.getText("freeplaneGTD.button.cancel"),
new AbstractAction () {
void actionPerformed(ActionEvent e) {
mainFrame.setVisible(false);
mainFrame.dispose();
}
});
new AbstractAction() {
void actionPerformed(ActionEvent e) {
mainFrame.setVisible(false);
mainFrame.dispose();
}
});
}

void editNode(Proxy.Node node) {
if (!model.setNode(node)) {
return
}
actionField.text=model.action
delegateField.text=model.delegate
contextField.text=model.context
todayField.selected=model.today
whenField.text=model.when
priorityField.text=model.priority
waitForField.text=model.waitFor
waitUntilField.text=model.waitUntil
doneField.selected=model.done
actionField.text = model.action
delegateField.text = model.delegate
contextField.text = model.context
todayField.selected = model.today
whenField.text = model.when
priorityField.text = model.priority
waitForField.text = model.waitFor
waitUntilField.text = model.waitUntil
doneField.selected = model.done
mainFrame.pack()
mainFrame.setLocationRelativeTo(UITools.frame)
mainFrame.setVisible(true)
Expand Down
41 changes: 24 additions & 17 deletions src/zips/lib/freeplaneGTD/ReportModel.groovy
Expand Up @@ -141,27 +141,34 @@ class ReportModel {
def delegateList() {
Map retval = [type: 'who']
List groups = []
Map naByGroupFull = actionList.groupBy { it['who'] } + actionList.groupBy { it['waitFor'] }
Map naByGroup = [:]
naByGroupFull.each {
Map naByWhoFull = actionList.groupBy({ it['who'] })
Map naByWaitForFull = actionList.groupBy({ it['waitFor'] })
Map naByDelegate = [:]
naByWhoFull.each {
key, value ->
if (key) {
def keyList = key.split(',')*.trim()
keyList.each {
naByGroup.put(it, naByGroup[it] ? naByGroup[it] + value : value)
}
}
if (key) {
def keyList = key.split(',')*.trim()
keyList.each {
naByDelegate.put(it, naByDelegate[it] ? (naByDelegate[it] + value).unique() : value)
}
}
}

naByGroup.each { key, value ->
naByGroup[key] = value.unique();
naByWaitForFull.each {
key, value ->
if (key) {
def keyList = key.split(',')*.trim()
keyList.each {
naByDelegate.put(it, naByDelegate[it] ? (naByDelegate[it] + value).unique() : value)
}
}
}

naByGroup = naByGroup.sort { it.toString().toLowerCase() }
naByGroup.each {

naByDelegate = naByDelegate.sort { it.toString().toLowerCase() }
naByDelegate.each {
key, value ->
List<Map> items = []
def curGroup = naByGroup[key].sort { a, b -> taskSortComparator(a, b) }
def curGroup = naByDelegate[key].sort { a, b -> taskSortComparator(a, b) }
curGroup.each {
def newItem = [done : it['done'],
priority : it['priority'],
Expand All @@ -174,10 +181,10 @@ class ReportModel {
details : it['details'],
notes : it['notes']
]
if (it['who'] && it['who'].trim()!=key) {
if (it['who'] && it['who'].trim() != key) {
newItem['who'] = it['who']
}
if (it['waitFor'] && it['waitFor'].trim()!=key) {
if (it['waitFor'] && it['waitFor'].trim() != key) {
newItem['waitFor'] = it['waitFor']
}
items << newItem
Expand Down

0 comments on commit 1e7dba9

Please sign in to comment.