"
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 -128 1 0 1)
enableChannel: svnEnabled
model: rulesetSelectionHolder
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
listModel: rulesetList
useIndex: false
highlightMode: line
doubleClickSelector: doEdit
)
(VerticalPanelViewSpec
name: 'Buttons1'
layout: (LayoutFrame -124 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 124 22)
)
(ActionButtonSpec
label: 'Copy'
name: 'ButtonCopy'
translateLabel: true
model: doCopy
enableChannel: canCopyHolder
extent: (Point 124 22)
)
(ActionButtonSpec
label: 'Edit'
name: 'ButtonEdit'
translateLabel: true
model: doEdit
enableChannel: canEditHolder
extent: (Point 124 22)
)
(ActionButtonSpec
label: 'Remove'
name: 'ButtonRemove'
translateLabel: true
model: doRemove
enableChannel: canRemoveHolder
extent: (Point 124 22)
)
)
)
)
(VerticalPanelViewSpec
name: 'Buttons2'
layout: (LayoutFrame -124 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 124 22)
)
(ActionButtonSpec
label: 'Import'
name: 'Button3'
translateLabel: true
model: doImport
extent: (Point 124 22)
)
)
)
)
)
)
)
! !
!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>
| ruleset |
ruleset := RBCompositeLintRule new.
ruleset name: 'New Rule Set ' , (self rulesetList size + 1) printString.
self doAdd: ruleset
"Modified: / 14-10-2014 / 16:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doAdd: anRBCompositeLintRule
| dialog |
dialog := LintRuleEditDialog new.
dialog rule: anRBCompositeLintRule.
dialog open.
dialog accepted ifTrue:[
self rulesetList add: anRBCompositeLintRule.
self rulesetSelectionHolder value: anRBCompositeLintRule.
self updateModifiedChannel.
].
"Created: / 27-02-2013 / 11:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 14-10-2014 / 16:29:47 / 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>
self doEdit: self rulesetSelectionHolder value.
"Modified: / 14-10-2014 / 16:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doEdit: rule
| edited dialog |
dialog := LintRuleEditDialog new.
dialog nameEditableHolder value: false.
edited := rule deepCopy.
dialog rule: edited.
dialog open.
dialog accepted ifTrue:[
rule name: edited name.
rule rules: edited rules.
self updateModifiedChannel.
].
"Created: / 14-10-2014 / 16:47:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 16-10-2014 / 11:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doExport
<resource: #uiCallback>
| file |
DIalog warn: 'Not yet implemented'.
^ self.
file := Dialog requestFileName: (resources string: 'Select file') default: (LastFileName ? Filename currentDirectory / 'exported-ruleset.st').
file isEmptyOrNil ifTrue:[ ^ self ].
self shouldImplement
"Modified: / 14-10-2014 / 16:33:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doImport
<resource: #uiCallback>
Dialog warn: 'Not yet implemented'
"Modified: / 14-10-2014 / 16:33:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
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 rulesetsUserDefined deepCopy
].
"Modified: / 14-10-2014 / 17:40:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
basicSaveSettings
| oldRulesets newRulesets toRemove toAdd |
oldRulesets := RBCompositeLintRule rulesetsUserDefined.
newRulesets := self rulesetList.
toAdd := OrderedCollection withAll: newRulesets.
toRemove := Set new.
RBCompositeLintRule rulesetsUserDefined do:[:oldRuleset |
| newRuleset |
newRuleset := newRulesets detect:[:each | each name = oldRuleset name ] ifNone: nil.
newRuleset isNil ifTrue:[
toRemove add: oldRuleset.
] ifFalse:[
toAdd remove: newRuleset.
oldRuleset rules: newRuleset rules.
].
].
oldRulesets removeAll:toRemove.
oldRulesets addAll:toAdd.
"Modified: / 14-10-2014 / 17:51:11 / 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 rulesetsUserDefined 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.9 2014-10-16 10:52:14 vrany Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.9 2014-10-16 10:52:14 vrany Exp $'
! !
LintRuleSettingsApplication initialize!