Added NotesDialog MVC. Wired window movement. Added GUIUtil

This commit is contained in:
Jonathan Bernard
2009-12-21 14:06:32 -06:00
parent 5000d266fe
commit 02fc6b5bb7
9 changed files with 212 additions and 5 deletions

View File

@ -0,0 +1,3 @@
package com.jdbernard.timestamper
def emptyAction = action(name: 'Empty Action')

View File

@ -9,6 +9,14 @@ application {
//frameClass = 'javax.swing.JFrame'
}
mvcGroups {
// MVC Group for "com.jdbernard.timestamper.NotesDialog"
'NotesDialog' {
actions = 'com.jdbernard.timestamper.NotesDialogActions'
model = 'com.jdbernard.timestamper.NotesDialogModel'
controller = 'com.jdbernard.timestamper.NotesDialogController'
view = 'com.jdbernard.timestamper.NotesDialogView'
}
// MVC Group for "com.jdbernard.timestamper.TimeStamperMain"
'TimeStamperMain' {
actions = 'com.jdbernard.timestamper.TimeStamperMainActions'

View File

@ -0,0 +1,26 @@
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)
}
}

View File

@ -1,12 +1,24 @@
package com.jdbernard.timestamper
import java.awt.Point
import java.awt.Rectangle
import java.awt.Toolkit
import java.util.Timer
class TimeStamperMainController {
// these will be injected by Griffon
def model
def view
Timer updateTimer
Point mousePressRelativeToFrame
void mvcGroupInit(Map args) {
// this method is called after model and view are injected
def notes = buildMVCGroup('NotesDialog')
view.notesDialog = notes.view.notesDialog
updateTimer
}
def exitGracefully = { evt = null ->
@ -16,4 +28,22 @@ class TimeStamperMainController {
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))
}
}

View File

@ -0,0 +1,7 @@
package com.jdbernard.timestamper
import groovy.beans.Bindable
class NotesDialogModel {
}

View File

@ -0,0 +1,28 @@
package com.jdbernard.timestamper
import java.awt.Color
import javax.swing.BoxLayout
import net.miginfocom.swing.MigLayout
notesDialog = dialog(
title: 'Notes',
modal: false,
undecorated: true,
minimumSize: [325, 200],
iconImage: imageIcon('/16-em-pencil.png').image,
iconImages: [imageIcon('/16-em-pencil.png').image]
) {
panel(
border:lineBorder(color: Color.BLACK, thickness:1, parent:true),
mousePressed: controller.&mousePressed,
mouseDragged: controller.&mouseDragged,
layout: new MigLayout('insets 5 5 5 5, fill')
) {
scrollPane(constraints: 'growx, growy') {
notesTextArea = textArea(lineWrap: true, columns: 20, rows: 5,
wrapStyleWord: true)
}
}
}

View File

@ -5,7 +5,7 @@ import java.awt.Font
import javax.swing.BoxLayout
import net.miginfocom.swing.MigLayout
application(title:'TimeStamper',
frame = application(title:'TimeStamper',
//size:[320,480],
pack:true,
//location:[50,50],
@ -17,7 +17,9 @@ application(title:'TimeStamper',
) {
panel(
border:lineBorder(color:Color.BLACK, thickness:1, parent:true),
layout: new MigLayout('insets 0 5 0 0, fill','', '[]0[]0[]')
layout: new MigLayout('insets 0 5 0 0, fill','', '[]0[]0[]'),
mousePressed: controller.&mousePressed,
mouseDragged: controller.&mouseDragged
) {
def mainFont = new Font(Font.SANS_SERIF, Font.BOLD, 12)
def timeFont = new Font(Font.SANS_SERIF, Font.BOLD, 14)
@ -45,10 +47,12 @@ application(title:'TimeStamper',
panel(constraints: 'alignx leading, aligny top, gapright 5px, wrap') {
boxLayout(axis: BoxLayout.X_AXIS)
toggleButton(showNotesAction, icon: imageIcon('/16-em-pencil.png'),
notesVisibleButton = toggleButton(showNotesAction, icon: imageIcon('/16-em-pencil.png'),
hideActionText: true,
border: emptyBorder(4))
toggleButton(showPunchcardAction,
punchcardVisibleButton = toggleButton(showPunchcardAction,
icon: imageIcon('/16-file-archive.png'),
hideActionText: true,
border: emptyBorder(4))
}