Revision 44902 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/DefaultJExpressionBuilderView2.java
DefaultJExpressionBuilderView2.java | ||
---|---|---|
12 | 12 |
import javax.swing.JPanel; |
13 | 13 |
import javax.swing.JScrollPane; |
14 | 14 |
import javax.swing.JSplitPane; |
15 |
import javax.swing.JTabbedPane; |
|
16 | 15 |
import javax.swing.JTextArea; |
17 | 16 |
import javax.swing.JTextField; |
18 | 17 |
import javax.swing.JTree; |
19 | 18 |
import javax.swing.border.EmptyBorder; |
19 |
import javax.swing.text.JTextComponent; |
|
20 |
import org.gvsig.expressionevaluator.swing.JTextComponentProxy; |
|
20 | 21 |
|
21 | 22 |
public class DefaultJExpressionBuilderView2 extends JPanel { |
22 | 23 |
|
23 |
private static class GridBagConstraintsBuilder {
|
|
24 |
protected static class GridBagConstraintsBuilder {
|
|
24 | 25 |
|
25 | 26 |
private GridBagConstraints gbc; |
26 | 27 |
|
... | ... | |
82 | 83 |
return this; |
83 | 84 |
} |
84 | 85 |
|
85 |
private GridBagConstraintsBuilder colspan(int n) {
|
|
86 |
public GridBagConstraintsBuilder colspan(int n) {
|
|
86 | 87 |
this.gbc.gridwidth = n; |
87 | 88 |
return this; |
88 | 89 |
} |
89 | 90 |
|
90 |
private GridBagConstraintsBuilder rowspan(int n) {
|
|
91 |
public GridBagConstraintsBuilder rowspan(int n) {
|
|
91 | 92 |
this.gbc.gridheight = n; |
92 | 93 |
return this; |
93 | 94 |
} |
94 | 95 |
|
95 |
private GridBagConstraintsBuilder span(int cols, int rows) {
|
|
96 |
public GridBagConstraintsBuilder span(int cols, int rows) {
|
|
96 | 97 |
this.gbc.gridwidth = cols; |
97 | 98 |
this.gbc.gridheight = rows; |
98 | 99 |
return this; |
99 | 100 |
} |
100 | 101 |
|
101 |
private GridBagConstraintsBuilder nospan() {
|
|
102 |
public GridBagConstraintsBuilder nospan() {
|
|
102 | 103 |
this.gbc.gridwidth = 1; |
103 | 104 |
this.gbc.gridheight = 1; |
104 | 105 |
return this; |
... | ... | |
115 | 116 |
JTree treeElements = new JTree(); |
116 | 117 |
JScrollPane scrElements = new JScrollPane(); |
117 | 118 |
|
118 |
JTextArea txtExpression = new JTextArea(); |
|
119 |
protected JTextComponentProxy txtExpression = new JTextComponentProxy() { |
|
120 |
JTextComponent text = new JTextArea(); |
|
121 |
@Override |
|
122 |
public JTextComponent getJTextComponent() { |
|
123 |
return text; |
|
124 |
} |
|
125 |
}; |
|
126 |
|
|
119 | 127 |
JScrollPane scrExpression = new JScrollPane(); |
120 | 128 |
|
121 | 129 |
JButton btnHistory = new JButton(); |
... | ... | |
153 | 161 |
JPanel pnlTop; |
154 | 162 |
JPanel pnlElement; |
155 | 163 |
|
164 |
EmptyBorder emptyborder2x2 = new EmptyBorder(2, 2, 2, 2); |
|
156 | 165 |
/** |
157 | 166 |
* Default constructor |
158 | 167 |
*/ |
... | ... | |
160 | 169 |
initComponents(); |
161 | 170 |
} |
162 | 171 |
|
163 |
private void initComponents() { |
|
164 |
EmptyBorder emptyborder2x2 = new EmptyBorder(2, 2, 2, 2); |
|
172 |
protected void initComponents0() { |
|
165 | 173 |
|
166 | 174 |
lstSimpleElement.setName("lstSimpleElement"); |
167 | 175 |
|
168 | 176 |
treeElements.setName("treeElements"); |
169 | 177 |
pnlDescription.setName("pnlDescription"); |
170 |
txtExpression.setLineWrap(true); |
|
171 |
txtExpression.setName("txtExpression"); |
|
172 |
txtExpression.setRows(2); |
|
178 |
getExpressionComponent().setName("txtExpression"); |
|
179 |
if( this.getExpressionComponent() instanceof JTextArea ) { |
|
180 |
((JTextArea)getExpressionComponent()).setLineWrap(true); |
|
181 |
((JTextArea)getExpressionComponent()).setRows(2); |
|
182 |
} |
|
173 | 183 |
|
174 | 184 |
|
175 | 185 |
btnHistory.setActionCommand("+"); |
... | ... | |
271 | 281 |
btnSimpleElementFilter.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.impl/src/main/resources/org/gvsig/expressionevaluator/swing/impl/common-filter.png")); |
272 | 282 |
btnSimpleElementFilter.setName("btnSimpleElementFilter"); |
273 | 283 |
btnSimpleElementFilter.setBorder(emptyborder2x2); |
274 |
|
|
275 |
// pnlScriptEditorContainer.setName("pnlScriptEditorContainer"); |
|
276 |
// |
|
277 |
// cboPickerScripts.setName("cboPickerScripts"); |
|
278 |
// |
|
279 |
// btnPickerRemove.setActionCommand("+"); |
|
280 |
// btnPickerRemove.setName("btnPickerRemove"); |
|
281 |
// btnPickerRemove.setText("R"); |
|
282 |
// btnPickerRemove.setBorder(emptyborder2x2); |
|
283 |
// |
|
284 |
// btnPickerSelectScript.setActionCommand("+"); |
|
285 |
// btnPickerSelectScript.setName("btnPickerSelectScript"); |
|
286 |
// btnPickerSelectScript.setText("S"); |
|
287 |
// btnPickerSelectScript.setBorder(emptyborder2x2); |
|
288 |
|
|
284 |
} |
|
285 |
|
|
286 |
public JTextComponent getExpressionComponent() { |
|
287 |
return this.txtExpression.getJTextComponent(); |
|
288 |
} |
|
289 |
|
|
290 |
protected void initComponents1() { |
|
289 | 291 |
this.scrExpression = new JScrollPane(); |
290 |
this.scrExpression.setViewportView(txtExpression);
|
|
292 |
this.scrExpression.setViewportView(getExpressionComponent());
|
|
291 | 293 |
this.scrExpression.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
292 | 294 |
this.scrExpression.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
293 | 295 |
|
... | ... | |
316 | 318 |
this.spnlItem.setBorder(emptyborder2x2); |
317 | 319 |
this.spnlItem.setOneTouchExpandable(true); |
318 | 320 |
|
319 |
// this.tabExpressionBuilder.setName("tabExpressionBuilder"); |
|
320 |
// this.tabExpressionBuilder.addTab("_Expression", null, this.spnlExpression); |
|
321 |
// this.tabExpressionBuilder.addTab("_Scripts", null, this.pnlScriptEditorContainer); |
|
322 |
|
|
323 | 321 |
this.setLayout(new BorderLayout()); |
324 |
// this.add(tabExpressionBuilder, BorderLayout.CENTER); |
|
325 | 322 |
this.add(this.spnlExpression, BorderLayout.CENTER); |
326 | 323 |
this.add(pnlCfgActions, BorderLayout.PAGE_START); |
327 |
|
|
328 | 324 |
} |
329 | 325 |
|
330 |
private JPanel getPanelTop() { |
|
326 |
protected void initComponents() { |
|
327 |
this.initComponents0(); |
|
328 |
this.initComponents1(); |
|
329 |
} |
|
330 |
|
|
331 |
protected JPanel getPanelTop() { |
|
331 | 332 |
if (this.pnlTop == null) { |
332 | 333 |
GridBagConstraintsBuilder cs = new GridBagConstraintsBuilder(); |
333 | 334 |
cs.anchor(GridBagConstraints.CENTER); |
334 | 335 |
cs.fill(GridBagConstraints.BOTH); |
335 | 336 |
|
336 |
JPanel pnlRight = new JPanel(); |
|
337 |
pnlRight.setLayout(new GridBagLayout()); |
|
338 |
pnlRight.add(this.btnHistory, cs.xy(0, 0).get()); |
|
339 |
pnlRight.add(this.btnBookmarks, cs.xy(1, 0).get()); |
|
340 |
pnlRight.add(this.btnEq, cs.xy(0, 1).get()); |
|
341 |
pnlRight.add(this.btnNeq, cs.xy(1, 1).get()); |
|
342 |
pnlRight.add(this.btnAdd, cs.xy(2, 1).get()); |
|
343 |
pnlRight.add(this.btnSubst, cs.xy(3, 1).get()); |
|
344 |
pnlRight.add(this.btnMult, cs.xy(0, 2).get()); |
|
345 |
pnlRight.add(this.btnDiv, cs.xy(1, 2).get()); |
|
346 |
pnlRight.add(this.btnParentOpen, cs.xy(2, 2).get()); |
|
347 |
pnlRight.add(this.btnParentClose, cs.xy(3, 2).get()); |
|
348 |
pnlRight.add(new JLabel(), cs.xy(0, 3).span(4,0).grow(1, 1).get()); |
|
337 |
JPanel pnlRight = createPanelOperators(); |
|
338 |
JPanel pnlLeft = createPanelExpressionWithMessages(); |
|
349 | 339 |
|
350 |
JPanel pnlLeft = new JPanel(); |
|
351 |
pnlLeft.setLayout(new GridBagLayout()); |
|
352 |
pnlLeft.add(this.scrExpression, cs.xy(0, 0).span(3, 1).grow(1, 1).get()); |
|
353 |
pnlLeft.add(this.lblMsg, cs.xy(0, 1).nospan().grow(1, 0).get()); |
|
354 |
pnlLeft.add(this.btnTip, cs.xy(1, 1).nospan().nogrow().get()); |
|
355 |
pnlLeft.add(this.lblColumn, cs.xy(2, 1).nospan().nogrow().get()); |
|
356 |
|
|
357 | 340 |
JPanel panel = new JPanel(); |
358 | 341 |
panel.setLayout(new GridBagLayout()); |
359 | 342 |
panel.add(pnlLeft, cs.xy(0, 0).nospan().grow(1, 1).get()); |
... | ... | |
364 | 347 |
return this.pnlTop; |
365 | 348 |
} |
366 | 349 |
|
367 |
private JPanel getPanelElement() { |
|
350 |
protected JPanel createPanelExpressionWithMessages() { |
|
351 |
GridBagConstraintsBuilder cs = new GridBagConstraintsBuilder(); |
|
352 |
cs.anchor(GridBagConstraints.CENTER); |
|
353 |
cs.fill(GridBagConstraints.BOTH); |
|
354 |
|
|
355 |
JPanel panel = new JPanel(); |
|
356 |
panel.setLayout(new GridBagLayout()); |
|
357 |
panel.add(this.scrExpression, cs.xy(0, 0).span(3, 1).grow(1, 1).get()); |
|
358 |
panel.add(this.lblMsg, cs.xy(0, 1).nospan().grow(1, 0).get()); |
|
359 |
panel.add(this.btnTip, cs.xy(1, 1).nospan().nogrow().get()); |
|
360 |
panel.add(this.lblColumn, cs.xy(2, 1).nospan().nogrow().get()); |
|
361 |
return panel; |
|
362 |
} |
|
363 |
|
|
364 |
protected JPanel createPanelOperators() { |
|
365 |
GridBagConstraintsBuilder cs = new GridBagConstraintsBuilder(); |
|
366 |
cs.anchor(GridBagConstraints.CENTER); |
|
367 |
cs.fill(GridBagConstraints.BOTH); |
|
368 |
|
|
369 |
JPanel panel = new JPanel(); |
|
370 |
panel.setLayout(new GridBagLayout()); |
|
371 |
panel.add(this.btnHistory, cs.xy(0, 0).get()); |
|
372 |
panel.add(this.btnBookmarks, cs.xy(1, 0).get()); |
|
373 |
panel.add(this.btnEq, cs.xy(0, 1).get()); |
|
374 |
panel.add(this.btnNeq, cs.xy(1, 1).get()); |
|
375 |
panel.add(this.btnAdd, cs.xy(2, 1).get()); |
|
376 |
panel.add(this.btnSubst, cs.xy(3, 1).get()); |
|
377 |
panel.add(this.btnMult, cs.xy(0, 2).get()); |
|
378 |
panel.add(this.btnDiv, cs.xy(1, 2).get()); |
|
379 |
panel.add(this.btnParentOpen, cs.xy(2, 2).get()); |
|
380 |
panel.add(this.btnParentClose, cs.xy(3, 2).get()); |
|
381 |
panel.add(new JLabel(), cs.xy(0, 3).span(4,0).grow(1, 1).get()); |
|
382 |
return panel; |
|
383 |
} |
|
384 |
|
|
385 |
protected JPanel getPanelElement() { |
|
368 | 386 |
if (this.pnlElement == null) { |
369 | 387 |
GridBagConstraintsBuilder cs = new GridBagConstraintsBuilder(); |
370 | 388 |
cs.anchor(GridBagConstraints.CENTER); |
Also available in: Unified diff