Changeset 116 in josm for src/org/openstreetmap/josm/gui/PreferenceDialog.java
- Timestamp:
- 2006-07-20T00:43:51+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r115 r116 11 11 import java.awt.event.ActionListener; 12 12 import java.util.Map; 13 import java.util.StringTokenizer; 13 14 import java.util.TreeMap; 14 15 import java.util.Vector; … … 19 20 import javax.swing.Box; 20 21 import javax.swing.DefaultListCellRenderer; 22 import javax.swing.DefaultListModel; 21 23 import javax.swing.JButton; 22 24 import javax.swing.JCheckBox; … … 81 83 Main.pref.put("draw.segment.direction", directionHint.isSelected()); 82 84 85 if (annotationSources.getModel().getSize() > 0) { 86 StringBuilder sb = new StringBuilder(); 87 for (int i = 0; i < annotationSources.getModel().getSize(); ++i) 88 sb.append(";"+annotationSources.getModel().getElementAt(i)); 89 Main.pref.put("annotation.sources", sb.toString().substring(1)); 90 } 91 83 92 for (int i = 0; i < colors.getRowCount(); ++i) { 84 93 String name = (String)colors.getValueAt(i, 0); … … 121 130 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 122 131 /** 123 * Combobox with all projections available124 */125 private JComboBox projectionCombo = new JComboBox(Projection.allProjections);126 /**127 132 * The main tab panel. 128 133 */ … … 161 166 private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows")); 162 167 private JTable colors; 168 169 /** 170 * Combobox with all projections available 171 */ 172 private JComboBox projectionCombo = new JComboBox(Projection.allProjections); 173 private JList annotationSources = new JList(new DefaultListModel()); 163 174 164 175 … … 227 238 directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction")); 228 239 240 String annos = Main.pref.get("annotation.sources"); 241 StringTokenizer st = new StringTokenizer(annos, ";"); 242 while (st.hasMoreTokens()) 243 ((DefaultListModel)annotationSources.getModel()).addElement(st.nextToken()); 229 244 230 245 … … 275 290 } 276 291 }); 292 293 // Annotation source panels 294 JPanel annoButton = new JPanel(new GridBagLayout()); 295 JButton addAnno = new JButton(tr("Add")); 296 addAnno.addActionListener(new ActionListener(){ 297 public void actionPerformed(ActionEvent e) { 298 String source = JOptionPane.showInputDialog(Main.parent, tr("Annotation preset source")); 299 if (source == null) 300 return; 301 ((DefaultListModel)annotationSources.getModel()).addElement(source); 302 requiresRestart = true; 303 } 304 }); 305 GBC g = GBC.eol().fill(GBC.HORIZONTAL); 306 g.weightx = 0; 307 annoButton.add(addAnno,g); 308 309 JButton editAnno = new JButton(tr("Edit")); 310 editAnno.addActionListener(new ActionListener(){ 311 public void actionPerformed(ActionEvent e) { 312 if (annotationSources.getSelectedIndex() == -1) 313 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit.")); 314 else { 315 String source = JOptionPane.showInputDialog(Main.parent, tr("Annotation preset source"), annotationSources.getSelectedValue()); 316 if (source == null) 317 return; 318 ((DefaultListModel)annotationSources.getModel()).setElementAt(source, annotationSources.getSelectedIndex()); 319 requiresRestart = true; 320 } 321 } 322 }); 323 annoButton.add(GBC.glue(0, 2), GBC.eol()); 324 annoButton.add(editAnno,g); 325 326 JButton deleteAnno = new JButton(tr("Delete")); 327 deleteAnno.addActionListener(new ActionListener(){ 328 public void actionPerformed(ActionEvent e) { 329 if (annotationSources.getSelectedIndex() == -1) 330 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete.")); 331 else { 332 ((DefaultListModel)annotationSources.getModel()).remove(annotationSources.getSelectedIndex()); 333 requiresRestart = true; 334 } 335 } 336 }); 337 annoButton.add(GBC.glue(0, 2), GBC.eol()); 338 annoButton.add(deleteAnno,g); 339 annotationSources.setVisibleRowCount(5); 340 341 277 342 278 343 // setting tooltips … … 290 355 drawRawGpsLines.setToolTipText(tr("If your gps device draw to few lines, select this to draw lines along your way.")); 291 356 colors.setToolTipText(tr("Colors used by different objects in JOSM.")); 357 annotationSources.setToolTipText(tr("The sources (url or filename) of annotation preset definition files. See http://josm.eigenheimstrasse.de/wiki/AnnotationPresets for help.")); 358 addAnno.setToolTipText(tr("Add a new annotation preset source to the list.")); 359 deleteAnno.setToolTipText(tr("Delete the selected source from the list.")); 292 360 293 361 // creating the gui … … 333 401 map.add(new JLabel(tr("Projection method")), GBC.std()); 334 402 map.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 335 map.add(projectionCombo, GBC.eol().fill(GBC.HORIZONTAL).insets(0,0,0,5)); 403 map.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,0,0,5)); 404 map.add(new JLabel(tr("Annotation preset sources")), GBC.eol()); 405 map.add(new JScrollPane(annotationSources), GBC.std().fill(GBC.HORIZONTAL).insets(10,0,10,0)); 406 map.add(annoButton, GBC.eol()); 407 336 408 map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 337 409
Note:
See TracChangeset
for help on using the changeset viewer.