Ignore:
Timestamp:
2006-07-20T00:43:51+02:00 (19 years ago)
Author:
imi
Message:
  • added color for scale bar
  • fixed scale bar in EPSG:4236 projection
  • added annotation preset system
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r115 r116  
    1111import java.awt.event.ActionListener;
    1212import java.util.Map;
     13import java.util.StringTokenizer;
    1314import java.util.TreeMap;
    1415import java.util.Vector;
     
    1920import javax.swing.Box;
    2021import javax.swing.DefaultListCellRenderer;
     22import javax.swing.DefaultListModel;
    2123import javax.swing.JButton;
    2224import javax.swing.JCheckBox;
     
    8183                        Main.pref.put("draw.segment.direction", directionHint.isSelected());
    8284
     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
    8392                        for (int i = 0; i < colors.getRowCount(); ++i) {
    8493                                String name = (String)colors.getValueAt(i, 0);
     
    121130        private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels());
    122131        /**
    123          * Combobox with all projections available
    124          */
    125         private JComboBox projectionCombo = new JComboBox(Projection.allProjections);
    126         /**
    127132         * The main tab panel.
    128133         */
     
    161166        private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
    162167        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());
    163174
    164175
     
    227238                directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction"));
    228239
     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());
    229244
    230245
     
    275290                        }
    276291                });
     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
    277342
    278343                // setting tooltips
     
    290355                drawRawGpsLines.setToolTipText(tr("If your gps device draw to few lines, select this to draw lines along your way."));
    291356                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."));
    292360
    293361                // creating the gui
     
    333401                map.add(new JLabel(tr("Projection method")), GBC.std());
    334402                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
    336408                map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    337409
Note: See TracChangeset for help on using the changeset viewer.