Tools__ChangeList.st
author vrany
Thu, 04 Aug 2011 20:03:33 +0200
changeset 10449 bdc2ecfadf41
parent 10334 3ac95963b1a5
child 10451 3fe1648adef5
permissions -rw-r--r--
ChangeSetBrowser2 refactoring/cleanup

"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

BrowserList subclass:#ChangeList
	instanceVariableNames:'listHolder listView showRemovedHolder showSameHolder
		acceptEnabledHolder'
	classVariableNames:'LastSelectionConditionString'
	poolDictionaries:''
	category:'Interface-Browsers-ChangeSet'
!

HierarchicalItem subclass:#ListEntry
	instanceVariableNames:'change application x'
	classVariableNames:''
	poolDictionaries:''
	privateIn:ChangeList
!

!ChangeList class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
! !

!ChangeList class methodsFor:'image specs'!

iconEqual
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconEqual inspect
     ImageEditor openOnClass:self andSelector:#iconEqual
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'Tools::ChangeList class iconEqual'
        ifAbsentPut:[(Depth8Image new) width: 12; height: 12; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@8*;H2M+ 5[7K,\3L7-/F1[?''.Z*6/+3%.MK@2\&99L;\.-?P7[6=/^GV+KGL2-ST@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8*;H2M+ 
5[7K,\3L7-/F1[?''.Z*6/+3%.MK@2\&99L;\.-?P7[6=/^GV+KGL2-ST@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[255 248 248 63 144 224 64 152 232 79 160 232 64 152 224 64 144 224 63 136 224 48 128 216 48 120 216 47 112 216 47 112 208 32 104 208 32 96 208 31 88 200 16 88 200 16 80 200 15 72 192 15 64 192 0 64 192 0 56 184 0 56 176 0 48 160 143 200 248 128 200 248 127 192 248 112 184 248 111 176 248 96 168 248 95 160 248 80 152 248 79 144 248 64 128 248 63 120 248 48 112 248 32 104 248 31 96 248 16 88 248 15 80 248 0 72 248 0 64 240 0 48 168 112 176 248 111 168 248 96 160 248 95 152 248 80 144 248 79 136 248 63 128 248 48 120 248 47 112 248 15 72 248 0 48 176 95 168 232 191 224 248 191 216 248 176 208 248 175 208 248 175 200 248 160 200 248 160 192 248 159 192 248 159 184 248 144 184 248 144 176 248 143 168 248 128 168 248 128 160 248 127 160 248 127 152 240 31 72 176 111 168 232 240 240 248 240 232 240 63 88 176 239 232 240 240 240 240 48 88 176 96 168 224 224 224 232 96 160 224 223 216 232 48 80 176 224 224 240 223 216 224 96 152 224 96 152 216 95 152 216 239 232 232 208 208 224 48 120 208 80 144 208 80 136 208 79 128 200 79 120 200 79 120 192 64 112 192 64 104 184 63 104 184 63 96 184 15 56 160 0 0 0 207 216 240 240 144 24 255 248 48 255 248 96 255 248 24 240 208 24 255 248 152 255 248 88 255 248 136 255 248 176 255 248 200 227 227 236 225 225 234 244 244 249 242 242 247 218 217 230 212 211 224 234 234 242 253 253 254 251 251 252 227 226 235 226 226 237 243 243 247 220 220 231 240 239 244 237 237 244 233 233 240 52 89 178 231 231 238 50 87 176 229 229 239 248 248 251 246 246 249 223 223 233 222 221 232 238 238 244 56 94 181 55 92 180 53 90 178 233 232 239 51 88 176 232 232 241 251 251 253 249 249 251 228 228 237 225 224 234 241 241 246 238 237 243 56 93 180 254 254 255 229 229 237 227 227 238 246 246 250 244 244 248 219 219 230 236 236 243 255 255 255 51 88 177 231 230 238 249 249 252 247 247 250 241 241 247 239 239 245 236 235 242 54 91 179 231 231 240 176 175 128 176 240 159 143 159 128 127 208 96 175 239 144 15 79 0 160 176 95 0 160 0 64 176 48 112 159 95 0 96 0 144 159 143 96 207 80 127 159 111 63 175 48 96 207 79 80 176 64 31 159 31 143 224 112 64 176 63 95 207 79 63 160 47 0 127 0 80 191 64 176 240 144 143 239 112 15 160 15 16 95 16 0 80 0 143 224 111 191 240 159 175 240 144 15 127 15 0 175 0 144 239 127 0 79 0 0 112 0 0 95 0 15 112 15 111 207 80 16 79 16 15 79 15 16 80 16 128 223 111 159 159 63 15 64 15 31 144 16 16 80 15 128 224 111 176 239 159 95 112 80 15 175 15 144 224 127 95 192 79 31 95 15 32 160 31 48 159 47 32 159 31 15 128 15 95 160 47 0 111 0 127 223 96 15 80 0 64 112 63 159 239 127]; mask:((ImageMask new) width: 12; height: 12; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@/?<O?5??G?<@@@@@C?<O?6??G?<@@@') ; yourself); yourself]
!

iconEqualGrayed
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconEqualGrayed  inspect
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'Tools::ChangeList class iconEqualGrayed'
        ifAbsentPut:[self iconEqual asGrayImageDepth: 8]
!

iconMinus
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconMinus inspect
     ImageEditor openOnClass:self andSelector:#iconMinus
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'Tools::ChangeList class iconMinus'
        ifAbsentPut:[(Depth8Image new) width: 12; height: 12; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8*;H2M+ 5[7K,\3L7-/F1[?''.Z*6/+3%.MK@2\&99L;\.-?P7[6=/^GV
+KGL2-ST@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[255 248 248 63 144 224 64 152 232 79 160 232 64 152 224 64 144 224 63 136 224 48 128 216 48 120 216 47 112 216 47 112 208 32 104 208 32 96 208 31 88 200 16 88 200 16 80 200 15 72 192 15 64 192 0 64 192 0 56 184 0 56 176 0 48 160 143 200 248 128 200 248 127 192 248 112 184 248 111 176 248 96 168 248 95 160 248 80 152 248 79 144 248 64 128 248 63 120 248 48 112 248 32 104 248 31 96 248 16 88 248 15 80 248 0 72 248 0 64 240 0 48 168 112 176 248 111 168 248 96 160 248 95 152 248 80 144 248 79 136 248 63 128 248 48 120 248 47 112 248 15 72 248 0 48 176 95 168 232 191 224 248 191 216 248 176 208 248 175 208 248 175 200 248 160 200 248 160 192 248 159 192 248 159 184 248 144 184 248 144 176 248 143 168 248 128 168 248 128 160 248 127 160 248 127 152 240 31 72 176 111 168 232 240 240 248 240 232 240 63 88 176 239 232 240 240 240 240 48 88 176 96 168 224 224 224 232 96 160 224 223 216 232 48 80 176 224 224 240 223 216 224 96 152 224 96 152 216 95 152 216 239 232 232 208 208 224 48 120 208 80 144 208 80 136 208 79 128 200 79 120 200 79 120 192 64 112 192 64 104 184 63 104 184 63 96 184 15 56 160 0 0 0 207 216 240 240 144 24 255 248 48 255 248 96 255 248 24 240 208 24 255 248 152 255 248 88 255 248 136 255 248 176 255 248 200 227 227 236 225 225 234 244 244 249 242 242 247 218 217 230 212 211 224 234 234 242 253 253 254 251 251 252 227 226 235 226 226 237 243 243 247 220 220 231 240 239 244 237 237 244 233 233 240 52 89 178 231 231 238 50 87 176 229 229 239 248 248 251 246 246 249 223 223 233 222 221 232 238 238 244 56 94 181 55 92 180 53 90 178 233 232 239 51 88 176 232 232 241 251 251 253 249 249 251 228 228 237 225 224 234 241 241 246 238 237 243 56 93 180 254 254 255 229 229 237 227 227 238 246 246 250 244 244 248 219 219 230 236 236 243 255 255 255 51 88 177 231 230 238 249 249 252 247 247 250 241 241 247 239 239 245 236 235 242 54 91 179 231 231 240 176 175 128 176 240 159 143 159 128 127 208 96 175 239 144 15 79 0 160 176 95 0 160 0 64 176 48 112 159 95 0 96 0 144 159 143 96 207 80 127 159 111 63 175 48 96 207 79 80 176 64 31 159 31 143 224 112 64 176 63 95 207 79 63 160 47 0 127 0 80 191 64 176 240 144 143 239 112 15 160 15 16 95 16 0 80 0 143 224 111 191 240 159 175 240 144 15 127 15 0 175 0 144 239 127 0 79 0 0 112 0 0 95 0 15 112 15 111 207 80 16 79 16 15 79 15 16 80 16 128 223 111 159 159 63 15 64 15 31 144 16 16 80 15 128 224 111 176 239 159 95 112 80 15 175 15 144 224 127 95 192 79 31 95 15 32 160 31 48 159 47 32 159 31 15 128 15 95 160 47 0 111 0 127 223 96 15 80 0 64 112 63 159 239 127]; mask:((ImageMask new) width: 12; height: 12; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@,@@@@E@@G?<O?0??C?<@@F@@D@@@@@') ; yourself); yourself]
!

iconMinusGrayed
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconMinusGrayed inspect
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'Tools::ChangeList class iconMinusGrayed'
        ifAbsentPut:[self iconMinus asGrayImageDepth: 8]
!

iconPlus
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconPlus inspect
     ImageEditor openOnClass:self andSelector:#addOverlayIcon3
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'XPToolbarIconLibrary class addOverlayIcon3'
        ifAbsentPut:[(Depth8Image new) width: 12; height: 12; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@K_ 5^ @@@@@@@@@@LGI*,\@@@@@@@@@@M*+5<\@@@@@@@@@@N&(.[4@@@@@8*;H2M+X1K7K,\3L7-/F1[?''.Z*6/+3%.MK@2\&99L;\.-?P7[6=/^F*
,;GL2-ST@@@@@L6;/,H@@@@@@@@@@NN>+=D@@@@@@@@@@LN57<<@@@@@@@@@@N[V+M$@@@@@') ; colorMapFromArray:#[255 248 248 63 144 224 64 152 232 79 160 232 64 152 224 64 144 224 63 136 224 48 128 216 48 120 216 47 112 216 47 112 208 32 104 208 32 96 208 31 88 200 16 88 200 16 80 200 15 72 192 15 64 192 0 64 192 0 56 184 0 56 176 0 48 160 143 200 248 128 200 248 127 192 248 112 184 248 111 176 248 96 168 248 95 160 248 80 152 248 79 144 248 64 128 248 63 120 248 48 112 248 32 104 248 31 96 248 16 88 248 15 80 248 0 72 248 0 64 240 0 48 168 112 176 248 111 168 248 96 160 248 95 152 248 80 144 248 79 136 248 63 128 248 48 120 248 47 112 248 15 72 248 0 48 176 95 168 232 191 224 248 191 216 248 176 208 248 175 208 248 175 200 248 160 200 248 160 192 248 159 192 248 159 184 248 144 184 248 144 176 248 143 168 248 128 168 248 128 160 248 127 160 248 127 152 240 31 72 176 111 168 232 240 240 248 240 232 240 63 88 176 239 232 240 240 240 240 48 88 176 96 168 224 224 224 232 96 160 224 223 216 232 48 80 176 224 224 240 223 216 224 96 152 224 96 152 216 95 152 216 239 232 232 208 208 224 48 120 208 80 144 208 80 136 208 79 128 200 79 120 200 79 120 192 64 112 192 64 104 184 63 104 184 63 96 184 15 56 160 0 0 0 207 216 240 240 144 24 255 248 48 255 248 96 255 248 24 240 208 24 255 248 152 255 248 88 255 248 136 255 248 176 255 248 200 227 227 236 225 225 234 244 244 249 242 242 247 218 217 230 212 211 224 234 234 242 253 253 254 251 251 252 227 226 235 226 226 237 243 243 247 220 220 231 240 239 244 237 237 244 233 233 240 52 89 178 231 231 238 50 87 176 229 229 239 248 248 251 246 246 249 223 223 233 222 221 232 238 238 244 56 94 181 55 92 180 53 90 178 233 232 239 51 88 176 232 232 241 251 251 253 249 249 251 228 228 237 225 224 234 241 241 246 238 237 243 56 93 180 254 254 255 229 229 237 227 227 238 246 246 250 244 244 248 219 219 230 236 236 243 255 255 255 51 88 177 231 230 238 249 249 252 247 247 250 241 241 247 239 239 245 236 235 242 54 91 179 231 231 240 176 175 128 176 240 159 143 159 128 127 208 96 175 239 144 15 79 0 160 176 95 0 160 0 64 176 48 112 159 95 0 96 0 144 159 143 96 207 80 127 159 111 63 175 48 96 207 79 80 176 64 31 159 31 143 224 112 64 176 63 95 207 79 63 160 47 0 127 0 80 191 64 176 240 144 143 239 112 15 160 15 16 95 16 0 80 0 143 224 111 191 240 159 175 240 144 15 127 15 0 175 0 144 239 127 0 79 0 0 112 0 0 95 0 15 112 15 111 207 80 16 79 16 15 79 15 16 80 16 128 223 111 159 159 63 15 64 15 31 144 16 16 80 15 128 224 111 176 239 159 95 112 80 15 175 15 144 224 127 95 192 79 31 95 15 32 160 31 48 159 47 32 159 31 15 128 15 95 160 47 0 111 0 127 223 96 15 80 0 64 112 63 159 239 127 95 159 79 16 175 16]; mask:((ImageMask new) width: 12; height: 12; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'C0,O@@<EC0G?<O?0??C?<@<FC0DO@@<@') ; yourself); yourself]
!

iconPlusGrayed
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

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

    "
     self iconPlusGrayed inspect
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'Tools::ChangeList class iconPlusGrayed'
        ifAbsentPut:[self iconPlus asGrayImageDepth: 8]
! !

!ChangeList 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:Tools::ChangeList andSelector:#windowSpec
     Tools::ChangeList new openInterface:#windowSpec
     Tools::ChangeList open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Change List'
          name: 'Change List'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 300 300)
        )
        component: 
       (SpecCollection
          collection: (
           (SelectionInListModelViewSpec
              name: 'List'
              layout: (LayoutFrame 0 0 0 0 0 1 0 1)
              model: selectionHolder
              menu: menuHolder
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
              listModel: listHolder
              multipleSelectOk: true
              useIndex: false
              highlightMode: line
              doubleClickSelector: selectionDoubleclicked
              postBuildCallback: postBuildList:
            )
           )
         
        )
      )
! !

!ChangeList class methodsFor:'menu specs'!

listMenu
    "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:Tools::ChangeList andSelector:#listMenu
     (Menu new fromLiteralArrayEncoding:(Tools::ChangeList listMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            enabled: hasChangeSelectedAndNotRemoved
            label: 'Apply'
            itemValue: listMenuApply
            translateLabel: true
            isVisible: acceptEnabledHolder
            shortcutKey: Accept
          )
         (MenuItem
            label: 'Apply all'
            itemValue: listMenuApplyAll
            translateLabel: true
            isVisible: acceptEnabledHolder
          )
         (MenuItem
            enabled: hasSingleChangeSelectedAndCanBrowse
            label: 'Browse'
            itemValue: listMenuBrowse
            translateLabel: true
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Delete'
            itemValue: listMenuDeleteSelection
            nameKey: Delete
            translateLabel: true
            shortcutKey: Delete
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Select...'
            translateLabel: true
            submenu: 
           (Menu
              (
               (MenuItem
                  label: 'Select same'
                  itemValue: listMenuSelectSame
                  translateLabel: true
                )
               (MenuItem
                  label: 'Select additions (new classes/methods)'
                  itemValue: listMenuSelectAdditions
                  translateLabel: true
                )
               (MenuItem
                  label: 'Select removals'
                  itemValue: listMenuSelectRemovals
                  translateLabel: true
                )
               (MenuItem
                  label: '-'
                )
               (MenuItem
                  label: 'Select all'
                  itemValue: listMenuSelectAll
                  translateLabel: true
                )
               (MenuItem
                  label: 'Select none'
                  itemValue: listMenuSelectNone
                  translateLabel: true
                )
               (MenuItem
                  label: '-'
                )
               (MenuItem
                  label: 'Select using block'
                  itemValue: listMenuSelectUsingBlock
                  translateLabel: true
                )
               )
              nil
              nil
            )
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Show Deleted'
            translateLabel: true
            indication: showRemovedHolder
          )
         (MenuItem
            label: 'Inspect change'
            itemValue: listMenuInspect
            translateLabel: true
          )
         )
        nil
        nil
      )
! !

!ChangeList class methodsFor:'plugIn spec'!

aspectSelectors
    "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."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #acceptEnabledHolder
        #inGeneratorHolder
        #menuHolder
        #outGeneratorHolder
        #selectionHolder
        #showRemovedHolder
        #showSameHolder
      ).

    "Modified: / 04-08-2011 / 18:42:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'accessing'!

acceptEnabled
    "return the value in 'acceptEnabledHolder'"

    ^ self acceptEnabledHolder value
!

acceptEnabled: newValue
    "set the value in 'acceptEnabledHolder'"

    self acceptEnabledHolder value: newValue
!

selection

    ^self selectionHolder value

    "Created: / 05-12-2009 / 14:48:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

showRemoved

    ^self showRemovedHolder value ? true

    "Created: / 05-12-2009 / 14:28:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'actions'!

selectionDoubleclicked

    | app |

    self selection do:
        [:e|e removed: e removed not].
    ((app := self masterApplication) respondsTo: #redrawChangeListViews)
        ifTrue:[app redrawChangeListViews].

    "Modified: / 16-03-2011 / 22:51:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'aspects'!

acceptEnabledHolder
    "return/create the valueHolder 'acceptEnabledHolder'"

    acceptEnabledHolder isNil ifTrue:[
        acceptEnabledHolder := ValueHolder with:nil "defaultValue here".
    ].
    ^ acceptEnabledHolder
!

acceptEnabledHolder:aValueModel
    acceptEnabledHolder := aValueModel.
!

listHolder
    listHolder isNil ifTrue:[
        listHolder := ValueHolder new.
    ].
    ^ listHolder
!

showRemovedHolder
    "return/create the 'showRemovedHolder' value holder (automatically generated)"

    showRemovedHolder isNil ifTrue:[
        showRemovedHolder := ValueHolder with: true.
        showRemovedHolder addDependent: self.
    ].
    ^ showRemovedHolder
!

showRemovedHolder:something
    "set the 'showRemovedHolder' value holder (automatically generated)"

    |oldValue newValue|

    showRemovedHolder notNil ifTrue:[
        oldValue := showRemovedHolder value.
        showRemovedHolder removeDependent:self.
    ].
    showRemovedHolder := something.
    showRemovedHolder notNil ifTrue:[
        showRemovedHolder addDependent:self.
    ].
    newValue := showRemovedHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:showRemovedHolder.
    ].
!

showSameHolder
    "return/create the 'showSameHolder' value holder (automatically generated)"

    showSameHolder isNil ifTrue:[
        showSameHolder := ValueHolder with: true.
        showSameHolder addDependent:self.
    ].
    ^ showSameHolder

    "Modified: / 04-08-2011 / 18:39:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

showSameHolder:something
    "set the 'showSameHolder' value holder (automatically generated)"

    |oldValue newValue|

    showSameHolder notNil ifTrue:[
        oldValue := showSameHolder value.
        showSameHolder removeDependent:self.
    ].
    showSameHolder := something.
    showSameHolder notNil ifTrue:[
        showSameHolder addDependent:self.
    ].
    newValue := showSameHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:showSameHolder.
    ].
! !

!ChangeList methodsFor:'change & update'!

update: aspect with: param from: sender

    sender == selectionHolder ifTrue:[
        self selectionChanged.
        ^self
    ].
    sender == showSameHolder ifTrue:[
        self updateList
    ].
    sender == showRemovedHolder ifTrue:[
        self updateList
    ].


    ^super update: aspect with: param from: sender

    "Created: / 24-10-2009 / 19:47:14 / 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 ifNil:[^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 + 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>"
!

handlesButtonPress:button inView:aView

    ^listView == aView

    "Created: / 08-12-2009 / 14:08:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'generators'!

makeGenerator
    "Superclass Tools::BrowserList says that I am responsible to implement this method"

    ^Iterator on:
        [:whatToDo|
        selectionHolder value do:
            [:changeListItem| | change |
            change := changeListItem change.
            change isCompositeChange ifTrue:
                [change changes do: whatToDo]]].

    "Modified: / 24-07-2009 / 23:00:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 24-10-2009 / 20:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'hooks'!

postBuildList: aView

    listView := aView scrolledView.
    listView delegate: self.

    "Created: / 08-12-2009 / 14:10:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'initialization'!

initialize

    super initialize.
    menuHolder := [self menuFor: #listMenu].

    "Created: / 29-10-2010 / 12:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'menu actions'!

listMenuApply

    self acceptEnabled ifFalse:[^self].

    self selectionHolder value do:[:e|e change apply].

    "Modified: / 24-10-2009 / 22:02:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

listMenuApplyAll

    self acceptEnabled ifFalse:[^self].

    self selection value do:
        [:e|e removed ifFalse:[e change apply]].

    "Created: / 05-12-2009 / 14:53:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

listMenuBrowse

    | classes methods methodsOnly |
    classes := Set new.
    methods := Set new.
    methodsOnly := true.
    self selectionHolder value do:
        [:each|
        each change isClassChange ifTrue:
            [each change changeClass ifNotNil:
                [classes add: each change changeClass.
                each change isMethodCodeChange 
                    ifTrue:
                        [each change changeMethod ifNotNil:
                            [methods add:each change changeMethod]]
                    ifFalse:
                        [methodsOnly := false]]]].

    methodsOnly 
        ifTrue:
            [methods size = 1 
                ifTrue:[Smalltalk browserClass openInMethod: methods anyOne]
                ifFalse:[Smalltalk browserClass browseMethods: methods asArray title: 'Selected methods from changeset' sort: true]]
        ifFalse:
            [classes size = 1
                ifTrue:[Smalltalk browserClass browseClass: classes anyOne]
                ifFalse:[Smalltalk browserClass browseClasses: classes]]




    "Modified: / 24-10-2009 / 22:02:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

listMenuDeleteSelection

    self selectionHolder value do:
        [:each|each removed: true].
    self updateList
!

listMenuInspect

    | selection |

    selection := self selectionHolder value collect:[:e|e change].
    selection size = 1
        ifTrue:[selection anyOne inspect]
        ifFalse:[selection inspect].

    "Modified: / 24-10-2009 / 22:02:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

listMenuSelectAdditions

    self listMenuSelectAllSuchThat:[:change|change delta = #+]
!

listMenuSelectAll

    self listMenuSelectAllSuchThat:[:change|true]
!

listMenuSelectAllSuchThat:conditionBlock 
    |newSelection|

    newSelection := self listHolder value 
                select:[:entry | conditionBlock value:entry change ].
    self selectionHolder value:newSelection
!

listMenuSelectNone

    self listMenuSelectAllSuchThat:[:change|false]
!

listMenuSelectRemovals

    self listMenuSelectAllSuchThat:[:change|change delta = #-]
!

listMenuSelectSame

    self listMenuSelectAllSuchThat:[:change|change delta = #=]
!

listMenuSelectUsingBlock

    |conditionBlockString conditionBlock dialog textHolder template|

    template :=
'[:change|
     "/ Define condition for selection below:
     "/ change is an instance of Change
     "/ change will be selected if and only if block returns true

    
     true"/always select the change
]
'.

    LastSelectionConditionString isNil ifTrue:[
        LastSelectionConditionString := template.
    ].


    textHolder := ValueHolder new.
    dialog := Dialog
                 forRequestText:(resources string:'Enter condition for selection')
                 lines:20
                 columns:70
                 initialAnswer:LastSelectionConditionString
                 model:textHolder.
    dialog addButton:(Button label:'Template' action:[textHolder value:template. textHolder changed:#value.]).
    dialog open.
    dialog accepted ifFalse:[^ self].

    conditionBlockString := textHolder value.
    LastSelectionConditionString := conditionBlockString.

    conditionBlock := Parser evaluate:conditionBlockString.
    conditionBlock isBlock ifFalse:[
        self error:'Bad selection block (syntax error?)'.
        ^ self
    ].

    self listMenuSelectAllSuchThat: conditionBlock
!

listMenuUndeleteSelection

    self selectionHolder value do:
        [:each|each removed: false].
    self updateList
! !

!ChangeList methodsFor:'private'!

application

    ^self

    "Created: / 05-12-2009 / 14:10:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

browserNameList

    ^'Change list'

    "Modified: / 24-07-2009 / 22:06:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

listEntryFor:chg 
    ^ListEntry change:chg application: self

    "Modified: / 05-12-2009 / 14:39:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

makeDependent

    "Modified: / 24-07-2009 / 22:06:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

makeIndependent

    "Modified: / 24-07-2009 / 22:06:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

parentOrModel

    ^self

    "Created: / 05-12-2009 / 14:14:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateList
    |inGenerator changeset|

    inGenerator := self inGeneratorHolder value.
    changeset := inGenerator ifNil:[ #() ] ifNotNil:[ inGenerator ].
    self listHolder value:(changeset 
                select:
                    [:chg | 
                    (self showRemovedHolder value or:[ chg removed not ])
                        and:[self showSameHolder not or:[chg delta ~~ #=]]
                    ]
                thenCollect:[:chg | self listEntryFor:chg ])

    "Modified: / 04-08-2011 / 18:41:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList methodsFor:'queries'!

hasChangeSelected

    ^self selectionHolder value size > 0
!

hasChangeSelectedAndNotRemoved

    | selection |
    selection := self selectionHolder value ? #().
    ^selection size > 0 and:
        [selection allSatisfy:[:e|e removed not]].
!

hasSingleChangeSelected

    ^self selectionHolder value size = 1
!

hasSingleChangeSelectedAndCanBrowse


    self selectionHolder value ? #() do:
        [:each|
        (each change isClassChange and:
            [each change isMethodChange not
                or:[each change isMethodCodeChange]]) ifFalse:[^false]].
    ^true
! !

!ChangeList::ListEntry class methodsFor:'instance creation'!

change: aChange

    ^self new change: aChange

    "Created: / 24-07-2009 / 22:43:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

change: aChange application: anApplicationModel

    ^self new change: aChange; application: anApplicationModel

    "Created: / 05-12-2009 / 14:16:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

change: aChange parent: aChangeList

    ^self new change: aChange; parent: aChangeList

    "Created: / 25-07-2009 / 23:33:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!ChangeList::ListEntry methodsFor:'accessing'!

application
    ^ application ifNil:[super application]

    "Modified: / 05-12-2009 / 14:16:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

application:anApplicationModel
    application := anApplicationModel.

    "Modified: / 05-12-2009 / 14:15:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

change
    ^ change
!

change:aChange

    self assert: ((aChange isKindOf: Change) or:[aChange isKindOf: RefactoryChange]).

    change := aChange.

    "Modified: / 25-07-2009 / 23:40:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

changeClass

    ^change changeClass
!

changeSource

    ^change changeSource

    "Created: / 19-07-2011 / 12:03:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

children

    children ifNil:
        [children :=
            change isCompositeChange 
                ifTrue:[change changes select:
                            [:chg|
                            (self application showRemovedHolder value or:[ chg removed not ])
                                and:[self application showSameHolder value or:[chg delta ~~ #=]]]
                            thenCollect:[:chg|(self application listEntryFor: chg) parent: self]]
                ifFalse:[#()]
        ].
    ^children

    "Created: / 25-07-2009 / 23:32:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 04-08-2011 / 18:48:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

delta

    ^change delta

    "Created: / 29-10-2010 / 14:32:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

iconDelta

    | iconSelector |
    iconSelector := self iconSelector.
    iconSelector ifNil:[^nil].
    self removed ifTrue:[iconSelector := iconSelector , #Grayed].
    ^self application class perform: iconSelector asSymbol.

    "Created: / 05-12-2009 / 14:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

iconRemoved

    ^self removed 
        ifTrue: [self application class uncheckedIcon ]
        ifFalse:[self application class checkedIcon ]

    "Created: / 05-12-2009 / 14:11:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

imageSource

    ^change imageSource

    "Created: / 19-07-2011 / 12:03:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

label

    | label |
    label := change displayString.
    self removed ifTrue:[label := label asText colorizeAllWith: Color gray].
    ^label

    "Created: / 05-11-2008 / 08:20:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 25-07-2009 / 23:43:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 05-12-2009 / 14:46:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

removed
    ^ change removed
!

removed:aBoolean
    change removed: aBoolean.
!

source

    ^change source
!

x
    ^ x
! !

!ChangeList::ListEntry methodsFor:'displaying'!

displayLabel:aLabel h:lH on:aGC x:newX y:y h:h 

    | cx icon |
    cx := x := newX.
    self application showRemoved ifTrue:
        [(icon := self iconRemoved) ifNotNil:
            [icon displayOn: aGC x: cx y: y + (h / 2) - (icon height / 2) ].
        cx := cx + 22."experimental value - this looks good"].
    (icon := self iconDelta) ifNotNil:
        [icon displayOn: aGC x: cx y: y + (h / 2) - (icon height / 2) ].
    cx := cx + 16."12 + 2px gap"                


    super displayLabel:aLabel h:lH on:aGC x:cx y:y h:h

    "Modified: / 05-12-2009 / 14:49:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeList::ListEntry methodsFor:'private'!

iconSelector

    | delta |
    delta := change delta.
    delta = #+ ifTrue:[^#iconPlus].
    delta = #- ifTrue:[^#iconMinus].
    delta = #= ifTrue:[^#iconEqual].

    ^nil.
! !

!ChangeList class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeList.st,v 1.4 2011-08-04 18:03:33 vrany Exp $'
!

version_SVN
    ^ '§Id: Tools__ChangeList.st 7486 2009-10-26 22:06:24Z vranyj1 §'
! !