svn-gvsig-desktop / trunk / extensions / extSymbology / src-test / org / gvsig / symbology / gui / layerproperties / TestLabelFieldCellEditor.java @ 22147
History | View | Annotate | Download (4.17 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
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
|
40 |
*/
|
41 |
package org.gvsig.symbology.gui.layerproperties; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.util.ArrayList; |
45 |
import java.util.List; |
46 |
import java.util.Vector; |
47 |
|
48 |
import javax.swing.JFrame; |
49 |
import javax.swing.JPanel; |
50 |
|
51 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.DefaultComboBoxConfigurableLookUpModel; |
52 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp; |
53 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
54 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator; |
55 |
import org.gvsig.symbology.fmap.labeling.parse.LabelExpressionParserConstants; |
56 |
|
57 |
public class TestLabelFieldCellEditor /*extends TestCase*/ { |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
public static void main(String[] args) { |
63 |
JFrame j = new JFrame("test field cell editor"); |
64 |
JPanel content = new JPanel(new BorderLayout(10, 10)); |
65 |
|
66 |
JComboBoxConfigurableLookUp combo = new JComboBoxConfigurableLookUp();
|
67 |
final DefaultComboBoxConfigurableLookUpModel m = (DefaultComboBoxConfigurableLookUpModel)combo.getModel();
|
68 |
|
69 |
ILookUp agent = new ILookUp() {
|
70 |
ArrayList<Object> allElements = new ArrayList<Object>(); |
71 |
{ |
72 |
for (int i = 0; i < LabelExpressionParserConstants.tokenImage.length; i++) { |
73 |
allElements.add(LabelExpressionParserConstants.tokenImage[i].replaceAll("\"", "")); |
74 |
} |
75 |
} |
76 |
public List<Object> doLookUpConsideringCaseSensitive(String text, |
77 |
Vector<Object> sortOrderedItems, StringComparator comp) { |
78 |
Vector<Object> suggested = new Vector<Object>(); |
79 |
|
80 |
String t_aux;
|
81 |
m.setEventNotificationEnabled(false);
|
82 |
m.removeAllElements(); |
83 |
|
84 |
// LabelExpressionParser p = new LabelExpressionParser(new StringReader(text));
|
85 |
try {
|
86 |
if (text.compareTo("Hola") != 0) { |
87 |
throw new Exception(); |
88 |
} |
89 |
|
90 |
t_aux = text; |
91 |
// p.FieldExpression();
|
92 |
// m.disableEvents();
|
93 |
// m.removeAllElements();
|
94 |
// m.addElement(text);
|
95 |
// m.enableEvents();
|
96 |
// } catch (ParseException e) {
|
97 |
// for (int i = 0; i < e.expectedTokenSequences.length; i++) {
|
98 |
// suggested.add(LabelExpressionParserConstants.tokenImage[e.expectedTokenSequences[i][0]].replaceAll("\"", ""));
|
99 |
// }
|
100 |
} |
101 |
catch (Exception e) { |
102 |
t_aux = "";
|
103 |
///System.out.println(e.getMessage());
|
104 |
// return (List) suggested;
|
105 |
} |
106 |
// System.out.println("gaste tots els elements");
|
107 |
|
108 |
for (Object string : allElements) { |
109 |
m.addElement(t_aux + " " + string);
|
110 |
suggested.add(t_aux + " " + string);
|
111 |
} |
112 |
// return suggested;
|
113 |
|
114 |
m.setEventNotificationEnabled(true);
|
115 |
return suggested;
|
116 |
} |
117 |
|
118 |
public List<Object> doLookUpIgnoringCaseSensitive(String text, |
119 |
Vector<Object> sortOrderedItems, StringComparator comp) { |
120 |
|
121 |
return null; |
122 |
} |
123 |
|
124 |
}; |
125 |
m.setCaseSensitive(true);
|
126 |
m.setLookUpAgent(agent); |
127 |
for (int i = 0; i < LabelExpressionParserConstants.tokenImage.length; i++) { |
128 |
m.addElement(LabelExpressionParserConstants.tokenImage[i]); |
129 |
} |
130 |
|
131 |
content.add(combo, BorderLayout.CENTER);
|
132 |
j.setContentPane(content); |
133 |
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
134 |
j.pack(); |
135 |
j.setVisible(true);
|
136 |
|
137 |
|
138 |
} |
139 |
} |