View Javadoc

1   /*
2    * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.gwtwidgets.client.ui.gsearch;
18  
19  import org.gwtwidgets.client.ui.gsearch.KeepListener;
20  import com.google.gwt.user.client.Element;
21  
22  public class GSearchControlImpl {
23  
24  	public native static GSearchControl createSearchObject()/*-{
25  	    var theGSearchControl = new $wnd.GSearchControl(); 
26  	    return theGSearchControl;
27  	}-*/;
28  
29  	public native void addSearcher(GSearchControl searchControl, GwebSearch theWebSearcher) /*-{
30  		searchControl.addSearcher(theWebSearcher);
31  	}-*/;
32  	
33  	
34  	public native void addSearcher(GSearchControl searchControl, GlocalSearch theLocalSearcher) /*-{
35  		searchControl.addSearcher(theLocalSearcher);
36  	}-*/;
37  
38  	public native void addSearcher(GSearchControl searchControl, GvideoSearch theVideoSearcher) /*-{
39  		searchControl.addSearcher(theVideoSearcher);
40  	}-*/;
41  
42  	public native void addSearcher(GSearchControl searchControl, GblogSearch theBlogSearcher) /*-{
43  		searchControl.addSearcher(theBlogSearcher);
44  	}-*/;
45  
46  	public native void addSearcher(GSearchControl searchControl, GwebSearch theWebSearcher, GsearcherOptions options) /*-{
47  		var theOptions = new $wnd.GsearcherOptions();
48  		var expanded =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getExpandMode()();
49  		var rootPanel =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()();
50  		var videoHeight =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()();		
51  		if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsExpandedSet()()){
52  			if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_CLOSED){
53  				theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_CLOSED);
54  			}
55  			if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_OPEN){
56  				theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_OPEN);
57  			}
58  			if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_PARTIAL){
59  				theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_PARTIAL);
60  			}
61  		}
62  		if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsRootSet()()){
63  			theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()());
64  		}
65  		if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsVideoHeightSet()()){
66  			theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()());
67  		}
68  		searchControl.addSearcher(theWebSearcher,theOptions);
69  	}-*/;
70  
71  	
72  	public native void addSearcher(GSearchControl searchControl, GlocalSearch theWebSearcher, GsearcherOptions options) /*-{
73  	var theOptions = new $wnd.GsearcherOptions();
74  	var expanded =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getExpandMode()();
75  	var rootPanel =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()();
76  	var videoHeight =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()();		
77  	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsExpandedSet()()){
78  		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_CLOSED){
79  			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_CLOSED);
80  		}
81  		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_OPEN){
82  			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_OPEN);
83  		}
84  		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_PARTIAL){
85  			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_PARTIAL);
86  		}
87  	}
88  	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsRootSet()()){
89  		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()());
90  	}
91  	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsVideoHeightSet()()){
92  		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()());
93  	}
94  	searchControl.addSearcher(theWebSearcher,theOptions);
95  }-*/;
96  	
97  	
98  	public native void addSearcher(GSearchControl searchControl, GvideoSearch theWebSearcher, GsearcherOptions options) /*-{
99  	var theOptions = new $wnd.GsearcherOptions();
100 	var expanded =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getExpandMode()();
101 	var rootPanel =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()();
102 	var videoHeight =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()();		
103 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsExpandedSet()()){
104 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_CLOSED){
105 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_CLOSED);
106 		}
107 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_OPEN){
108 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_OPEN);
109 		}
110 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_PARTIAL){
111 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_PARTIAL);
112 		}
113 	}
114 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsRootSet()()){
115 		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()());
116 	}
117 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsVideoHeightSet()()){
118 		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()());
119 	}
120 	searchControl.addSearcher(theWebSearcher,theOptions);
121 }-*/;
122 	
123 	
124 	public native void addSearcher(GSearchControl searchControl, GblogSearch theWebSearcher, GsearcherOptions options) /*-{
125 	var theOptions = new $wnd.GsearcherOptions();
126 	var expanded =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getExpandMode()();
127 	var rootPanel =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()();
128 	var videoHeight =  options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()();		
129 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsExpandedSet()()){
130 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_CLOSED){
131 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_CLOSED);
132 		}
133 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_OPEN){
134 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_OPEN);
135 		}
136 		if (expanded == @org.gwtwidgets.client.ui.gsearch.GSearchControl::EXPAND_MODE_PARTIAL){
137 			theOptions.setExpandMode($wnd.GSearchControl.EXPAND_MODE_PARTIAL);
138 		}
139 	}
140 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsRootSet()()){
141 		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getRoot()());
142 	}
143 	if (options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getIsVideoHeightSet()()){
144 		theOptions.setRoot(options.@org.gwtwidgets.client.ui.gsearch.GsearcherOptions::getVideoResultsTbHeight()());
145 	}
146 	searchControl.addSearcher(theWebSearcher,theOptions);
147 }-*/;
148 	
149 	public native void execute(GSearchControl searchControl,String searchString) /*-{
150 		searchControl.execute(searchString);
151 	}-*/;
152 	
153 	public native void execute(GSearchControl searchControl) /*-{
154 		searchControl.execute();
155 	}-*/;
156 	
157 
158 	public native void draw(GSearchControl searchControl, Element div) /*-{
159 		searchControl.draw(div);
160 	}-*/;
161 	
162 	public native void draw(GSearchControl searchControl, Element div, GdrawOptions options) /*-{
163 		var theOptions = new $wnd.GdrawOptions();
164 		if (options.@org.gwtwidgets.client.ui.gsearch.GdrawOptions::isInputAttached()()){
165 			theOptions.setInput(options.@org.gwtwidgets.client.ui.gsearch.GdrawOptions::getInputElement()());
166 		}
167 		if (options.@org.gwtwidgets.client.ui.gsearch.GdrawOptions::isDrawModeSet()()){
168 			if (options.@org.gwtwidgets.client.ui.gsearch.GdrawOptions::getDrawMode()()==@org.gwtwidgets.client.ui.gsearch.GSearchControl::DRAW_MODE_LINEAR){
169 				theOptions.setDrawMode($wnd.GSearchControl.DRAW_MODE_LINEAR);
170 			} else {
171 				theOptions.setDrawMode($wnd.GSearchControl.DRAW_MODE_TABBED);
172 			}
173 		}
174 		searchControl.draw(div,theOptions);
175 	}-*/;
176 
177 	public native void setLinkTarget(GSearchControl searchControl, int flag) /*-{
178 		if (flag == @org.gwtwidgets.client.ui.gsearch.GSearch::LINK_TARGET_BLANK){
179 			searchControl.setLinkTarget($wnd.GSearch.LINK_TARGET_BLANK);
180 		}
181 		if (flag == @org.gwtwidgets.client.ui.gsearch.GSearch::LINK_TARGET_SELF){
182 			searchControl.setLinkTarget($wnd.GSearch.LINK_TARGET_SELF);
183 		}
184 		if (flag == @org.gwtwidgets.client.ui.gsearch.GSearch::LINK_TARGET_PARENT){
185 			searchControl.setLinkTarget($wnd.GSearch.LINK_TARGET_PARENT);
186 		}
187 		if (flag == @org.gwtwidgets.client.ui.gsearch.GSearch::LINK_TARGET_TOP){
188 			searchControl.setLinkTarget($wnd.GSearch.LINK_TARGET_TOP);
189 		}		
190 	}-*/;
191 
192 	public native void setTimeoutInterval(GSearchControl searchControl, int timeoutInterval) /*-{
193 		if (timeoutInterval == @org.gwtwidgets.client.ui.gsearch.GSearchControl::TIMEOUT_SHORT){
194 			searchControl.setTimeoutInterval($wnd.GSearchControl.TIMEOUT_SHORT);
195 		}
196 		if (timeoutInterval == @org.gwtwidgets.client.ui.gsearch.GSearchControl::TIMEOUT_MEDIUM){
197 			searchControl.setTimeoutInterval($wnd.GSearchControl.TIMEOUT_MEDIUM);
198 		}
199 		if (timeoutInterval == @org.gwtwidgets.client.ui.gsearch.GSearchControl::TIMEOUT_LONG){
200 			searchControl.setTimeoutInterval($wnd.GSearchControl.TIMEOUT_LONG);
201 		}
202 	}-*/;
203 
204 	public native void setResultSetSize(GSearchControl searchControl, int size) /*-{
205 		if (size == @org.gwtwidgets.client.ui.gsearch.GSearch::LARGE_RESULTSET){
206 			searchControl.setResultSetSize($wnd.GSearch.LARGE_RESULTSET);
207 		}
208 		if (size == @org.gwtwidgets.client.ui.gsearch.GSearch::SMALL_RESULTSET){
209 			searchControl.setResultSetSize($wnd.GSearch.SMALL_RESULTSET);
210 		}
211 	}-*/;
212 
213 	public native void cancelSearch(GSearchControl searchControl) /*-{
214 		searchControl.cancel();
215 	}-*/;
216 
217 	public native void clearAllResults(GSearchControl searchControl) /*-{
218 		searchControl.clearAllResults();
219 	}-*/;
220 	
221 	public native void run()/*-{
222 	    $wnd.alert("Clicked");
223 	}-*/;
224 
225 	public native void setOnKeepCallback(GSearchControl searchControl, KeepListener theListener) /*-{
226 		searchControl.setOnKeepCallback(null, this.@org.gwtwidgets.client.ui.gsearch.GSearchControlImpl::run()(), $wnd.GSearchControl.KEEP_LABEL_INCLUDE);
227 	}-*/;
228 
229 	public native String getResults(GSearchControl searchControl) /*-{
230 		return searchControl.results;
231 	}-*/;
232 }