Revision 44259 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/elements/DefaultFunctionElement.java
DefaultFunctionElement.java | ||
---|---|---|
28 | 28 |
implements FunctionElement { |
29 | 29 |
|
30 | 30 |
private final Function function; |
31 |
private final ExpressionBuilderConfig config; |
|
32 | 31 |
|
33 |
public DefaultFunctionElement(ExpressionBuilderConfig config, Function function) {
|
|
32 |
public DefaultFunctionElement(Function function) { |
|
34 | 33 |
super( |
35 | 34 |
function.name(), |
35 |
function.name(), |
|
36 | 36 |
function.isSQLCompatible() |
37 | 37 |
? "expressionbuilder-element-function-sql" |
38 | 38 |
: "expressionbuilder-element-function" |
39 | 39 |
); |
40 | 40 |
this.function = function; |
41 |
this.config = config; |
|
42 | 41 |
} |
43 | 42 |
|
44 | 43 |
@Override |
... | ... | |
48 | 47 |
|
49 | 48 |
@Override |
50 | 49 |
public boolean isEnabled() { |
51 |
if( this.config.isSQLCompatible() ) {
|
|
50 |
if( this.getConfig().getPreferences().isSQLCompatible() ) {
|
|
52 | 51 |
return this.function.isSQLCompatible(); |
53 | 52 |
} |
54 | 53 |
return true; |
... | ... | |
65 | 64 |
} |
66 | 65 |
|
67 | 66 |
@Override |
67 |
public String getName() { |
|
68 |
return this.function.name(); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public Object getValue() { |
|
73 |
return this.function.name(); |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public String getLabel() { |
|
78 |
return "<html><b>" + function.name() + "</b> return " + function.returnType() + "</html>"; |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public String getRenderedValue() { |
|
83 |
return function.template() == null ? function.name() + "({{}})" : function.template(); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
68 | 87 |
public String getDescription() { |
69 | 88 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
70 | 89 |
|
... | ... | |
72 | 91 |
html.append("<html>\n"); |
73 | 92 |
|
74 | 93 |
Function theFunction = this.getFunction(); |
75 |
if (theFunction == null) { |
|
76 |
html.append("<b>").append(i18n.getTranslation("_Function")).append("</b> ").append(this.getName()).append("<br>\n<br>\n"); |
|
77 |
html.append("<b>").append(i18n.getTranslation("_Return")).append("</b> Object<br>\n<br>\n"); |
|
78 |
html.append("<b>").append(i18n.getTranslation("_Template")).append(":</b> ").append(this.getName()).append("()<br>\n"); |
|
79 |
} else { |
|
80 |
html.append("<b>").append(i18n.getTranslation("_Function")).append("</b> ").append(this.getName()).append("<br>\n<br>\n"); |
|
81 |
List<String> aliases = theFunction.aliases(); |
|
82 |
if( aliases!=null && !aliases.isEmpty() ) { |
|
83 |
html.append("<b>").append(i18n.getTranslation("_Aliases")).append(":</b> ").append("<ul>\n"); |
|
84 |
for (String alias : aliases) { |
|
85 |
html.append("<li>").append(alias).append("</li>\n"); |
|
86 |
} |
|
87 |
html.append("</ul>\n"); |
|
94 |
html.append("<b>").append(i18n.getTranslation("_Function")).append("</b> ").append(this.getName()).append("<br>\n<br>\n"); |
|
95 |
List<String> aliases = theFunction.aliases(); |
|
96 |
if( aliases!=null && !aliases.isEmpty() ) { |
|
97 |
html.append("<b>").append(i18n.getTranslation("_Aliases")).append(":</b> ").append("<ul>\n"); |
|
98 |
for (String alias : aliases) { |
|
99 |
html.append("<li>").append(alias).append("</li>\n"); |
|
88 | 100 |
} |
89 |
html.append("<b>").append(i18n.getTranslation("_Return")).append("</b> "); |
|
90 |
html.append(StringUtils.isEmpty(theFunction.returnType()) ? "Objec" : theFunction.returnType()); |
|
91 |
html.append("<br>\n"); |
|
92 |
html.append("<b>").append(i18n.getTranslation("_Template")).append("</b> "); |
|
93 |
html.append(StringUtils.isEmpty(theFunction.template()) ? this.getName() + "()" : theFunction.template()); |
|
94 |
html.append("<br>\n"); |
|
101 |
html.append("</ul>\n"); |
|
102 |
} |
|
103 |
html.append("<b>").append(i18n.getTranslation("_Return")).append("</b> "); |
|
104 |
html.append(StringUtils.isEmpty(theFunction.returnType()) ? "Objec" : theFunction.returnType()); |
|
105 |
html.append("<br>\n"); |
|
106 |
html.append("<b>").append(i18n.getTranslation("_Template")).append("</b> "); |
|
107 |
html.append(StringUtils.isEmpty(theFunction.template()) ? this.getName() + "()" : theFunction.template()); |
|
108 |
html.append("<br>\n"); |
|
95 | 109 |
|
96 |
String[] args = theFunction.descriptionArgs(); |
|
97 |
if (args != null) { |
|
98 |
html.append("<b>").append(i18n.getTranslation("_Arguments")).append(":</b> ").append("<ul>\n"); |
|
99 |
for (String arg : args) { |
|
100 |
html.append("<li>").append(arg).append("</li>\n"); |
|
101 |
} |
|
102 |
html.append("</ul>\n"); |
|
103 |
html.append("<br>\n"); |
|
110 |
String[] args = theFunction.descriptionArgs(); |
|
111 |
if (args != null) { |
|
112 |
html.append("<b>").append(i18n.getTranslation("_Arguments")).append(":</b> ").append("<ul>\n"); |
|
113 |
for (String arg : args) { |
|
114 |
html.append("<li>").append(arg).append("</li>\n"); |
|
104 | 115 |
} |
105 |
String functionDescription = theFunction.description(); |
|
106 |
if( !StringUtils.isBlank(functionDescription) ) { |
|
107 |
html.append("<b>").append(i18n.getTranslation("_Description")).append("</b><br>\n"); |
|
108 |
html.append(functionDescription.replace("\n", "<br>")).append("<br>\n"); |
|
109 |
} |
|
116 |
html.append("</ul>\n"); |
|
117 |
html.append("<br>\n"); |
|
110 | 118 |
} |
119 |
String functionDescription = theFunction.description(); |
|
120 |
if( !StringUtils.isBlank(functionDescription) ) { |
|
121 |
html.append("<b>").append(i18n.getTranslation("_Description")).append("</b><br>\n"); |
|
122 |
html.append(functionDescription.replace("\n", "<br>")).append("<br>\n"); |
|
123 |
} |
|
111 | 124 |
|
112 | 125 |
html.append("</html>\n"); |
113 | 126 |
return html.toString(); |
Also available in: Unified diff