Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 348792
Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.core/web/edit/setup.js (-3 / +61 lines)
Lines 271-276 exports.setUpEditor = function(isReadOnly){ Link Here
271
			}
271
			}
272
		};	
272
		};	
273
		
273
		
274
		var escHandler = {
275
			handlers: [],
276
			
277
			addHandler: function(handler) {
278
				this.handlers.push(handler);
279
			},
280
			
281
			cancel: function() {
282
				var handled = false;
283
				// To be safe, we give all our handlers a chance, not just the first one.
284
				// In case the user has left multiple modal popups open (such as key assist and search)
285
				for (var i=0; i<this.handlers.length; i++) {
286
					handled = this.handlers[i].cancel() || handled;
287
				}
288
				return handled;
289
			},
290
		
291
			isActive: function() {
292
				for (var i=0; i<this.handlers.length; i++) {
293
					if (this.handlers[i].isActive()) {
294
						return true;
295
					}
296
				}
297
				return false;
298
			},
299
		
300
			lineUp: function() {
301
				return false;
302
			},
303
			lineDown: function() {
304
				return false;
305
			},
306
			enter: function() {
307
				return false;
308
			}
309
		};
310
		
274
		var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
311
		var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
275
			// Register commands that depend on external services, the registry, etc.
312
			// Register commands that depend on external services, the registry, etc.
276
			var commandGenerator = new mEditorCommands.EditorCommandFactory(serviceRegistry, commandService, fileClient, inputManager, "pageActions", isReadOnly);
313
			var commandGenerator = new mEditorCommands.EditorCommandFactory(serviceRegistry, commandService, fileClient, inputManager, "pageActions", isReadOnly);
Lines 285-290 exports.setUpEditor = function(isReadOnly){ Link Here
285
			var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
322
			var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
286
			keyModeStack.push(codeBindings);
323
			keyModeStack.push(codeBindings);
287
			
324
			
325
			// give our external escape handler a shot at handling escape
326
			keyModeStack.push(escHandler);
327
			
288
			// global search
328
			// global search
289
			editor.getTextView().setKeyBinding(new mKeyBinding.KeyBinding("h", true), "Search Files");
329
			editor.getTextView().setKeyBinding(new mKeyBinding.KeyBinding("h", true), "Search Files");
290
			editor.getTextView().setAction("Search Files", function() {
330
			editor.getTextView().setAction("Search Files", function() {
Lines 299-307 exports.setUpEditor = function(isReadOnly){ Link Here
299
					} if (!searchPattern) {
339
					} if (!searchPattern) {
300
						return;
340
						return;
301
					}
341
					}
302
					searchFloat.onclick = function() {
342
					dojo.connect(document, "onkeypress", dojo.hitch(this, function (e){ 
303
						searchFloat.style.display = "none";
343
						if (e.charOrCode === dojo.keys.ESCAPE) {
344
							searchFloat.style.display = "none";
345
						}
346
					}));
347
					
348
					var searchFloatEscHandler = {
349
						isActive: function() {
350
							return searchFloat.style.display === "block";
351
						},
352
						
353
						cancel: function() {
354
							if (this.isActive()) {
355
								searchFloat.style.display = "none";
356
								return true;
357
							}
358
							return false;   // not handled
359
						}
304
					};
360
					};
361
					escHandler.addHandler(searchFloatEscHandler);
362
					
305
					// TEMPORARY until we can better scope the search
363
					// TEMPORARY until we can better scope the search
306
					var extensionFilter = "";
364
					var extensionFilter = "";
307
					var fileName = inputManager.getTitle();
365
					var fileName = inputManager.getTitle();
Lines 382-388 exports.setUpEditor = function(isReadOnly){ Link Here
382
		inputManager.setInput(dojo.hash(), editor);
440
		inputManager.setInput(dojo.hash(), editor);
383
		
441
		
384
		// TODO search location needs to be gotten from somewhere
442
		// TODO search location needs to be gotten from somewhere
385
		mGlobalCommands.generateBanner("toolbar", serviceRegistry, commandService, prefsService, searcher, editor, editor);
443
		mGlobalCommands.generateBanner("toolbar", serviceRegistry, commandService, prefsService, searcher, editor, editor, escHandler);
386
		mGlobalCommands.generateDomCommandsInBanner(commandService, editor);
444
		mGlobalCommands.generateDomCommandsInBanner(commandService, editor);
387
			
445
			
388
		var syntaxChecker = new mSyntaxchecker.SyntaxChecker(serviceRegistry, editor);
446
		var syntaxChecker = new mSyntaxchecker.SyntaxChecker(serviceRegistry, editor);
(-)a/bundles/org.eclipse.orion.client.core/web/orion/globalCommands.js (-1 / +18 lines)
Lines 151-157 define(['dojo', 'dijit', 'orion/commands', 'orion/util', 'orion/textview/keyBind Link Here
151
	 * @name orion.globalCommands#generateBanner
151
	 * @name orion.globalCommands#generateBanner
152
	 * @function
152
	 * @function
153
	 */
153
	 */
154
	function generateBanner(parentId, serviceRegistry, commandService, prefsService, searcher, handler, editor) {
154
	function generateBanner(parentId, serviceRegistry, commandService, prefsService, searcher, handler, /* optional */ editor, /* optional */ escapeProvider) {
155
		// this needs to come from somewhere but I'm not going to do a separate get for it
155
		// this needs to come from somewhere but I'm not going to do a separate get for it
156
		var searchLocation = "/filesearch?q=";
156
		var searchLocation = "/filesearch?q=";
157
		var text;
157
		var text;
Lines 262-267 define(['dojo', 'dijit', 'orion/commands', 'orion/util', 'orion/textview/keyBind Link Here
262
			}
262
			}
263
		}));
263
		}));
264
		
264
		
265
		if (escapeProvider) {
266
			var keyAssistEscHandler = {
267
				isActive: function() {
268
					return keyAssistNode.style.display === "block";
269
				},
270
				
271
				cancel: function() {
272
					if (this.isActive()) {
273
						keyAssistNode.style.display = "none";
274
						return true;
275
					}
276
					return false;   // not handled
277
				}
278
			};
279
			escapeProvider.addHandler(keyAssistEscHandler);
280
		}
281
		
265
		var keyAssistCommand = new mCommands.Command({
282
		var keyAssistCommand = new mCommands.Command({
266
			name: "Show Keys",
283
			name: "Show Keys",
267
			id: "eclipse.keyAssist",
284
			id: "eclipse.keyAssist",

Return to bug 348792