Changeset 5675 in josm for trunk


Ignore:
Timestamp:
2013-01-27T14:36:50+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #8382 - CCE in TaggingPreset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r5643 r5675  
    513513        }
    514514
     515        private static String getValue(Component comp) {
     516            if (comp instanceof JosmComboBox) {
     517                return ((JosmComboBox) comp).getEditor().getItem().toString();
     518            } else if (comp instanceof JTextField) {
     519                return ((JTextField) comp).getText();
     520            } else if (comp instanceof JPanel) {
     521                return getValue(((JPanel)comp).getComponent(0));
     522            } else {
     523                return null;
     524            }
     525        }
     526       
    515527        @Override
    516528        public void addCommands(List<Tag> changedTags) {
    517529
    518530            // return if unchanged
    519             String v = null;
    520             if (value instanceof JosmComboBox) {
    521                 v = ((JosmComboBox) value).getEditor().getItem().toString();
    522             } else if (value instanceof JTextField) {
    523                 v = ((JTextField) value).getText();
    524             } else if (value instanceof JPanel) {
    525                 // this is what was alluded to with "ugly fashion" above.
    526                 v = ((JTextField) (((JPanel)value).getComponent(0))).getText();
    527             } else {
     531            String v = getValue(value);
     532            if (v == null) {
    528533                System.err.println("No 'last value' support for component " + value);
    529534                return;
    530535            }
    531                
     536           
    532537            v = v.trim();
    533538
Note: See TracChangeset for help on using the changeset viewer.