Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint;
|
---|
3 |
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 | import java.util.Arrays;
|
---|
6 |
|
---|
7 | import javax.swing.AbstractAction;
|
---|
8 | import javax.swing.Action;
|
---|
9 | import javax.swing.JCheckBoxMenuItem;
|
---|
10 | import javax.swing.JMenu;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
13 | import org.openstreetmap.josm.gui.mappaint.loader.MapPaintStyleLoader;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * GUI elements for a {@link StyleSetting.BooleanStyleSetting} class.
|
---|
17 | * @since 12831
|
---|
18 | */
|
---|
19 | public class BooleanStyleSettingGui implements StyleSettingGui {
|
---|
20 |
|
---|
21 | final StyleSetting.BooleanStyleSetting setting;
|
---|
22 |
|
---|
23 | public BooleanStyleSettingGui(StyleSetting.BooleanStyleSetting setting) {
|
---|
24 | this.setting = setting;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public void addMenuEntry(JMenu menu) {
|
---|
29 | final JCheckBoxMenuItem item = new JCheckBoxMenuItem();
|
---|
30 | Action a = new AbstractAction(setting.label) {
|
---|
31 | @Override
|
---|
32 | public void actionPerformed(ActionEvent e) {
|
---|
33 | setting.setValue(item.isSelected());
|
---|
34 | MainApplication.worker.submit(new MapPaintStyleLoader(Arrays.asList(setting.parentStyle)));
|
---|
35 | }
|
---|
36 | };
|
---|
37 | item.setAction(a);
|
---|
38 | item.setSelected((boolean) setting.getValue());
|
---|
39 | menu.add(item);
|
---|
40 | }
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.