Changeset 352 in josm


Ignore:
Timestamp:
2007-10-08T00:04:33+02:00 (17 years ago)
Author:
gebner
Message:

Resurrect the JComboBox editor for properties with multiple values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r347 r352  
    136136                p.add(keyField, GBC.eol().fill(GBC.HORIZONTAL));
    137137                               
    138                 final JTextField valueField = new JTextField((String)propertyData.getValueAt(row, 1));
     138                final JComboBox valueField = (JComboBox) propertyData.getValueAt(row, 1);
    139139                p.add(new JLabel(tr("Value")), GBC.std());
    140140                p.add(Box.createHorizontalStrut(10), GBC.std());
     
    144144                        @Override public void selectInitialValue() {
    145145                                valueField.requestFocusInWindow();
    146                                 valueField.selectAll();
     146                                valueField.getEditor().selectAll();
    147147                        }
    148148                };
     
    154154                        }
    155155                });
     156                String oldValue = valueField.getEditor().getItem().toString();
    156157                dlg.setVisible(true);
    157158
     
    159160                if (answer == null || answer == JOptionPane.UNINITIALIZED_VALUE ||
    160161                                (answer instanceof Integer && (Integer)answer != JOptionPane.OK_OPTION)) {
    161                         return;
    162                 }
    163 
    164                 String value = valueField.getText();
     162                        valueField.getEditor().setItem(oldValue);
     163                        return;
     164                }
     165
     166                String value = valueField.getEditor().getItem().toString();
    165167                if (value.equals(tr("<different>")))
    166168                        return;
     
    288290                }
    289291                @Override public Class<?> getColumnClass(int columnIndex) {
    290                         return String.class;
     292                        return columnIndex == 1 ? Relation.class : String.class;
    291293                }
    292294        };
     
    300302                }
    301303                @Override public Class<?> getColumnClass(int columnIndex) {
    302                         return columnIndex == 1 ? Relation.class : String.class;
     304                        return String.class;
    303305                }
    304306        };
     
    349351                                Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
    350352                                if (c instanceof JLabel) {
    351                                         String str = (String) value;
     353                                        String str = ((JComboBox) value).getEditor().getItem().toString();
    352354                                        ((JLabel)c).setText(str);
    353355                                        if (str.equals(tr("<different>")))
     
    459461                }
    460462                for (Entry<String, Collection<String>> e : props.entrySet()) {
    461                         String value=(e.getValue().size() > 1 || valueCount.get(e.getKey()) != newSelection.size() ? tr("<different>") : e.getValue().iterator().next());
    462                         propertyData.addRow(new Object[]{e.getKey(), value});
     463            JComboBox value = new JComboBox(e.getValue().toArray());
     464            value.setEditable(true);
     465            value.getEditor().setItem(e.getValue().size() > 1 || valueCount.get(e.getKey()) != newSelection.size() ? tr("<different>") : e.getValue().iterator().next());
     466            propertyData.addRow(new Object[]{e.getKey(), value});
    463467                }
    464468               
Note: See TracChangeset for help on using the changeset viewer.