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

Last change on this file since 5794 was 5794, checked in by Don-vip, 11 years ago

see #7846 - fix copyright + javadoc + potential NPEs

File size: 1.1 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.data.osm.Relation;
10
11/**
12 * Ancestor for all actions that want to work with relation collection and
13 * to be disabled is the collection is empty
14 * @since 5793
15 */
16public abstract class AbstractRelationAction extends AbstractAction {
17 protected Collection<Relation> relations = Collections.<Relation>emptySet();
18
19 /**
20 * Specifies the working set of relations.
21 * @param relations The new working set of relations. Can be null or empty
22 */
23 public void setRelations(Collection<Relation> relations) {
24 if (relations==null) {
25 this.relations = Collections.<Relation>emptySet();
26 } else {
27 this.relations = relations;
28 }
29 updateEnabledState();
30 }
31
32 protected void updateEnabledState() {
33 setEnabled(!relations.isEmpty());
34 }
35}
Note: See TracBrowser for help on using the repository browser.