- Timestamp:
- 2014-10-30T20:23:04+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r7539 r7679 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.command.ChangePropertyCommand; 33 import org.openstreetmap.josm.data.SelectionChangedListener;34 import org.openstreetmap.josm.data.osm.DataSet;35 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 34 import org.openstreetmap.josm.gui.ExtendedDialog; … … 40 38 41 39 /** 42 * 43 * @author master 44 * 45 * Dialog to add tags as part of the remotecontrol 40 * Dialog to add tags as part of the remotecontrol. 46 41 * Existing Keys get grey color and unchecked selectboxes so they will not overwrite the old Key-Value-Pairs by default. 47 42 * You can choose the tags you want to add by selectboxes. You can edit the tags before you apply them. 48 * 43 * @author master 44 * @since 3850 49 45 */ 50 public class AddTagsDialog extends ExtendedDialog implements SelectionChangedListener { 51 52 53 /** initially given tags **/ 54 String[][] tags; 46 public class AddTagsDialog extends ExtendedDialog { 55 47 56 48 private final JTable propertyTable; 57 private Collection<? extends OsmPrimitive> sel;58 int[] count;59 60 String sender;61 staticSet<String> trustedSenders = new HashSet<>();49 private final Collection<? extends OsmPrimitive> sel; 50 private final int[] count; 51 52 private final String sender; 53 private static final Set<String> trustedSenders = new HashSet<>(); 62 54 63 55 /** … … 122 114 } 123 115 124 public AddTagsDialog(String[][] tags, String senderName) { 116 /** 117 * Constructs a new {@code AddTagsDialog}. 118 */ 119 public AddTagsDialog(String[][] tags, String senderName, Collection<? extends OsmPrimitive> primitives) { 125 120 super(Main.parent, tr("Add tags to selected objects"), new String[] { tr("Add selected tags"), tr("Add all tags"), tr("Cancel")}, 126 121 false, … … 129 124 130 125 this.sender = senderName; 131 132 DataSet.addSelectionListener(this);133 134 126 135 127 final DefaultTableModel tm = new DefaultTableModel(new String[] {tr("Assume"), tr("Key"), tr("Value"), tr("Existing values")}, tags.length) { … … 141 133 }; 142 134 143 sel = Main.main.getCurrentDataSet().getSelected();135 sel = primitives; 144 136 count = new int[tags.length]; 145 137 … … 168 160 propertyTable = new JTable(tm) { 169 161 170 private static final long serialVersionUID = 1L;171 172 162 @Override 173 163 public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { … … 200 190 return tr("Enable the checkbox to accept the value"); 201 191 } 202 203 192 }; 204 193 … … 240 229 241 230 /** 242 * This method looks for existing tags in the current selection and sets the corresponding boolean in the boolean array existing[]243 */244 private void findExistingTags() {245 TableModel tm = propertyTable.getModel();246 for (int i=0; i<tm.getRowCount(); i++) {247 String key = (String)tm.getValueAt(i, 1);248 String value = (String)tm.getValueAt(i, 1);249 count[i] = 0;250 for (OsmPrimitive osm : sel) {251 if (osm.keySet().contains(key) && !osm.get(key).equals(value)) {252 count[i]++;253 break;254 }255 }256 }257 propertyTable.repaint();258 }259 260 /**261 231 * If you click the "Add tags" button build a ChangePropertyCommand for every key that has a checked checkbox to apply the key value pair to all selected osm objects. 262 232 * You get a entry for every key in the command queue. … … 280 250 } 281 251 setVisible(false); 282 }283 284 @Override285 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {286 sel = newSelection;287 findExistingTags();288 252 } 289 253 … … 323 287 } 324 288 } 325 326 327 289 }); 328 290 } … … 332 294 * Ask user and add the tags he confirm. 333 295 * @param keyValue is a table or {{tag1,val1},{tag2,val2},...} 334 * @param sender is a string for skipping confirmations. Use e pmty string for always confirmed adding.296 * @param sender is a string for skipping confirmations. Use empty string for always confirmed adding. 335 297 * @param primitives OSM objects that will be modified 336 298 * @since 7521 … … 344 306 } 345 307 } else { 346 new AddTagsDialog(keyValue, sender ).showDialog();308 new AddTagsDialog(keyValue, sender, primitives).showDialog(); 347 309 } 348 310 }
Note:
See TracChangeset
for help on using the changeset viewer.