Sfoglia il codice sorgente

Fixed display reaction to instVar selection

Sebastian Sastre 11 anni fa
parent
commit
7e9d191718
3 ha cambiato i file con 77 aggiunte e 24 eliminazioni
  1. 24 5
      js/Helios-Inspector.deploy.js
  2. 37 13
      js/Helios-Inspector.js
  3. 16 6
      st/Helios-Inspector.st

+ 24 - 5
js/Helios-Inspector.deploy.js

@@ -511,11 +511,31 @@ smalltalk.method({
 selector: "renderContentOn:",
 fn: function (html){
 var self=this;
-smalltalk.send(smalltalk.send(html,"_div",[]),"_with_",[smalltalk.send(smalltalk.send(self["@model"],"_selectedInstVarObject",[]),"_printString",[])]);
+smalltalk.send(smalltalk.send(html,"_div",[]),"_with_",[smalltalk.send(self,"_selectionDisplayString",[])]);
 return self}
 }),
 smalltalk.HLInspectorDisplay);
 
+smalltalk.addMethod(
+"_selectionDisplayString",
+smalltalk.method({
+selector: "selectionDisplayString",
+fn: function (){
+var self=this;
+var $2,$1;
+var selection;
+selection=smalltalk.send(self["@model"],"_selection",[]);
+$2=smalltalk.send(smalltalk.send(smalltalk.send(self["@model"],"_variables",[]),"_keys",[]),"_includes_",[selection]);
+if(smalltalk.assert($2)){
+$1=smalltalk.send(smalltalk.send(self["@model"],"_instVarObjectAt_",[selection]),"_printString",[]);
+} else {
+$1="";
+};
+return $1;
+}
+}),
+smalltalk.HLInspectorDisplay);
+
 
 
 smalltalk.addClass('HLInspectorModel', smalltalk.Object, ['announcer', 'environment', 'inspectee', 'code', 'variables', 'selection'], 'Helios-Inspector');
@@ -651,7 +671,7 @@ selector: "initializeSelection",
 fn: function (){
 var self=this;
 var $1;
-self["@selection"]=smalltalk.send(self,"_inspectee",[]);
+self["@selection"]="";
 $1=self["@selection"];
 return $1;
 }
@@ -738,10 +758,9 @@ smalltalk.addMethod(
 "_selectedInstVar_",
 smalltalk.method({
 selector: "selectedInstVar:",
-fn: function (anInstVarObject){
+fn: function (anInstVarName){
 var self=this;
-smalltalk.send(self,"_halt",[]);
-smalltalk.send(self,"_selection_",[smalltalk.send(smalltalk.send(self,"_variables",[]),"_keyAtValue_",[anInstVarObject])]);
+smalltalk.send(self,"_selection_",[anInstVarName]);
 return self}
 }),
 smalltalk.HLInspectorModel);

+ 37 - 13
js/Helios-Inspector.js

@@ -702,11 +702,36 @@ selector: "renderContentOn:",
 category: 'rendering',
 fn: function (html){
 var self=this;
-smalltalk.send(smalltalk.send(html,"_div",[]),"_with_",[smalltalk.send(smalltalk.send(self["@model"],"_selectedInstVarObject",[]),"_printString",[])]);
+smalltalk.send(smalltalk.send(html,"_div",[]),"_with_",[smalltalk.send(self,"_selectionDisplayString",[])]);
 return self},
 args: ["html"],
-source: "renderContentOn: html\x0a\x09\x0a    html div with: model selectedInstVarObject printString\x0a    ",
-messageSends: ["with:", "printString", "selectedInstVarObject", "div"],
+source: "renderContentOn: html\x0a\x09\x0a    html div with: self selectionDisplayString\x0a    ",
+messageSends: ["with:", "selectionDisplayString", "div"],
+referencedClasses: []
+}),
+smalltalk.HLInspectorDisplay);
+
+smalltalk.addMethod(
+"_selectionDisplayString",
+smalltalk.method({
+selector: "selectionDisplayString",
+category: 'rendering',
+fn: function (){
+var self=this;
+var $2,$1;
+var selection;
+selection=smalltalk.send(self["@model"],"_selection",[]);
+$2=smalltalk.send(smalltalk.send(smalltalk.send(self["@model"],"_variables",[]),"_keys",[]),"_includes_",[selection]);
+if(smalltalk.assert($2)){
+$1=smalltalk.send(smalltalk.send(self["@model"],"_instVarObjectAt_",[selection]),"_printString",[]);
+} else {
+$1="";
+};
+return $1;
+},
+args: [],
+source: "selectionDisplayString\x0a\x09|selection|\x0a\x09selection := model selection.\x0a    ^ (model variables keys includes: selection)\x0a    \x09ifTrue:[(model instVarObjectAt: selection) printString]\x0a      \x09ifFalse:['']",
+messageSends: ["selection", "ifTrue:ifFalse:", "printString", "instVarObjectAt:", "includes:", "keys", "variables"],
 referencedClasses: []
 }),
 smalltalk.HLInspectorDisplay);
@@ -892,13 +917,13 @@ category: 'initialization',
 fn: function (){
 var self=this;
 var $1;
-self["@selection"]=smalltalk.send(self,"_inspectee",[]);
+self["@selection"]="";
 $1=self["@selection"];
 return $1;
 },
 args: [],
-source: "initializeSelection\x0a\x0a\x09^ selection := self inspectee",
-messageSends: ["inspectee"],
+source: "initializeSelection\x0a\x0a\x09^ selection := ''",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.HLInspectorModel);
@@ -1009,14 +1034,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "selectedInstVar:",
 category: 'actions',
-fn: function (anInstVarObject){
+fn: function (anInstVarName){
 var self=this;
-smalltalk.send(self,"_halt",[]);
-smalltalk.send(self,"_selection_",[smalltalk.send(smalltalk.send(self,"_variables",[]),"_keyAtValue_",[anInstVarObject])]);
+smalltalk.send(self,"_selection_",[anInstVarName]);
 return self},
-args: ["anInstVarObject"],
-source: "selectedInstVar: anInstVarObject\x0a    self halt.\x0a\x09self selection: (self variables keyAtValue: anInstVarObject)",
-messageSends: ["halt", "selection:", "keyAtValue:", "variables"],
+args: ["anInstVarName"],
+source: "selectedInstVar: anInstVarName\x0a\x0a    self selection: anInstVarName\x0a\x0a\x09\x22self selection: (self variables keyAtValue: anInstVarObject)\x22",
+messageSends: ["selection:"],
 referencedClasses: []
 }),
 smalltalk.HLInspectorModel);
@@ -1315,7 +1339,7 @@ smalltalk.send(self,"_selectItem_",[anObject],smalltalk.HLNavigationListWidget);
 smalltalk.send(smalltalk.send(self,"_model",[]),"_selectedInstVar_",[anObject]);
 return self},
 args: ["anObject"],
-source: "selectItem: anObject\x0a\x0a\x09super selectItem: anObject.\x0a    \x0a    self model selectedInstVar: anObject",
+source: "selectItem: anObject\x0a\x09   \x0a\x09super selectItem: anObject.\x0a    \x0a    self model selectedInstVar: anObject",
 messageSends: ["selectItem:", "selectedInstVar:", "model"],
 referencedClasses: []
 }),

+ 16 - 6
st/Helios-Inspector.st

@@ -231,7 +231,15 @@ model: aModel
 
 renderContentOn: html
 	
-    html div with: model selectedInstVarObject printString
+    html div with: self selectionDisplayString
+!
+
+selectionDisplayString
+	|selection|
+	selection := model selection.
+    ^ (model variables keys includes: selection)
+    	ifTrue:[(model instVarObjectAt: selection) printString]
+      	ifFalse:['']
 ! !
 
 Object subclass: #HLInspectorModel
@@ -322,9 +330,11 @@ instVarObjectAt: anInstVarName
 	^ self variables at: anInstVarName
 !
 
-selectedInstVar: anInstVarObject
-    self halt.
-	self selection: (self variables keyAtValue: anInstVarObject)
+selectedInstVar: anInstVarName
+
+    self selection: anInstVarName
+
+	"self selection: (self variables keyAtValue: anInstVarObject)"
 !
 
 subscribe: aWidget
@@ -348,7 +358,7 @@ initializeEnvironment
 
 initializeSelection
 
-	^ selection := self inspectee
+	^ selection := ''
 ! !
 
 !HLInspectorModel methodsFor: 'reactions'!
@@ -442,7 +452,7 @@ initializeItems
 !HLInspectorVariables methodsFor: 'reactions'!
 
 selectItem: anObject
-
+	   
 	super selectItem: anObject.
     
     self model selectedInstVar: anObject