Revision 4221

View differences:

org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text.properties
299 299
_Cant_calculate_opposite_vertices=No se han podido calcular los v\u00e9rtices opuestos
300 300
_Show_editing_tool_options=Mostrar las opciones de las herramientas de edicion
301 301
_There_are_problems_saving_changes=Problemas guardando los cambios
302
_See_error_log_for_more_information=Mire el registro de errores para m\u00e1s informaci\u00f3n
302
_See_error_log_for_more_information=Mire el registro de errores para m\u00e1s informaci\u00f3n
303
_Keep_when_null=Mantener cuando sea nulo
304
_It_does_not_replace_the_default_values_when_the_marker_is_null=No sustituye los valores por defecto cuando en el marcador esten a nulo.
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
297 297
_Cant_calculate_opposite_vertices=Can't calculate opposite vertices
298 298
_Show_editing_tool_options=Show editing tool options
299 299
_There_are_problems_saving_changes=There are problems saving changes
300
_See_error_log_for_more_information=See error log for more information
300
_See_error_log_for_more_information=See error log for more information
301
_Keep_when_null=Keep when null
302
_It_does_not_replace_the_default_values_when_the_marker_is_null=It does not replace the default values when the marker is null.
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/EditingToolOptionsPanel.java
21 21
import javax.json.JsonValue;
22 22
import javax.swing.ImageIcon;
23 23
import javax.swing.JButton;
24
import javax.swing.JCheckBoxMenuItem;
24 25
import javax.swing.JLabel;
25 26
import javax.swing.JPanel;
26 27
import javax.swing.JTabbedPane;
......
110 111
    private static int currentTab = 0;
111 112
    private JButton acceptOptionsButton;
112 113
    private JTextField txtBookmarkName;
114
    private JCheckBoxMenuItem keepWhenNullInMarkerMenuItem;
115
    
113 116
    private KeyListener keylistener = new KeyListener() {
114 117
        @Override
115 118
        public void keyTyped(KeyEvent e) {
......
266 269
                BookmarksController bookmarksController = ToolsSwingLocator.getToolsSwingManager().createBookmarksController(
267 270
                        bookmarks,
268 271
                        bookmarksButton
269
                );
272
                );                
273
                bookmarksController.addMenuItem(this.getKeepWhenNullInMarkerMenuItem());
270 274
                bookmarksController.addActionListener((ActionEvent e) -> {
271 275
                    EditableFeature feature;
276
                    EditingToolOptionsDefaultValueBookmark bookmark;
272 277
                    BookmarkEvent<EditingToolOptionsDefaultValueBookmark> b = (BookmarkEvent<EditingToolOptionsDefaultValueBookmark>) e;
273 278
                    switch (b.getID()) {
274 279
                        case ID_GETVALUE:
275
                            EditingToolOptionsDefaultValueBookmark bookmark = new EditingToolOptionsDefaultValueBookmark();
280
                            bookmark = new EditingToolOptionsDefaultValueBookmark();
276 281
                            bookmark.setDefaultValues(service.getDefaultFeatureValues());
282
                            bookmark.setKeepWhenNullInMarker(this.getKeepWhenNullInMarkerMenuItem().isSelected());
277 283
                            b.setCurrentValue(bookmark);
278 284
                            break;
279 285
                        case ID_SETVALUE:
280 286
                            if (b.getCurrentValue() == null) {
281 287
                                return;
282 288
                            }
283
                            JsonObject bookmarkFeature = b.getCurrentValue().getDefaultValues();
284
                            feature = service.getDefaultFeatureValues();
285
                            feature.copyFrom(bookmarkFeature);
289
                            bookmark = b.getCurrentValue();
290
                            this.getKeepWhenNullInMarkerMenuItem().setSelected(bookmark.getKeepWhenNullInMarker());
291
                            JsonObject bookmarkFeature = bookmark.getDefaultValues();
292
                            feature = service.getDefaultFeatureValues(); this.featureform.fetch(feature);
293
                            boolean keepWhenNull = this.getKeepWhenNullInMarkerMenuItem().isSelected();
294
                            feature.copyFrom(
295
                                    bookmarkFeature, 
296
                                    (FeatureAttributeDescriptor t) -> !(keepWhenNull && bookmarkFeature.getOrDefault(t.getName(), null)==null)
297
                            );
286 298
                            featureform.setFeature(feature);
287 299
                            applyDefaultValues();
288 300
                            txtBookmarkName.setText(b.getBookmark().getName());
289 301
                            txtBookmarkName.setCaretPosition(0);
290 302
                            break;
303

  
291 304
                    }
292 305
                });
293 306

  
......
692 705
    public static class EditingToolOptionsDefaultValueBookmark implements Persistent {
693 706
        
694 707
        private JsonObject values;
708
        private boolean keepWhenNullInMarker;
695 709
        private String label;
696 710
        
697 711
        public EditingToolOptionsDefaultValueBookmark() {
......
733 747
        @Override
734 748
        public void saveToState(PersistentState state) throws PersistenceException {            
735 749
            state.set("values", Objects.toString(this.values,null));
750
            state.set("keepWhenNullInMarker",this.keepWhenNullInMarker);
736 751
        }
737 752

  
738 753
        @Override
......
747 762
                    LOGGER.warn("Can't restore default value from persistence", ex);
748 763
                }
749 764
            }
765
            this.keepWhenNullInMarker = state.getBoolean("keepWhenNullInMarker", false);
750 766
        }
767

  
768
        public void setKeepWhenNullInMarker(boolean keepWhenNullInMarker) {
769
            this.keepWhenNullInMarker = keepWhenNullInMarker;
770
        }
771

  
772
        public boolean getKeepWhenNullInMarker() {
773
            return this.keepWhenNullInMarker;
774
        }
751 775
    }
752 776
    
753 777
    public static void registerPersistence() {
......
756 780
            DynStruct definition = manager.addDefinition(EditingToolOptionsDefaultValueBookmark.class,
757 781
                    "EditingToolOptionsDefaultValueBookmark", "EditingToolOptionsDefaultValueBookmark persistence definition", null, null);
758 782
            definition.addDynFieldString("values");
783
            definition.addDynFieldBoolean("keepWhenNullInMarker").setMandatory(false);
759 784
        }
760 785
    }
761 786
    
......
830 855

  
831 856
        return panel;
832 857
    }
833
    
858

  
859
    private JCheckBoxMenuItem getKeepWhenNullInMarkerMenuItem() {
860
       if( keepWhenNullInMarkerMenuItem == null ) {
861
           I18nManager i18n = ToolsLocator.getI18nManager();
862
           JCheckBoxMenuItem item = new JCheckBoxMenuItem();
863
           item.setText(i18n.getTranslation("_Keep_when_null"));
864
           item.setToolTipText(i18n.getTranslation("_It_does_not_replace_the_default_values_when_the_marker_is_null"));
865
           keepWhenNullInMarkerMenuItem = item;
866
       }
867
       return keepWhenNullInMarkerMenuItem;
868
    }
834 869
}

Also available in: Unified diff