Revision 44191 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/java/org/gvsig/expressionevaluator/swing/impl/DefaultExpressionEvaluatorSwingManager.java
DefaultExpressionEvaluatorSwingManager.java | ||
---|---|---|
21 | 21 |
import org.gvsig.expressionevaluator.swing.Element.GroupElement; |
22 | 22 |
import org.gvsig.expressionevaluator.swing.Element.VariableElement; |
23 | 23 |
import org.gvsig.expressionevaluator.swing.ElementFactory; |
24 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
|
24 | 25 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
25 | 26 |
import org.gvsig.expressionevaluator.swing.FunctionAdditionalPanelFactory; |
26 | 27 |
import org.gvsig.expressionevaluator.swing.JExpressionPicker; |
... | ... | |
34 | 35 |
public class DefaultExpressionEvaluatorSwingManager |
35 | 36 |
implements ExpressionEvaluatorSwingManager { |
36 | 37 |
|
37 |
private Map<String, ElementFactory> elementsFactories; |
|
38 |
private Map<String, FunctionAdditionalPanelFactory> functionAdditionalPanelFactories; |
|
38 |
private final Map<String, ElementFactory> elementsFactories;
|
|
39 |
private final Map<String, FunctionAdditionalPanelFactory> functionAdditionalPanelFactories;
|
|
39 | 40 |
|
40 | 41 |
public DefaultExpressionEvaluatorSwingManager() { |
41 | 42 |
this.elementsFactories = new HashMap<>(); |
... | ... | |
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
@Override |
46 |
public List<Element> createElements(Collection<SymbolTable> symbolTables) { |
|
47 |
public List<Element> createElements(ExpressionBuilderConfig config, Collection<SymbolTable> symbolTables) {
|
|
47 | 48 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
48 | 49 |
Map<String, Function> functions = new HashMap<>(); |
49 | 50 |
|
... | ... | |
60 | 61 |
String groupName = function.group(); |
61 | 62 |
GroupElement group = operatorGroups.get(groupName); |
62 | 63 |
if (group == null) { |
63 |
group = new DefaultGroupElement(groupName); |
|
64 |
group = new DefaultGroupElement(config, groupName);
|
|
64 | 65 |
operatorGroups.put(groupName, group); |
65 | 66 |
} |
66 |
group.addElement(new DefaultFunctionElement(function)); |
|
67 |
group.addElement(new DefaultFunctionElement(config, function));
|
|
67 | 68 |
} else { |
68 | 69 |
String groupName = function.group(); |
69 | 70 |
GroupElement group = functionGroups.get(groupName); |
70 | 71 |
if (group == null) { |
71 |
group = new DefaultGroupElement(groupName); |
|
72 |
group = new DefaultGroupElement(config, groupName);
|
|
72 | 73 |
functionGroups.put(groupName, group); |
73 | 74 |
} |
74 |
group.addElement(new DefaultFunctionElement(function)); |
|
75 |
group.addElement(new DefaultFunctionElement(config, function));
|
|
75 | 76 |
} |
76 | 77 |
} |
77 |
GroupElement builtinFunctions = this.createGroupElement(i18n.getTranslation("_Functions")); |
|
78 |
GroupElement builtinFunctions = this.createGroupElement(config, i18n.getTranslation("_Functions"));
|
|
78 | 79 |
for (GroupElement group : functionGroups.values()) { |
79 | 80 |
builtinFunctions.addElement(group); |
80 | 81 |
} |
81 |
GroupElement operatorFunctions = this.createGroupElement(i18n.getTranslation("_Operators")); |
|
82 |
GroupElement operatorFunctions = this.createGroupElement(config, i18n.getTranslation("_Operators"));
|
|
82 | 83 |
for (GroupElement group : operatorGroups.values()) { |
83 | 84 |
operatorFunctions.addElement(group); |
84 | 85 |
} |
... | ... | |
90 | 91 |
|
91 | 92 |
@Override |
92 | 93 |
public void registerElement(ElementFactory factory) { |
93 |
if (this.elementsFactories == null) { |
|
94 |
this.elementsFactories = new HashMap<>(); |
|
95 |
} |
|
96 | 94 |
this.elementsFactories.put(factory.getName().toLowerCase(), factory); |
97 | 95 |
} |
98 | 96 |
|
99 | 97 |
@Override |
100 | 98 |
public Collection<ElementFactory> getElementFactories() { |
101 |
if (this.elementsFactories == null) { |
|
102 |
this.elementsFactories = new HashMap<>(); |
|
103 |
} |
|
104 | 99 |
List<ElementFactory> factories = new ArrayList<>(); |
105 | 100 |
factories.addAll(this.elementsFactories.values()); |
106 | 101 |
Collections.sort(factories, new Comparator<ElementFactory>() { |
... | ... | |
131 | 126 |
} |
132 | 127 |
|
133 | 128 |
@Override |
134 |
public GroupElement createGroupElement(String name) { |
|
135 |
GroupElement e = new DefaultGroupElement(name); |
|
129 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name) {
|
|
130 |
GroupElement e = new DefaultGroupElement(config, name);
|
|
136 | 131 |
return e; |
137 | 132 |
} |
138 | 133 |
|
139 | 134 |
@Override |
140 |
public GroupElement createGroupElement(String name, List<Element> elements) { |
|
141 |
GroupElement e = new DefaultGroupElement(this, name, elements); |
|
135 |
public GroupElement createGroupElement(ExpressionBuilderConfig config, String name, List<Element> elements) {
|
|
136 |
GroupElement e = new DefaultGroupElement(this, config, name, elements);
|
|
142 | 137 |
return e; |
143 | 138 |
} |
144 | 139 |
|
145 | 140 |
@Override |
146 |
public FunctionElement createFunctionElement(Function function) { |
|
147 |
FunctionElement e = new DefaultFunctionElement(function); |
|
141 |
public FunctionElement createFunctionElement(ExpressionBuilderConfig config, Function function) {
|
|
142 |
FunctionElement e = new DefaultFunctionElement(config, function);
|
|
148 | 143 |
return e; |
149 | 144 |
} |
150 | 145 |
|
151 | 146 |
@Override |
152 |
public ConstantElement createConstantElement(Object value) { |
|
153 |
ConstantElement e = new DefaultConstantValueElement(value, null); |
|
147 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value) {
|
|
148 |
ConstantElement e = new DefaultConstantValueElement(config, value, null);
|
|
154 | 149 |
return e; |
155 | 150 |
} |
156 | 151 |
|
157 | 152 |
@Override |
158 |
public ConstantElement createConstantElement(Object value, String description) { |
|
159 |
ConstantElement e = new DefaultConstantValueElement(value, description); |
|
153 |
public ConstantElement createConstantElement(ExpressionBuilderConfig config, Object value, String description) {
|
|
154 |
ConstantElement e = new DefaultConstantValueElement(config, value, description);
|
|
160 | 155 |
return e; |
161 | 156 |
} |
162 | 157 |
|
163 | 158 |
@Override |
164 |
public VariableElement createVariableElement(String label, String source, String name, String typeName, String description) { |
|
165 |
VariableElement e = new DefaultVariableElement(label, source, name, typeName, description); |
|
159 |
public VariableElement createVariableElement(ExpressionBuilderConfig config, String label, String source, String name, String typeName, String description) {
|
|
160 |
VariableElement e = new DefaultVariableElement(config, label, source, name, typeName, description);
|
|
166 | 161 |
return e; |
167 | 162 |
} |
168 | 163 |
|
Also available in: Unified diff