1 | Orients adding properties
|
---|
2 |
|
---|
3 | From: <>
|
---|
4 |
|
---|
5 |
|
---|
6 | ---
|
---|
7 |
|
---|
8 | .../josm/gui/dialogs/PropertiesDialog.java | 39 +++++++++++++++++++----
|
---|
9 | 1 files changed, 32 insertions(+), 7 deletions(-)
|
---|
10 |
|
---|
11 | diff --git a/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java b/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
|
---|
12 | index 80ee10a..36e9f58 100644
|
---|
13 | --- a/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
|
---|
14 | +++ b/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
|
---|
15 | @@ -23,6 +23,7 @@ import java.util.Vector;
|
---|
16 | import java.util.Map.Entry;
|
---|
17 |
|
---|
18 | import javax.swing.Box;
|
---|
19 | +import javax.swing.ComboBoxModel;
|
---|
20 | import javax.swing.DefaultComboBoxModel;
|
---|
21 | import javax.swing.JButton;
|
---|
22 | import javax.swing.JComboBox;
|
---|
23 | @@ -177,20 +178,44 @@ public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
---|
24 | JPanel p = new JPanel(new BorderLayout());
|
---|
25 | p.add(new JLabel("<html>"+trn("This will change {0} object.","This will change {0} objects.", sel.size(),sel.size())+"<br><br>"+tr("Please select a key")),
|
---|
26 | BorderLayout.NORTH);
|
---|
27 | - TreeSet<String> allKeys = new TreeSet<String>();
|
---|
28 | - for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives())
|
---|
29 | - allKeys.addAll(osm.keySet());
|
---|
30 | + final TreeMap<String,TreeSet<String>> allData = new TreeMap<String,TreeSet<String>>();
|
---|
31 | + for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) {
|
---|
32 | + for (String key : osm.keySet()) {
|
---|
33 | + TreeSet<String> values = null;
|
---|
34 | + if (allData.containsKey(key))
|
---|
35 | + values = allData.get(key);
|
---|
36 | + else {
|
---|
37 | + values = new TreeSet<String>();
|
---|
38 | + allData.put(key, values);
|
---|
39 | + }
|
---|
40 | + values.add(osm.get(key));
|
---|
41 | + }
|
---|
42 | + }
|
---|
43 | for (int i = 0; i < data.getRowCount(); ++i)
|
---|
44 | - allKeys.remove(data.getValueAt(i, 0));
|
---|
45 | - final JComboBox keys = new JComboBox(new Vector<String>(allKeys));
|
---|
46 | + allData.remove(data.getValueAt(i, 0));
|
---|
47 | + final JComboBox keys = new JComboBox(new Vector<String>(allData.keySet()));
|
---|
48 | keys.setEditable(true);
|
---|
49 | p.add(keys, BorderLayout.CENTER);
|
---|
50 |
|
---|
51 | JPanel p2 = new JPanel(new BorderLayout());
|
---|
52 | p.add(p2, BorderLayout.SOUTH);
|
---|
53 | p2.add(new JLabel(tr("Please select a value")), BorderLayout.NORTH);
|
---|
54 | - final JTextField values = new JTextField();
|
---|
55 | + final JComboBox values = new JComboBox();
|
---|
56 | + values.setEditable(true);
|
---|
57 | p2.add(values, BorderLayout.CENTER);
|
---|
58 | +
|
---|
59 | + ActionListener link = new ActionListener() {
|
---|
60 | +
|
---|
61 | + public void actionPerformed(ActionEvent e) {
|
---|
62 | + String key = keys.getEditor().getItem().toString();
|
---|
63 | + Vector<String> newValues = new Vector<String>(allData.get(key));
|
---|
64 | + values.setModel(new DefaultComboBoxModel(newValues));
|
---|
65 | +
|
---|
66 | + }
|
---|
67 | +
|
---|
68 | + };
|
---|
69 | + keys.addActionListener(link);
|
---|
70 | +
|
---|
71 | JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){
|
---|
72 | @Override public void selectInitialValue() {
|
---|
73 | keys.requestFocusInWindow();
|
---|
74 | @@ -201,7 +226,7 @@ public class PropertiesDialog extends ToggleDialog implements SelectionChangedLi
|
---|
75 | if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
|
---|
76 | return;
|
---|
77 | String key = keys.getEditor().getItem().toString();
|
---|
78 | - String value = values.getText();
|
---|
79 | + String value = values.getEditor().getItem().toString();
|
---|
80 | if (value.equals(""))
|
---|
81 | return;
|
---|
82 | Main.main.editLayer().add(new ChangePropertyCommand(sel, key, value));
|
---|