- Timestamp:
- 2013-02-12T11:32:16+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r3851 r5706 10 10 import java.awt.GridBagLayout; 11 11 import java.awt.event.ActionEvent; 12 import java.awt.event.KeyEvent; 12 13 import java.util.Collection; 14 import javax.swing.AbstractAction; 13 15 14 16 import javax.swing.JPanel; 15 17 import javax.swing.JTable; 18 import javax.swing.KeyStroke; 16 19 import javax.swing.table.DefaultTableModel; 17 20 import javax.swing.table.TableCellRenderer; … … 40 43 private final JTable propertyTable; 41 44 private Collection<? extends OsmPrimitive> sel; 42 boolean[] existing;45 int[] count; 43 46 47 static class DeleteTagMarker { 48 int num; 49 public DeleteTagMarker(int num) { 50 this.num = num; 51 } 52 public String toString() { 53 return tr("<delete from {0} objects>", num); 54 } 55 } 56 57 44 58 public AddTagsDialog(String[][] tags) { 45 super(Main.parent, tr("Add tags to selected objects"), new String[] { tr("Add tags"),tr("Cancel")},59 super(Main.parent, tr("Add tags to selected objects"), new String[] { tr("Add selected tags"), tr("Add all tags"), tr("Cancel")}, 46 60 false, 47 61 true); 48 62 setToolTipTexts(new String[]{tr("Add checked tags to selected objects"), tr("Shift+Enter: Add all tags to selected objects"), ""}); 63 49 64 DataSet.addSelectionListener(this); 50 65 … … 59 74 60 75 sel = Main.main.getCurrentDataSet().getSelected(); 61 existing = new boolean[tags.length];62 76 count = new int[tags.length]; 77 63 78 for (int i = 0; i<tags.length; i++) { 64 existing[i] = false;79 count[i] = 0; 65 80 String key = tags[i][0]; 66 81 Boolean b = Boolean.TRUE; … … 68 83 if (osm.keySet().contains(key)) { 69 84 b = Boolean.FALSE; 70 existing[i]=true;85 count[i]++; 71 86 break; 72 87 } … … 74 89 tm.setValueAt(b, i, 0); 75 90 tm.setValueAt(tags[i][0], i, 1); 76 tm.setValueAt(tags[i][1] , i, 2);91 tm.setValueAt(tags[i][1].isEmpty() ? new DeleteTagMarker(count[i]) : tags[i][1], i, 2); 77 92 } 78 93 … … 84 99 public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { 85 100 Component c = super.prepareRenderer(renderer, row, column); 86 if ( existing[row]) {101 if (count[row]>0) { 87 102 c.setFont(c.getFont().deriveFont(Font.ITALIC)); 88 103 c.setForeground(new Color(100, 100, 100)); … … 94 109 } 95 110 }; 96 111 97 112 // a checkbox has a size of 15 px 98 113 propertyTable.getColumnModel().getColumn(0).setMaxWidth(15); 99 114 // get edit results if the table looses the focus, for example if a user clicks "add tags" 100 115 propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 116 propertyTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_MASK), "shiftenter"); 117 propertyTable.getActionMap().put("shiftenter", new AbstractAction() { 118 @Override public void actionPerformed(ActionEvent e) { 119 buttonAction(1, e); // add all tags on Shift-Enter 120 } 121 }); 101 122 102 123 // set the content of this AddTagsDialog consisting of the tableHeader and the table itself. … … 106 127 tablePanel.add(propertyTable, GBC.eol().fill(GBC.BOTH)); 107 128 setContent(tablePanel); 108 129 setDefaultButton(2); 109 130 // set the default Dimensions and show the dialog 110 131 setPreferredSize(new Dimension(400,tablePanel.getPreferredSize().height+100)); … … 119 140 for (int i=0; i<tm.getRowCount(); i++) { 120 141 String key = (String)tm.getValueAt(i, 1); 121 existing[i] = false;142 count[i] = 0; 122 143 for (OsmPrimitive osm : sel) { 123 144 if (osm.keySet().contains(key)) { 124 existing[i] = true;145 count[i]++; 125 146 break; 126 147 } … … 136 157 @Override 137 158 protected void buttonAction(int buttonIndex, ActionEvent evt) { 138 if (buttonIndex == 0) {159 if (buttonIndex != 2) { 139 160 TableModel tm = propertyTable.getModel(); 140 161 for (int i=0; i<tm.getRowCount(); i++) { 141 if ((Boolean)tm.getValueAt(i, 0)) { 142 Main.main.undoRedo.add(new ChangePropertyCommand(sel, (String)tm.getValueAt(i, 1), (String)tm.getValueAt(i, 2))); 162 if (buttonIndex==1 || (Boolean)tm.getValueAt(i, 0)) { 163 String key =(String)tm.getValueAt(i, 1); 164 Object value = tm.getValueAt(i, 2); 165 Main.main.undoRedo.add(new ChangePropertyCommand(sel, 166 key, value instanceof String ? (String) value : "")); 143 167 } 144 168 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r5680 r5706 218 218 int i = 0; 219 219 for (String tag : tagSet) { 220 keyValue[i++] = tag.split("="); 220 // support a = b===c as "a"="b===c" 221 String [] pair = tag.split("\\s*=\\s*",2); 222 keyValue[i][0] = pair[0]; 223 keyValue[i][1] = pair.length<2 ? "": pair[1]; 224 i++; 221 225 } 222 226
Note:
See TracChangeset
for help on using the changeset viewer.