+package jp.ymir.taskReporter.ui
+import com.toedter.calendar._
+import java.beans.PropertyChangeEvent
+import java.beans.PropertyChangeListener
+import java.util.Calendar
+import java.util.Date
+import scala.swing._
+import scala.swing.event._
+
+class DateChooser extends Component {
+ override lazy val peer = new JDateChooser()
+
+ case class DateChanged(from: Option[Date], to: Option[Date]) extends Event
+
+ peer.addPropertyChangeListener("date", new PropertyChangeListener {
+ def propertyChange(e: PropertyChangeEvent) {
+ if (e.getPropertyName == "date") {
+ publish(
+ DateChanged(
+ from = Option(e.getOldValue.asInstanceOf[Date]),
+ to = Option(e.getNewValue.asInstanceOf[Date])))
+ }
+ }
+ })
+
+ def calendar: Option[Calendar] = peer.getCalendar match {
+ case null => None
+ case cal => Some(cal)
+ }
+ def calendar_=(cal: Option[Calendar])
+ = peer.setCalendar(cal.getOrElse(null))
+
+ def calendarChooser: CalendarChooser = new CalendarChooser(peer.getJCalendar)
+
+ def dateFormatString: String = peer.getDateFormatString
+ def dateFormatString_=(fmt: String) = peer.setDateFormatString(fmt)
+}