- Timestamp:
- 2017-07-23T14:36:03+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r12353 r12496 123 123 model = new ConflictListModel(); 124 124 125 lstConflicts = new JList<>(model); 126 lstConflicts.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 127 lstConflicts.setCellRenderer(new OsmPrimitivRenderer()); 128 lstConflicts.addMouseListener(new MouseEventHandler()); 125 synchronized (this) { 126 lstConflicts = new JList<>(model); 127 lstConflicts.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 128 lstConflicts.setCellRenderer(new OsmPrimitivRenderer()); 129 lstConflicts.addMouseListener(new MouseEventHandler()); 130 } 129 131 addListSelectionListener(e -> Main.map.mapView.repaint()); 130 132 … … 165 167 * @since 5958 166 168 */ 167 public void addListSelectionListener(ListSelectionListener listener) {169 public synchronized void addListSelectionListener(ListSelectionListener listener) { 168 170 lstConflicts.getSelectionModel().addListSelectionListener(listener); 169 171 } … … 174 176 * @since 5958 175 177 */ 176 public void removeListSelectionListener(ListSelectionListener listener) {178 public synchronized void removeListSelectionListener(ListSelectionListener listener) { 177 179 lstConflicts.getSelectionModel().removeListSelectionListener(listener); 178 180 } … … 191 193 */ 192 194 private void resolve() { 193 if (conflicts == null || model.getSize() == 0) 194 return; 195 196 int index = lstConflicts.getSelectedIndex(); 197 if (index < 0) { 198 index = 0; 199 } 200 201 Conflict<? extends OsmPrimitive> c = conflicts.get(index); 202 ConflictResolutionDialog dialog = new ConflictResolutionDialog(Main.parent); 203 dialog.getConflictResolver().populate(c); 204 dialog.showDialog(); 205 206 lstConflicts.setSelectedIndex(index); 207 195 synchronized (this) { 196 if (conflicts == null || model.getSize() == 0) 197 return; 198 199 int index = lstConflicts.getSelectedIndex(); 200 if (index < 0) { 201 index = 0; 202 } 203 204 Conflict<? extends OsmPrimitive> c = conflicts.get(index); 205 ConflictResolutionDialog dialog = new ConflictResolutionDialog(Main.parent); 206 dialog.getConflictResolver().populate(c); 207 dialog.showDialog(); 208 209 lstConflicts.setSelectedIndex(index); 210 } 208 211 Main.map.mapView.repaint(); 209 212 } … … 214 217 public void refreshView() { 215 218 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer(); 216 conflicts = editLayer == null ? new ConflictCollection() : editLayer.getConflicts(); 219 synchronized (this) { 220 conflicts = editLayer == null ? new ConflictCollection() : editLayer.getConflicts(); 221 } 217 222 GuiHelper.runInEDT(() -> { 218 223 model.fireContentChanged(); … … 221 226 } 222 227 223 private void updateTitle() {228 private synchronized void updateTitle() { 224 229 int conflictsCount = conflicts.size(); 225 230 if (conflictsCount > 0) { … … 247 252 g.setColor(preferencesColor); 248 253 Visitor conflictPainter = new ConflictPainter(nc, g); 249 for (OsmPrimitive o : lstConflicts.getSelectedValuesList()) { 250 if (conflicts == null || !conflicts.hasConflictForMy(o)) { 251 continue; 252 } 253 conflicts.getConflictForMy(o).getTheir().accept(conflictPainter); 254 synchronized (this) { 255 for (OsmPrimitive o : lstConflicts.getSelectedValuesList()) { 256 if (conflicts == null || !conflicts.hasConflictForMy(o)) { 257 continue; 258 } 259 conflicts.getConflictForMy(o).getTheir().accept(conflictPainter); 260 } 254 261 } 255 262 } … … 281 288 * @return the conflict collection currently held by this dialog; may be null 282 289 */ 283 public ConflictCollection getConflicts() {290 public synchronized ConflictCollection getConflicts() { 284 291 return conflicts; 285 292 } … … 290 297 * @return Conflict 291 298 */ 292 public Conflict<? extends OsmPrimitive> getSelectedConflict() {299 public synchronized Conflict<? extends OsmPrimitive> getSelectedConflict() { 293 300 if (conflicts == null || model.getSize() == 0) 294 301 return null; … … 299 306 } 300 307 301 private boolean isConflictSelected() {308 private synchronized boolean isConflictSelected() { 302 309 final ListSelectionModel selModel = lstConflicts.getSelectionModel(); 303 310 return selModel.getMinSelectionIndex() >= 0 && selModel.getMaxSelectionIndex() >= selModel.getMinSelectionIndex(); … … 316 323 317 324 @Override 318 public void selectionChanged(SelectionChangeEvent event) {325 public synchronized void selectionChanged(SelectionChangeEvent event) { 319 326 lstConflicts.setValueIsAdjusting(true); 320 327 lstConflicts.clearSelection(); … … 416 423 417 424 @Override 418 public OsmPrimitive getElementAt(int index) {425 public synchronized OsmPrimitive getElementAt(int index) { 419 426 if (index < 0 || index >= getSize()) 420 427 return null; … … 423 430 424 431 @Override 425 public int getSize() {432 public synchronized int getSize() { 426 433 return conflicts != null ? conflicts.size() : 0; 427 434 } 428 435 429 public int indexOf(OsmPrimitive my) {436 public synchronized int indexOf(OsmPrimitive my) { 430 437 if (conflicts != null) { 431 438 for (int i = 0; i < conflicts.size(); i++) { … … 437 444 } 438 445 439 public OsmPrimitive get(int idx) {446 public synchronized OsmPrimitive get(int idx) { 440 447 return conflicts != null ? conflicts.get(idx).getMy() : null; 441 448 } … … 469 476 public void actionPerformed(ActionEvent e) { 470 477 Collection<OsmPrimitive> sel = new LinkedList<>(); 471 for (OsmPrimitive o : lstConflicts.getSelectedValuesList()) { 472 sel.add(o); 478 synchronized (this) { 479 for (OsmPrimitive o : lstConflicts.getSelectedValuesList()) { 480 sel.add(o); 481 } 473 482 } 474 483 DataSet ds = Main.getLayerManager().getEditDataSet(); … … 499 508 final ConflictResolver resolver = new ConflictResolver(); 500 509 final List<Command> commands = new ArrayList<>(); 501 for (OsmPrimitive osmPrimitive : lstConflicts.getSelectedValuesList()) { 502 Conflict<? extends OsmPrimitive> c = conflicts.getConflictForMy(osmPrimitive); 503 if (c != null) { 504 resolver.populate(c); 505 resolver.decideRemaining(type); 506 commands.add(resolver.buildResolveCommand()); 510 synchronized (this) { 511 for (OsmPrimitive osmPrimitive : lstConflicts.getSelectedValuesList()) { 512 Conflict<? extends OsmPrimitive> c = conflicts.getConflictForMy(osmPrimitive); 513 if (c != null) { 514 resolver.populate(c); 515 resolver.decideRemaining(type); 516 commands.add(resolver.buildResolveCommand()); 517 } 507 518 } 508 519 }
Note:
See TracChangeset
for help on using the changeset viewer.