Removed Action portions. Added logging framework. GUI architecture changed (move to dependancy injection)

This commit is contained in:
Jonathan Bernard
2009-12-23 18:29:13 -06:00
parent 5b19542355
commit cee6de1147
15 changed files with 1534 additions and 53 deletions

View File

@ -1,11 +1,18 @@
package com.jdbernard.timestamper
import java.awt.Point
class NotesDialogController {
// these will be injected by Griffon
def model
def view
void mvcGroupInit(Map args) {
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
}
}

View File

@ -9,10 +9,17 @@ class TimeStamperMainController {
def view
void mvcGroupInit(Map args) {
def notes = buildMVCGroup('NotesDialog')
def punchcard = buildMVCGroup('PunchcardDialog')
view.notesDialog = notes.view.notesDialog
view.punchcardDialog = punchcard.view.punchcardDialog
if (logger.isTraceEnabled())
logger.trace("Initializeing TimeStamperMain MVC...")
def thisMVC = ['model': model, 'view': view, 'controller': this]
model.notesDialogMVC = buildMVCGroup('NotesDialog', 'notesDialog',
'mainMVC': thisMVC)
model.punchcardDialogMVC = buildMVCGroup('PunchcardDialog',
'punchcardDialog', 'mainMVC': thisMVC)
// load application properties
Properties prop = new Properties()
@ -21,7 +28,9 @@ class TimeStamperMainController {
if (!model.configFile.exists()) model.configFile.createNewFile()
try { model.configFile.withInputStream { prop.load(it) } }
catch (IOException ioe) { /* TODO */ }
catch (IOException ioe) {
logger.error('Unable to load configuration', ioe)
}
model.config = prop
@ -42,16 +51,27 @@ class TimeStamperMainController {
// load the last marker
model.currentMarker = model.timeline.getLastMarker(new Date())
if (logger.isTraceEnabled())
logger.trace("TimeStamperMain MVC initialization complete.")
}
def exitGracefully = { evt = null ->
if (logger.isTraceEnabled()) logger.trace("Exiting gracefully.")
// save config
try { model.configFile.withOutputStream { out ->
model.config.store(out, null) } }
catch (IOException ioe) {}
catch (IOException ioe) {
logger.error("Unable to save the configuration file", ioe)
}
// save timeline and properties
model.timelineProperties.save()
if (logger.isTraceEnabled()) logger.trace("Completed graceful shutdown.")
app.shutdown()
}