SVN__WorkingCopyBrowser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 08 Aug 2011 15:43:44 +0200
changeset 775 f321c3505bf7
parent 403 7358e44af42e
child 817 c258e10fedc3
permissions -rw-r--r--
Updates from SVN

"
 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:libsvn' }"

"{ NameSpace: SVN }"

Browser subclass:#WorkingCopyBrowser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SVN-UI-Browsers'
!

!WorkingCopyBrowser 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.

"
! !

!WorkingCopyBrowser class methodsFor:'instance creation'!

on: aWorkingCopy

    ^self new workingCopy: aWorkingCopy
! !

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

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'Working Copy Status'
          name: 'Working Copy Status'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 300 300)
        )
        component: 
       (SpecCollection
          collection: (
           (DataSetSpec
              name: 'WCEntryTable'
              layout: (LayoutFrame 0 0 0 0 0 1 -30 1)
              model: selectionHolder
              menu: entryMenu
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
              dataList: workingCopyEntriesAspect
              useIndex: false
              columnHolder: wcEntryTableColumns
            )
           (CheckBoxSpec
              label: 'Show only changed etries'
              name: 'ShowOnlyChanged'
              layout: (LayoutFrame 0 0 -30 1 0 1 0 1)
              model: showOnlyChanged
              translateLabel: true
            )
           )
         
        )
      )
! !

!WorkingCopyBrowser class methodsFor:'menu specs'!

entryMenu
    "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:SVN::WorkingCopyBrowser andSelector:#entryMenu
     (Menu new fromLiteralArrayEncoding:(SVN::WorkingCopyBrowser entryMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'Show changes'
            itemValue: entryMenuShowChanges
            translateLabel: true
            labelImage: (ResourceRetriever #'SVN::IconLibrary' compare 'Show changes')
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Revert'
            itemValue: entryMenuRevert
            translateLabel: true
            labelImage: (ResourceRetriever #'SVN::IconLibrary' revert 'Revert')
          )
         )
        nil
        nil
      )
! !

!WorkingCopyBrowser class methodsFor:'others'!

version_CVS
    ^ '$Header$'
! !

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

    ^ #(
        #model
      ).

! !

!WorkingCopyBrowser class methodsFor:'tableColumns specs'!

wcEntryTableColumns
    "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:SVN::WorkingCopyStatusUI andSelector:#wcEntryTableColumns
    "

    <resource: #tableColumns>

    ^#(
      (DataSetColumnSpec
         label: ''
         activeHelpKey: ''
         labelButtonType: Button
         printSelector: statusIcon
         canSelect: false
         showRowSeparator: false
         showColSeparator: false
       )
      (DataSetColumnSpec
         label: 'Container'
         activeHelpKey: ''
         labelButtonType: Button
         printSelector: pathText
         canSelect: false
         showRowSeparator: false
         showColSeparator: false
       )
      (DataSetColumnSpec
         label: 'Rev'
         activeHelpKey: ''
         labelButtonType: Button
         printSelector: revision
         canSelect: false
         showRowSeparator: false
         showColSeparator: false
       )
      (DataSetColumnSpec
         label: 'Author'
         activeHelpKey: ''
         labelButtonType: Button
         printSelector: author
         canSelect: false
         showRowSeparator: false
         showColSeparator: false
       )
      (DataSetColumnSpec
         label: 'Date'
         activeHelpKey: ''
         labelButtonType: Button
         printSelector: date
         canSelect: false
         showRowSeparator: false
         showColSeparator: false
       )
      )

    "Modified: / 18-08-2009 / 14:31:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!WorkingCopyBrowser methodsFor:'accessing'!

workingCopy

    ^self model

    "Created: / 11-04-2008 / 10:20:36 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 12-04-2008 / 21:02:26 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

workingCopy: aWorkingCopy

    self model: aWorkingCopy

    "Created: / 11-04-2008 / 10:20:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 12-04-2008 / 21:02:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!WorkingCopyBrowser methodsFor:'aspects'!

showOnlyChanged

    |holder|

    (holder := builder bindingAt:#showOnlyChanged) isNil ifTrue:[
        holder := true asValue.
        holder onChangeEvaluate:
            [self model changed].
        builder aspectAt:#showOnlyChanged put:holder.
    ].
    ^ holder.

    "Created: / 21-10-2008 / 18:53:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

workingCopyEntriesAspect


    |holder|

    (holder := builder bindingAt:#workingCopyEntriesAspect) isNil ifTrue:[
        holder := (PluggableAdaptor on: self modelHolder)
                    getBlock:[:model|self workingCopyEntries]
                    putBlock:[:model :value|self error:'Should never be sent']
                    updateBlock:[:model :aspect :value|true].
        builder aspectAt:#workingCopyEntriesAspect put:holder.
    ].
    ^ holder.

    "Created: / 11-04-2008 / 10:24:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 21-10-2008 / 18:55:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!WorkingCopyBrowser methodsFor:'hooks'!

commonPostBuild

    ^self model changed

    "Created: / 11-04-2008 / 10:33:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 12-04-2008 / 21:05:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!WorkingCopyBrowser methodsFor:'menu actions'!

entryMenuRevert

    | entry |
    entry := self selection.
    entry ifNotNil:[entry revert]

    "Modified: / 09-10-2008 / 20:30:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Created: / 05-12-2009 / 20:10:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

entryMenuShowChanges
    self entryMenuShowChangesAgainst:SVN::Revision head

    "Modified: / 09-10-2008 / 20:30:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Created: / 05-12-2009 / 20:10:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

entryMenuShowChangesAgainst:rev 
    |wc entry wcChangeSet repoChangeSet diffset lang |
    wc := self model.
    entry := self selection.
    lang := entry programmingLanguage.
    (lang notNil and: [lang isSmalltalk]) ifTrue:[
        wcChangeSet := wc changeSetForContainer:entry path.
        wcChangeSet name: wcChangeSet name, ' (working copy)'.
        repoChangeSet := wc branch changeSetForContainer:entry path revision:rev.
        diffset := ChangeSetDiff versionA:wcChangeSet versionB:repoChangeSet.
        (Tools::ChangeSetDiffTool new)
            beSingleColumn;
            diffset:diffset;
            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: entry path with: rev printString);
            open
    ] ifFalse:[
        | text1 text2 |
        text1 := (wc containerReadStreamFor: entry path) contents asString.
        text2 := wc branch cat: entry path.
        (Tools::TextDiffTool new)
            versionALabel: 'Working copy';
            versionBLabel: ('r %1' bindWith: rev printString);
            versionA: text1 versionB: text2;
            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: entry path with: rev printString);
            open
    ]

    "Created: / 09-10-2008 / 20:14:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 09-08-2009 / 14:14:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 07-07-2011 / 21:49:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 07-07-2011 / 23:09:09 / jv"
! !

!WorkingCopyBrowser methodsFor:'private'!

workingCopyEntries
    | status |

    status := self model status.
    ^ self showOnlyChanged value 
        ifTrue: [ status reject: [:entry | entry status isNormal ] ]
        ifFalse: [ status ]

    "Created: / 21-10-2008 / 18:55:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 18-08-2009 / 09:12:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!WorkingCopyBrowser class methodsFor:'documentation'!

version_SVN
    ^ '§Id: SVN__WorkingCopyBrowser.st 354 2011-07-07 22:28:54Z vranyj1 §'
! !