class: Tools::LintRuleSettingsApplication
changed: #doEdit
explicitly set modified after editing a rule
"
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 }"
AbstractSettingsApplication subclass:#LintRuleSettingsApplication
instanceVariableNames:'rulesetList rulesetSelectionHolder hasSelectionHolder'
classVariableNames:'LastFileName'
poolDictionaries:''
category:'Interface-Lint'
!
!LintRuleSettingsApplication 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.
"
! !
!LintRuleSettingsApplication class methodsFor:'class initialization'!
initialize
Smalltalk addStartBlock:[
NewLauncher
addSettingsApplicationByClass: self name
withName: 'Tools/SmallLint'
icon: nil.
]
"Created: / 04-02-2012 / 21:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 27-02-2013 / 22:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication class methodsFor:'interface opening'!
open
| settingsApp |
settingsApp := SettingsDialog new.
settingsApp addApplClass:self fullName
withName:'SmallLint Rules'.
settingsApp showRoot: false.
settingsApp selectedItem value:
(settingsApp applicationList root children anyOne).
settingsApp open.
"Created: / 26-05-2008 / 12:17:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
"Modified: / 27-02-2013 / 11:25:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication 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::LintRuleSettingsApplication andSelector:#windowSpec
Tools::LintRuleSettingsApplication new openInterface:#windowSpec
Tools::LintRuleSettingsApplication open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'Profiles'
name: 'Profiles'
min: (Point 10 10)
bounds: (Rectangle 0 0 782 552)
)
component:
(SpecCollection
collection: (
(LabelSpec
label: 'Predefined SmallLint Rule Sets'
name: 'Label'
layout: (LayoutFrame 0 0 35 0 0 1 65 0)
translateLabel: true
adjust: left
)
(SelectionInListModelViewSpec
name: 'ProfileList'
layout: (LayoutFrame 0 0 65 0 -100 1 0 1)
enableChannel: svnEnabled
model: rulesetSelectionHolder
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
listModel: rulesetList
useIndex: false
highlightMode: line
doubleClickSelector: doEdit
)
(VerticalPanelViewSpec
name: 'Buttons1'
layout: (LayoutFrame -95 1 65 0 0 1 0 0.7)
horizontalLayout: fit
verticalLayout: top
horizontalSpace: 5
verticalSpace: 3
component:
(SpecCollection
collection: (
(ActionButtonSpec
label: 'Add'
name: 'ButtonAdd'
translateLabel: true
model: doAdd
extent: (Point 95 22)
)
(ActionButtonSpec
label: 'Copy'
name: 'ButtonCopy'
translateLabel: true
model: doCopy
enableChannel: canCopyHolder
extent: (Point 95 22)
)
(ActionButtonSpec
label: 'Edit'
name: 'ButtonEdit'
translateLabel: true
model: doEdit
enableChannel: canEditHolder
extent: (Point 95 22)
)
(ActionButtonSpec
label: 'Remove'
name: 'ButtonRemove'
translateLabel: true
model: doRemove
enableChannel: canRemoveHolder
extent: (Point 95 22)
)
)
)
)
(VerticalPanelViewSpec
name: 'Buttons2'
layout: (LayoutFrame -95 1 0 0.7 0 1 0 1)
horizontalLayout: fit
verticalLayout: bottom
horizontalSpace: 5
verticalSpace: 3
component:
(SpecCollection
collection: (
(ActionButtonSpec
label: 'Export'
name: 'Button2'
translateLabel: true
model: doExport
enableChannel: canExportHolder
extent: (Point 95 22)
)
(ActionButtonSpec
label: 'Import'
name: 'Button3'
translateLabel: true
model: doImport
extent: (Point 95 22)
)
)
)
)
)
)
)
"Modified: / 28-02-2013 / 10:03:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication methodsFor:'accessing'!
selection
^self selectionHolder value
"Created: / 25-08-2010 / 14:10:03 / Jan Vrany <enter your email here>"
!
selection: anObject
self selectionHolder value: anObject
"Created: / 25-08-2010 / 14:09:40 / Jan Vrany <enter your email here>"
! !
!LintRuleSettingsApplication methodsFor:'actions'!
doAdd
<resource: #uiCallback>
self doAdd: RBCompositeLintRule new
"Modified: / 27-02-2013 / 11:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doAdd: anRBCompositeLintRule
anRBCompositeLintRule name isNil ifTrue:[
anRBCompositeLintRule name: 'New Rule Set ' , (self rulesetList size + 1) printString
].
self rulesetList add: anRBCompositeLintRule.
self rulesetSelectionHolder value: anRBCompositeLintRule.
self updateModifiedChannel.
self doEdit.
"Created: / 27-02-2013 / 11:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doCopy
<resource: #uiCallback>
| ruleset |
ruleset := self rulesetSelectionHolder value deepCopy.
ruleset name: ruleset name , ' (copy)'.
self doAdd: ruleset
"Modified: / 27-02-2013 / 11:30:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doEdit
<resource: #uiCallback>
| rule |
rule := self rulesetSelectionHolder value.
LintRuleEditDialog new
rule: rule deepCopy;
open.
"/ does not work (are we editing the original, so that the compare does never work?)
self modifiedChannel value:true.
"/ self updateModifiedChannel
"Modified: / 27-02-2013 / 11:57:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doExport
<resource: #uiCallback>
| file |
file := Dialog requestFileName: (resources string: 'Select file') default: (LastFileName ? Filename currentDirectory / 'exported-ruleset.st').
file isEmptyOrNil ifTrue:[ ^ self ].
self shouldImplement
"Modified: / 27-02-2013 / 23:53:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doImport
<resource: #uiCallback>
"automatically generated by UIPainter..."
"*** the code below performs no action"
"*** (except for some feedback on the Transcript)"
"*** Please change as required and accept in the browser."
"*** (and replace this comment by something more useful ;-)"
"action to be defined here..."
Transcript showCR:self class name, ': action for doImport ...'.
!
doRemove
<resource: #uiCallback>
| rule idx |
rule := self rulesetSelectionHolder value.
idx := self rulesetList indexOf: rule.
idx ~~ 0 ifTrue:[
self rulesetList remove: rule.
self rulesetList size > 0 ifTrue:[
self rulesetSelectionHolder value: (self rulesetList at: ((idx -1 ) max: 1))
]
].
self updateModifiedChannel
"Modified: / 27-02-2013 / 11:57:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication methodsFor:'aspects'!
canCopyHolder
^self hasSelectionHolder
"Created: / 27-02-2013 / 11:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
canEditHolder
^self hasSelectionHolder
"Created: / 27-02-2013 / 11:24:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
canExportHolder
^self hasSelectionHolder
"Created: / 27-02-2013 / 11:24:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
canRemoveHolder
^self hasSelectionHolder
"Created: / 27-02-2013 / 11:24:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
hasSelectionHolder
"return/create the 'hasSelectionHolder' value holder (automatically generated)"
hasSelectionHolder isNil ifTrue:[
hasSelectionHolder := (AspectAdaptor forAspect: #notNil) subjectChannel: self rulesetSelectionHolder
].
^ hasSelectionHolder
"Modified: / 27-02-2013 / 11:24:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
rulesetList
"return/create the 'rulesetList' value holder (automatically generated)"
rulesetList isNil ifTrue:[
rulesetList := List new.
].
^ rulesetList
"Modified: / 27-02-2013 / 11:14:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
rulesetSelectionHolder
"return/create the 'rulesetSelectionHolder' value holder (automatically generated)"
rulesetSelectionHolder isNil ifTrue:[
rulesetSelectionHolder := ValueHolder new.
].
^ rulesetSelectionHolder
! !
!LintRuleSettingsApplication methodsFor:'protocol'!
basicReadSettings
"superclass AbstractSettingsApplication says that I am responsible to implement this method"
RBCompositeLintRule notNil ifTrue:[
self rulesetList removeAll; addAll: RBCompositeLintRule rulesets
].
"Modified: / 27-02-2013 / 11:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
basicSaveSettings
"superclass AbstractSettingsApplication says that I am responsible to implement this method"
RBCompositeLintRule rulesets: self rulesetList asOrderedCollection
"Modified: / 27-02-2013 / 11:16:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
helpFilename
"subclasses must return the relative name of a helpFile
in the doc/online/<language>/help directory.
Or nil, if no help is available."
^ nil
"Modified: / 27-02-2013 / 11:16:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication methodsFor:'queries'!
hasUnsavedChanges
"superclass AbstractSettingsApplication says that I am responsible to implement this method"
RBCompositeLintRule isNil ifTrue:[^ false].
SequenceableCollection missingClassInLiteralArrayErrorSignal handle:[:ex |
"/ maybe we have to load additional packages...
(Smalltalk isPackageLoaded:'stx:goodies/refactoryBrowser/lint/spelling') ifFalse:[
Smalltalk loadPackage:'stx:goodies/refactoryBrowser/lint/spelling'.
ex restart.
].
ex reject.
] do:[
^ RBCompositeLintRule rulesets asArray ~= self rulesetList asArray
].
"Modified: / 28-02-2013 / 10:03:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LintRuleSettingsApplication class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.4 2014-02-26 12:57:03 cg Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.4 2014-02-26 12:57:03 cg Exp $'
! !
LintRuleSettingsApplication initialize!