| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @extends {WebInspector.VBox} | 9 * @extends {WebInspector.VBox} |
| 10 * @implements {WebInspector.ListWidget.Delegate} | 10 * @implements {WebInspector.ListWidget.Delegate} |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 this._list.clear(); | 51 this._list.clear(); |
| 52 var patterns = this._setting.getAsArray(); | 52 var patterns = this._setting.getAsArray(); |
| 53 for (var i = 0; i < patterns.length; ++i) | 53 for (var i = 0; i < patterns.length; ++i) |
| 54 this._list.appendItem(patterns[i], true); | 54 this._list.appendItem(patterns[i], true); |
| 55 }, | 55 }, |
| 56 | 56 |
| 57 _addButtonClicked: function() | 57 _addButtonClicked: function() |
| 58 { | 58 { |
| 59 this._list.addNewItem(this._setting.getAsArray().length); | 59 this._list.addNewItem(this._setting.getAsArray().length, {pattern: "", d
isabled: false}); |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @override | 63 * @override |
| 64 * @param {*} item | 64 * @param {*} item |
| 65 * @param {boolean} editable |
| 65 * @return {!Element} | 66 * @return {!Element} |
| 66 */ | 67 */ |
| 67 renderItem: function(item) | 68 renderItem: function(item, editable) |
| 68 { | 69 { |
| 69 var element = createElementWithClass("div", "blackbox-list-item"); | 70 var element = createElementWithClass("div", "blackbox-list-item"); |
| 70 element.createChild("div", "blackbox-pattern").textContent = item.patter
n; | 71 var pattern = element.createChild("div", "blackbox-pattern"); |
| 72 pattern.textContent = item.pattern; |
| 73 pattern.title = item.pattern; |
| 71 element.createChild("div", "blackbox-separator"); | 74 element.createChild("div", "blackbox-separator"); |
| 72 element.createChild("div", "blackbox-behavior").textContent = item.disab
led ? this._disabledLabel : this._blackboxLabel; | 75 element.createChild("div", "blackbox-behavior").textContent = item.disab
led ? this._disabledLabel : this._blackboxLabel; |
| 73 if (item.disabled) | 76 if (item.disabled) |
| 74 element.classList.add("blackbox-disabled"); | 77 element.classList.add("blackbox-disabled"); |
| 75 return element; | 78 return element; |
| 76 }, | 79 }, |
| 77 | 80 |
| 78 /** | 81 /** |
| 79 * @override | 82 * @override |
| 83 * @param {*} item |
| 80 * @param {number} index | 84 * @param {number} index |
| 81 */ | 85 */ |
| 82 removeItemRequested: function(index) | 86 removeItemRequested: function(item, index) |
| 83 { | 87 { |
| 84 var patterns = this._setting.getAsArray(); | 88 var patterns = this._setting.getAsArray(); |
| 85 patterns.splice(index, 1); | 89 patterns.splice(index, 1); |
| 86 this._muteUpdate = true; | 90 this._muteUpdate = true; |
| 87 this._setting.setAsArray(patterns); | 91 this._setting.setAsArray(patterns); |
| 88 this._muteUpdate = false; | 92 this._muteUpdate = false; |
| 89 this._list.removeItem(index); | 93 this._list.removeItem(index); |
| 90 }, | 94 }, |
| 91 | 95 |
| 92 /** | 96 /** |
| 93 * @override | 97 * @override |
| 94 * @param {*|null} item | 98 * @param {*} item |
| 95 * @param {!WebInspector.ListWidget.Editor} editor | 99 * @param {!WebInspector.ListWidget.Editor} editor |
| 100 * @param {boolean} isNew |
| 96 */ | 101 */ |
| 97 commitEdit: function(item, editor) | 102 commitEdit: function(item, editor, isNew) |
| 98 { | 103 { |
| 99 var pattern = item; | 104 item.pattern = editor.control("pattern").value.trim(); |
| 100 if (!pattern) | 105 item.disabled = editor.control("behavior").value === this._disabledLabel
; |
| 101 pattern = {pattern: "", disabled: false}; | |
| 102 | |
| 103 pattern.pattern = editor.control("pattern").value.trim(); | |
| 104 pattern.disabled = editor.control("behavior").value === this._disabledLa
bel; | |
| 105 | 106 |
| 106 var list = this._setting.getAsArray(); | 107 var list = this._setting.getAsArray(); |
| 107 if (!item) | 108 if (isNew) |
| 108 list.push(pattern); | 109 list.push(item); |
| 109 this._setting.setAsArray(list); | 110 this._setting.setAsArray(list); |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * @override | 114 * @override |
| 114 * @param {*|null} item | 115 * @param {*} item |
| 115 * @return {!WebInspector.ListWidget.Editor} | 116 * @return {!WebInspector.ListWidget.Editor} |
| 116 */ | 117 */ |
| 117 beginEdit: function(item) | 118 beginEdit: function(item) |
| 118 { | 119 { |
| 119 var editor = this._createEditor(); | 120 var editor = this._createEditor(); |
| 120 if (item) { | 121 editor.control("pattern").value = item.pattern; |
| 121 editor.control("pattern").value = item.pattern; | 122 editor.control("behavior").value = item.disabled ? this._disabledLabel :
this._blackboxLabel; |
| 122 editor.control("behavior").value = item.disabled ? this._disabledLab
el : this._blackboxLabel; | |
| 123 } else { | |
| 124 editor.control("pattern").value = ""; | |
| 125 editor.control("behavior").value = this._blackboxLabel; | |
| 126 } | |
| 127 return editor; | 123 return editor; |
| 128 }, | 124 }, |
| 129 | 125 |
| 130 /** | 126 /** |
| 131 * @return {!WebInspector.ListWidget.Editor} | 127 * @return {!WebInspector.ListWidget.Editor} |
| 132 */ | 128 */ |
| 133 _createEditor: function() | 129 _createEditor: function() |
| 134 { | 130 { |
| 135 if (this._editor) | 131 if (this._editor) |
| 136 return this._editor; | 132 return this._editor; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 * @return {boolean} | 167 * @return {boolean} |
| 172 */ | 168 */ |
| 173 function behaviorValidator(input) | 169 function behaviorValidator(input) |
| 174 { | 170 { |
| 175 return true; | 171 return true; |
| 176 } | 172 } |
| 177 }, | 173 }, |
| 178 | 174 |
| 179 __proto__: WebInspector.VBox.prototype | 175 __proto__: WebInspector.VBox.prototype |
| 180 } | 176 } |
| OLD | NEW |