Finished catching up to 1.7 functionality.

This commit is contained in:
Jonathan Bernard
2009-12-26 14:49:46 -06:00
parent cee6de1147
commit 6d212ea771
21 changed files with 346 additions and 67 deletions

View File

@ -1,16 +1,22 @@
package com.jdbernard.timestamper
package com.jdbernard.timestamper
import java.awt.Point
class PunchcardDialogController {
// these will be injected by Griffon
def model
def view
void mvcGroupInit(Map args) {
// this method is called after model and view are injected
def loc = model.mainMVC.view.frame.location
Point p = new Point(0, (int) model.mainMVC.view.frame.bounds.height + 50)
p.translate((int) loc.x, (int) loc.y)
view.dialog.location = p
}
/*
def action = { evt = null ->
}
*/
}
}

View File

@ -10,8 +10,7 @@ class TimeStamperMainController {
void mvcGroupInit(Map args) {
if (logger.isTraceEnabled())
logger.trace("Initializeing TimeStamperMain MVC...")
logger.traceIfEnabled("Initializing TimeStamperMain MVC...")
def thisMVC = ['model': model, 'view': view, 'controller': this]
@ -27,6 +26,9 @@ class TimeStamperMainController {
model.configFile = new File(userHomeDir, ".timestamperrc")
if (!model.configFile.exists()) model.configFile.createNewFile()
logger.traceIfEnabled("Reading configuration from "
+ "'${model.configFile.name}'")
try { model.configFile.withInputStream { prop.load(it) } }
catch (IOException ioe) {
logger.error('Unable to load configuration', ioe)
@ -40,27 +42,41 @@ class TimeStamperMainController {
lastUsed = 'timeline.default.properties'
model.config.setProperty('lastUsed', lastUsed)
}
logger.traceIfEnabled("Reading Timeline properties from '${lastUsed}'")
File propertyFile = new File(lastUsed)
if (!propertyFile.exists()) propertyFile.createNewFile()
model.timelineProperties = new TimelineProperties(propertyFile)
load(propertyFile)
}
def load = { File propertiesFile ->
try {
model.config.setProperty('lastUsed', propertiesFile.canonicalPath)
} catch (IOException ioe) { logger.error(ioe) }
// load the properties file
model.timelineProperties = new TimelineProperties(propertiesFile)
// load the main timeline
model.timeline = model.timelineProperties.timeline
// load the last marker
model.currentMarker = model.timeline.getLastMarker(new Date())
if (logger.isTraceEnabled())
logger.trace("TimeStamperMain MVC initialization complete.")
}
def saveas = {
}
def exitGracefully = { evt = null ->
if (logger.isTraceEnabled()) logger.trace("Exiting gracefully.")
logger.traceIfEnabled("Exiting gracefully.")
// save config
logger.debugIfEnabled("Config: ${model.config}")
logger.debugIfEnabled("Storing config to file: ${model.configFile.path}")
try { model.configFile.withOutputStream { out ->
model.config.store(out, null) } }
catch (IOException ioe) {
@ -70,15 +86,20 @@ class TimeStamperMainController {
// save timeline and properties
model.timelineProperties.save()
if (logger.isTraceEnabled()) logger.trace("Completed graceful shutdown.")
logger.traceIfEnabled("Completed graceful shutdown.")
app.shutdown()
}
def newTask = { mark ->
model.currentMarker = new TimelineMarker(new Date(), mark,
"No comments.")
model.timeline.addMarker(model.currentMarker)
def newTask = { mark, notes = "No comments.", timestamp = new Date() ->
TimelineMarker tm = new TimelineMarker(timestamp, mark, notes)
model.timeline.addMarker(tm)
model.currentMarker = model.timeline.getLastMarker(new Date())
}
def deleteTask = { marker ->
model.timeline.removeMarker(marker)
model.currentMarker = model.timeline.getLastMarker(new Date())
}
}