1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.plugins.columbusCSV;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import javax.swing.ButtonGroup;
|
---|
7 | import javax.swing.JCheckBox;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
|
---|
10 | import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
|
---|
11 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Implements the preferences dialog for this plugin.
|
---|
15 | * @author Oliver Wieland <oliver.wieland@online.de>
|
---|
16 | */
|
---|
17 | public class ColumbusCSVPreferences extends DefaultTabPreferenceSetting {
|
---|
18 | public static final String PREFIX = "columbuscsv.";
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Show summary after import.
|
---|
22 | */
|
---|
23 | public static final String SHOW_SUMMARY = PREFIX + "import.showSummary";
|
---|
24 | /**
|
---|
25 | * Disable auto zoom after import.
|
---|
26 | */
|
---|
27 | public static final String ZOOM_AFTER_IMPORT = PREFIX + "import.dontZoomAfterImport";
|
---|
28 | /**
|
---|
29 | * If <tt>true</tt>, all DOP values (hdop, vdop, pdop) are ignored. If the V-900 runs in simple mode,
|
---|
30 | * this setting has no effect.
|
---|
31 | */
|
---|
32 | public static final String IGNORE_VDOP = PREFIX + "import.ignoreVDOP";
|
---|
33 | /**
|
---|
34 | * Issue warning on missing audio files.
|
---|
35 | */
|
---|
36 | public static final String WARN_MISSING_AUDIO = PREFIX + "warn.missingAudio";
|
---|
37 | /**
|
---|
38 | * Issue warning on conversion errors.
|
---|
39 | */
|
---|
40 | public static final String WARN_CONVERSION_ERRORS = PREFIX + "warn.conversionErrors";
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Ui elements for each flag.
|
---|
44 | */
|
---|
45 | private final JCheckBox colCSVShowSummary = new JCheckBox(tr("Show summary after import"));
|
---|
46 | private final JCheckBox colCSVDontZoomAfterImport = new JCheckBox(tr("Do not zoom after import"));
|
---|
47 | private final JCheckBox colCSVIgnoreVDOP = new JCheckBox(tr("Ignore hdop/vdop/pdop entries"));
|
---|
48 | private final JCheckBox colCSVWarnMissingAudio = new JCheckBox(tr("Warn on missing audio files"));
|
---|
49 | private final JCheckBox colCSVWarnConversionErrors = new JCheckBox(tr("Warn on conversion errors"));
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Creates a new preferences instance.
|
---|
53 | */
|
---|
54 | public ColumbusCSVPreferences() {
|
---|
55 | super();
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Applies the (new) settings after settings dialog has been closed successfully.
|
---|
60 | */
|
---|
61 | @Override
|
---|
62 | public boolean ok() {
|
---|
63 | Config.getPref().putBoolean(SHOW_SUMMARY, colCSVShowSummary.isSelected());
|
---|
64 | Config.getPref().putBoolean(ZOOM_AFTER_IMPORT, colCSVDontZoomAfterImport.isSelected());
|
---|
65 | Config.getPref().putBoolean(IGNORE_VDOP, colCSVIgnoreVDOP.isSelected());
|
---|
66 | Config.getPref().putBoolean(WARN_CONVERSION_ERRORS, colCSVWarnConversionErrors.isSelected());
|
---|
67 | Config.getPref().putBoolean(WARN_MISSING_AUDIO, colCSVWarnMissingAudio.isSelected());
|
---|
68 | return false;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * If <tt>true</tt>, a summary dialog is shown after import. Default is <tt>true</tt>.
|
---|
73 | * @return <tt>true</tt> if a summary dialog is shown after import
|
---|
74 | */
|
---|
75 | public static boolean showSummary() {
|
---|
76 | return Config.getPref().getBoolean(SHOW_SUMMARY, true);
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * If <tt>true</tt>, the bounding box will not be scaled to the imported data.
|
---|
81 | * @return <tt>true</tt> if the bounding box will not be scaled to the imported data
|
---|
82 | */
|
---|
83 | public static boolean zoomAfterImport() {
|
---|
84 | return Config.getPref().getBoolean(ZOOM_AFTER_IMPORT, true);
|
---|
85 | }
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * If <tt>true</tt>, all DOP values (hdop, vdop, pdop) are ignored. If the V-900 runs in simple mode,
|
---|
89 | * this setting has no effect.
|
---|
90 | * Default is <tt>false</tt>.
|
---|
91 | * @return <tt>true</tt> if all DOP values (hdop, vdop, pdop) are ignored
|
---|
92 | */
|
---|
93 | public static boolean ignoreDOP() {
|
---|
94 | return Config.getPref().getBoolean(IGNORE_VDOP, false);
|
---|
95 | }
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * If <tt>true</tt>, the plugin issues warnings when either date or position errors occurr.
|
---|
99 | * Default is <tt>true</tt>.
|
---|
100 | * @return <tt>true</tt> if the plugin issues warnings when either date or position errors occurr.
|
---|
101 | */
|
---|
102 | public static boolean warnConversion() {
|
---|
103 | return Config.getPref().getBoolean(WARN_CONVERSION_ERRORS, false);
|
---|
104 | }
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * If <tt>true</tt>, the plugin issues a warning if a referenced audio file is missing.
|
---|
108 | * Default is <tt>true</tt>.
|
---|
109 | * @return <tt>true</tt> if the plugin issues a warning when a referenced audio file is missing
|
---|
110 | */
|
---|
111 | public static boolean warnMissingAudio() {
|
---|
112 | return Config.getPref().getBoolean(WARN_MISSING_AUDIO, false);
|
---|
113 | }
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Populates the UI with our settings.
|
---|
117 | * @param gui The pane to populate.
|
---|
118 | */
|
---|
119 | @Override
|
---|
120 | public void addGui(PreferenceTabbedPane gui) {
|
---|
121 | // Import settings
|
---|
122 | ButtonGroup gpsImportGroup = new ButtonGroup();
|
---|
123 | gpsImportGroup.add(colCSVShowSummary);
|
---|
124 | gpsImportGroup.add(colCSVDontZoomAfterImport);
|
---|
125 | gpsImportGroup.add(colCSVIgnoreVDOP);
|
---|
126 |
|
---|
127 | // Warning settings
|
---|
128 | ButtonGroup gpsWarningsGroup = new ButtonGroup();
|
---|
129 | gpsWarningsGroup.add(colCSVWarnMissingAudio);
|
---|
130 | gpsWarningsGroup.add(colCSVWarnConversionErrors);
|
---|
131 |
|
---|
132 | // Apply settings
|
---|
133 | colCSVShowSummary.setSelected(Config.getPref().getBoolean(SHOW_SUMMARY, true));
|
---|
134 | colCSVDontZoomAfterImport.setSelected(Config.getPref().getBoolean(ZOOM_AFTER_IMPORT, true));
|
---|
135 | colCSVIgnoreVDOP.setSelected(Config.getPref().getBoolean(IGNORE_VDOP, false));
|
---|
136 | colCSVWarnConversionErrors.setSelected(Config.getPref().getBoolean(WARN_CONVERSION_ERRORS, true));
|
---|
137 | colCSVWarnMissingAudio.setSelected(Config.getPref().getBoolean(WARN_MISSING_AUDIO, true));
|
---|
138 | }
|
---|
139 |
|
---|
140 | @Override
|
---|
141 | public boolean isExpert() {
|
---|
142 | return false;
|
---|
143 | }
|
---|
144 |
|
---|
145 | }
|
---|