]> gitweb @ CieloNegro.org - task-reporter.git/blob - src/main/scala/jp/ymir/taskReporter/ui/TaskEditor.scala
wip
[task-reporter.git] / src / main / scala / jp / ymir / taskReporter / ui / TaskEditor.scala
1 package jp.ymir.taskReporter.ui
2 import com.toedter.calendar._
3 import java.awt.Insets
4 import jp.ymir.taskReporter.core._
5 import scala.swing._
6
7 class TaskEditor extends GridBagPanel {
8   import GridBagPanel.Anchor._
9   import GridBagPanel.Fill._
10
11   private val commonInsets = new Insets(2, 3, 2, 3)
12
13   val date = Component.wrap(new JDateChooser() {
14     setDateFormatString("yyyy-MM-dd")
15     getJCalendar().setTodayButtonVisible(true)
16     getJCalendar().setWeekOfYearVisible(false)
17   })
18   add(
19     new Label("報告日"),
20     new Constraints { gridx = 0; gridy = 0 })
21   add(
22     date,
23     new Constraints() {
24       gridx = 1; gridy = 0; anchor = West
25       ipadx = 3; ipady = 3; insets = commonInsets
26     })
27   date.minimumSize = date.preferredSize
28
29   val ticketID = new TextField(6) {
30     val isDigit = (c : Char) => c >= '0' && c <= '9'
31     inputVerifier = _ => wrapString(text).forall(isDigit)
32     peer.setMargin(commonInsets)
33   }
34   add(
35     new Label("チケットID"),
36     new Constraints { gridx = 0; gridy = 1 })
37   add(
38     ticketID,
39     new Constraints() {
40       gridx = 1; gridy = 1; anchor = West; insets = commonInsets
41     })
42   ticketID.minimumSize = ticketID.preferredSize
43
44   val title = new TextField() {
45     peer.setMargin(commonInsets)
46   }
47   add(
48     new Label("作業名"),
49     new Constraints { gridx = 0; gridy = 2 })
50   add(
51     title,
52     new Constraints() {
53       gridx = 1; gridy = 2; fill = Horizontal; weightx = 1.0
54       insets = commonInsets
55     })
56
57   val expectedCompletionDate = Component.wrap(new JDateChooser() {
58     setDateFormatString("yyyy-MM-dd")
59     getJCalendar().setTodayButtonVisible(true)
60     getJCalendar().setWeekOfYearVisible(false)
61   })
62   add(
63     new Label("作業完了予定年月日"),
64     new Constraints { gridx = 0; gridy = 3 })
65   add(
66     expectedCompletionDate,
67     new Constraints() {
68       gridx = 1; gridy = 3; anchor = West
69       ipadx = 3; ipady = 3; insets = commonInsets
70     })
71   expectedCompletionDate.minimumSize = expectedCompletionDate.preferredSize
72
73   val deadline = Component.wrap(new JDateChooser() {
74     setDateFormatString("yyyy-MM-dd")
75     getJCalendar().setTodayButtonVisible(true)
76     getJCalendar().setNullDateButtonVisible(true)
77     getJCalendar().setWeekOfYearVisible(false)
78   })
79   add(
80     new Label("タスク期限"),
81     new Constraints { gridx = 0; gridy = 4 })
82   add(
83     deadline,
84     new Constraints() {
85       gridx = 1; gridy = 4; anchor = West
86       ipadx = 3; ipady = 3; insets = commonInsets
87     })
88   deadline.minimumSize = deadline.preferredSize
89
90   val status = new ComboBox[Task.Status](Task.Status.all)
91   add(
92     new Label("状態"),
93     new Constraints { gridx = 0; gridy = 5 })
94   add(
95     status,
96     new Constraints {
97       gridx = 1; gridy = 5; anchor = West
98       ipadx = 3; ipady = 3; insets = commonInsets
99     })
100
101   val description = new ScrollPane(new TextArea() {
102     rows = 5
103     peer.setMargin(commonInsets)
104   })
105   add(
106     new Label("説明"),
107     new Constraints { gridx = 0; gridy = 6 })
108   add(
109     description,
110     new Constraints() {
111       gridx = 1; gridy = 6; fill = Horizontal; weightx = 1.0
112       insets = commonInsets
113     })
114   description.minimumSize = description.preferredSize
115 }