@@ -87,10 +87,6 @@ objectExtend(TreeView.prototype, {
87
87
onEvent : function ( evt ) { }
88
88
} ;
89
89
this . tree . controllers . appendController ( controller ) ;
90
-
91
- // this.atomService = Components.classes["@mozilla.org/atom-service;1"].
92
- // getService(Components.interfaces.nsIAtomService);
93
-
94
90
this . _loadSeleniumCommands ( ) ;
95
91
} ,
96
92
@@ -123,13 +119,22 @@ objectExtend(TreeView.prototype, {
123
119
return this . clipboard ;
124
120
} ,
125
121
126
- setTextBox : function ( id , value , disabled ) {
127
- this . document . getElementById ( id ) . value = value ;
128
- this . document . getElementById ( id ) . disabled = disabled ;
122
+ updateTextBox : function ( id , value , disabled , autoComplete ) {
123
+ var e = this . document . getElementById ( id ) ;
124
+ e . value = value ;
125
+ e . disabled = disabled ;
126
+ if ( arguments . length == 4 ) {
127
+ e . disableAutoComplete = ! autoComplete ;
128
+ if ( autoComplete ) {
129
+ e . setAttribute ( "enablehistory" , 'true' ) ;
130
+ } else {
131
+ e . removeAttribute ( "enablehistory" ) ;
132
+ }
133
+ }
129
134
} ,
130
135
131
136
updateTarget : function ( value , disabled ) {
132
- this . setTextBox ( "commandTarget" , value , disabled ) ;
137
+ this . updateTextBox ( "commandTarget" , value , disabled ) ;
133
138
this . document . getElementById ( 'selectElementButton' ) . disabled = disabled ;
134
139
this . document . getElementById ( 'findElementButton' ) . disabled = disabled ;
135
140
} ,
@@ -202,21 +207,21 @@ objectExtend(TreeView.prototype, {
202
207
var command = this . currentCommand ;
203
208
var candidates = [ ] ;
204
209
var targetBox = this . document . getElementById ( "commandTarget" ) ;
205
-
206
- // various strategies for auto-populating the target field
207
- if ( command . isRollup ( ) && Editor . rollupManager ) {
208
- candidates = Editor . rollupManager . getRollupRulesForDropdown ( ) ;
209
- }
210
- else {
211
- if ( command . targetCandidates ) {
212
- candidates = candidates . concat ( command . targetCandidates ) ;
213
- }
214
- // if lastURL exists, load only those targets associated with it.
215
- // Otherwise, show all possible targets.
216
- if ( Editor . uiMap ) {
217
- candidates = candidates
218
- . concat ( Editor . uiMap . getUISpecifierStringStubs ( ) ) ;
219
- }
210
+
211
+ if ( command . type == 'command' ) {
212
+ // various strategies for auto-populating the target field
213
+ if ( command . isRollup ( ) && Editor . rollupManager ) {
214
+ candidates = Editor . rollupManager . getRollupRulesForDropdown ( ) ;
215
+ } else {
216
+ if ( command . targetCandidates ) {
217
+ candidates = candidates . concat ( command . targetCandidates ) ;
218
+ }
219
+ // if lastURL exists, load only those targets associated with it.
220
+ // Otherwise, show all possible targets.
221
+ if ( Editor . uiMap ) {
222
+ candidates = candidates . concat ( Editor . uiMap . getUISpecifierStringStubs ( ) ) ;
223
+ }
224
+ }
220
225
}
221
226
222
227
if ( candidates . length > 0 ) {
@@ -233,7 +238,7 @@ objectExtend(TreeView.prototype, {
233
238
XulUtils . toXPCOMArray ( types ) ) ;
234
239
this . updateTarget ( this . encodeText ( command . target ) , false ) ;
235
240
} else {
236
- targetBox . setAttribute ( "enablehistory" , "false ") ;
241
+ targetBox . removeAttribute ( "enablehistory" ) ;
237
242
targetBox . disableAutoComplete = true ;
238
243
this . updateTarget ( this . encodeText ( command . target ) , false ) ;
239
244
}
@@ -257,8 +262,7 @@ objectExtend(TreeView.prototype, {
257
262
args [ name ] = "" ;
258
263
keys . push ( name ) ;
259
264
}
260
- this . setTextBox ( 'commandValue' ,
261
- this . encodeText ( to_kwargs ( args , keys ) ) , false ) ;
265
+ this . updateTextBox ( 'commandValue' , this . encodeText ( to_kwargs ( args , keys ) ) , false ) ;
262
266
}
263
267
}
264
268
} ,
@@ -274,15 +278,21 @@ objectExtend(TreeView.prototype, {
274
278
} ,
275
279
276
280
encodeText : function ( text ) {
277
- text = text . replace ( / \\ / g, "\\\\" ) ;
278
- text = text . replace ( / \n / g, "\\n" ) ;
279
- return text ;
281
+ if ( text ) {
282
+ text = text . replace ( / \\ / g, "\\\\" ) ;
283
+ text = text . replace ( / \n / g, "\\n" ) ;
284
+ return text ;
285
+ }
286
+ return '' ;
280
287
} ,
281
288
282
289
decodeText : function ( text ) {
283
- text = text . replace ( / \\ n / g, "\n" ) ;
284
- text = text . replace ( / \\ \\ / g, "\\" ) ;
285
- return text ;
290
+ if ( text ) {
291
+ text = text . replace ( / \\ n / g, "\n" ) ;
292
+ text = text . replace ( / \\ \\ / g, "\\" ) ;
293
+ return text ;
294
+ }
295
+ return '' ;
286
296
} ,
287
297
288
298
/*
@@ -326,23 +336,25 @@ objectExtend(TreeView.prototype, {
326
336
var command = this . getCommand ( this . tree . currentIndex ) ;
327
337
this . currentCommand = command ;
328
338
if ( command . type == 'command' ) {
329
- this . setTextBox ( "commandAction" , command . command , false ) ;
339
+ this . updateTextBox ( "commandAction" , command . command , false , true ) ;
330
340
this . updateSeleniumTargets ( ) ;
331
- this . setTextBox ( "commandValue" , this . encodeText ( command . value ) , false ) ;
341
+ this . updateTextBox ( "commandValue" , this . encodeText ( command . value ) , false ) ;
332
342
} else if ( command . type == 'comment' ) {
333
- this . setTextBox ( "commandAction" , command . comment , false ) ;
343
+ this . updateTextBox ( "commandAction" , command . comment , false , false ) ;
334
344
this . updateTarget ( '' , true ) ;
335
- this . setTextBox ( "commandValue" , '' , true ) ;
345
+ this . updateTextBox ( "commandValue" , '' , true ) ;
336
346
}
337
-
347
+
338
348
this . selectRecordIndex ( this . tree . currentIndex ) ;
339
- this . editor . showReference ( command ) ;
340
- this . editor . showUIReference ( command . target ) ;
341
- this . editor . showRollupReference ( command ) ;
349
+ if ( command . type == 'command' ) {
350
+ this . editor . showReference ( command ) ;
351
+ this . editor . showUIReference ( command . target ) ;
352
+ this . editor . showRollupReference ( command ) ;
353
+ }
342
354
} else {
343
- this . setTextBox ( "commandAction" , '' , true ) ;
355
+ this . updateTextBox ( "commandAction" , '' , true ) ;
344
356
this . updateTarget ( '' , true ) ;
345
- this . setTextBox ( "commandValue" , '' , true ) ;
357
+ this . updateTextBox ( "commandValue" , '' , true ) ;
346
358
this . currentCommand = null ;
347
359
}
348
360
window . updateCommands ( 'select' ) ;
@@ -358,8 +370,10 @@ objectExtend(TreeView.prototype, {
358
370
if ( this . currentCommand != null ) {
359
371
this . executeAction ( new TreeView . UpdateCommandAction ( this , key , value ) ) ;
360
372
if ( key == 'command' ) {
361
- this . updateSeleniumTargets ( ) ;
362
- this . editor . showReference ( this . currentCommand ) ;
373
+ if ( this . currentCommand . type == 'command' ) {
374
+ this . updateSeleniumTargets ( ) ;
375
+ this . editor . showReference ( this . currentCommand ) ;
376
+ }
363
377
}
364
378
else if ( key == 'targetCandidates' ) {
365
379
this . updateSeleniumTargets ( ) ;
@@ -379,9 +393,9 @@ objectExtend(TreeView.prototype, {
379
393
}
380
394
} ,
381
395
onHide : function ( ) {
382
- this . setTextBox ( "commandAction" , '' , true ) ;
396
+ this . updateTextBox ( "commandAction" , '' , true ) ;
383
397
this . updateTarget ( '' , true ) ;
384
- this . setTextBox ( "commandValue" , '' , true ) ;
398
+ this . updateTextBox ( "commandValue" , '' , true ) ;
385
399
this . currentCommand = null ;
386
400
} ,
387
401
getRecordIndex : function ( ) {
@@ -646,7 +660,7 @@ TreeView.UpdateCommandAction = function(treeView, key, value) {
646
660
this . value = value ;
647
661
this . index = this . treeView . tree . currentIndex ;
648
662
this . wasNewCommand = this . command == treeView . newCommand ;
649
- }
663
+ } ;
650
664
651
665
TreeView . UpdateCommandAction . prototype = {
652
666
execute : function ( ) {
@@ -689,12 +703,12 @@ TreeView.UpdateCommandAction.prototype = {
689
703
this . treeView . selectCommand ( ) ;
690
704
}
691
705
}
692
- }
706
+ } ;
693
707
694
708
TreeView . DeleteCommandAction = function ( treeView , ranges ) {
695
709
this . treeView = treeView ;
696
710
this . ranges = ranges ;
697
- }
711
+ } ;
698
712
699
713
TreeView . DeleteCommandAction . prototype = {
700
714
execute : function ( ) {
@@ -730,13 +744,13 @@ TreeView.DeleteCommandAction.prototype = {
730
744
}
731
745
this . treeView . selection . select ( currentIndex ) ;
732
746
}
733
- }
747
+ } ;
734
748
735
749
TreeView . PasteCommandAction = function ( treeView , index , commands ) {
736
750
this . treeView = treeView ;
737
751
this . index = index ;
738
752
this . commands = commands ;
739
- }
753
+ } ;
740
754
741
755
TreeView . PasteCommandAction . prototype = {
742
756
execute : function ( ) {
@@ -767,7 +781,7 @@ TreeView.PasteCommandAction.prototype = {
767
781
this . treeView . selection . select ( currentIndex ) ;
768
782
this . treeView . treebox . ensureRowIsVisible ( currentIndex ) ;
769
783
}
770
- }
784
+ } ;
771
785
772
786
//D'n'D action for the undo/redo process
773
787
TreeView . dndCommandAction = function ( treeView , sourceIndex , dropIndex , orientation ) {
@@ -786,7 +800,7 @@ TreeView.dndCommandAction = function(treeView, sourceIndex, dropIndex, orientati
786
800
this . sourceIndexU ++ ;
787
801
}
788
802
this . orientationU = this . orientation == Ci . nsITreeView . DROP_BEFORE ? Ci . nsITreeView . DROP_AFTER : Ci . nsITreeView . DROP_BEFORE ;
789
- }
803
+ } ;
790
804
791
805
TreeView . dndCommandAction . prototype = {
792
806
@@ -834,4 +848,4 @@ TreeView.dndCommandAction.prototype = {
834
848
}
835
849
836
850
}
837
- }
851
+ } ;
0 commit comments