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 * 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 */ | 123 */ |
124 uiSourceCode() { | 124 uiSourceCode() { |
125 return this._uiSourceCode; | 125 return this._uiSourceCode; |
126 } | 126 } |
127 | 127 |
128 /** | 128 /** |
129 * @override | 129 * @override |
130 */ | 130 */ |
131 wasShown() { | 131 wasShown() { |
132 super.wasShown(); | 132 super.wasShown(); |
133 this._boundWindowFocused = this._windowFocused.bind(this); | |
134 this.element.ownerDocument.defaultView.addEventListener('focus', this._bound
WindowFocused, false); | |
135 this._checkContentUpdated(); | |
136 // We need CodeMirrorTextEditor to be initialized prior to this call as it c
alls |cursorPositionToCoordinates| internally. @see crbug.com/506566 | 133 // We need CodeMirrorTextEditor to be initialized prior to this call as it c
alls |cursorPositionToCoordinates| internally. @see crbug.com/506566 |
137 setImmediate(this._updateBucketDecorations.bind(this)); | 134 setImmediate(this._updateBucketDecorations.bind(this)); |
138 } | 135 } |
139 | 136 |
140 /** | 137 /** |
141 * @override | 138 * @override |
142 */ | 139 */ |
143 willHide() { | 140 willHide() { |
144 super.willHide(); | 141 super.willHide(); |
145 UI.context.setFlavor(Sources.UISourceCodeFrame, null); | 142 UI.context.setFlavor(Sources.UISourceCodeFrame, null); |
146 this.element.ownerDocument.defaultView.removeEventListener('focus', this._bo
undWindowFocused, false); | |
147 delete this._boundWindowFocused; | |
148 this._uiSourceCode.removeWorkingCopyGetter(); | 143 this._uiSourceCode.removeWorkingCopyGetter(); |
149 } | 144 } |
150 | 145 |
151 /** | 146 /** |
152 * @return {boolean} | 147 * @return {boolean} |
153 */ | 148 */ |
154 _canEditSource() { | 149 _canEditSource() { |
155 if (Persistence.persistence.binding(this._uiSourceCode)) | 150 if (Persistence.persistence.binding(this._uiSourceCode)) |
156 return true; | 151 return true; |
157 if (this._uiSourceCode.project().canSetFileContent()) | 152 if (this._uiSourceCode.project().canSetFileContent()) |
158 return true; | 153 return true; |
159 if (this._uiSourceCode.project().isServiceProject()) | 154 if (this._uiSourceCode.project().isServiceProject()) |
160 return false; | 155 return false; |
161 return this._uiSourceCode.contentType() !== Common.resourceTypes.Document; | 156 return this._uiSourceCode.contentType() !== Common.resourceTypes.Document; |
162 } | 157 } |
163 | 158 |
164 _windowFocused(event) { | |
165 this._checkContentUpdated(); | |
166 } | |
167 | |
168 _checkContentUpdated() { | |
169 if (!this.loaded || !this.isShowing()) | |
170 return; | |
171 this._uiSourceCode.checkContentUpdated(true); | |
172 } | |
173 | |
174 commitEditing() { | 159 commitEditing() { |
175 if (!this._uiSourceCode.isDirty()) | 160 if (!this._uiSourceCode.isDirty()) |
176 return; | 161 return; |
177 | 162 |
178 this._muteSourceCodeEvents = true; | 163 this._muteSourceCodeEvents = true; |
179 this._uiSourceCode.commitWorkingCopy(); | 164 this._uiSourceCode.commitWorkingCopy(); |
180 delete this._muteSourceCodeEvents; | 165 delete this._muteSourceCodeEvents; |
181 } | 166 } |
182 | 167 |
183 /** | 168 /** |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 679 |
695 /** | 680 /** |
696 * @param {!Workspace.UISourceCode.Message} a | 681 * @param {!Workspace.UISourceCode.Message} a |
697 * @param {!Workspace.UISourceCode.Message} b | 682 * @param {!Workspace.UISourceCode.Message} b |
698 * @return {number} | 683 * @return {number} |
699 */ | 684 */ |
700 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { | 685 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { |
701 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - | 686 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - |
702 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; | 687 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; |
703 }; | 688 }; |
OLD | NEW |