Incremental GUI updates. Copied over code for TimelineDayDisplay.
This commit is contained in:
@ -1,26 +1,11 @@
|
||||
package com.jdbernard.timestamper
|
||||
|
||||
import java.awt.Point
|
||||
import java.awt.Rectangle
|
||||
import java.awt.Toolkit
|
||||
|
||||
class NotesDialogController {
|
||||
// these will be injected by Griffon
|
||||
def model
|
||||
def view
|
||||
|
||||
|
||||
void mvcGroupInit(Map args) {
|
||||
}
|
||||
|
||||
Point mousePressRelativeToDialog
|
||||
|
||||
def mousePressed = { evt -> mousePressRelativeToDialog = evt?.point }
|
||||
|
||||
def mouseDragged = { evt ->
|
||||
GUIUtil.componentDragged(view.notesDialog, evt,
|
||||
mousePressRelativeToDialog,
|
||||
new Rectangle(Toolkit.defaultToolkit.screenSize),
|
||||
app.views.TimeStamperMain.frame.bounds)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.jdbernard.timestamper
|
||||
|
||||
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 action = { evt = null ->
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,49 +1,64 @@
|
||||
package com.jdbernard.timestamper
|
||||
|
||||
import java.awt.Point
|
||||
import java.awt.Rectangle
|
||||
import java.awt.Toolkit
|
||||
import java.util.Timer
|
||||
import com.jdbernard.timestamper.core.TimelineMarker
|
||||
import com.jdbernard.timestamper.core.TimelineProperties
|
||||
|
||||
class TimeStamperMainController {
|
||||
// these will be injected by Griffon
|
||||
def model
|
||||
def view
|
||||
|
||||
Timer updateTimer
|
||||
|
||||
Point mousePressRelativeToFrame
|
||||
|
||||
void mvcGroupInit(Map args) {
|
||||
def notes = buildMVCGroup('NotesDialog')
|
||||
def punchcard = buildMVCGroup('PunchcardDialog')
|
||||
view.notesDialog = notes.view.notesDialog
|
||||
view.punchcardDialog = punchcard.view.punchcardDialog
|
||||
|
||||
updateTimer
|
||||
// load application properties
|
||||
Properties prop = new Properties()
|
||||
String userHomeDir = System.getProperty('user.home')
|
||||
model.configFile = new File(userHomeDir, ".timestamperrc")
|
||||
if (!model.configFile.exists()) model.configFile.createNewFile()
|
||||
|
||||
try { model.configFile.withInputStream { prop.load(it) } }
|
||||
catch (IOException ioe) { /* TODO */ }
|
||||
|
||||
model.config = prop
|
||||
|
||||
// load the last used timeline file
|
||||
String lastUsed = model.config.getProperty('lastUsed', null)
|
||||
if (lastUsed == null) {
|
||||
lastUsed = 'timeline.default.properties'
|
||||
model.config.setProperty('lastUsed', lastUsed)
|
||||
}
|
||||
File propertyFile = new File(lastUsed)
|
||||
if (!propertyFile.exists()) propertyFile.createNewFile()
|
||||
|
||||
model.timelineProperties = new TimelineProperties(propertyFile)
|
||||
|
||||
// load the main timeline
|
||||
model.timeline = model.timelineProperties.timeline
|
||||
|
||||
// load the last marker
|
||||
model.currentMarker = model.timeline.getLastMarker(new Date())
|
||||
|
||||
}
|
||||
|
||||
def exitGracefully = { evt = null ->
|
||||
// save config
|
||||
try { model.configFile.withOutputStream { out ->
|
||||
model.config.store(out, null) } }
|
||||
catch (IOException ioe) {}
|
||||
|
||||
// save timeline and properties
|
||||
model.timelineProperties.save()
|
||||
app.shutdown()
|
||||
}
|
||||
|
||||
def showToolsMenu = { evt = null ->
|
||||
|
||||
}
|
||||
|
||||
def showNotes = { evt = null ->
|
||||
view.notesDialog.visible = view.notesVisibleButton.selected
|
||||
}
|
||||
|
||||
def showPunchcard = { evt = null ->
|
||||
|
||||
}
|
||||
|
||||
def mousePressed = { evt = null ->
|
||||
mousePressRelativeToFrame = evt?.point
|
||||
}
|
||||
|
||||
def mouseDragged = { evt = null ->
|
||||
GUIUtil.componentDragged(view.frame, evt, mousePressRelativeToFrame,
|
||||
new Rectangle(Toolkit.defaultToolkit.screenSize))
|
||||
def newTask = { mark ->
|
||||
model.currentMarker = new TimelineMarker(new Date(), mark,
|
||||
"No comments.")
|
||||
model.timeline.addMarker(model.currentMarker)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user