Still updating pit-swing.

This commit is contained in:
Jonathan Bernard
2010-03-09 00:28:26 -06:00
parent cd8cdf02a4
commit fcec66de70
8 changed files with 742 additions and 50 deletions

View File

@ -1,5 +1,8 @@
package com.jdbernard.pit.swing
import com.jdbernard.pit.Category
import com.jdbernard.pit.Status
class NewIssueDialogController {
// these will be injected by Griffon
def model

View File

@ -66,18 +66,17 @@ class PITController {
newMVC.model.id = projectDir.canonicalPath
// still not unique?
if (projectPanelMVC[(newMVC.model.id)]) {
if (model.projectPanelMVCs[(newMVC.model.id)]) {
// first time this has happened?
if (!projectIdMap[(newMVC.model.id)])
projectIdMap[(newMVC.model.id)] = 0
if (!model.projectIdMap[(newMVC.model.id)])
model.projectIdMap[(newMVC.model.id)] = 0
// no? increment
else projectIdMap[(newMVC.model.id)] =
projectIdMap[(newMVC.model.id)] + 1
else model.projectIdMap[(newMVC.model.id)] =
model.projectIdMap[(newMVC.model.id)] + 1
// use our new, unique id
newMVC.model.id = projectDir.name +
projectIdMap[(newMVC.model.id)]
newMVC.model.id += "-" + model.projectIdMap[(newMVC.model.id)]
}
}
@ -85,6 +84,12 @@ class PITController {
view.mainTabbedPane.addTab(newMVC.model.id, newMVC.view.panel)
}
def closeProject = { evt = null ->
model.projectPanelMVCs.remove(view.mainTabbedPane.getTitleAt(
view.mainTabbedPane.selectedIndex))
view.mainTabbedPane.remove(view.mainTabbedPane.selectedComponent)
}
def shutdown = { evt = null ->
app.shutdown()
}

View File

@ -16,7 +16,9 @@ class ProjectPanelController {
def view
void mvcGroupInit(Map args) {
view.projectTree.model = new DefaultTreeModel(makeNodes(model.rootProject))
//model.rootProject = args.rootProject
view.projectTree.model = new DefaultTreeModel(
makeNodes(model.rootProject))
}
/**
@ -91,13 +93,13 @@ class ProjectPanelController {
}
def newIssue = { evt = null ->
newIssueDialogMVC.controller.show()
if (newIssueDialogMVC.model.accept) {
def nidmodel = newIssueDialodMVC.model
def issueText = ""
model.newIssueDialogMVC.controller.show()
if (model.newIssueDialogMVC.model.accept) {
def nidModel = model.newIssueDialogMVC.model
def issueText = nidModel.text
if (model.templates[(nidModel.category)]) {
issueText = model.templates[(nidModel.category)]
if (model.mainMVC.model.templates[(nidModel.category)]) {
issueText = model.mainMVC.model.templates[(nidModel.category)]
issueText = issueText.replaceFirst(/TITLE/,
nidModel.text)
}

View File

@ -6,25 +6,22 @@ import com.jdbernard.pit.Project
import groovy.beans.Bindable
class ProjectPanelModel {
def mainMVC
// other GUI components
def mainMVC
def newIssueDialogMVC
// data owned by this panel
String id
@Bindable Project rootProject
@Bindable Project popupProject = null
@Bindable Project selectedProject = null
@Bindable Issue popupIssue = null
// cache the ListModels
def projectListModels = [:]
@Bindable Project popupProject = null
@Bindable Project selectedProject = null
@Bindable Issue popupIssue = null
// filter for projects and issues
Filter filter
def newIssueDialogMVC
String id
def issueCellRenderer
// local filter for projects and issues
Filter filter
}

View File

@ -15,8 +15,7 @@ dialog = dialog(title: 'New Task...', modal: true, pack: true,
insets: [5, 5, 0, 5], fill: GBC.HORIZONTAL))
titleTextField = textField(
constraints: gbc(gridx: 0, gridy: 1, gridwidth: 3,
insets: [0, 10, 0, 5], fill: GBC.HORIZONTAL),
keyTyped: { model.text = titleTextField.text })
insets: [0, 10, 0, 5], fill: GBC.HORIZONTAL))
label('Category:',
constraints: gbc(gridx: 0, gridy: 2, insets: [5, 5, 0, 0],
@ -26,7 +25,7 @@ dialog = dialog(title: 'New Task...', modal: true, pack: true,
fill: GBC.HORIZONTAL),
model: new DefaultComboBoxModel(Category.values()),
editable: false,
itemStateChanged: { model.category = categoryComboBox.selectedValue })
itemStateChanged: { model.category = categoryComboBox.selectedItem })
label('Status:',
constraints: gbc(gridx: 0, gridy: 3, insets: [5, 5, 0, 0],
@ -36,7 +35,7 @@ dialog = dialog(title: 'New Task...', modal: true, pack: true,
fill: GBC.HORIZONTAL),
model: new DefaultComboBoxModel(Status.values()),
editable: false,
itemStateChanged: { model.status = statusComboBox.selectedValue })
itemStateChanged: { model.status = statusComboBox.selectedItem })
label('Priority (0-9, 0 is highest priority):',
constraints: gbc(gridx: 0, gridy: 4, insets: [5, 5, 0, 0],
@ -56,6 +55,7 @@ dialog = dialog(title: 'New Task...', modal: true, pack: true,
anchor: GBC.EAST))
button('Create Issue',
actionPerformed: {
model.text = titleTextField.text
model.accept = true
dialog.visible = false
},

View File

@ -26,6 +26,13 @@ actions {
closure: controller.openProject
)
action(
id: 'closeProject',
name: 'Close',
enabled: bind { projectPanelMVCs.size() > 0 },
closure: controller.closeProject
)
action(
id: 'shutdown',
name: 'Exit',
@ -62,6 +69,8 @@ frame = application(title:'Personal Issue Tracker',
menuBar() {
menu("File") {
menuItem(openProject)
menuItem(closeProject)
separator()
menuItem(shutdown)
}

View File

@ -37,7 +37,7 @@ actions {
id: 'deleteProject',
name: 'Delete Project',
closure: controller.deleteProject,
enabled: bind {model.selectedProject != null }
enabled: bind { model.selectedProject != null }
)
action (
@ -47,6 +47,7 @@ actions {
closure: controller.deleteProject,
enabled: bind { model.popupProject != null }
)
action (
id: 'deleteIssue',
name: 'Delete Issue',
@ -75,7 +76,7 @@ issuePopupMenu = popupMenu() {
menuItem(deleteIssuePop)
separator()
menu('Change Category') {
menu('Change Category', enabled: bind { model.popupIssue != null }) {
Category.values().each { category ->
menuItem(category.toString(),
icon: model.mainMVC.model.categoryIcons[(category)],
@ -88,7 +89,7 @@ issuePopupMenu = popupMenu() {
}
}
menu('Change Status') {
menu('Change Status', enabled: bind { model.popupIssue != null }) {
Status.values().each { status ->
menuItem(status.toString(),
icon: model.mainMVC.model.statusIcons[(status)],
@ -122,6 +123,7 @@ issuePopupMenu = popupMenu() {
// main split view
panel = splitPane(orientation: JSplitPane.HORIZONTAL_SPLIT,
// dividerLocation: bind(source: model.mainModel, property: dividerLocation),
oneTouchExpandable: true,
constraints: gbc(fill: GBC.BOTH, insets: [10,10,10,10],
weightx: 2, weighty: 2)) {
@ -161,9 +163,6 @@ panel = splitPane(orientation: JSplitPane.HORIZONTAL_SPLIT,
evt.x, evt.y)
}
})
projectTree.model = new DefaultTreeModel(
new DefaultMutableTreeNode())
projectTree.rootVisible = false
projectTree.selectionModel.selectionMode =
TreeSelectionModel.SINGLE_TREE_SELECTION
@ -217,6 +216,7 @@ panel = splitPane(orientation: JSplitPane.HORIZONTAL_SPLIT,
sourceValue: { issueList.selectedValue != null }))
}
scrollPane(constraints: "bottom") {
issueTextArea = textArea(
wrapStyleWord: true,