Tools__ToDoListBrowser.st
author Claus Gittinger <cg@exept.de>
Mon, 23 Oct 2006 10:57:41 +0200
changeset 7443 a917d853cc8f
child 7454 f28b45142694
permissions -rw-r--r--
initial checkin

"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

ApplicationModel subclass:#ToDoListBrowser
	instanceVariableNames:'toDoList selectionIndexHolder'
	classVariableNames:'TheOneAndOnlyToDoListBrowser'
	poolDictionaries:''
	category:'Interface-Smalltalk-ToDo'
!

!ToDoListBrowser class methodsFor:'documentation'!

documentation
"
    documentation to be added.

    [author:]
        cg (cg@FUSI)

    [instance variables:]

    [class variables:]

    [see also:]

"
!

examples
"
  Starting the application:
                                                                [exBegin]
    ToDoListBrowser open

                                                                [exEnd]

  more examples to be added:
                                                                [exBegin]
    ... add code fragment for 
    ... executable example here ...
                                                                [exEnd]
"
!

history
    "Created: / 21-10-2006 / 15:05:53 / cg"
! !

!ToDoListBrowser class methodsFor:'class initialization'!

current
    ^ TheOneAndOnlyToDoListBrowser

    "Created: / 21-10-2006 / 20:37:48 / cg"
!

current:aBrowser
    TheOneAndOnlyToDoListBrowser := aBrowser.

    "Created: / 21-10-2006 / 20:38:08 / cg"
!

new
    |b|

    b := super new.
    TheOneAndOnlyToDoListBrowser isNil ifTrue:[
        TheOneAndOnlyToDoListBrowser := b.
    ].
    ^ b

    "Created: / 21-10-2006 / 20:39:03 / cg"
! !

!ToDoListBrowser class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:ToDoListBrowser andSelector:#windowSpec
     ToDoListBrowser new openInterface:#windowSpec
     ToDoListBrowser open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'ToDoListBrowser'
          name: 'ToDoListBrowser'
          min: (Point 10 10)
          max: (Point 1024 768)
          bounds: (Rectangle 0 0 577 395)
          menu: mainMenu
        )
        component: 
       (SpecCollection
          collection: (
           (DataSetSpec
              name: 'Table1'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
              model: selectionIndexHolder
              menu: itemMenu
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
              dataList: toDoList
              doubleClickSelector: itemDoubleClicked:
              columnHolder: tableColumns
            )
           )
         
        )
      )
! !

!ToDoListBrowser class methodsFor:'menu specs'!

itemMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:ToDoListBrowser andSelector:#itemMenu
     (Menu new fromLiteralArrayEncoding:(ToDoListBrowser itemMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'Browse'
            itemValue: browseItem
            translateLabel: true
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Remove'
            itemValue: removeItem
            translateLabel: true
          )
         )
        nil
        nil
      )
!

mainMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:ToDoListBrowser andSelector:#mainMenu
     (Menu new fromLiteralArrayEncoding:(ToDoListBrowser mainMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'File'
            translateLabel: true
            submenu: 
           (Menu
              (
               (MenuItem
                  label: 'Exit'
                  itemValue: closeRequest
                  translateLabel: true
                )
               )
              nil
              nil
            )
          )
         (MenuItem
            label: 'List'
            translateLabel: true
            submenu: 
           (Menu
              (
               (MenuItem
                  label: 'Clear'
                  itemValue: clearList
                  translateLabel: true
                )
               )
              nil
              nil
            )
          )
         (MenuItem
            label: 'Help'
            translateLabel: true
            startGroup: right
            submenu: 
           (Menu
              (
               (MenuItem
                  label: 'Documentation'
                  itemValue: openDocumentation
                  translateLabel: true
                )
               (MenuItem
                  label: '-'
                )
               (MenuItem
                  label: 'About this Application...'
                  itemValue: openAboutThisApplication
                  translateLabel: true
                )
               )
              nil
              nil
            )
          )
         )
        nil
        nil
      )
! !

!ToDoListBrowser class methodsFor:'tableColumns specs'!

tableColumns
    "This resource specification was automatically generated
     by the DataSetBuilder of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the DataSetBuilder may not be able to read the specification."

    "
     DataSetBuilder new openOnClass:ToDoListBrowser andSelector:#tableColumns
    "

    <resource: #tableColumns>

    ^#(
      (DataSetColumnSpec
         label: 'Type'
         labelButtonType: Button
         width: 32
         model: severity
         canSelect: false
       )
      (DataSetColumnSpec
         label: 'Prio'
         labelButtonType: Button
         width: 30
         model: priority
         canSelect: false
       )
      (DataSetColumnSpec
         label: 'Time'
         labelButtonType: Button
         width: 50
         model: time
         canSelect: false
       )
      (DataSetColumnSpec
         label: 'Where'
         labelButtonType: Button
         model: methodOrClassName
         canSelect: false
       )
      (DataSetColumnSpec
         label: 'Message'
         labelButtonType: Button
         model: message
         canSelect: false
       )
      )
    
! !

!ToDoListBrowser methodsFor:'accessing'!

addEntry:anEntry
    self toDoList add:anEntry

    "Created: / 21-10-2006 / 15:38:08 / cg"
    "Modified: / 21-10-2006 / 21:14:31 / cg"
!

selectionIndexHolder
    selectionIndexHolder isNil ifTrue:[
        selectionIndexHolder := nil asValue.
    ].
    ^ selectionIndexHolder

    "Created: / 22-10-2006 / 02:00:41 / cg"
!

toDoList
    toDoList isNil ifTrue:[
        toDoList := ToDoList theOneAndOnlyToDoList.
    ].
    ^ toDoList

    "Created: / 21-10-2006 / 20:57:18 / cg"
! !

!ToDoListBrowser methodsFor:'initialization & release'!

closeDownViews
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is really closed.
     See also #closeDownViews, which is invoked before and may suppress the close
     or ask the user for confirmation."

    "/ change the code below as required ...
    "/ This should cleanup any leftover resources
    "/ (for example, temporary files)
    "/ super closeRequest will initiate the closeDown

    "/ add your code here

    "/ do not remove the one below ...
    ^ super closeDownViews
!

closeRequest
    "This is a hook method generated by the Browser.
     It will be invoked when your app/dialog-window is about to be
     closed (this method has a chance to suppress the close).
     See also #closeDownViews, which is invoked when the close is really done."

    "/ change the code below as required ...
    "/ Closing can be suppressed, by simply returning.
    "/ The 'super closeRequest' at the end will initiate the real closeDown

    ("self hasUnsavedChanges" false) ifTrue:[
        (self confirm:(resources string:'Close without saving ?')) ifFalse:[
            ^ self
        ]
    ].

    ^ super closeRequest

    "Modified: / 21-10-2006 / 19:21:02 / cg"
!

postBuildWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked during the initialization of your app/dialog,
     after all of the visual components have been built, 
     but BEFORE the top window is made visible.
     Add any app-specific actions here (reading files, setting up values etc.)
     See also #postOpenWith:, which is invoked after opening."

    "/ add any code here ...

    ^ super postBuildWith:aBuilder
!

postOpenWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked right after the applications window has been opened.
     Add any app-specific actions here (starting background processes etc.).
     See also #postBuildWith:, which is invoked before opening."

    "/ add any code here ...

    ^ super postOpenWith:aBuilder
!

release
    self == TheOneAndOnlyToDoListBrowser ifTrue:[
        TheOneAndOnlyToDoListBrowser := nil
    ].
    super release.

    "Created: / 21-10-2006 / 20:40:31 / cg"
! !

!ToDoListBrowser methodsFor:'menu actions'!

clearList
    toDoList removeAll

    "Created: / 22-10-2006 / 00:02:15 / cg"
!

menuSave
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'save' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''save'' defined.'.
!

menuSaveAs
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'saveAs' is selected."

    "/ change below and add any actions as required here ...
    self warn:'no action for ''saveAs'' defined.'.
!

openAboutThisApplication
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'help-about' is selected."

    "/ could open a customized aboutBox here ...
    super openAboutThisApplication
!

openDocumentation
    "This method was generated by the Browser.
     It will be invoked when the menu-item 'help-documentation' is selected."

    "/ change below as required ...

    "/ to open an HTML viewer on some document (under 'doc/online/<language>/' ):
    HTMLDocumentView openFullOnDocumentationFile:'TOP.html'.

    "/ add application-specific help files under the 'doc/online/<language>/help/appName'
    "/ directory, and open a viewer with:
    "/ HTMLDocumentView openFullOnDocumentationFile:'help/<MyApplication>/TOP.html'.
! !

!ToDoListBrowser methodsFor:'menu actions-item'!

browseItem
    (toDoList at:self selectionIndexHolder value) browse

    "Created: / 22-10-2006 / 02:00:20 / cg"
!

removeItem
    (toDoList removeIndex:self selectionIndexHolder value)

    "Created: / 22-10-2006 / 10:45:52 / cg"
! !

!ToDoListBrowser methodsFor:'user actions'!

itemDoubleClicked:itemIndex
    (toDoList at:itemIndex) browse

    "Created: / 22-10-2006 / 01:49:13 / cg"
! !

!ToDoListBrowser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/Tools__ToDoListBrowser.st,v 1.1 2006-10-23 08:57:41 cg Exp $'
! !