Tools__Inspector2.st
branchjv
changeset 13647 c79b566b32bd
parent 13289 cc75e3cd0362
child 15566 184cea584be5
--- a/Tools__Inspector2.st	Thu Oct 17 01:47:13 2013 +0100
+++ b/Tools__Inspector2.st	Sat Oct 26 01:22:46 2013 +0100
@@ -16,8 +16,9 @@
 ApplicationModel subclass:#Inspector2
 	instanceVariableNames:'tabViewAspect navigationHistoryHolder navigationStateAspect
 		browser currentObjectHolder colorProfileHolder
-		toolbarBackgroundHolder'
-	classVariableNames:'LastExtent ColorProfiles'
+		toolbarBackgroundHolder evaluationLanguageHolder
+		evaluationLanguageList'
+	classVariableNames:'LastExtent ColorProfiles EvaluationLanguageMap'
 	poolDictionaries:''
 	category:'Interface-Inspector2'
 !
@@ -71,10 +72,11 @@
         at: #green put: Color green lighter;
         at: #blue put: Color blue lighter;
         at: #yellow put: Color yellow lighter;
-        at: #gray put: Color gray;
-        yourself.
+        at: #gray put: Color gray.       
 
-    "Modified: / 17-01-2012 / 12:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    EvaluationLanguageMap :=  Dictionary new.
+
+    "Modified: / 26-10-2013 / 00:42:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !Inspector2 class methodsFor:'help specs'!
@@ -138,6 +140,9 @@
 #colorProfile
 ''
 
+#evaluationLanguage
+'Language used for evaluating expressions in code panes'
+
 )
 ! !
 
@@ -371,41 +376,51 @@
     <resource: #canvas>
 
     ^ 
-     #(FullSpec
-        name: windowSpec
-        window: 
-       (WindowSpec
-          label: 'Inspector2'
-          name: 'Inspector2'
-          labelChannel: windowTitleAspect
-          min: (Point 0 0)
-          bounds: (Rectangle 0 0 388 421)
-          menu: mainMenu
-        )
-        component: 
-       (SpecCollection
-          collection: (
-           (MenuPanelSpec
-              name: 'ToolBar'
-              layout: (LayoutFrame 0 0 0 0 0 1 40 0)
-              backgroundChannel: toolbarBackgroundHolder
-              menu: toolbarMenu
-              textDefault: true
-            )
-           (NoteBookViewSpec
-              name: 'NoteBook'
-              layout: (LayoutFrame 0 0 40 0 0 1 0 1)
-              model: tabSelectionIndexAspect
-              menu: tabLabelsAspect
-              useIndex: true
-              fitLastRow: false
-              canvas: tabViewAspect
-              keepCanvasAlive: true
-            )
+    #(FullSpec
+       name: windowSpec
+       window: 
+      (WindowSpec
+         label: 'Inspector2'
+         name: 'Inspector2'
+         labelChannel: windowTitleAspect
+         min: (Point 0 0)
+         bounds: (Rectangle 0 0 490 654)
+         menu: mainMenu
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (MenuPanelSpec
+             name: 'ToolBar'
+             layout: (LayoutFrame 0 0 0 0 0 1 40 0)
+             backgroundChannel: toolbarBackgroundHolder
+             menu: toolbarMenu
+             textDefault: true
            )
-         
-        )
-      )
+          (NoteBookViewSpec
+             name: 'NoteBook'
+             layout: (LayoutFrame 0 0 40 0 0 1 0 1)
+             model: tabSelectionIndexAspect
+             menu: tabLabelsAspect
+             useIndex: true
+             fitLastRow: false
+             canvas: tabViewAspect
+             keepCanvasAlive: true
+           )
+          (ComboListSpec
+             name: 'EvaluationLanguageCombo'
+             layout: (LayoutFrame -200 1 7 0.0 -40 1 32 0)
+             activeHelpKey: evaluationLanguage
+             visibilityChannel: evaluationLanguageComboVisibleHolder
+             model: evaluationLanguageHolder
+             comboList: evaluationLanguageList
+             useIndex: false
+             postBuildCallback: postBuildEvaluationLanguageCombo:
+           )
+          )
+        
+       )
+     )
 ! !
 
 !Inspector2 class methodsFor:'menu specs'!
@@ -781,12 +796,14 @@
 
 currentObjectHolder
     currentObjectHolder isNil ifTrue:[
-        currentObjectHolder := ValueHolder new
+        currentObjectHolder := ValueHolder new.
+        currentObjectHolder addDependent: self.
     ].
     ^ currentObjectHolder
 
     "Created: / 27-02-2008 / 12:05:22 / janfrog"
     "Created: / 19-08-2011 / 08:58:48 / cg"
+    "Modified: / 26-10-2013 / 00:34:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 currentObjectIsFilename
@@ -805,6 +822,58 @@
     "Created: / 15-01-2012 / 10:06:28 / cg"
 !
 
+evaluationLanguageComboVisibleHolder
+    <resource: #uiAspect>
+
+    "/ Do not show language combo when language is Smalltalk.
+    "/ For those not working with multiple languages is too disturbing.
+    ^ BlockValue
+        with:[:o | o class programmingLanguage isSmalltalk not ]
+        argument:self currentObjectHolder
+
+    "Modified (comment): / 25-10-2013 / 19:39:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+evaluationLanguageHolder
+    <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 ;-)"
+
+    evaluationLanguageHolder isNil ifTrue:[
+        evaluationLanguageHolder := ValueHolder new.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+       evaluationLanguageHolder addDependent:self.
+"/       evaluationLanguageHolder onChangeSend:#evaluationLanguageHolderChanged to:self.
+    ].
+    ^ evaluationLanguageHolder.
+
+    "Modified: / 26-10-2013 / 00:43:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+evaluationLanguageList
+    <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 ;-)"
+
+    evaluationLanguageList isNil ifTrue:[
+        evaluationLanguageList := ValueHolder new.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+"/       evaluationLanguageList addDependent:self.
+"/       evaluationLanguageList onChangeSend:#evaluationLanguageListChanged to:self.
+    ].
+    ^ evaluationLanguageList.
+!
+
 expandArraysInAllList
     ^ InspectorView expandArraysInAllLists
 
@@ -908,6 +977,54 @@
     "Modified: / 27-02-2008 / 12:05:56 / janfrog"
 ! !
 
+!Inspector2 methodsFor:'change & update'!
+
+update:something with:aParameter from:changedObject
+    "Invoked when an object that I depend upon sends a change notification."
+
+    "stub code automatically generated - please change as required"
+
+    changedObject == currentObjectHolder ifTrue:[
+         self updateEvaluationLanguageList.
+         ^ self.
+    ].
+    changedObject == evaluationLanguageHolder  ifTrue:[
+         self updateEvaluationLanguage.
+         ^ self.
+    ].  
+    super update:something with:aParameter from:changedObject
+
+    "Modified: / 26-10-2013 / 00:44:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateEvaluationLanguage
+    | evaluationLanguage |
+
+    evaluationLanguage :=  self evaluationLanguageHolder value.
+    "/ Remember user's selection for future...
+    EvaluationLanguageMap at: self currentObject class programmingLanguage put: evaluationLanguage.
+    "/ Update compiler class in all inspectors...
+    self setDoItActionForLanguage: evaluationLanguage.
+
+    "Created: / 26-10-2013 / 00:36:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateEvaluationLanguageList
+    | currentObject currentObjectLanguage |
+
+    currentObject := self currentObject.
+    currentObjectLanguage := currentObject class programmingLanguage.
+    currentObjectLanguage isSmalltalk ifFalse:[
+        self evaluationLanguageList value: (Array with: currentObjectLanguage with: SmalltalkLanguage instance)
+    ] ifTrue:[
+        self evaluationLanguageList value: (Array with: currentObjectLanguage).
+    ].
+
+    self evaluationLanguageHolder value:(EvaluationLanguageMap at: currentObjectLanguage ifAbsent:[currentObjectLanguage])
+
+    "Created: / 26-10-2013 / 00:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !Inspector2 methodsFor:'configuration'!
 
 hideHashes:aBoolean
@@ -932,6 +1049,14 @@
     #todo
 ! !
 
+!Inspector2 methodsFor:'hooks'!
+
+postBuildEvaluationLanguageCombo: aComboBoxView
+"/    aComboBoxView font: (aComboBoxView font asSize: (aComboBoxView font size * 1.5) rounded)
+
+    "Modified: / 26-10-2013 / 01:00:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !Inspector2 methodsFor:'menu'!
 
 backButtonMenuChannel
@@ -1116,6 +1241,36 @@
     "Created: / 15-07-2011 / 16:25:42 / cg"
 ! !
 
+!Inspector2 methodsFor:'private'!
+
+setDoItActionForLanguage: language
+
+
+    self currentState tabViews do:[:view | 
+        (view respondsTo: #workspace) ifTrue:[
+            view workspace doItAction: 
+                [:theCode |
+                    |evaluator|
+
+                    (evaluator := language evaluatorClass)
+                    notNil ifTrue:[
+                        evaluator
+                            evaluate:theCode 
+                            in:nil 
+                            receiver:self currentObject 
+                            notifying:view workspace 
+                            logged:true 
+                            ifFail:nil
+                    ] ifFalse:[
+                        'object''s class provides no evaluator'
+                    ]
+                ].
+        ].
+    ]
+
+    "Created: / 26-10-2013 / 01:13:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 
 !Inspector2::NavigationState class methodsFor:'creating classes'!