Skip to content

Commit

Permalink
Fixed as-is
Browse files Browse the repository at this point in the history
Core libs are moved to external module
Out directory is used for release
  • Loading branch information
gpapp committed Jun 15, 2017
1 parent 7707559 commit 3d0250f
Show file tree
Hide file tree
Showing 48 changed files with 2,058 additions and 1,087 deletions.
25 changes: 25 additions & 0 deletions FreePlaneGTD.iml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/out/production/FreePlaneGTD" />
<output-test url="file://$MODULE_DIR$/out/test/FreePlaneGTD" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/test/lib" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/harness/src" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/harness/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/gdsl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/scripts" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/lib" />
<excludeFolder url="file://$MODULE_DIR$/src/resources/zips/translations" />
</content>
<orderEntry type="module" module-name="lib" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="freeplane-plugins" level="project" />
<orderEntry type="library" name="freeplane" level="application" />
<orderEntry type="library" name="groovy-2.4.8" level="application" />
<orderEntry type="inheritedJdk" />
</component>
</module>
2 changes: 1 addition & 1 deletion doc/GTD with Freeplane.html
Expand Up @@ -63,7 +63,7 @@

## Install Freeplane

Download and install [Freeplane](http://freeplane.sourceforge.net)
Download and install [Freeplane](http://freeplane.sourceforge.net)
for your computer.

## Install the add-on
Expand Down
90 changes: 90 additions & 0 deletions harness/src/FreePlaneGTD/Harness.groovy
@@ -0,0 +1,90 @@
package FreePlaneGTD

import freeeplaneHarness.MyController
import freeplaneGTD.ReportModel
import freeplaneGTD.ReportWindow
import groovy.swing.SwingBuilder
import org.freeplane.core.resources.ResourceBundles
import org.freeplane.features.mode.Controller
import org.freeplane.main.application.ApplicationResourceController
import org.freeplane.plugin.script.FreeplaneScriptBaseClass
import org.freeplane.plugin.script.proxy.Proxy
import org.knopflerfish.framework.FrameworkContext
import org.knopflerfish.framework.ServiceURLStreamHandlerFactory

import javax.swing.*
import java.awt.*
import java.awt.event.ActionEvent

/**
* Created by gpapp on 2017.05.28..
*/
class Harness implements Runnable {
private static final String PROPERTY_FILE = "harness/keys.properties"

@Override
void run() {
def config = new FreeplaneScriptBaseClass.ConfigProperties()
Proxy.Map map

JFrame myFrame
SwingBuilder.edtBuilder {
myFrame = frame(title: 'FreePlaneGTD.Harness',
defaultCloseOperation: JFrame.EXIT_ON_CLOSE) {
borderLayout()
button(name: 'toolbar', constraints: BorderLayout.NORTH)
button(
constraints: BorderLayout.SOUTH,
text: 'Refresh',
action:
new AbstractAction() {
@Override
void actionPerformed(ActionEvent e) {
Controller currentController = Controller.currentController
ReportWindow reportWindow = currentController.getExtension(ReportWindow.class)
if (!reportWindow) {
reportWindow = new ReportWindow()
currentController.addExtension(ReportWindow.class, reportWindow)
}
reportWindow.show(currentController, config)
reportWindow.refresh(map.root)
}
}
)
}
}

myFrame.visible = true
myFrame.setLocation(10, 10)
myFrame.setSize(100, 100)

def resourceController = new ApplicationResourceController()
Controller.currentController = new MyController(resourceController, myFrame)
((ResourceBundles) resourceController.resources).
addResources("hu", new URL("file:src/zips/translations/freeplaneGTD_en.properties"))

ServiceURLStreamHandlerFactory streamHandlerFactory = new ServiceURLStreamHandlerFactory()
URL.setURLStreamHandlerFactory(streamHandlerFactory)
streamHandlerFactory.addFramework(new FrameworkContext([
"org.osgi.framework.security": "",
"org.osgi.framework.storage" : "/usr/share/freeplane/fwdir"]))


map = Controller.currentController.newMap()
addNode(map, "ID__1", "*test task 1")
addNode(map, "ID__2", "*test task 2 {2017-06-19}")
addNode(map, "ID__3", "*test task 3 #3 {2017-06-19} @Context1 @Context2")


config.properties.put(ReportWindow.FREEPLANE_GTD_DEFAULT_VIEW, ReportModel.VIEW.WHEN.toString())
config.properties.put(ReportWindow.FREEPLANE_GTD_REMEMBER_LAST_POSITION, Boolean.TRUE)


}

private static void addNode(Proxy.Map map, String id, String text) {
Proxy.Node child = map.root.createChild()
child.text = text
}

}
6 changes: 6 additions & 0 deletions harness/src/freeeplaneHarness/MyController.groovy
Expand Up @@ -52,6 +52,7 @@ import org.freeplane.view.swing.map.MapViewController
import javax.swing.*
import java.awt.dnd.DragGestureListener
import java.awt.dnd.DropTargetListener
import java.awt.event.ActionEvent
import java.awt.event.KeyListener
import java.awt.event.MouseWheelListener

Expand Down Expand Up @@ -442,4 +443,9 @@ class MyController extends Controller implements Proxy.Controller {
void export(Proxy.Map map, File file, String s, boolean b) {

}

@Override
void quit(ActionEvent actionEvent) {
System.exit(0)
}
}
15 changes: 15 additions & 0 deletions lib/lib.iml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/../out/production/FreePlaneGTD/zips/lib" />
<output-test url="file://$MODULE_DIR$/../out/test/lib" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="freeplane-plugins" level="project" />
<orderEntry type="library" name="freeplane" level="application" />
<orderEntry type="library" name="groovy-2.4.8" level="application" />
<orderEntry type="inheritedJdk" />
</component>
</module>
File renamed without changes.
File renamed without changes.
File renamed without changes.
145 changes: 145 additions & 0 deletions lib/src/freeplaneGTD/JSHandler.groovy
@@ -0,0 +1,145 @@
package freeplaneGTD

import org.freeplane.core.ui.components.UITools
import org.freeplane.core.util.TextUtils
import org.freeplane.features.clipboard.ClipboardController
import org.freeplane.features.mode.Controller
import org.freeplane.plugin.script.ScriptContext
import org.freeplane.plugin.script.proxy.Proxy
import org.freeplane.plugin.script.proxy.ProxyFactory
import org.freeplane.plugin.script.proxy.ScriptUtils

import javax.swing.*
import java.awt.*
import java.util.List
import java.util.logging.Level
import java.util.logging.Logger

class JSHandler {
private final ReportModel report
private final ReportWindow target

JSHandler(ReportModel report, ReportWindow target) {
this.target = target
this.report = report
}

void toggleDone(String linkNodeID) {
try {
def nodesFound = ScriptUtils.c().find { it.id == linkNodeID }

if (nodesFound[0] != null) {
def node = nodesFound[0]
if (node.icons.contains(report.mapReader.iconDone)) {
node.icons.remove(report.mapReader.iconDone)
} else {
node.icons.add(report.mapReader.iconDone)
}
target.refreshContent()
} else {
UITools.informationMessage("Cannot find node to mark as done")
}
} catch (Exception e) {
System.err.println(e)
}
}

void followLink(String linkNodeID) {
try {
def nodesFound = ScriptUtils.c().find { it.id == linkNodeID }

if (nodesFound[0] != null) {
switchToMainWindow()
if (target.autoFoldMap) {
foldToTop(nodesFound[0])
}
unfoldBranch(nodesFound[0])
ScriptUtils.c().centerOnNode(nodesFound[0])
ScriptUtils.c().select(nodesFound[0])
} else {
UITools.informationMessage("Next Action not found in mind map. Refresh Next Action list")
}
} catch (Exception e) {
Logger.anonymousLogger.log(Level.SEVERE, e.message, e)
}
}

void copyToClipboard(int pos) {
try {
Map feeder
ClipboardController clip = ClipboardController.controller
switch (target.selectedView) {
case ReportModel.VIEW.PROJECT: feeder = [type: 'project', groups: [report.projectList()['groups'][pos]]]; break
case ReportModel.VIEW.WHO: feeder = [type: 'who', groups: [report.delegateList()['groups'][pos]]]; break
case ReportModel.VIEW.CONTEXT: feeder = [type: 'context', groups: [report.contextList()['groups'][pos]]]; break
case ReportModel.VIEW.WHEN: feeder = [type: 'when', groups: [report.timelineList()['groups'][pos]]]; break
default: throw new UnsupportedOperationException("Invalid selection pane: " + target.selectedView)
}
clip.clipboardContents = ClipBoardUtil.createTransferable(feeder, report.mapReader, target.showNotes)
UITools.informationMessage(TextUtils.getText('freeplaneGTD.message.copy_ok'))
} catch (Exception e) {
Logger.anonymousLogger.log(Level.SEVERE, e.message, e)
}
}

void selectOnMap(int pos) {
try {
List list
switch (target.selectedView) {
case ReportModel.VIEW.PROJECT: list = (List) report.projectList()['groups'][pos]['items']; break
case ReportModel.VIEW.WHO: list = (List) report.delegateList()['groups'][pos]['items']; break
case ReportModel.VIEW.CONTEXT: list = (List) report.contextList()['groups'][pos]['items']; break
case ReportModel.VIEW.WHEN: list = (List) report.timelineList()['groups'][pos]['items']; break
default: throw new UnsupportedOperationException("Invalid selection pane: " + target.selectedView)
}
List ids = list.collect { it['nodeID'] }
def nodesFound = ScriptUtils.c().find { ids.contains(it.id) }
if (nodesFound.size() > 0) {
if (target.autoFoldMap) {
foldToTop(nodesFound[0])
}
nodesFound.each {
unfoldBranch(it)
}
ScriptUtils.c().centerOnNode(nodesFound[0])
ScriptUtils.c().selectMultipleNodes(nodesFound)
switchToMainWindow()
} else {
UITools.informationMessage("Error finding selection")
}
}

catch (Exception e) {
Logger.anonymousLogger.log(Level.SEVERE, e.message, e)
}
}

private static void switchToMainWindow() {
JFrame parentFrame = Controller.currentController.viewController.menuComponent as JFrame
for (Window window : Window.windows) {
if (parentFrame == window) {
window.toFront()
}
}
}

// recursive unfolding of branch
private void unfoldBranch(Proxy.Node thisNode) {
Proxy.Node rootNode = thisNode.getMap().getRoot()
if (thisNode != rootNode) {
if (thisNode.folded) thisNode.setFolded(false)
unfoldBranch(thisNode.getParent())
}
}

// fold to first level
private void foldToTop(Proxy.Node thisNode) {
Proxy.Node rootNode = thisNode.getMap().getRoot()
def Nodes = ScriptUtils.c().findAll()
Nodes.each {
if(!it.folded) it.setFolded(true)
}
rootNode.setFolded(false)
}

}
File renamed without changes.

0 comments on commit 3d0250f

Please sign in to comment.