1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.relation;
|
---|
3 |
|
---|
4 | import java.util.Arrays;
|
---|
5 | import java.util.Collection;
|
---|
6 |
|
---|
7 | import javax.swing.Action;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
|
---|
10 | import org.openstreetmap.josm.actions.relation.DownloadMembersAction;
|
---|
11 | import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
|
---|
12 | import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
|
---|
13 | import org.openstreetmap.josm.actions.relation.EditRelationAction;
|
---|
14 | import org.openstreetmap.josm.actions.relation.SelectInRelationListAction;
|
---|
15 | import org.openstreetmap.josm.actions.relation.SelectMembersAction;
|
---|
16 | import org.openstreetmap.josm.actions.relation.SelectRelationAction;
|
---|
17 | import org.openstreetmap.josm.gui.PopupMenuHandler;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Utility class to setup a {@link PopupMenuHandler} with a consistent set of relation actions.
|
---|
21 | * @since 14685
|
---|
22 | */
|
---|
23 | public final class RelationPopupMenus {
|
---|
24 | private RelationPopupMenus() {
|
---|
25 | // Hide default constructor for utils classes
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Adds relation actions to the given {@link PopupMenuHandler}
|
---|
30 | * @param menu handler to add actions to
|
---|
31 | * @param excludeActions 0 or more action classes to exclude, i.e., not add
|
---|
32 | * @return {@code menu}
|
---|
33 | */
|
---|
34 | @SafeVarargs
|
---|
35 | public static PopupMenuHandler setupHandler(PopupMenuHandler menu, Class<? extends Action>... excludeActions) {
|
---|
36 | final Collection<Class<? extends Action>> exclude = Arrays.asList(excludeActions);
|
---|
37 | if (!exclude.contains(EditRelationAction.class)) {
|
---|
38 | menu.addAction(new EditRelationAction());
|
---|
39 | }
|
---|
40 |
|
---|
41 | if (!exclude.contains(DuplicateRelationAction.class)) {
|
---|
42 | menu.addAction(new DuplicateRelationAction());
|
---|
43 | }
|
---|
44 |
|
---|
45 | if (!exclude.contains(DeleteRelationsAction.class)) {
|
---|
46 | menu.addAction(new DeleteRelationsAction());
|
---|
47 | menu.addSeparator();
|
---|
48 | }
|
---|
49 |
|
---|
50 | if (!exclude.contains(SelectInRelationListAction.class)) {
|
---|
51 | menu.addAction(new SelectInRelationListAction());
|
---|
52 | }
|
---|
53 |
|
---|
54 | menu.addAction(new SelectRelationAction(false));
|
---|
55 | menu.addAction(new SelectRelationAction(true));
|
---|
56 | menu.addAction(new SelectMembersAction(false));
|
---|
57 | menu.addAction(new SelectMembersAction(true));
|
---|
58 | menu.addSeparator();
|
---|
59 |
|
---|
60 | menu.addAction(new DownloadMembersAction());
|
---|
61 | menu.addAction(new DownloadSelectedIncompleteMembersAction());
|
---|
62 |
|
---|
63 | return menu;
|
---|
64 | }
|
---|
65 | }
|
---|