package authoritymanager.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class QueryWidget extends Composite {
	private String path ;
	private String name ;
	private Widget widget ;
	
	public QueryWidget() {
		super() ;
		path = "" ;
		name = "" ;
		widget = null ;
	}
	
	public void setWidget(Widget widget) {
		this.widget = widget ;
		initWidget(this.widget) ;
	}
	
	public Widget getWidget() {
		return widget ;
	}
	
	public String getPath() {
		return this.path ;
	}
	
	public void setPath(String path) {
		this.path = path ;
	}
	
	public String getName() {
		return this.name ;
	}
	
	public void setName(String name) {
		this.name = name ;
	}
	
	public String getValue() {
		if (widget != null && widget.getClass() == TextBox.class) {
			return ((TextBox) widget).getText();
		}
		if (widget != null && widget.getClass() == ListBox.class) {
			int iSelected = ((ListBox) widget).getSelectedIndex();
			return ((ListBox) widget).getItemText(iSelected);
		}
		return null;
	}
}
