"
COPYRIGHT (c) 2006 by eXept Software AG
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.
"
"{ Package: 'stx:libtool' }"
"{ NameSpace: Tools }"
CodeViewService subclass:#BackgroundSourceProcessingService
instanceVariableNames:'job done modified'
classVariableNames:''
poolDictionaries:''
category:'Interface-CodeView'
!
!BackgroundSourceProcessingService class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
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
"
An abstract base class for all services that process current
(displayed) source code. All processing is done in background
job, that is restarted whenever a text in the editor is changed.
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
job <BackgroundJob> A background job.
[class variables:]
[see also:]
"
! !
!BackgroundSourceProcessingService class methodsFor:'testing'!
isAbstract
^self == Tools::BackgroundSourceProcessingService
"Created: / 24-01-2012 / 12:27:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'acessing-defaults'!
defaultJobName
"Returns a human-readable job name, to ease identification in process browser"
^ 'CodeView2''s source processing job'
"Created: / 24-01-2012 / 12:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'change & update'!
sourceChanged:force
"Called when codeview's text changes"
(force or:[codeView textView modified]) ifTrue:[
self process
].
"Modified: / 22-08-2011 / 13:51:53 / cg"
"Modified (format): / 05-09-2011 / 05:06:40 / cg"
"Modified: / 24-01-2012 / 12:25:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
update:aspect with:param from:sender
textView notNil ifTrue:[
"/sender == textView modifiedChannel ifTrue:[^self codeChanged: false].
sender == textView model ifTrue:[
^ self sourceChanged:true
].
(sender == textView and:[aspect == #sizeOfContents]) ifTrue:[
^ self sourceChanged:true
].
].
codeView notNil ifTrue:[
sender == codeView languageHolder ifTrue:[
^ self sourceChanged:true
].
sender == codeView classHolder ifTrue:[
^ self sourceChanged:true
].
].
super
update:aspect
with:param
from:sender
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 13-09-2011 / 12:00:29 / cg"
"Modified: / 16-09-2011 / 17:30:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'event handling'!
linesDeletedFrom:start to:end
self sourceChanged:true
"Created: / 06-07-2011 / 17:14:36 / jv"
"Created: / 16-09-2011 / 15:18:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
linesInsertedFrom:start to:end
self sourceChanged:true
"Created: / 06-07-2011 / 17:14:36 / jv"
"Created: / 16-09-2011 / 15:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
linesModifiedFrom:start to:end
self sourceChanged:true
"Created: / 06-07-2011 / 17:14:36 / jv"
"Created: / 16-09-2011 / 15:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'initialization'!
initialize
job := (Smalltalk at:#BackgroundJob)
named:self defaultJobName
on:[self process:true].
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-08-2011 / 16:47:53 / cg"
"Modified (format): / 26-09-2011 / 15:39:56 / cg"
"Modified: / 24-01-2012 / 12:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'processing'!
process
"(Re)starts the processing job. Should be called whenever a source
must be (re)processed."
| prio |
"/ this clobbers the codeViews modified state; therefore, we have to remember
"/ this info somewhere ...
codeView browser ifNotNil:[
textView modified ifTrue:[
codeView browser navigationState realModifiedState: true
].
textView modifiedChannel setValue:false.
].
job scheduled ifTrue:[
job running ifFalse:[
"/ process already created, but did not get a change to start yet;
^ self
] ifTrue:[
job stop.
]
].
prio := Processor userBackgroundPriority - 1.
textView shown ifFalse:[
prio := prio - 1 max:1
].
job startWithPriority: prio.
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>"
"Modified: / 26-09-2011 / 15:40:23 / cg"
"Created: / 24-01-2012 / 12:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
process: delayed
"Do the real source processing. If delayed is true, actuall data update must
be done within the event queue using #pushUserEvent:...
"
self subclassResponsibility
"Created: / 24-01-2012 / 12:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService methodsFor:'registering'!
registerIn: aCodeView
super registerIn: aCodeView.
textView addDependent: self.
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BackgroundSourceProcessingService class methodsFor:'documentation'!
version
^ '$Id: Tools__BackgroundSourceProcessingService.st 7854 2012-01-30 17:49:41Z vranyj1 $'
!
version_CVS
^ '§Header: /cvs/stx/stx/libtool/Tools__BackgroundSourceProcessingService.st,v 1.1 2012/01/24 12:57:30 vrany Exp §'
!
version_SVN
^ '$Id: Tools__BackgroundSourceProcessingService.st 7854 2012-01-30 17:49:41Z vranyj1 $'
! !