Tools__LintRuleDetail.st
author Claus Gittinger <cg@exept.de>
Fri, 05 Aug 2011 08:37:04 +0200
changeset 10480 51d36cce6bbe
parent 10473 4201cd16dc0b
child 10500 ab0acb018129
permissions -rw-r--r--
oops - merge error

"
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
 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:libtool' }"

"{ NameSpace: Tools }"

ApplicationModel subclass:#LintRuleDetail
	instanceVariableNames:'ruleHolder rationaleVisibleHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Lint'
!

!LintRuleDetail class methodsFor:'documentation'!

copyright
"
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
 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.
"
! !

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

    <resource: #canvas>

    ^
     #(FullSpec
	name: windowSpec
	window:
       (WindowSpec
	  label: 'SmalllintRuleDetail'
	  name: 'SmalllintRuleDetail'
	  min: (Point 10 10)
	  bounds: (Rectangle 0 0 560 300)
	)
	component:
       (SpecCollection
	  collection: (
	   (VerticalPanelViewSpec
	      name: 'Panel'
	      layout: (LayoutFrame 0 0 0 0 0 1 0 1)
	      horizontalLayout: fit
	      verticalLayout: topSpaceFit
	      horizontalSpace: 0
	      verticalSpace: 0
	      component:
	     (SpecCollection
		collection: (
		 (ViewSpec
		    name: 'Label'
		    component:
		   (SpecCollection
		      collection: (
		       (LabelSpec
			  label: 'Name...'
			  name: 'Name'
			  layout: (LayoutFrame 20 0 0 0 -150 1 30 0)
			  translateLabel: true
			  labelChannel: ruleNameAspect
			  adjust: left
			)
		       (CheckBoxSpec
			  label: 'Show Rationale'
			  name: 'CheckBox1'
			  layout: (LayoutFrame -150 1 0 0 0 1 30 0)
			  model: rationaleVisibleHolder
			  translateLabel: true
			)
		       )

		    )
		    extent: (Point 560 30)
		  )
		 (HTMLViewSpec
		    name: 'Rationale'
		    level: 0
		    visibilityChannel: rationaleVisibleHolder
		    hasHorizontalScrollBar: true
		    hasVerticalScrollBar: true
		    htmlText: ruleRationaleAspect
		    extent: (Point 300 268)
		    postBuildCallback: setupHTMLView:
		  )
		 )

	      )
	    )
	   )

	)
      )
! !

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

    ^ #(
	#ruleHolder
      ).

! !

!LintRuleDetail methodsFor:'aspects'!

rationaleVisibleHolder
    "return/create the 'rationaleVisibleHolder' value holder (automatically generated)"

    rationaleVisibleHolder isNil ifTrue:[
	rationaleVisibleHolder := ValueHolder with: false.
	rationaleVisibleHolder addDependent:self.
    ].
    ^ rationaleVisibleHolder

    "Modified: / 04-08-2011 / 21:39:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

rationaleVisibleHolder:something
    "set the 'rationaleVisibleHolder' value holder (automatically generated)"

    |oldValue newValue|

    rationaleVisibleHolder notNil ifTrue:[
	oldValue := rationaleVisibleHolder value.
	rationaleVisibleHolder removeDependent:self.
    ].
    rationaleVisibleHolder := something.
    rationaleVisibleHolder notNil ifTrue:[
	rationaleVisibleHolder addDependent:self.
    ].
    newValue := rationaleVisibleHolder value.
    oldValue ~~ newValue ifTrue:[
	self update:#value with:newValue from:rationaleVisibleHolder.
    ].
!

ruleHolder
    "return/create the 'ruleHolder' value holder (automatically generated)"

    ruleHolder isNil ifTrue:[
	ruleHolder := ValueHolder new.
    ].
    ^ ruleHolder
!

ruleHolder:something
    "set the 'ruleHolder' value holder (automatically generated)"

    |oldValue newValue|

    ruleHolder notNil ifTrue:[
	oldValue := ruleHolder value.
	ruleHolder removeDependent:self.
    ].
    ruleHolder := something.
    ruleHolder notNil ifTrue:[
	ruleHolder addDependent:self.
    ].
    newValue := ruleHolder value.
    oldValue ~~ newValue ifTrue:[
	self update:#value with:newValue from:ruleHolder.
    ].
!

ruleNameAspect
    <resource: #uiAspect>

    |holder|

    (holder := builder bindingAt:#ruleNameAspect) isNil ifTrue:[
	holder := (AspectAdaptor forAspect: #displayString) subjectChannel: self ruleHolder.
	builder aspectAt:#ruleNameAspect put:holder.
"/       holder addDependent:self.
"/       holder onChangeSend:#ruleNameAspectChanged to:self.
    ].
    ^ holder.

    "Modified: / 05-02-2010 / 12:51:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

ruleRationaleAspect
    <resource: #uiAspect>

    |holder|

    (holder := builder bindingAt:#ruleRationaleAspect) isNil ifTrue:[
	holder := (AspectAdaptor forAspect: #rationale) subjectChannel: self ruleHolder.
	builder aspectAt:#ruleRationaleAspect put:holder.
"/       holder addDependent:self.
"/       holder onChangeSend:#ruleRationaleAspectChanged to:self.
    ].
    ^ holder.

    "Modified: / 05-02-2010 / 12:51:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LintRuleDetail methodsFor:'change & update'!

update:something with:aParameter from:changedObject
    "Invoked when an object that I depend upon sends a change notification."

    changedObject == ruleHolder ifTrue:[
	self updateVisibility.
	 ^ self.
    ].
    changedObject == rationaleVisibleHolder ifTrue:[
	self updateVisibility.
	 ^ self.
    ].
    super update:something with:aParameter from:changedObject

    "Modified: / 04-08-2011 / 21:31:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateVisibility

    self ruleHolder value notNil
	ifTrue:[self show]
	ifFalse:[self hide]

    "Created: / 04-08-2011 / 16:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LintRuleDetail methodsFor:'private'!

hide

    self visibility: false height: 0

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

show

    self visibility: true height: (self rationaleVisibleHolder value ifTrue:[130] ifFalse:[30])

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

visibility: visibility height: height
    | container list detail h |
    (container := self window container) ifNil:[^self].
    h := visibility ifFalse:[0] ifTrue:[height].

    container isVisible == visibility ifFalse:
	[container isVisible: visibility].


    list := container container subViews first.
    detail := container container subViews second.

    (list layout bottomOffset ~= height negated) ifTrue:
	[list layout:
	    (list layout bottomOffset: height negated; yourself)].
    (detail layout topOffset ~= height negated) ifTrue:
	[detail layout:
	    (detail layout topOffset: height negated; yourself)].

    "Created: / 11-03-2010 / 09:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LintRuleDetail methodsFor:'initialization'!

setupHTMLView:aView
    aView painter
	leftMargin:20;
	topMargin:5.

    "Created: / 04-08-2011 / 18:00:36 / cg"

! !

!LintRuleDetail class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleDetail.st,v 1.5 2011-08-05 06:37:04 cg Exp $'
!

version_SVN
    ^ '§Id: Tools__LintRuleDetail.st 7617 2010-08-25 12:56:19Z vranyj1 §'
! !