Tools__CodeViewService.st
author vrany
Wed, 06 Jul 2011 18:30:58 +0200
changeset 10227 e10d21aee889
parent 10070 808a953bdb64
child 10414 8900da9aa39c
permissions -rw-r--r--
More improvements in BreakpointService

"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

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 }"

Object subclass:#CodeViewService
	instanceVariableNames:'enabled codeView textView gutterView'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-CodeView'
!

!CodeViewService class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

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

!CodeViewService class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!CodeViewService class methodsFor:'accessing'!

availableServices

    ^self allSubclasses select:
        [:cls|cls isAbstract not and:[cls isAvailable]].

    "
        Tools::CodeViewService availableServices
    "

    "Created: / 07-03-2010 / 13:42:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 03-04-2011 / 23:07:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

label

    "Answers short label - for UI"

    ^self class name

    "Created: / 07-03-2010 / 13:58:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService class methodsFor:'registering'!

registerIn: aCodeView

    ^self new 
        registerIn: aCodeView;
        yourself.

    "Created: / 07-03-2010 / 13:50:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService class methodsFor:'testing'!

isAbstract

    ^self == Tools::CodeViewService

    "Created: / 07-03-2010 / 13:41:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isAvailable

    ^true

    "Created: / 03-04-2011 / 23:07:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'accessing'!

enabled
    ^ enabled
!

enabled:aBoolean
    enabled := aBoolean.
!

label

    ^self class label

    "Created: / 07-03-2010 / 14:03:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'change & update'!

update: aspect with: param from: sender

    "Get updated whenever something changes in the code view.
     Subclasses may override this"

    "Intentionally left blank here"

    "Created: / 06-03-2010 / 19:23:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'event handling'!

buttonMotion: button x:x y:y in: view

    "Handles an event in given view (a subview of codeView).
     If the method returns true, the event will not be processed
     by the view."

    ^false

    "Created: / 06-03-2010 / 20:17:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 13:05:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

buttonPress: button x:x y:y in: view

    "Handles an event in given view (a subview of codeView).
     If the method returns true, the event will not be processed
     by the view."

    ^false

    "Created: / 06-03-2010 / 20:36:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 13:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

keyPress:key x:x y:y in: view

    "Handles an event in given view (a subview of codeView).
     If the method returns true, the event will not be processed
     by the view."

    ^false

    "Created: / 06-03-2010 / 20:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 13:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

keyRelease: key x: x y: y in: view

    "Handles an event in given view (a subview of codeView).
     If the method returns true, the event will not be processed
     by the view."

    ^false

    "Created: / 06-03-2010 / 20:35:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 13:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

linesDeletedFrom: start to: end

    "Created: / 06-07-2011 / 17:14:23 / jv"
!

linesInsertedFrom: start to: end

    "Created: / 06-07-2011 / 17:14:31 / jv"
!

linesModifiedFrom: start to: end

    "Created: / 06-07-2011 / 17:14:36 / jv"
! !

!CodeViewService methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."


    "/ please change as required (and remove this comment)
    "/ enabled := nil.
    "/ codeView := nil.
    "/ textView := nil.

    super initialize.

    "Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'redrawing'!

drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg

    "Called by both gutterView and textView (well, not yet) to
     allow services to draw custom things on text view.
     Ask JV what the args means if unsure (I'm lazy to document
     them, now it is just an experiment...)"

    "Intentionally left blank, to be overriden by subclasses"

    "Created: / 17-06-2011 / 13:49:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'registering'!

registerIn: aCodeView

    "Installs myself in aCodeView"

    codeView := aCodeView.
    codeView addDependent: self.
    textView := aCodeView textView. 
    gutterView := aCodeView gutterView.
    enabled := true.

    "Created: / 06-03-2010 / 19:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

unregister

    "Uninstall myself from my codeView"

    codeView removeDependent: self.
    codeView := nil.
    textView := nil.

    "Created: / 06-03-2010 / 19:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-06-2011 / 12:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService methodsFor:'testing'!

isEnabled

    ^enabled == true

    "Created: / 07-03-2010 / 13:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CodeViewService class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeViewService.st,v 1.3 2011-07-06 16:30:58 vrany Exp $'
!

version_SVN
    ^ '§Id: Tools__CodeViewService.st 7790 2011-06-17 13:33:22Z vranyj1 §'
! !