- Timestamp:
- 2006-11-30T00:00:37+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r169 r172 23 23 import javax.swing.JOptionPane; 24 24 import javax.swing.JPanel; 25 import javax.swing.JToolBar;26 25 import javax.swing.KeyStroke; 27 26 import javax.swing.UIManager; … … 44 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 45 44 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 45 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 46 46 import org.openstreetmap.josm.plugins.PluginException; 47 47 import org.openstreetmap.josm.plugins.PluginInformation; … … 88 88 */ 89 89 public static PleaseWaitDialog pleaseWaitDlg; 90 91 /** 92 * True, when in applet mode 93 */ 94 public static boolean applet = false; 95 96 /** 97 * The toolbar preference control to register new actions. 98 */ 99 public static ToolbarPreferences toolbar = new ToolbarPreferences(); 90 100 91 101 … … 163 173 164 174 // creating toolbar 165 final JToolBar toolBar = new JToolBar(); 166 toolBar.setFloatable(false); 167 toolBar.add(menu.download); 168 toolBar.add(menu.upload); 169 toolBar.addSeparator(); 170 toolBar.add(menu.newAction); 171 toolBar.add(menu.open); 172 toolBar.add(menu.save); 173 toolBar.add(menu.gpxExport); 174 toolBar.addSeparator(); 175 toolBar.add(menu.undo); 176 toolBar.add(menu.redo); 177 toolBar.addSeparator(); 178 toolBar.add(menu.preferences); 179 contentPane.add(toolBar, BorderLayout.NORTH); 175 contentPane.add(toolbar.control, BorderLayout.NORTH); 180 176 181 177 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), "Help"); 182 178 contentPane.getActionMap().put("Help", menu.help); 183 179 184 contentPane.updateUI(); 180 toolbar.refreshToolbarControl(); 181 182 toolbar.control.updateUI(); 183 contentPane.updateUI(); 185 184 } 186 185 … … 247 246 248 247 protected static Rectangle bounds; 249 250 248 251 249 private final CommandQueueListener redoUndoListener = new CommandQueueListener(){ … … 346 344 return false; 347 345 } 348 346 349 347 private static void downloadFromParamString(final boolean rawGps, String s) { 350 348 if (s.startsWith("http:")) { -
src/org/openstreetmap/josm/actions/DownloadAction.java
r158 r172 35 35 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 36 36 import org.openstreetmap.josm.data.Bounds; 37 import org.openstreetmap.josm.data.Preferences; 37 38 import org.openstreetmap.josm.data.coor.LatLon; 38 39 import org.openstreetmap.josm.gui.BookmarkList; 39 40 import org.openstreetmap.josm.gui.MapView; 40 41 import org.openstreetmap.josm.gui.WorldChooser; 41 import org.openstreetmap.josm.gui.BookmarkList.Bookmark;42 42 import org.openstreetmap.josm.tools.GBC; 43 43 … … 184 184 bookmarks.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ 185 185 public void valueChanged(ListSelectionEvent e) { 186 Bookmark b = (Bookmark)bookmarks.getSelectedValue(); 186 Preferences.Bookmark b = (Preferences.Bookmark)bookmarks.getSelectedValue(); 187 187 for (int i = 0; i < 4; ++i) { 188 188 latlon[i].setText(b == null ? "" : ""+b.latlon[i]); … … 199 199 add.addActionListener(new ActionListener(){ 200 200 public void actionPerformed(ActionEvent e) { 201 Bookmark b = readBookmark(); 201 Preferences.Bookmark b = readBookmark(); 202 202 if (b == null) { 203 203 JOptionPane.showMessageDialog(Main.parent, tr("Please enter the desired coordinates first.")); … … 232 232 233 233 // Finally: the dialog 234 Bookmark b; 234 Preferences.Bookmark b; 235 235 boolean anySelected = false; 236 236 do { … … 278 278 * checkbox. 279 279 */ 280 Bookmark readBookmark() { 280 Preferences.Bookmark readBookmark() { 281 281 try { 282 Bookmark b = new Bookmark(); 282 Preferences.Bookmark b = new Preferences.Bookmark(); 283 283 for (int i = 0; i < 4; ++i) { 284 284 if (latlon[i].getText().equals("")) -
src/org/openstreetmap/josm/actions/JosmAction.java
r155 r172 28 28 putValue(SHORT_DESCRIPTION, tooltip); 29 29 putValue(MNEMONIC_KEY, mnemonic); 30 putValue("toolbar", iconName); 31 Main.toolbar.register(this); 30 32 } 31 33 … … 37 39 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(shortCut, modifier), name); 38 40 Main.contentPane.getActionMap().put(name, this); 41 putValue("toolbar", iconName); 42 Main.toolbar.register(this); 39 43 } 40 44 -
src/org/openstreetmap/josm/actions/NewAction.java
r169 r172 4 4 5 5 import java.awt.event.ActionEvent; 6 import java.awt.event.InputEvent; 6 7 import java.awt.event.KeyEvent; 7 8 … … 10 11 public class NewAction extends JosmAction { 11 12 12 13 13 public NewAction() { 14 super(tr("New"), "new", tr("Create a new map."), KeyEvent.VK_N); 14 super(tr("New"), "new", tr("Create a new map."), KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK); 15 15 } 16 16 -
src/org/openstreetmap/josm/actions/RenameLayerAction.java
r138 r172 43 43 panel.add(name); 44 44 JCheckBox filerename = new JCheckBox(tr("Also rename the file")); 45 panel.add(filerename); 46 filerename.setEnabled(file != null); 45 if (Main.applet) { 46 filerename.setEnabled(false); 47 filerename.setSelected(false); 48 } else { 49 panel.add(filerename); 50 filerename.setEnabled(file != null); 51 } 47 52 if (filerename.isEnabled()) 48 53 filerename.setSelected(Main.pref.getBoolean("layer.rename-file", true)); -
src/org/openstreetmap/josm/data/Preferences.java
r171 r172 5 5 import java.awt.Color; 6 6 import java.io.BufferedReader; 7 import java.io.File; 7 8 import java.io.FileReader; 8 9 import java.io.FileWriter; … … 10 11 import java.io.PrintWriter; 11 12 import java.util.ArrayList; 13 import java.util.Collection; 14 import java.util.LinkedList; 12 15 import java.util.Map; 13 16 import java.util.SortedMap; 17 import java.util.StringTokenizer; 14 18 import java.util.TreeMap; 15 19 import java.util.Map.Entry; 16 20 21 import org.openstreetmap.josm.Main; 17 22 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 18 23 import org.openstreetmap.josm.tools.ColorHelper; … … 33 38 } 34 39 40 /** 41 * Class holding one bookmarkentry. 42 * @author imi 43 */ 44 public static class Bookmark { 45 public String name; 46 public double[] latlon = new double[4]; // minlat, minlon, maxlat, maxlon 47 @Override public String toString() { 48 return name; 49 } 50 } 51 35 52 public final ArrayList<PreferenceChangedListener> listener = new ArrayList<PreferenceChangedListener>(); 36 53 … … 90 107 } 91 108 109 92 110 private final void firePreferenceChanged(final String key, final String value) { 93 111 for (final PreferenceChangedListener l : listener) 94 112 l.preferenceChanged(key, value); 95 113 } 96 97 114 98 115 /** … … 148 165 properties.put("color.scale", ColorHelper.color2html(Color.white)); 149 166 } 167 168 public Collection<Bookmark> loadBookmarks() throws IOException { 169 File bookmarkFile = new File(getPreferencesDir()+"bookmarks"); 170 if (!bookmarkFile.exists()) 171 bookmarkFile.createNewFile(); 172 BufferedReader in = new BufferedReader(new FileReader(bookmarkFile)); 173 174 Collection<Bookmark> bookmarks = new LinkedList<Bookmark>(); 175 for (String line = in.readLine(); line != null; line = in.readLine()) { 176 StringTokenizer st = new StringTokenizer(line, ","); 177 if (st.countTokens() < 5) 178 continue; 179 Bookmark b = new Bookmark(); 180 b.name = st.nextToken(); 181 try { 182 for (int i = 0; i < b.latlon.length; ++i) 183 b.latlon[i] = Double.parseDouble(st.nextToken()); 184 bookmarks.add(b); 185 } catch (NumberFormatException x) { 186 // line not parsed 187 } 188 } 189 in.close(); 190 return bookmarks; 191 } 192 193 public void saveBookmarks(Collection<Bookmark> bookmarks) throws IOException { 194 File bookmarkFile = new File(Main.pref.getPreferencesDir()+"bookmarks"); 195 if (!bookmarkFile.exists()) 196 bookmarkFile.createNewFile(); 197 PrintWriter out = new PrintWriter(new FileWriter(bookmarkFile)); 198 for (Bookmark b : bookmarks) { 199 b.name.replace(',', '_'); 200 out.print(b.name+","); 201 for (int i = 0; i < b.latlon.length; ++i) 202 out.print(b.latlon[i]+(i<b.latlon.length-1?",":"")); 203 out.println(); 204 } 205 out.close(); 206 } 150 207 } -
src/org/openstreetmap/josm/data/ServerSidePreferences.java
r101 r172 2 2 3 3 import java.net.URL; 4 import java.util.Collection; 5 import java.util.Collections; 4 6 5 7 /** … … 17 19 this.serverUrl = serverUrl; 18 20 this.userName = userName; 21 load(); 19 22 } 20 23 … … 29 32 @Override protected void save() { 30 33 } 34 35 @Override public Collection<Bookmark> loadBookmarks() { 36 return Collections.<Bookmark>emptyList(); 37 } 38 39 @Override public void saveBookmarks(Collection<Bookmark> bookmarks) { 40 } 31 41 } -
src/org/openstreetmap/josm/gui/BookmarkList.java
r161 r172 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.io.BufferedReader;6 import java.io.File;7 import java.io.FileReader;8 import java.io.FileWriter;9 5 import java.io.IOException; 10 import java. io.PrintWriter;11 import java.util. StringTokenizer;6 import java.util.Collection; 7 import java.util.LinkedList; 12 8 13 9 import javax.swing.DefaultListModel; … … 16 12 17 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.Preferences; 18 15 19 16 /** … … 22 19 */ 23 20 public class BookmarkList extends JList { 24 25 /**26 * Class holding one bookmarkentry.27 * @author imi28 */29 public static class Bookmark {30 public String name;31 public double[] latlon = new double[4]; // minlat, minlon, maxlat, maxlon32 @Override public String toString() {33 return name;34 }35 }36 21 37 22 /** … … 50 35 DefaultListModel model = (DefaultListModel)getModel(); 51 36 model.removeAllElements(); 52 File bookmarkFile = new File(Main.pref.getPreferencesDir()+"bookmarks");53 37 try { 54 if (!bookmarkFile.exists()) 55 bookmarkFile.createNewFile(); 56 BufferedReader in = new BufferedReader(new FileReader(bookmarkFile)); 57 58 for (String line = in.readLine(); line != null; line = in.readLine()) { 59 StringTokenizer st = new StringTokenizer(line, ","); 60 if (st.countTokens() < 5) 61 continue; 62 Bookmark b = new Bookmark(); 63 b.name = st.nextToken(); 64 try { 65 for (int i = 0; i < b.latlon.length; ++i) 66 b.latlon[i] = Double.parseDouble(st.nextToken()); 67 model.addElement(b); 68 } catch (NumberFormatException x) { 69 // line not parsed 70 } 71 } 72 in.close(); 38 for (Preferences.Bookmark b : Main.pref.loadBookmarks()) 39 model.addElement(b); 73 40 } catch (IOException e) { 41 e.printStackTrace(); 74 42 JOptionPane.showMessageDialog(Main.parent, tr("Could not read bookmarks.")+"\n"+e.getMessage()); 75 43 } … … 80 48 */ 81 49 public void save() { 82 File bookmarkFile = new File(Main.pref.getPreferencesDir()+"bookmarks");83 50 try { 84 if (!bookmarkFile.exists()) 85 bookmarkFile.createNewFile(); 86 PrintWriter out = new PrintWriter(new FileWriter(bookmarkFile)); 87 DefaultListModel m = (DefaultListModel)getModel(); 88 for (Object o : m.toArray()) { 89 Bookmark b = (Bookmark)o; 90 b.name.replace(',', '_'); 91 out.print(b.name+","); 92 for (int i = 0; i < b.latlon.length; ++i) 93 out.print(b.latlon[i]+(i<b.latlon.length-1?",":"")); 94 out.println(); 95 } 96 out.close(); 51 Collection<Preferences.Bookmark> bookmarks = new LinkedList<Preferences.Bookmark>(); 52 for (Object o : ((DefaultListModel)getModel()).toArray()) 53 bookmarks.add((Preferences.Bookmark)o); 54 Main.pref.saveBookmarks(bookmarks); 97 55 } catch (IOException e) { 98 56 JOptionPane.showMessageDialog(Main.parent,tr("Could not write bookmark.")+"\n"+e.getMessage()); -
src/org/openstreetmap/josm/gui/MainApplet.java
r159 r172 40 40 {"reset-preferences", tr("any"),tr("If specified, reset the configuration instead of reading it.")} 41 41 }; 42 42 43 43 private Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); 44 44 … … 75 75 } 76 76 77 Main.applet = true; 77 78 Main.pref = new ServerSidePreferences(getCodeBase(), username); 78 79 79 80 Main.preConstructorInit(args); 80 81 Main.parent = this; 81 82 new MainCaller().postConstructorProcessCmdLine(args); 82 } 83 84 MainMenu m = Main.main.menu; // shortcut 85 86 // remove offending stuff from JOSM (that would break the SecurityManager) 87 m.remove(m.fileMenu); 88 m.open.setEnabled(false); 89 m.exit.setEnabled(false); 90 m.save.setEnabled(false); 91 m.saveAs.setEnabled(false); 92 m.gpxExport.setEnabled(false); 93 } 83 94 84 95 private Collection<String> readParameter(String s, Collection<String> v) { -
src/org/openstreetmap/josm/gui/MapFrame.java
r167 r172 57 57 * The status line below the map 58 58 */ 59 p ublicMapStatus statusLine;59 private MapStatus statusLine; 60 60 61 61 public ConflictDialog conflictDialog; … … 126 126 127 127 // status line below the map 128 statusLine = new MapStatus(this); 128 if (!Main.applet) 129 statusLine = new MapStatus(this); 129 130 } 130 131 … … 189 190 panel.add(this, BorderLayout.CENTER); 190 191 panel.add(toolBarActions, BorderLayout.WEST); 191 panel.add(statusLine, BorderLayout.SOUTH); 192 if (statusLine != null) 193 panel.add(statusLine, BorderLayout.SOUTH); 192 194 } 193 195 } -
src/org/openstreetmap/josm/gui/MapStatus.java
r155 r172 232 232 // Listen to keyboard/mouse events for pressing/releasing alt key and 233 233 // inform the collector. 234 235 236 237 238 239 240 241 242 243 234 Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){ 235 public void eventDispatched(AWTEvent event) { 236 synchronized (collector) { 237 mouseState.modifiers = ((InputEvent)event).getModifiersEx(); 238 if (event instanceof MouseEvent) 239 mouseState.mousePos = ((MouseEvent)event).getPoint(); 240 collector.notify(); 241 } 242 } 243 }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); 244 244 } 245 245 -
src/org/openstreetmap/josm/gui/WorldChooser.java
r155 r172 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.Preferences; 22 import org.openstreetmap.josm.data.coor.EastNorth; 21 23 import org.openstreetmap.josm.data.coor.LatLon; 22 import org.openstreetmap.josm.data.coor.EastNorth;23 24 import org.openstreetmap.josm.data.projection.Projection; 24 import org.openstreetmap.josm.gui.BookmarkList.Bookmark;25 25 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; 26 26 … … 136 136 list.addListSelectionListener(new ListSelectionListener(){ 137 137 public void valueChanged(ListSelectionEvent e) { 138 Bookmark b = (Bookmark)list.getSelectedValue(); 138 Preferences.Bookmark b = (Preferences.Bookmark)list.getSelectedValue(); 139 139 if (b != null) { 140 140 markerMin = getProjection().latlon2eastNorth(new LatLon(b.latlon[0],b.latlon[1])); -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r167 r172 315 315 316 316 @Override public Component[] getMenuEntries() { 317 if (Main.applet) { 318 return new Component[]{ 319 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 320 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 321 new JSeparator(), 322 new JMenuItem(new RenameLayerAction(associatedFile, this)), 323 new JSeparator(), 324 new JMenuItem(new LayerListPopup.InfoAction(this))}; 325 } 317 326 return new Component[]{ 318 327 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), -
src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r155 r172 56 56 public ConvertToDataLayerAction() { 57 57 super(tr("Convert to data layer"), ImageProvider.get("converttoosm")); 58 58 } 59 59 public void actionPerformed(ActionEvent e) { 60 60 DataSet ds = new DataSet(); … … 76 76 Main.main.addLayer(new OsmDataLayer(ds, tr("Data Layer"), null)); 77 77 Main.main.removeLayer(RawGpsLayer.this); 78 79 78 } 79 } 80 80 81 81 public static class GpsPoint { … … 89 89 } 90 90 } 91 91 92 92 /** 93 93 * A list of ways which containing a list of points. … … 109 109 } 110 110 }); 111 111 } 112 112 }); 113 113 } … … 130 130 g.setColor(Color.GRAY); 131 131 Point old = null; 132 132 133 133 boolean force = Main.pref.getBoolean("draw.rawgps.lines.force"); 134 134 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); … … 240 240 } 241 241 }); 242 242 243 243 JMenuItem tagimage = new JMenuItem(tr("Import images"), ImageProvider.get("tagimages")); 244 244 tagimage.addActionListener(new ActionListener(){ … … 264 264 Main.pref.put("tagimages.lastdirectory", fc.getCurrentDirectory().getPath()); 265 265 GeoImageLayer.create(files, RawGpsLayer.this); 266 266 } 267 267 268 268 private void addRecursiveFiles(LinkedList<File> files, File[] sel) { … … 273 273 files.add(f); 274 274 } 275 275 } 276 276 }); 277 277 278 if (Main.applet) 279 return new Component[]{ 280 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 281 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 282 new JSeparator(), 283 color, 284 line, 285 new JMenuItem(new ConvertToDataLayerAction()), 286 new JSeparator(), 287 new JMenuItem(new RenameLayerAction(associatedFile, this)), 288 new JSeparator(), 289 new JMenuItem(new LayerListPopup.InfoAction(this))}; 278 290 return new Component[]{ 279 291 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), … … 289 301 new JSeparator(), 290 302 new JMenuItem(new LayerListPopup.InfoAction(this))}; 291 303 } 292 304 293 305 public void preferenceChanged(String key, String newValue) { -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r168 r172 8 8 import java.awt.event.ActionListener; 9 9 import java.util.Collection; 10 import java.util.Iterator; 10 11 import java.util.LinkedList; 11 12 … … 84 85 public PreferenceDialog() { 85 86 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 86 for (PreferenceSetting setting : settings) 87 setting.addGui(this); 87 for (Iterator<PreferenceSetting> it = settings.iterator(); it.hasNext();) { 88 try { 89 it.next().addGui(this); 90 } catch (SecurityException e) { 91 it.remove(); 92 } 93 } 88 94 } 89 95 … … 98 104 settings.add(new AnnotationPresetPreference()); 99 105 settings.add(new PluginPreference()); 106 settings.add(Main.toolbar); 100 107 101 108 for (PluginProxy plugin : Main.plugins) { -
src/org/openstreetmap/josm/io/OsmConnection.java
r153 r172 37 37 protected HttpURLConnection activeConnection; 38 38 39 private static OsmAuth authentication; 39 private static OsmAuth authentication = new OsmAuth(); 40 40 /** 41 41 * Initialize the http defaults and the authenticator. 42 42 */ 43 43 static { 44 HttpURLConnection.setFollowRedirects(true); 45 Authenticator.setDefault(authentication = new OsmAuth()); 44 //TODO: refactor this crap (maybe just insert the damn auth http-header by yourself) 45 try { 46 HttpURLConnection.setFollowRedirects(true); 47 Authenticator.setDefault(authentication); 48 } catch (SecurityException e) { 49 } 46 50 } 47 51 -
src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r153 r172 66 66 if (!f.exists()) 67 67 f = new File("bin/org/openstreetmap/josm/Main.class"); 68 if (!f.exists()) 69 f = new File("build/org/openstreetmap/josm/Main.class"); 68 70 if (f.exists()) { 69 71 DateFormat sdf = SimpleDateFormat.getDateTimeInstance();
Note:
See TracChangeset
for help on using the changeset viewer.