ChgSetBrwsr.st
author Claus Gittinger <cg@exept.de>
Wed, 29 May 1996 13:23:56 +0200
changeset 581 d1a1ae9d49e4
parent 224 1ca3d2486f59
child 1470 6c0fc11207fe
permissions -rw-r--r--
removed old non-thread support

"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

ChangesBrowser subclass:#ChangeSetBrowser
	 instanceVariableNames:'changeSet originalChangeSet'
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Interface-Browsers'
!

!ChangeSetBrowser class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    like a changesBrowser, but manipulates the per-project change-lists.
"
! !

!ChangeSetBrowser class methodsFor:'instance creation'!

openOn:aChangeSet
    "create c changes browser on a change set"

    ^ ((self new label:'ChangeSet Browser') changeSet:aChangeSet) open
! !

!ChangeSetBrowser methodsFor:'initialize / release'!

changeListMenu
    |labels selectors|

    labels := #(
			     'apply change'
			     'apply changes to end'
			     'apply all changes'
			     '-'
			     'delete'
			     'delete to end'
			     'delete changes for this class to end'
			     'delete all changes for this class'
			     '-'
			     'update'
"/                             'compress'
			     'compare with current version'
			     '-'
			     'make change a patch'
"/                             'update sourcefile from change'
			     '-'
			     'saveback changeSet'
		).

    selectors := #(
			     doApply
			     doApplyRest
			     doApplyAll
			     nil
			     doDelete
			     doDeleteRest
			     doDeleteClassRest
			     doDeleteClassAll
			     nil
			     doUpdate
"/                             doCompress
			     doCompare
			     nil
			     doMakePatch
"/                             doMakePermanent
			     nil
			     doSaveBack
		).

    ^ PopUpMenu 
	 labels:labels
	 selectors:selectors
	 receiver:self

    "Created: 3.12.1995 / 18:06:35 / cg"
    "Modified: 3.12.1995 / 18:13:06 / cg"
! !

!ChangeSetBrowser methodsFor:'private'!

changeSet:aChangeSet
    originalChangeSet := aChangeSet.
    changeSet := OrderedCollection new.
    originalChangeSet notNil ifTrue:[
	originalChangeSet do:[:aChange |
	    changeSet add:aChange
	].
    ].
!

checkIfFileHasChanged
    Processor removeTimedBlock:checkBlock.
    changeSet size ~= originalChangeSet size ifTrue:[
        self newLabel:'(outdated)'.
        autoUpdate ifTrue:[
            self doUpdate
        ]
    ] ifFalse:[
        self newLabel:''
    ].
    Processor addTimedBlock:checkBlock afterSeconds:5.

    "Created: 3.12.1995 / 13:52:30 / cg"
    "Modified: 3.12.1995 / 14:15:06 / cg"
!

classNameOfChange:nr
    ^ (changeSet at:nr) class name

    "Created: 3.12.1995 / 18:15:56 / cg"
    "Modified: 3.12.1995 / 18:20:12 / cg"
!

numberOfChanges
    ^ changeSet size

    "Created: 3.12.1995 / 18:15:56 / cg"
!

queryCloseText
	^ 'Quit without updating changeSet ?'
!

readChangesFileInBackground:dummy
    "read the changeSet, create a list of header-lines"

    changeSet size == 0 ifTrue:[^ nil].

    self newLabel:'updating ...'.
    self withCursor:(Cursor read) do:[
	changeChunks := OrderedCollection new.
	changeHeaderLines := OrderedCollection new.

	changeSet do:[:aChange |
	    changeChunks add:(aChange printString).
	    changeHeaderLines add:(aChange printString)
	].
	changeClassNames := OrderedCollection new:(changeChunks size).
	anyChanges := false
    ].
    self newLabel:''.

    "Created: 3.12.1995 / 18:02:39 / cg"
!

saveBackChanges
    "save back the change set"

    [originalChangeSet isEmpty] whileFalse:[
	originalChangeSet removeLast
    ].
    changeSet do:[:aChange |
	originalChangeSet add:aChange
    ]
!

silentDeleteChange:changeNr
    "delete a change do not update changeListView"

    anyChanges := true.
    changeChunks removeIndex:changeNr.
    changeHeaderLines removeIndex:changeNr.
"/    changeClassNames removeIndex:changeNr.
    changeSet removeIndex:changeNr

    "Created: 3.12.1995 / 18:14:17 / cg"
    "Modified: 3.12.1995 / 18:18:42 / cg"
!

streamForChange:changeNr
    "answer a stream for change"

    |change|

    change := changeSet at:changeNr.
    change isNil ifTrue:[^nil].
    ^ ReadStream on:(change source)
! !

!ChangeSetBrowser methodsFor:'user actions'!

doSaveBack
    anyChanges ifTrue:[
	self saveBackChanges.
	self doUpdate
    ]
!

doUpdate
    changeSet := OrderedCollection new.
    originalChangeSet notNil ifTrue:[
        originalChangeSet do:[:aChange |
            changeSet add:aChange
        ].
    ].
    super doUpdate

    "Created: 3.12.1995 / 13:54:14 / cg"
! !

!ChangeSetBrowser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/Attic/ChgSetBrwsr.st,v 1.11 1995-12-03 18:44:23 cg Exp $'
! !