Changeset 32958 in osm for applications/editors/josm/plugins/globalsat
- Timestamp:
- 2016-09-08T23:47:01+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatConfigDialog.java
r32649 r32958 10 10 import java.awt.GridBagLayout; 11 11 import java.awt.Insets; 12 import java.awt.event.ActionListener;13 12 import java.awt.event.KeyEvent; 14 13 14 import javax.swing.AbstractButton; 15 15 import javax.swing.BoxLayout; 16 16 import javax.swing.ButtonGroup; … … 34 34 public class IntegerTextField extends JTextField { 35 35 36 IntegerTextField() { 37 setHorizontalAlignment(JTextField.RIGHT); 38 } 39 36 40 static final String badchars = "-`~!@#$%^&*()_+=\\|\"':;?/>.<, "; 37 41 … … 75 79 conf = config; 76 80 GridBagConstraints c = new GridBagConstraints(); 77 System.out.println("read config " + config);78 81 79 82 Dimension xx = aSeconds.getPreferredSize(); 80 83 aSeconds.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 81 aSeconds.setHorizontalAlignment(JTextField.RIGHT);82 84 aMeters.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 83 aMeters.setHorizontalAlignment(JTextField.RIGHT);84 85 bSeconds.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 85 bSeconds.setHorizontalAlignment(JTextField.RIGHT);86 86 bMeters.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 87 bMeters.setHorizontalAlignment(JTextField.RIGHT);88 87 cSeconds.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 89 cSeconds.setHorizontalAlignment(JTextField.RIGHT);90 88 cMeters.setPreferredSize(new Dimension((int) xx.getWidth() + 50, (int) xx.getHeight())); 91 cMeters.setHorizontalAlignment(JTextField.RIGHT);92 89 93 90 setLayout(new GridBagLayout()); 94 91 95 ButtonGroup logFormat = new ButtonGroup(); 96 logFormat.add(formatPosOnly); 97 logFormat.add(formatPosTDS); 98 logFormat.add(formatPosTDSA); 92 createButtonGroup(formatPosOnly, formatPosTDS, formatPosTDSA); 99 93 100 94 JPanel logPanel = new JPanel(); … … 125 119 126 120 minLogSpeed = new IntegerTextField(); 127 minLogSpeed.setHorizontalAlignment(JTextField.RIGHT);128 121 c.insets = new Insets(4, 4, 0, 4); 129 122 c.gridwidth = 1; … … 134 127 add(minLogSpeed, c); 135 128 136 disableLogSpeed.addActionListener(new ActionListener() { 137 @Override 138 public void actionPerformed(java.awt.event.ActionEvent e) { 139 minLogSpeed.setEnabled(disableLogSpeed.isSelected()); 140 } 141 }); 129 disableLogSpeed.addActionListener(e -> minLogSpeed.setEnabled(disableLogSpeed.isSelected())); 142 130 143 131 disableLogDist = new JCheckBox(tr("Disable data logging if distance falls below")); … … 151 139 152 140 minLogDist = new IntegerTextField(); 153 minLogDist.setHorizontalAlignment(JTextField.RIGHT);154 141 c.insets = new Insets(0, 4, 4, 4); 155 142 c.gridwidth = 1; … … 162 149 minLogDist.setPreferredSize(new Dimension((int) x.getWidth() + 50, (int) x.getHeight())); 163 150 164 disableLogDist.addActionListener(new ActionListener() { 165 @Override 166 public void actionPerformed(java.awt.event.ActionEvent e) { 167 minLogDist.setEnabled(disableLogDist.isSelected()); 168 } 169 }); 151 disableLogDist.addActionListener(e -> minLogDist.setEnabled(disableLogDist.isSelected())); 170 152 171 153 disableLogDist.setSelected(conf.getDisableLogDist()); … … 177 159 minLogDist.setText("" + conf.getDistThres()); 178 160 179 ButtonGroup group = new ButtonGroup(); 180 group.add(aTime); 181 group.add(aDist); 161 createButtonGroup(aTime, aDist); 182 162 183 163 c.insets = new Insets(4, 4, 0, 4); … … 203 183 add(aMeters, c); 204 184 205 group = new ButtonGroup(); 206 group.add(bTime); 207 group.add(bDist); 185 createButtonGroup(bTime, bDist); 208 186 209 187 c.insets = new Insets(4, 4, 0, 4); … … 229 207 add(bMeters, c); 230 208 231 group = new ButtonGroup(); 232 group.add(cTime); 233 group.add(cDist); 209 createButtonGroup(cTime, cDist); 234 210 235 211 c.insets = new Insets(4, 4, 0, 4); … … 254 230 c.gridy = 8; 255 231 add(cMeters, c); 256 257 // add(new JLabel(tr("Memory Usage:")));258 // add(memUsage);259 //add ID textbox260 232 261 233 switch(conf.getLogFormat()) { … … 273 245 } 274 246 275 if (conf.getSwATimeOrDist() == 0) { 276 aTime.setSelected(true); 277 aDist.setSelected(false); 278 } else { 279 aTime.setSelected(false); 280 aDist.setSelected(true); 281 } 282 283 if (conf.getSwBTimeOrDist() == 0) { 284 bTime.setSelected(true); 285 bDist.setSelected(false); 286 } else { 287 bTime.setSelected(false); 288 bDist.setSelected(true); 289 } 290 291 if (conf.getSwCTimeOrDist() == 0) { 292 cTime.setSelected(true); 293 cDist.setSelected(false); 294 } else { 295 cTime.setSelected(false); 296 cDist.setSelected(true); 297 } 247 enableTimeDistRadioButton(conf.getSwATimeOrDist(), aTime, aDist); 248 enableTimeDistRadioButton(conf.getSwBTimeOrDist(), bTime, bDist); 249 enableTimeDistRadioButton(conf.getSwCTimeOrDist(), cTime, cDist); 298 250 299 251 aSeconds.setText("" + conf.getSwATime() / 1000); … … 305 257 cSeconds.setText("" + conf.getSwCTime() / 1000); 306 258 cMeters.setText("" + conf.getSwCDist()); 259 } 260 261 private static ButtonGroup createButtonGroup(AbstractButton ... buttons) { 262 ButtonGroup group = new ButtonGroup(); 263 for (AbstractButton b : buttons) { 264 group.add(b); 265 } 266 return group; 267 } 268 269 private static void enableTimeDistRadioButton(int timeOrDist, AbstractButton time, AbstractButton dist) { 270 if (timeOrDist == 0) { 271 time.setSelected(true); 272 dist.setSelected(false); 273 } else { 274 time.setSelected(false); 275 dist.setSelected(true); 276 } 307 277 } 308 278
Note:
See TracChangeset
for help on using the changeset viewer.