source: josm/trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java@ 11885

Last change on this file since 11885 was 11590, checked in by Don-vip, 7 years ago

see #11924 - remove workarounds for jdk9 compilation problems with diamond operator - sounds a lot like JDK-8075793 (solved in b150)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.relation;
3
4import java.util.Collection;
5import java.util.Collections;
6
7import javax.swing.AbstractAction;
8
9import org.openstreetmap.josm.actions.OsmPrimitiveAction;
10import org.openstreetmap.josm.data.osm.OsmPrimitive;
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.tools.SubclassFilteredCollection;
13
14/**
15 * Ancestor for all actions that want to work with relation collection and
16 * to be disabled if the collection is empty
17 * @since 5793
18 */
19public abstract class AbstractRelationAction extends AbstractAction implements OsmPrimitiveAction {
20 protected transient Collection<Relation> relations = Collections.<Relation>emptySet();
21
22 @SuppressWarnings("unused")
23 protected static final Collection<Relation> getRelations(Collection<? extends OsmPrimitive> primitives) {
24 if (primitives == null || primitives.isEmpty()) {
25 return Collections.<Relation>emptySet();
26 } else {
27 return new SubclassFilteredCollection<>(primitives, Relation.class::isInstance);
28 }
29 }
30
31 @Override
32 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
33 this.relations = getRelations(primitives);
34 updateEnabledState();
35 }
36
37 protected void updateEnabledState() {
38 setEnabled(!relations.isEmpty());
39 }
40}
Note: See TracBrowser for help on using the repository browser.