LintRuleSelectionDialog refactored to show a list of configured rulesets.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 13 Oct 2014 22:09:35 +0200
changeset 14758 214db44dab86
parent 14757 6b6d158a629b
child 14759 47e9d7d9bfed
LintRuleSelectionDialog refactored to show a list of configured rulesets.
Tools__LintRuleSelectionDialog.st
--- a/Tools__LintRuleSelectionDialog.st	Mon Oct 13 19:45:17 2014 +0200
+++ b/Tools__LintRuleSelectionDialog.st	Mon Oct 13 22:09:35 2014 +0200
@@ -30,7 +30,7 @@
 SimpleDialog subclass:#LintRuleSelectionDialog
 	instanceVariableNames:'selectionHolder variablePanel relativeCorners detailsShown
 		listSelection rulesetList rulesetHolder rulesetNameList
-		rulesetNameHolder'
+		rulesetNameHolder canAcceptHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Lint'
@@ -123,6 +123,98 @@
          label: 'Select Lint Rules'
          name: 'Select Lint Rules'
          min: (Point 10 10)
+         bounds: (Rectangle 0 0 466 403)
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (LinkButtonSpec
+             label: 'Configure Rule Sets...'
+             name: 'Button1'
+             layout: (LayoutFrame -250 1 0 0 -3 1 24 0)
+             translateLabel: true
+             labelChannel: configureRulesetsButtonLabel
+             adjust: right
+             model: doConfigureRulesets
+           )
+          (HorizontalPanelViewSpec
+             name: 'BottonPanel'
+             layout: (LayoutFrame 0 0.0 -40 1 0 1.0 0 1)
+             horizontalLayout: right
+             verticalLayout: center
+             horizontalSpace: 3
+             verticalSpace: 3
+             reverseOrderIfOKAtLeft: true
+             component: 
+            (SpecCollection
+               collection: (
+                (ActionButtonSpec
+                   label: 'Cancel'
+                   name: 'CancelButton'
+                   translateLabel: true
+                   model: doCancel
+                   extent: (Point 120 25)
+                 )
+                (ActionButtonSpec
+                   label: 'OK'
+                   name: 'OKButton'
+                   translateLabel: true
+                   model: doAccept
+                   enableChannel: canAcceptHolder
+                   isDefault: true
+                   defaultable: true
+                   extent: (Point 120 25)
+                 )
+                )
+              
+             )
+           )
+          (LabelSpec
+             label: 'Select Ruleset'
+             name: 'Label1'
+             layout: (LayoutFrame 3 0 0 0 -250 1 24 0)
+             translateLabel: true
+             adjust: left
+           )
+          (SelectionInListModelViewSpec
+             name: 'SelectionInListModelView1'
+             layout: (LayoutFrame 3 0 30 0 -3 1 -40 1)
+             model: rulesetHolder
+             hasHorizontalScrollBar: true
+             hasVerticalScrollBar: true
+             listModel: rulesetList
+             useIndex: false
+             highlightMode: line
+           )
+          )
+        
+       )
+     )
+!
+
+windowSpec_old
+    "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::LintRuleSelectionDialog andSelector:#windowSpec
+     Tools::LintRuleSelectionDialog new openInterface:#windowSpec
+     Tools::LintRuleSelectionDialog open
+    "
+
+    <resource: #canvas>
+
+    ^ 
+    #(FullSpec
+       name: windowSpec
+       window: 
+      (WindowSpec
+         label: 'Select Lint Rules'
+         name: 'Select Lint Rules'
+         min: (Point 10 10)
          bounds: (Rectangle 0 0 600 400)
        )
        component: 
@@ -239,6 +331,8 @@
         
        )
      )
+
+    "Created: / 13-10-2014 / 20:40:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !LintRuleSelectionDialog methodsFor:'accessing'!
@@ -282,6 +376,18 @@
     "Created: / 08-10-2014 / 23:10:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+doEditRuleset
+    self doEditRuleset: self rulesetHolder value.
+
+    "Created: / 13-10-2014 / 21:06:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doEditRuleset: anRBCompositeLintRule
+    ^ self shouldImplement
+
+    "Created: / 13-10-2014 / 21:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 hideResultView
 
     detailsShown == true ifFalse:[^self].
@@ -319,13 +425,35 @@
     "Created: / 15-04-2010 / 20:09:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+canAcceptHolder
+    <resource: #uiAspect>
+
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+    "*** (and replace this comment by something more useful ;-)"
+
+    canAcceptHolder isNil ifTrue:[
+        canAcceptHolder := false asValue.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+"/       canAcceptHolder addDependent:self.
+"/       canAcceptHolder onChangeSend:#canAcceptHolderChanged to:self.
+    ].
+    ^ canAcceptHolder.
+
+    "Modified: / 13-10-2014 / 21:05:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 configureRulesetsButtonLabel
-    ^'Configure Rule Sets...' asText
+    ^'Configure...' asText
         colorizeAllWith: Color blue;
         actionForAll:[ self doConfigureRulesets ];
         yourself
 
     "Created: / 08-10-2014 / 23:10:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-10-2014 / 20:55:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 listSelection
@@ -415,12 +543,15 @@
     "return/create the 'rulesetNameHolder' value holder (automatically generated)"
 
     rulesetNameHolder isNil ifTrue:[
-        rulesetNameHolder := self rulesetHolder value name asValue.
+        | ruleset |
+
+        ruleset := self rulesetHolder value.
+        rulesetNameHolder := ValueHolder with: (ruleset notNil ifTrue:[ ruleset displayString ] ifFalse:[ nil ]).
         rulesetNameHolder addDependent:self.
     ].
     ^ rulesetNameHolder
 
-    "Modified: / 27-02-2013 / 23:42:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-10-2014 / 20:49:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 rulesetNameHolder:something
@@ -487,8 +618,18 @@
          ^ self.
     ].
     changedObject == rulesetHolder ifTrue:[
-        self rulesetNameHolder value: self rulesetHolder value name.
-        self selection: self rulesetHolder value flattened.
+        | ruleset |
+
+        ruleset := self rulesetHolder value.
+        ruleset notNil ifTrue:[
+            self rulesetNameHolder value: ruleset value name withoutNotifying: self.
+            self selection: ruleset value flattened.
+            self canAcceptHolder value: true.
+        ] ifFalse:[ 
+            self rulesetNameHolder value: nil withoutNotifying: self.
+            self selection: nil.
+            self canAcceptHolder value: false.
+        ].
          ^ self.
     ].
     changedObject == rulesetNameHolder ifTrue:[
@@ -497,7 +638,7 @@
     ].
     super update:something with:aParameter from:changedObject
 
-    "Modified: / 27-02-2013 / 23:27:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-10-2014 / 21:05:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 updateRulesetHolder
@@ -526,32 +667,35 @@
 updateRulesetNameList
 
     self rulesetNameList value: 
-        ((self rulesetList collect:[:e|e name])
-            add: 'New Ruleset...' asText allItalic;
+        ((self rulesetList collect:[:e|e displayString])
+"/            add: 'New Ruleset...' asText allItalic;
             yourself)
 
     "Created: / 27-02-2013 / 23:08:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-10-2014 / 20:46:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !LintRuleSelectionDialog methodsFor:'hooks'!
 
 commonPostBuild
     self updateRulesetNameList.
+    self canAcceptHolder value: self rulesetHolder value notNil
 
     "Created: / 27-02-2013 / 23:10:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-10-2014 / 21:05:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !LintRuleSelectionDialog class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSelectionDialog.st,v 1.7 2014-10-08 22:58:27 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSelectionDialog.st,v 1.8 2014-10-13 20:09:35 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSelectionDialog.st,v 1.7 2014-10-08 22:58:27 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSelectionDialog.st,v 1.8 2014-10-13 20:09:35 vrany Exp $'
 !
 
 version_SVN
-    ^ '$Id: Tools__LintRuleSelectionDialog.st,v 1.7 2014-10-08 22:58:27 vrany Exp $'
+    ^ '$Id: Tools__LintRuleSelectionDialog.st,v 1.8 2014-10-13 20:09:35 vrany Exp $'
 ! !