diff --git a/fhrsPlugin/build.xml b/fhrsPlugin/build.xml index bc03eb1..1ed93f2 100644 --- a/fhrsPlugin/build.xml +++ b/fhrsPlugin/build.xml @@ -2,7 +2,7 @@ - + diff --git a/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/FHRSPlugin.java b/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/FHRSPlugin.java index 1899842..312885d 100644 --- a/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/FHRSPlugin.java +++ b/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/FHRSPlugin.java @@ -15,6 +15,7 @@ import org.openstreetmap.josm.gui.*; import org.openstreetmap.josm.plugins.*; +import org.openstreetmap.josm.tools.I18n; import java.awt.event.*; import java.io.BufferedReader; @@ -100,10 +101,10 @@ private void createMenu() { final MainMenu menu = MainApplication.getMenu(); if (FHRSMenu == null) { FHRSMenu = menu.addMenu("FHRS", "FHRS", 0, menu.getDefaultMenuPos(), "help"); - FHRSGet = new JMenuItem("Get information"); + FHRSGet = new JMenuItem(I18n.tr("Get information")); FHRSGet.setEnabled(true); FHRSGet.addActionListener(getFHRSAction); - FHRSSearch = new JMenuItem("Search entry"); + FHRSSearch = new JMenuItem(I18n.tr("Search entry")); FHRSSearch.setEnabled(true); FHRSSearch.addActionListener(searchFHRSAction); FHRSMenu.add(FHRSGet); @@ -320,7 +321,7 @@ public void updateObjectData(String fhrsId) { } } if (osmTags.size() > 0) { - Map osmTagsToSet = mergeTagsDialog.showTagsDialog(osmTags, warnCapitalization); + Map osmTagsToSet = mergeTagsDialog.showTagsDialog(osmTags, warnCapitalization, JsonToOSM); if (osmTagsToSet != null && osmTagsToSet.size() > 0) { ChangePropertyCommand changePropertyCommand = new ChangePropertyCommand( diff --git a/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/mergeTagsDialog.java b/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/mergeTagsDialog.java index c0f9853..fa0a324 100644 --- a/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/mergeTagsDialog.java +++ b/fhrsPlugin/src/org/openstreetmap/josm/plugins/fhrs/mergeTagsDialog.java @@ -11,23 +11,29 @@ import javax.swing.*; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellEditor; +import javax.swing.table.TableRowSorter; import org.openstreetmap.josm.plugins.fhrs.FHRSPlugin.fhrsAuthority; public class mergeTagsDialog { - public static Map showTagsDialog (final Map osmTags, boolean warnCapitalization) { + public static Map showTagsDialog (final Map osmTags, boolean warnCapitalization, final Map JsonToOSM) { final JPanel panel = new JPanel(); Object[][] columnValues = {}; final List columnValuesList = new ArrayList(); final List tagList = new ArrayList<>(osmTags.keySet()); final Map returnValues = new HashMap(); Collections.sort(tagList); + String jsonDisplay = ""; for(final String osmTag : tagList) { final FHRSPlugin.oldAndNewValues oanv = osmTags.get(osmTag); + for(Map.Entry entry : JsonToOSM.entrySet()) { + if (entry.getValue() == osmTag) jsonDisplay = entry.getKey(); + } if (oanv.newValue != "") { columnValuesList.add(new Object[] { false, + jsonDisplay, osmTag, oanv.newValue, oanv.oldValue @@ -41,9 +47,18 @@ public static Map showTagsDialog (final Map sorter = new TableRowSorter(thisTableModel); + osmTagsTable.setRowSorter(sorter); + List sortKeys = new ArrayList<>(25); + sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING)); + sorter.setSortKeys(sortKeys); + panel.setLayout(new BorderLayout()); panel.add(osmTagsTable.getTableHeader(), BorderLayout.PAGE_START); panel.add(osmTagsTable, BorderLayout.CENTER); @@ -58,7 +73,7 @@ public static Map showTagsDialog (final Map oComboBox = new JComboBox(); + oComboBox.addItem("addr:city"); + oComboBox.addItem("addr:housename"); + oComboBox.addItem("addr:housenumber"); + oComboBox.addItem("addr:street"); + oComboBox.addItem("addr:unit"); + oComboBox.setSelectedItem(value.toString()); + if (table.getValueAt(row, 1).toString().substring(0, 5).equals("Addre")) { + editor = new DefaultCellEditor(oComboBox); + } else { + JTextField roTextField = new JTextField(); + roTextField.setEditable(false); + editor = new DefaultCellEditor(roTextField); + } + } + if (table.getValueAt(row, 1) == "LocalAuthorityName" && column == 3) { JComboBox oComboBox = new JComboBox(); for (fhrsAuthority auth: FHRSPlugin.fhrsAuthorities) { oComboBox.addItem(auth.name); } oComboBox.setSelectedItem(value.toString()); editor = new DefaultCellEditor(oComboBox); - } else if (value instanceof String && table.getValueAt(row, 1) != "fhrs:authority") { - editor = new DefaultCellEditor(new JTextField()); - //} else if (value instanceof Boolean) { - // editor = new DefaultCellEditor(new JCheckBox()); } return editor.getTableCellEditorComponent(table, value, isSelected, row, column); @@ -101,7 +129,7 @@ public Component getTableCellEditorComponent(JTable table, Object value, boolean static class osmTagsTableModel extends AbstractTableModel { private static final long serialVersionUID = 1L; - String[] columnNames = { "Merge", "Tag", "New value", "Old Value" }; + String[] columnNames = { "Merge", "FHRS Data", "Tag", "New value", "Old Value" }; public Object[][] data; @Override @@ -135,7 +163,7 @@ public Class getColumnClass(final int c) { */ @Override public boolean isCellEditable(final int row, final int col) { - return (col == 0 || col == 2); + return (col == 0 || col == 2 || col == 3); } /*