Ignore:
Timestamp:
2009-04-16T11:04:20+02:00 (15 years ago)
Author:
guggis
Message:

fixed problem with dirty state. Now sets the dialog into dirty state when either the name or the value of a tag is changed.

Location:
applications/editors/josm/plugins/tageditor
Files:
149 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/tageditor/build.number

    r14426 r14520  
    11#Build Number for ANT. Do not edit!
    2 #Wed Apr 08 11:49:48 CEST 2009
    3 build.number=186
     2#Thu Apr 16 11:00:52 CEST 2009
     3build.number=204
  • applications/editors/josm/plugins/tageditor/build.xml

    r14429 r14520  
    3838        <property name="plugin.description"     value="Provides a dialog for editing tags in a tabular grid."/>
    3939        <property name="plugin.doc.url"         value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/TagEditor"/>
    40         <property name="plugin.main.version"    value="0.7"/>   
     40        <property name="plugin.main.version"    value="1515"/> 
    4141    <property name="plugin.jar.name"        value="${ant.project.name}.jar"/>
    4242       
     
    7373                </exec>
    7474        <mkdir dir="${plugin.build.dir}"/>
    75     </target>
     75    </target>   
    7676       
    7777        <!--
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TableCellEditor.java

    r14416 r14520  
    3434        private TagFieldEditor editor = null;
    3535        private TagModel currentTag = null;
     36        private TagEditorModel tagEditorModel = null;
    3637        private int currentColumn = 0;
    3738
     
    194195        @Override
    195196        public boolean stopCellEditing() {
     197                if (tagEditorModel == null) {
     198                        logger.warning("no tag editor model set. Can't update edited values. Please set tag editor model first");
     199                        return super.stopCellEditing();
     200            }
    196201               
    197202                if (currentColumn == 0) {
    198                         currentTag.setName(editor.getText());
     203                        tagEditorModel.updateTagName(currentTag, editor.getText());
    199204                } else if (currentColumn == 1){
    200205                        if (currentTag.getValueCount() > 1 && ! editor.getText().equals("")) {
    201                                 currentTag.setValue(editor.getText());
     206                                tagEditorModel.updateTagValue(currentTag, editor.getText());           
    202207                        } else if (currentTag.getValueCount() <= 1) {
    203                                 currentTag.setValue(editor.getText());
     208                                tagEditorModel.updateTagValue(currentTag, editor.getText());
    204209                        }
    205210                }
     
    243248        }
    244249       
     250        /**
     251         * sets the tag editor model
     252         * 
     253         * @param tagEditorModel  the tag editor model
     254         */
     255        public void setTagEditorModel(TagEditorModel tagEditorModel) {
     256                this.tagEditorModel = tagEditorModel;
     257        }
     258       
    245259}
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java

    r14338 r14520  
    1010import javax.swing.JScrollPane;
    1111import javax.swing.ScrollPaneConstants;
    12 import javax.swing.table.TableCellEditor;
     12
    1313
    1414import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionCache;
     
    103103                // creates a default model and a default cache
    104104                //
    105                 tagEditorModel = new TagEditorModel();
    106                
     105                tagEditorModel = new TagEditorModel();         
    107106               
    108107                build();
     
    125124        public void setTagEditorModel(TagEditorModel tagEditorModel) {
    126125                tblTagEditor.setModel(tagEditorModel);
     126                for (int i=0; i<=1; i++) {
     127                        TableCellEditor editor = (TableCellEditor)tblTagEditor.getColumnModel().getColumn(i).getCellEditor();
     128                        if (editor != null) {
     129                                editor.setTagEditorModel(tagEditorModel);
     130                        }
     131                }
    127132                presetManager.setModel(tagEditorModel);
    128133        }
     
    145150       
    146151        public void stopEditing() {
    147                 TableCellEditor editor = tblTagEditor.getCellEditor();
     152                TableCellEditor editor = (TableCellEditor) tblTagEditor.getCellEditor();
    148153                if (editor != null) {
    149154                        editor.stopCellEditing();
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditorModel.java

    r14416 r14520  
    1313
    1414import javax.swing.DefaultComboBoxModel;
     15import javax.swing.SwingUtilities;
    1516import javax.swing.table.AbstractTableModel;
    1617
     
    6768        }
    6869       
    69         protected void fireDirtyStateChanged(boolean oldValue, boolean newValue) {
     70        protected void fireDirtyStateChanged(final boolean oldValue, final boolean newValue) {
    7071                propChangeSupport.firePropertyChange(PROP_DIRTY, oldValue, newValue);
    7172        }
     
    534535       
    535536       
     537        /**
     538         * updates the name of a tag and sets the dirty state to  true if
     539         * the new name is different from the old name. 
     540         *
     541         * @param tag   the tag
     542         * @param newName  the new name
     543         */
    536544        public void updateTagName(TagModel tag, String newName) {
    537545                String oldName = tag.getName();
     
    542550        }
    543551       
     552        /**
     553         * updates the value value of a tag and sets the dirty state to true if the
     554         * new name is different from the old name
     555         *
     556         * @param tag  the tag
     557         * @param newValue  the new value
     558         */
    544559        public void updateTagValue(TagModel tag, String newValue) {
    545560                String oldValue = tag.getValue();
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTable.java

    r14338 r14520  
    340340                //
    341341                editor = new TableCellEditor();
     342                editor.setTagEditorModel((TagEditorModel)getModel());
    342343                getColumnModel().getColumn(0).setCellEditor(editor);
    343344                getColumnModel().getColumn(1).setCellEditor(editor);
     
    468469
    469470        }
    470        
    471        
     471
    472472       
    473473}
Note: See TracChangeset for help on using the changeset viewer.