| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 this._treeOutline = new UI.TreeOutlineInShadow(); | 39 this._treeOutline = new UI.TreeOutlineInShadow(); |
| 40 this._treeOutline.registerRequiredCSS('sources/revisionHistory.css'); | 40 this._treeOutline.registerRequiredCSS('sources/revisionHistory.css'); |
| 41 this._treeOutline.makeDense(); | 41 this._treeOutline.makeDense(); |
| 42 this.element.appendChild(this._treeOutline.element); | 42 this.element.appendChild(this._treeOutline.element); |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @param {!Workspace.UISourceCode} uiSourceCode | 45 * @param {!Workspace.UISourceCode} uiSourceCode |
| 46 * @this {Sources.RevisionHistoryView} | 46 * @this {Sources.RevisionHistoryView} |
| 47 */ | 47 */ |
| 48 function populateRevisions(uiSourceCode) { | 48 function populateRevisions(uiSourceCode) { |
| 49 if (uiSourceCode.history.length) | 49 if (uiSourceCode.history().length) |
| 50 this._createUISourceCodeItem(uiSourceCode); | 50 this._createUISourceCodeItem(uiSourceCode); |
| 51 } | 51 } |
| 52 | 52 |
| 53 Workspace.workspace.uiSourceCodes().forEach(populateRevisions.bind(this)); | 53 Workspace.workspace.uiSourceCodes().forEach(populateRevisions.bind(this)); |
| 54 Workspace.workspace.addEventListener( | 54 Workspace.workspace.addEventListener( |
| 55 Workspace.Workspace.Events.WorkingCopyCommittedByUser, this._revisionAdd
ed, this); | 55 Workspace.Workspace.Events.WorkingCopyCommittedByUser, this._revisionAdd
ed, this); |
| 56 Workspace.workspace.addEventListener( | 56 Workspace.workspace.addEventListener( |
| 57 Workspace.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemove
d, this); | 57 Workspace.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemove
d, this); |
| 58 Workspace.workspace.addEventListener(Workspace.Workspace.Events.ProjectRemov
ed, this._projectRemoved, this); | 58 Workspace.workspace.addEventListener(Workspace.Workspace.Events.ProjectRemov
ed, this._projectRemoved, this); |
| 59 } | 59 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 if (rootElement.childAt(i).title.localeCompare(uiSourceCode.displayName())
> 0) { | 81 if (rootElement.childAt(i).title.localeCompare(uiSourceCode.displayName())
> 0) { |
| 82 rootElement.insertChild(uiSourceCodeItem, i); | 82 rootElement.insertChild(uiSourceCodeItem, i); |
| 83 break; | 83 break; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 if (i === rootElement.childCount()) | 86 if (i === rootElement.childCount()) |
| 87 rootElement.appendChild(uiSourceCodeItem); | 87 rootElement.appendChild(uiSourceCodeItem); |
| 88 | 88 |
| 89 this._uiSourceCodeItems.set(uiSourceCode, uiSourceCodeItem); | 89 this._uiSourceCodeItems.set(uiSourceCode, uiSourceCodeItem); |
| 90 | 90 |
| 91 var revisionCount = uiSourceCode.history.length; | 91 var history = uiSourceCode.history(); |
| 92 var revisionCount = history.length; |
| 92 for (var i = revisionCount - 1; i >= 0; --i) { | 93 for (var i = revisionCount - 1; i >= 0; --i) { |
| 93 var revision = uiSourceCode.history[i]; | 94 var revision = history[i]; |
| 94 var historyItem = | 95 var historyItem = new Sources.RevisionHistoryTreeElement(revision, history
[i - 1], i !== revisionCount - 1); |
| 95 new Sources.RevisionHistoryTreeElement(revision, uiSourceCode.history[
i - 1], i !== revisionCount - 1); | |
| 96 uiSourceCodeItem.appendChild(historyItem); | 96 uiSourceCodeItem.appendChild(historyItem); |
| 97 } | 97 } |
| 98 | 98 |
| 99 var linkItem = new UI.TreeElement(); | 99 var linkItem = new UI.TreeElement(); |
| 100 linkItem.selectable = false; | 100 linkItem.selectable = false; |
| 101 uiSourceCodeItem.appendChild(linkItem); | 101 uiSourceCodeItem.appendChild(linkItem); |
| 102 | 102 |
| 103 var revertToOriginal = | 103 var revertToOriginal = |
| 104 linkItem.listItemElement.createChild('span', 'revision-history-link revi
sion-history-link-row'); | 104 linkItem.listItemElement.createChild('span', 'revision-history-link revi
sion-history-link-row'); |
| 105 revertToOriginal.textContent = Common.UIString('apply original content'); | 105 revertToOriginal.textContent = Common.UIString('apply original content'); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 _revisionAdded(event) { | 128 _revisionAdded(event) { |
| 129 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data.uiSour
ceCode); | 129 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data.uiSour
ceCode); |
| 130 var uiSourceCodeItem = this._uiSourceCodeItems.get(uiSourceCode); | 130 var uiSourceCodeItem = this._uiSourceCodeItems.get(uiSourceCode); |
| 131 if (!uiSourceCodeItem) { | 131 if (!uiSourceCodeItem) { |
| 132 uiSourceCodeItem = this._createUISourceCodeItem(uiSourceCode); | 132 uiSourceCodeItem = this._createUISourceCodeItem(uiSourceCode); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 var historyLength = uiSourceCode.history.length; | 136 var history = uiSourceCode.history(); |
| 137 var historyItem = new Sources.RevisionHistoryTreeElement( | 137 var historyItem = |
| 138 uiSourceCode.history[historyLength - 1], uiSourceCode.history[historyLen
gth - 2], false); | 138 new Sources.RevisionHistoryTreeElement(history[history.length - 1], hist
ory[history.length - 2], false); |
| 139 if (uiSourceCodeItem.firstChild()) | 139 if (uiSourceCodeItem.firstChild()) |
| 140 uiSourceCodeItem.firstChild().allowRevert(); | 140 uiSourceCodeItem.firstChild().allowRevert(); |
| 141 uiSourceCodeItem.insertChild(historyItem, 0); | 141 uiSourceCodeItem.insertChild(historyItem, 0); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * @param {!Workspace.UISourceCode} uiSourceCode | 145 * @param {!Workspace.UISourceCode} uiSourceCode |
| 146 */ | 146 */ |
| 147 _revealUISourceCode(uiSourceCode) { | 147 _revealUISourceCode(uiSourceCode) { |
| 148 var uiSourceCodeItem = this._uiSourceCodeItems.get(uiSourceCode); | 148 var uiSourceCodeItem = this._uiSourceCodeItems.get(uiSourceCode); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 contentSpan.textContent = lineContent; | 293 contentSpan.textContent = lineContent; |
| 294 child.listItemElement.appendChild(contentSpan); | 294 child.listItemElement.appendChild(contentSpan); |
| 295 child.listItemElement.classList.add('revision-history-line'); | 295 child.listItemElement.classList.add('revision-history-line'); |
| 296 contentSpan.classList.add('revision-history-line-' + changeType); | 296 contentSpan.classList.add('revision-history-line-' + changeType); |
| 297 } | 297 } |
| 298 | 298 |
| 299 allowRevert() { | 299 allowRevert() { |
| 300 this._revertElement.classList.remove('hidden'); | 300 this._revertElement.classList.remove('hidden'); |
| 301 } | 301 } |
| 302 }; | 302 }; |
| OLD | NEW |