Line | |
---|
1 | package org.openstreetmap.josm.gui.dialogs.relation.actions;
|
---|
2 |
|
---|
3 | import java.util.Comparator;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import javax.swing.JButton;
|
---|
7 | import javax.swing.JToolBar;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.actions.ExpertToggleAction;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * An action group for the relation editor, to be used in one of the tool bars.
|
---|
13 | *
|
---|
14 | * @author Michael Zangl
|
---|
15 | * @since 14027
|
---|
16 | */
|
---|
17 | public interface IRelationEditorActionGroup {
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Get the position at which the action group should be added.
|
---|
21 | *
|
---|
22 | * @return The order index, default is to add at the end.
|
---|
23 | */
|
---|
24 | default int order() {
|
---|
25 | return 100;
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Get the actions in this action group.
|
---|
30 | *
|
---|
31 | * @param editorAccess
|
---|
32 | * Methods to access the relation editor.
|
---|
33 | * @return The actions
|
---|
34 | */
|
---|
35 | List<AbstractRelationEditorAction> getActions(IRelationEditorActionAccess editorAccess);
|
---|
36 |
|
---|
37 | static void fillToolbar(JToolBar toolbar, List<IRelationEditorActionGroup> groups,
|
---|
38 | IRelationEditorActionAccess editorAccess) {
|
---|
39 | groups.stream().sorted(Comparator.comparingInt(IRelationEditorActionGroup::order)).forEach(group -> {
|
---|
40 | if (toolbar.getComponentCount() > 0) {
|
---|
41 | toolbar.addSeparator();
|
---|
42 | }
|
---|
43 |
|
---|
44 | for (AbstractRelationEditorAction action : group.getActions(editorAccess)) {
|
---|
45 | JButton button = toolbar.add(action);
|
---|
46 | if (action.isExpertOnly()) {
|
---|
47 | ExpertToggleAction.addVisibilitySwitcher(button);
|
---|
48 | }
|
---|
49 | }
|
---|
50 | });
|
---|
51 | }
|
---|
52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.