ChangeSetBrowser.st
author claus
Thu, 10 Aug 1995 20:38:26 +0200
changeset 111 b4ef3e799345
parent 110 570a38362ae1
child 128 6eb4cc559360
permissions -rw-r--r--
,

"
 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 comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

$Header: /cvs/stx/stx/libtool/ChangeSetBrowser.st,v 1.7 1995-08-10 18:37:11 claus Exp $
'!

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

version
"
$Header: /cvs/stx/stx/libtool/ChangeSetBrowser.st,v 1.7 1995-08-10 18:37:11 claus Exp $
"
!

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'!

initializeMiddleButtonMenu
    |labels|

    labels := resources array:#(
			       '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').

    changeListView
	middleButtonMenu:(PopUpMenu 
			    labels:labels
			 selectors:#(
				     doApply
				     doApplyRest
				     doApplyAll
				     nil
				     doDelete
				     doDeleteRest
				     doDeleteClassRest
				     doDeleteClassAll
				     nil
				     doUpdate
				     doCompress
				     doCompare
				     nil
				     doMakePatch
				     doMakePermanent
				     nil
				     doSaveBack)
			  receiver:self
			       for:changeListView)
! !

!ChangeSetBrowser methodsFor:'private'!

queryCloseText
	^ 'Quit without updating changeSet ?'
!

streamForChange:changeNr
    "answer a stream for change"

    |change|

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

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

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

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

    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
    ]
!

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.
    changeClassNames removeIndex:changeNr.
    changeSet removeIndex:changeNr
! !

!ChangeSetBrowser methodsFor:'user actions'!

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