Serious bug-fixing, yo.
This commit is contained in:
@ -13,6 +13,8 @@ class PITController {
|
||||
|
||||
void mvcGroupInit(Map args) {
|
||||
|
||||
model.newIssueDialogMVC = buildMVCGroup('NewIssueDialog')
|
||||
|
||||
SwingUtilities.invokeAndWait {
|
||||
model.issueListRenderer = new IssueTableCellRenderer()
|
||||
|
||||
@ -27,27 +29,27 @@ class PITController {
|
||||
|
||||
// look for general config options
|
||||
pitrcFile = new File(pitHome, 'pitrc')
|
||||
if(logDbg) logger.debug("$pitrcFile is " +
|
||||
if (logDbg) logger.debug("$pitrcFile is " +
|
||||
(pitrcFile.exists() ? '' : 'not ') + "present.")
|
||||
|
||||
// load general config (if present)
|
||||
if (pitrcFile.exists()) {
|
||||
pitrcFile.withInputStream() { config.load(it) }
|
||||
if (pitrcFile.exists() && pitrcFile.canRead()) {
|
||||
pitrcFile.withInputStream { config.load(it) }
|
||||
if (logDbg) logger.debug("Loaded pitrc")
|
||||
}
|
||||
|
||||
// look for swing specific config
|
||||
pitswingrcFile = new File(pitHome, 'pitswingrc')
|
||||
if (logDbg) logger.debug("$pitswingrcFile is " +
|
||||
(pitswingrcFile.exists() ? '' : 'not ') + "present.")
|
||||
if (logDbg) logger.debug("$pitswingrcFile is " +
|
||||
(pitswingrcFile.exists() ? '' : 'not ') + "present.")
|
||||
|
||||
// load swing specific config (if present)
|
||||
if (pitswingrcFile.exists()) {
|
||||
pitswingrcFile.withInputStream() { config.load(it) }
|
||||
if(logDbg) logger.debug("Loaded pitswingrc")
|
||||
if (pitswingrcFile.exists() && pitswingrcFile.canRead()) {
|
||||
pitswingrcFile.withInputStream { config.load(it) }
|
||||
if (logDbg) logger.debug("Loaded pitswingrc")
|
||||
}
|
||||
|
||||
// Process Configurable Options
|
||||
// Process configurable options
|
||||
// ----------------------------
|
||||
|
||||
if (logDbg) {
|
||||
@ -59,15 +61,16 @@ class PITController {
|
||||
Category.values().each { category ->
|
||||
def expectedKey = "issue." + category.name().toLowerCase() +
|
||||
".template"
|
||||
if(logDbg) logger.debug("Looking for key: $expectedKey")
|
||||
if (logDbg) logger.debug("Looking for key: $expectedKey")
|
||||
|
||||
config.keySet().each { currentKey ->
|
||||
if (currentKey == expectedKey)
|
||||
model.templates[(category)] =
|
||||
config.getProperty(expectedKey, "")
|
||||
if (currentKey == expectedKey)
|
||||
model.templates[(category)] =
|
||||
config.getProperty(expectedKey, "")
|
||||
if (logDbg) logger.debug("Template for category $category: '" +
|
||||
model.templates[(category)] + "'")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// load custom issueListRenderer
|
||||
@ -76,12 +79,12 @@ class PITController {
|
||||
// load initial repositories
|
||||
if (config.containsKey('initial-repositories')) {
|
||||
def initRepos = config.getProperty('initial-repositories', '')
|
||||
initRepos = initRepos.split(/[;:,]/)
|
||||
initRepos = initRepos.split(/[:;,]/)
|
||||
initRepos.each { repoPath -> loadProject(new File(repoPath)) }
|
||||
if(logDbg) logger.debug("Init repos: '$initRepos'")
|
||||
if (logDbg) logger.debug("Init repos: '$initRepos'")
|
||||
}
|
||||
|
||||
// load custom issue CSS
|
||||
// load custom issue css
|
||||
if (config.containsKey('issue.display.css')) {
|
||||
def issueCSS = config.getProperty('issue.display.css', "")
|
||||
|
||||
@ -89,20 +92,16 @@ class PITController {
|
||||
def cssFile
|
||||
|
||||
// use short-circuit logic to test several possible locations
|
||||
// for a css file
|
||||
if ((cssFile = new File(pitHome, issueCSS)).exists() ||
|
||||
(cssFile = new File(pitHome.parentFile(), issueCSS)).exists() ||
|
||||
(cssFile = new File(issueCSS).exists()))
|
||||
(cssFile = new File(issueCSS)).exists())
|
||||
issueCSS = cssFile.text
|
||||
|
||||
if (logDbg) logger.debug("CS for issue display: $issueCSS")
|
||||
|
||||
if (logDbg) logger.debug("CSS for issue display: $issueCSS")
|
||||
model.issueCSS = issueCSS
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
model.newIssueDialogMVC = buildMVCGroup('NewIssueDialog')
|
||||
}
|
||||
|
||||
void refreshIssues() {
|
||||
@ -111,12 +110,11 @@ class PITController {
|
||||
}
|
||||
}
|
||||
|
||||
def openProject = { evt = null ->
|
||||
def openProject = { evt = null ->
|
||||
if (view.openDialog.showOpenDialog(view.frame) !=
|
||||
JFileChooser.APPROVE_OPTION) return
|
||||
JFileChooser.APPROVE_OPTIONS) return
|
||||
|
||||
loadProject(view.openDialog.selectedFile)
|
||||
|
||||
}
|
||||
|
||||
def loadProject = { File projectDir ->
|
||||
@ -124,7 +122,7 @@ class PITController {
|
||||
|
||||
// if this is not a valid directory, do nothing
|
||||
// TODO: log to the user that this is not a valid directory
|
||||
if (!projectDir.exists() || !projectDir.isDirectory()) return;
|
||||
if (!projectDir.exists() || !projectDir.isDirectory()) return
|
||||
|
||||
// create new ProjectPanel MVC
|
||||
newMVC = buildMVCGroup('ProjectPanel',
|
||||
@ -134,28 +132,30 @@ class PITController {
|
||||
issueCSS: model.issueCSS,
|
||||
rootProject: new FileProject(projectDir))
|
||||
newMVC.model.id = projectDir.name
|
||||
|
||||
|
||||
// if we already have a tab with this id
|
||||
if (model.projectPanelMVCs[(newMVC.model.id)]) {
|
||||
|
||||
// try using the canonical path
|
||||
newMVC.model.id = projectDir.canonicalPath
|
||||
|
||||
// still not unique?
|
||||
if (model.projectPanelMVCs[(newMVC.model.id)]) {
|
||||
|
||||
|
||||
// first time this has happened?
|
||||
if (!model.projectIdMap[(newMVC.model.id)])
|
||||
if (!model.projectIdMap[(newMVC.model.id)])
|
||||
model.projectIdMap[(newMVC.model.id)] = 0
|
||||
|
||||
// no? increment
|
||||
else model.projectIdMap[(newMVC.model.id)] =
|
||||
else model.projectIdMap[(newMVC.model.id)] =
|
||||
model.projectIdMap[(newMVC.model.id)] + 1
|
||||
|
||||
// use our new, unique id
|
||||
newMVC.model.id += "-" + model.projectIdMap[(newMVC.model.id)]
|
||||
newMVC.model.id += "-" + model.projectIdMap[(newMVC.model.id)]
|
||||
}
|
||||
}
|
||||
|
||||
model.projectPanelMVCs[newMVC.model.id] = newMVC
|
||||
model.projectPanelMVCs[(newMVC.model.id)] = newMVC
|
||||
view.mainTabbedPane.addTab(newMVC.model.id, newMVC.view.panel)
|
||||
}
|
||||
|
||||
|
@ -34,17 +34,18 @@ class ProjectPanelController {
|
||||
refreshProject()
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* displayProject
|
||||
* @param project Project to display.
|
||||
*
|
||||
* @param project Project to display
|
||||
*/
|
||||
void displayProject(Project project) {
|
||||
view.issueTextArea.text = ""
|
||||
view.issueTextDisplay.text = ""
|
||||
view.issueTextPanelLayout.show(view.issueTextPanel, "display")
|
||||
void displayProject(Project project) {
|
||||
if (!project) return
|
||||
|
||||
view.issueTextArea.text = ""
|
||||
view.issueTextDisplay.text = ""
|
||||
view.issueTextPanelLayout.show(view.issueTextPanel, 'display')
|
||||
|
||||
// build a new IssueTableModel if none cached
|
||||
if (!model.projectTableModels[(project.name)]) {
|
||||
def itm = new IssueTableModel(project,
|
||||
model.filter ?: model.mainMVC.model.filter)
|
||||
@ -67,7 +68,7 @@ class ProjectPanelController {
|
||||
if (!issue) return
|
||||
|
||||
// hack because binding view.issueTextArea.font to
|
||||
// mainMVC.mode.issueDetailFont causes problems
|
||||
// mainMVC.model.issueDetailFont causes problems
|
||||
if (view.issueTextArea.font != model.mainMVC.model.issueDetailFont)
|
||||
view.issueTextArea.font = model.mainMVC.model.issueDetailFont
|
||||
|
||||
@ -75,10 +76,10 @@ class ProjectPanelController {
|
||||
view.issueTextArea.caretPosition = 0
|
||||
view.issueTextDisplay.text = rst2html(issue.text)
|
||||
view.issueTextDisplay.caretPosition = 0
|
||||
view.issueTextPanelLayout.show(view.issueTextPanel, "display")
|
||||
view.issueTextPanelLayout.show(view.issueTextPanel, 'display')
|
||||
}
|
||||
|
||||
void showProjectPopup(Project project, def x, def y) {
|
||||
void showProejctPopup(Project project, def x, def y) {
|
||||
model.popupProject = project
|
||||
view.projectPopupMenu.show(view.projectTree, x, y)
|
||||
}
|
||||
@ -120,7 +121,7 @@ class ProjectPanelController {
|
||||
|
||||
def project
|
||||
|
||||
if (evt.source == view.newProjectButton)
|
||||
if (evt.source == view.newProjectButton)
|
||||
project = model.selectedProject ?: model.rootProject
|
||||
else project = model.popupProject ?: model.rootProject
|
||||
def newProject = project.createNewProject(name)
|
||||
@ -134,7 +135,7 @@ class ProjectPanelController {
|
||||
|
||||
if (evt.source == view.deleteProjectButton)
|
||||
project = model.selectedProject ?: model.rootProject
|
||||
else project = model.popupProject ?: model.rootModel
|
||||
else project = model.popupProject ?: model.rootProject
|
||||
|
||||
project.delete()
|
||||
|
||||
@ -185,7 +186,7 @@ class ProjectPanelController {
|
||||
}
|
||||
|
||||
String rst2html(String rst) {
|
||||
Document doc // memory model of document
|
||||
Document doc
|
||||
StringWriter outString
|
||||
StringBuilder result = new StringBuilder()
|
||||
|
||||
@ -201,19 +202,18 @@ class ProjectPanelController {
|
||||
|
||||
// java's embeded html is primitive, we need to massage the results
|
||||
outString.toString().eachLine { line ->
|
||||
|
||||
// remove the XML version and encoding, title element,
|
||||
// meta elements
|
||||
|
||||
// remove the XML version and encoding, title element, meta elems
|
||||
if (line =~ /<\?.*\?>/ || line =~ /<meta.*$/ || line =~ /<title.*$/) { return }
|
||||
|
||||
// all other elements, remove all class,xmlns attributes
|
||||
// all other elements, remove all class, xmlns attributes
|
||||
def m = (line =~ /(<\S+)(\s*(class|xmlns)=".*"\s*)*(\/?>.*)/)
|
||||
if (m) line = m[0][1] + m[0][4]
|
||||
|
||||
result.append(line)
|
||||
|
||||
|
||||
// add in the CSS information to the head
|
||||
if (line =~/<head>/) result.append('<style type="text/css">' +
|
||||
if (line =~ /<head>/) result.append('<style type="text/css">' +
|
||||
model.issueCSS + '</style>')
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user