01: package org.columba.core.gui.search;
02:
03: import javax.swing.JComponent;
04: import javax.swing.JLabel;
05: import javax.swing.JTextField;
06:
07: import org.columba.core.gui.search.api.ICriteriaRenderer;
08: import org.columba.core.search.api.ISearchCriteria;
09: import org.columba.core.search.api.ISearchProvider;
10:
11: public class StringCriteriaRenderer implements ICriteriaRenderer {
12:
13: private JTextField textField;
14:
15: private ISearchCriteria criteria;
16:
17: private JLabel label;
18:
19: private ISearchProvider provider;
20:
21: public StringCriteriaRenderer(ISearchCriteria criteria,
22: ISearchProvider provider) {
23: this .criteria = criteria;
24: this .provider = provider;
25: label = new JLabel(criteria.getName() + ":");
26: textField = new JTextField(15);
27: label.setLabelFor(textField);
28: }
29:
30: public JComponent getEditor() {
31: return textField;
32: }
33:
34: public ISearchCriteria getCriteria() {
35: return criteria;
36: }
37:
38: public Object getValue() {
39: String s = textField.getText();
40: if (s.length() > 0)
41: return s;
42:
43: return null;
44: }
45:
46: public JLabel getLabel() {
47: return label;
48: }
49:
50: public ISearchProvider getProvider() {
51: return provider;
52: }
53:
54: public void clear() {
55: textField.setText("");
56: }
57:
58: }
|