- Timestamp:
- 2006-03-24T01:45:42+01:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r54 r68 3 3 4 4 import java.awt.BorderLayout; 5 import java.awt.Container;6 5 import java.awt.Dimension; 7 6 import java.awt.Point; … … 11 10 import java.io.File; 12 11 import java.util.Arrays; 13 import java.util.Collection; 12 import java.util.Iterator; 13 import java.util.LinkedList; 14 import java.util.StringTokenizer; 14 15 15 16 import javax.swing.JFrame; … … 66 67 * The main panel. 67 68 */ 68 p rivate Containerpanel;69 public JPanel panel; 69 70 /** 70 71 * The mapFrame currently loaded. … … 80 81 */ 81 82 public File currentDirectory = new File("."); 83 84 private OpenAction openAction; 85 86 private DownloadAction downloadAction; 82 87 83 88 /** … … 87 92 public Main() { 88 93 super("Java Open Street Map - Editor"); 94 Main.main = this; 89 95 setLayout(new BorderLayout()); 90 96 panel = new JPanel(new BorderLayout()); … … 93 99 setVisible(true); 94 100 95 // creating actions 96 DownloadAction downloadAction = new DownloadAction(); 101 downloadAction = new DownloadAction(); 97 102 UploadAction uploadAction = new UploadAction(); 98 OpenActionopenAction = new OpenAction();103 openAction = new OpenAction(); 99 104 SaveAction saveAction = new SaveAction(); 100 105 ExitAction exitAction = new ExitAction(); … … 188 193 setupUiDefaults(); 189 194 195 LinkedList<String> arguments = new LinkedList<String>(Arrays.asList(args)); 196 197 if (arguments.contains("--help")) { 198 System.out.println("Java OpenStreetMap Editor"); 199 System.out.println(); 200 System.out.println("usage:"); 201 System.out.println("\tjava -jar josm.jar <options>"); 202 System.out.println(); 203 System.out.println("options:"); 204 System.out.println("\t--help Show this help"); 205 System.out.println("\t--download=minlat,minlon,maxlat,maxlon Download the bounding box"); 206 System.out.println("\t--open=file(.osm|.xml|.gpx|.txt|.csv) Open the specific file"); 207 System.out.println("\t--no-fullscreen Don't launch in fullscreen mode"); 208 System.out.println("\t--reset-preferences Reset the preferences to default"); 209 System.exit(0); 210 } 211 212 190 213 // load preferences 191 214 String errMsg = null; 192 215 try { 193 pref.load(); 216 if (arguments.remove("--reset-preferences")) 217 pref.save(); 218 else 219 pref.load(); 194 220 } catch (PreferencesException e1) { 195 221 e1.printStackTrace(); … … 211 237 } 212 238 213 main =new Main();239 new Main(); 214 240 main.setVisible(true); 215 241 216 Collection<String> arguments = Arrays.asList(args); 217 218 if (arguments.contains("--show-modifiers")) { 242 243 if (arguments.remove("--show-modifiers")) { 219 244 Point p = main.getLocationOnScreen(); 220 245 Dimension s = main.getSize(); … … 223 248 } 224 249 225 if (!arguments. contains("--no-fullscreen")) {250 if (!arguments.remove("--no-fullscreen")) { 226 251 if (Toolkit.getDefaultToolkit().isFrameStateSupported(MAXIMIZED_BOTH)) 227 252 main.setExtendedState(MAXIMIZED_BOTH); // some platform are able to maximize … … 231 256 } 232 257 } 233 } 234 258 259 for (Iterator<String> it = arguments.iterator(); it.hasNext();) { 260 String s = it.next(); 261 if (s.startsWith("--open=")) { 262 main.openAction.openFile(new File(s.substring(7))); 263 it.remove(); 264 } else if (s.startsWith("--download=")) { 265 downloadFromParamString(false, s.substring(11)); 266 it.remove(); 267 } else if (s.startsWith("--downloadgps=")) { 268 downloadFromParamString(true, s.substring(14)); 269 it.remove(); 270 } 271 } 272 273 if (!arguments.isEmpty()) { 274 String s = "Unknown Parameter:\n"; 275 for (String arg : arguments) 276 s += arg+"\n"; 277 JOptionPane.showMessageDialog(main, s); 278 } 279 } 280 281 282 private static void downloadFromParamString(boolean rawGps, String s) { 283 StringTokenizer st = new StringTokenizer(s, ","); 284 if (st.countTokens() != 4) { 285 JOptionPane.showMessageDialog(main, "Download option does not take "+st.countTokens()+" bounding parameter."); 286 return; 287 } 288 289 try { 290 main.downloadAction.download(rawGps, Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken())); 291 } catch (NumberFormatException e) { 292 JOptionPane.showMessageDialog(main, "Could not parse the Coordinates."); 293 } 294 } 235 295 236 296 /** -
src/org/openstreetmap/josm/actions/AboutAction.java
r30 r68 38 38 39 39 public AboutAction() { 40 super("About", "about", "Display the about screen.", KeyEvent.VK_A , null);40 super("About", "about", "Display the about screen.", KeyEvent.VK_A); 41 41 } 42 42 -
src/org/openstreetmap/josm/actions/AutoScaleAction.java
r30 r68 3 3 import java.awt.event.ActionEvent; 4 4 import java.awt.event.KeyEvent; 5 6 import javax.swing.KeyStroke; 5 7 6 8 import org.openstreetmap.josm.gui.MapFrame; … … 18 20 19 21 public AutoScaleAction(MapFrame mapFrame) { 20 super("Auto Scale", "autoscale", "Zoom the view to show the whole layer. Disabled if the view is moved.", 21 KeyEvent.VK_A, null); 22 super("Auto Scale", "autoscale", "Zoom the view to show the whole layer. Disabled if the view is moved.", "Alt-A", KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_MASK)); 22 23 mapView = mapFrame.mapView; 23 24 } -
src/org/openstreetmap/josm/actions/DownloadAction.java
r66 r68 66 66 67 67 public DownloadAction() { 68 super("Download from OSM", "download", "Download map data from the OSM server.", KeyEvent.VK_D,69 KeyStroke.get AWTKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));68 super("Download from OSM", "download", "Download map data from the OSM server.", "Ctrl-Shift-D", 69 KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); 70 70 } 71 71 … … 254 254 } 255 255 256 final OsmServerReader osmReader = new OsmServerReader(b.latlon[0], b.latlon[1], b.latlon[2], b.latlon[3]); 256 double minlon = b.latlon[0]; 257 double minlat = b.latlon[1]; 258 double maxlon = b.latlon[2]; 259 double maxlat = b.latlon[3]; 260 download(rawGps.isSelected(), minlon, minlat, maxlon, maxlat); 261 return DownloadStatus.FINISHED; 262 } 263 264 /** 265 * Read a bookmark from the current set edit fields. If one of the fields is 266 * empty or contain illegal chars, <code>null</code> is returned. 267 * The name of the bookmark is <code>null</code>. 268 * @return A bookmark containing information from the edit fields and rawgps 269 * checkbox. 270 */ 271 Bookmark readBookmark() { 272 try { 273 Bookmark b = new Bookmark(); 274 for (int i = 0; i < 4; ++i) { 275 if (latlon[i].getText().equals("")) 276 return null; 277 b.latlon[i] = Double.parseDouble(latlon[i].getText()); 278 } 279 b.rawgps = rawGps.isSelected(); 280 return b; 281 } catch (NumberFormatException x) { 282 return null; 283 } 284 } 285 286 287 /** 288 * Extrakt URL arguments. 289 */ 290 private Map<String, Double> readArgs(String s) { 291 int i = s.indexOf('?'); 292 if (i == -1) 293 return new HashMap<String, Double>(); 294 String[] args = s.substring(i+1).split("&"); 295 HashMap<String, Double> map = new HashMap<String, Double>(); 296 for (String arg : args) { 297 int eq = arg.indexOf('='); 298 if (eq != -1) { 299 try { 300 map.put(arg.substring(0, eq), Double.parseDouble(arg.substring(eq + 1))); 301 } catch (NumberFormatException e) { 302 } 303 } 304 } 305 return map; 306 } 307 308 /** 309 * Set the four edit fields to the given bounds coordinates. 310 */ 311 private void setEditBounds(Bounds b) { 312 GeoPoint bottomLeft = b.min; 313 GeoPoint topRight = b.max; 314 if (bottomLeft.isOutSideWorld()) 315 bottomLeft = new GeoPoint(-89.999, -179.999); // do not use the Projection constants, since this looks better. 316 if (topRight.isOutSideWorld()) 317 topRight = new GeoPoint(89.999, 179.999); 318 latlon[0].setText(""+bottomLeft.lat); 319 latlon[1].setText(""+bottomLeft.lon); 320 latlon[2].setText(""+topRight.lat); 321 latlon[3].setText(""+topRight.lon); 322 for (JTextField f : latlon) 323 f.setCaretPosition(0); 324 } 325 326 /** 327 * Do the download for the given area. 328 */ 329 public void download(final boolean rawGps, double minlat, double minlon, double maxlat, double maxlon) { 330 final OsmServerReader osmReader = new OsmServerReader(minlat, minlon, maxlat, maxlon); 257 331 new Thread(new PleaseWaitRunnable("Downloading data"){ 258 332 @Override 259 333 public void realRun() { 260 334 try { 261 String name = latlon[0].getText() + " " 262 + latlon[1].getText() + " x " + latlon[2].getText() 263 + " " + latlon[3].getText(); 335 String name = latlon[0].getText() + " " + latlon[1].getText() + " x " + latlon[2].getText() + " " + latlon[3].getText(); 264 336 265 337 Layer layer = null; 266 if (rawGps .isSelected()) {338 if (rawGps) { 267 339 layer = new RawGpsDataLayer(osmReader.parseRawGps(), name); 268 340 } else { … … 273 345 closeDialog(); 274 346 JOptionPane.showMessageDialog(Main.main, 275 347 "No data imported."); 276 348 } 277 349 … … 303 375 } 304 376 }).start(); 305 return DownloadStatus.FINISHED;306 }307 308 /**309 * Read a bookmark from the current set edit fields. If one of the fields is310 * empty or contain illegal chars, <code>null</code> is returned.311 * The name of the bookmark is <code>null</code>.312 * @return A bookmark containing information from the edit fields and rawgps313 * checkbox.314 */315 Bookmark readBookmark() {316 try {317 Bookmark b = new Bookmark();318 for (int i = 0; i < 4; ++i) {319 if (latlon[i].getText().equals(""))320 return null;321 b.latlon[i] = Double.parseDouble(latlon[i].getText());322 }323 b.rawgps = rawGps.isSelected();324 return b;325 } catch (NumberFormatException x) {326 return null;327 }328 }329 330 331 /**332 * Extrakt URL arguments.333 */334 private Map<String, Double> readArgs(String s) {335 int i = s.indexOf('?');336 if (i == -1)337 return new HashMap<String, Double>();338 String[] args = s.substring(i+1).split("&");339 HashMap<String, Double> map = new HashMap<String, Double>();340 for (String arg : args) {341 int eq = arg.indexOf('=');342 if (eq != -1) {343 try {344 map.put(arg.substring(0, eq), Double.parseDouble(arg.substring(eq + 1)));345 } catch (NumberFormatException e) {346 }347 }348 }349 return map;350 }351 352 /**353 * Set the four edit fields to the given bounds coordinates.354 */355 private void setEditBounds(Bounds b) {356 GeoPoint bottomLeft = b.min;357 GeoPoint topRight = b.max;358 if (bottomLeft.isOutSideWorld())359 bottomLeft = new GeoPoint(-89.999, -179.999); // do not use the Projection constants, since this looks better.360 if (topRight.isOutSideWorld())361 topRight = new GeoPoint(89.999, 179.999);362 latlon[0].setText(""+bottomLeft.lat);363 latlon[1].setText(""+bottomLeft.lon);364 latlon[2].setText(""+topRight.lat);365 latlon[3].setText(""+topRight.lon);366 for (JTextField f : latlon)367 f.setCaretPosition(0);368 377 } 369 378 } -
src/org/openstreetmap/josm/actions/ExitAction.java
r30 r68 15 15 */ 16 16 public ExitAction() { 17 super("Exit", "exit", "Exit the application.", KeyEvent.VK_X , null);17 super("Exit", "exit", "Exit the application.", KeyEvent.VK_X); 18 18 } 19 19 -
src/org/openstreetmap/josm/actions/JosmAction.java
r50 r68 1 1 package org.openstreetmap.josm.actions; 2 3 import java.awt.AWTKeyStroke;4 2 5 3 import javax.swing.AbstractAction; 6 4 import javax.swing.BorderFactory; 5 import javax.swing.JComponent; 7 6 import javax.swing.JDialog; 8 7 import javax.swing.JLabel; 8 import javax.swing.KeyStroke; 9 9 import javax.swing.SwingUtilities; 10 10 … … 64 64 65 65 /** 66 * Construct the action .66 * Construct the action as menu action entry. 67 67 * 68 68 * @param name Name of the action (entry name in menu) 69 69 * @param iconName Name of the icon (without extension) 70 * @param desc Short tooltip description 71 * @param mnemonic If non-<code>null</code>, the Mnemonic in menu 72 * @param shortCut If non-<code>null</code>, the shortcut keystroke 70 * @param tooltip Short tooltip description 71 * @param mnemonic Mnemonic in the menu 73 72 */ 74 public JosmAction(String name, String iconName, String desc, Integer mnemonic, AWTKeyStroke shortCut) {73 public JosmAction(String name, String iconName, String tooltip, int mnemonic) { 75 74 super(name, ImageProvider.get(iconName)); 76 putValue(SHORT_DESCRIPTION, desc); 77 if (mnemonic != null) 78 putValue(MNEMONIC_KEY, mnemonic); 79 if (shortCut != null) 80 putValue(ACCELERATOR_KEY, shortCut); 75 putValue(SHORT_DESCRIPTION, tooltip); 76 putValue(MNEMONIC_KEY, mnemonic); 77 } 78 79 80 public JosmAction(String name, String iconName, String tooltip, String shortCutName, KeyStroke shortCut) { 81 super(name, ImageProvider.get(iconName)); 82 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+shortCutName+"</font> </html>"); 83 Main.main.panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name); 84 Main.main.panel.getActionMap().put(name, this); 81 85 } 82 86 } -
src/org/openstreetmap/josm/actions/OpenAction.java
r58 r68 41 41 */ 42 42 public OpenAction() { 43 super("Open", "open", "Open a file.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));43 super("Open", "open", "Open a file.", "Ctrl-O", KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); 44 44 } 45 45 … … 58 58 if (filename == null) 59 59 return; 60 61 openFile(filename); 62 } 63 64 /** 65 * Open the given file. 66 */ 67 public void openFile(File filename) { 60 68 String fn = filename.getName(); 61 62 69 try { 63 70 Layer layer; -
src/org/openstreetmap/josm/actions/PreferencesAction.java
r30 r68 3 3 import java.awt.event.ActionEvent; 4 4 import java.awt.event.KeyEvent; 5 6 import javax.swing.KeyStroke; 5 7 6 8 import org.openstreetmap.josm.gui.PreferenceDialog; … … 17 19 */ 18 20 public PreferencesAction() { 19 super("Preferences", "preference", "Open a preferences page for global settings.", 20 KeyEvent.VK_P, null); 21 super("Preferences", "preference", "Open a preferences page for global settings.", "F12", KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); 21 22 } 22 23 -
src/org/openstreetmap/josm/actions/RedoAction.java
r31 r68 21 21 */ 22 22 public RedoAction() { 23 super("Redo", "redo", "Redo the last undone action.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));23 super("Redo", "redo", "Redo the last undone action.", "Ctrl-Shift-Z", KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); 24 24 setEnabled(false); 25 25 } -
src/org/openstreetmap/josm/actions/SaveAction.java
r67 r68 32 32 */ 33 33 public SaveAction() { 34 super("Save", "save", "Save the current data.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));34 super("Save", "save", "Save the current data.", "Ctrl-S", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); 35 35 } 36 36 -
src/org/openstreetmap/josm/actions/UndoAction.java
r31 r68 21 21 */ 22 22 public UndoAction() { 23 super("Undo", "undo", "Undo the last action.", null, KeyStroke.getAWTKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));23 super("Undo", "undo", "Undo the last action.", "Ctrl-Z", KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK)); 24 24 setEnabled(false); 25 25 } -
src/org/openstreetmap/josm/actions/UploadAction.java
r58 r68 34 34 35 35 public UploadAction() { 36 super("Upload to OSM", "upload", "Upload all changes to the OSM server.", KeyEvent.VK_U,37 KeyStroke.get AWTKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));36 super("Upload to OSM", "upload", "Upload all changes to the OSM server.", "Ctrl-Shift-U", 37 KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); 38 38 } 39 39 -
src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java
r66 r68 46 46 */ 47 47 public AddLineSegmentAction(MapFrame mapFrame) { 48 super("Add Line Segment", "addlinesegment", "Add a line segment between two nodes.", KeyEvent.VK_G, mapFrame);48 super("Add Line Segment", "addlinesegment", "Add a line segment between two nodes.", "G", KeyEvent.VK_G, mapFrame); 49 49 } 50 50 -
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r66 r68 28 28 */ 29 29 public AddNodeAction(MapFrame mapFrame) { 30 super("Add nodes", "addnode", "Add nodes to the map.", KeyEvent.VK_N, mapFrame);30 super("Add nodes", "addnode", "Add nodes to the map.", "N", KeyEvent.VK_N, mapFrame); 31 31 } 32 32 -
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r66 r68 43 43 */ 44 44 public AddWayAction(MapFrame mapFrame, MapMode followMode) { 45 super("Add Way", "addway", "Combine selected segments to a new way.", KeyEvent.VK_W, mapFrame);45 super("Add Way", "addway", "Combine selected segments to a new way.", "W", KeyEvent.VK_W, mapFrame); 46 46 this.followMode = followMode; 47 47 } -
src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r64 r68 43 43 */ 44 44 public DeleteAction(MapFrame mapFrame) { 45 super("Delete", "delete", "Delete nodes, streets or segments.", KeyEvent.VK_D, mapFrame);45 super("Delete", "delete", "Delete nodes, streets or segments.", "Delete", KeyEvent.VK_DELETE, mapFrame); 46 46 } 47 47 -
src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r30 r68 5 5 import java.awt.event.MouseListener; 6 6 import java.awt.event.MouseMotionListener; 7 8 import javax.swing.KeyStroke; 7 9 8 10 import org.openstreetmap.josm.actions.JosmAction; … … 31 33 /** 32 34 * Construct a mapMode with the given icon and the given MapFrame 33 *34 * @param iconName The filename of the icon.35 * @param mapFrame The parent MapFrame, this MapMode belongs to.36 35 */ 37 public MapMode(String name, String iconName, String tooltip, int mnemonic, MapFrame mapFrame) {38 super(name, "mapmode/"+iconName, tooltip, mnemonic, null);36 public MapMode(String name, String iconName, String tooltip, String keyname, int keystroke, MapFrame mapFrame) { 37 super(name, "mapmode/"+iconName, tooltip, keyname, KeyStroke.getKeyStroke(keystroke, 0)); 39 38 this.mapFrame = mapFrame; 40 39 mv = mapFrame.mapView; -
src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
r40 r68 47 47 */ 48 48 public MoveAction(MapFrame mapFrame) { 49 super("Move", "move", "Move selected objects around ", KeyEvent.VK_M, mapFrame);49 super("Move", "move", "Move selected objects around.", "M", KeyEvent.VK_M, mapFrame); 50 50 } 51 51 -
src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java
r64 r68 63 63 */ 64 64 public SelectionAction(MapFrame mapFrame) { 65 super("Selection", "selection", "Select objects by dragging or clicking ", KeyEvent.VK_S, mapFrame);65 super("Selection", "selection", "Select objects by dragging or clicking.", "S", KeyEvent.VK_S, mapFrame); 66 66 this.selectionManager = new SelectionManager(this, false, mv); 67 67 } -
src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r23 r68 41 41 */ 42 42 public ZoomAction(MapFrame mapFrame) { 43 super("Zoom", "zoom", "Zoom in by dragging ", KeyEvent.VK_Z, mapFrame);43 super("Zoom", "zoom", "Zoom in by dragging.", "Z", KeyEvent.VK_Z, mapFrame); 44 44 mv = mapFrame.mapView; 45 45 selectionManager = new SelectionManager(this, true, mv); -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r66 r68 127 127 @Override 128 128 public boolean equals(Object obj) { 129 if ( getClass() != obj.getClass() || id == 0 || obj == null|| ((OsmPrimitive)obj).id == 0)129 if (obj == null || getClass() != obj.getClass() || id == 0 || ((OsmPrimitive)obj).id == 0) 130 130 return super.equals(obj); 131 131 return id == ((OsmPrimitive)obj).id; -
src/org/openstreetmap/josm/gui/MapFrame.java
r61 r68 26 26 import org.openstreetmap.josm.gui.dialogs.PropertiesDialog; 27 27 import org.openstreetmap.josm.gui.dialogs.SelectionListDialog; 28 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 28 29 import org.openstreetmap.josm.gui.layer.Layer; 29 30 … … 52 53 */ 53 54 public MapStatus statusLine; 54 /**55 * The action to open the layer list56 */57 private LayerList layerList;58 /**59 * Action to open the properties panel for the selected objects60 */61 private PropertiesDialog propertiesDialog;62 /**63 * Action to open a list of all selected objects64 */65 private SelectionListDialog selectionListDialog;66 67 55 /** 68 56 * Construct a map with a given DataSet. The set cannot be replaced after … … 113 101 114 102 toggleDialogs.setLayout(new BoxLayout(toggleDialogs, BoxLayout.Y_AXIS)); 115 toolBarActions.add(new IconToggleButton(this, layerList = new LayerList(this))); 116 toggleDialogs.add(layerList); 117 toolBarActions.add(new IconToggleButton(this, propertiesDialog = new PropertiesDialog(this))); 118 toggleDialogs.add(propertiesDialog); 119 toolBarActions.add(new IconToggleButton(this, selectionListDialog = new SelectionListDialog(this))); 120 toggleDialogs.add(selectionListDialog); 121 103 addIconToggle(toggleDialogs, new LayerList(this)); 104 addIconToggle(toggleDialogs, new PropertiesDialog(this)); 105 addIconToggle(toggleDialogs, new SelectionListDialog(this)); 122 106 123 107 // status line below the map 124 108 statusLine = new MapStatus(this); 109 } 110 111 112 private void addIconToggle(JPanel toggleDialogs, ToggleDialog dlg) { 113 toolBarActions.add(new IconToggleButton(this, dlg.action)); 114 toggleDialogs.add(dlg); 125 115 } 126 116 -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r44 r68 74 74 */ 75 75 public LayerList(MapFrame mapFrame) { 76 super("Layers", "List of all layers", "layerlist", KeyEvent.VK_L, "Open a list of all loaded layers.");76 super("Layers", "List of all layers", "layerlist", "Open a list of all loaded layers.", "L", KeyEvent.VK_L); 77 77 setPreferredSize(new Dimension(320,100)); 78 78 add(new JScrollPane(layers), BorderLayout.CENTER); -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r66 r68 213 213 */ 214 214 public PropertiesDialog(MapFrame mapFrame) { 215 super("Properties", "Properties Dialog", "properties", KeyEvent.VK_P, "Property for selected objects.");215 super("Properties", "Properties Dialog", "properties", "Property for selected objects.", "P", KeyEvent.VK_P); 216 216 mv = mapFrame.mapView; 217 217 -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r66 r68 51 51 */ 52 52 public SelectionListDialog(MapFrame mapFrame) { 53 super("Current Selection", "Selection List", "selectionlist", KeyEvent.VK_E, "Open a selection list window.");53 super("Current Selection", "Selection List", "selectionlist", "Open a selection list window.", "E", KeyEvent.VK_E); 54 54 setPreferredSize(new Dimension(320,150)); 55 55 displaylist.setCellRenderer(new OsmPrimitivRenderer()); … … 107 107 if (colon == -1) 108 108 return key.indexOf(search) != -1 || value.indexOf(search) != -1; 109 return key.equals(search.substring(0, colon)) && value.indexOf(search.substring(colon+1)) != -1; 109 String searchKey = search.substring(0, colon); 110 String searchValue = search.substring(colon+1); 111 if (searchKey.equals("type") && (searchValue.equals("segment")||searchValue.equals("way")||searchValue.equals("node"))) 112 return true; 113 return key.equals(searchKey) && value.indexOf(searchValue) != -1; 110 114 } 111 115 }); -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r30 r68 3 3 import java.awt.BorderLayout; 4 4 import java.awt.event.ActionEvent; 5 import java.util.HashMap; 6 import java.util.Map; 5 import java.awt.event.KeyEvent; 7 6 8 7 import javax.swing.AbstractButton; 9 import javax.swing.Action;10 8 import javax.swing.BorderFactory; 11 9 import javax.swing.JLabel; 12 10 import javax.swing.JPanel; 11 import javax.swing.KeyStroke; 13 12 14 import org.openstreetmap.josm. gui.ImageProvider;13 import org.openstreetmap.josm.actions.JosmAction; 15 14 16 15 /** … … 20 19 * @author imi 21 20 */ 22 public class ToggleDialog extends JPanel implements Action{21 public class ToggleDialog extends JPanel { 23 22 23 /** 24 * The action to toggle this dialog. 25 */ 26 public JosmAction action; 27 24 28 /** 25 29 * Create a new ToggleDialog. 26 30 * @param title The title of the dialog. 27 31 */ 28 public ToggleDialog(String title, String name, String iconName, int mnemonic, String tooltip) { 29 putValue(SMALL_ICON, ImageProvider.get("dialogs", iconName)); 30 putValue(NAME, name); 31 putValue(MNEMONIC_KEY, mnemonic); 32 putValue(SHORT_DESCRIPTION, tooltip); 32 public ToggleDialog(String title, String name, String iconName, String tooltip, String shortCutName, int shortCut) { 33 action = new JosmAction(name, "dialogs/"+iconName, tooltip, "Alt-"+shortCutName, KeyStroke.getKeyStroke(shortCut, KeyEvent.ALT_MASK)){ 34 public void actionPerformed(ActionEvent e) { 35 boolean show = !isVisible(); 36 if (e.getSource() instanceof AbstractButton) 37 show = ((AbstractButton)e.getSource()).isSelected(); 38 setVisible(show); 39 } 40 }; 33 41 34 42 setLayout(new BorderLayout()); … … 37 45 setBorder(BorderFactory.createEtchedBorder()); 38 46 } 39 40 /**41 * Show this if not shown. Else request the focus.42 */43 public void actionPerformed(ActionEvent e) {44 boolean show = !isVisible();45 if (e.getSource() instanceof AbstractButton)46 show = ((AbstractButton)e.getSource()).isSelected();47 setVisible(show);48 }49 50 // to satisfy Action interface51 52 private Map<String, Object> properties = new HashMap<String, Object>();53 public Object getValue(String key) {54 return properties.get(key);55 }56 public void putValue(String key, Object value) {57 properties.put(key, value);58 }59 47 }
Note:
See TracChangeset
for help on using the changeset viewer.