X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=src%2Fmain%2Fscala%2Fjp%2Fymir%2FtaskReporter%2Fui%2FMainFrame.scala;h=1807a064d3535292c20dee4fb8493d57b2492022;hb=100ec0110d33876011bbd191da7e614445b627a5;hp=4e7edbf578613c230a31676af9b46b7f9e110493;hpb=f15de07f6b5b7439132def85ae2e86c38edc0289;p=task-reporter.git diff --git a/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala b/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala index 4e7edbf..1807a06 100644 --- a/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala +++ b/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala @@ -3,6 +3,7 @@ import java.awt.Dimension import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent import java.io._ +import javax.swing.BorderFactory import javax.swing.JOptionPane import javax.swing.JSplitPane import javax.swing.KeyStroke @@ -15,12 +16,10 @@ import scala.swing._ import scala.swing.event._ class MainFrame(reportFile: Option[File]) extends Frame { - private var reportSet = new ReportSet(reportFile) + private val reportSet = new ReportSet(reportFile) - title = "Task Reporter " + Main.getVersion - - size = Preferences.mainFrameSize() - centerOnScreen + title = "Task Reporter " + Main.getVersion + preferredSize = Preferences.mainFrameSize() peer.addComponentListener(new ComponentAdapter() { override def componentResized(e: ComponentEvent) { @@ -44,7 +43,8 @@ class MainFrame(reportFile: Option[File]) extends Frame { val r = chooser.showOpenDialog(null) if (r == FileChooser.Result.Approve) { Preferences.lastChosenDir() = chooser.selectedFile.getParentFile - reportSet = new ReportSet(Some(chooser.selectedFile)) + reportSet.load(chooser.selectedFile) + // FIXME: select the last report } } }) @@ -81,26 +81,53 @@ class MainFrame(reportFile: Option[File]) extends Frame { contents = new SplitPane { peer.setOrientation(JSplitPane.HORIZONTAL_SPLIT) - resizeWeight = 0.3 + continuousLayout = true + oneTouchExpandable = true + resizeWeight = 0 // Let the left pane be fixed + + rightComponent = new SplitPane { + peer.setOrientation(JSplitPane.VERTICAL_SPLIT) + continuousLayout = true + oneTouchExpandable = true + resizeWeight = 0.5 + + leftComponent = new ScrollPane( + new Table() { + peer.setModel(new Report()) // Empty report + }) + } leftComponent = new BorderPanel { - val title = new Label("Report date") { - horizontalAlignment = Alignment.Leading - } - layout(title) = BorderPanel.Position.North - - val scroll = new ScrollPane { - horizontalScrollBarPolicy = ScrollPane.BarPolicy.Never - verticalScrollBarPolicy = ScrollPane.BarPolicy.Always - contents = new ListView[String] { - // FIXME - // listData = - } + border = BorderFactory.createEmptyBorder(5, 5, 5, 5) + + val reportsScroll = new ScrollPane( + new Table() { + peer.setModel(reportSet) + if (rowCount > 0) { + selection.rows += rowCount - 1 // Select the last report + } + selection.reactions += { + case TableRowsSelected(_, _, false) => + // FIXME + } + }) + layout(reportsScroll) = BorderPanel.Position.Center + + val buttons = new FlowPanel(FlowPanel.Alignment.Left)() { + contents += new Button(new Action("Add") { + def apply = {} // FIXME + }) + contents += new Button(new Action("Delete...") { + def apply = {} // FIXME + }) } - layout(scroll) = BorderPanel.Position.Center + layout(buttons) = BorderPanel.Position.South + + preferredSize = minimumSize } } + centerOnScreen visible = true override def closeOperation { @@ -150,9 +177,10 @@ class MainFrame(reportFile: Option[File]) extends Frame { } Preferences.lastChosenDir() = chooser.selectedFile.getParentFile - reportSet.file = Some(chooser.selectedFile) + reportSet.save(chooser.selectedFile) + } + else { + reportSet.save } - - reportSet.save } }