Revision 45166 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featurequery/DefaultFeatureQueryCalculatedColumnsPanel.java
DefaultFeatureQueryCalculatedColumnsPanel.java | ||
---|---|---|
62 | 62 |
public class DefaultFeatureQueryCalculatedColumnsPanel |
63 | 63 |
extends DefaultFeatureQueryCalculatedColumnsPanelView |
64 | 64 |
implements FeatureQueryCalculatedColumnsPanel { |
65 |
|
|
66 |
private class AttributeListElement extends ListElement { |
|
67 |
|
|
68 |
public AttributeListElement(FeatureAttributeDescriptor value) { |
|
69 |
super(value.getLabel(), value); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String getLabel() { |
|
74 |
return ((FeatureAttributeDescriptor) this.getValue()).getName(); |
|
75 |
} |
|
76 |
|
|
77 |
} |
|
65 | 78 |
|
66 | 79 |
private class ColumnController implements DocumentListener, ChangeListener, ActionListener { |
67 | 80 |
|
... | ... | |
80 | 93 |
private final JTextComponent txtScale; |
81 | 94 |
|
82 | 95 |
private final Logger LOGGER = LoggerFactory.getLogger(ColumnController.class); |
96 |
private final JButton btnColumnMore; |
|
97 |
private final JButton btnApplyChanges; |
|
83 | 98 |
|
84 | 99 |
public ColumnController( |
85 | 100 |
JTextComponent txtName, |
... | ... | |
91 | 106 |
JButton btnExpressionBookmarks, |
92 | 107 |
JTextComponent txtSize, |
93 | 108 |
JTextComponent txtPrecision, |
94 |
JTextComponent txtScale |
|
109 |
JTextComponent txtScale, |
|
110 |
JButton btnApplyChanges, |
|
111 |
JButton btnColumnMore |
|
95 | 112 |
) { |
96 | 113 |
this.txtName = txtName; |
97 | 114 |
this.cboDataType = cboDataType; |
... | ... | |
103 | 120 |
this.txtSize = txtSize; |
104 | 121 |
this.txtPrecision = txtPrecision; |
105 | 122 |
this.txtScale = txtScale; |
123 |
this.btnApplyChanges = btnApplyChanges; |
|
124 |
this.btnColumnMore = btnColumnMore; |
|
106 | 125 |
this.hasChanges = false; |
107 | 126 |
this.initComponents(); |
108 | 127 |
this.setEnabled(false); |
... | ... | |
184 | 203 |
this.txtSize.setEnabled(enabled); |
185 | 204 |
this.txtPrecision.setEnabled(enabled); |
186 | 205 |
this.txtScale.setEnabled(enabled); |
206 |
this.btnApplyChanges.setEnabled(enabled); |
|
207 |
this.btnColumnMore.setEnabled(enabled); |
|
187 | 208 |
} |
188 | 209 |
|
189 | 210 |
public void clean() { |
... | ... | |
193 | 214 |
this.txtSize.setText(""); |
194 | 215 |
this.txtPrecision.setText(""); |
195 | 216 |
this.txtScale.setText(""); |
217 |
this.btnApplyChanges.setEnabled(false); |
|
218 |
this.btnColumnMore.setEnabled(false); |
|
219 |
this.hasChanges = false; |
|
196 | 220 |
|
197 | 221 |
} |
198 | 222 |
|
... | ... | |
230 | 254 |
} |
231 | 255 |
} |
232 | 256 |
// doEnabledByDataType(); |
257 |
this.btnColumnMore.setEnabled(true); |
|
258 |
this.btnApplyChanges.setEnabled(false); |
|
233 | 259 |
this.hasChanges = false; |
234 | 260 |
} |
235 | 261 |
|
... | ... | |
260 | 286 |
LOGGER.warn("Not able to coerce text to integer from scale box.", ex); |
261 | 287 |
} |
262 | 288 |
this.hasChanges = false; |
289 |
this.btnColumnMore.setEnabled(true); |
|
290 |
this.btnApplyChanges.setEnabled(false); |
|
263 | 291 |
return attr; |
264 | 292 |
} |
265 | 293 |
|
266 | 294 |
private void doHasChanges() { |
295 |
this.btnApplyChanges.setEnabled(true); |
|
267 | 296 |
this.hasChanges = true; |
268 | 297 |
} |
269 | 298 |
|
... | ... | |
374 | 403 |
this.btnColumnExpressionBookmarks, |
375 | 404 |
this.txtColumnSize, |
376 | 405 |
this.txtColumnPrecision, |
377 |
this.txtColumnScale |
|
406 |
this.txtColumnScale, |
|
407 |
this.btnApplyChanges, |
|
408 |
this.btnColumnMore |
|
378 | 409 |
); |
379 | 410 |
// this.lstAttributes.setCellRenderer(new FeatureAttributeListCellRenderer()); |
380 | 411 |
|
... | ... | |
411 | 442 |
}); |
412 | 443 |
|
413 | 444 |
this.btnAdd.addActionListener((ActionEvent e) -> { |
414 |
doAdd(); |
|
445 |
if (checkColumnControllerHasChangesWithUser()) { |
|
446 |
doAdd(); |
|
447 |
} |
|
415 | 448 |
}); |
416 | 449 |
|
417 | 450 |
this.btnRemove.addActionListener((ActionEvent e) -> { |
... | ... | |
433 | 466 |
this.btnColumnMore.addActionListener((ActionEvent e) -> { |
434 | 467 |
doColumnMore(); |
435 | 468 |
}); |
436 |
|
|
469 |
|
|
437 | 470 |
} |
438 | 471 |
|
439 | 472 |
private boolean checkColumnControllerHasChangesWithUser() { |
440 |
if (columnController.hasChanges()) {
|
|
473 |
if (this.hasChanges()) {
|
|
441 | 474 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
442 | 475 |
String message = i18n.getTranslation("_Changes_has_not_been_saved_Are_you_sure_you_want_to_continue"); |
443 | 476 |
String title = i18n.getTranslation("_Changes_not_saved"); |
... | ... | |
532 | 565 |
|
533 | 566 |
@Override |
534 | 567 |
public FeatureQuery fetch(FeatureQuery query) { |
568 |
if (hasChanges()) { |
|
569 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
570 |
String message = i18n.getTranslation("_Changes_has_not_been_saved_Do_you_want_to_save_them_before_continue"); |
|
571 |
String title = i18n.getTranslation("_Changes_not_saved"); |
|
572 |
int r = ToolsSwingLocator.getThreadSafeDialogsManager().confirmDialog(message, title, |
|
573 |
JOptionPane.YES_NO_OPTION, |
|
574 |
JOptionPane.QUESTION_MESSAGE); |
|
575 |
if (r == JOptionPane.YES_NO_OPTION) { |
|
576 |
doApplyChanges(); |
|
577 |
} |
|
578 |
} |
|
579 |
|
|
535 | 580 |
if (query == null) { |
536 | 581 |
return this.query.getCopy(); |
537 | 582 |
} |
... | ... | |
564 | 609 |
return; |
565 | 610 |
} |
566 | 611 |
for (EditableFeatureAttributeDescriptor col : cols) { |
567 |
ListElement lf = new ListElement(col.getLabel(), col);
|
|
612 |
ListElement lf = new AttributeListElement(col);
|
|
568 | 613 |
this.lstAttributesModel.addElement(lf); |
569 | 614 |
} |
570 | 615 |
if (this.lstAttributesModel.getSize() > 0) { |
... | ... | |
604 | 649 |
this.columnController.put(newAttr); |
605 | 650 |
this.columnController.setEnabled(true); |
606 | 651 |
|
607 |
this.lstAttributesModel.addElement(new ListElement(newAttr.getName(), newAttr));
|
|
652 |
this.lstAttributesModel.addElement(new AttributeListElement(newAttr));
|
|
608 | 653 |
ListElement.setSelected(this.lstAttributes, newAttr); |
654 |
this.lstAttributes.revalidate(); |
|
655 |
this.lstAttributes.repaint(); |
|
609 | 656 |
this.actualEditableAttribute = newAttr; |
610 | 657 |
|
611 | 658 |
} |
... | ... | |
647 | 694 |
private void doApplyChanges() { |
648 | 695 |
this.columnController.fetch(this.actualEditableAttribute); |
649 | 696 |
this.lstAttributes.invalidate(); |
697 |
this.lstAttributes.repaint(); |
|
650 | 698 |
} |
651 | 699 |
|
652 | 700 |
private void doUp(JList lstColumns) { |
Also available in: Unified diff