]> gitweb @ CieloNegro.org - task-reporter.git/commitdiff
wip
authorPHO <pho@cielonegro.org>
Sun, 5 Oct 2014 13:45:17 +0000 (22:45 +0900)
committerPHO <pho@cielonegro.org>
Sun, 5 Oct 2014 13:45:17 +0000 (22:45 +0900)
src/main/scala/jp/ymir/taskReporter/core/Report.scala
src/main/scala/jp/ymir/taskReporter/core/ReportSet.scala
src/main/scala/jp/ymir/taskReporter/core/Task.scala
src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala

index 54942607e052fbf6dc44c7bac7ddbe739098abba..ef9a437e75008bb5fee7de188c8439f757938a7f 100644 (file)
@@ -1,11 +1,15 @@
 package jp.ymir.taskReporter.core
-import java.util.Calendar
 import java.text.SimpleDateFormat
+import java.util.Calendar
+import java.util.GregorianCalendar
+import javax.swing.table.AbstractTableModel
 import scala.collection.immutable._
 
-class Report(private val _date: Calendar) {
+class Report(private val _date: Calendar) extends AbstractTableModel {
   private var _tasks : Seq[Task] = Vector()
 
+  def this() = this(new GregorianCalendar())
+
   def date : Calendar = _date
   def size : Int      = _tasks.size
 
@@ -14,8 +18,37 @@ class Report(private val _date: Calendar) {
     _tasks = _tasks :+ task
   }
 
-  def dateString : String = {
+  def dateString : String = dateString(_date)
+  def dateString(date: Calendar) : String = {
     val fmt = new SimpleDateFormat("yyyy-MM-dd")
-    fmt.format(_date.getTime)
+    fmt.format(date.getTime)
+  }
+
+  /* Method definitions for AbstractTableModel
+   */
+  def getColumnCount = 6
+  def getRowCount    = _tasks.size
+
+  override def getColumnName(column: Int) : String = {
+    column match {
+      case 0 => "チケットID"
+      case 1 => "作業名"
+      case 2 => "仮期限"
+      case 3 => "期限"
+      case 4 => "状態"
+      case 5 => "補足"
+    }
+  }
+
+  def getValueAt(row: Int, column: Int) : Object = {
+    val task = _tasks(row)
+    column match {
+      case 0 => task.ticketID : Integer
+      case 1 => task.title
+      case 2 => task.tentativeDeadline.map(dateString).getOrElse("")
+      case 3 => task.deadline         .map(dateString).getOrElse("")
+      case 4 => task.status
+      case 5 => task.supplement
+    }
   }
 }
index f90071dd1c65a74b584eda74969aa176bac8724e..b27af43a376f14dfaf528e6891af6785b99763b6 100644 (file)
@@ -1,5 +1,6 @@
 package jp.ymir.taskReporter.core
 import java.io._
+import java.text.SimpleDateFormat
 import java.util.Calendar
 import javax.swing.table.AbstractTableModel
 import jp.ymir.taskReporter.core._
index ebc869385de41335797d1b6eabc34ee6f22d7c29..7b38e0a8013f8ddbecf77d0b1e64c87642d2b7a6 100644 (file)
@@ -10,7 +10,7 @@ class Task(tsvLine: String) {
     case object DoingFine extends Status
     case object Lagging extends Status
     case object WillDelay extends Status
-    case object DeadlinePostponed extends Status
+    case object DeadlineChanged extends Status
     case object Completed extends Status
   }
 
@@ -24,7 +24,7 @@ class Task(tsvLine: String) {
     throw new InvalidNumberOfColumnsException(tsvLine)
   }
 
-  val date : Calendar = {
+  var date : Calendar = {
     val pattern = """^(?:報告日:)?(\d{4})/(\d{2})/(\d{2})$""".r
     cols(0) match {
       case pattern(year, month, day) =>
@@ -32,16 +32,58 @@ class Task(tsvLine: String) {
     }
   }
 
-  val ticketID : Int = {
+  var ticketID : Int = {
     val pattern = """^(?:チケットID:)?(\d+)$""".r
     cols(1) match {
       case pattern(id) => id.toInt
     }
   }
 
-  val title : String = {
+  var title : String = {
     val pattern = """^(?:作業名:)?(.*)$""".r
-    cols(1) match {
+    cols(2) match {
+      case pattern(title) => title
+    }
+  }
+
+  var tentativeDeadline : Option[Calendar] = {
+    val pattern = """^(?:仮期限:)?(\d{4})/(\d{2})/(\d{2})$""".r
+    cols(3) match {
+      case pattern(year, month, day) =>
+        Some(new GregorianCalendar(year.toInt, month.toInt, day.toInt))
+      case _ =>
+        None
+    }
+  }
+
+  var deadline : Option[Calendar] = {
+    val pattern = """^(?:期限:)?(\d{4})/(\d{2})/(\d{2})$""".r
+    cols(4) match {
+      case pattern(year, month, day) =>
+        Some(new GregorianCalendar(year.toInt, month.toInt, day.toInt))
+      case _ =>
+        None
+    }
+  }
+
+  var status : Status = {
+    val pattern = """^(?:状態:)?(.+)$""".r
+    cols(5) match {
+      case pattern(s) =>
+        s match {
+          case "未作業"   => Status.NoProgress
+          case "順調"     => Status.DoingFine
+          case "悪化"     => Status.Lagging
+          case "遅延"     => Status.WillDelay
+          case "期限変更" => Status.DeadlineChanged
+          case "完了"     => Status.Completed
+        }
+    }
+  }
+
+  var supplement : String = {
+    val pattern = """^(?:補足:)?(.*)$""".r
+    cols(6) match {
       case pattern(title) => title
     }
   }
index 94897af964a7dd3920c1286603d7eca46034705f..1807a064d3535292c20dee4fb8493d57b2492022 100644 (file)
@@ -44,6 +44,7 @@ class MainFrame(reportFile: Option[File]) extends Frame {
           if (r == FileChooser.Result.Approve) {
             Preferences.lastChosenDir() = chooser.selectedFile.getParentFile
             reportSet.load(chooser.selectedFile)
+            // FIXME: select the last report
           }
         }
       })
@@ -78,26 +79,53 @@ class MainFrame(reportFile: Option[File]) extends Frame {
     }
   }
 
-  val rootSplit = new SplitPane {
+  contents = new SplitPane {
     peer.setOrientation(JSplitPane.HORIZONTAL_SPLIT)
     continuousLayout   = true
     oneTouchExpandable = true
-    resizeWeight       = 0.3
+    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 {
       border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
 
-      val scroll = new ScrollPane(
+      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(scroll) = BorderPanel.Position.Center
+      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(buttons) = BorderPanel.Position.South
+
+      preferredSize = minimumSize
     }
   }
-  contents = rootSplit
-
-  // This can only be done after putting the pane on the frame.
-  rootSplit.dividerLocation = 0.3
 
   centerOnScreen
   visible = true