Changeset 5821 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2013-04-02T00:55:56+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java
r5799 r5821 7 7 import javax.swing.AbstractAction; 8 8 9 import org.openstreetmap.josm.actions.OsmPrimitiveAction; 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 11 import org.openstreetmap.josm.data.osm.Relation; 12 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 10 13 11 14 /** … … 14 17 * @since 5793 15 18 */ 16 public abstract class AbstractRelationAction extends AbstractAction {19 public abstract class AbstractRelationAction extends AbstractAction implements OsmPrimitiveAction { 17 20 protected Collection<Relation> relations = Collections.<Relation>emptySet(); 18 21 19 /** 20 * Specifies the working set of relations. 21 * @param relations The new working set of relations. Can be null or empty 22 protected static final Collection<Relation> getRelations(Collection<? extends OsmPrimitive> primitives) { 23 if (primitives == null || primitives.isEmpty()) { 24 return Collections.<Relation>emptySet(); 25 } else { 26 return new SubclassFilteredCollection<OsmPrimitive, Relation>( 27 primitives, OsmPrimitive.relationPredicate); 28 } 29 } 30 31 /* (non-Javadoc) 32 * @see org.openstreetmap.josm.actions.relation.RelationAction#setPrimitives 22 33 */ 23 public void setRelations(Collection<Relation> relations) { 24 if (relations==null) { 25 this.relations = Collections.<Relation>emptySet(); 26 } else { 27 this.relations = relations; 28 } 34 @Override 35 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) { 36 this.relations = getRelations(primitives); 29 37 updateEnabledState(); 30 38 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r5799 r5821 6 6 7 7 import java.awt.event.ActionEvent; 8 import java.util.Collection; 8 9 9 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.data.osm.Relation; 10 13 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 11 14 import org.openstreetmap.josm.tools.ImageProvider; 15 import org.openstreetmap.josm.tools.Predicate; 16 import org.openstreetmap.josm.tools.Utils; 12 17 13 18 /** 14 19 * The action for downloading members of relations 15 20 * @since 5793 16 21 */ 17 22 public class DownloadMembersAction extends AbstractRelationAction { … … 32 37 Main.worker.submit(new DownloadRelationTask(relations, Main.map.mapView.getEditLayer())); 33 38 } 39 40 @Override 41 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) { 42 // selected non-new relations 43 this.relations = Utils.filter(getRelations(primitives), new Predicate<Relation>(){ 44 @Override public boolean evaluate(Relation r) { 45 return !r.isNew(); 46 }}); 47 updateEnabledState(); 48 } 34 49 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r5799 r5821 14 14 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 15 15 import org.openstreetmap.josm.tools.ImageProvider; 16 import org.openstreetmap.josm.tools.Predicate; 17 import org.openstreetmap.josm.tools.Utils; 16 18 17 19 /** … … 51 53 Main.map.mapView.getEditLayer())); 52 54 } 55 56 @Override 57 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) { 58 // selected relations with incomplete members 59 this.relations = Utils.filter(getRelations(primitives), new Predicate<Relation>(){ 60 @Override public boolean evaluate(Relation r) { 61 return !r.isNew() && r.hasIncompleteMembers(); 62 }}); 63 updateEnabledState(); 64 } 53 65 } -
trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java
r5799 r5821 17 17 */ 18 18 public class DuplicateRelationAction extends AbstractRelationAction { 19 20 /** 21 * Constructs a new {@code DuplicateRelationAction}. 22 */ 19 23 public DuplicateRelationAction() { 20 24 putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window"));
Note:
See TracChangeset
for help on using the changeset viewer.