Ticket #18919: 18919-partly-fix.patch
| File 18919-partly-fix.patch, 4.9 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
69 69 * @since 2689 70 70 */ 71 71 public class ChangesetContentPanel extends JPanel implements PropertyChangeListener, ChangesetAware { 72 72 private JTable tblContent; 73 73 private ChangesetContentTableModel model; 74 74 private transient Changeset currentChangeset; 75 75 … … 121 121 122 122 protected JPanel buildContentPanel() { 123 123 JPanel pnl = new JPanel(new BorderLayout()); 124 JTabletblContent = new JTable(124 tblContent = new JTable( 125 125 model, 126 126 new ChangesetContentTableColumnModel(), 127 127 model.getSelectionModel() … … 213 213 ); 214 214 } 215 215 216 private Set<HistoryOsmPrimitive> getSelectedPrimitives() { 217 return model.getSelectedPrimitives(tblContent); 218 } 219 216 220 class ChangesetContentTablePopupMenu extends JPopupMenu { 217 221 ChangesetContentTablePopupMenu() { 218 222 add(actDownloadContentAction); … … 287 291 288 292 @Override 289 293 public void actionPerformed(ActionEvent e) { 290 Set<HistoryOsmPrimitive> selected = model.getSelectedPrimitives();294 Set<HistoryOsmPrimitive> selected = getSelectedPrimitives(); 291 295 if (selected.isEmpty()) return; 292 296 showHistory(selected); 293 297 } … … 309 313 310 314 @Override 311 315 public void actionPerformed(ActionEvent e) { 312 final List<PrimitiveId> primitiveIds = model.getSelectedPrimitives().stream().map(HistoryOsmPrimitive::getPrimitiveId)316 final List<PrimitiveId> primitiveIds = getSelectedPrimitives().stream().map(HistoryOsmPrimitive::getPrimitiveId) 313 317 .collect(Collectors.toList()); 314 318 MainApplication.worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null)); 315 319 } … … 329 333 protected Set<OsmPrimitive> getTarget() { 330 334 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 331 335 if (isEnabled() && ds != null) { 332 return model.getSelectedPrimitives().stream()336 return getSelectedPrimitives().stream() 333 337 .map(p -> ds.getPrimitiveById(p.getPrimitiveId())).filter(Objects::nonNull).collect(Collectors.toSet()); 334 338 } 335 339 return Collections.emptySet(); … … 363 367 public void actionPerformed(ActionEvent e) { 364 368 final Set<OsmPrimitive> target = getTarget(); 365 369 if (target.isEmpty()) { 366 alertNoPrimitivesTo( model.getSelectedPrimitives(), tr("Nothing to select"),370 alertNoPrimitivesTo(getSelectedPrimitives(), tr("Nothing to select"), 367 371 HelpUtil.ht("/Dialog/ChangesetCacheManager#NothingToSelectInLayer")); 368 372 return; 369 373 } … … 384 388 public void actionPerformed(ActionEvent e) { 385 389 final Set<OsmPrimitive> target = getTarget(); 386 390 if (target.isEmpty()) { 387 alertNoPrimitivesTo( model.getSelectedPrimitives(), tr("Nothing to zoom to"),391 alertNoPrimitivesTo(getSelectedPrimitives(), tr("Nothing to zoom to"), 388 392 HelpUtil.ht("/Dialog/ChangesetCacheManager#NothingToZoomTo")); 389 393 return; 390 394 } -
src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
8 8 import java.util.Set; 9 9 10 10 import javax.swing.DefaultListSelectionModel; 11 import javax.swing.JTable; 11 12 import javax.swing.table.AbstractTableModel; 12 13 13 14 import org.openstreetmap.josm.data.osm.ChangesetDataSet; … … 59 60 60 61 /** 61 62 * Returns the selected history primitives. 63 * @param table the JTable used with this model 62 64 * @return the selected history primitives 63 65 */ 64 public Set<HistoryOsmPrimitive> getSelectedPrimitives( ) {66 public Set<HistoryOsmPrimitive> getSelectedPrimitives(JTable table) { 65 67 Set<HistoryOsmPrimitive> ret = new HashSet<>(); 66 for (int i = 0; i < data.size(); i++) { 67 if (selectionModel.isSelectedIndex(i)) { 68 ret.add(data.get(i).getPrimitive()); 69 } 68 int[] selection = table.getSelectedRows(); 69 for (int i = 0; i < selection.length; i++) { 70 ret.add(data.get(table.convertRowIndexToModel(selection[i])).getPrimitive()); 70 71 } 72 71 73 return ret; 72 74 } 73 75
