Tools__ChangeList.st
branchjv
changeset 12269 79f87eee62e5
parent 12268 cb43ab66c093
child 12271 bc7b5cfd0460
--- a/Tools__ChangeList.st	Thu Jul 26 17:09:41 2012 +0100
+++ b/Tools__ChangeList.st	Thu Jul 26 19:46:57 2012 +0100
@@ -27,8 +27,8 @@
 
 "{ NameSpace: Tools }"
 
-Tools::BrowserListWithFilter subclass:#ChangeList
-	instanceVariableNames:'listHolder showRemovedHolder showSameHolder showColumnSpecHolder
+BrowserListWithFilter subclass:#ChangeList
+	instanceVariableNames:'listHolder showRemovedHolder showSameHolder showTimestampHolder
 		allowRemoveHolder allowAcceptHolder scrollToBottom'
 	classVariableNames:'LastSelectionConditionString'
 	poolDictionaries:''
@@ -140,23 +140,9 @@
         component: 
        (SpecCollection
           collection: (
-           (SelectionInListModelViewSpec
-              name: 'List'
-              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
-              model: selectionHolder
-              menu: menuHolderWithShowFilter
-              hasHorizontalScrollBar: true
-              hasVerticalScrollBar: true
-              listModel: listHolder
-              multipleSelectOk: true
-              useIndex: false
-              highlightMode: line
-              doubleClickSelector: selectionDoubleclicked
-              postBuildCallback: postBuildListView:
-            )
            (InputFieldSpec
               name: 'Filter'
-              layout: (LayoutFrame 0 0 0 0 0 1 26 0)
+              layout: (LayoutFrame 0 0 0 0 0 1 19 0)
               initiallyInvisible: true
               model: filterPatternHolder
               immediateAccept: true
@@ -169,12 +155,138 @@
               useDynamicPreferredHeight: true
               postBuildCallback: postBuildFilterView:
             )
+           (DataSetSpec
+              name: 'List'
+              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+              model: selectionHolder
+              menu: menuHolderWithShowFilter
+              hasHorizontalScrollBar: true
+              hasVerticalScrollBar: true
+              dataList: listHolder
+              useIndex: false
+              doubleClickSelector: selectionDoubleclicked
+              columnHolder: listColumns
+              showLabels: false
+              multipleSelectOk: true
+              postBuildCallback: postBuildListView:
+            )
            )
          
         )
       )
+! !
 
-    "Modified: / 29-11-2011 / 15:52:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!ChangeList class methodsFor:'list specs'!
+
+listColumnSpec
+    "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:Tools::ChangeList andSelector:#listColumnSpec
+    "
+
+    <resource: #tableColumns>
+
+    ^#(
+      (DataSetColumnSpec
+         label: 'Removed'
+         id: 'removed'
+         labelButtonType: Button
+         width: 20
+         minWidth: 20
+         editorType: CheckToggle
+         rendererType: CheckToggle
+         model: notRemoved
+         menuFromApplication: false
+         printSelector: notRemoved
+         isResizeable: false
+         showRowSeparator: false
+         showSelectionHighLighted: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Delta'
+         id: 'delta'
+         labelButtonType: Button
+         width: 20
+         minWidth: 20
+         menuFromApplication: false
+         printSelector: iconDelta
+         canSelect: false
+         isResizeable: false
+         showRowSeparator: false
+         showSelectionHighLighted: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Change'
+         id: change
+         labelAlignment: left
+         labelButtonType: Button
+         model: string
+         menuFromApplication: false
+         canSelect: false
+         showRowSeparator: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Class'
+         id: 'className'
+         labelAlignment: left
+         activeHelpKey: ''
+         activeHelpKeyForLabel: ''
+         labelButtonType: Button
+         usePreferredWidth: true
+         model: className
+         menuFromApplication: false
+         canSelect: false
+         showRowSeparator: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Selector'
+         id: 'selector'
+         labelAlignment: left
+         activeHelpKey: ''
+         activeHelpKeyForLabel: ''
+         labelButtonType: Button
+         usePreferredWidth: true
+         model: selector
+         menuFromApplication: false
+         canSelect: false
+         showRowSeparator: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Category'
+         id: category
+         labelAlignment: left
+         labelButtonType: Button
+         usePreferredWidth: true
+         model: category
+         menuFromApplication: false
+         canSelect: false
+         showRowSeparator: false
+         showColSeparator: false
+       )
+      (DataSetColumnSpec
+         label: 'Time Stamp'
+         id: timeStamp
+         labelAlignment: left
+         labelButtonType: Button
+         usePreferredWidth: true
+         model: timeStamp
+         menuFromApplication: false
+         canSelect: false
+         showRowSeparator: false
+         showColSeparator: false
+       )
+      )
+    
 ! !
 
 !ChangeList class methodsFor:'menu specs'!
@@ -312,21 +424,20 @@
      these can be connected to aspects of an embedding application
      (if this app is embedded in a subCanvas)."
 
-    ^super aspectSelectors , #(
+    ^ #(
         #allowAcceptHolder
         #allowRemoveHolder
-
         #inGeneratorHolder
         #menuHolder
         #outGeneratorHolder
         #selectionHolder
-
+        #showTimestampHolder
+        #showFilterHolder
         #showRemovedHolder
         #showSameHolder
-        #showColumnSpecHolder
       ).
 
-    "Modified: / 03-04-2012 / 11:47:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-07-2012 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ChangeList methodsFor:'accessing'!
@@ -472,6 +583,19 @@
     ].
 !
 
+listColumns
+
+    |holder|
+    (holder := builder bindingAt:#listColumns) isNil ifTrue:[
+        builder aspectAt:#listColumns put:(holder := List new).
+        self listColumnShow: #delta.
+        self listColumnShow: #change.
+    ].
+    ^ holder
+
+    "Created: / 26-07-2012 / 18:03:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 listHolder
     listHolder isNil ifTrue:[
         listHolder := ValueHolder new.
@@ -479,37 +603,6 @@
     ^ listHolder
 !
 
-showColumnSpecHolder
-    "return/create the 'showColumnSpecHolder' value holder (automatically generated)"
-
-    showColumnSpecHolder isNil ifTrue:[
-        showColumnSpecHolder := List with:#timestamp.
-        showColumnSpecHolder addDependent:self.
-    ].
-    ^ showColumnSpecHolder
-
-    "Modified: / 03-04-2012 / 11:49:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-showColumnSpecHolder:something
-    "set the 'showColumnSpecHolder' value holder (automatically generated)"
-
-    |oldValue newValue|
-
-    showColumnSpecHolder notNil ifTrue:[
-        oldValue := showColumnSpecHolder value.
-        showColumnSpecHolder removeDependent:self.
-    ].
-    showColumnSpecHolder := something.
-    showColumnSpecHolder notNil ifTrue:[
-        showColumnSpecHolder addDependent:self.
-    ].
-    newValue := showColumnSpecHolder value.
-    oldValue ~~ newValue ifTrue:[
-        self update:#value with:newValue from:showColumnSpecHolder.
-    ].
-!
-
 showRemovedHolder
     "return/create the 'showRemovedHolder' value holder (automatically generated)"
 
@@ -568,12 +661,52 @@
     oldValue ~~ newValue ifTrue:[
         self update:#value with:newValue from:showSameHolder.
     ].
+!
+
+showTimestampHolder
+    "return/create the 'showTimestampHolder' value holder (automatically generated)"
+
+    showTimestampHolder isNil ifTrue:[
+        showTimestampHolder := ValueHolder new.
+        showTimestampHolder addDependent:self.
+    ].
+    ^ showTimestampHolder
+!
+
+showTimestampHolder:something
+    "set the 'showTimestampHolder' value holder (automatically generated)"
+
+    |oldValue newValue|
+
+    showTimestampHolder notNil ifTrue:[
+        oldValue := showTimestampHolder value.
+        showTimestampHolder removeDependent:self.
+    ].
+    showTimestampHolder := something.
+    showTimestampHolder notNil ifTrue:[
+        showTimestampHolder addDependent:self.
+    ].
+    newValue := showTimestampHolder value.
+    oldValue ~~ newValue ifTrue:[
+        self update:#value with:newValue from:showTimestampHolder.
+    ].
 ! !
 
 !ChangeList methodsFor:'change & update'!
 
 update: aspect with: param from: sender
 
+    sender == allowRemoveHolder ifTrue:[
+        self listColumn: #removed visible: allowRemoveHolder value.
+        ^self.
+    ].
+
+    sender == showTimestampHolder ifTrue:[
+        self listColumn: #timeStamp visible: showTimestampHolder value.
+        ^self.
+    ].
+
+
     sender == selectionHolder ifTrue:[
         self selectionChanged.
         ^self
@@ -586,52 +719,16 @@
         self updateList.
         ^self.
     ].
-    sender == showColumnSpecHolder ifTrue:[
-        listView notNil ifTrue:[
-            listView invalidate.
-        ].
-        ^self.
-    ].
 
     ^super update: aspect with: param from: sender
 
     "Created: / 24-10-2009 / 19:47:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (format): / 27-12-2011 / 14:20:30 / cg"
-    "Modified: / 03-04-2012 / 11:27:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-07-2012 / 18:44:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ChangeList methodsFor:'event processing'!
 
-buttonPress:button x:x y:y view:aView
-
-    | itemIndex item |
-
-    button ~= 1 ifTrue:[^aView buttonPress:button x:x y:y].
-
-    itemIndex := aView yVisibleToLineNr:y.
-    itemIndex isNil ifTrue:[^self].
-    itemIndex == 0 ifTrue:[^self].
-    itemIndex > aView list size ifTrue:[^self].
-    item := aView list at: itemIndex.
-
-    ((aView left + x) between: (item x) and: ((item x ? 0) + 16))
-        ifFalse:[^aView buttonPress:button x:x y:y].
-
-    item removed: item removed not.
-    aView invalidate
-
-    "Created: / 08-12-2009 / 14:12:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-11-2011 / 14:55:41 / cg"
-    "Modified: / 15-02-2012 / 18:17:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-handlesButtonPress:button inView:aView
-
-    ^listView scrolledView == aView
-
-    "Created: / 08-12-2009 / 14:08:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 handlesKeyPress:key inView:aView
     ^(key == #Accept or:[ key == #Ctrls]) 
         and:[ listView scrolledView == aView ]
@@ -876,6 +973,62 @@
     "Modified: / 24-07-2009 / 22:06:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
 !
 
+listColumn: columnId visible: visible
+    visible ifTrue:[
+        self listColumnShow: columnId 
+    ] ifFalse:[
+        self listColumnHide: columnId
+    ]
+
+    "Created: / 26-07-2012 / 18:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+listColumnHide: columnId
+    self listColumns do:[:spec|
+        spec id = columnId ifTrue:[
+            self listColumns remove: spec.
+            listView notNil ifTrue:[
+                listView invalidate.
+            ].
+            ^self
+        ].
+    ]
+
+    "Created: / 26-07-2012 / 18:19:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+listColumnShow: columnId
+
+    | columns |
+    columns := self listColumns.
+
+    columns do:[:spec|
+        spec id = columnId ifTrue:[
+            ^self.
+        ]
+    ].
+
+    self class listColumnSpec do:[:specArray|
+        | spec |
+
+        spec := specArray decodeAsLiteralArray.
+        spec id = columnId ifTrue:[
+            columnId == #removed ifTrue:[
+                columns addFirst: spec.
+            ] ifFalse:[
+                columns add: spec.
+            ].
+            listView notNil ifTrue:[
+                listView invalidate.
+            ].
+            ^self.
+        ]
+
+    ].
+
+    "Created: / 26-07-2012 / 17:56:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 listEntryFor:chg 
     ^ListEntry change:chg application: self
 
@@ -905,7 +1058,7 @@
     inGenerator := self inGeneratorHolder value.
     listView notNil ifTrue:[
         ((listView isKindOf: ScrollableView) not or:[listView scrolledView notNil]) ifTrue:[
-            firstLineShown := listView yVisibleToLineNr:1.
+            firstLineShown := listView firstLineShown
         ].
     ].
     oldSel := self selection.
@@ -940,7 +1093,7 @@
     ]
 
     "Modified: / 28-12-2011 / 15:46:15 / cg"
-    "Modified: / 25-07-2012 / 15:18:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-07-2012 / 18:03:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ChangeList methodsFor:'queries'!
@@ -1126,8 +1279,22 @@
     "Modified: / 05-12-2009 / 14:46:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+notRemoved
+    ^ self removed not
+
+    "Created: / 26-07-2012 / 18:31:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+notRemoved: aBoolean
+    ^ self removed: aBoolean not
+
+    "Created: / 26-07-2012 / 18:31:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 removed
-    ^ change removed
+    ^ change removed == true
+
+    "Modified: / 26-07-2012 / 18:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 removed:aBoolean
@@ -1139,6 +1306,12 @@
     ^change source
 !
 
+timeStamp
+    ^change timeOfChangeIfKnown
+
+    "Created: / 26-07-2012 / 18:38:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 x
     ^ x
 ! !
@@ -1160,20 +1333,20 @@
 
     super displayLabel:aLabel h:lH on:aGC x:cx y:y h:h.
 
-    "Now, display additional columns..."
-    (list showColumn: #timestamp) ifTrue:[
-        cx := cx + (aLabel widthOn: aGC) + 5."px - padding"
-        colS := change timeOfChangeIfKnown notNil 
-                    ifTrue:[change timeOfChangeIfKnown printString]
-                    ifFalse:['???'].
-        [ (colW := colS widthOn: aGC) > (aGC width - cx - 5) ] whileTrue:[
-            colS = '...' ifTrue:[ ^ self ].
-            colS := '...' , (colS copyFrom: 6).
-        ].
-        super displayLabel:colS h:lH on:aGC x: (aGC width - 5 - colW) y:y h:h.
-    ].
+"/    "Now, display additional columns..."
+"/    (list showColumn: #timestamp) ifTrue:[
+"/        cx := cx + (aLabel widthOn: aGC) + 5."px - padding"
+"/        colS := change timeOfChangeIfKnown notNil 
+"/                    ifTrue:[change timeOfChangeIfKnown printString]
+"/                    ifFalse:['???'].
+"/        [ (colW := colS widthOn: aGC) > (aGC width - cx - 5) ] whileTrue:[
+"/            colS = '...' ifTrue:[ ^ self ].
+"/            colS := '...' , (colS copyFrom: 6).
+"/        ].
+"/        super displayLabel:colS h:lH on:aGC x: (aGC width - 5 - colW) y:y h:h.
+"/    ].
 
-    "Modified: / 17-05-2012 / 23:05:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-07-2012 / 18:38:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ChangeList::ListEntry methodsFor:'private'!
@@ -1203,7 +1376,7 @@
 !ChangeList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeList.st,v 1.16 2012/07/25 23:18:13 cg Exp $'
+    ^ '$Id: Tools__ChangeList.st 8027 2012-07-26 18:46:57Z vranyj1 $'
 !
 
 version_CVS
@@ -1211,5 +1384,5 @@
 !
 
 version_SVN
-    ^ '$Id: Tools__ChangeList.st 8026 2012-07-26 16:09:41Z vranyj1 $'
+    ^ '$Id: Tools__ChangeList.st 8027 2012-07-26 18:46:57Z vranyj1 $'
 ! !