Changeset 1743 in josm for trunk/src/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2009-07-07T19:54:54+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/MapPaintPreference.java
r1742 r1743 2 2 package org.openstreetmap.josm.gui.preferences; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.GridBagLayout; 7 8 import javax.swing.BorderFactory; 9 import javax.swing.JCheckBox; 10 import javax.swing.JComboBox; 11 import javax.swing.JLabel; 12 import javax.swing.JPanel; 13 import javax.swing.JScrollPane; 14 4 15 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.tools.GBC; 5 18 6 19 public class MapPaintPreference implements PreferenceSetting { 20 private StyleSources sources; 21 private JCheckBox enableIconDefault; 22 private JCheckBox enableDefault; 23 private JComboBox styleCombo = new JComboBox(); 7 24 8 25 public static class Factory implements PreferenceSettingFactory { … … 13 30 14 31 public void addGui(final PreferenceDialog gui) { 15 // this is intended for a future configuration panel for mappaint! 32 enableDefault = new JCheckBox(tr("Enable built-in defaults"), 33 Main.pref.getBoolean("mappaint.style.enable-defaults", true)); 34 enableIconDefault = new JCheckBox(tr("Enable built-in icon defaults"), 35 Main.pref.getBoolean("mappaint.icon.enable-defaults", true)); 36 37 styleCombo.addItem("standard"); 38 39 String style = Main.pref.get("mappaint.style", "standard"); 40 styleCombo.setEditable(true); 41 for (int i = 0; i < styleCombo.getItemCount(); ++i) { 42 if (styleCombo.getItemAt(i).getClass().getName().equals(style)) { 43 styleCombo.setSelectedIndex(i); 44 break; 45 } 46 } 47 48 JPanel panel = new JPanel(new GridBagLayout()); 49 JScrollPane scrollpane = new JScrollPane(panel); 50 panel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 51 panel.add(enableDefault, GBC.std().insets(5,5,5,0)); 52 panel.add(enableIconDefault, GBC.eol().insets(5,5,5,0)); 53 54 panel.add(new JLabel(tr("Used style")), GBC.std().insets(5,5,0,5)); 55 panel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 56 panel.add(styleCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,0,5,0)); 57 58 sources = new StyleSources("mappaint.style.sources", "mappaint.icon.sources", 59 "http://josm.openstreetmap.de/styles", false, tr("Map Paint Styles")); 60 panel.add(sources, GBC.eol().fill(GBC.BOTH)); 61 gui.mapcontent.addTab(tr("Map Paint Styles"), scrollpane); 16 62 } 17 63 18 64 public boolean ok() { 19 return false; // dummy 65 Boolean restart = Main.pref.put("mappaint.style.enable-defaults", enableDefault.getSelectedObjects() != null); 66 if(Main.pref.put("mappaint.icon.enable-defaults", enableIconDefault.getSelectedObjects() != null)) 67 restart = true; 68 if(sources.finish()) 69 restart = true; 70 Main.pref.put("mappaint.style", styleCombo.getEditor().getItem().toString()); 71 return restart; 20 72 } 21 73 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r1742 r1743 45 45 46 46 public final javax.swing.JTabbedPane displaycontent = new javax.swing.JTabbedPane(); 47 public final javax.swing.JTabbedPane mapcontent = new javax.swing.JTabbedPane(); 47 48 48 49 /** … … 118 119 119 120 display.add(displaycontent, GBC.eol().fill(GBC.BOTH)); 121 map.add(mapcontent, GBC.eol().fill(GBC.BOTH)); 120 122 for (Iterator<PreferenceSetting> it = settings.iterator(); it.hasNext();) { 121 123 try { … … 150 152 settingsFactory.add(new LafPreference.Factory()); 151 153 settingsFactory.add(new LanguagePreference.Factory()); 152 settingsFactory.add(new MapPaintPreference.Factory());153 154 settingsFactory.add(new ServerAccessPreference.Factory()); 154 155 settingsFactory.add(new FilePreferences.Factory()); 155 156 settingsFactory.add(new ProxyPreferences.Factory()); 156 157 settingsFactory.add(new ProjectionPreference.Factory()); 158 settingsFactory.add(new MapPaintPreference.Factory()); 157 159 settingsFactory.add(new TaggingPresetPreference.Factory()); 158 160 settingsFactory.add(new PluginPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r1742 r1743 8 8 9 9 import javax.swing.BorderFactory; 10 import javax.swing.Box; 10 11 import javax.swing.JComboBox; 11 12 import javax.swing.JLabel; 13 import javax.swing.JScrollPane; 12 14 import javax.swing.JPanel; 13 15 … … 50 52 51 53 JPanel projPanel = new JPanel(); 52 projPanel.setBorder(BorderFactory.create TitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection")));54 projPanel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 53 55 projPanel.setLayout(new GridBagLayout()); 54 56 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5)); … … 58 60 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 59 61 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 60 gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL)); 62 projPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 63 JScrollPane scrollpane = new JScrollPane(projPanel); 64 gui.mapcontent.addTab(tr("Map Projection"), scrollpane); 61 65 } 62 66 -
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r1742 r1743 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color;7 6 import java.awt.GridBagLayout; 8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 import java.util.ArrayList;11 7 import java.util.Collection; 12 8 import java.util.HashMap; 13 9 14 10 import javax.swing.BorderFactory; 15 import javax.swing.Box;16 import javax.swing.DefaultListModel;17 import javax.swing.JButton;18 11 import javax.swing.JCheckBox; 19 import javax.swing.JLabel;20 import javax.swing.JList;21 12 import javax.swing.JMenu; 22 13 import javax.swing.JMenuItem; 23 import javax.swing.JOptionPane;24 14 import javax.swing.JPanel; 15 import javax.swing.JSeparator; 25 16 import javax.swing.JScrollPane; 26 import javax.swing.JSeparator;27 17 28 18 import org.openstreetmap.josm.Main; … … 41 31 42 32 public static Collection<TaggingPreset> taggingPresets; 43 private JList taggingPresetSources;33 private StyleSources sources; 44 34 private JCheckBox sortMenu; 45 35 private JCheckBox enableDefault; 46 36 47 37 public void addGui(final PreferenceDialog gui) { 48 49 taggingPresetSources = new JList(new DefaultListModel());50 38 sortMenu = new JCheckBox(tr("Sort presets menu"), 51 39 Main.pref.getBoolean("taggingpreset.sortmenu", false)); … … 53 41 Main.pref.getBoolean("taggingpreset.enable-defaults", true)); 54 42 55 Collection<String> sources = Main.pref.getCollection("taggingpreset.sources", null); 56 if(sources != null) 57 for(String s : sources) 58 ((DefaultListModel)taggingPresetSources.getModel()).addElement(s); 59 60 JButton addAnno = new JButton(tr("Add")); 61 addAnno.addActionListener(new ActionListener(){ 62 public void actionPerformed(ActionEvent e) { 63 String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source")); 64 if (source != null) 65 ((DefaultListModel)taggingPresetSources.getModel()).addElement(source); 66 } 67 }); 68 69 JButton editAnno = new JButton(tr("Edit")); 70 editAnno.addActionListener(new ActionListener(){ 71 public void actionPerformed(ActionEvent e) { 72 if (taggingPresetSources.getSelectedIndex() == -1) 73 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit.")); 74 else { 75 String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source"), taggingPresetSources.getSelectedValue()); 76 if (source != null) 77 ((DefaultListModel)taggingPresetSources.getModel()).setElementAt(source, taggingPresetSources.getSelectedIndex()); 78 } 79 } 80 }); 81 82 JButton deleteAnno = new JButton(tr("Delete")); 83 deleteAnno.addActionListener(new ActionListener(){ 84 public void actionPerformed(ActionEvent e) { 85 if (taggingPresetSources.getSelectedIndex() == -1) 86 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete.")); 87 else { 88 ((DefaultListModel)taggingPresetSources.getModel()).remove(taggingPresetSources.getSelectedIndex()); 89 } 90 } 91 }); 92 taggingPresetSources.setVisibleRowCount(3); 93 94 taggingPresetSources.setToolTipText(tr("The sources (URL or filename) of tagging preset definition files. See http://josm.openstreetmap.de/wiki/TaggingPresets for help.")); 95 addAnno.setToolTipText(tr("Add a new tagging preset source to the list.")); 96 deleteAnno.setToolTipText(tr("Delete the selected source from the list.")); 97 98 JPanel tpPanel = new JPanel(); 99 tpPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Tagging Presets"))); 100 tpPanel.setLayout(new GridBagLayout()); 101 tpPanel.add(sortMenu, GBC.eol().insets(5,5,5,0)); 102 tpPanel.add(enableDefault, GBC.eol().insets(5,5,5,0)); 103 tpPanel.add(new JLabel(tr("Tagging preset sources")), GBC.eol().insets(5,5,5,0)); 104 tpPanel.add(new JScrollPane(taggingPresetSources), GBC.eol().insets(5,0,5,0).fill(GBC.BOTH)); 105 JPanel buttonPanel = new JPanel(new GridBagLayout()); 106 tpPanel.add(buttonPanel, GBC.eol().insets(5,0,5,5).fill(GBC.HORIZONTAL)); 107 buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 108 buttonPanel.add(addAnno, GBC.std().insets(0,5,0,0)); 109 buttonPanel.add(editAnno, GBC.std().insets(5,5,5,0)); 110 buttonPanel.add(deleteAnno, GBC.std().insets(0,5,0,0)); 111 gui.map.add(tpPanel, GBC.eol().fill(GBC.BOTH)); 43 JPanel panel = new JPanel(new GridBagLayout()); 44 JScrollPane scrollpane = new JScrollPane(panel); 45 panel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 46 panel.add(sortMenu, GBC.eol().insets(5,5,5,0)); 47 panel.add(enableDefault, GBC.eol().insets(5,0,5,0)); 48 sources = new StyleSources("taggingpreset.sources", "taggingpreset.icon.sources", 49 "http://josm.openstreetmap.de/presets", false, tr("Tagging Presets")); 50 panel.add(sources, GBC.eol().fill(GBC.BOTH)); 51 gui.mapcontent.addTab(tr("Tagging Presets"), scrollpane); 112 52 } 113 53 114 54 public boolean ok() { 115 boolean restart; 116 Main.pref.put("taggingpreset.enable-defaults", enableDefault.getSelectedObjects() != null); 117 restart = Main.pref.put("taggingpreset.sortmenu", sortMenu.getSelectedObjects() != null); 118 int num = taggingPresetSources.getModel().getSize(); 119 if (num > 0) 120 { 121 ArrayList<String> l = new ArrayList<String>(); 122 for (int i = 0; i < num; ++i) 123 l.add((String)taggingPresetSources.getModel().getElementAt(i)); 124 if(Main.pref.putCollection("taggingpreset.sources", l)) 125 restart = true; 126 } 127 else if(Main.pref.putCollection("taggingpreset.sources", null)) 55 boolean restart = Main.pref.put("taggingpreset.enable-defaults", 56 enableDefault.getSelectedObjects() != null); 57 if(Main.pref.put("taggingpreset.sortmenu", sortMenu.getSelectedObjects() != null)) 58 restart = true; 59 if(sources.finish()) 128 60 restart = true; 129 61 return restart;
Note:
See TracChangeset
for help on using the changeset viewer.