- Timestamp:
- 2006-12-29T16:57:07+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r172 r178 43 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 44 44 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 45 import org.openstreetmap.josm.gui.preferences.AnnotationPresetPreference; 45 46 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 46 47 import org.openstreetmap.josm.plugins.PluginException; … … 175 176 contentPane.add(toolbar.control, BorderLayout.NORTH); 176 177 177 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), "Help"); 178 contentPane.getActionMap().put("Help", menu.help); 179 180 toolbar.refreshToolbarControl(); 181 182 toolbar.control.updateUI(); 183 contentPane.updateUI(); 178 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), "Help"); 179 contentPane.getActionMap().put("Help", menu.help); 180 181 AnnotationPresetPreference.initialize(); 182 183 toolbar.refreshToolbarControl(); 184 185 toolbar.control.updateUI(); 186 contentPane.updateUI(); 184 187 } 185 188 … … 189 192 */ 190 193 public void loadPlugins() { 191 194 if (Main.pref.hasKey("plugins")) { 192 195 for (String pluginName : Main.pref.get("plugins").split(",")) { 193 196 try { … … 206 209 } 207 210 } 208 211 } 209 212 210 213 /** … … 307 310 bounds = !args.containsKey("no-fullscreen") ? new Rectangle(0,0,screenDimension.width,screenDimension.height) : new Rectangle(1000,740); 308 311 309 pleaseWaitDlg = new PleaseWaitDialog();312 pleaseWaitDlg = new PleaseWaitDialog(); 310 313 } 311 314 … … 323 326 324 327 public static boolean breakBecauseUnsavedChanges() { 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 328 if (map != null) { 329 boolean modified = false; 330 boolean uploadedModified = false; 331 for (final Layer l : map.mapView.getAllLayers()) { 332 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 333 modified = true; 334 uploadedModified = ((OsmDataLayer)l).uploadedModified; 335 break; 336 } 337 } 338 if (modified) { 339 final String msg = uploadedModified ? "\n"+tr("Hint: Some changes came from uploading new data to the server.") : ""; 340 final int answer = JOptionPane.showConfirmDialog( 341 parent, tr("There are unsaved changes. Discard the changes and continue?")+msg, 342 tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION); 343 if (answer != JOptionPane.YES_OPTION) 344 return true; 345 } 346 } 347 return false; 348 } 346 349 347 350 private static void downloadFromParamString(final boolean rawGps, String s) { -
src/org/openstreetmap/josm/actions/AboutAction.java
r162 r178 55 55 56 56 public AboutAction() { 57 super(tr("About"), "about",tr("Display the about screen."), KeyEvent.VK_F1, KeyEvent.SHIFT_DOWN_MASK );57 super(tr("About"), "about",tr("Display the about screen."), KeyEvent.VK_F1, KeyEvent.SHIFT_DOWN_MASK, true); 58 58 } 59 59 -
src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r167 r178 27 27 28 28 public AlignInCircleAction() { 29 super(tr("Align Nodes in Circle"), "aligncircle", tr("Move the selected nodes into a circle."), KeyEvent.VK_O, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK );29 super(tr("Align Nodes in Circle"), "aligncircle", tr("Move the selected nodes into a circle."), KeyEvent.VK_O, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK, true); 30 30 } 31 31 -
src/org/openstreetmap/josm/actions/AlignInLineAction.java
r167 r178 27 27 28 28 public AlignInLineAction() { 29 super(tr("Align Nodes in Line"), "alignline", tr("Move the selected nodes onto a line."), KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK );29 super(tr("Align Nodes in Line"), "alignline", tr("Move the selected nodes onto a line."), KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK, true); 30 30 } 31 31 -
src/org/openstreetmap/josm/actions/DiskAccessAction.java
r138 r178 39 39 40 40 public DiskAccessAction(String name, String iconName, String tooltip, int shortCut, int modifiers) { 41 super(name, iconName, tooltip, shortCut, modifiers );41 super(name, iconName, tooltip, shortCut, modifiers, true); 42 42 } 43 43 -
src/org/openstreetmap/josm/actions/DownloadAction.java
r172 r178 85 85 86 86 public DownloadAction() { 87 super(tr("Download from OSM"), "download", tr("Download map data from the OSM server."), KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK );87 super(tr("Download from OSM"), "download", tr("Download map data from the OSM server."), KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true); 88 88 // TODO remove when bug in Java6 is fixed 89 89 for (JTextField f : latlon) -
src/org/openstreetmap/josm/actions/DownloadIncompleteAction.java
r175 r178 60 60 61 61 public DownloadIncompleteAction() { 62 super(tr("Download incomplete objects"), "downloadincomplete", tr("Download all (selected) incomplete ways from the OSM server."), KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK );62 super(tr("Download incomplete objects"), "downloadincomplete", tr("Download all (selected) incomplete ways from the OSM server."), KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK, true); 63 63 } 64 64 -
src/org/openstreetmap/josm/actions/ExitAction.java
r104 r178 16 16 */ 17 17 public ExitAction() { 18 super(tr("Exit"), "exit", tr("Exit the application."), KeyEvent.VK_ X);18 super(tr("Exit"), "exit", tr("Exit the application."), KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK, true); 19 19 } 20 20 -
src/org/openstreetmap/josm/actions/JosmAction.java
r172 r178 16 16 abstract public class JosmAction extends AbstractAction { 17 17 18 /** 19 * Construct the action as menu action entry. 20 * 21 * @param name Name of the action (entry name in menu) 22 * @param iconName Name of the icon (without extension) 23 * @param tooltip Short tooltip description 24 * @param mnemonic Mnemonic in the menu 25 */ 26 public JosmAction(String name, String iconName, String tooltip, int mnemonic) { 27 super(name, ImageProvider.get(iconName)); 28 putValue(SHORT_DESCRIPTION, tooltip); 29 putValue(MNEMONIC_KEY, mnemonic); 30 putValue("toolbar", iconName); 31 Main.toolbar.register(this); 32 } 33 34 35 public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier) { 18 public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier, boolean register) { 36 19 super(name, ImageProvider.get(iconName)); 37 20 setHelpId(); … … 40 23 Main.contentPane.getActionMap().put(name, this); 41 24 putValue("toolbar", iconName); 42 Main.toolbar.register(this); 25 if (register) 26 Main.toolbar.register(this); 43 27 } 44 28 -
src/org/openstreetmap/josm/actions/NewAction.java
r172 r178 12 12 13 13 public NewAction() { 14 super(tr("New"), "new", tr("Create a new map."), KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK );14 super(tr("New"), "new", tr("Create a new map."), KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK, true); 15 15 } 16 16 -
src/org/openstreetmap/josm/actions/PreferencesAction.java
r176 r178 26 26 */ 27 27 public PreferencesAction() { 28 super(tr("Preferences"), "preference", tr("Open a preferences page for global settings."), KeyEvent.VK_F12, 0 );28 super(tr("Preferences"), "preference", tr("Open a preferences page for global settings."), KeyEvent.VK_F12, 0, true); 29 29 } 30 30 -
src/org/openstreetmap/josm/actions/RedoAction.java
r113 r178 21 21 */ 22 22 public RedoAction() { 23 super(tr("Redo"), "redo", tr("Redo the last undone action."), KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK );23 super(tr("Redo"), "redo", tr("Redo the last undone action."), KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true); 24 24 setEnabled(false); 25 25 } -
src/org/openstreetmap/josm/actions/ReverseSegmentAction.java
r128 r178 24 24 25 25 public ReverseSegmentAction() { 26 super(tr("Reverse Segments"), "segmentflip", tr("Revert the direction of all selected Segments."), KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK );26 super(tr("Reverse Segments"), "segmentflip", tr("Revert the direction of all selected Segments."), KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK, true); 27 27 } 28 28 -
src/org/openstreetmap/josm/actions/UndoAction.java
r113 r178 21 21 */ 22 22 public UndoAction() { 23 super(tr("Undo"), "undo", tr("Undo the last action."), KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK );23 super(tr("Undo"), "undo", tr("Undo the last action."), KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK, true); 24 24 setEnabled(false); 25 25 } -
src/org/openstreetmap/josm/actions/UploadAction.java
r153 r178 34 34 public class UploadAction extends JosmAction { 35 35 public UploadAction() { 36 super(tr("Upload to OSM"), "upload", tr("Upload all changes to the OSM server."), KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK );36 super(tr("Upload to OSM"), "upload", tr("Upload all changes to the OSM server."), KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true); 37 37 } 38 38 -
src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r113 r178 28 28 */ 29 29 public MapMode(String name, String iconName, String tooltip, int keystroke, MapFrame mapFrame, Cursor cursor) { 30 super(name, "mapmode/"+iconName, tooltip, keystroke, 0 );30 super(name, "mapmode/"+iconName, tooltip, keystroke, 0, false); 31 31 // this.cursor = cursor; 32 32 putValue("active", false); -
src/org/openstreetmap/josm/gui/MapView.java
r169 r178 323 323 recalculateCenterScale(); 324 324 325 if ( !oldCenter.equals(center))325 if ((oldCenter == null && center != null) || !oldCenter.equals(center)) 326 326 firePropertyChange("center", oldCenter, center); 327 327 if (oldAutoScale != autoScale) -
src/org/openstreetmap/josm/gui/annotation/AnnotationCellRenderer.java
r177 r178 1 /**2 *3 */4 1 package org.openstreetmap.josm.gui.annotation; 5 2 6 3 import java.awt.Component; 4 import java.awt.Image; 7 5 6 import javax.swing.Action; 8 7 import javax.swing.DefaultListCellRenderer; 8 import javax.swing.ImageIcon; 9 9 import javax.swing.JComponent; 10 10 import javax.swing.JLabel; … … 15 15 final public class AnnotationCellRenderer extends DefaultListCellRenderer { 16 16 @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 17 AnnotationPreset a = (AnnotationPreset)value; 18 if (a == null || a.name == null) 19 return super.getListCellRendererComponent(list, "", index, false, false); 20 JComponent c = (JComponent)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 21 JLabel l = new JLabel((a).name); 22 l.setForeground(c.getForeground()); 23 l.setBackground(c.getBackground()); 24 l.setFont(c.getFont()); 25 l.setBorder(c.getBorder()); 26 if (a.types == null) 27 l.setIcon(ImageProvider.get("data", "empty")); 28 else if (a.types.size() != 1) 29 l.setIcon(ImageProvider.get("data", "object")); 30 else 31 l.setIcon(ImageProvider.get("data", a.types.iterator().next().getSimpleName().toLowerCase())); 32 l.setOpaque(true); 33 return l; 34 } 17 AnnotationPreset a = ((ForwardActionListener)value).preset; 18 String name = a == null ? null : (String)a.getValue(Action.NAME); 19 if (name == null) 20 return super.getListCellRendererComponent(list, "", index, false, false); 21 JComponent c = (JComponent)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 22 JLabel l = new JLabel(name); 23 l.setForeground(c.getForeground()); 24 l.setBackground(c.getBackground()); 25 l.setFont(c.getFont()); 26 l.setBorder(c.getBorder()); 27 ImageIcon icon = (ImageIcon)a.getValue(Action.SMALL_ICON); 28 if (icon != null) 29 l.setIcon(new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH))); 30 else { 31 if (a.types == null) 32 l.setIcon(ImageProvider.get("data", "empty")); 33 else if (a.types.size() != 1) 34 l.setIcon(ImageProvider.get("data", "object")); 35 else 36 l.setIcon(ImageProvider.get("data", a.types.iterator().next().getSimpleName().toLowerCase())); 37 } 38 l.setOpaque(true); 39 return l; 40 } 35 41 } -
src/org/openstreetmap/josm/gui/annotation/AnnotationPreset.java
r167 r178 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.Image; 8 import java.awt.event.ActionEvent; 7 9 import java.io.BufferedReader; 10 import java.io.FileInputStream; 8 11 import java.io.IOException; 9 12 import java.io.InputStream; 10 13 import java.io.InputStreamReader; 11 14 import java.io.UnsupportedEncodingException; 15 import java.net.URL; 12 16 import java.util.Collection; 13 17 import java.util.LinkedList; 14 18 import java.util.List; 15 19 import java.util.StringTokenizer; 20 21 import javax.swing.AbstractAction; 22 import javax.swing.ImageIcon; 16 23 import javax.swing.JCheckBox; 17 24 import javax.swing.JComboBox; 18 25 import javax.swing.JLabel; 26 import javax.swing.JOptionPane; 19 27 import javax.swing.JPanel; 20 28 import javax.swing.JTextField; 21 29 30 import org.openstreetmap.josm.Main; 22 31 import org.openstreetmap.josm.command.ChangePropertyCommand; 23 32 import org.openstreetmap.josm.command.Command; … … 38 47 * It is also able to construct dialogs out of preset definitions. 39 48 */ 40 public class AnnotationPreset {49 public class AnnotationPreset extends AbstractAction { 41 50 42 51 private static interface Item { … … 146 155 String currentName; 147 156 Collection<Class<?>> currentTypes; 157 ImageIcon currentIcon; 148 158 private static int unknownCounter = 1; 149 159 … … 170 180 } 171 181 } 182 currentIcon = (a.getValue("icon") == null) ? null : new ImageIcon(a.getValue("icon")); 172 183 } else if (qname.equals("text")) 173 184 current.add(new Text(a.getValue("key"), a.getValue("text"), a.getValue("default"), parseBoolean(a.getValue("delete_if_empty")))); … … 201 212 202 213 private boolean parseBoolean(String s) { 203 204 214 return s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no"); 215 } 205 216 206 217 @Override public void endElement(String ns, String lname, String qname) { 207 218 if (qname.equals("item")) { 208 data.add(new AnnotationPreset(current, currentName, current Types));219 data.add(new AnnotationPreset(current, currentName, currentIcon, currentTypes)); 209 220 current = null; 210 221 currentName = null; 211 222 currentTypes = null; 223 currentIcon = null; 212 224 } 213 225 } … … 215 227 216 228 private List<Item> data; 217 public String name;218 229 public Collection<Class<?>> types; 219 220 public AnnotationPreset(List<Item> data, String name, Collection<Class<?>> currentTypes) { 230 231 public AnnotationPreset(List<Item> data, String name, ImageIcon icon, Collection<Class<?>> currentTypes) { 232 super(name, icon == null ? null : new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_SMOOTH))); 233 putValue("toolbar", "annotation_"+name); 221 234 this.data = data; 222 this.name = name;223 235 this.types = currentTypes; 236 Main.toolbar.register(this); 224 237 } 225 238 … … 244 257 } 245 258 259 public static Collection<AnnotationPreset> readFromPreferences() { 260 LinkedList<AnnotationPreset> allPresets = new LinkedList<AnnotationPreset>(); 261 String allAnnotations = Main.pref.get("annotation.sources"); 262 StringTokenizer st = new StringTokenizer(allAnnotations, ";"); 263 while (st.hasMoreTokens()) { 264 InputStream in = null; 265 String source = st.nextToken(); 266 try { 267 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 268 in = new URL(source).openStream(); 269 else if (source.startsWith("resource://")) 270 in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 271 else 272 in = new FileInputStream(source); 273 allPresets.addAll(AnnotationPreset.readAll(in)); 274 in.close(); 275 } catch (IOException e) { 276 e.printStackTrace(); 277 JOptionPane.showMessageDialog(Main.parent, tr("Could not read annotation preset source: {0}",source)); 278 } catch (SAXException e) { 279 e.printStackTrace(); 280 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing {0}: ", source)+e.getMessage()); 281 } 282 } 283 return allPresets; 284 } 285 286 246 287 public JPanel createPanel() { 247 288 if (data == null) … … 253 294 } 254 295 255 public Command createCommand(Collection<OsmPrimitive> participants) { 296 public void actionPerformed(ActionEvent e) { 297 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 298 JPanel p = createPanel(); 299 if (p == null) 300 return; 301 int answer; 302 if (p.getComponentCount() == 0) 303 answer = JOptionPane.OK_OPTION; 304 else 305 answer = JOptionPane.showConfirmDialog(Main.parent, p, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()), JOptionPane.OK_CANCEL_OPTION); 306 if (answer == JOptionPane.OK_OPTION) { 307 Command cmd = createCommand(Main.ds.getSelected()); 308 if (cmd != null) 309 Main.main.editLayer().add(cmd); 310 } 311 Main.ds.setSelected(Main.ds.getSelected()); // force update 312 } 313 314 private Command createCommand(Collection<OsmPrimitive> participants) { 256 315 Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(); 257 316 for (OsmPrimitive osm : participants) -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r155 r178 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.io.FileInputStream;17 import java.io.IOException;18 import java.io.InputStream;19 import java.net.URL;20 16 import java.util.Collection; 21 17 import java.util.HashMap; 22 18 import java.util.Map; 23 import java.util.StringTokenizer;24 19 import java.util.TreeMap; 25 20 import java.util.TreeSet; … … 43 38 import org.openstreetmap.josm.Main; 44 39 import org.openstreetmap.josm.command.ChangePropertyCommand; 45 import org.openstreetmap.josm.command.Command;46 40 import org.openstreetmap.josm.data.SelectionChangedListener; 47 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 49 43 import org.openstreetmap.josm.gui.annotation.AnnotationCellRenderer; 50 44 import org.openstreetmap.josm.gui.annotation.AnnotationPreset; 45 import org.openstreetmap.josm.gui.annotation.ForwardActionListener; 46 import org.openstreetmap.josm.gui.preferences.AnnotationPresetPreference; 51 47 import org.openstreetmap.josm.tools.ImageProvider; 52 import org.xml.sax.SAXException;53 48 54 49 /** … … 214 209 */ 215 210 private final JTable propertyTable = new JTable(data); 216 private JComboBox annotationPresets = new JComboBox(); 211 public JComboBox annotationPresets = new JComboBox(); 212 217 213 218 214 /** … … 222 218 super(tr("Properties"), "propertiesdialog", tr("Property for selected objects."), KeyEvent.VK_P, 150); 223 219 224 Vector<AnnotationPreset> allPresets = new Vector<AnnotationPreset>(); 225 String allAnnotations = Main.pref.get("annotation.sources"); 226 StringTokenizer st = new StringTokenizer(allAnnotations, ";"); 227 while (st.hasMoreTokens()) { 228 InputStream in = null; 229 String source = st.nextToken(); 230 try { 231 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 232 in = new URL(source).openStream(); 233 else if (source.startsWith("resource://")) 234 in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 235 else 236 in = new FileInputStream(source); 237 allPresets.addAll(AnnotationPreset.readAll(in)); 238 in.close(); 239 } catch (IOException e) { 240 e.printStackTrace(); 241 JOptionPane.showMessageDialog(Main.parent, tr("Could not read annotation preset source: {0}",source)); 242 } catch (SAXException e) { 243 e.printStackTrace(); 244 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing {0}: ", source)+e.getMessage()); 245 } 246 } 247 if (allPresets.size() > 0) { 248 allPresets.add(0, new AnnotationPreset()); 220 if (AnnotationPresetPreference.annotationPresets.size() > 0) { 221 Vector<ActionListener> allPresets = new Vector<ActionListener>(); 222 for (final AnnotationPreset p : AnnotationPresetPreference.annotationPresets) 223 allPresets.add(new ForwardActionListener(this, p)); 224 225 allPresets.add(0, new ForwardActionListener(this, new AnnotationPreset())); 249 226 annotationPresets.setModel(new DefaultComboBoxModel(allPresets)); 250 227 add(annotationPresets, BorderLayout.NORTH); … … 252 229 annotationPresets.addActionListener(new ActionListener(){ 253 230 public void actionPerformed(ActionEvent e) { 254 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 255 AnnotationPreset preset = (AnnotationPreset)annotationPresets.getSelectedItem(); 256 JPanel p = preset.createPanel(); 257 if (p == null) 258 return; 259 int answer; 260 if (p.getComponentCount() == 0) 261 answer = JOptionPane.OK_OPTION; 262 else 263 answer = JOptionPane.showConfirmDialog(Main.parent, p, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()), JOptionPane.OK_CANCEL_OPTION); 264 if (answer == JOptionPane.OK_OPTION) { 265 Command cmd = preset.createCommand(sel); 266 if (cmd != null) { 267 Main.main.editLayer().add(cmd); 268 selectionChanged(sel); // update whole table 269 } 270 } 271 annotationPresets.setSelectedIndex(0); 231 AnnotationPreset preset = ((ForwardActionListener)annotationPresets.getSelectedItem()).preset; 232 preset.actionPerformed(e); 272 233 } 273 234 }); -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r155 r178 24 24 25 25 public final class ToggleDialogAction extends JosmAction { 26 27 26 public final String prefname; 27 public AbstractButton button; 28 28 29 30 super(name, iconName, tooltip, shortCut, modifier);31 32 29 private ToggleDialogAction(String name, String iconName, String tooltip, int shortCut, int modifier, String prefname) { 30 super(name, iconName, tooltip, shortCut, modifier, false); 31 this.prefname = prefname; 32 } 33 33 34 35 36 37 38 39 40 34 public void actionPerformed(ActionEvent e) { 35 if (e != null && !(e.getSource() instanceof AbstractButton)) 36 button.setSelected(!button.isSelected()); 37 setVisible(button.isSelected()); 38 Main.pref.put(prefname+".visible", button.isSelected()); 39 } 40 } 41 41 42 42 /** … … 61 61 String help = getClass().getName(); 62 62 help = help.substring(help.lastIndexOf('.')+1, help.length()-6); 63 64 63 return "Dialog/"+help; 64 } 65 65 } -
src/org/openstreetmap/josm/gui/preferences/AnnotationPresetPreference.java
r168 r178 6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.ActionListener; 8 import java.util.Collection; 8 9 import java.util.StringTokenizer; 9 10 … … 18 19 19 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.annotation.AnnotationPreset; 20 22 import org.openstreetmap.josm.tools.GBC; 21 23 22 24 public class AnnotationPresetPreference implements PreferenceSetting { 23 25 24 private JList annotationSources = new JList(new DefaultListModel()); 26 public static Collection<AnnotationPreset> annotationPresets; 27 private JList annotationSources; 25 28 26 29 public void addGui(final PreferenceDialog gui) { 30 annotationSources = new JList(new DefaultListModel()); 27 31 String annos = Main.pref.get("annotation.sources"); 28 32 StringTokenizer st = new StringTokenizer(annos, ";"); … … 92 96 Main.pref.put("annotation.sources", null); 93 97 } 98 99 /** 100 * Initialize the annotation presets (load and may display error) 101 */ 102 public static void initialize() { 103 annotationPresets = AnnotationPreset.readFromPreferences(); 104 } 94 105 } -
src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r172 r178 82 82 private Move moveAction = new Move(); 83 83 84 /** 85 * Key: Registered name (property "toolbar" of action). 86 * Value: The action to execute. 87 */ 84 88 private Map<String, Action> actions = new HashMap<String, Action>(); 85 89 -
src/org/openstreetmap/josm/tools/ShortCutLabel.java
r113 r178 9 9 public static String name(int shortCut, int modifiers) { 10 10 String s = ""; 11 if ((modifiers & KeyEvent.CTRL_MASK) != 0 )11 if ((modifiers & KeyEvent.CTRL_MASK) != 0 || (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0) 12 12 s += tr("Ctrl-"); 13 if ((modifiers & KeyEvent.ALT_MASK) != 0 )13 if ((modifiers & KeyEvent.ALT_MASK) != 0 || (modifiers & KeyEvent.ALT_DOWN_MASK) != 0) 14 14 s += tr("Alt-"); 15 if ((modifiers & KeyEvent.ALT_GRAPH_MASK) != 0 )15 if ((modifiers & KeyEvent.ALT_GRAPH_MASK) != 0 || (modifiers & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0) 16 16 s += tr("AltGr-"); 17 if ((modifiers & KeyEvent.SHIFT_MASK) != 0 )17 if ((modifiers & KeyEvent.SHIFT_MASK) != 0 || (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0) 18 18 s += tr("Shift-"); 19 19 if (shortCut >= KeyEvent.VK_F1 && shortCut <= KeyEvent.VK_F12)
Note:
See TracChangeset
for help on using the changeset viewer.