Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.rhem.client.widget;
import java.text.ParseException;
import com.google.gwt.core.client.GWT;
import com.sencha.gxt.cell.core.client.form.TriggerFieldCell;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.widget.core.client.form.PropertyEditor;
public class SearchTriggerFieldCell<T> extends TriggerFieldCell<T> {
public interface SearchTriggerFieldAppearance extends TriggerFieldAppearance {
}
private class MyPropertyEditor extends PropertyEditor<T>{
@Override
public String render(T object) {//convert object to text
if (object == null) {
return "";
}
LabelProvider<? super T> provider = getLabelProvider();
return provider == null ? object.toString() : provider.getLabel(object);
}
@Override
public T parse(CharSequence text) throws ParseException {//convert text to object
//not implemented yet
return null;
}
}
private final LabelProvider<? super T> labelProvider;
public SearchTriggerFieldCell(LabelProvider<? super T> labelProvider){
this(labelProvider, GWT.<SearchTriggerFieldAppearance> create(SearchTriggerFieldAppearance.class));
}
public SearchTriggerFieldCell(LabelProvider<? super T> labelProvider, SearchTriggerFieldAppearance appearance){
super(appearance);
this.labelProvider = labelProvider;
setPropertyEditor(new MyPropertyEditor());
}
public LabelProvider<? super T> getLabelProvider() {
return labelProvider;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.