| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * | 10 * |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 { | 34 { |
| 35 WebInspector.Object.call(this); | 35 WebInspector.Object.call(this); |
| 36 | 36 |
| 37 this._tabbedPane = new WebInspector.TabbedPane(); | 37 this._tabbedPane = new WebInspector.TabbedPane(); |
| 38 this._tabbedPane.shrinkableTabs = true; | 38 this._tabbedPane.shrinkableTabs = true; |
| 39 this._tabbedPane.element.addStyleClass("navigator-tabbed-pane"); | 39 this._tabbedPane.element.addStyleClass("navigator-tabbed-pane"); |
| 40 | 40 |
| 41 this._scriptsView = new WebInspector.NavigatorView(); | 41 this._scriptsView = new WebInspector.NavigatorView(); |
| 42 this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSel
ected, this._scriptSelected, this); | 42 this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSel
ected, this._scriptSelected, this); |
| 43 this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSea
rchStarted, this._itemSearchStarted, this); | 43 this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSea
rchStarted, this._itemSearchStarted, this); |
| 44 this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemRen
amingRequested, this._itemRenamingRequested, this); |
| 44 | 45 |
| 45 this._contentScriptsView = new WebInspector.NavigatorView(); | 46 this._contentScriptsView = new WebInspector.NavigatorView(); |
| 46 this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.
ItemSelected, this._scriptSelected, this); | 47 this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.
ItemSelected, this._scriptSelected, this); |
| 47 this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.
ItemSearchStarted, this._itemSearchStarted, this); | 48 this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.
ItemSearchStarted, this._itemSearchStarted, this); |
| 49 this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.
ItemRenamingRequested, this._itemRenamingRequested, this); |
| 48 | 50 |
| 49 this._snippetsView = new WebInspector.SnippetsNavigatorView(); | 51 this._snippetsView = new WebInspector.SnippetsNavigatorView(); |
| 50 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSe
lected, this._scriptSelected, this); | 52 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSe
lected, this._scriptSelected, this); |
| 51 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSe
archStarted, this._itemSearchStarted, this); | 53 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSe
archStarted, this._itemSearchStarted, this); |
| 52 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.FileRe
named, this._fileRenamed, this); | 54 this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemRe
namingRequested, this._itemRenamingRequested, this); |
| 53 this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Event
s.SnippetCreationRequested, this._snippetCreationRequested, this); | 55 this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Event
s.SnippetCreationRequested, this._snippetCreationRequested, this); |
| 54 this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Event
s.ItemRenamingRequested, this._itemRenamingRequested, this); | |
| 55 | 56 |
| 56 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInsp
ector.UIString("Sources"), this._scriptsView); | 57 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInsp
ector.UIString("Sources"), this._scriptsView); |
| 57 this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab); | 58 this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab); |
| 58 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ContentScriptsTab,
WebInspector.UIString("Content scripts"), this._contentScriptsView); | 59 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ContentScriptsTab,
WebInspector.UIString("Content scripts"), this._contentScriptsView); |
| 59 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.SnippetsTab, WebIns
pector.UIString("Snippets"), this._snippetsView); | 60 this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.SnippetsTab, WebIns
pector.UIString("Snippets"), this._snippetsView); |
| 60 } | 61 } |
| 61 | 62 |
| 62 WebInspector.ScriptsNavigator.Events = { | 63 WebInspector.ScriptsNavigator.Events = { |
| 63 ScriptSelected: "ScriptSelected", | 64 ScriptSelected: "ScriptSelected", |
| 64 SnippetCreationRequested: "SnippetCreationRequested", | 65 SnippetCreationRequested: "SnippetCreationRequested", |
| 65 ItemRenamingRequested: "ItemRenamingRequested", | 66 ItemRenamingRequested: "ItemRenamingRequested", |
| 66 ItemSearchStarted: "ItemSearchStarted", | 67 ItemSearchStarted: "ItemSearchStarted", |
| 67 FileRenamed: "FileRenamed" | |
| 68 } | 68 } |
| 69 | 69 |
| 70 WebInspector.ScriptsNavigator.ScriptsTab = "scripts"; | 70 WebInspector.ScriptsNavigator.ScriptsTab = "scripts"; |
| 71 WebInspector.ScriptsNavigator.ContentScriptsTab = "contentScripts"; | 71 WebInspector.ScriptsNavigator.ContentScriptsTab = "contentScripts"; |
| 72 WebInspector.ScriptsNavigator.SnippetsTab = "snippets"; | 72 WebInspector.ScriptsNavigator.SnippetsTab = "snippets"; |
| 73 | 73 |
| 74 WebInspector.ScriptsNavigator.prototype = { | 74 WebInspector.ScriptsNavigator.prototype = { |
| 75 /* | 75 /* |
| 76 * @return {WebInspector.View} | 76 * @return {WebInspector.View} |
| 77 */ | 77 */ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 * @param {WebInspector.Event} event | 143 * @param {WebInspector.Event} event |
| 144 */ | 144 */ |
| 145 _itemSearchStarted: function(event) | 145 _itemSearchStarted: function(event) |
| 146 { | 146 { |
| 147 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemS
earchStarted, event.data); | 147 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemS
earchStarted, event.data); |
| 148 }, | 148 }, |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * @param {WebInspector.Event} event | 151 * @param {WebInspector.Event} event |
| 152 */ | 152 */ |
| 153 _fileRenamed: function(event) | |
| 154 { | |
| 155 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.FileR
enamed, event.data); | |
| 156 }, | |
| 157 | |
| 158 /** | |
| 159 * @param {WebInspector.Event} event | |
| 160 */ | |
| 161 _itemRenamingRequested: function(event) | 153 _itemRenamingRequested: function(event) |
| 162 { | 154 { |
| 163 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemR
enamingRequested, event.data); | 155 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemR
enamingRequested, event.data); |
| 164 }, | 156 }, |
| 165 | 157 |
| 166 /** | 158 /** |
| 167 * @param {WebInspector.Event} event | 159 * @param {WebInspector.Event} event |
| 168 */ | 160 */ |
| 169 _snippetCreationRequested: function(event) | 161 _snippetCreationRequested: function(event) |
| 170 { | 162 { |
| 171 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.Snipp
etCreationRequested, event.data); | 163 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.Snipp
etCreationRequested, event.data); |
| 172 }, | 164 }, |
| 173 | 165 |
| 174 __proto__: WebInspector.Object.prototype | 166 __proto__: WebInspector.Object.prototype |
| 175 } | 167 } |
| 176 | 168 |
| 177 /** | 169 /** |
| 178 * @constructor | 170 * @constructor |
| 179 * @extends {WebInspector.NavigatorView} | 171 * @extends {WebInspector.NavigatorView} |
| 180 */ | 172 */ |
| 181 WebInspector.SnippetsNavigatorView = function() | 173 WebInspector.SnippetsNavigatorView = function() |
| 182 { | 174 { |
| 183 WebInspector.NavigatorView.call(this); | 175 WebInspector.NavigatorView.call(this); |
| 184 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); | 176 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); |
| 185 } | 177 } |
| 186 | 178 |
| 187 WebInspector.SnippetsNavigatorView.Events = { | 179 WebInspector.SnippetsNavigatorView.Events = { |
| 188 SnippetCreationRequested: "SnippetCreationRequested", | 180 SnippetCreationRequested: "SnippetCreationRequested" |
| 189 ItemRenamingRequested: "ItemRenamingRequested" | |
| 190 } | 181 } |
| 191 | 182 |
| 192 WebInspector.SnippetsNavigatorView.prototype = { | 183 WebInspector.SnippetsNavigatorView.prototype = { |
| 193 /** | 184 /** |
| 194 * @param {Event} event | 185 * @param {Event} event |
| 195 * @param {WebInspector.UISourceCode=} uiSourceCode | 186 * @param {WebInspector.UISourceCode=} uiSourceCode |
| 196 */ | 187 */ |
| 197 handleContextMenu: function(event, uiSourceCode) | 188 handleContextMenu: function(event, uiSourceCode) |
| 198 { | 189 { |
| 199 var contextMenu = new WebInspector.ContextMenu(event); | 190 var contextMenu = new WebInspector.ContextMenu(event); |
| 200 if (uiSourceCode) { | 191 if (uiSourceCode) { |
| 201 contextMenu.appendItem(WebInspector.UIString("Run"), this._handleEva
luateSnippet.bind(this, uiSourceCode)); | 192 contextMenu.appendItem(WebInspector.UIString("Run"), this._handleEva
luateSnippet.bind(this, uiSourceCode)); |
| 202 contextMenu.appendItem(WebInspector.UIString("Rename"), this.handleR
ename.bind(this, uiSourceCode)); | 193 contextMenu.appendItem(WebInspector.UIString("Rename"), this.request
Rename.bind(this, uiSourceCode)); |
| 203 contextMenu.appendItem(WebInspector.UIString("Remove"), this._handle
RemoveSnippet.bind(this, uiSourceCode)); | 194 contextMenu.appendItem(WebInspector.UIString("Remove"), this._handle
RemoveSnippet.bind(this, uiSourceCode)); |
| 204 contextMenu.appendSeparator(); | 195 contextMenu.appendSeparator(); |
| 205 } | 196 } |
| 206 contextMenu.appendItem(WebInspector.UIString("New"), this._handleCreateS
nippet.bind(this)); | 197 contextMenu.appendItem(WebInspector.UIString("New"), this._handleCreateS
nippet.bind(this)); |
| 207 contextMenu.show(); | 198 contextMenu.show(); |
| 208 }, | 199 }, |
| 209 | 200 |
| 210 /** | 201 /** |
| 211 * @param {WebInspector.UISourceCode} uiSourceCode | 202 * @param {WebInspector.UISourceCode} uiSourceCode |
| 212 */ | 203 */ |
| 213 _handleEvaluateSnippet: function(uiSourceCode) | 204 _handleEvaluateSnippet: function(uiSourceCode) |
| 214 { | 205 { |
| 215 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets
) | 206 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets
) |
| 216 return; | 207 return; |
| 217 WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode); | 208 WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode); |
| 218 }, | 209 }, |
| 219 | 210 |
| 220 /** | 211 /** |
| 221 * @param {WebInspector.UISourceCode} uiSourceCode | 212 * @param {WebInspector.UISourceCode} uiSourceCode |
| 222 */ | 213 */ |
| 223 handleRename: function(uiSourceCode) | |
| 224 { | |
| 225 this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemR
enamingRequested, uiSourceCode); | |
| 226 }, | |
| 227 | |
| 228 /** | |
| 229 * @param {WebInspector.UISourceCode} uiSourceCode | |
| 230 */ | |
| 231 _handleRemoveSnippet: function(uiSourceCode) | 214 _handleRemoveSnippet: function(uiSourceCode) |
| 232 { | 215 { |
| 233 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets
) | 216 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets
) |
| 234 return; | 217 return; |
| 235 WebInspector.scriptSnippetModel.deleteScriptSnippet(uiSourceCode); | 218 WebInspector.scriptSnippetModel.deleteScriptSnippet(uiSourceCode); |
| 236 }, | 219 }, |
| 237 | 220 |
| 238 _handleCreateSnippet: function() | 221 _handleCreateSnippet: function() |
| 239 { | 222 { |
| 240 this._snippetCreationRequested(); | 223 this._snippetCreationRequested(); |
| 241 }, | 224 }, |
| 242 | 225 |
| 243 _snippetCreationRequested: function() | 226 _snippetCreationRequested: function() |
| 244 { | 227 { |
| 245 this.dispatchEventToListeners(WebInspector.SnippetsNavigatorView.Events.
SnippetCreationRequested, null); | 228 this.dispatchEventToListeners(WebInspector.SnippetsNavigatorView.Events.
SnippetCreationRequested, null); |
| 246 }, | 229 }, |
| 247 | 230 |
| 248 __proto__: WebInspector.NavigatorView.prototype | 231 __proto__: WebInspector.NavigatorView.prototype |
| 249 } | 232 } |
| OLD | NEW |