Changeset 7413 in josm
- Timestamp:
- 2014-08-16T03:49:41+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r7153 r7413 13 13 import java.util.ArrayList; 14 14 import java.util.Collection; 15 import java.util.Collections; 15 16 import java.util.EnumSet; 16 17 import java.util.HashSet; … … 33 34 import org.openstreetmap.josm.command.Command; 34 35 import org.openstreetmap.josm.command.SequenceCommand; 35 import org.openstreetmap.josm.data.osm. Node;36 import org.openstreetmap.josm.data.osm.DataSet; 36 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 38 import org.openstreetmap.josm.data.osm.Relation; 38 39 import org.openstreetmap.josm.data.osm.RelationMember; 39 40 import org.openstreetmap.josm.data.osm.Tag; 40 import org.openstreetmap.josm.data.osm.Way;41 41 import org.openstreetmap.josm.gui.ExtendedDialog; 42 42 import org.openstreetmap.josm.gui.MapView; … … 45 45 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 46 46 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Link; 47 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.PresetLink; 47 48 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Role; 48 49 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Roles; … … 207 208 return null; 208 209 PresetPanel p = new PresetPanel(); 209 Li nkedList<TaggingPresetItem> l = new LinkedList<>();210 Li nkedList<TaggingPresetItem> presetLink = new LinkedList<>();211 if (types != null){210 List<Link> l = new LinkedList<>(); 211 List<PresetLink> presetLink = new LinkedList<>(); 212 if (types != null){ 212 213 JPanel pp = new JPanel(); 213 for (TaggingPresetType t : types){214 for (TaggingPresetType t : types) { 214 215 JLabel la = new JLabel(ImageProvider.get(t.getIconName())); 215 216 la.setToolTipText(tr("Elements of type {0} are supported.", tr(t.getName()))); … … 224 225 boolean presetInitiallyMatches = !selected.isEmpty() && Utils.forAll(selected, this); 225 226 JPanel items = new JPanel(new GridBagLayout()); 226 for (TaggingPresetItem i : data) {227 if (i instanceof Link) {228 l.add( i);229 } else if (i instanceof TaggingPresetItems.PresetLink) {230 presetLink.add( i);227 for (TaggingPresetItem i : data) { 228 if (i instanceof Link) { 229 l.add((Link) i); 230 } else if (i instanceof PresetLink) { 231 presetLink.add((PresetLink) i); 231 232 } else { 232 if (i.addToPanel(items, selected, presetInitiallyMatches)) {233 if (i.addToPanel(items, selected, presetInitiallyMatches)) { 233 234 p.hasElements = true; 234 235 } … … 243 244 if (!presetLink.isEmpty()) { 244 245 p.add(new JLabel(tr("Edit also …")), GBC.eol().insets(0, 8, 0, 0)); 245 for (TaggingPresetItemlink : presetLink) {246 for (PresetLink link : presetLink) { 246 247 link.addToPanel(p, selected, presetInitiallyMatches); 247 248 } … … 249 250 250 251 // add Link 251 for (TaggingPresetItemlink : l) {252 for (Link link : l) { 252 253 link.addToPanel(p, selected, presetInitiallyMatches); 253 254 } … … 261 262 262 263 public boolean isShowable() { 263 for (TaggingPresetItem i : data) {264 if (!(i instanceof TaggingPresetItems.Optional || i instanceof TaggingPresetItems.Space || i instanceof TaggingPresetItems.Key))264 for (TaggingPresetItem i : data) { 265 if (!(i instanceof TaggingPresetItems.Optional || i instanceof TaggingPresetItems.Space || i instanceof TaggingPresetItems.Key)) 265 266 return true; 266 267 } … … 282 283 @Override 283 284 public void actionPerformed(ActionEvent e) { 284 if (Main.main == null) return; 285 if (Main.main.getCurrentDataSet() == null) return; 286 287 Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected()); 285 if (Main.main == null) { 286 return; 287 } 288 DataSet ds = Main.main.getCurrentDataSet(); 289 Collection<OsmPrimitive> participants = Collections.emptyList(); 290 if (Main.main != null && ds != null) { 291 participants = ds.getSelected(); 292 } 293 294 // Display dialog even if no data layer (used by preset-tagging-tester plugin) 295 Collection<OsmPrimitive> sel = createSelection(participants); 288 296 int answer = showDialog(sel, supportsRelation()); 297 298 if (ds == null) { 299 return; 300 } 289 301 290 302 if (!sel.isEmpty() && answer == DIALOG_ANSWER_APPLY) { … … 299 311 r.put(t.getKey(), t.getValue()); 300 312 } 301 for (OsmPrimitive osm : Main.main.getCurrentDataSet().getSelected()) {313 for (OsmPrimitive osm : ds.getSelected()) { 302 314 String role = suggestRoleForOsmPrimitive(osm); 303 315 RelationMember rm = new RelationMember(role == null ? "" : role, osm); … … 312 324 }); 313 325 } 314 Main.main.getCurrentDataSet().setSelected(Main.main.getCurrentDataSet().getSelected()); // force update 315 326 ds.setSelected(ds.getSelected()); // force update 316 327 } 317 328 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSelector.java
r7412 r7413 16 16 import java.awt.event.MouseEvent; 17 17 import java.util.ArrayList; 18 import java.util.Arrays;19 18 import java.util.Collection; 20 19 import java.util.Collections; … … 343 342 if (!Objects.equals(oldPreset, newPreset)) { 344 343 int[] indices = lsResult.getSelectedIndices(); 345 System.out.println(newPreset + " / "+Arrays.toString(indices));346 344 for (ListSelectionListener listener : listSelectionListeners) { 347 345 listener.valueChanged(new ListSelectionEvent(lsResult, lsResult.getSelectedIndex(),
Note:
See TracChangeset
for help on using the changeset viewer.