| 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 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * @override | 39 * @override |
| 40 * @param {!Workspace.UISourceCode} uiSourceCode | 40 * @param {!Workspace.UISourceCode} uiSourceCode |
| 41 * @return {boolean} | 41 * @return {boolean} |
| 42 */ | 42 */ |
| 43 accept(uiSourceCode) { | 43 accept(uiSourceCode) { |
| 44 if (!super.accept(uiSourceCode)) | 44 if (!super.accept(uiSourceCode)) |
| 45 return false; | 45 return false; |
| 46 return uiSourceCode.project().type() !== Workspace.projectTypes.ContentScrip
ts && | 46 return !Bindings.NetworkProject.isContentScriptUISourceCode(uiSourceCode) && |
| 47 uiSourceCode.project().type() !== Workspace.projectTypes.Snippets; | 47 !Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode); |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * @param {!Common.Event} event | 51 * @param {!Common.Event} event |
| 52 */ | 52 */ |
| 53 _inspectedURLChanged(event) { | 53 _inspectedURLChanged(event) { |
| 54 var mainTarget = SDK.targetManager.mainTarget(); | 54 var mainTarget = SDK.targetManager.mainTarget(); |
| 55 if (event.data !== mainTarget) | 55 if (event.data !== mainTarget) |
| 56 return; | 56 return; |
| 57 var inspectedURL = mainTarget && mainTarget.inspectedURL(); | 57 var inspectedURL = mainTarget && mainTarget.inspectedURL(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 super(); | 96 super(); |
| 97 SDK.targetManager.addEventListener(SDK.TargetManager.Events.InspectedURLChan
ged, this._inspectedURLChanged, this); | 97 SDK.targetManager.addEventListener(SDK.TargetManager.Events.InspectedURLChan
ged, this._inspectedURLChanged, this); |
| 98 } | 98 } |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * @override | 101 * @override |
| 102 * @param {!Workspace.UISourceCode} uiSourceCode | 102 * @param {!Workspace.UISourceCode} uiSourceCode |
| 103 * @return {boolean} | 103 * @return {boolean} |
| 104 */ | 104 */ |
| 105 accept(uiSourceCode) { | 105 accept(uiSourceCode) { |
| 106 return uiSourceCode.project().type() === Workspace.projectTypes.Network; | 106 return Bindings.NetworkProject.isNetworkUISourceCode(uiSourceCode) && |
| 107 !Bindings.NetworkProject.isContentScriptUISourceCode(uiSourceCode); |
| 107 } | 108 } |
| 108 | 109 |
| 109 /** | 110 /** |
| 110 * @param {!Common.Event} event | 111 * @param {!Common.Event} event |
| 111 */ | 112 */ |
| 112 _inspectedURLChanged(event) { | 113 _inspectedURLChanged(event) { |
| 113 var mainTarget = SDK.targetManager.mainTarget(); | 114 var mainTarget = SDK.targetManager.mainTarget(); |
| 114 if (event.data !== mainTarget) | 115 if (event.data !== mainTarget) |
| 115 return; | 116 return; |
| 116 var inspectedURL = mainTarget && mainTarget.inspectedURL(); | 117 var inspectedURL = mainTarget && mainTarget.inspectedURL(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 toolbar.appendToolbarItem(addButton); | 151 toolbar.appendToolbarItem(addButton); |
| 151 this.element.insertBefore(toolbar.element, this.element.firstChild); | 152 this.element.insertBefore(toolbar.element, this.element.firstChild); |
| 152 } | 153 } |
| 153 | 154 |
| 154 /** | 155 /** |
| 155 * @override | 156 * @override |
| 156 * @param {!Workspace.UISourceCode} uiSourceCode | 157 * @param {!Workspace.UISourceCode} uiSourceCode |
| 157 * @return {boolean} | 158 * @return {boolean} |
| 158 */ | 159 */ |
| 159 accept(uiSourceCode) { | 160 accept(uiSourceCode) { |
| 160 return uiSourceCode.project().type() === Workspace.projectTypes.FileSystem; | 161 return Persistence.FileSystemWorkspaceBinding.isFileSystemUISourceCode(uiSou
rceCode); |
| 161 } | 162 } |
| 162 | 163 |
| 163 /** | 164 /** |
| 164 * @override | 165 * @override |
| 165 * @param {!Event} event | 166 * @param {!Event} event |
| 166 */ | 167 */ |
| 167 handleContextMenu(event) { | 168 handleContextMenu(event) { |
| 168 var contextMenu = new UI.ContextMenu(event); | 169 var contextMenu = new UI.ContextMenu(event); |
| 169 Sources.NavigatorView.appendAddFolderItem(contextMenu); | 170 Sources.NavigatorView.appendAddFolderItem(contextMenu); |
| 170 contextMenu.show(); | 171 contextMenu.show(); |
| 171 } | 172 } |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 /** | 175 /** |
| 175 * @unrestricted | 176 * @unrestricted |
| 176 */ | 177 */ |
| 177 Sources.ContentScriptsNavigatorView = class extends Sources.NavigatorView { | 178 Sources.ContentScriptsNavigatorView = class extends Sources.NavigatorView { |
| 178 constructor() { | 179 constructor() { |
| 179 super(); | 180 super(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 /** | 183 /** |
| 183 * @override | 184 * @override |
| 184 * @param {!Workspace.UISourceCode} uiSourceCode | 185 * @param {!Workspace.UISourceCode} uiSourceCode |
| 185 * @return {boolean} | 186 * @return {boolean} |
| 186 */ | 187 */ |
| 187 accept(uiSourceCode) { | 188 accept(uiSourceCode) { |
| 188 return uiSourceCode.project().type() === Workspace.projectTypes.ContentScrip
ts; | 189 return Bindings.NetworkProject.isContentScriptUISourceCode(uiSourceCode); |
| 189 } | 190 } |
| 190 }; | 191 }; |
| 191 | 192 |
| 192 /** | 193 /** |
| 193 * @unrestricted | 194 * @unrestricted |
| 194 */ | 195 */ |
| 195 Sources.SnippetsNavigatorView = class extends Sources.NavigatorView { | 196 Sources.SnippetsNavigatorView = class extends Sources.NavigatorView { |
| 196 constructor() { | 197 constructor() { |
| 197 super(); | 198 super(); |
| 198 var toolbar = new UI.Toolbar('navigator-toolbar'); | 199 var toolbar = new UI.Toolbar('navigator-toolbar'); |
| 199 var newButton = new UI.ToolbarButton('', 'largeicon-add', Common.UIString('N
ew Snippet')); | 200 var newButton = new UI.ToolbarButton('', 'largeicon-add', Common.UIString('N
ew Snippet')); |
| 200 newButton.addEventListener('click', this._handleCreateSnippet.bind(this)); | 201 newButton.addEventListener('click', this._handleCreateSnippet.bind(this)); |
| 201 toolbar.appendToolbarItem(newButton); | 202 toolbar.appendToolbarItem(newButton); |
| 202 this.element.insertBefore(toolbar.element, this.element.firstChild); | 203 this.element.insertBefore(toolbar.element, this.element.firstChild); |
| 203 } | 204 } |
| 204 | 205 |
| 205 /** | 206 /** |
| 206 * @override | 207 * @override |
| 207 * @param {!Workspace.UISourceCode} uiSourceCode | 208 * @param {!Workspace.UISourceCode} uiSourceCode |
| 208 * @return {boolean} | 209 * @return {boolean} |
| 209 */ | 210 */ |
| 210 accept(uiSourceCode) { | 211 accept(uiSourceCode) { |
| 211 return uiSourceCode.project().type() === Workspace.projectTypes.Snippets; | 212 return Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode); |
| 212 } | 213 } |
| 213 | 214 |
| 214 /** | 215 /** |
| 215 * @override | 216 * @override |
| 216 * @param {!Event} event | 217 * @param {!Event} event |
| 217 */ | 218 */ |
| 218 handleContextMenu(event) { | 219 handleContextMenu(event) { |
| 219 var contextMenu = new UI.ContextMenu(event); | 220 var contextMenu = new UI.ContextMenu(event); |
| 220 contextMenu.appendItem(Common.UIString('New'), this._handleCreateSnippet.bin
d(this)); | 221 contextMenu.appendItem(Common.UIString('New'), this._handleCreateSnippet.bin
d(this)); |
| 221 contextMenu.show(); | 222 contextMenu.show(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 236 contextMenu.appendSeparator(); | 237 contextMenu.appendSeparator(); |
| 237 contextMenu.appendItem(Common.UIString('Save as...'), this._handleSaveAs.bin
d(this, uiSourceCode)); | 238 contextMenu.appendItem(Common.UIString('Save as...'), this._handleSaveAs.bin
d(this, uiSourceCode)); |
| 238 contextMenu.show(); | 239 contextMenu.show(); |
| 239 } | 240 } |
| 240 | 241 |
| 241 /** | 242 /** |
| 242 * @param {!Workspace.UISourceCode} uiSourceCode | 243 * @param {!Workspace.UISourceCode} uiSourceCode |
| 243 */ | 244 */ |
| 244 _handleEvaluateSnippet(uiSourceCode) { | 245 _handleEvaluateSnippet(uiSourceCode) { |
| 245 var executionContext = UI.context.flavor(SDK.ExecutionContext); | 246 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
| 246 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets || !ex
ecutionContext) | 247 if (!Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode) || !exe
cutionContext) |
| 247 return; | 248 return; |
| 248 Snippets.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSource
Code); | 249 Snippets.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSource
Code); |
| 249 } | 250 } |
| 250 | 251 |
| 251 /** | 252 /** |
| 252 * @param {!Workspace.UISourceCode} uiSourceCode | 253 * @param {!Workspace.UISourceCode} uiSourceCode |
| 253 */ | 254 */ |
| 254 _handleSaveAs(uiSourceCode) { | 255 _handleSaveAs(uiSourceCode) { |
| 255 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets) | 256 if (!Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode)) |
| 256 return; | 257 return; |
| 257 uiSourceCode.saveAs(); | 258 uiSourceCode.saveAs(); |
| 258 } | 259 } |
| 259 | 260 |
| 260 /** | 261 /** |
| 261 * @param {!Workspace.UISourceCode} uiSourceCode | 262 * @param {!Workspace.UISourceCode} uiSourceCode |
| 262 */ | 263 */ |
| 263 _handleRemoveSnippet(uiSourceCode) { | 264 _handleRemoveSnippet(uiSourceCode) { |
| 264 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets) | 265 if (!Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode)) |
| 265 return; | 266 return; |
| 266 uiSourceCode.remove(); | 267 uiSourceCode.remove(); |
| 267 } | 268 } |
| 268 | 269 |
| 269 _handleCreateSnippet() { | 270 _handleCreateSnippet() { |
| 270 this.create(Snippets.scriptSnippetModel.project(), ''); | 271 this.create(Snippets.scriptSnippetModel.project(), ''); |
| 271 } | 272 } |
| 272 | 273 |
| 273 /** | 274 /** |
| 274 * @override | 275 * @override |
| 275 */ | 276 */ |
| 276 sourceDeleted(uiSourceCode) { | 277 sourceDeleted(uiSourceCode) { |
| 277 this._handleRemoveSnippet(uiSourceCode); | 278 this._handleRemoveSnippet(uiSourceCode); |
| 278 } | 279 } |
| 279 }; | 280 }; |
| OLD | NEW |