Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / algorithm / TableFilterPanel.java @ 328

History | View | Annotate | Download (3.84 KB)

1 59 nbrodin
package es.unex.sextante.gui.algorithm;
2
3
import info.clearthought.layout.TableLayout;
4
import info.clearthought.layout.TableLayoutConstants;
5
6
import javax.swing.JButton;
7
import javax.swing.JPanel;
8
import javax.swing.JTextField;
9 316 omartinez
import org.gvsig.expressionevaluator.Expression;
10
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
11
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
12
import org.gvsig.expressionevaluator.swing.ExpressionPickerController;
13
import org.gvsig.expressionevaluator.swing.JExpressionBuilder;
14
import org.gvsig.fmap.dal.feature.FeatureStore;
15
import org.gvsig.fmap.dal.swing.DataSwingManager;
16
import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement;
17 59 nbrodin
18
/**
19 316 omartinez
 * A panel with a text field and a button, which pops-up a filter dialog
20
 *
21
 * @author omartinez
22
 *
23 59 nbrodin
 */
24 315 omartinez
public class TableFilterPanel
25 316 omartinez
        extends
26
        JPanel {
27 59 nbrodin
28 316 omartinez
    private JTextField textField;
29
    private JButton button;
30
    private FeatureStore m_Store = null;
31
    private ExpressionPickerController expressionControler;
32
    private FeatureStoreElement element;
33 59 nbrodin
34 316 omartinez
    /**
35
     * Creates a new file selection panel.
36
     *
37
     * @param bFolder true if the selection must be a folder instead of a file
38
     * @param bOpen true to show a open file dialog. False to show a save file
39
     * one
40
     * @param sExts a list of permitted file extensions
41
     * @param sDescription a description of the panel to show in the file dialog
42
     */
43
    public TableFilterPanel(FeatureStore m_Store) {
44 59 nbrodin
45 316 omartinez
        super();
46 59 nbrodin
47 316 omartinez
        initGUI();
48 59 nbrodin
49 316 omartinez
        this.setStore(m_Store);
50 59 nbrodin
51 316 omartinez
    }
52 59 nbrodin
53 316 omartinez
    public TableFilterPanel() {
54 59 nbrodin
55 316 omartinez
        super();
56 59 nbrodin
57 316 omartinez
        initGUI();
58 59 nbrodin
59 316 omartinez
    }
60 59 nbrodin
61 316 omartinez
    private void initGUI() {
62 59 nbrodin
63 316 omartinez
        button = new JButton("");
64
        textField = new JTextField("");
65
        textField.setMaximumSize(new java.awt.Dimension(340, 18));
66 59 nbrodin
67 316 omartinez
        final TableLayout thisLayout = new TableLayout(new double[][]{{TableLayoutConstants.FILL, 25.0},
68
        {TableLayoutConstants.FILL}});
69
        this.setLayout(thisLayout);
70
        this.add(textField, "0,  0");
71
        this.add(button, "1,  0");
72
        ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager();
73
        this.expressionControler = swingManager.createExpressionPickerController(textField, button);
74
        this.element = (FeatureStoreElement) swingManager.createElement(
75
                DataSwingManager.FEATURE_STORE_EXPRESSION_ELEMENT,
76
                this.expressionControler,
77
                null);
78
        if (element != null) {
79 328 omartinez
            this.expressionControler.addElement(element);
80 316 omartinez
        }
81
    }
82 59 nbrodin
83 316 omartinez
    /**
84
     * Returns the filepath currently shown in the text field
85
     *
86
     * @return the filepath currently shown in the text field
87
     */
88
    public Expression getExpression() {
89 59 nbrodin
90 316 omartinez
//        return textField.getText();
91
        return this.expressionControler.get();
92 59 nbrodin
93 316 omartinez
    }
94 59 nbrodin
95 316 omartinez
    /**
96
     * Returns this panel's JTextField widget.
97
     *
98
     * @return the text field widget used to input/store the selected file's
99
     * path and name
100
     */
101
    public JTextField getTextField() {
102 59 nbrodin
103 316 omartinez
        return (this.textField);
104 59 nbrodin
105 316 omartinez
    }
106 59 nbrodin
107 316 omartinez
    /**
108
     * Returns this panel's JButton widget.
109
     *
110
     * @return the button widget used to pop up the file selector widget
111
     */
112
    public JButton getButton() {
113 59 nbrodin
114 316 omartinez
        return (this.button);
115 59 nbrodin
116 316 omartinez
    }
117 59 nbrodin
118 316 omartinez
    public void setStore(FeatureStore store) {
119
        this.m_Store = store;
120
        this.element.setFeatureStore(store);
121 59 nbrodin
122 316 omartinez
    }
123 59 nbrodin
124 316 omartinez
    public void setPhrase(final String sText) {
125 59 nbrodin
126 316 omartinez
        textField.setText(sText);
127 59 nbrodin
128 316 omartinez
    }
129 59 nbrodin
130 316 omartinez
    public String getPhrase() {
131 59 nbrodin
132 316 omartinez
        return textField.getText();
133 59 nbrodin
134 316 omartinez
    }
135 59 nbrodin
136 316 omartinez
    @Override
137
    public void setToolTipText(final String sText) {
138 59 nbrodin
139 316 omartinez
        textField.setToolTipText(sText);
140 59 nbrodin
141 316 omartinez
    }
142 59 nbrodin
}