Revision 45739 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/featuretype/DefaultFeatureTypePanel.java
DefaultFeatureTypePanel.java | ||
---|---|---|
10 | 10 |
import javax.swing.AbstractAction; |
11 | 11 |
import javax.swing.JComponent; |
12 | 12 |
import javax.swing.JOptionPane; |
13 |
import javax.swing.JPanel; |
|
14 |
import javax.swing.JScrollBar; |
|
15 |
import javax.swing.JScrollPane; |
|
16 |
import javax.swing.JSplitPane; |
|
13 | 17 |
import javax.swing.event.ChangeListener; |
14 | 18 |
import javax.swing.event.ListSelectionEvent; |
15 | 19 |
import javax.swing.event.ListSelectionListener; |
... | ... | |
21 | 25 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
22 | 26 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
23 | 27 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
28 |
import org.gvsig.fmap.dal.feature.FeatureRule; |
|
24 | 29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
25 | 30 |
import org.gvsig.fmap.dal.feature.FeatureType; |
26 | 31 |
import org.gvsig.texteditor.JTextEditor; |
... | ... | |
50 | 55 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureTypePanel.class); |
51 | 56 |
|
52 | 57 |
private FeatureType originalFeatureType = null; |
58 |
private JSplitPane splRules; |
|
59 |
private JSplitPane splAttributes; |
|
53 | 60 |
|
54 | 61 |
private class FeatureTypeTableModel extends AbstractTableModel { |
55 | 62 |
|
... | ... | |
216 | 223 |
private boolean fieldSelectionAllowed; |
217 | 224 |
private TagsController tagsController; |
218 | 225 |
private ChangeListenerHelper changeListenerHelper; |
226 |
private AggregateController<FeatureRule> rulesController; |
|
219 | 227 |
|
220 | 228 |
public DefaultFeatureTypePanel() { |
221 | 229 |
this.mode = MODE_SHOW_ONLY; |
... | ... | |
224 | 232 |
this.initComponents(); |
225 | 233 |
} |
226 | 234 |
|
235 |
private JSplitPane createVerticalSplit(JPanel container, JPanel top, boolean scrolltop, JPanel bottom, boolean scrollbottom) { |
|
236 |
JComponent compTop = top; |
|
237 |
JComponent compBottom = bottom; |
|
238 |
if( scrolltop ) { |
|
239 |
compTop = new JScrollPane( |
|
240 |
top, |
|
241 |
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |
|
242 |
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER |
|
243 |
); |
|
244 |
} |
|
245 |
if( scrollbottom ) { |
|
246 |
compBottom = new JScrollPane( |
|
247 |
bottom, |
|
248 |
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |
|
249 |
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER |
|
250 |
); |
|
251 |
} |
|
252 |
JSplitPane split = new JSplitPane( |
|
253 |
JSplitPane.VERTICAL_SPLIT, |
|
254 |
false, |
|
255 |
compTop, |
|
256 |
compBottom |
|
257 |
); |
|
258 |
split.setOneTouchExpandable(true); |
|
259 |
container.removeAll(); |
|
260 |
container.setLayout(new BorderLayout()); |
|
261 |
container.add(split, BorderLayout.CENTER); |
|
262 |
return split; |
|
263 |
} |
|
264 |
|
|
227 | 265 |
@SuppressWarnings("Convert2Lambda") |
228 | 266 |
private void initComponents() { |
229 | 267 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
... | ... | |
232 | 270 |
this.pnlCfgActions.setLayout(new BorderLayout(0,0)); |
233 | 271 |
this.pnlCfgActions.add(c, BorderLayout.CENTER); |
234 | 272 |
|
273 |
this.splRules = createVerticalSplit( |
|
274 |
this.gridRules, |
|
275 |
this.gridRulesTable, false, |
|
276 |
this.gridRulesDetail, true |
|
277 |
); |
|
278 |
this.splAttributes = createVerticalSplit( |
|
279 |
this.gridAttributes, |
|
280 |
this.gridAttributesTable, false, |
|
281 |
this.gridAttributesDetail, true |
|
282 |
); |
|
283 |
|
|
235 | 284 |
this.changeListenerHelper = swingManager.createChangeListenerHelper(); |
236 | 285 |
|
237 | 286 |
swingManager.translate(this.btnDelete); |
... | ... | |
243 | 292 |
swingManager.translate(this.lblDescription); |
244 | 293 |
swingManager.translate(this.lblTags); |
245 | 294 |
swingManager.translate(this.tabFeatureType); |
295 |
swingManager.translate(this.lblRulesDefaultRules); |
|
296 |
swingManager.translate(this.lblRulesCustomRules); |
|
297 |
swingManager.translate(this.chkRulesValidateFeatureBeforeInsert); |
|
298 |
swingManager.translate(this.chkRulesValidateFeaturesAtFinishEditing); |
|
299 |
swingManager.translate(this.lblRuleName); |
|
300 |
swingManager.translate(this.lblRuleDescription); |
|
301 |
swingManager.translate(this.lblRuleCheckAtFinishEditing); |
|
302 |
swingManager.translate(this.lblRuleCheckAtUpdate); |
|
303 |
swingManager.translate(this.lblRuleValidation); |
|
304 |
swingManager.translate(this.btnRulesNew); |
|
305 |
swingManager.translate(this.btnRulesDelete); |
|
306 |
swingManager.translate(this.btnRuleFormFieldModify); |
|
307 |
swingManager.translate(this.btnRuleFormFieldAccept); |
|
308 |
swingManager.translate(this.btnRuleFormFieldDiscard); |
|
309 |
swingManager.translate(this.btnRuleValidation); |
|
310 |
swingManager.translate(this.btnRuleValidationBookmarks); |
|
311 |
swingManager.translate(this.btnRuleValidationHistory); |
|
246 | 312 |
|
247 | 313 |
this.tableModel = new FeatureTypeTableModel(); |
248 | 314 |
this.tblFields.setModel(this.tableModel); |
... | ... | |
301 | 367 |
lblTagsDescription |
302 | 368 |
); |
303 | 369 |
|
304 |
|
|
370 |
FeatureRuleController ruleController = new FeatureRuleController( |
|
371 |
txtRuleName, |
|
372 |
txtRuleDescription, |
|
373 |
chkRuleCheckAtFinishEditing, |
|
374 |
chkRuleCheckAtUpdate, |
|
375 |
txtRuleValidation, |
|
376 |
btnRuleValidation, |
|
377 |
btnRuleValidationBookmarks, |
|
378 |
btnRuleValidationHistory |
|
379 |
); |
|
380 |
|
|
381 |
this.rulesController = new DefaultAggregateController<>( |
|
382 |
this.tblRules, |
|
383 |
this.btnRuleFormFieldModify, |
|
384 |
this.btnRuleFormFieldDiscard, |
|
385 |
this.btnRuleFormFieldAccept, |
|
386 |
this.btnRulesNew, |
|
387 |
this.btnRulesDelete, |
|
388 |
ruleController |
|
389 |
); |
|
390 |
|
|
305 | 391 |
this.setPreferredSize(new Dimension(700, 500)); |
306 | 392 |
if( this.tblFields.getRowCount()>0 ) { |
307 | 393 |
this.tblFields.getSelectionModel().setSelectionInterval(0, 0); |
... | ... | |
421 | 507 |
} |
422 | 508 |
|
423 | 509 |
@Override |
424 |
public boolean isModifyingAField() {
|
|
425 |
return btnFormFieldAccept.isEnabled(); |
|
510 |
public boolean isEditing() {
|
|
511 |
return btnFormFieldAccept.isEnabled() || this.rulesController.isEditing();
|
|
426 | 512 |
} |
427 | 513 |
|
428 | 514 |
private void doFormFieldAccept() { |
... | ... | |
510 | 596 |
this.originalFeatureType = null; |
511 | 597 |
if (type == null) { |
512 | 598 |
this.store = null; |
599 |
this.rulesController.setModel(new FeatureRulesModel()); |
|
600 |
this.chkRuleCheckAtFinishEditing.setSelected(false); |
|
601 |
this.chkRuleCheckAtUpdate.setSelected(true); |
|
513 | 602 |
} else { |
514 | 603 |
FeatureType ftypeToCompare = type.getOriginalFeatureType(); |
515 | 604 |
if (ftypeToCompare == null) { |
... | ... | |
517 | 606 |
} |
518 | 607 |
this.originalFeatureType = ftypeToCompare.getCopy(); |
519 | 608 |
this.featureType = (EditableFeatureType) type.getCopy(); |
609 |
this.rulesController.setModel(new FeatureRulesModel(this.featureType.getRules())); |
|
610 |
this.chkRuleCheckAtFinishEditing.setSelected(type.isCheckFeaturesAtFinishEditing()); |
|
611 |
this.chkRuleCheckAtUpdate.setSelected(type.isCheckFeaturesAtInsert()); |
|
520 | 612 |
// Nos quedamos una referencia para evitar que se destruya, ya que |
521 | 613 |
// el featureType se guarda solo una WeakReference. |
522 | 614 |
this.store = type.getStore(); |
Also available in: Unified diff