Revision 44148 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 | ||
---|---|---|
58 | 58 |
private final ExpressionEvaluatorSwingManager manager; |
59 | 59 |
private final ActionListener buttonAction; |
60 | 60 |
private final JMenuItem menuItem; |
61 |
private final AbstractAutomaticExpressionChecker automaticExpressionChecker; |
|
61 | 62 |
|
62 | 63 |
public DefaultExpressionPickerController(ExpressionEvaluatorSwingManager manager, JTextComponent text, JButton button) { |
63 | 64 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
... | ... | |
67 | 68 |
this.config = new DefaultExpressionBuilderConfig(manager); |
68 | 69 |
this.text = text; |
69 | 70 |
this.button = button; |
70 |
this.value = ExpressionEvaluatorLocator.getManager().createExpression();
|
|
71 |
this.value = null;
|
|
71 | 72 |
this.button.setIcon(this.getIcon("picker-expression")); |
72 | 73 |
this.buttonAction = new ActionListener() { |
73 | 74 |
@Override |
... | ... | |
83 | 84 |
this.menuItem = new JMenuItem(i18n.getTranslation("_Show_expression_builder")); |
84 | 85 |
this.menuItem.addActionListener(buttonAction); |
85 | 86 |
popupMenu.add(this.menuItem); |
87 |
|
|
88 |
this.automaticExpressionChecker = new AbstractAutomaticExpressionChecker(config, text) { |
|
89 |
@Override |
|
90 |
protected Expression getExpression() { |
|
91 |
return get(); |
|
92 |
} |
|
93 |
}; |
|
86 | 94 |
} |
87 | 95 |
|
88 |
@Override |
|
89 |
public void unbind() { |
|
90 |
this.button.removeActionListener(this.buttonAction); |
|
91 |
JPopupMenu popupMenu = this.text.getComponentPopupMenu(); |
|
92 |
popupMenu.remove(this.menuItem); |
|
93 |
} |
|
94 |
|
|
95 | 96 |
private void doSelectExpression() { |
96 |
this.value.setPhrase(this.text.getText());
|
|
97 |
Expression theValue = this.get();
|
|
97 | 98 |
|
98 | 99 |
DefaultJExpressionBuilder panel = new DefaultJExpressionBuilder(this.manager, this.config); |
99 |
panel.setExpression(this.value);
|
|
100 |
panel.setExpression(theValue);
|
|
100 | 101 |
|
101 | 102 |
WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
102 | 103 |
Dialog dialog = windowManager.createDialog( |
... | ... | |
113 | 114 |
|
114 | 115 |
@Override |
115 | 116 |
public Expression get() { |
117 |
if( value == null ) { |
|
118 |
return null; |
|
119 |
} |
|
116 | 120 |
this.value.setPhrase(this.text.getText()); |
117 | 121 |
return this.value; |
118 | 122 |
} |
... | ... | |
121 | 125 |
public void set(Expression value) { |
122 | 126 |
if( value==null ) { |
123 | 127 |
this.text.setText(""); |
124 |
this.value.setPhrase("");
|
|
128 |
this.value = null;
|
|
125 | 129 |
} else { |
126 | 130 |
this.value = value; |
127 | 131 |
this.text.setText(this.value.getPhrase()); |
Also available in: Unified diff