source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/BooleanStyleSettingGui.java@ 12831

Last change on this file since 12831 was 12831, checked in by bastiK, 7 years ago

see #15229 - extract GUI from StyleSetting class

File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import java.awt.event.ActionEvent;
5import java.util.Arrays;
6
7import javax.swing.AbstractAction;
8import javax.swing.Action;
9import javax.swing.JCheckBoxMenuItem;
10import javax.swing.JMenu;
11
12import org.openstreetmap.josm.gui.MainApplication;
13import org.openstreetmap.josm.gui.mappaint.loader.MapPaintStyleLoader;
14
15/**
16 * GUI elements for a {@link StyleSetting.BooleanStyleSetting} class.
17 * @since 12831
18 */
19public 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.