Revision 44163 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/DefaultExpressionPickerController.java
DefaultExpressionPickerController.java | ||
---|---|---|
14 | 14 |
import org.gvsig.expressionevaluator.DataTypes; |
15 | 15 |
import org.gvsig.expressionevaluator.Expression; |
16 | 16 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
17 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
17 | 18 |
import org.gvsig.expressionevaluator.SymbolTable; |
18 | 19 |
import org.gvsig.expressionevaluator.swing.Element; |
19 | 20 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
59 | 60 |
private final ActionListener buttonAction; |
60 | 61 |
private final JMenuItem menuItem; |
61 | 62 |
private final AbstractAutomaticExpressionChecker automaticExpressionChecker; |
63 |
private boolean returnNullWhenEmptyExpression; |
|
62 | 64 |
|
63 | 65 |
public DefaultExpressionPickerController(ExpressionEvaluatorSwingManager manager, JTextComponent text, JButton button) { |
64 | 66 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
... | ... | |
69 | 71 |
this.text = text; |
70 | 72 |
this.button = button; |
71 | 73 |
this.value = null; |
74 |
this.returnNullWhenEmptyExpression = true; |
|
72 | 75 |
this.button.setIcon(this.getIcon("picker-expression")); |
73 | 76 |
this.buttonAction = new ActionListener() { |
74 | 77 |
@Override |
... | ... | |
115 | 118 |
@Override |
116 | 119 |
public Expression get() { |
117 | 120 |
String s = this.text.getText(); |
118 |
if( StringUtils.isBlank(s) ) { |
|
119 |
return null; |
|
121 |
if( this.returnNullWhenEmptyExpression ) { |
|
122 |
if( ExpressionUtils.isEmpty(this.value) && StringUtils.isBlank(s) ) { |
|
123 |
return null; |
|
124 |
} |
|
120 | 125 |
} |
121 |
if( value == null ) { |
|
122 |
value = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
126 |
if( this.value == null ) {
|
|
127 |
this.value = ExpressionEvaluatorLocator.getManager().createExpression();
|
|
123 | 128 |
} |
124 |
this.value.setPhrase(this.text.getText());
|
|
129 |
this.value.setPhrase(StringUtils.defaultIfBlank(this.text.getText(),null));
|
|
125 | 130 |
return this.value; |
126 | 131 |
} |
127 | 132 |
|
... | ... | |
130 | 135 |
if( value==null ) { |
131 | 136 |
this.text.setText(""); |
132 | 137 |
this.value = null; |
138 |
this.returnNullWhenEmptyExpression = true; |
|
133 | 139 |
} else { |
134 | 140 |
this.value = value; |
135 | 141 |
this.text.setText(this.value.getPhrase()); |
142 |
this.returnNullWhenEmptyExpression = false; |
|
136 | 143 |
} |
137 | 144 |
} |
138 | 145 |
|
Also available in: Unified diff