/*
 * Copyright (c) 2009 The Olympos Development Team.
 * 
 * http://sourceforge.net/projects/olympos/
 * 
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html. If redistributing this code, this
 * entire header must remain intact.
 */
Ext.namespace("cwe");

cwe.ui.SearchField = function() {

};

cwe.ui.SearchField = Ext.extend(Ext.form.TriggerField, {
	initComponent : function() {
		var self = this;

		Ext.apply(this, {
		    cls : "searchField",
		    triggerClass : "searchResetButton",
		    wrapFocusClass : "",
		    enableKeyEvents : true,
		    onTriggerClick : function(e) {
			    self.setValue("");
			    self.updateSearch("");
		    }
		});

		cwe.ui.SearchField.superclass.initComponent.apply(this, arguments);

		this.on("change", function(searchField, e) {
			self.updateSearch(searchField.getValue());
		});

		this.on("keypress", function(searchField, e) {
			if (e.getKey() == e.ENTER) {
				self.updateSearch(searchField.getValue());
				self.startValue = searchField.getValue();
			}
		});
	}
});
