- Timestamp:
- 2006-07-21T00:31:54+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r116 r119 7 7 import java.awt.Rectangle; 8 8 import java.awt.Toolkit; 9 import java.awt.event.ActionEvent; 9 10 import java.io.File; 10 import java.io.IOException;11 11 import java.net.URI; 12 12 import java.net.URISyntaxException; … … 19 19 import java.util.regex.Pattern; 20 20 21 import javax.swing.AbstractAction; 21 22 import javax.swing.Action; 22 23 import javax.swing.JMenu; … … 46 47 import org.openstreetmap.josm.gui.MapFrame; 47 48 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 49 import org.openstreetmap.josm.gui.dialogs.AnnotationTester; 48 50 import org.openstreetmap.josm.gui.dialogs.SelectionListDialog; 49 51 import org.openstreetmap.josm.gui.layer.Layer; … … 128 130 } 129 131 } 130 132 131 133 /** 132 134 * Remove the specified layer from the map. If it is the last layer, remove the map as well. … … 142 144 main = this; 143 145 contentPane.add(panel, BorderLayout.CENTER); 146 147 final Action annotationTesterAction = new AbstractAction(){ 148 public void actionPerformed(ActionEvent e) { 149 String[] args = pref.get("annotation.sources").split(";"); 150 new AnnotationTester(args); 151 } 152 }; 153 annotationTesterAction.putValue(Action.NAME, "Annotation Preset Tester"); 154 annotationTesterAction.putValue(Action.SMALL_ICON, ImageProvider.get("annotation-tester")); 144 155 145 156 final Action uploadAction = new UploadAction(); … … 171 182 mainMenu.add(layerMenu); 172 183 layerMenu.setVisible(false); 173 184 174 185 final JMenu editMenu = new JMenu(tr("Edit")); 175 186 editMenu.setMnemonic('E'); … … 183 194 final JMenu helpMenu = new JMenu(tr("Help")); 184 195 helpMenu.setMnemonic('H'); 196 helpMenu.add(annotationTesterAction); 197 helpMenu.addSeparator(); 185 198 helpMenu.add(aboutAction); 186 199 mainMenu.add(helpMenu); … … 263 276 */ 264 277 public static void preConstructorInit(Map<String, Collection<String>> args) { 265 // load preferences266 String errMsg = null;267 278 try { 268 if (args.containsKey("reset-preferences")) { 269 Main.pref.resetToDefault(); 270 } else { 271 Main.pref.load(); 272 } 273 } catch (final IOException e1) { 274 e1.printStackTrace(); 275 errMsg = tr("Preferences could not be loaded. Write default preference file to \"{0}\".", 276 pref.getPreferencesDir() + "preferences"); 277 Main.pref.resetToDefault(); 278 } 279 280 try { 281 Main.pref.upgrade(Integer.parseInt(AboutAction.version)); 282 } catch (NumberFormatException e1) { 283 } 284 285 286 if (errMsg != null) 287 JOptionPane.showMessageDialog(null, errMsg); 279 Main.pref.upgrade(Integer.parseInt(AboutAction.version)); 280 } catch (NumberFormatException e1) { 281 } 288 282 289 283 try { -
src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r113 r119 70 70 text += " "+tr(v.className)+" "+v.name; 71 71 } else 72 text += objects.size()+" "+trn("object","objects",objects.size());72 text += " "+objects.size()+" "+trn("object","objects",objects.size()); 73 73 DefaultMutableTreeNode root = new DefaultMutableTreeNode(new JLabel(text, ImageProvider.get("data", "key"), JLabel.HORIZONTAL)); 74 74 if (objects.size() == 1) -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r102 r119 153 153 } 154 154 } 155 if (my == null) 155 if (my == null) { 156 // Add the way and replace any incomplete segments that we already have 156 157 ds.ways.add(other); 157 else { 158 for (Segment s : other.segments) { 159 if (s.incomplete) { 160 for (Segment ourSegment : ds.segments) { 161 if (ourSegment.id == s.id) { 162 mergedSegments.put(s, ourSegment); 163 break; 164 } 165 } 166 } 167 } 168 } else { 158 169 mergeCommon(my, other); 159 170 if (my.modified && !other.modified) … … 213 224 t.segments.addAll(newSegments); 214 225 } 215 for (Segment ls : t.segments) {226 for (Segment ls : t.segments) 216 227 fixSegment(ls); 217 }218 228 } 219 229 -
src/org/openstreetmap/josm/gui/MainApplication.java
r115 r119 8 8 import java.awt.event.WindowEvent; 9 9 import java.io.File; 10 import java.io.IOException; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; … … 87 88 } 88 89 89 // very first thing to do is to setup the locale 90 // get the preferences. 91 final File prefDir = new File(Main.pref.getPreferencesDir()); 92 if (prefDir.exists() && !prefDir.isDirectory()) { 93 JOptionPane.showMessageDialog(null, "Cannot open preferences directory: "+Main.pref.getPreferencesDir()); 94 return; 95 } 96 if (!prefDir.exists()) 97 prefDir.mkdirs(); 98 try { 99 if (args.containsKey("reset-preferences")) { 100 Main.pref.resetToDefault(); 101 } else { 102 Main.pref.load(); 103 } 104 } catch (final IOException e1) { 105 e1.printStackTrace(); 106 JOptionPane.showMessageDialog(null, "Preferences could not be loaded. Write default preference file to "+pref.getPreferencesDir()+"preferences"); 107 Main.pref.resetToDefault(); 108 } 109 110 // setup the locale 90 111 if (args.containsKey("language") && !args.get("language").isEmpty() && args.get("language").iterator().next().length() >= 2) { 91 112 String s = args.get("language").iterator().next(); … … 98 119 l = new Locale(s.substring(0,2), s.substring(3,5), s.substring(6)); 99 120 Locale.setDefault(l); 121 } else if (!Main.pref.get("language").equals("")) { 122 String lang = Main.pref.get("language"); 123 for (Locale l : Locale.getAvailableLocales()) { 124 if (l.toString().equals(lang)) { 125 Locale.setDefault(l); 126 break; 127 } 128 } 100 129 } 101 130 131 // Locale is set. From now on, tr(), trn() and trc() may be called. 132 102 133 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { 103 134 System.out.println(tr("Java OpenStreetMap Editor")+"\n\n"+ … … 127 158 } 128 159 129 final File prefDir = new File(Main.pref.getPreferencesDir());130 if (prefDir.exists() && !prefDir.isDirectory()) {131 JOptionPane.showMessageDialog(null, tr("Cannot open preferences directory: {0}",Main.pref.getPreferencesDir()));132 return;133 }134 if (!prefDir.exists())135 prefDir.mkdirs();136 137 160 preConstructorInit(args); 138 161 JFrame mainFrame = new JFrame(tr("Java Open Street Map - Editor")); -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r118 r119 10 10 import java.awt.event.ActionEvent; 11 11 import java.awt.event.ActionListener; 12 import java.util.Locale; 12 13 import java.util.Map; 13 14 import java.util.StringTokenizer; … … 69 70 public void actionPerformed(ActionEvent e) { 70 71 Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 72 Main.pref.put("language", languages.getSelectedItem().toString()); 71 73 Main.pref.put("projection", projectionCombo.getSelectedItem().getClass().getName()); 72 74 Main.pref.put("osm-server.url", osmDataServer.getText()); … … 94 96 String name = (String)colors.getValueAt(i, 0); 95 97 Color col = (Color)colors.getValueAt(i, 1); 96 Main.pref.put("color."+ tr(name), ColorHelper.color2html(col));98 Main.pref.put("color."+name, ColorHelper.color2html(col)); 97 99 } 98 100 … … 130 132 */ 131 133 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 134 private JComboBox languages = new JComboBox(new Locale[]{Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH}); 132 135 /** 133 136 * The main tab panel. … … 202 205 requiresRestart = true; 203 206 } 207 }); 208 209 // language 210 String lang = Main.pref.get("language"); 211 for (int i = 0; i < languages.getItemCount(); ++i) { 212 if (languages.getItemAt(i).toString().equals(lang)) { 213 languages.setSelectedIndex(i); 214 break; 215 } 216 } 217 languages.setRenderer(new DefaultListCellRenderer(){ 218 @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 219 return super.getListCellRendererComponent(list, ((Locale)value).getDisplayName(), index, isSelected, cellHasFocus); 220 } 204 221 }); 205 222 … … 359 376 display.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 360 377 display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 378 display.add(new JLabel(tr("Language")), GBC.std()); 379 display.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 380 display.add(languages, GBC.eol().fill(GBC.HORIZONTAL)); 361 381 display.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0)); 362 382 display.add(forceRawGpsLines, GBC.eop().insets(40,0,0,0)); -
src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r104 r119 5 5 import java.awt.BorderLayout; 6 6 import java.awt.Component; 7 import java.awt.Dimension;8 7 import java.awt.event.KeyEvent; 9 8 import java.util.Collection; … … 30 29 31 30 public CommandStackDialog(final MapFrame mapFrame) { 32 super(tr("Command Stack"), "commandstack", tr("Open a list of all commands (undo buffer)."), KeyEvent.VK_C); 33 setPreferredSize(new Dimension(320,100)); 31 super(tr("Command Stack"), "commandstack", tr("Open a list of all commands (undo buffer)."), KeyEvent.VK_C, 100); 34 32 mapFrame.mapView.addLayerChangeListener(new LayerChangeListener(){ 35 33 public void activeLayerChange(Layer oldLayer, Layer newLayer) {} -
src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r104 r119 49 49 50 50 public ConflictDialog() { 51 super(tr("Conflict"), "conflict", tr("Merging conflicts."), KeyEvent.VK_C );51 super(tr("Conflict"), "conflict", tr("Merging conflicts."), KeyEvent.VK_C, 100); 52 52 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 53 53 displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r104 r119 5 5 import java.awt.BorderLayout; 6 6 import java.awt.Component; 7 import java.awt.Dimension;8 7 import java.awt.GridLayout; 9 8 import java.awt.event.ActionEvent; … … 117 116 */ 118 117 public LayerList(MapFrame mapFrame) { 119 super(tr("Layers"), "layerlist", tr("Open a list of all loaded layers."), KeyEvent.VK_L );118 super(tr("Layers"), "layerlist", tr("Open a list of all loaded layers."), KeyEvent.VK_L, 100); 120 119 instance = new JList(model); 121 setPreferredSize(new Dimension(320,100));122 120 add(new JScrollPane(instance), BorderLayout.CENTER); 123 121 instance.setBackground(UIManager.getColor("Button.background")); -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r116 r119 7 7 import java.awt.BorderLayout; 8 8 import java.awt.Component; 9 import java.awt.Dimension;10 9 import java.awt.Font; 11 10 import java.awt.GridLayout; … … 209 208 */ 210 209 public PropertiesDialog(MapFrame mapFrame) { 211 super(tr("Properties"), "propertiesdialog", tr("Property for selected objects."), KeyEvent.VK_P); 212 setPreferredSize(new Dimension(320,150)); 213 210 super(tr("Properties"), "propertiesdialog", tr("Property for selected objects."), KeyEvent.VK_P, 150); 211 214 212 Vector<AnnotationPreset> allPresets = new Vector<AnnotationPreset>(); 215 213 String allAnnotations = Main.pref.get("annotation.sources"); … … 219 217 String source = st.nextToken(); 220 218 try { 221 222 223 224 225 226 227 228 229 230 231 232 233 234 219 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 220 in = new URL(source).openStream(); 221 else if (source.startsWith("resource://")) 222 in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 223 else 224 in = new FileInputStream(source); 225 allPresets.addAll(AnnotationPreset.readAll(in)); 226 } catch (IOException e) { 227 e.printStackTrace(); 228 JOptionPane.showMessageDialog(Main.parent, tr("Could not read annotation preset source: {0}",source)); 229 } catch (SAXException e) { 230 e.printStackTrace(); 231 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing {0}: ", source)+e.getMessage()); 232 } 235 233 } 236 234 if (allPresets.size() > 0) { … … 256 254 } 257 255 annotationPresets.setSelectedIndex(0); 258 256 } 259 257 }); 260 258 -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r115 r119 4 4 5 5 import java.awt.BorderLayout; 6 import java.awt.Dimension;7 6 import java.awt.GridBagLayout; 8 7 import java.awt.GridLayout; … … 63 62 private OsmIdReader idReader = new OsmIdReader(); 64 63 public SelectionWebsiteLoader(String urlStr, SearchMode mode) { 65 66 67 64 super(tr("Load Selection")); 65 this.mode = mode; 66 URL u = null; 68 67 try {u = new URL(urlStr);} catch (MalformedURLException e) {} 69 70 68 this.url = u; 69 } 71 70 @Override protected void realRun() { 72 71 currentAction.setText(tr("Contact {0}...", url.getHost())); 73 72 sel = mode != SearchMode.remove ? new LinkedList<OsmPrimitive>() : Main.ds.allNonDeletedPrimitives(); 74 73 try { 75 76 74 URLConnection con = url.openConnection(); 75 InputStream in = new ProgressInputStream(con, progress, currentAction); 77 76 currentAction.setText(tr("Downloading...")); 78 77 Map<Long, String> ids = idReader.parseIds(in); 79 80 81 82 83 84 85 78 for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) { 79 if (ids.containsKey(osm.id) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.id))) { 80 if (mode == SearchMode.remove) 81 sel.remove(osm); 82 else 83 sel.add(osm); 84 } 86 85 } 87 88 89 90 91 92 93 94 86 } catch (IOException e) { 87 e.printStackTrace(); 88 JOptionPane.showMessageDialog(Main.parent, tr("Could not read from url: \"{0}\"",url)); 89 } catch (SAXException e) { 90 e.printStackTrace(); 91 JOptionPane.showMessageDialog(Main.parent,tr("Parsing error in url: \"{0}\"",url)); 92 } 93 } 95 94 @Override protected void cancel() { 96 95 sel = null; … … 100 99 if (sel != null) 101 100 Main.ds.setSelected(sel); 102 103 } 104 101 } 102 } 103 105 104 /** 106 105 * The selection's list data. … … 111 110 */ 112 111 private JList displaylist = new JList(list); 113 112 114 113 /** 115 114 * Create a SelectionList dialog. … … 117 116 */ 118 117 public SelectionListDialog(MapFrame mapFrame) { 119 super(tr("Current Selection"), "selectionlist", tr("Open a selection list window."), KeyEvent.VK_E); 120 setPreferredSize(new Dimension(320,150)); 118 super(tr("Current Selection"), "selectionlist", tr("Open a selection list window."), KeyEvent.VK_E, 150); 121 119 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 122 120 displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); … … 132 130 133 131 JPanel buttonPanel = new JPanel(new GridLayout(1,2)); 134 132 135 133 JButton button = new JButton(tr("Select"), ImageProvider.get("mapmode/selection/select")); 136 134 button.setToolTipText(tr("Set the selected elements on the map to the selected items in the list above.")); … … 150 148 }); 151 149 buttonPanel.add(button); 152 150 153 151 button = new JButton(tr("Search"), ImageProvider.get("dialogs", "search")); 154 152 button.setToolTipText(tr("Search for objects.")); … … 164 162 "<li><code>-name:Bak</code> - not 'Bak' in the name.</li>" + 165 163 "<li><code>foot:</code> - key=foot set to any value." + 166 164 "</ul></html>")); 167 165 168 166 JRadioButton replace = new JRadioButton(tr("replace selection"), true); … … 183 181 @Override public void selectInitialValue() { 184 182 input.requestFocusInWindow(); 185 183 } 186 184 }; 187 185 pane.createDialog(Main.parent,tr("Search")).setVisible(true); … … 194 192 }); 195 193 buttonPanel.add(button); 196 194 197 195 add(buttonPanel, BorderLayout.SOUTH); 198 196 selectionChanged(Main.ds.getSelected()); … … 241 239 if (search.startsWith("http://") || search.startsWith("ftp://") || search.startsWith("https://") || search.startsWith("file:/")) { 242 240 SelectionWebsiteLoader loader = new SelectionWebsiteLoader(search, mode); 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 241 if (loader.url != null) { 242 Main.worker.execute(loader); 243 loader.pleaseWaitDlg.setVisible(true); 244 return; 245 } 246 } 247 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 248 SearchCompiler.Match matcher = SearchCompiler.compile(search); 249 for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) { 250 if (mode == SearchMode.replace) { 251 if (matcher.match(osm)) 252 sel.add(osm); 253 else 254 sel.remove(osm); 255 } else if (mode == SearchMode.add && !osm.selected && matcher.match(osm)) 256 sel.add(osm); 257 else if (mode == SearchMode.remove && osm.selected && matcher.match(osm)) 258 sel.remove(osm); 259 } 260 Main.ds.setSelected(sel); 261 } 264 262 } -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r113 r119 2 2 3 3 import java.awt.BorderLayout; 4 import java.awt.Dimension; 4 5 import java.awt.event.ActionEvent; 5 6 import java.awt.event.KeyEvent; … … 44 45 public final String prefName; 45 46 46 public ToggleDialog(String name, String iconName, String tooltip, int shortCut ) {47 public ToggleDialog(String name, String iconName, String tooltip, int shortCut, int preferredHeight) { 47 48 this.prefName = iconName; 49 setPreferredSize(new Dimension(330,preferredHeight)); 48 50 action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortCut, KeyEvent.ALT_MASK, iconName); 49 51 setLayout(new BorderLayout()); -
src/org/openstreetmap/josm/test/MergeVisitorTest.java
r106 r119 238 238 assertSame("Do not import incomplete segments when merging ways.", s, w.segments.iterator().next()); 239 239 } 240 241 /** 242 * When merging an incomplete way over a dataset that contain already all 243 * necessary segments, the way must be completed. 244 */ 245 @Bug(117) 246 public void testMergeIncompleteOnExistingDoesNotComplete() { 247 // create a dataset with an segment (as base for the later incomplete way) 248 DataSet ds = new DataSet(); 249 Node[] n = createNodes(ds, 2); 250 Segment s = DataSetTestCaseHelper.createSegment(ds, n[0], n[1]); 251 s.id = 23; 252 // create an incomplete way which references the former segment 253 Way w = new Way(); 254 Segment incompleteSegment = new Segment(s.id); 255 w.segments.add(incompleteSegment); 256 w.id = 42; 257 // merge both 258 MergeVisitor v = new MergeVisitor(ds); 259 v.visit(w); 260 v.fixReferences(); 240 261 262 assertTrue(ds.ways.contains(w)); 263 assertEquals(1, w.segments.size()); 264 assertFalse(w.segments.get(0).incomplete); 265 } 266 267 /** 268 * Deleted segments should be deleted when merged over unchanged segments. 269 * Deleted segments should also raise an conflict when merged over changed segments. 270 */ 271 //TODO 272 241 273 /** 242 274 * Create that amount of nodes and add them to the dataset. The id will be 1,2,3,4...
Note:
See TracChangeset
for help on using the changeset viewer.