Tools__ChangeSetDiffList.st
author vrany
Wed, 06 Jul 2011 16:39:45 +0200
changeset 10217 fcb21281008f
parent 10192 f898a869986e
child 10246 0a4d2feea6a3
permissions -rw-r--r--
changed: #listEntryIconFor:

"
 Copyright (c) 2007-2010 Jan Vrany
 Copyright (c) 2009-2010 eXept Software AG

 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:#ChangeSetDiffList
	instanceVariableNames:'listHolder listEntryLabelGenerator listEntryIconGenerator'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Diff'
!

Object subclass:#ListEntry
	instanceVariableNames:'model application'
	classVariableNames:''
	poolDictionaries:''
	privateIn:ChangeSetDiffList
!

!ChangeSetDiffList class methodsFor:'documentation'!

copyright
"
 Copyright (c) 2007-2010 Jan Vrany
 Copyright (c) 2009-2010 eXept Software AG

 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.

"
! !

!ChangeSetDiffList 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:SVN::DiffList andSelector:#windowSpec
     SVN::DiffList new openInterface:#windowSpec
     SVN::DiffList open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Diff List'
          name: 'Diff 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
            )
           )
         
        )
      )
! !

!ChangeSetDiffList 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)."

    ^ #(
        #inGeneratorHolder
        #outGeneratorHolder
        #menuHolder
        #listEntryLabelGenerator
        #listEntryIconGenerator
      ).

    "Modified: / 24-11-2009 / 09:59:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffList methodsFor:'accessing'!

listEntryIconGenerator
    ^ listEntryIconGenerator
!

listEntryIconGenerator:aBlock
    listEntryIconGenerator := aBlock.
!

listEntryLabelGenerator
    ^ listEntryLabelGenerator
!

listEntryLabelGenerator:aBlock
    listEntryLabelGenerator := aBlock.
! !

!ChangeSetDiffList methodsFor:'aspects'!

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

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

!ChangeSetDiffList methodsFor:'change & update'!

update: aspect with: param from: sender

    aspect == #resolution ifTrue:[^(self componentAt: #List) invalidateRepairNow: true].
        
    sender == selectionHolder ifTrue:[^self selectionChanged].
    super update: aspect with: param from: sender.

    "Modified: / 24-11-2009 / 18:34:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffList methodsFor:'generators'!

makeGenerator

    ^Iterator on:
        [:whatToDo|
        self selectionHolder value do:
            [:each|each model do: whatToDo]]

    "Modified: / 26-11-2009 / 17:23:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffList methodsFor:'private'!

listEntryIconFor:aDiffComponent 
    |a hasA b hasB hasBase|

    aDiffComponent isDiffSet ifTrue:[
        ^ nil
    ].
    hasA := (a := aDiffComponent versionA) notNil and:[a isMethodRemoveChange not].
    hasB := (b := aDiffComponent versionB) notNil and:[b isMethodRemoveChange not].
    hasBase := aDiffComponent versionBase notNil.
    (hasA & hasB & hasBase) ifTrue:[
        ^ ToolbarIconLibrary versionABBase12x12 
    ].
    (hasA & hasB) ifTrue:[
        ^ ToolbarIconLibrary versionAB12x12
    ].
    (hasA & hasBase) ifTrue:[
        ^ ToolbarIconLibrary versionABase12x12
    ].
    (hasA) ifTrue:[
        ^ ToolbarIconLibrary versionA12x12
    ].
    (hasB & hasBase) ifTrue:[
        ^ ToolbarIconLibrary versionBBase12x12
    ].
    (hasB) ifTrue:[
        ^ ToolbarIconLibrary versionB12x12
    ].
    ^ nil

    "Created: / 21-11-2009 / 21:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 09-06-2011 / 08:19:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 06-07-2011 / 16:38:33 / jv"
!

listEntryLabelFor:diff 

    ^listEntryLabelGenerator 
        ifNotNil: [listEntryLabelGenerator value: diff]
        ifNil:[diff name]

    "Modified: / 24-11-2009 / 10:00:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

makeDependent

    "Nothing to do"
!

makeIndependent

    "Nothing to do"
!

updateList
    "Superclass Tools::BrowserList says that I am responsible to implement this method"
    
    | newDiffs newList |
    self listHolder value ? #() do: [:entry|entry model removeDependent: self].

    newList := SortedCollection new:16.
    newList sortBlock:[:a :b | a asString < b asString ].
    newDiffs := self inGeneratorHolder value ? #().
    (newDiffs isKindOf: Tools::ChangseSetDiffComponent) ifTrue:
        [newDiffs := newDiffs diffs].
    newDiffs do:
        [:item|
        newList add:(ListEntry model: item application: self).
        item addDependent: self].
    self listHolder value:newList

    "Modified: / 06-07-2011 / 12:58:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

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

model: model application: application

    ^self new
        model: model;
        application: application

    "Created: / 24-11-2009 / 18:29:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffList::ListEntry methodsFor:'accessing'!

application
    ^ application
!

application:aDiffList
    application := aDiffList.
!

icon

    ^application 
        ifNotNil:[application listEntryIconFor: model]
        ifNil:[nil]

    "Created: / 24-11-2009 / 18:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

label

    ^application 
        ifNotNil:[application listEntryLabelFor: model]
        ifNil:[model displayString]

    "Created: / 24-11-2009 / 18:26:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 26-11-2009 / 17:33:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

model
    ^ model
!

model:aDiffComponent
    model := aDiffComponent.
! !

!ChangeSetDiffList::ListEntry methodsFor:'displaying'!

displayOn: aGC x: x y: y opaque: opaque

    | icon  |
    (icon := self icon) ifNotNil:[icon displayOn: aGC x: x y: y - icon height opaque: opaque].
    self label displayOn: aGC x: x + 16 y:y opaque: opaque

    "Created: / 24-11-2009 / 18:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ChangeSetDiffList class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__ChangeSetDiffList.st,v 1.2 2011-07-06 14:39:45 vrany Exp $'
!

version_SVN
    ^ '§Id: SVN__DiffList.st 341 2011-06-09 07:22:53Z vranyj1 §'
! !