- Timestamp:
- 2018-06-13T01:33:47+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r13838 r13926 32 32 import org.openstreetmap.josm.data.coor.conversion.ICoordinateFormat; 33 33 import org.openstreetmap.josm.data.osm.DataSet; 34 import org.openstreetmap.josm.data.osm.IPrimitive; 35 import org.openstreetmap.josm.data.osm.OsmData; 34 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 35 37 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; … … 265 267 266 268 /** 269 * Replies the current selected OSM primitives, from a end-user point of view. 270 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}. 271 * @return The current selected OSM primitives, from a end-user point of view. Can be {@code null}. 272 * @since 6546 273 */ 274 public Collection<OsmPrimitive> getInProgressSelection() { 275 return Collections.emptyList(); 276 } 277 278 /** 267 279 * Replies the current selected primitives, from a end-user point of view. 268 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.280 * It is not always technically the same collection of primitives than {@link OsmData#getSelected()}. 269 281 * @return The current selected primitives, from a end-user point of view. Can be {@code null}. 270 * @since 6546271 */ 272 public Collection< OsmPrimitive> getInProgressSelection() {282 * @since 13926 283 */ 284 public Collection<? extends IPrimitive> getInProgressISelection() { 273 285 return Collections.emptyList(); 274 286 } -
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r13842 r13926 16 16 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 import org.openstreetmap.josm.data.osm.OsmData; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 20 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 155 156 @Override 156 157 protected void updateEnabledState() { 157 DataSet ds = getLayerManager().getActiveDataSet();158 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 158 159 setEnabled(ds != null && !ds.selectionEmpty()); 159 160 } -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r13905 r13926 26 26 import org.openstreetmap.josm.data.conflict.Conflict; 27 27 import org.openstreetmap.josm.data.osm.DataSet; 28 import org.openstreetmap.josm.data.osm.IPrimitive; 29 import org.openstreetmap.josm.data.osm.OsmData; 28 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 31 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 77 79 */ 78 80 public static void zoomToSelection() { 79 DataSet dataSet = MainApplication.getLayerManager().getActiveDataSet();81 OsmData<?, ?, ?, ?> dataSet = MainApplication.getLayerManager().getActiveData(); 80 82 if (dataSet == null) { 81 83 return; 82 84 } 83 Collection< OsmPrimitive> sel = dataSet.getSelected();85 Collection<? extends IPrimitive> sel = dataSet.getSelected(); 84 86 if (sel.isEmpty()) { 85 87 JOptionPane.showMessageDialog( … … 97 99 * @param sel The primitives to zoom to, e.g. the current selection. 98 100 */ 99 public static void zoomTo(Collection< OsmPrimitive> sel) {101 public static void zoomTo(Collection<? extends IPrimitive> sel) { 100 102 BoundingXYVisitor bboxCalculator = new BoundingXYVisitor(); 101 103 bboxCalculator.computeBoundingBox(sel); … … 354 356 @Override 355 357 protected void updateEnabledState() { 356 DataSet ds = getLayerManager().getActiveDataSet();358 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 357 359 MapFrame map = MainApplication.getMap(); 358 360 switch (mode) { -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r13434 r13926 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm. DataSet;11 import org.openstreetmap.josm.data.osm.OsmData; 12 12 import org.openstreetmap.josm.gui.MainApplication; 13 13 import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog; … … 38 38 @Override 39 39 public void actionPerformed(ActionEvent ae) { 40 DataSet set = getLayerManager().getActiveDataSet();40 OsmData<?, ?, ?, ?> set = getLayerManager().getActiveData(); 41 41 if (set != null && !set.selectionEmpty()) { 42 42 HistoryBrowserDialogManager.getInstance().showHistory(set.getAllSelected()); -
trunk/src/org/openstreetmap/josm/actions/InfoAction.java
r13434 r13926 9 9 import java.util.Collection; 10 10 11 import org.openstreetmap.josm.data.osm. DataSet;11 import org.openstreetmap.josm.data.osm.OsmData; 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 import org.openstreetmap.josm.gui.dialogs.InspectPrimitiveDialog; … … 34 34 @Override 35 35 public void actionPerformed(ActionEvent ae) { 36 DataSet set = getLayerManager().getActiveDataSet();36 OsmData<?, ?, ?, ?> set = getLayerManager().getActiveData(); 37 37 if (set != null) { 38 38 new InspectPrimitiveDialog(set.getAllSelected(), set).showDialog(); -
trunk/src/org/openstreetmap/josm/actions/SelectAllAction.java
r13434 r13926 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.data.osm. DataSet;11 import org.openstreetmap.josm.data.osm.Osm Primitive;10 import org.openstreetmap.josm.data.osm.IPrimitive; 11 import org.openstreetmap.josm.data.osm.OsmData; 12 12 import org.openstreetmap.josm.tools.Shortcut; 13 13 … … 30 30 if (!isEnabled()) 31 31 return; 32 DataSet ds = getLayerManager().getActiveDataSet();33 ds.setSelected(ds.getPrimitives( OsmPrimitive::isSelectable));32 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 33 ds.setSelected(ds.getPrimitives(IPrimitive::isSelectable)); 34 34 } 35 35 … … 39 39 @Override 40 40 protected void updateEnabledState() { 41 setEnabled(getLayerManager().getActiveData Set() != null);41 setEnabled(getLayerManager().getActiveData() != null); 42 42 } 43 43 } -
trunk/src/org/openstreetmap/josm/actions/TaggingPresetSearchAction.java
r13434 r13926 31 31 public void actionPerformed(ActionEvent e) { 32 32 33 if (MainApplication.getLayerManager().getActiveData Set() == null)33 if (MainApplication.getLayerManager().getActiveData() == null) 34 34 return; 35 35 -
trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java
r13434 r13926 30 30 if (!isEnabled()) 31 31 return; 32 getLayerManager().getActiveData Set().setSelected();32 getLayerManager().getActiveData().setSelected(); 33 33 } 34 34 … … 38 38 @Override 39 39 protected void updateEnabledState() { 40 setEnabled(getLayerManager().getActiveData Set() != null);40 setEnabled(getLayerManager().getActiveData() != null); 41 41 } 42 42 } -
trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java
r13434 r13926 38 38 @Override 39 39 protected void updateEnabledState() { 40 setEnabled(getLayerManager().getActiveData Set() != null);40 setEnabled(getLayerManager().getActiveData() != null); 41 41 } 42 42 -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r13849 r13926 35 35 import org.openstreetmap.josm.data.osm.DataSet; 36 36 import org.openstreetmap.josm.data.osm.Node; 37 import org.openstreetmap.josm.data.osm.OsmData; 37 38 import org.openstreetmap.josm.data.osm.OsmPrimitive; 38 39 import org.openstreetmap.josm.data.osm.Way; … … 354 355 private boolean removeHighlighting() { 355 356 boolean needsRepaint = false; 356 DataSet ds = getLayerManager().getActiveDataSet();357 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 357 358 if (ds != null && !ds.getHighlightedVirtualNodes().isEmpty()) { 358 359 needsRepaint = true; -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r13761 r13926 885 885 @Override 886 886 protected void updateEnabledState() { 887 setEnabled(getLayerManager().getActiveData Set() != null);887 setEnabled(getLayerManager().getActiveData() != null); 888 888 } 889 889 -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r13654 r13926 93 93 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder; 94 94 import org.openstreetmap.josm.data.osm.DataSet; 95 import org.openstreetmap.josm.data.osm.IPrimitive; 96 import org.openstreetmap.josm.data.osm.OsmData; 95 97 import org.openstreetmap.josm.data.osm.OsmPrimitive; 96 98 import org.openstreetmap.josm.data.osm.UserInfo; … … 523 525 } 524 526 525 /**526 * Replies the current selected primitives, from a end-user point of view.527 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.528 * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,529 * see {@link DrawAction#getInProgressSelection()}.530 *531 * @return The current selected primitives, from a end-user point of view. Can be {@code null}.532 * @since 6546533 */534 527 @Override 535 528 public Collection<OsmPrimitive> getInProgressSelection() { … … 538 531 } else { 539 532 DataSet ds = layerManager.getActiveDataSet(); 533 if (ds == null) return null; 534 return ds.getSelected(); 535 } 536 } 537 538 @Override 539 public Collection<? extends IPrimitive> getInProgressISelection() { 540 if (map != null && map.mapMode instanceof DrawAction) { 541 return ((DrawAction) map.mapMode).getInProgressSelection(); 542 } else { 543 OsmData<?, ?, ?, ?> ds = layerManager.getActiveData(); 540 544 if (ds == null) return null; 541 545 return ds.getSelected(); -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r13925 r13926 70 70 import org.openstreetmap.josm.data.osm.DataSet; 71 71 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 72 import org.openstreetmap.josm.data.osm.IPrimitive; 72 73 import org.openstreetmap.josm.data.osm.Node; 73 74 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 602 603 * @param osm The primitive to derive the colors from 603 604 */ 604 private void popupSetLabelColors(JLabel lbl, OsmPrimitive osm) { 605 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 606 if (ds.isSelected(osm)) { 605 private void popupSetLabelColors(JLabel lbl, IPrimitive osm) { 606 if (osm.isSelected()) { 607 607 lbl.setBackground(SystemColor.textHighlight); 608 608 lbl.setForeground(SystemColor.textHighlightText); -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
r13761 r13926 15 15 import org.openstreetmap.josm.data.osm.BBox; 16 16 import org.openstreetmap.josm.data.osm.DataSet; 17 import org.openstreetmap.josm.data.osm.Node; 17 import org.openstreetmap.josm.data.osm.INode; 18 import org.openstreetmap.josm.data.osm.IPrimitive; 19 import org.openstreetmap.josm.data.osm.IRelation; 20 import org.openstreetmap.josm.data.osm.IRelationMember; 21 import org.openstreetmap.josm.data.osm.IWay; 22 import org.openstreetmap.josm.data.osm.OsmData; 18 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 import org.openstreetmap.josm.data.osm.Relation;20 import org.openstreetmap.josm.data.osm.RelationMember;21 24 import org.openstreetmap.josm.data.osm.Way; 22 25 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; … … 36 39 37 40 private final StringBuilder s = new StringBuilder(); 38 private final DataSetds;39 40 InspectPrimitiveDataText( DataSetds) {41 private final OsmData<?, ?, ?, ?> ds; 42 43 InspectPrimitiveDataText(OsmData<?, ?, ?, ?> ds) { 41 44 this.ds = ds; 42 45 } … … 63 66 * @param o primitive to add 64 67 */ 65 public void addPrimitive( OsmPrimitive o) {68 public void addPrimitive(IPrimitive o) { 66 69 67 70 addHeadline(o); … … 82 85 addSpecial(o); 83 86 addReferrers(s, o); 84 addConflicts(o); 87 if (o instanceof OsmPrimitive) { 88 addConflicts((OsmPrimitive) o); 89 } 85 90 s.append(NL); 86 91 } 87 92 88 void addHeadline( OsmPrimitive o) {93 void addHeadline(IPrimitive o) { 89 94 addType(o); 90 95 addNameAndId(o); 91 96 } 92 97 93 void addType( OsmPrimitive o) {94 if (o instanceof Node) {98 void addType(IPrimitive o) { 99 if (o instanceof INode) { 95 100 s.append(tr("Node: ")); 96 } else if (o instanceof Way) {101 } else if (o instanceof IWay) { 97 102 s.append(tr("Way: ")); 98 } else if (o instanceof Relation) {103 } else if (o instanceof IRelation) { 99 104 s.append(tr("Relation: ")); 100 105 } 101 106 } 102 107 103 void addNameAndId( OsmPrimitive o) {108 void addNameAndId(IPrimitive o) { 104 109 String name = o.get("name"); 105 110 if (name == null) { … … 110 115 } 111 116 112 void addState( OsmPrimitive o) {117 void addState(IPrimitive o) { 113 118 StringBuilder sb = new StringBuilder(INDENT); 114 119 /* selected state is left out: not interesting as it is always selected */ … … 141 146 } 142 147 143 void addCommon( OsmPrimitive o) {148 void addCommon(IPrimitive o) { 144 149 add(tr("Data Set: "), Integer.toHexString(o.getDataSet().hashCode())); 145 150 add(tr("Edited at: "), o.isTimestampEmpty() ? tr("<new object>") … … 151 156 } 152 157 153 void addAttributes( OsmPrimitive o) {158 void addAttributes(IPrimitive o) { 154 159 if (o.hasKeys()) { 155 160 add(tr("Tags: ")); … … 161 166 } 162 167 163 void addSpecial( OsmPrimitive o) {164 if (o instanceof Node) {165 addCoordinates(( Node) o);166 } else if (o instanceof Way) {168 void addSpecial(IPrimitive o) { 169 if (o instanceof INode) { 170 addCoordinates((INode) o); 171 } else if (o instanceof IWay) { 167 172 addBbox(o); 168 173 add(tr("Centroid: "), 169 174 toStringCSV(", ", Main.getProjection().eastNorth2latlon( 170 175 Geometry.getCentroid(((Way) o).getNodes())))); 171 addWayNodes(( Way) o);172 } else if (o instanceof Relation) {176 addWayNodes((IWay<?>) o); 177 } else if (o instanceof IRelation) { 173 178 addBbox(o); 174 addRelationMembers(( Relation) o);175 } 176 } 177 178 void addRelationMembers( Relationr) {179 addRelationMembers((IRelation<?>) o); 180 } 181 } 182 183 void addRelationMembers(IRelation<?> r) { 179 184 add(trn("{0} Member: ", "{0} Members: ", r.getMembersCount(), r.getMembersCount())); 180 for ( RelationMemberm : r.getMembers()) {185 for (IRelationMember<?> m : r.getMembers()) { 181 186 s.append(INDENT).append(INDENT); 182 187 addHeadline(m.getMember()); … … 186 191 } 187 192 188 void addWayNodes( Wayw) {193 void addWayNodes(IWay<?> w) { 189 194 add(tr("{0} Nodes: ", w.getNodesCount())); 190 for ( Node n : w.getNodes()) {195 for (INode n : w.getNodes()) { 191 196 s.append(INDENT).append(INDENT); 192 197 addNameAndId(n); … … 195 200 } 196 201 197 void addBbox( OsmPrimitive o) {202 void addBbox(IPrimitive o) { 198 203 BBox bbox = o.getBBox(); 199 204 if (bbox != null) { … … 210 215 } 211 216 212 void addCoordinates( Node n) {217 void addCoordinates(INode n) { 213 218 if (n.isLatLonKnown()) { 214 219 add(tr("Coordinates:"), " ", … … 225 230 } 226 231 227 void addReferrers(StringBuilder s, OsmPrimitive o) {228 List< OsmPrimitive> refs = o.getReferrers();232 void addReferrers(StringBuilder s, IPrimitive o) { 233 List<? extends IPrimitive> refs = o.getReferrers(); 229 234 if (!refs.isEmpty()) { 230 235 add(tr("Part of: ")); 231 for ( OsmPrimitive p : refs) {236 for (IPrimitive p : refs) { 232 237 s.append(INDENT).append(INDENT); 233 238 addHeadline(p); … … 238 243 239 244 void addConflicts(OsmPrimitive o) { 240 Conflict<?> c = ds.getConflicts().getConflictForMy(o);245 Conflict<?> c = ((DataSet) ds).getConflicts().getConflictForMy(o); 241 246 if (c != null) { 242 247 add(tr("In conflict with: ")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r13636 r13926 22 22 23 23 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.data.osm.DataSet;25 24 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 25 import org.openstreetmap.josm.data.osm.IPrimitive; 26 import org.openstreetmap.josm.data.osm.OsmData; 26 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm. OsmPrimitiveComparator;28 import org.openstreetmap.josm.data.osm.PrimitiveComparator; 28 29 import org.openstreetmap.josm.gui.ExtendedDialog; 29 30 import org.openstreetmap.josm.gui.MainApplication; … … 52 53 public class InspectPrimitiveDialog extends ExtendedDialog { 53 54 54 protected transient List< OsmPrimitive> primitives;55 protected transient List<IPrimitive> primitives; 55 56 private boolean mappaintTabLoaded; 56 57 private boolean editcountTabLoaded; … … 62 63 * @since 12672 (signature) 63 64 */ 64 public InspectPrimitiveDialog(final Collection< OsmPrimitive> primitives, DataSetdata) {65 public InspectPrimitiveDialog(final Collection<? extends IPrimitive> primitives, OsmData<?, ?, ?, ?> data) { 65 66 super(Main.parent, tr("Advanced object info"), tr("Close")); 66 67 this.primitives = new ArrayList<>(primitives); … … 105 106 } 106 107 107 protected static String buildDataText( DataSet data, List<OsmPrimitive> primitives) {108 protected static String buildDataText(OsmData<?, ?, ?, ?> data, List<IPrimitive> primitives) { 108 109 InspectPrimitiveDataText dt = new InspectPrimitiveDataText(data); 109 110 primitives.stream() 110 .sorted( OsmPrimitiveComparator.orderingWaysRelationsNodes().thenComparing(OsmPrimitiveComparator.comparingNames()))111 .sorted(PrimitiveComparator.orderingWaysRelationsNodes().thenComparing(PrimitiveComparator.comparingNames())) 111 112 .forEachOrdered(dt::addPrimitive); 112 113 return dt.toString(); … … 171 172 Count only tagged nodes (so empty way nodes don't inflate counts). 172 173 */ 173 protected static String buildListOfEditorsText(Iterable< OsmPrimitive> primitives) {174 protected static String buildListOfEditorsText(Iterable<? extends IPrimitive> primitives) { 174 175 final Map<String, Integer> editCountByUser = new TreeMap<>(Collator.getInstance(Locale.getDefault())); 175 176 176 177 // Count who edited each selected object 177 for ( OsmPrimitive o : primitives) {178 for (IPrimitive o : primitives) { 178 179 if (o.getUser() != null) { 179 180 String username = o.getUser().getName(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r13925 r13926 344 344 345 345 protected void setCurrentRelationAsSelection() { 346 MainApplication.getLayerManager().getActiveData Set().setSelected(displaylist.getSelectedValue());346 MainApplication.getLayerManager().getActiveData().setSelected(displaylist.getSelectedValue()); 347 347 } 348 348 -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r13925 r13926 46 46 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 47 47 import org.openstreetmap.josm.data.osm.Node; 48 import org.openstreetmap.josm.data.osm.OsmData; 48 49 import org.openstreetmap.josm.data.osm.OsmPrimitive; 49 50 import org.openstreetmap.josm.data.osm.OsmPrimitiveComparator; … … 295 296 296 297 protected void updateEnabledState() { 297 setEnabled(MainApplication.getLayerManager().getActiveData Set() != null);298 setEnabled(MainApplication.getLayerManager().getActiveData() != null); 298 299 } 299 300 … … 320 321 Collection<OsmPrimitive> sel = model.getSelected(); 321 322 if (sel.isEmpty()) return; 322 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();323 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 323 324 if (ds == null) return; 324 325 ds.setSelected(sel); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r13817 r13926 34 34 import org.openstreetmap.josm.actions.AbstractInfoAction; 35 35 import org.openstreetmap.josm.data.osm.DataSelectionListener; 36 import org.openstreetmap.josm.data.osm.DataSet; 36 import org.openstreetmap.josm.data.osm.IPrimitive; 37 import org.openstreetmap.josm.data.osm.OsmData; 37 38 import org.openstreetmap.josm.data.osm.OsmPrimitive; 38 39 import org.openstreetmap.josm.data.osm.User; … … 364 365 users.add(data.get(index).user); 365 366 } 366 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();367 Collection< OsmPrimitive> selected = ds.getAllSelected();368 Collection< OsmPrimitive> byUser = new LinkedList<>();369 for ( OsmPrimitive p : selected) {367 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 368 Collection<? extends IPrimitive> selected = ds.getAllSelected(); 369 Collection<IPrimitive> byUser = new LinkedList<>(); 370 for (IPrimitive p : selected) { 370 371 if (users.contains(p.getUser())) { 371 372 byUser.add(p); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r13925 r13926 63 63 import org.openstreetmap.josm.data.osm.DataSet; 64 64 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 65 import org.openstreetmap.josm.data.osm.IPrimitive; 65 66 import org.openstreetmap.josm.data.osm.IRelation; 67 import org.openstreetmap.josm.data.osm.IRelationMember; 66 68 import org.openstreetmap.josm.data.osm.Node; 67 69 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 230 232 231 233 private final PreferenceChangedListener preferenceListener = e -> { 232 if (MainApplication.getLayerManager().getActiveData Set() != null) {234 if (MainApplication.getLayerManager().getActiveData() != null) { 233 235 // Re-load data when display preference change 234 236 updateSelection(); … … 488 490 OsmDataLayer layer = MainApplication.getLayerManager().getActiveDataLayer(); 489 491 if (!layer.isLocked()) { 490 RelationEditor.getEditor( 491 layer, relation, ((MemberInfo) membershipData.getValueAt(row, 1)).role).setVisible(true); 492 List<RelationMember> members = new ArrayList<>(); 493 for (IRelationMember<?> rm : ((MemberInfo) membershipData.getValueAt(row, 1)).role) { 494 if (rm instanceof RelationMember) { 495 members.add((RelationMember) rm); 496 } 497 } 498 RelationEditor.getEditor(layer, relation, members).setVisible(true); 492 499 } 493 500 } … … 533 540 public void setVisible(boolean b) { 534 541 super.setVisible(b); 535 if (b && MainApplication.getLayerManager().getActiveData Set() != null) {542 if (b && MainApplication.getLayerManager().getActiveData() != null) { 536 543 updateSelection(); 537 544 } … … 559 566 560 567 // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode 561 Collection< OsmPrimitive> newSel = Optional.ofNullable(Main.main.getInProgressSelection()).orElseGet(Collections::emptyList);568 Collection<? extends IPrimitive> newSel = Optional.ofNullable(Main.main.getInProgressISelection()).orElseGet(Collections::emptyList); 562 569 String selectedTag; 563 570 Relation selectedRelation = null; … … 578 585 valueCount.clear(); 579 586 Set<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class); 580 for ( OsmPrimitive osm : newSel) {587 for (IPrimitive osm : newSel) { 581 588 types.add(TaggingPresetType.forPrimitive(osm)); 582 589 for (String key : osm.keySet()) { … … 610 617 membershipData.setRowCount(0); 611 618 612 Map< Relation, MemberInfo> roles = new HashMap<>();613 for ( OsmPrimitive primitive: newSel) {614 for ( OsmPrimitive ref: primitive.getReferrers(true)) {615 if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {616 Relation r = (Relation) ref;619 Map<IRelation<?>, MemberInfo> roles = new HashMap<>(); 620 for (IPrimitive primitive: newSel) { 621 for (IPrimitive ref: primitive.getReferrers(true)) { 622 if (ref instanceof IRelation && !ref.isIncomplete() && !ref.isDeleted()) { 623 IRelation<?> r = (IRelation<?>) ref; 617 624 MemberInfo mi = Optional.ofNullable(roles.get(r)).orElseGet(() -> new MemberInfo(newSel)); 618 625 roles.put(r, mi); 619 626 int i = 1; 620 for ( RelationMemberm : r.getMembers()) {627 for (IRelationMember<?> m : r.getMembers()) { 621 628 if (m.getMember() == primitive) { 622 629 mi.add(m, i); … … 628 635 } 629 636 630 List< Relation> sortedRelations = new ArrayList<>(roles.keySet());637 List<IRelation<?>> sortedRelations = new ArrayList<>(roles.keySet()); 631 638 sortedRelations.sort((o1, o2) -> { 632 639 int comp = Boolean.compare(o1.isDisabledAndHidden(), o2.isDisabledAndHidden()); … … 634 641 }); 635 642 636 for ( Relationr: sortedRelations) {643 for (IRelation<?> r: sortedRelations) { 637 644 membershipData.addRow(new Object[]{r, roles.get(r)}); 638 645 } … … 888 895 889 896 static class MemberInfo { 890 private final List< RelationMember> role = new ArrayList<>();891 private Set< OsmPrimitive> members = new HashSet<>();897 private final List<IRelationMember<?>> role = new ArrayList<>(); 898 private Set<IPrimitive> members = new HashSet<>(); 892 899 private List<Integer> position = new ArrayList<>(); 893 private Collection< OsmPrimitive> selection;900 private Collection<? extends IPrimitive> selection; 894 901 private String positionString; 895 902 private String roleString; 896 903 897 MemberInfo(Collection< OsmPrimitive> selection) {904 MemberInfo(Collection<? extends IPrimitive> selection) { 898 905 this.selection = selection; 899 906 } 900 907 901 void add( RelationMemberr, Integer p) {908 void add(IRelationMember<?> r, Integer p) { 902 909 role.add(r); 903 910 members.add(r.getMember()); … … 921 928 String getRoleString() { 922 929 if (roleString == null) { 923 for ( RelationMemberr : role) {930 for (IRelationMember<?> r : role) { 924 931 if (roleString == null) { 925 932 roleString = r.getRole(); … … 1175 1182 return; 1176 1183 String key = editHelper.getDataKey(tagTable.getSelectedRow()); 1177 Collection< OsmPrimitive> sel = Main.main.getInProgressSelection();1184 Collection<? extends IPrimitive> sel = Main.main.getInProgressISelection(); 1178 1185 if (sel.isEmpty()) 1179 1186 return; … … 1183 1190 } 1184 1191 1185 static SearchSetting createSearchSetting(String key, Collection< OsmPrimitive> sel, boolean sameType) {1192 static SearchSetting createSearchSetting(String key, Collection<? extends IPrimitive> sel, boolean sameType) { 1186 1193 String sep = ""; 1187 1194 StringBuilder s = new StringBuilder(); 1188 1195 Set<String> consideredTokens = new TreeSet<>(); 1189 for ( OsmPrimitive p : sel) {1196 for (IPrimitive p : sel) { 1190 1197 String val = p.get(key); 1191 1198 if (val == null || (!sameType && consideredTokens.contains(val))) { -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r13434 r13926 22 22 23 23 import org.openstreetmap.josm.actions.AutoScaleAction; 24 import org.openstreetmap.josm.data.osm.DataSet; 24 import org.openstreetmap.josm.data.osm.IPrimitive; 25 import org.openstreetmap.josm.data.osm.OsmData; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 27 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 247 248 if (!isEnabled()) 248 249 return; 249 OsmPrimitive p = getPrimitiveToZoom();250 IPrimitive p = getPrimitiveToZoom(); 250 251 if (p != null) { 251 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();252 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 252 253 if (ds != null) { 253 254 ds.setSelected(p.getPrimitiveId()); … … 262 263 } 263 264 264 protected OsmPrimitive getPrimitiveToZoom() {265 protected IPrimitive getPrimitiveToZoom() { 265 266 if (primitiveId == null) 266 267 return null; 267 DataSet ds = MainApplication.getLayerManager().getActiveDataSet();268 OsmData<?, ?, ?, ?> ds = MainApplication.getLayerManager().getActiveData(); 268 269 if (ds == null) 269 270 return null; … … 272 273 273 274 public void updateEnabledState() { 274 setEnabled(MainApplication.getLayerManager().getActiveData Set() != null && getPrimitiveToZoom() != null);275 setEnabled(MainApplication.getLayerManager().getActiveData() != null && getPrimitiveToZoom() != null); 275 276 } 276 277 } -
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r13654 r13926 14 14 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 import org.openstreetmap.josm.data.osm.OsmData; 16 17 import org.openstreetmap.josm.gui.MainApplication; 17 18 import org.openstreetmap.josm.gui.io.AsynchronousUploadPrimitivesTask; … … 175 176 * The current active data layer. It might be editable or not, based on its read-only status. 176 177 */ 177 private OsmDataLayer dataLayer; 178 private AbstractOsmDataLayer dataLayer; 179 180 /** 181 * The current active OSM data layer. It might be editable or not, based on its read-only status. 182 */ 183 private OsmDataLayer osmDataLayer; 178 184 179 185 private final List<ActiveLayerChangeListener> activeLayerChangeListeners = new CopyOnWriteArrayList<>(); … … 262 268 263 269 private void setActiveLayer(Layer layer, boolean forceEditLayerUpdate) { 264 ActiveLayerChangeEvent event = new ActiveLayerChangeEvent(this, dataLayer, activeLayer);270 ActiveLayerChangeEvent event = new ActiveLayerChangeEvent(this, osmDataLayer, activeLayer); 265 271 activeLayer = layer; 272 if (activeLayer instanceof AbstractOsmDataLayer) { 273 dataLayer = (AbstractOsmDataLayer) layer; 274 } 266 275 if (activeLayer instanceof OsmDataLayer) { 267 dataLayer = (OsmDataLayer) activeLayer;276 osmDataLayer = (OsmDataLayer) activeLayer; 268 277 } else if (forceEditLayerUpdate) { 269 dataLayer = null;278 osmDataLayer = null; 270 279 } 271 280 fireActiveLayerChange(event); … … 274 283 private void fireActiveLayerChange(ActiveLayerChangeEvent event) { 275 284 GuiHelper.assertCallFromEdt(); 276 if (event.getPreviousActiveLayer() != activeLayer || event.getPreviousDataLayer() != dataLayer) {285 if (event.getPreviousActiveLayer() != activeLayer || event.getPreviousDataLayer() != osmDataLayer) { 277 286 for (ActiveLayerChangeListener l : activeLayerChangeListeners) { 278 287 l.activeOrEditLayerChanged(event); … … 307 316 } 308 317 309 if (layer == activeLayer || layer == dataLayer) {318 if (layer == activeLayer || layer == osmDataLayer) { 310 319 Layer nextActive = suggestNextActiveLayer(layer); 311 320 setActiveLayer(nextActive, true); … … 376 385 */ 377 386 public synchronized OsmDataLayer getEditLayer() { 378 if ( dataLayer != null && !dataLayer.isLocked())379 return dataLayer;387 if (osmDataLayer != null && !osmDataLayer.isLocked()) 388 return osmDataLayer; 380 389 else 381 390 return null; … … 390 399 */ 391 400 public synchronized OsmDataLayer getActiveDataLayer() { 392 if ( dataLayer != null)393 return dataLayer;401 if (osmDataLayer != null) 402 return osmDataLayer; 394 403 else 395 404 return null; … … 402 411 */ 403 412 public synchronized DataSet getEditDataSet() { 404 if (dataLayer != null && !dataLayer.isLocked()) { 413 if (osmDataLayer != null && !osmDataLayer.isLocked()) { 414 return osmDataLayer.getDataSet(); 415 } else { 416 return null; 417 } 418 } 419 420 /** 421 * Gets the data set of the active data layer. The dataset can be read-only. 422 * @return That data set, <code>null</code> if there is no active data layer. 423 * @since 13926 424 */ 425 public synchronized OsmData<?, ?, ?, ?> getActiveData() { 426 if (dataLayer != null) { 405 427 return dataLayer.getDataSet(); 406 428 } else { … … 410 432 411 433 /** 412 * Gets the data set of the active data layer. The dataset can be read-only.434 * Gets the data set of the active {@link OsmDataLayer}. The dataset can be read-only. 413 435 * @return That data set, <code>null</code> if there is no active data layer. 414 436 * @see #getEditDataSet … … 416 438 */ 417 439 public synchronized DataSet getActiveDataSet() { 418 if ( dataLayer != null) {419 return dataLayer.getDataSet();440 if (osmDataLayer != null) { 441 return osmDataLayer.getDataSet(); 420 442 } else { 421 443 return null; … … 475 497 */ 476 498 public void invalidateEditLayer() { 477 if ( dataLayer != null) {478 dataLayer.invalidate();499 if (osmDataLayer != null) { 500 osmDataLayer.invalidate(); 479 501 } 480 502 } … … 512 534 513 535 // Reset only the edit layer as empty 514 if ( dataLayer == layer) {515 ActiveLayerChangeEvent activeLayerChangeEvent = new ActiveLayerChangeEvent(this, dataLayer, activeLayer);516 dataLayer = null;536 if (osmDataLayer == layer) { 537 ActiveLayerChangeEvent activeLayerChangeEvent = new ActiveLayerChangeEvent(this, osmDataLayer, activeLayer); 538 osmDataLayer = null; 517 539 fireActiveLayerChange(activeLayerChangeEvent); 518 540 } … … 532 554 533 555 // Set the layer as edit layer if the edit layer is empty. 534 if ( dataLayer == null) {535 ActiveLayerChangeEvent layerChangeEvent = new ActiveLayerChangeEvent(this, dataLayer, activeLayer);536 dataLayer = layer;556 if (osmDataLayer == null) { 557 ActiveLayerChangeEvent layerChangeEvent = new ActiveLayerChangeEvent(this, osmDataLayer, activeLayer); 558 osmDataLayer = layer; 537 559 fireActiveLayerChange(layerChangeEvent); 538 560 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r13855 r13926 123 123 * @since 17 124 124 */ 125 public class OsmDataLayer extends Abstract ModifiableLayer implements Listener, DataSelectionListener, HighlightUpdateListener {125 public class OsmDataLayer extends AbstractOsmDataLayer implements Listener, DataSelectionListener, HighlightUpdateListener { 126 126 private static final int HATCHED_SIZE = 15; 127 127 /** Property used to know if this layer has to be saved on disk */ … … 420 420 * @since 13558 421 421 */ 422 @Override 422 423 public DataSet getDataSet() { 423 424 return data; -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
r13434 r13926 67 67 public void updateEnabledState() { 68 68 setEnabled(MainApplication.isDisplayingMapView() 69 && (MainApplication.getLayerManager().getActiveData Set() != null || mapHasGpxorMarkerLayer()));69 && (MainApplication.getLayerManager().getActiveData() != null || mapHasGpxorMarkerLayer())); 70 70 } 71 71 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r13623 r13926 39 39 import org.openstreetmap.josm.data.osm.DataSet; 40 40 import org.openstreetmap.josm.data.osm.IPrimitive; 41 import org.openstreetmap.josm.data.osm.OsmData; 41 42 import org.openstreetmap.josm.data.osm.OsmPrimitive; 42 43 import org.openstreetmap.josm.data.osm.Relation; … … 495 496 boolean disableApply = false; 496 497 if (!sel.isEmpty()) { 497 DataSetds = sel.iterator().next().getDataSet();498 OsmData<?, ?, ?, ?> ds = sel.iterator().next().getDataSet(); 498 499 disableApply = ds != null && ds.isLocked(); 499 500 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java
r13434 r13926 43 43 @Override 44 44 public void actionPerformed(ActionEvent e) { 45 if (MainApplication.getLayerManager().getActiveData Set() != null) {45 if (MainApplication.getLayerManager().getActiveData() != null) { 46 46 TaggingPresetSearchPrimitiveDialog.getInstance().showDialog(); 47 47 } … … 50 50 @Override 51 51 protected void updateEnabledState() { 52 setEnabled(getLayerManager().getActiveData Set() != null);52 setEnabled(getLayerManager().getActiveData() != null); 53 53 } 54 54 }
Note:
See TracChangeset
for help on using the changeset viewer.