Changeset 397 in josm


Ignore:
Timestamp:
Oct 16, 2007 11:18:46 PM (6 years ago)
Author:
framm
Message:
  • added a built-in set of tagging presets. this can be disabled from preferences panel, or replaced with an own control file.
Location:
trunk
Files:
53 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r343 r397  
    22<classpath> 
    33        <classpathentry kind="src" path="src"/> 
    4         <classpathentry excluding="build/|dist/|src/|test/" including="images/" kind="src" path=""/> 
     4        <classpathentry excluding="build/|dist/|src/|test/" including="images/|presets/" kind="src" path=""/> 
    55        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    6         <classpathentry kind="lib" path="lib/metadata-extractor-2.3.1.jar"/> 
     6        <classpathentry kind="lib" path="/home/fred/src/eclipse-workspace/JOSM/lib/metadata-extractor-2.3.1-nosun.jar"/> 
    77        <classpathentry kind="lib" path="lib/gettext-commons-0.9.jar" sourcepath="C:/Download/gettext-commons-0.9-src.zip"/> 
    88        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 
  • trunk/build.xml

    r392 r397  
    2525                </copy> 
    2626 
     27                <!-- presets --> 
     28                <copy todir="build/presets"> 
     29                        <fileset dir="presets" /> 
     30                </copy> 
     31 
    2732                <!-- create josm-custom.jar --> 
    2833                <jar destfile="dist/josm-custom.jar" basedir="build"> 
     
    3742        </target> 
    3843 
    39  
    40  
    4144        <target name="init"> 
    4245                <mkdir dir="build" /> 
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r343 r397  
    44import static org.openstreetmap.josm.tools.I18n.tr; 
    55 
     6import java.awt.BorderLayout; 
     7import java.awt.GridBagLayout; 
    68import java.awt.event.ActionEvent; 
    79import java.awt.event.ActionListener; 
     10import java.util.Vector; 
    811 
    912import javax.swing.Action; 
     13import javax.swing.DefaultComboBoxModel; 
    1014import javax.swing.JMenu; 
    1115import javax.swing.JMenuBar; 
    1216import javax.swing.JMenuItem; 
     17import javax.swing.JPanel; 
    1318 
    1419import org.openstreetmap.josm.actions.AboutAction; 
     
    3540import org.openstreetmap.josm.actions.search.SearchAction; 
    3641import org.openstreetmap.josm.data.DataSetChecker; 
     42import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; 
     43import org.openstreetmap.josm.gui.tagging.ForwardActionListener; 
     44import org.openstreetmap.josm.gui.tagging.TaggingCellRenderer; 
     45import org.openstreetmap.josm.gui.tagging.TaggingPreset; 
     46import org.openstreetmap.josm.tools.GBC; 
    3747 
    3848/** 
     
    7585        public final JMenu connectionMenu = new JMenu(tr("Connection")); 
    7686        public final JMenu toolsMenu = new JMenu(tr("Tools")); 
     87        public final JMenu presetsMenu = new JMenu(tr("Presets")); 
    7788 
    7889        public final JMenu zoomToMenu = new JMenu(tr("Zoom To")); 
     
    128139                layerMenu.setVisible(false); 
    129140 
     141                add(presetsMenu); 
     142                 
    130143                JMenuItem check = new JMenuItem("DEBUG: Check Dataset"); 
    131144                check.addActionListener(new ActionListener(){ 
     
    140153                helpMenu.add(about); 
    141154                add(helpMenu); 
     155                 
    142156    } 
    143157} 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r352 r397  
    321321                super(tr("Properties/Memberships"), "propertiesdialog", tr("Properties for selected objects."), KeyEvent.VK_P, 150); 
    322322 
     323                // --------------------------------------- 
     324                // This drop-down will probably be removed soon. 
     325                // 
    323326                if (TaggingPresetPreference.taggingPresets.size() > 0) { 
    324327                        Vector<ActionListener> allPresets = new Vector<ActionListener>(); 
     
    326329                                allPresets.add(new ForwardActionListener(this, p)); 
    327330 
    328                         allPresets.add(0, new ForwardActionListener(this, new TaggingPreset())); 
     331                        TaggingPreset empty = new TaggingPreset(); 
     332                        // empty.setName("this drop-down will be removed soon"); 
     333                        allPresets.add(0, new ForwardActionListener(this, empty)); 
    329334                        taggingPresets.setModel(new DefaultComboBoxModel(allPresets)); 
    330335                        JPanel north = new JPanel(new GridBagLayout()); 
     
    341346                }); 
    342347                taggingPresets.setRenderer(new TaggingCellRenderer()); 
     348                 
     349                // End of "will be removed soon". 
     350                // -------------------------------------------- 
    343351 
    344352                // setting up the properties table 
  • trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java

    r298 r397  
    44import static org.openstreetmap.josm.tools.I18n.tr; 
    55 
     6import java.awt.Color; 
     7import java.awt.GridBagLayout; 
     8 
     9import javax.swing.BorderFactory; 
    610import javax.swing.JComboBox; 
    711import javax.swing.JLabel; 
     12import javax.swing.JPanel; 
    813 
    914import org.openstreetmap.josm.Main; 
     
    2631                } 
    2732                projectionCombo.addActionListener(gui.requireRestartAction); 
    28  
    29                 gui.map.add(new JLabel(tr("Projection method")), GBC.std()); 
    30                 gui.map.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 
    31                 gui.map.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,0,0,5)); 
     33                 
     34                JPanel projPanel = new JPanel(); 
     35                projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection"))); 
     36                projPanel.setLayout(new GridBagLayout()); 
     37                projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5)); 
     38                projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 
     39                projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 
     40                gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL)); 
    3241    } 
    3342 
  • trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java

    r343 r397  
    44import static org.openstreetmap.josm.tools.I18n.tr; 
    55 
     6import java.awt.Color; 
    67import java.awt.GridBagLayout; 
    78import java.awt.event.ActionEvent; 
     
    1011import java.util.StringTokenizer; 
    1112 
     13import javax.swing.Action; 
     14import javax.swing.BorderFactory; 
    1215import javax.swing.Box; 
    1316import javax.swing.DefaultListModel; 
    1417import javax.swing.JButton; 
     18import javax.swing.JCheckBox; 
    1519import javax.swing.JLabel; 
    1620import javax.swing.JList; 
     21import javax.swing.JMenuItem; 
    1722import javax.swing.JOptionPane; 
    1823import javax.swing.JPanel; 
    1924import javax.swing.JScrollPane; 
     25import javax.swing.JSeparator; 
     26import javax.swing.border.BevelBorder; 
    2027 
    2128import org.openstreetmap.josm.Main; 
     
    2734        public static Collection<TaggingPreset> taggingPresets; 
    2835        private JList taggingPresetSources; 
     36        private JCheckBox enableDefault; 
     37         
     38        public void addGui(final PreferenceDialog gui) { 
     39                 
     40                taggingPresetSources = new JList(new DefaultListModel()); 
     41                enableDefault = new JCheckBox(tr("Enable built-in defaults"),  
     42                                Main.pref.getBoolean("taggingpreset.enable-defaults")); 
    2943 
    30         public void addGui(final PreferenceDialog gui) { 
    31                 taggingPresetSources = new JList(new DefaultListModel()); 
    3244                String annos = Main.pref.get("taggingpreset.sources"); 
    3345                StringTokenizer st = new StringTokenizer(annos, ";"); 
     
    7890                deleteAnno.setToolTipText(tr("Delete the selected source from the list.")); 
    7991 
    80                 gui.map.add(new JLabel(tr("Tagging preset sources")), GBC.eol().insets(0,5,0,0)); 
    81                 gui.map.add(new JScrollPane(taggingPresetSources), GBC.eol().fill(GBC.BOTH)); 
     92                JPanel tpPanel = new JPanel(); 
     93                tpPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Tagging Presets"))); 
     94                tpPanel.setLayout(new GridBagLayout()); 
     95                tpPanel.add(enableDefault, GBC.eol().insets(5,5,5,0)); 
     96                tpPanel.add(new JLabel(tr("Tagging preset sources")), GBC.eol().insets(5,5,5,0)); 
     97                tpPanel.add(new JScrollPane(taggingPresetSources), GBC.eol().insets(5,0,5,0).fill(GBC.BOTH)); 
    8298                JPanel buttonPanel = new JPanel(new GridBagLayout()); 
    83                 gui.map.add(buttonPanel, GBC.eol().fill(GBC.HORIZONTAL)); 
     99                tpPanel.add(buttonPanel, GBC.eol().insets(5,0,5,5).fill(GBC.HORIZONTAL)); 
    84100                buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 
    85101                buttonPanel.add(addAnno, GBC.std().insets(0,5,0,0)); 
    86102                buttonPanel.add(editAnno, GBC.std().insets(5,5,5,0)); 
    87103                buttonPanel.add(deleteAnno, GBC.std().insets(0,5,0,0)); 
     104                gui.map.add(tpPanel, GBC.eol().fill(GBC.BOTH)); 
    88105        } 
    89106 
    90107        public void ok() { 
     108                Main.pref.put("taggingpreset.enable-defaults", enableDefault.getSelectedObjects() != null); 
    91109                if (taggingPresetSources.getModel().getSize() > 0) { 
    92110                        StringBuilder sb = new StringBuilder(); 
     
    103121        public static void initialize() { 
    104122                taggingPresets = TaggingPreset.readFromPreferences(); 
     123                for (final TaggingPreset p : taggingPresets) { 
     124                        if (p.getValue(Action.NAME).equals(" ")) { 
     125                                Main.main.menu.presetsMenu.add(new JSeparator()); 
     126                        } else { 
     127                                Main.main.menu.presetsMenu.add(new JMenuItem(p)); 
     128                        } 
     129                }                
    105130        } 
    106131} 
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r304 r397  
    167167        /** 
    168168         * Called from the XML parser to set the icon 
     169         *  
     170         * FIXME for Java 1.6 - use 24x24 icons for LARGE_ICON_KEY (button bar) 
     171         * and the 16x16 icons for SMALL_ICON. 
    169172         */ 
    170173        public void setIcon(String iconName) { 
     
    172175                if (icon == null) 
    173176                        icon = new ImageIcon(iconName); 
    174                 if (Math.max(icon.getIconHeight(), icon.getIconWidth()) != 24) 
    175                         icon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH)); 
     177                if (Math.max(icon.getIconHeight(), icon.getIconWidth()) != 16) 
     178                        icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH)); 
    176179                putValue(Action.SMALL_ICON, icon); 
    177180        } 
     
    225228                LinkedList<TaggingPreset> allPresets = new LinkedList<TaggingPreset>(); 
    226229                String allTaggingPresets = Main.pref.get("taggingpreset.sources"); 
     230                 
     231                if (Main.pref.getBoolean("taggingpreset.enable-defaults")) { 
     232                        InputStream in = Main.class.getResourceAsStream("/presets/presets.xml"); 
     233                        try { 
     234                                allPresets.addAll(TaggingPreset.readAll(in)); 
     235                        } catch (SAXException x) { 
     236                                JOptionPane.showMessageDialog(Main.parent, tr("Error parsing presets.xml: ")+x.getMessage()); 
     237                        } 
     238                } 
     239                 
    227240                StringTokenizer st = new StringTokenizer(allTaggingPresets, ";"); 
    228241                while (st.hasMoreTokens()) { 
     
    232245                                if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 
    233246                                        in = new URL(source).openStream(); 
    234                                 else if (source.startsWith("resource://")) 
     247                                else if (source.startsWith("resource://"))  
    235248                                        in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 
    236249                                else 
     
    248261                return allPresets; 
    249262        } 
    250  
    251263 
    252264        public JPanel createPanel() { 
Note: See TracChangeset for help on using the changeset viewer.