Revision 3373 org.gvsig.legend.vectorfilterexpression.app.mainplugin/trunk/org.gvsig.legend.vectorfilterexpression.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/ExpressionFieldCellEditor.java
ExpressionFieldCellEditor.java | ||
---|---|---|
7 | 7 |
* as published by the Free Software Foundation; either version 2 |
8 | 8 |
* of the License, or (at your option) any later version. |
9 | 9 |
* |
10 |
* This progra/** |
|
11 |
* gvSIG. Desktop Geographic Information System. |
|
12 |
* |
|
13 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 3 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
10 | 20 |
* This program is distributed in the hope that it will be useful, |
11 | 21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
... | ... | |
14 | 24 |
* |
15 | 25 |
* You should have received a copy of the GNU General Public License |
16 | 26 |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
28 |
* MA 02110-1301, USA. |
|
18 | 29 |
* |
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
30 |
* For any additional information, do not hesitate to contact us |
|
31 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
40 | 32 |
*/ |
41 | 33 |
package org.gvsig.symbology.gui.layerproperties; |
42 | 34 |
|
43 | 35 |
import java.awt.Component; |
44 |
import java.util.EventObject;
|
|
36 |
import javax.swing.AbstractCellEditor;
|
|
45 | 37 |
|
46 | 38 |
import javax.swing.JTable; |
47 |
import javax.swing.JTextField; |
|
48 |
import javax.swing.event.CellEditorListener; |
|
49 | 39 |
import javax.swing.table.TableCellEditor; |
40 |
import org.gvsig.expressionevaluator.Expression; |
|
41 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
42 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
43 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
44 |
import org.gvsig.expressionevaluator.swing.JExpressionPicker; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
46 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
47 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
50 | 48 |
|
51 | 49 |
/** |
52 | 50 |
* Cell Editor for expressions. It controls the edition events in an expression |
53 | 51 |
* column of the table |
54 | 52 |
* |
55 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
|
53 |
* @author gvSIG Team
|
|
56 | 54 |
*/ |
57 |
public class ExpressionFieldCellEditor extends JTextField implements TableCellEditor { |
|
55 |
public class ExpressionFieldCellEditor |
|
56 |
extends AbstractCellEditor |
|
57 |
implements TableCellEditor |
|
58 |
{ |
|
58 | 59 |
|
59 |
private static final long serialVersionUID = 1L;
|
|
60 |
private final JExpressionPicker picker;
|
|
60 | 61 |
|
61 |
public ExpressionFieldCellEditor() { |
|
62 |
|
|
62 |
public ExpressionFieldCellEditor(FeatureStore store) { |
|
63 |
ExpressionEvaluatorSwingManager manager = ExpressionEvaluatorSwingLocator.getManager(); |
|
64 |
this.picker = manager.createJExpressionPicker(); |
|
65 |
if( store != null ) { |
|
66 |
DataSwingManager dataSwingManager = DALSwingLocator.getManager(); |
|
67 |
dataSwingManager.configureExpressionBuilder(picker, store); |
|
68 |
} |
|
63 | 69 |
} |
64 | 70 |
|
65 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
71 |
@Override |
|
72 |
public Object getCellEditorValue() { |
|
73 |
Expression value = this.picker.getExpression(); |
|
74 |
if( value == null ) { |
|
75 |
return null; |
|
76 |
} |
|
77 |
return value.getPhrase(); |
|
78 |
} |
|
66 | 79 |
|
67 |
return null; |
|
68 |
} |
|
80 |
@Override |
|
81 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
82 |
if( value instanceof String ) { |
|
83 |
this.picker.setExpression(ExpressionUtils.createExpression((String) value)); |
|
84 |
} else { |
|
85 |
this.picker.setExpression(null); |
|
86 |
} |
|
87 |
return this.picker.asJComponent(); |
|
88 |
} |
|
69 | 89 |
|
70 |
public void addCellEditorListener(CellEditorListener l) { |
|
71 |
throw new RuntimeException("Not yet implemented"); |
|
72 |
} |
|
73 | 90 |
|
74 |
public void cancelCellEditing() { |
|
75 |
throw new RuntimeException("Not yet implemented"); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
public Object getCellEditorValue() { |
|
80 |
return null; |
|
81 |
} |
|
82 |
|
|
83 |
public boolean isCellEditable(EventObject anEvent) { |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
public void removeCellEditorListener(CellEditorListener l) { |
|
88 |
throw new RuntimeException("Not yet implemented"); |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
93 |
return false; |
|
94 |
} |
|
95 |
|
|
96 |
public boolean stopCellEditing() { |
|
97 |
return false; |
|
98 |
} |
|
99 |
|
|
100 | 91 |
} |
Also available in: Unified diff