Revision 47378 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/impl/DefaultEditingNotificationManager.java

View differences:

DefaultEditingNotificationManager.java
28 28
import java.util.HashMap;
29 29
import java.util.List;
30 30
import java.util.Map;
31
import java.util.Objects;
31 32
import javax.swing.JComponent;
32 33
import javax.swing.SwingUtilities;
33 34
import org.apache.commons.lang.StringUtils;
......
52 53
import org.gvsig.fmap.dal.feature.EditableFeatureType;
53 54
import org.gvsig.fmap.dal.feature.Feature;
54 55
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
56
import org.gvsig.fmap.dal.feature.FeatureReference;
57
import org.gvsig.fmap.dal.feature.FeatureRule;
55 58
import org.gvsig.fmap.dal.feature.FeatureStore;
56 59
import org.gvsig.fmap.dal.feature.FeatureType;
60
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException;
57 61
import org.gvsig.fmap.dal.swing.DALSwingLocator;
58 62
import org.gvsig.tools.ToolsLocator;
59 63
import org.gvsig.tools.dynobject.DynObjectManager;
......
290 294
        Tags tags = featureType.getTags();
291 295
        boolean forceShowForm = tags != null && tags.getBoolean(TAG_FORCE_SHOW_FORM_ON_INSERT, false);
292 296
        while( true ) {
293
            if( !forceShowForm ) {
297
            boolean validateOk = true;
298
            if( feature instanceof EditableFeature ) {
299
                // Esto deberia ser siempre cierto.
300
                try {
301
                    for (FeatureRule rule : featureType.getRules()) {
302
                        if( rule != null ) {
303
                            if( rule.checkWhen(FeatureRule.CHECK_WHEN_USER_EDIT_FEATURE) ) {
304
                                try {
305
                                    rule.validate((EditableFeature) feature, feature.getStore());
306
                                } catch (ValidateFeaturesException ex) {
307
                                    validateOk = false;
308
                                } catch (Exception ex) {
309
                                    FeatureReference ref = feature.getReference();
310
                                    LOGGER.warn("Can't run validate rule '"+rule.getName()+"' on feature '"+Objects.toString(ref)+"'.", ex);
311
                                }
312
                            }
313
                        }
314
                    } 
315
                } catch (Exception ex) {
316
                    FeatureReference ref = feature.getReference();
317
                    LOGGER.warn("Can't run validate feature '"+Objects.toString(ref)+"'.");
318
                }
319
            }
320
            if( validateOk && !forceShowForm ) {
294 321
                if( canWriteFeature(feature) ) {
295 322
                    // La feature se puede validar y no precisa de intervencion del
296 323
                    // usuario. Retornamos true.
......
312 339
        }
313 340
    }
314 341
    
342
    @Override
315 343
    public boolean canWriteFeature(Feature feature) {
316 344
        FeatureType featureType = feature.getType();
317 345
        if( !featureType.isCheckFeaturesAtInsert() ) {

Also available in: Unified diff