Revision 44855 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/DefaultJExpressionBuilder.java
DefaultJExpressionBuilder.java | ||
---|---|---|
20 | 20 |
import java.util.Locale; |
21 | 21 |
import java.util.Map; |
22 | 22 |
import java.util.Objects; |
23 |
import java.util.function.Function; |
|
24 |
import java.util.function.Predicate; |
|
23 | 25 |
import javax.swing.DefaultListCellRenderer; |
24 | 26 |
import javax.swing.ImageIcon; |
25 | 27 |
import javax.swing.JComponent; |
... | ... | |
74 | 76 |
import org.gvsig.tools.swing.api.script.ScriptSwingManager; |
75 | 77 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
76 | 78 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
79 |
import org.gvsig.tools.util.Factory; |
|
77 | 80 |
import org.gvsig.tools.util.ToolsUtilLocator; |
78 | 81 |
|
79 | 82 |
/** |
... | ... | |
322 | 325 |
@Override |
323 | 326 |
protected void setMessage(int mode, String text) { |
324 | 327 |
super.setMessage(mode, text); |
325 |
lblMsg.setText("<html>"+StringUtils.abbreviate(text,100)+"</html>");
|
|
328 |
message(text);
|
|
326 | 329 |
} |
327 | 330 |
|
328 | 331 |
@Override |
329 | 332 |
protected void setPreview(Object value) { |
330 | 333 |
super.setPreview(value); |
331 |
lblMsg.setText("<html>"+StringUtils.abbreviate(this.getPreview(),100)+"</html>");
|
|
334 |
message(this.getPreview());
|
|
332 | 335 |
} |
333 | 336 |
|
334 | 337 |
@Override |
335 | 338 |
protected void setTip(String theTip) { |
336 | 339 |
super.setTip(theTip); |
337 |
btnTip.setToolTipText(this.getTip());
|
|
340 |
btnTip.setToolTipText(toHTML(this.getTip()));
|
|
338 | 341 |
btnTip.setVisible(this.isTipEnabled()); |
339 | 342 |
} |
343 |
|
|
344 |
@Override |
|
345 |
protected String getSuggestion() { |
|
346 |
return builderConfig.getSuggestion(this.getExpression()); |
|
347 |
} |
|
340 | 348 |
|
341 | 349 |
}; |
342 | 350 |
this.infoPanel = new InfoPanel(this.pnlDescription, load_description_from_resource()); |
... | ... | |
659 | 667 |
this.spnlItem.setDividerLocation(dim.width/3); |
660 | 668 |
} |
661 | 669 |
|
670 |
private void message(String text) { |
|
671 |
if( StringUtils.isBlank(text) ) { |
|
672 |
lblMsg.setText(""); |
|
673 |
return; |
|
674 |
} |
|
675 |
String msg = text; |
|
676 |
String tail = ""; |
|
677 |
if( StringUtils.contains(msg, "\n") ) { |
|
678 |
String[] ss = StringUtils.split(msg, "\n"); |
|
679 |
if( ss.length>1 ) { |
|
680 |
tail = String.format("(%d lines more)", ss.length); |
|
681 |
msg = ss[0]; |
|
682 |
} |
|
683 |
} |
|
684 |
lblMsg.setText(toHTML(StringUtils.abbreviate(msg,70)+tail)); |
|
685 |
} |
|
686 |
|
|
687 |
private String toHTML(String s) { |
|
688 |
s = StringUtils.replace(s, "\n", "\n<br>"); |
|
689 |
s = StringUtils.replace(s, "<html>", ""); |
|
690 |
s = StringUtils.replace(s, "</html>", ""); |
|
691 |
s = "<html>"+s+"</html>"; |
|
692 |
return s; |
|
693 |
} |
|
694 |
|
|
662 | 695 |
private String removeCursorMark(String s) { |
663 | 696 |
if( s == null ) { |
664 | 697 |
return null; |
... | ... | |
961 | 994 |
} |
962 | 995 |
|
963 | 996 |
@Override |
997 |
public void expandElement(Predicate<Element> condition) { |
|
998 |
if( condition == null ) { |
|
999 |
return; |
|
1000 |
} |
|
1001 |
this.initializeTree(); |
|
1002 |
for (int i = 0; i < this.treeElements.getRowCount(); i++) { |
|
1003 |
TreePath path = this.treeElements.getPathForRow(i); |
|
1004 |
if( condition.test((Element) path.getLastPathComponent()) ) { |
|
1005 |
// FIXME: habria que expandir los padres hasta llegar a este. |
|
1006 |
this.treeElements.expandPath(path); |
|
1007 |
return; |
|
1008 |
} |
|
1009 |
} |
|
1010 |
} |
|
1011 |
|
|
1012 |
@Override |
|
964 | 1013 |
public Object getProperty(String name) { |
965 | 1014 |
return this.builderConfig.getProperty(name); |
966 | 1015 |
} |
... | ... | |
994 | 1043 |
public void setAllowedFunctions(java.util.function.Function<String, Integer> allow) { |
995 | 1044 |
this.builderConfig.setAllowedFunctions(allow); |
996 | 1045 |
} |
1046 |
|
|
1047 |
@Override |
|
1048 |
public void addSuggestionFactory(Factory factory) { |
|
1049 |
this.builderConfig.addSuggestionFactory(factory); |
|
1050 |
} |
|
1051 |
|
|
1052 |
@Override |
|
1053 |
public String getSuggestion(Expression expression) { |
|
1054 |
return this.builderConfig.getSuggestion(expression); |
|
1055 |
} |
|
1056 |
|
|
1057 |
@Override |
|
1058 |
public void copyConfigFrom(ExpressionBuilderConfig other) { |
|
1059 |
this.builderConfig.copyConfigFrom(other); |
|
1060 |
} |
|
1061 |
|
|
1062 |
@Override |
|
1063 |
public Function<String, Integer> getAllowedFunctions() { |
|
1064 |
return this.builderConfig.getAllowedFunctions(); |
|
1065 |
} |
|
1066 |
|
|
1067 |
@Override |
|
1068 |
public Collection<Factory> getSuggestionFactories() { |
|
1069 |
return this.builderConfig.getSuggestionFactories(); |
|
1070 |
} |
|
1071 |
|
|
1072 |
@Override |
|
1073 |
public void removeAllElements() { |
|
1074 |
this.builderConfig.removeAllElements(); |
|
1075 |
} |
|
1076 |
|
|
997 | 1077 |
} |
Also available in: Unified diff