Changes in / [2024:2060] in josm
- Location:
- /trunk
- Files:
-
- 49 added
- 11 deleted
- 91 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/presets/presets.xml
r2024 r2060 2436 2436 <label text="Edit Hunting Stand" /> 2437 2437 <key key="amenity" value="hunting_stand" /> 2438 <check key="shelter" text="Shelter" default="off" delete_if_empty="true" />2439 <check key="hide" text="Hide" default="off" delete_if_empty="true" />2440 <check key="lock" text="Lock" default="off" delete_if_empty="true" />2441 2438 <combo key="height" text="Height" values="low,half,full,5,10,15,20" default="" delete_if_empty="true" /> 2439 <combo key="shelter" text="Shelter" values="yes,no,unknown" default="" delete_if_empty="true" /> 2440 <combo key="hide" text="Hide" values="yes,no,unknown" default="" delete_if_empty="true" /> 2441 <combo key="lock" text="Lock" values="yes,no,unknown" default="" delete_if_empty="true" /> 2442 2442 </item> 2443 2443 <item name="Fountain" icon="presets/spring.png" type="node,closedway"> … … 2673 2673 <key key="amenity" value="bank" /> 2674 2674 <text key="name" text="Name" default="" delete_if_empty="true" /> 2675 <text key="operator" text="Operator" default="" delete_if_empty="true" /> 2675 2676 <combo key="opening_hours" text="Opening Hours" values="24/7,Mo-Fr 08:30-20:00,Tu-Su 08:00-15:00; Sa 08:00-12:00" default="" delete_if_empty="true" /> 2676 2677 <check key="atm" text="Automated Teller Machine" default="on" delete_if_empty="true" /> -
/trunk/src/org/openstreetmap/josm/Main.java
r2024 r2060 2 2 package org.openstreetmap.josm; 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.trn; 4 5 5 6 import java.awt.BorderLayout; … … 10 11 import java.awt.event.KeyEvent; 11 12 import java.io.File; 13 import java.io.IOException; 12 14 import java.net.URI; 13 15 import java.net.URISyntaxException; 16 import java.util.ArrayList; 14 17 import java.util.Collection; 18 import java.util.List; 15 19 import java.util.Map; 16 20 import java.util.StringTokenizer; … … 22 26 import javax.swing.JComponent; 23 27 import javax.swing.JFrame; 28 import javax.swing.JLabel; 24 29 import javax.swing.JOptionPane; 25 30 import javax.swing.JPanel; 26 31 import javax.swing.UIManager; 27 32 33 import org.openstreetmap.josm.actions.OpenFileAction; 28 34 import org.openstreetmap.josm.actions.SaveAction; 29 35 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; … … 45 51 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 46 52 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 53 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 47 54 import org.openstreetmap.josm.gui.layer.Layer; 48 55 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 333 340 // 334 341 try { 335 CoordinateFormat format = CoordinateFormat.valueOf(Main.pref.get("coordinates")); 342 //CoordinateFormat format = CoordinateFormat.valueOf(Main.pref.get("coordinates")); 336 343 CoordinateFormat.setCoordinateFormat(CoordinateFormat.valueOf(Main.pref.get("coordinates"))); 337 344 } catch (IllegalArgumentException iae) { … … 393 400 } 394 401 395 public static boolean breakBecauseUnsavedChanges() { 402 public static boolean saveUnsavedModifications() { 403 if (map == null) return true; 404 SaveLayersDialog dialog = new SaveLayersDialog(Main.parent); 405 List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>(); 406 for (OsmDataLayer l: Main.map.mapView.getLayersOfType(OsmDataLayer.class)) { 407 if (l.requiresSaveToFile() || l.requiresUploadToServer()) { 408 layersWithUnmodifiedChanges.add(l); 409 } 410 } 411 dialog.prepareForSavingAndUpdatingLayersBeforeExit(); 412 if (!layersWithUnmodifiedChanges.isEmpty()) { 413 dialog.getModel().populate(layersWithUnmodifiedChanges); 414 dialog.setVisible(true); 415 switch(dialog.getUserAction()) { 416 case CANCEL: return false; 417 case PROCEED: return true; 418 default: return false; 419 } 420 } 421 return true; 422 } 423 424 /** 425 * Saves all {@see OsmDataLayer}s with an associated file and with unsaved 426 * data modifications. 427 * 428 * @return true, if the save operation was successful; false, otherwise 429 */ 430 public static boolean saveUnsavedModifications_old() { 396 431 Shortcut.savePrefs(); 397 if (map != null) { 398 boolean modified = false; 399 boolean uploadedModified = false; 400 for (final Layer l : map.mapView.getAllLayers()) { 401 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 402 modified = true; 403 uploadedModified = ((OsmDataLayer)l).uploadedModified; 404 break; 405 } 406 } 407 if (modified) { 408 final String msg = uploadedModified ? "\n" 409 +tr("Hint: Some changes came from uploading new data to the server.") : ""; 410 int result = new ExtendedDialog(parent, tr("Unsaved Changes"), 411 new javax.swing.JLabel(tr("There are unsaved changes. Discard the changes and continue?")+msg), 412 new String[] {tr("Save and Exit"), tr("Discard and Exit"), tr("Cancel")}, 413 new String[] {"save.png", "exit.png", "cancel.png"}).getValue(); 414 415 // Save before exiting 416 if(result == 1) { 417 Boolean savefailed = false; 418 for (final Layer l : map.mapView.getAllLayers()) { 419 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 420 SaveAction save = new SaveAction(); 421 if(!save.doSave(l)) { 422 savefailed = true; 423 } 424 } 425 } 426 return savefailed; 427 } 428 else if(result != 2) // Cancel exiting unless the 2nd button was clicked 429 return true; 430 } 431 } 432 return false; 432 if (map == null) 433 return true; // nothing to save, return success 434 435 int numUnsavedLayers = 0; 436 for (final OsmDataLayer l : map.mapView.getLayersOfType(OsmDataLayer.class)) { 437 if (l.requiresSaveToFile()) { 438 numUnsavedLayers++; 439 } 440 } 441 if (numUnsavedLayers == 0) 442 return true; // nothing to save, return success 443 444 String msg = trn( 445 "There are unsaved changes in {0} layer. Discard the changes and continue?", 446 "There are unsaved changes in {0} layers. Discard the changes and continue?", 447 numUnsavedLayers, 448 numUnsavedLayers 449 ); 450 451 ExtendedDialog ed = new ExtendedDialog(parent, 452 tr("Unsaved Changes"), 453 new String[] {tr("Save and Exit"), tr("Discard and Exit"), tr("Cancel")}); 454 ed.setButtonIcons(new String[] {"save.png", "exit.png", "cancel.png"}); 455 ed.setContent(new JLabel(msg)); 456 ed.showDialog(); 457 458 switch(ed.getValue()) { 459 case 2: /* discard and exit */ return true; 460 case 3: /* cancel */ return false; 461 } 462 boolean savefailed = false; 463 for (OsmDataLayer l : map.mapView.getLayersOfType(OsmDataLayer.class)) { 464 if(!new SaveAction().doSave(l)) { 465 savefailed = true; 466 } 467 } 468 return !savefailed; 433 469 } 434 470 … … 452 488 453 489 if (s.startsWith("file:")) { 490 File f = null; 454 491 try { 455 main.menu.openFile.openFile(new File(new URI(s)));492 f = new File(new URI(s)); 456 493 } catch (URISyntaxException e) { 457 494 JOptionPane.showMessageDialog( … … 462 499 ); 463 500 } 501 try { 502 if (f!=null) { 503 OpenFileAction.openFile(f); 504 } 505 }catch(IOException e) { 506 e.printStackTrace(); 507 JOptionPane.showMessageDialog( 508 Main.parent, 509 tr("<html>Could not read file ''{0}\''.<br> Error is: <br>{1}</html>", f.getName(), e.getMessage()), 510 tr("Error"), 511 JOptionPane.ERROR_MESSAGE 512 ); 513 } 464 514 return; 465 515 } … … 474 524 } 475 525 } 476 477 main.menu.openFile.openFile(new File(s)); 526 File f = new File(s); 527 try { 528 OpenFileAction.openFile(f); 529 }catch(IOException e) { 530 e.printStackTrace(); 531 JOptionPane.showMessageDialog( 532 Main.parent, 533 tr("<html>Could not read file ''{0}\''.<br> Error is: <br>{1}</html>", f.getName(), e.getMessage()), 534 tr("Error"), 535 JOptionPane.ERROR_MESSAGE 536 ); 537 } 478 538 } 479 539 -
/trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r2024 r2060 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.net.URL; 7 8 import java.util.ArrayList; 8 9 import java.util.Iterator; … … 31 32 * @return the base URL, i.e. http://api.openstreetmap.org/browse 32 33 */ 33 protectedString getBaseURL() {34 static public String getBaseBrowseUrl() { 34 35 String baseUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"); 35 36 Pattern pattern = Pattern.compile("/api/?$"); 36 37 String ret = pattern.matcher(baseUrl).replaceAll("/browse"); 37 38 if (ret.equals(baseUrl)) { 38 System.out.println(tr("WARNING: unexpected format of API base URL. Redirection to history page for OSM primitive will probably fail. API base URL is: ''{0}''",baseUrl)); 39 System.out.println(tr("WARNING: unexpected format of API base URL. Redirection to info or history page for OSM primitive will probably fail. API base URL is: ''{0}''",baseUrl)); 39 40 } 40 41 if (ret.startsWith("http://api.openstreetmap.org/")) { … … 45 46 } 46 47 47 protected void launchBrowser() { 48 /** 49 * replies the base URL for browsing information about a user 50 * 51 * @return the base URL, i.e. http://ww.openstreetmap.org/user 52 */ 53 static public String getBaseUserUrl() { 54 String baseUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"); 55 Pattern pattern = Pattern.compile("/api/?$"); 56 String ret = pattern.matcher(baseUrl).replaceAll("/user"); 57 if (ret.equals(baseUrl)) { 58 System.out.println(tr("WARNING: unexpected format of API base URL. Redirection to user page for OSM user will probably fail. API base URL is: ''{0}''",baseUrl)); 59 } 60 if (ret.startsWith("http://api.openstreetmap.org/")) { 61 ret = ret.substring("http://api.openstreetmap.org/".length()); 62 ret = "http://www.openstreetmap.org/" + ret; 63 } 64 return ret; 65 } 66 67 protected void launchBrowser(URL url) { 68 OpenBrowser.displayUrl( 69 url.toString() 70 ); 71 } 72 73 protected void launchBrowser(String url) { 74 OpenBrowser.displayUrl( 75 url 76 ); 77 } 78 79 protected void launchInfoBrowsersForSelectedPrimitives() { 48 80 ArrayList<OsmPrimitive> primitivesToShow = new ArrayList<OsmPrimitive>(getCurrentDataSet().getSelected()); 49 81 … … 52 84 Iterator<OsmPrimitive> it = primitivesToShow.iterator(); 53 85 while(it.hasNext()) { 54 if (it.next(). id== 0) {86 if (it.next().getId() == 0) { 55 87 it.remove(); 56 88 } … … 74 106 } 75 107 for(int i = 0; i < max; i++) { 76 OpenBrowser.displayUrl( 77 createInfoUrl(primitivesToShow.get(i)) 78 ); 108 launchBrowser(createInfoUrl(primitivesToShow.get(i))); 79 109 } 80 110 } 81 111 82 112 public void actionPerformed(ActionEvent e) { 83 launch Browser();113 launchInfoBrowsersForSelectedPrimitives(); 84 114 } 85 115 86 protected abstract String createInfoUrl(O smPrimitive primitive);116 protected abstract String createInfoUrl(Object infoObject); 87 117 88 118 @Override -
/trunk/src/org/openstreetmap/josm/actions/AbstractMergeAction.java
r2024 r2060 66 66 layerList.setModel(new DefaultComboBoxModel(targetLayers.toArray())); 67 67 layerList.setSelectedIndex(0); 68 68 69 69 JPanel pnl = new JPanel(); 70 70 pnl.setLayout(new GridBagLayout()); 71 71 pnl.add(new JLabel(tr("Please select the target layer.")), GBC.eol()); 72 72 pnl.add(layerList, GBC.eol()); 73 74 int decision = new ExtendedDialog(Main.parent, tr("Select target layer"), pnl, new String[] { tr("Merge"), 75 tr("Cancel") }, new String[] { "dialogs/mergedown", "cancel" }).getValue(); 76 if (decision != 1) 73 74 ExtendedDialog ed = new ExtendedDialog(Main.parent, 75 tr("Select target layer"), 76 new String[] { tr("Merge"), tr("Cancel") }); 77 ed.setButtonIcons(new String[] { "dialogs/mergedown", "cancel" }); 78 ed.setContent(pnl); 79 ed.showDialog(); 80 if (ed.getValue() != 1) 77 81 return null; 82 78 83 Layer targetLayer = (Layer) layerList.getSelectedItem(); 79 84 return targetLayer; -
/trunk/src/org/openstreetmap/josm/actions/ApiPreconditionChecker.java
r2024 r2060 1 // License: GPL. For details, see LICENSE file.2 1 package org.openstreetmap.josm.actions; 3 2 … … 16 15 import org.openstreetmap.josm.data.osm.Way; 17 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 18 import org.openstreetmap.josm.io.OsmApi; 19 19 import org.openstreetmap.josm.io.OsmApiInitializationException; … … 25 25 OsmApi api = OsmApi.getOsmApi(); 26 26 try { 27 api.initialize(); 27 api.initialize(NullProgressMonitor.INSTANCE); 28 28 long maxNodes = 0; 29 29 if (api.getCapabilities().isDefined("waynodes", "maximum")) { … … 71 71 for (Entry<String,String> e : osmPrimitive.entrySet()) { 72 72 if(e.getValue().length() > 255) { 73 if (osmPrimitive. deleted) {73 if (osmPrimitive.isDeleted()) { 74 74 // if OsmPrimitive is going to be deleted we automatically shorten the 75 75 // value … … 77 77 tr("Warning: automatically truncating value of tag ''{0}'' on deleted primitive {1}", 78 78 e.getKey(), 79 Long.toString(osmPrimitive. id)79 Long.toString(osmPrimitive.getId()) 80 80 ) 81 81 ); … … 85 85 JOptionPane.showMessageDialog(Main.parent, 86 86 tr("Length of value for tag ''{0}'' on primitive {1} exceeds the max. allowed length {2}. Values length is {3}.", 87 e.getKey(), Long.toString(osmPrimitive. id), 255, e.getValue().length()87 e.getKey(), Long.toString(osmPrimitive.getId()), 255, e.getValue().length() 88 88 ), 89 89 tr("Precondition Violation"), … … 103 103 tr("{0} nodes in way {1} exceed the max. allowed number of nodes {2}", 104 104 ((Way)osmPrimitive).getNodesCount(), 105 Long.toString(osmPrimitive. id),105 Long.toString(osmPrimitive.getId()), 106 106 maxNodes 107 107 ), -
/trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2024 r2060 90 90 HashSet<Relation> relationsUsingWays = new HashSet<Relation>(); 91 91 for (Relation r : getCurrentDataSet().relations) { 92 if (r. deleted|| r.incomplete) {92 if (r.isDeleted() || r.incomplete) { 93 93 continue; 94 94 } … … 118 118 for (HashSet<Way> waylinks : backlinks.values()) { 119 119 if (!waylinks.containsAll(selectedWays)) { 120 int option = new ExtendedDialog(Main.parent, 120 121 ExtendedDialog ed = new ExtendedDialog(Main.parent, 121 122 tr("Combine ways with different memberships?"), 122 tr("The selected ways have differing relation memberships. " 123 + "Do you still want to combine them?"), 124 new String[] {tr("Combine Anyway"), tr("Cancel")}, 125 new String[] {"combineway.png", "cancel.png"}).getValue(); 126 if (option == 1) { 123 new String[] {tr("Combine Anyway"), tr("Cancel")}); 124 ed.setButtonIcons(new String[] {"combineway.png", "cancel.png"}); 125 ed.setContent(tr("The selected ways have differing relation memberships. " 126 + "Do you still want to combine them?")); 127 ed.showDialog(); 128 129 if (ed.getValue() == 1) { 127 130 break; 128 131 } … … 150 153 Object secondTry = actuallyCombineWays(selectedWays, true); 151 154 if (secondTry instanceof List<?>) { 152 int option= new ExtendedDialog(Main.parent,155 ExtendedDialog ed = new ExtendedDialog(Main.parent, 153 156 tr("Change directions?"), 154 tr("The ways can not be combined in their current directions. " 155 + "Do you want to reverse some of them?"), 156 new String[] {tr("Reverse and Combine"), tr("Cancel")}, 157 new String[] {"wayflip.png", "cancel.png"}).getValue(); 158 if (option != 1) return; 157 new String[] {tr("Reverse and Combine"), tr("Cancel")}); 158 ed.setButtonIcons(new String[] {"wayflip.png", "cancel.png"}); 159 ed.setContent(tr("The ways can not be combined in their current directions. " 160 + "Do you want to reverse some of them?")); 161 ed.showDialog(); 162 if (ed.getValue() != 1) return; 163 159 164 nodeList = (List<Node>) secondTry; 160 165 } else { … … 177 182 for (Way w : selectedWays) { 178 183 modifyWay = w; 179 if (w. id!= 0) {184 if (w.getId() != 0) { 180 185 break; 181 186 } … … 205 210 206 211 if (!components.isEmpty()) { 207 int answer = new ExtendedDialog(Main.parent, 212 213 ExtendedDialog ed = new ExtendedDialog(Main.parent, 208 214 tr("Enter values for all conflicts."), 209 p, 210 new String[] {tr("Solve Conflicts"), tr("Cancel")}, 211 new String[] {"dialogs/conflict.png", "cancel.png"}).getValue(); 212 if (answer != 1) return; 215 new String[] {tr("Solve Conflicts"), tr("Cancel")}); 216 ed.setButtonIcons(new String[] {"dialogs/conflict.png", "cancel.png"}); 217 ed.setContent(p); 218 ed.showDialog(); 219 220 if (ed.getValue() != 1) return; 213 221 214 222 for (Entry<String, JComboBox> e : components.entrySet()) { -
/trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java
r2024 r2060 7 7 8 8 import javax.swing.JFileChooser; 9 import javax.swing.filechooser.FileFilter;10 9 11 10 import org.openstreetmap.josm.Main; 12 11 import org.openstreetmap.josm.gui.ExtendedDialog; 13 import org.openstreetmap.josm.io.FileImporter;14 12 import org.openstreetmap.josm.tools.Shortcut; 15 13 … … 39 37 fc.setMultiSelectionEnabled(multiple); 40 38 fc.setAcceptAllFileFilterUsed(false); 41 FileFilter defaultFilter = null; 42 for (FileImporter imExporter: ExtensionFileFilter.importers) { 43 fc.addChoosableFileFilter(imExporter.filter); 44 if (extension != null && extension.endsWith(imExporter.filter.defaultExtension)) { 45 defaultFilter = imExporter.filter; 46 } 47 } 48 49 if (defaultFilter == null) { 50 defaultFilter = new ExtensionFileFilter.AllFormatsImporter().filter; 51 } 52 fc.setFileFilter(defaultFilter); 39 System.out.println("opening fc for extension " + extension); 40 ExtensionFileFilter.applyChoosableImportFileFilters(fc, extension); 53 41 54 42 int answer = open ? fc.showOpenDialog(Main.parent) : fc.showSaveDialog(Main.parent); -
/trunk/src/org/openstreetmap/josm/actions/ExitAction.java
r2024 r2060 21 21 public ExitAction() { 22 22 super(tr("Exit"), "exit", tr("Exit the application."), 23 Shortcut.registerShortcut("system:menuexit", tr("Exit"), KeyEvent.VK_Q, Shortcut.GROUP_MENU), true); 23 Shortcut.registerShortcut("system:menuexit", tr("Exit"), KeyEvent.VK_Q, Shortcut.GROUP_MENU), true); 24 24 } 25 25 26 26 public void actionPerformed(ActionEvent e) { 27 if ( !Main.breakBecauseUnsavedChanges()) {27 if (Main.saveUnsavedModifications()) { 28 28 Main.saveGuiGeometry(); 29 29 System.exit(0); -
/trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
r2024 r2060 7 7 import java.util.ArrayList; 8 8 import java.util.Arrays; 9 9 import java.util.Collections; 10 import java.util.Comparator; 11 import java.util.LinkedList; 12 import java.util.List; 13 14 import javax.swing.JFileChooser; 10 15 import javax.swing.filechooser.FileFilter; 11 16 … … 26 31 * filters used in JOSM. 27 32 * 28 * @author imi29 33 */ 30 34 public class ExtensionFileFilter extends FileFilter { 31 private final String extension;32 private final String description;33 public final String defaultExtension;34 35 35 36 /** … … 41 42 public static ArrayList<FileExporter> exporters = new ArrayList<FileExporter>(Arrays.asList(new GpxExporter(), 42 43 new OsmExporter(), new OsmGzipExporter(), new OsmBzip2Exporter())); 43 44 45 46 private final String extensions; 47 private final String description; 48 /** 49 * @deprecated use {@see #getDefaultExtension() 50 */ 51 @Deprecated 52 public final String defaultExtension; 53 54 55 static protected void sort(List<ExtensionFileFilter> filters) { 56 Collections.sort( 57 filters, 58 new Comparator<ExtensionFileFilter>() { 59 private AllFormatsImporter all = new AllFormatsImporter(); 60 public int compare(ExtensionFileFilter o1, ExtensionFileFilter o2) { 61 if (o1.getDescription().equals(all.filter.getDescription())) return 1; 62 if (o2.getDescription().equals(all.filter.getDescription())) return -1; 63 return o1.getDescription().compareTo(o2.getDescription()); 64 } 65 } 66 ); 67 } 68 69 /** 70 * Replies an ordered list of {@see ExtensionFileFilter}s for importing. 71 * The list is ordered according to their description, an {@see AllFormatsImporter} 72 * is append at the end. 73 * 74 * @return an ordered list of {@see ExtensionFileFilter}s for importing. 75 */ 76 public static List<ExtensionFileFilter> getImportExtensionFileFilters() { 77 LinkedList<ExtensionFileFilter> filters = new LinkedList<ExtensionFileFilter>(); 78 for (FileImporter importer : importers) { 79 if (filters.contains(importer.filter)) { 80 continue; 81 } 82 filters.add(importer.filter); 83 } 84 sort(filters); 85 return filters; 86 } 87 88 /** 89 * Replies an ordered list of {@see ExtensionFileFilter}s for exporting. 90 * The list is ordered according to their description, an {@see AllFormatsImporter} 91 * is append at the end. 92 * 93 * @return an ordered list of {@see ExtensionFileFilter}s for exporting. 94 */ 95 public static List<ExtensionFileFilter> getExportExtensionFileFilters() { 96 LinkedList<ExtensionFileFilter> filters = new LinkedList<ExtensionFileFilter>(); 97 for (FileExporter exporter : exporters) { 98 if (filters.contains(exporter.filter)) { 99 continue; 100 } 101 filters.add(exporter.filter); 102 } 103 sort(filters); 104 return filters; 105 } 106 107 /** 108 * Replies the default {@see ExtensionFileFilter} for a given extension 109 * 110 * @param extension the extension 111 * @return the default {@see ExtensionFileFilter} for a given extension 112 */ 113 public static ExtensionFileFilter getDefaultImportExtensionFileFilter(String extension) { 114 if (extension == null) return new AllFormatsImporter().filter; 115 for (FileImporter importer : importers) { 116 if (extension.equals(importer.filter.getDefaultExtension())) 117 return importer.filter; 118 } 119 return new AllFormatsImporter().filter; 120 } 121 122 /** 123 * Replies the default {@see ExtensionFileFilter} for a given extension 124 * 125 * @param extension the extension 126 * @return the default {@see ExtensionFileFilter} for a given extension 127 */ 128 public static ExtensionFileFilter getDefaultExportExtensionFileFilter(String extension) { 129 if (extension == null) return new AllFormatsImporter().filter; 130 for (FileExporter exporter : exporters) { 131 if (extension.equals(exporter.filter.getDefaultExtension())) 132 return exporter.filter; 133 } 134 return new AllFormatsImporter().filter; 135 } 136 137 /** 138 * Applies the choosable {@see FileFilter} to a {@see JFileChooser} before using the 139 * file chooser for selecting a file for reading. 140 * 141 * @param fileChooser the file chooser 142 * @param extension the default extension 143 */ 144 public static void applyChoosableImportFileFilters(JFileChooser fileChooser, String extension) { 145 for (ExtensionFileFilter filter: getImportExtensionFileFilters()) { 146 fileChooser.addChoosableFileFilter(filter); 147 } 148 fileChooser.setFileFilter(getDefaultImportExtensionFileFilter(extension)); 149 } 150 151 /** 152 * Applies the choosable {@see FileFilter} to a {@see JFileChooser} before using the 153 * file chooser for selecting a file for writing. 154 * 155 * @param fileChooser the file chooser 156 * @param extension the default extension 157 */ 158 public static void applyChoosableExportFileFilters(JFileChooser fileChooser, String extension) { 159 for (ExtensionFileFilter filter: getExportExtensionFileFilters()) { 160 fileChooser.addChoosableFileFilter(filter); 161 } 162 fileChooser.setFileFilter(getDefaultExportExtensionFileFilter(extension)); 163 } 164 44 165 /** 45 166 * Construct an extension file filter by giving the extension to check after. 46 167 */ 47 public ExtensionFileFilter(String extension, String def Ext, String description) {48 this.extension = extension; 49 defaultExtension = def Ext;168 public ExtensionFileFilter(String extension, String defaultExtension, String description) { 169 this.extensions = extension; 170 this.defaultExtension = defaultExtension; 50 171 this.description = description; 51 172 } … … 53 174 public boolean acceptName(String filename) { 54 175 String name = filename.toLowerCase(); 55 for (String ext : extension.split(",")) 176 for (String ext : extensions.split(",")) 56 177 if (name.endsWith("."+ext)) 57 178 return true; … … 68 189 return description; 69 190 } 70 191 192 public String getDefaultExtension() { 193 return defaultExtension; 194 } 195 71 196 /** 72 197 * Dummy importer that adds the "All Formats"-Filter when opening files … … 75 200 public AllFormatsImporter() { 76 201 super( 77 new ExtensionFileFilter("osm,xml,osm.gz,osm.bz2,osm.bz,gpx,gpx.gz,nmea,nme,nma,txt", "", tr("All Formats") 78 + " (*.gpx *.osm *.nmea ...)")); 202 new ExtensionFileFilter("osm,xml,osm.gz,osm.bz2,osm.bz,gpx,gpx.gz,nmea,nme,nma,txt,wms", "", tr("All Formats") 203 + " (*.gpx *.osm *.nmea ...)")); 79 204 } 80 205 @Override public boolean acceptFile(File pathname) { … … 82 207 } 83 208 } 209 210 @Override 211 public int hashCode() { 212 final int prime = 31; 213 int result = 1; 214 result = prime * result + ((defaultExtension == null) ? 0 : defaultExtension.hashCode()); 215 result = prime * result + ((description == null) ? 0 : description.hashCode()); 216 result = prime * result + ((extensions == null) ? 0 : extensions.hashCode()); 217 return result; 218 } 219 220 @Override 221 public boolean equals(Object obj) { 222 if (this == obj) 223 return true; 224 if (obj == null) 225 return false; 226 if (getClass() != obj.getClass()) 227 return false; 228 ExtensionFileFilter other = (ExtensionFileFilter) obj; 229 if (defaultExtension == null) { 230 if (other.defaultExtension != null) 231 return false; 232 } else if (!defaultExtension.equals(other.defaultExtension)) 233 return false; 234 if (description == null) { 235 if (other.description != null) 236 return false; 237 } else if (!description.equals(other.description)) 238 return false; 239 if (extensions == null) { 240 if (other.extensions != null) 241 return false; 242 } else if (!extensions.equals(other.extensions)) 243 return false; 244 return true; 245 } 84 246 } -
/trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r2024 r2060 20 20 21 21 @Override 22 protected String createInfoUrl(OsmPrimitive primitive) { 23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.id + "/history"; 22 protected String createInfoUrl(Object infoObject) { 23 OsmPrimitive primitive = (OsmPrimitive)infoObject; 24 return getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history"; 24 25 } 25 26 } -
/trunk/src/org/openstreetmap/josm/actions/InfoAction.java
r2024 r2060 20 20 21 21 @Override 22 protected String createInfoUrl(OsmPrimitive primitive) { 23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.id; 22 protected String createInfoUrl(Object infoObject) { 23 OsmPrimitive primitive = (OsmPrimitive)infoObject; 24 return getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId(); 24 25 } 25 26 } -
/trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r2024 r2060 95 95 Node useNode = null; 96 96 for (Node n: selectedNodes) { 97 if (n. id> 0) {97 if (n.getId() > 0) { 98 98 useNode = n; 99 99 break; … … 127 127 HashSet<Relation> relationsUsingNodes = new HashSet<Relation>(); 128 128 for (Relation r : getCurrentDataSet().relations) { 129 if (r. deleted|| r.incomplete) {129 if (r.isDeleted() || r.incomplete) { 130 130 continue; 131 131 } … … 155 155 for (HashSet<Node> nodelinks : backlinks.values()) { 156 156 if (!nodelinks.containsAll(allNodes)) { 157 int option= new ExtendedDialog(Main.parent,157 ExtendedDialog ed = new ExtendedDialog(Main.parent, 158 158 tr("Merge nodes with different memberships?"), 159 tr("The selected nodes have differing relation memberships. " 160 + "Do you still want to merge them?"), 161 new String[] {tr("Merge Anyway"), tr("Cancel")}, 162 new String[] {"mergenodes.png", "cancel.png"}).getValue(); 163 if (option == 1) { 159 new String[] {tr("Merge Anyway"), tr("Cancel")}); 160 ed.setButtonIcons(new String[] {"mergenodes.png", "cancel.png"}); 161 ed.setContent(tr("The selected nodes have differing relation memberships. " 162 + "Do you still want to merge them?")); 163 ed.showDialog(); 164 165 if (ed.getValue() == 1) { 164 166 break; 165 167 } … … 217 219 218 220 for (Way w : getCurrentDataSet().ways) { 219 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {221 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 220 222 continue; 221 223 } -
/trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r2024 r2060 8 8 import java.io.File; 9 9 import java.io.IOException; 10 import java.util.Arrays; 11 import java.util.List; 10 12 11 13 import javax.swing.JFileChooser; … … 13 15 14 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 15 18 import org.openstreetmap.josm.io.FileImporter; 19 import org.openstreetmap.josm.io.OsmTransferException; 16 20 import org.openstreetmap.josm.tools.Shortcut; 21 import org.xml.sax.SAXException; 17 22 18 23 /** … … 37 42 return; 38 43 File[] files = fc.getSelectedFiles(); 39 for (int i = files.length; i > 0; --i) { 40 openFile(files[i-1]); 41 } 42 } 43 44 /** 45 * Open the given file. 46 */ 47 public void openFile(File file) { 48 try { 49 System.out.println("Open file: " + file.getAbsolutePath() + " (" + file.length() + " bytes)"); 50 for (FileImporter importer : ExtensionFileFilter.importers) 51 if (importer.acceptFile(file)) { 52 importer.importData(file); 53 } 54 } catch (IOException x) { 55 x.printStackTrace(); 56 JOptionPane.showMessageDialog( 57 Main.parent, 58 tr("<html>Could not read file ''{0}\''. Error is: <br>{1}</html>", file.getName(), x.getMessage()), 59 tr("Error"), 60 JOptionPane.ERROR_MESSAGE 61 ); 62 63 } 44 OpenFileTask task = new OpenFileTask(Arrays.asList(files)); 45 Main.worker.submit(task); 64 46 } 65 47 … … 68 50 setEnabled(! Main.applet); 69 51 } 52 53 static public void openFile(File f) throws IOException { 54 for (FileImporter importer : ExtensionFileFilter.importers) 55 if (importer.acceptFile(f)) { 56 importer.importData(f); 57 } 58 } 59 60 static public class OpenFileTask extends PleaseWaitRunnable { 61 private List<File> files; 62 private boolean cancelled; 63 64 public OpenFileTask(List<File> files) { 65 super(tr("Opening files"), false /* don't ignore exception */); 66 this.files = files; 67 } 68 @Override 69 protected void cancel() { 70 this.cancelled = true; 71 } 72 73 @Override 74 protected void finish() { 75 // do nothing 76 } 77 78 @Override 79 protected void realRun() throws SAXException, IOException, OsmTransferException { 80 if (files == null || files.isEmpty()) return; 81 getProgressMonitor().setTicks(files.size()); 82 for (File f : files) { 83 if (cancelled) return; 84 getProgressMonitor().subTask(tr("Opening file ''{0}'' ...", f.getAbsolutePath())); 85 try { 86 System.out.println("Open file: " + f.getAbsolutePath() + " (" + f.length() + " bytes)"); 87 openFile(f); 88 } catch (Exception e) { 89 e.printStackTrace(); 90 JOptionPane.showMessageDialog( 91 Main.parent, 92 tr("<html>Could not read file ''{0}\''.<br> Error is: <br>{1}</html>", f.getName(), e.getMessage()), 93 tr("Error"), 94 JOptionPane.ERROR_MESSAGE 95 ); 96 } 97 getProgressMonitor().worked(1); 98 } 99 } 100 } 70 101 } -
/trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r2024 r2060 126 126 protected Map<OsmPrimitiveType, Integer> getSourceStatistics() { 127 127 HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>(); 128 for (Class type: new Class[] {Node.class, Way.class, Relation.class}) { 128 for (Class<? extends OsmPrimitive> type: new Class[] {Node.class, Way.class, Relation.class}) { 129 129 if (!getSourceTagsByType(type).isEmpty()) { 130 130 ret.put(OsmPrimitiveType.from(type), getSourcePrimitivesByType(type).size()); … … 136 136 protected Map<OsmPrimitiveType, Integer> getTargetStatistics() { 137 137 HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>(); 138 for (Class type: new Class[] {Node.class, Way.class, Relation.class}) { 138 for (Class<? extends OsmPrimitive> type: new Class[] {Node.class, Way.class, Relation.class}) { 139 139 int count = getSubcollectionByType(getEditLayer().data.getSelected(), type).size(); 140 140 if (count > 0) { … … 156 156 protected void pasteFromHomogeneousSource(Collection<? extends OsmPrimitive> targets) { 157 157 TagCollection tc = null; 158 Class sourceType = null; 159 for (Class type : new Class[] {Node.class, Way.class, Relation.class}) { 158 for (Class<? extends OsmPrimitive> type : new Class[] {Node.class, Way.class, Relation.class}) { 160 159 TagCollection tc1 = getSourceTagsByType(type); 161 160 if (!tc1.isEmpty()) { 162 161 tc = tc1; 163 sourceType = type;164 162 } 165 163 } -
/trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r2024 r2060 72 72 layer.setName(file.getName()); 73 73 layer.setAssociatedFile(file); 74 if (layer instanceof OsmDataLayer) { 75 ((OsmDataLayer) layer).onPostSaveToFile(); 76 } 74 77 Main.parent.repaint(); 75 78 } catch (IOException e) { … … 88 91 */ 89 92 public boolean checkSaveConditions(Layer layer) { 90 if (layer == null) {91 JOptionPane.showMessageDialog(92 Main.parent,93 tr("Internal Error: cannot check conditions for no layer. Please report this as a bug."),94 tr("Error"),95 JOptionPane.ERROR_MESSAGE96 );97 return false;98 }99 if (Main.map == null) {100 JOptionPane.showMessageDialog(101 Main.parent,102 tr("No document open so nothing to save."),103 tr("Warning"),104 JOptionPane.WARNING_MESSAGE105 );106 return false;107 }108 109 93 if (layer instanceof OsmDataLayer && isDataSetEmpty((OsmDataLayer)layer) && 1 != new ExtendedDialog(Main.parent, tr("Empty document"), tr("The document contains no data."), new String[] {tr("Save anyway"), tr("Cancel")}, new String[] {"save.png", "cancel.png"}).getValue()) 110 94 return false; … … 128 112 public static File openFileDialog(Layer layer) { 129 113 if (layer instanceof OsmDataLayer) 130 return createAndOpenSaveFileChooser(tr("Save OSM file"), " .osm");114 return createAndOpenSaveFileChooser(tr("Save OSM file"), "osm"); 131 115 else if (layer instanceof GpxLayer) 132 return createAndOpenSaveFileChooser(tr("Save GPX file"), " .gpx");133 return createAndOpenSaveFileChooser(tr("Save Layer"), " .lay");116 return createAndOpenSaveFileChooser(tr("Save GPX file"), "gpx"); 117 return createAndOpenSaveFileChooser(tr("Save Layer"), "lay"); 134 118 } 135 119 … … 144 128 private boolean isDataSetEmpty(OsmDataLayer layer) { 145 129 for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives()) 146 if (!osm. deleted|| osm.id> 0)130 if (!osm.isDeleted() || osm.getId() > 0) 147 131 return false; 148 132 return true; … … 183 167 fc.setMultiSelectionEnabled(false); 184 168 fc.setAcceptAllFileFilterUsed(false); 185 186 FileFilter defaultFilter = null; 187 for (FileExporter exporter : ExtensionFileFilter.exporters) { 188 fc.addChoosableFileFilter(exporter.filter); 189 if (extension.endsWith(exporter.filter.defaultExtension)) { 190 defaultFilter = exporter.filter; 191 } 192 } 193 if (defaultFilter != null) { 194 fc.setFileFilter(defaultFilter); 195 } 196 169 ExtensionFileFilter.applyChoosableExportFileFilters(fc, extension); 197 170 int answer = fc.showSaveDialog(Main.parent); 198 171 if (answer != JFileChooser.APPROVE_OPTION) … … 210 183 FileFilter ff = fc.getFileFilter(); 211 184 if (ff instanceof ExtensionFileFilter) { 212 fn += "." + ((ExtensionFileFilter)ff). defaultExtension;185 fn += "." + ((ExtensionFileFilter)ff).getDefaultExtension(); 213 186 } else { 214 187 fn += extension; -
/trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r2024 r2060 73 73 while ((line = input.readLine()) != null) { 74 74 // Skip potential private information 75 if (line.trim().toLowerCase().startsWith("osm-server.username")) 75 if (line.trim().toLowerCase().startsWith("osm-server.username")) { 76 76 continue; 77 if (line.trim().toLowerCase().startsWith("osm-server.password")) 77 } 78 if (line.trim().toLowerCase().startsWith("osm-server.password")) { 78 79 continue; 79 if (line.trim().toLowerCase().startsWith("marker.show")) 80 } 81 if (line.trim().toLowerCase().startsWith("marker.show")) { 80 82 continue; 83 } 81 84 82 85 text.append(line); … … 97 100 sp.setPreferredSize(new Dimension(600, 500)); 98 101 99 int result = new ExtendedDialog(Main.parent, tr(tr("Status Report")), sp, 100 new String[] {tr("Copy to clipboard and close"), tr("Close") }, 101 new String[] {"copy.png", "cancel.png" }).getValue(); 102 ExtendedDialog ed = new ExtendedDialog(Main.parent, 103 tr("Status Report"), 104 new String[] {tr("Copy to clipboard and close"), tr("Close") }); 105 ed.setButtonIcons(new String[] {"copy.png", "cancel.png" }); 106 ed.setContent(sp); 107 ed.showDialog(); 102 108 103 if( result!= 1) return;109 if(ed.getValue() != 1) return; 104 110 try { 105 111 Toolkit.getDefaultToolkit().getSystemClipboard().setContents( … … 107 113 public void lostOwnership(Clipboard clipboard, Transferable contents) {} 108 114 } 109 115 ); 110 116 } 111 117 catch (RuntimeException x) {} -
/trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r2024 r2060 102 102 for (Node n : selectedNodes) { 103 103 for (Way w : getCurrentDataSet().ways) { 104 if (w. deleted|| w.incomplete) {104 if (w.isDeleted() || w.incomplete) { 105 105 continue; 106 106 } … … 293 293 294 294 for (Relation r : getCurrentDataSet().relations) { 295 if (r. deleted|| r.incomplete) {295 if (r.isDeleted() || r.incomplete) { 296 296 continue; 297 297 } -
/trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2024 r2060 66 66 int count = 0; 67 67 for (Way w : getCurrentDataSet().ways) { 68 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {68 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 69 69 continue; 70 70 } … … 91 91 int count = 0; 92 92 for (Way w : getCurrentDataSet().ways) { 93 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {93 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 94 94 continue; 95 95 } … … 321 321 HashSet<String> rolesToReAdd = null; 322 322 for (Relation r : getCurrentDataSet().relations) { 323 if (r. deleted|| r.incomplete) {323 if (r.isDeleted() || r.incomplete) { 324 324 continue; 325 325 } … … 368 368 // modify all ways containing the nodes 369 369 for (Way w : getCurrentDataSet().ways) { 370 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {370 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 371 371 continue; 372 372 } -
/trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r2024 r2060 79 79 // bounds defined? => use the bbox downloader 80 80 // 81 new DownloadOsmTaskList().download(false, areas, new PleaseWaitProgressMonitor()); 81 new DownloadOsmTaskList().download(false, areas, new PleaseWaitProgressMonitor(tr("Updating data"))); 82 82 } 83 83 } -
/trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2024 r2060 166 166 protected void initMultiFetchReaderWithNodes(MultiFetchServerObjectReader reader) { 167 167 for (OsmPrimitive primitive : toUpdate) { 168 if (primitive instanceof Node && primitive. id> 0) {168 if (primitive instanceof Node && primitive.getId() > 0) { 169 169 reader.append((Node)primitive); 170 170 } else if (primitive instanceof Way) { 171 171 Way way = (Way)primitive; 172 172 for (Node node: way.getNodes()) { 173 if (node. id> 0) {173 if (node.getId() > 0) { 174 174 reader.append(node); 175 175 } … … 181 181 protected void initMultiFetchReaderWithWays(MultiFetchServerObjectReader reader) { 182 182 for (OsmPrimitive primitive : toUpdate) { 183 if (primitive instanceof Way && primitive. id> 0) {183 if (primitive instanceof Way && primitive.getId() > 0) { 184 184 reader.append((Way)primitive); 185 185 } … … 189 189 protected void initMultiFetchReaderWithRelations(MultiFetchServerObjectReader reader) { 190 190 for (OsmPrimitive primitive : toUpdate) { 191 if (primitive instanceof Relation && primitive. id> 0) {191 if (primitive instanceof Relation && primitive.getId() > 0) { 192 192 reader.append((Relation)primitive); 193 193 } -
/trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2024 r2060 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.FlowLayout; 6 import java.awt.BorderLayout; 7 import java.awt.Dimension; 7 8 import java.awt.GridBagConstraints; 8 9 import java.awt.GridBagLayout; 9 10 import java.awt.event.ActionEvent; 11 import java.awt.event.ActionListener; 10 12 import java.awt.event.KeyEvent; 11 13 import java.io.IOException; 12 14 import java.net.HttpURLConnection; 13 15 import java.util.Collection; 16 import java.util.HashMap; 14 17 import java.util.LinkedList; 15 18 import java.util.List; 19 import java.util.Map; 16 20 import java.util.logging.Logger; 17 21 import java.util.regex.Matcher; 18 22 import java.util.regex.Pattern; 19 23 24 import javax.swing.BoxLayout; 25 import javax.swing.ButtonGroup; 20 26 import javax.swing.JCheckBox; 21 27 import javax.swing.JLabel; … … 23 29 import javax.swing.JOptionPane; 24 30 import javax.swing.JPanel; 31 import javax.swing.JRadioButton; 25 32 import javax.swing.JScrollPane; 33 import javax.swing.JTabbedPane; 26 34 27 35 import org.openstreetmap.josm.Main; 36 import org.openstreetmap.josm.data.APIDataSet; 28 37 import org.openstreetmap.josm.data.conflict.ConflictCollection; 38 import org.openstreetmap.josm.data.osm.Changeset; 29 39 import org.openstreetmap.josm.data.osm.DataSet; 30 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 34 44 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 35 45 import org.openstreetmap.josm.gui.historycombobox.SuggestingJHistoryComboBox; 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 36 47 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 48 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 49 import org.openstreetmap.josm.io.ChangesetProcessingType; 37 50 import org.openstreetmap.josm.io.OsmApi; 38 51 import org.openstreetmap.josm.io.OsmApiException; 39 52 import org.openstreetmap.josm.io.OsmApiInitializationException; 53 import org.openstreetmap.josm.io.OsmChangesetCloseException; 40 54 import org.openstreetmap.josm.io.OsmServerWriter; 41 55 import org.openstreetmap.josm.tools.GBC; 42 56 import org.openstreetmap.josm.tools.Shortcut; 57 import org.openstreetmap.josm.tools.WindowGeometry; 43 58 import org.xml.sax.SAXException; 44 59 … … 108 123 } 109 124 125 public boolean checkPreUploadConditions(OsmDataLayer layer) { 126 return checkPreUploadConditions(layer, new APIDataSet(layer.data)); 127 } 128 129 public boolean checkPreUploadConditions(OsmDataLayer layer, APIDataSet apiData) { 130 ConflictCollection conflicts = layer.getConflicts(); 131 if (conflicts !=null && !conflicts.isEmpty()) { 132 JOptionPane.showMessageDialog( 133 Main.parent, 134 tr("<html>There are unresolved conflicts in layer ''{0}''.<br>" 135 + "You have to resolve them first.<html>", layer.getName()), 136 tr("Warning"), 137 JOptionPane.WARNING_MESSAGE 138 ); 139 return false; 140 } 141 // Call all upload hooks in sequence. The upload confirmation dialog 142 // is one of these. 143 for(UploadHook hook : uploadHooks) 144 if(!hook.checkUpload(apiData.getPrimitivesToAdd(), apiData.getPrimitivesToUpdate(), apiData.getPrimitivesToDelete())) 145 return false; 146 147 return true; 148 } 149 110 150 public void actionPerformed(ActionEvent e) { 111 151 if (!isEnabled()) … … 121 161 } 122 162 123 ConflictCollection conflicts = Main.map.mapView.getEditLayer().getConflicts(); 124 if (conflicts !=null && !conflicts.isEmpty()) { 125 JOptionPane.showMessageDialog( 126 Main.parent, 127 tr("There are unresolved conflicts. You have to resolve these first."), 128 tr("Warning"), 129 JOptionPane.WARNING_MESSAGE 130 ); 131 Main.map.conflictDialog.showDialog(); 132 return; 133 } 134 135 final LinkedList<OsmPrimitive> add = new LinkedList<OsmPrimitive>(); 136 final LinkedList<OsmPrimitive> update = new LinkedList<OsmPrimitive>(); 137 final LinkedList<OsmPrimitive> delete = new LinkedList<OsmPrimitive>(); 138 for (OsmPrimitive osm : getCurrentDataSet().allPrimitives()) { 139 if (osm.get("josm/ignore") != null) { 140 continue; 141 } 142 if (osm.id == 0 && !osm.deleted) { 143 add.addLast(osm); 144 } else if (osm.modified && !osm.deleted) { 145 update.addLast(osm); 146 } else if (osm.deleted && osm.id != 0) { 147 delete.addFirst(osm); 148 } 149 } 150 151 if (add.isEmpty() && update.isEmpty() && delete.isEmpty()) { 163 APIDataSet apiData = new APIDataSet(Main.main.getCurrentDataSet()); 164 if (apiData.isEmpty()) { 152 165 JOptionPane.showMessageDialog( 153 166 Main.parent, 154 167 tr("No changes to upload."), 155 168 tr("Warning"), 156 JOptionPane. WARNING_MESSAGE169 JOptionPane.INFORMATION_MESSAGE 157 170 ); 158 171 return; 159 172 } 160 161 // Call all upload hooks in sequence. The upload confirmation dialog 162 // is one of these. 163 for(UploadHook hook : uploadHooks) 164 if(!hook.checkUpload(add, update, delete)) 165 return; 166 167 final Collection<OsmPrimitive> all = new LinkedList<OsmPrimitive>(); 168 all.addAll(add); 169 all.addAll(update); 170 all.addAll(delete); 171 172 Main.worker.execute(new UploadDiffTask(all)); 173 if (!checkPreUploadConditions(Main.map.mapView.getEditLayer(), apiData)) 174 return; 175 Main.worker.execute( 176 createUploadTask( 177 Main.map.mapView.getEditLayer(), 178 apiData.getPrimitives(), 179 UploadConfirmationHook.getUploadDialogPanel().getChangeset(), 180 UploadConfirmationHook.getUploadDialogPanel().getChangesetProcessingType() 181 ) 182 ); 173 183 } 174 184 … … 235 245 ); 236 246 switch(ret) { 237 case JOptionPane.CLOSED_OPTION: return; 238 case JOptionPane.CANCEL_OPTION: return; 239 case 0: synchronizePrimitive(id); break; 240 case 1: synchronizeDataSet(); break; 241 default: 242 // should not happen 243 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 247 case JOptionPane.CLOSED_OPTION: return; 248 case JOptionPane.CANCEL_OPTION: return; 249 case 0: synchronizePrimitive(id); break; 250 case 1: synchronizeDataSet(); break; 251 default: 252 // should not happen 253 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 244 254 } 245 255 } … … 275 285 ); 276 286 switch(ret) { 277 case JOptionPane.CLOSED_OPTION: return; 278 case 1: return; 279 case 0: synchronizeDataSet(); break; 280 default: 281 // should not happen 282 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 287 case JOptionPane.CLOSED_OPTION: return; 288 case 1: return; 289 case 0: synchronizeDataSet(); break; 290 default: 291 // should not happen 292 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 283 293 } 284 294 } … … 353 363 } 354 364 365 if (e instanceof OsmChangesetCloseException) { 366 ExceptionDialogUtil.explainOsmChangesetCloseException((OsmChangesetCloseException)e); 367 return; 368 } 355 369 if (e instanceof OsmApiException) { 356 370 OsmApiException ex = (OsmApiException)e; … … 441 455 442 456 443 class UploadConfirmationHook implements UploadHook { 444 445 private JCheckBox cbUseAtomicUpload; 446 447 protected JPanel buildChangesetControlPanel() { 448 JPanel pnl = new JPanel(); 449 pnl.setLayout(new FlowLayout(FlowLayout.LEFT)); 450 pnl.add(cbUseAtomicUpload = new JCheckBox(tr("upload all changes in one request"))); 451 cbUseAtomicUpload.setToolTipText(tr("Enable to upload all changes in one request, disable to use one request per changed primitive")); 452 boolean useAtomicUpload = Main.pref.getBoolean("osm-server.atomic-upload", true); 453 cbUseAtomicUpload.setSelected(useAtomicUpload); 454 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasChangesetSupport()); 455 return pnl; 457 static public class UploadConfirmationHook implements UploadHook { 458 static private UploadDialogPanel uploadDialogPanel; 459 460 static public UploadDialogPanel getUploadDialogPanel() { 461 if (uploadDialogPanel == null) { 462 uploadDialogPanel = new UploadDialogPanel(); 463 } 464 return uploadDialogPanel; 456 465 } 457 466 458 467 public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 459 460 JPanel p = new JPanel(new GridBagLayout()); 461 462 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer(); 463 464 if (!add.isEmpty()) { 465 p.add(new JLabel(tr("Objects to add:")), GBC.eol()); 466 JList l = new JList(add.toArray()); 467 l.setCellRenderer(renderer); 468 l.setVisibleRowCount(l.getModel().getSize() < 6 ? l.getModel().getSize() : 10); 469 p.add(new JScrollPane(l), GBC.eol().fill()); 470 } 471 472 if (!update.isEmpty()) { 473 p.add(new JLabel(tr("Objects to modify:")), GBC.eol()); 474 JList l = new JList(update.toArray()); 475 l.setCellRenderer(renderer); 476 l.setVisibleRowCount(l.getModel().getSize() < 6 ? l.getModel().getSize() : 10); 477 p.add(new JScrollPane(l), GBC.eol().fill()); 478 } 479 480 if (!delete.isEmpty()) { 481 p.add(new JLabel(tr("Objects to delete:")), GBC.eol()); 482 JList l = new JList(delete.toArray()); 483 l.setCellRenderer(renderer); 484 l.setVisibleRowCount(l.getModel().getSize() < 6 ? l.getModel().getSize() : 10); 485 p.add(new JScrollPane(l), GBC.eol().fill()); 486 } 487 488 p.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3)); 489 SuggestingJHistoryComboBox cmt = new SuggestingJHistoryComboBox(); 490 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>())); 491 cmt.setHistory(cmtHistory); 492 p.add(cmt, GBC.eol().fill(GBC.HORIZONTAL)); 493 //final JTextField cmt = new JTextField(lastCommitComment); 494 495 // configuration options for atomic upload 496 p.add(buildChangesetControlPanel(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 497 468 final UploadDialogPanel panel = getUploadDialogPanel(); 469 panel.setUploadedPrimitives(add, update, delete); 470 471 ExtendedDialog dialog = new ExtendedDialog( 472 Main.parent, 473 tr("Upload these changes?"), 474 new String[] {tr("Upload Changes"), tr("Cancel")} 475 ) { 476 @Override 477 public void setVisible(boolean visible) { 478 if (visible) { 479 new WindowGeometry( 480 panel.getClass().getName(), 481 WindowGeometry.centerInWindow(JOptionPane.getFrameForComponent(Main.parent), new Dimension(400,400)) 482 ).apply(this); 483 panel.startUserInput(); 484 } else { 485 new WindowGeometry(this).remember(panel.getClass().getName()); 486 } 487 super.setVisible(visible); 488 } 489 }; 490 491 dialog.setButtonIcons(new String[] {"upload.png", "cancel.png"}); 492 dialog.setContent(panel, false /* no scroll pane */); 498 493 while(true) { 499 int result = new ExtendedDialog(Main.parent, 500 tr("Upload these changes?"), 501 p, 502 new String[] {tr("Upload Changes"), tr("Cancel")}, 503 new String[] {"upload.png", "cancel.png"}).getValue(); 504 494 dialog.showDialog(); 495 int result = dialog.getValue(); 505 496 // cancel pressed 506 497 if (result != 1) return false; 507 508 498 // don't allow empty commit message 509 if ( cmt.getText().trim().length() < 3) {499 if (! panel.hasChangesetComment()) { 510 500 continue; 511 501 } 512 513 // store the history of comments 514 cmt.addCurrentItemToHistory(); 515 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory()); 516 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected()); 517 502 panel.rememberUserInput(); 518 503 break; 519 504 } … … 522 507 } 523 508 524 525 class UploadDiffTask extends PleaseWaitRunnable { 509 public UploadDiffTask createUploadTask(OsmDataLayer layer, Collection<OsmPrimitive> toUpload, Changeset changeset, ChangesetProcessingType changesetProcessingType) { 510 return new UploadDiffTask(layer, toUpload, changeset, changesetProcessingType); 511 } 512 513 public class UploadDiffTask extends PleaseWaitRunnable { 526 514 private boolean uploadCancelled = false; 527 515 private Exception lastException = null; 528 516 private Collection <OsmPrimitive> toUpload; 529 517 private OsmServerWriter writer; 530 531 public UploadDiffTask(Collection <OsmPrimitive> toUpload) { 532 super(tr("Uploading"),false /* don't ignore exceptions */); 518 private OsmDataLayer layer; 519 private Changeset changeset; 520 private ChangesetProcessingType changesetProcessingType; 521 522 private UploadDiffTask(OsmDataLayer layer, Collection <OsmPrimitive> toUpload, Changeset changeset, ChangesetProcessingType changesetProcessingType) { 523 super(tr("Uploading data for layer ''{0}''", layer.getName()),false /* don't ignore exceptions */); 533 524 this.toUpload = toUpload; 525 this.layer = layer; 526 this.changeset = changeset; 527 this.changesetProcessingType = changesetProcessingType == null ? ChangesetProcessingType.USE_NEW_AND_CLOSE : changesetProcessingType; 534 528 } 535 529 … … 537 531 writer = new OsmServerWriter(); 538 532 try { 539 writer.uploadOsm(getCurrentDataSet().version, toUpload, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 533 ProgressMonitor monitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 534 writer.uploadOsm(layer.data.version, toUpload, changeset,changesetProcessingType, monitor); 540 535 } catch (Exception sxe) { 541 536 if (uploadCancelled) { … … 554 549 // partially uploaded 555 550 // 556 getEditLayer().cleanupAfterUpload(writer.getProcessedPrimitives());557 DataSet.fireSelectionChanged( getEditLayer().data.getSelected());558 getEditLayer().fireDataChange();551 layer.cleanupAfterUpload(writer.getProcessedPrimitives()); 552 DataSet.fireSelectionChanged(layer.data.getSelected()); 553 layer.fireDataChange(); 559 554 if (lastException != null) { 560 555 handleFailedUpload(lastException); 556 } else { 557 layer.onPostUploadToServer(); 561 558 } 562 559 } … … 565 562 uploadCancelled = true; 566 563 if (writer != null) { 567 writer.disconnectActiveConnection(); 564 writer.cancel(); 565 } 566 } 567 568 public boolean isSuccessful() { 569 return !isCancelled() && !isFailed(); 570 } 571 572 public boolean isCancelled() { 573 return uploadCancelled; 574 } 575 576 public boolean isFailed() { 577 return lastException != null; 578 } 579 } 580 581 /** 582 * The panel displaying information about primitives to upload and providing 583 * UI widgets for entering the changeset comment and other configuration 584 * settings. 585 * 586 */ 587 static public class UploadDialogPanel extends JPanel { 588 589 private JList lstAdd; 590 private JList lstUpdate; 591 private JList lstDelete; 592 private JLabel lblAdd; 593 private JLabel lblUpdate; 594 private JLabel lblDelete; 595 private JPanel pnlLists; 596 private JCheckBox cbUseAtomicUpload; 597 private SuggestingJHistoryComboBox cmt; 598 private TagEditorPanel tagEditorPanel; 599 private JTabbedPane southTabbedPane; 600 private ButtonGroup bgChangesetHandlingOptions; 601 private Map<ChangesetProcessingType, JRadioButton> rbChangesetHandlingOptions; 602 603 protected JPanel buildListsPanel() { 604 pnlLists = new JPanel(); 605 pnlLists.setLayout(new GridBagLayout()); 606 607 return pnlLists; 608 } 609 610 protected JPanel buildChangesetHandlingControlPanel() { 611 JPanel pnl = new JPanel(); 612 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 613 bgChangesetHandlingOptions = new ButtonGroup(); 614 rbChangesetHandlingOptions = new HashMap<ChangesetProcessingType, JRadioButton>(); 615 ChangesetProcessingTypeChangedAction a = new ChangesetProcessingTypeChangedAction(); 616 for(ChangesetProcessingType type: ChangesetProcessingType.values()) { 617 rbChangesetHandlingOptions.put(type, new JRadioButton()); 618 rbChangesetHandlingOptions.get(type).addActionListener(a); 619 } 620 JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE); 621 rb.setText(tr("Use a new changeset and close it")); 622 rb.setToolTipText(tr("Select to upload the data using a new changeset and to close the changeset after the upload")); 623 624 rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN); 625 rb.setText(tr("Use a new changeset and leave it open")); 626 rb.setToolTipText(tr("Select to upload the data using a new changeset and to leave the changeset open after the upload")); 627 628 pnl.add(new JLabel(tr("Upload to a new or to an existing changeset?"))); 629 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE)); 630 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN)); 631 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE)); 632 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN)); 633 634 for(ChangesetProcessingType type: ChangesetProcessingType.values()) { 635 rbChangesetHandlingOptions.get(type).setVisible(false); 636 bgChangesetHandlingOptions.add(rbChangesetHandlingOptions.get(type)); 637 } 638 return pnl; 639 } 640 641 protected JPanel buildChangesetControlPanel() { 642 JPanel pnl = new JPanel(); 643 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 644 pnl.add(cbUseAtomicUpload = new JCheckBox(tr("upload all changes in one request"))); 645 cbUseAtomicUpload.setToolTipText(tr("Enable to upload all changes in one request, disable to use one request per changed primitive")); 646 boolean useAtomicUpload = Main.pref.getBoolean("osm-server.atomic-upload", true); 647 cbUseAtomicUpload.setSelected(useAtomicUpload); 648 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasSupportForDiffUploads()); 649 650 pnl.add(buildChangesetHandlingControlPanel()); 651 return pnl; 652 } 653 654 protected JPanel buildUploadControlPanel() { 655 JPanel pnl = new JPanel(); 656 pnl.setLayout(new GridBagLayout()); 657 pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3)); 658 cmt = new SuggestingJHistoryComboBox(); 659 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>())); 660 cmt.setHistory(cmtHistory); 661 pnl.add(cmt, GBC.eol().fill(GBC.HORIZONTAL)); 662 663 // configuration options for atomic upload 664 // 665 pnl.add(buildChangesetControlPanel(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 666 return pnl; 667 } 668 669 protected void build() { 670 setLayout(new GridBagLayout()); 671 GridBagConstraints gc = new GridBagConstraints(); 672 gc.fill = GridBagConstraints.BOTH; 673 gc.weightx = 1.0; 674 gc.weighty = 1.0; 675 add(buildListsPanel(), gc); 676 677 southTabbedPane = new JTabbedPane(); 678 southTabbedPane.add(buildUploadControlPanel()); 679 tagEditorPanel = new TagEditorPanel(); 680 southTabbedPane.add(tagEditorPanel); 681 southTabbedPane.setTitleAt(0, tr("Settings")); 682 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 683 JPanel pnl = new JPanel(); 684 pnl.setLayout(new BorderLayout()); 685 pnl.add(southTabbedPane,BorderLayout.CENTER); 686 gc.fill = GridBagConstraints.HORIZONTAL; 687 gc.gridy = 1; 688 gc.weightx = 1.0; 689 gc.weighty = 0.0; 690 add(pnl, gc); 691 } 692 693 694 protected UploadDialogPanel() { 695 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer(); 696 697 lstAdd = new JList(); 698 lstAdd.setCellRenderer(renderer); 699 lstAdd.setVisibleRowCount(Math.min(lstAdd.getModel().getSize(), 10)); 700 701 lstUpdate = new JList(); 702 lstUpdate.setCellRenderer(renderer); 703 lstUpdate.setVisibleRowCount(Math.min(lstUpdate.getModel().getSize(), 10)); 704 705 lstDelete = new JList(); 706 lstDelete.setCellRenderer(renderer); 707 lstDelete.setVisibleRowCount(Math.min(lstDelete.getModel().getSize(), 10)); 708 build(); 709 } 710 711 public void setUploadedPrimitives(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 712 lstAdd.setListData(add.toArray()); 713 lstUpdate.setListData(update.toArray()); 714 lstDelete.setListData(delete.toArray()); 715 716 717 GridBagConstraints gcLabel = new GridBagConstraints(); 718 gcLabel.fill = GridBagConstraints.HORIZONTAL; 719 gcLabel.weightx = 1.0; 720 gcLabel.weighty = 0.0; 721 gcLabel.anchor = GridBagConstraints.FIRST_LINE_START; 722 723 GridBagConstraints gcList = new GridBagConstraints(); 724 gcList.fill = GridBagConstraints.BOTH; 725 gcList.weightx = 1.0; 726 gcList.weighty = 1.0; 727 gcList.anchor = GridBagConstraints.CENTER; 728 pnlLists.removeAll(); 729 int y = -1; 730 if (!add.isEmpty()) { 731 y++; 732 gcLabel.gridy = y; 733 pnlLists.add(lblAdd = new JLabel(tr("Objects to add:")), gcLabel); 734 y++; 735 gcList.gridy = y; 736 pnlLists.add(new JScrollPane(lstAdd), gcList); 737 } 738 if (!update.isEmpty()) { 739 y++; 740 gcLabel.gridy = y; 741 pnlLists.add(lblUpdate = new JLabel(tr("Objects to modify:")), gcLabel); 742 y++; 743 gcList.gridy = y; 744 pnlLists.add(new JScrollPane(lstUpdate), gcList); 745 } 746 if (!delete.isEmpty()) { 747 y++; 748 gcLabel.gridy = y; 749 pnlLists.add(lblDelete = new JLabel(tr("Objects to delete:")), gcLabel); 750 y++; 751 gcList.gridy = y; 752 pnlLists.add(new JScrollPane(lstDelete), gcList); 753 } 754 } 755 756 public boolean hasChangesetComment() { 757 if (!getChangesetProcessingType().isUseNew()) 758 return true; 759 return cmt.getText().trim().length() >= 3; 760 } 761 762 public void rememberUserInput() { 763 // store the history of comments 764 cmt.addCurrentItemToHistory(); 765 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory()); 766 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected()); 767 } 768 769 public void startUserInput() { 770 tagEditorPanel.initAutoCompletion(Main.main.getEditLayer()); 771 initChangesetProcessingType(); 772 cmt.getEditor().selectAll(); 773 cmt.requestFocus(); 774 } 775 776 public ChangesetProcessingType getChangesetProcessingType() { 777 ChangesetProcessingType changesetProcessingType = null; 778 for (ChangesetProcessingType type: ChangesetProcessingType.values()) { 779 if (rbChangesetHandlingOptions.get(type).isSelected()) { 780 changesetProcessingType = type; 781 break; 782 } 783 } 784 return changesetProcessingType == null ? 785 ChangesetProcessingType.USE_NEW_AND_CLOSE : 786 changesetProcessingType; 787 } 788 789 public Changeset getChangeset() { 790 Changeset changeset = new Changeset(); 791 tagEditorPanel.getModel().applyToPrimitive(changeset); 792 changeset.put("comment", cmt.getText()); 793 return changeset; 794 } 795 796 protected void initChangesetProcessingType() { 797 for (ChangesetProcessingType type: ChangesetProcessingType.values()) { 798 // show options for new changeset, disable others 799 // 800 rbChangesetHandlingOptions.get(type).setVisible(type.isUseNew()); 801 } 802 if (OsmApi.getOsmApi().getCurrentChangeset() != null) { 803 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset(); 804 for (ChangesetProcessingType type: ChangesetProcessingType.values()) { 805 // show options for using existing changeset 806 // 807 if (!type.isUseNew()) { 808 rbChangesetHandlingOptions.get(type).setVisible(true); 809 } 810 } 811 JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE); 812 rb.setText(tr("Use the existing changeset {0} and close it after upload",cs.getId())); 813 rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to close the changeset after this upload",cs.getId())); 814 815 rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN); 816 rb.setText(tr("Use the existing changeset {0} and leave it open",cs.getId())); 817 rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to leave the changeset open for further uploads",cs.getId())); 818 819 rbChangesetHandlingOptions.get(getChangesetProcessingType()).setSelected(true); 820 821 } else { 822 ChangesetProcessingType type = getChangesetProcessingType(); 823 if (!type.isUseNew()) { 824 type = ChangesetProcessingType.USE_NEW_AND_CLOSE; 825 } 826 rbChangesetHandlingOptions.get(type).setSelected(true); 827 } 828 } 829 830 class ChangesetProcessingTypeChangedAction implements ActionListener { 831 public void actionPerformed(ActionEvent e) { 832 ChangesetProcessingType type = getChangesetProcessingType(); 833 if (type.isUseNew()) { 834 tagEditorPanel.setEnabled(true); 835 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 836 cmt.setEnabled(true); 837 } else { 838 tagEditorPanel.setEnabled(false); 839 cmt.setEnabled(false); 840 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset(); 841 if (cs != null) { 842 tagEditorPanel.getModel().initFromPrimitive(cs); 843 southTabbedPane.setTitleAt(1, tr("Tags of changeset {0} (read-only)", cs.getId())); 844 cmt.setText(cs.get("comment" == null ? "" : cs.get("comment"))); 845 } 846 } 568 847 } 569 848 } -
/trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r2024 r2060 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.AWTEvent; 7 import java.awt.Cursor; 8 import java.awt.EventQueue; 9 import java.awt.Toolkit; 10 import java.awt.event.AWTEventListener; 6 11 import java.awt.event.ActionEvent; 7 12 import java.awt.event.InputEvent; 8 13 import java.awt.event.KeyEvent; 9 14 import java.awt.event.MouseEvent; 15 import java.util.Collection; 10 16 import java.util.Collections; 17 import java.util.HashSet; 11 18 12 19 import org.openstreetmap.josm.Main; 13 20 import org.openstreetmap.josm.command.Command; 14 21 import org.openstreetmap.josm.command.DeleteCommand; 22 import org.openstreetmap.josm.data.osm.Node; 15 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 24 import org.openstreetmap.josm.data.osm.Relation; 25 import org.openstreetmap.josm.data.osm.Way; 17 26 import org.openstreetmap.josm.data.osm.WaySegment; 18 27 import org.openstreetmap.josm.gui.MapFrame; … … 38 47 * @author imi 39 48 */ 40 public class DeleteAction extends MapMode { 49 50 /** 51 * This class contains stubs for highlighting affected primitives when affected. 52 * However, way segments can be deleted as well, but cannot be highlighted 53 * alone. If the highlight feature for this delete action is to be implemented 54 * properly, highlighting way segments must be possible first. --xeen, 2009-09-02 55 */ 56 public class DeleteAction extends MapMode implements AWTEventListener { 57 //private boolean drawTargetHighlight; 58 private boolean drawTargetCursor; 59 //private Collection<? extends OsmPrimitive> oldPrims = null; 60 61 // Cache previous mouse event (needed when only the modifier keys are 62 // pressed but the mouse isn't moved) 63 private MouseEvent oldEvent = null; 64 65 private enum Cursors { 66 none, 67 node, 68 segment, 69 way_node_only, 70 way_normal, 71 way_only; 72 73 private Cursor c = null; 74 // This loads and caches the cursor for each 75 public Cursor cursor() { 76 if(c == null) { 77 String nm = "delete_" + this.name().toLowerCase(); 78 // "None" has no special icon 79 nm = nm.equals("delete_none") ? "delete" : nm; 80 this.c = ImageProvider.getCursor("normal", nm); 81 } 82 return c; 83 } 84 } 85 private Cursors currCursor = Cursors.none; 41 86 42 87 /** … … 57 102 if (!isEnabled()) 58 103 return; 104 //drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true); 105 drawTargetCursor = Main.pref.getBoolean("draw.target-cursor", true); 106 59 107 Main.map.mapView.addMouseListener(this); 108 Main.map.mapView.addMouseMotionListener(this); 109 // This is required to update the cursors when ctrl/shift/alt is pressed 110 try { 111 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 112 } catch (SecurityException ex) {} 113 114 currCursor = Cursors.none; 60 115 } 61 116 … … 63 118 super.exitMode(); 64 119 Main.map.mapView.removeMouseListener(this); 120 Main.map.mapView.removeMouseMotionListener(this); 121 try { 122 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 123 } catch (SecurityException ex) {} 65 124 } 66 125 … … 94 153 95 154 /** 155 * Listen to mouse move to be able to update the cursor (and highlights) 156 * @param MouseEvent The mouse event that has been captured 157 */ 158 @Override public void mouseMoved(MouseEvent e) { 159 oldEvent = e; 160 updateCursor(e, e.getModifiers()); 161 } 162 163 /** 164 * This function handles all work related to updating the cursor and 165 * highlights. For now, only the cursor is enabled because highlighting 166 * requires WaySegment to be highlightable. 167 * 168 * Normally the mouse event also contains the modifiers. However, when the 169 * mouse is not moved and only modifier keys are pressed, no mouse event 170 * occurs. We can use AWTEvent to catch those but still lack a proper 171 * mouseevent. Instead we copy the previous event and only update the 172 * modifiers. 173 * 174 * @param MouseEvent 175 * @parm int modifiers 176 */ 177 private void updateCursor(MouseEvent e, int modifiers) { 178 if(!Main.map.mapView.isActiveLayerVisible() || e == null) 179 return; 180 181 // Clean old highlights 182 //cleanOldHighlights(); 183 184 Command c = buildDeleteCommands(e, modifiers, true); 185 if(c == null) { 186 setCursor(Cursors.none); 187 return; 188 } 189 190 Collection<OsmPrimitive> prims = new HashSet<OsmPrimitive>(); 191 Collection<OsmPrimitive> mods = new HashSet<OsmPrimitive>(); 192 c.fillModifiedData(mods, prims, prims); 193 194 if(prims.size() == 0 && mods.size() == 0) { 195 // Default-Cursor 196 setCursor(Cursors.none); 197 return; 198 } 199 200 // There are no deleted parts if solely a way segment is deleted 201 // This is no the case when actually deleting only a segment but that 202 // segment happens to be the whole way. This is an acceptable error 203 // though 204 if(prims.size() == 0) { 205 setCursor(Cursors.segment); 206 } else if(prims.size() == 1 && prims.toArray()[0] instanceof Node) { 207 setCursor(Cursors.node); 208 } else if(prims.size() == 1 && prims.toArray()[0] instanceof Way) { 209 setCursor(Cursors.way_only); 210 } else { 211 // Decide between non-accel click where "useless" nodes are deleted 212 // and ctrl-click where nodes and ways are deleted 213 boolean ctrl = (modifiers & ActionEvent.CTRL_MASK) != 0; 214 if(ctrl) { 215 setCursor(Cursors.way_node_only); 216 } else { 217 setCursor(Cursors.way_normal); 218 } 219 220 } 221 222 // Needs to implement WaySegment highlight first 223 /*if(drawTargetHighlight) { 224 // Add new highlights 225 for(OsmPrimitive p : prims) { 226 p.highlighted = true; 227 } 228 oldPrims = prims; 229 }*/ 230 231 // We only need to repaint if the highlights changed 232 //Main.map.mapView.repaint(); 233 } 234 235 /** 236 * Small helper function that cleans old highlights 237 */ 238 /*private void cleanOldHighlights() { 239 if(oldPrims == null) 240 return; 241 for(OsmPrimitive p: oldPrims) { 242 p.highlighted = false; 243 } 244 }*/ 245 246 /** 96 247 * If user clicked with the left button, delete the nearest object. 97 248 * position. … … 107 258 Main.map.mapView.requestFocus(); 108 259 109 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 110 boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 111 boolean alt = (e.getModifiers() & (ActionEvent.ALT_MASK|InputEvent.ALT_GRAPH_MASK)) != 0; 260 Command c = buildDeleteCommands(e, e.getModifiers(), false); 261 if (c != null) { 262 Main.main.undoRedo.add(c); 263 } 264 265 getCurrentDataSet().setSelected(); 266 Main.map.mapView.repaint(); 267 } 268 269 @Override public String getModeHelpText() { 270 return tr("Click to delete. Shift: delete way segment. Alt: don't delete unused nodes when deleting a way. Ctrl: delete referring objects."); 271 } 272 273 @Override public boolean layerIsSupported(Layer l) { 274 return l instanceof OsmDataLayer; 275 } 276 277 @Override 278 protected void updateEnabledState() { 279 setEnabled(Main.map != null && Main.map.mapView != null && Main.map.mapView.isActiveLayerDrawable()); 280 } 281 282 /** 283 * Deletes the relation in the context of the given layer. Also notifies 284 * {@see RelationDialogManager} and {@see OsmDataLayer#fireDataChange()} events. 285 * 286 * @param layer the layer in whose context the relation is deleted. Must not be null. 287 * @param toDelete the relation to be deleted. Must not be null. 288 * @exception IllegalArgumentException thrown if layer is null 289 * @exception IllegalArgumentException thrown if toDelete is nul 290 */ 291 public static void deleteRelation(OsmDataLayer layer, Relation toDelete) { 292 if (layer == null) 293 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "layer")); 294 if (toDelete == null) 295 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "toDelete")); 296 297 Command cmd = DeleteCommand.delete(layer, Collections.singleton(toDelete)); 298 if (cmd != null) { 299 // cmd can be null if the user cancels dialogs DialogCommand displays 300 Main.main.undoRedo.add(cmd); 301 RelationDialogManager.getRelationDialogManager().close(layer, toDelete); 302 layer.fireDataChange(); 303 } 304 } 305 306 /** 307 * This function takes any mouse event argument and builds the list of elements 308 * that should be deleted but does not actually delete them. 309 * @param e MouseEvent from which modifiers and position are taken 310 * @param int modifiers For explanation: @see updateCursor 311 * @param Simulate Set to true if the user should be bugged with additional 312 * dialogs 313 * @return 314 */ 315 private Command buildDeleteCommands(MouseEvent e, int modifiers, boolean simulate) { 316 // Note: CTRL is the only modifier that is checked in MouseMove, don't 317 // forget updating it there 318 boolean ctrl = (modifiers & ActionEvent.CTRL_MASK) != 0; 319 boolean shift = (modifiers & ActionEvent.SHIFT_MASK) != 0; 320 boolean alt = (modifiers & (ActionEvent.ALT_MASK|InputEvent.ALT_GRAPH_MASK)) != 0; 112 321 113 322 OsmPrimitive sel = Main.map.mapView.getNearestNode(e.getPoint()); … … 119 328 c = DeleteCommand.deleteWaySegment(getEditLayer(),ws); 120 329 } else if (ctrl) { 121 c = DeleteCommand.deleteWithReferences(getEditLayer(),Collections.singleton((OsmPrimitive)ws.way)); 330 c = DeleteCommand.deleteWithReferences(getEditLayer(),Collections.singleton((OsmPrimitive)ws.way),true); 122 331 } else { 123 c = DeleteCommand.delete(getEditLayer(),Collections.singleton((OsmPrimitive)ws.way), !alt); 332 c = DeleteCommand.delete(getEditLayer(),Collections.singleton((OsmPrimitive)ws.way), !alt, simulate); 124 333 } 125 334 } … … 127 336 c = DeleteCommand.deleteWithReferences(getEditLayer(),Collections.singleton(sel)); 128 337 } else { 129 c = DeleteCommand.delete(getEditLayer(),Collections.singleton(sel), !alt); 130 } 131 if (c != null) { 132 Main.main.undoRedo.add(c); 133 } 134 135 getCurrentDataSet().setSelected(); 136 Main.map.mapView.repaint(); 137 } 138 139 @Override public String getModeHelpText() { 140 return tr("Click to delete. Shift: delete way segment. Alt: don't delete unused nodes when deleting a way. Ctrl: delete referring objects."); 141 } 142 143 @Override public boolean layerIsSupported(Layer l) { 144 return l instanceof OsmDataLayer; 145 } 146 147 @Override 148 protected void updateEnabledState() { 149 setEnabled(Main.map != null && Main.map.mapView != null && Main.map.mapView.isActiveLayerDrawable()); 150 } 151 152 /** 153 * Deletes the relation in the context of the given layer. Also notifies 154 * {@see RelationDialogManager} and {@see OsmDataLayer#fireDataChange()} events. 155 * 156 * @param layer the layer in whose context the relation is deleted. Must not be null. 157 * @param toDelete the relation to be deleted. Must not be null. 158 * @exception IllegalArgumentException thrown if layer is null 159 * @exception IllegalArgumentException thrown if toDelete is nul 160 */ 161 public static void deleteRelation(OsmDataLayer layer, Relation toDelete) { 162 if (layer == null) 163 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "layer")); 164 if (toDelete == null) 165 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "toDelete")); 166 if (toDelete == null) 167 return; 168 Command cmd = DeleteCommand.delete(layer, Collections.singleton(toDelete)); 169 if (cmd != null) { 170 // cmd can be null if the user cancels dialogs DialogCommand displays 171 // 172 Main.main.undoRedo.add(cmd); 173 RelationDialogManager.getRelationDialogManager().close(layer, toDelete); 174 layer.fireDataChange(); 175 } 338 c = DeleteCommand.delete(getEditLayer(),Collections.singleton(sel), !alt, simulate); 339 } 340 341 return c; 342 } 343 344 /** 345 * This function sets the given cursor in a safe way. This implementation 346 * differs from the on in DrawAction (it is favorable, too). 347 * FIXME: Update DrawAction to use this "setCursor-style" and move function 348 * to MapMode. 349 * @param c 350 */ 351 private void setCursor(final Cursors c) { 352 if(currCursor.equals(c) || (!drawTargetCursor && currCursor.equals(Cursors.none))) 353 return; 354 try { 355 // We invoke this to prevent strange things from happening 356 EventQueue.invokeLater(new Runnable() { 357 public void run() { 358 // Don't change cursor when mode has changed already 359 if(!(Main.map.mapMode instanceof DeleteAction)) 360 return; 361 362 Main.map.mapView.setCursor(c.cursor()); 363 //System.out.println("Set cursor to: " + c.name()); 364 } 365 }); 366 currCursor = c; 367 } catch(Exception e) {} 368 } 369 370 /** 371 * This is required to update the cursors when ctrl/shift/alt is pressed 372 */ 373 public void eventDispatched(AWTEvent e) { 374 // We don't have a mouse event, so we pass the old mouse event but the 375 // new modifiers. 376 updateCursor(oldEvent, ((InputEvent)e).getModifiers()); 176 377 } 177 378 } -
/trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2024 r2060 765 765 Way way = null; 766 766 for (Way w : getCurrentDataSet().ways) { 767 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {767 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 768 768 continue; 769 769 } -
/trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r2024 r2060 465 465 if(s.size() > max) 466 466 { 467 if(1 != new ExtendedDialog(Main.parent, tr("Move elements"), 468 tr("You did move more than {0} elements. " 469 + "Moving a large number of elements is often an error.\n" 470 + "Really move them?", max), 471 new String[] {tr("Move them"), tr("Undo move")}, 472 new String[] {"reorder.png", "cancel.png"}).getValue()) 467 ExtendedDialog ed = new ExtendedDialog( 468 Main.parent, 469 tr("Move elements"), 470 new String[] {tr("Move them"), tr("Undo move")}); 471 ed.setButtonIcons(new String[] {"reorder.png", "cancel.png"}); 472 ed.setContent(tr("You moved more than {0} elements. " 473 + "Moving a large number of elements is often an error.\n" 474 + "Really move them?", max)); 475 ed.toggleEnable("movedManyElements"); 476 ed.setToggleCheckboxText(tr("Always move and don't show dialog again")); 477 ed.showDialog(); 478 479 if(ed.getValue() != 1 && ed.getValue() != ExtendedDialog.DialogNotShown) 473 480 { 474 481 Main.main.undoRedo.undo(); -
/trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r2024 r2060 227 227 228 228 switch (mode) { 229 case NONE: 230 return false; 231 case MISSING_KEY: 232 return osm.get(key) == null; 233 case ANY: 234 return true; 235 case ANY_VALUE: 236 return osm.get(key) != null; 237 case ANY_KEY: 238 for (String v:osm.getKeys().values()) { 239 if (v.equals(value)) 240 return true; 241 } 242 return false; 243 case EXACT: 244 return value.equals(osm.get(key)); 245 case ANY_KEY_REGEXP: 246 for (String v:osm.getKeys().values()) { 247 if (valuePattern.matcher(v).matches()) 248 return true; 249 } 250 return false; 251 case ANY_VALUE_REGEXP: 252 case EXACT_REGEXP: 253 for (Entry<String, String> entry:osm.entrySet()) { 254 if (keyPattern.matcher(entry.getKey()).matches()) { 255 if (mode == Mode.ANY_VALUE_REGEXP 256 || valuePattern.matcher(entry.getValue()).matches()) 229 case NONE: 230 return false; 231 case MISSING_KEY: 232 return osm.get(key) == null; 233 case ANY: 234 return true; 235 case ANY_VALUE: 236 return osm.get(key) != null; 237 case ANY_KEY: 238 for (String v:osm.getKeys().values()) { 239 if (v.equals(value)) 257 240 return true; 258 241 } 259 } 260 return false; 261 case MISSING_KEY_REGEXP: 262 for (String k:osm.keySet()) { 263 if (keyPattern.matcher(k).matches()) 264 return false; 265 } 266 return true; 242 return false; 243 case EXACT: 244 return value.equals(osm.get(key)); 245 case ANY_KEY_REGEXP: 246 for (String v:osm.getKeys().values()) { 247 if (valuePattern.matcher(v).matches()) 248 return true; 249 } 250 return false; 251 case ANY_VALUE_REGEXP: 252 case EXACT_REGEXP: 253 for (Entry<String, String> entry:osm.entrySet()) { 254 if (keyPattern.matcher(entry.getKey()).matches()) { 255 if (mode == Mode.ANY_VALUE_REGEXP 256 || valuePattern.matcher(entry.getValue()).matches()) 257 return true; 258 } 259 } 260 return false; 261 case MISSING_KEY_REGEXP: 262 for (String k:osm.keySet()) { 263 if (keyPattern.matcher(k).matches()) 264 return false; 265 } 266 return true; 267 267 } 268 268 throw new AssertionError("Missed state"); … … 402 402 private static class Modified extends Match { 403 403 @Override public boolean match(OsmPrimitive osm) { 404 return osm. modified|| osm.id== 0;404 return osm.isModified() || osm.getId() == 0; 405 405 } 406 406 @Override public String toString() {return "modified";} -
/trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java
r2024 r2060 48 48 Map<Long, String> ids = idReader.parseIds(in); 49 49 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) { 50 if (ids.containsKey(osm. id) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.id))) {50 if (ids.containsKey(osm.getId()) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.getId()))) { 51 51 if (mode == SearchAction.SearchMode.remove) { 52 52 sel.remove(osm); -
/trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r2024 r2060 36 36 super.executeCommand(); 37 37 osm.cloneFrom(newOsm); 38 osm. modified= true;38 osm.setModified(true); 39 39 return true; 40 40 } … … 47 47 String msg = ""; 48 48 switch(OsmPrimitiveType.from(osm)) { 49 case NODE: msg = marktr("Change node {0}"); break; 50 case WAY: msg = marktr("Change way {0}"); break; 51 case RELATION: msg = marktr("Change relation {0}"); break; 49 case NODE: msg = marktr("Change node {0}"); break; 50 case WAY: msg = marktr("Change way {0}"); break; 51 case RELATION: msg = marktr("Change relation {0}"); break; 52 52 } 53 53 return new DefaultMutableTreeNode( -
/trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r2024 r2060 77 77 if (value == null) { 78 78 for (OsmPrimitive osm : objects) { 79 osm. modified= true;79 osm.setModified(true); 80 80 osm.remove(key); 81 81 } 82 82 } else { 83 83 for (OsmPrimitive osm : objects) { 84 osm. modified= true;84 osm.setModified(true); 85 85 osm.put(key, value); 86 86 } -
/trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r2024 r2060 51 51 relation.getMember(position).role = newRole; 52 52 53 oldModified = relation. modified;54 relation. modified= true;53 oldModified = relation.isModified(); 54 relation.setModified(true); 55 55 return true; 56 56 } … … 58 58 @Override public void undoCommand() { 59 59 relation.getMember(position).role = oldRole; 60 relation. modified=oldModified;60 relation.setModified(oldModified); 61 61 } 62 62 -
/trunk/src/org/openstreetmap/josm/command/Command.java
r2024 r2060 89 89 e.getKey().cloneFrom(e.getValue()); 90 90 } 91 getLayer().setModified(true);92 91 } 93 92 … … 114 113 if (o != null) 115 114 return o; 116 Main.debug("unable to find osm with id: " + osm. id+ " hashCode: " + osm.hashCode());115 Main.debug("unable to find osm with id: " + osm.getId() + " hashCode: " + osm.hashCode()); 117 116 for (OsmPrimitive t : cloneMap.keySet()) { 118 117 OsmPrimitive to = cloneMap.get(t); 119 Main.debug("now: " + t. id+ " hashCode: " + t.hashCode());120 Main.debug("orig: " + to. id+ " hashCode: " + to.hashCode());118 Main.debug("now: " + t.getId() + " hashCode: " + t.hashCode()); 119 Main.debug("orig: " + to.getId() + " hashCode: " + to.hashCode()); 121 120 } 122 121 return o; -
/trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java
r2024 r2060 45 45 return new DefaultMutableTreeNode( 46 46 new JLabel( 47 tr("Resolve conflicts in coordinates in {0}",conflict.getMy(). id),47 tr("Resolve conflicts in coordinates in {0}",conflict.getMy().getId()), 48 48 ImageProvider.get("data", "object"), 49 49 JLabel.HORIZONTAL -
/trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r2024 r2060 43 43 */ 44 44 public class DeleteCommand extends Command { 45 46 45 /** 47 46 * The primitives that get deleted. … … 157 156 * If a way is deleted, only the way and no nodes are deleted. 158 157 * 158 * @param layer 159 159 * @param selection The list of all object to be deleted. 160 * @param simulate Set to true if the user should not be bugged with additional dialogs 160 161 * @return command A command to perform the deletions, or null of there is nothing to delete. 161 162 */ 162 public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) { 163 public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean simulate) { 163 164 CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(layer.data); 164 165 for (OsmPrimitive osm : selection) { … … 168 169 if (v.data.isEmpty()) 169 170 return null; 170 if (!checkAndConfirmOutlyingDeletes(layer,v.data)) 171 if (!checkAndConfirmOutlyingDeletes(layer,v.data) && !simulate) 171 172 return null; 172 173 return new DeleteCommand(layer,v.data); 173 174 } 174 175 175 private static int testRelation(Relation ref, OsmPrimitive osm) { 176 public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) { 177 return deleteWithReferences(layer, selection, false); 178 } 179 180 private static int testRelation(Relation ref, OsmPrimitive osm, boolean simulate) { 181 // If this delete action is simulated, do not bug the user with dialogs 182 // and assume the relations should be deleted 183 if(simulate) 184 return 1; 185 176 186 String role = new String(); 177 187 for (RelationMember m : ref.getMembers()) { … … 181 191 } 182 192 } 183 if (role.length() > 0) 184 return new ExtendedDialog(Main.parent, tr("Conflicting relation"), tr( 185 "Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", 186 osm.getDisplayName(DefaultNameFormatter.getInstance()), ref.getDisplayName(DefaultNameFormatter.getInstance()), role), new String[] { tr("Delete from relation"), 187 tr("Cancel") }, new String[] { "dialogs/delete.png", "cancel.png" }).getValue(); 188 else 189 return new ExtendedDialog(Main.parent, tr("Conflicting relation"), tr( 190 "Selection \"{0}\" is used by relation \"{1}\".\nDelete from relation?", 191 osm.getDisplayName(DefaultNameFormatter.getInstance()), 192 ref.getDisplayName(DefaultNameFormatter.getInstance())), new String[] { tr("Delete from relation"), tr("Cancel") }, new String[] { 193 "dialogs/delete.png", "cancel.png" }).getValue(); 193 ExtendedDialog dialog = new ExtendedDialog( 194 Main.parent, 195 tr("Conflicting relation"), 196 new String[] { tr("Delete from relation"),tr("Cancel") } 197 ); 198 dialog.setButtonIcons( new String[] { "dialogs/delete.png", "cancel.png" }); 199 if (role.length() > 0) { 200 dialog.setContent( 201 tr( 202 "<html>Selection \"{0}\" is used by relation \"{1}\" with role {2}.<br>Delete from relation?</html>", 203 osm.getDisplayName(DefaultNameFormatter.getInstance()), 204 ref.getDisplayName(DefaultNameFormatter.getInstance()), 205 role 206 ) 207 ); 208 dialog.showDialog(); 209 return dialog.getValue(); 210 } else { 211 dialog.setContent( 212 tr( 213 "<html>Selection \"{0}\" is used by relation \"{1}\".<br>Delete from relation?</html>", 214 osm.getDisplayName(DefaultNameFormatter.getInstance()), 215 ref.getDisplayName(DefaultNameFormatter.getInstance()) 216 ) 217 ); 218 dialog.showDialog(); 219 return dialog.getValue(); 220 } 194 221 } 195 222 196 223 public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) { 197 return delete(layer, selection, true); 224 return delete(layer, selection, true, false); 198 225 } 199 226 … … 243 270 * @param selection The objects to delete. 244 271 * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well 272 * @param simulate Set to true if the user should not be bugged with additional questions 245 273 * @return command a command to perform the deletions, or null if there is nothing to delete. 246 274 */ 247 public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay) { 275 public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, 276 boolean alsoDeleteNodesInWay) { 277 return delete(layer, selection, alsoDeleteNodesInWay, false); 278 } 279 280 public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, 281 boolean alsoDeleteNodesInWay, boolean simulate) { 248 282 if (selection.isEmpty()) 249 283 return null; … … 260 294 } 261 295 262 if (!checkAndConfirmOutlyingDeletes(layer,primitivesToDelete)) 296 if (!simulate && !checkAndConfirmOutlyingDeletes(layer,primitivesToDelete)) 263 297 return null; 264 298 … … 273 307 waysToBeChanged.add((Way) ref); 274 308 } else if (ref instanceof Relation) { 275 if (testRelation((Relation) ref, osm) == 1) { 309 if (testRelation((Relation) ref, osm, simulate) == 1) { 276 310 Collection<OsmPrimitive> relset = relationsToBeChanged.get(ref); 277 311 if (relset == null) { … … 314 348 } 315 349 if (!found) { 316 if (testRelation((Relation) ref, w) == 1) { 350 if (testRelation((Relation) ref, w, simulate) == 1) { 317 351 relset.add(w); 318 352 relationsToBeChanged.put(ref, relset); … … 355 389 } 356 390 Way w = (Way) primitive; 357 if (w. id== 0) { // new ways with id == 0 are fine,391 if (w.getId() == 0) { // new ways with id == 0 are fine, 358 392 continue; // process existing ways only 359 393 } … … 363 397 // nodes ... 364 398 for (Node n : wnew.getNodes()) { 365 if (n. id!= 0 || !primitivesToDelete.contains(n)) {399 if (n.getId() != 0 || !primitivesToDelete.contains(n)) { 366 400 nodesToKeep.add(n); 367 401 } … … 426 460 if (a != null) { 427 461 for (OsmPrimitive osm : primitivesToDelete) { 428 if (osm instanceof Node && osm. id!= 0) {462 if (osm instanceof Node && osm.getId() != 0) { 429 463 Node n = (Node) osm; 430 464 if (!a.contains(n.getCoor())) { -
/trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r2024 r2060 45 45 return new DefaultMutableTreeNode( 46 46 new JLabel( 47 tr("Resolve conflicts in deleted state in {0}",conflict.getMy(). id),47 tr("Resolve conflicts in deleted state in {0}",conflict.getMy().getId()), 48 48 ImageProvider.get("data", "object"), 49 49 JLabel.HORIZONTAL … … 62 62 63 63 if (decision.equals(MergeDecisionType.KEEP_MINE)) { 64 if (conflict.getMy(). deleted) {64 if (conflict.getMy().isDeleted()) { 65 65 // because my was involved in a conflict it my still be referred 66 66 // to from a way or a relation. Fix this now. … … 69 69 } 70 70 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) { 71 if (conflict.getTheir(). deleted) {71 if (conflict.getTheir().isDeleted()) { 72 72 layer.data.unlinkReferencesToPrimitive(conflict.getMy()); 73 73 conflict.getMy().delete(true); 74 74 } else { 75 conflict.getMy().delete d =conflict.getTheir().deleted;75 conflict.getMy().delete(conflict.getTheir().isDeleted()); 76 76 } 77 77 } else -
/trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r2024 r2060 69 69 OldState os = new OldState(); 70 70 os.latlon = new LatLon(n.getCoor()); 71 os.modified = n. modified;71 os.modified = n.isModified(); 72 72 oldState.add(os); 73 73 } … … 93 93 for (Node n : nodes) { 94 94 n.setEastNorth(n.getEastNorth().add(x, y)); 95 n. modified= true;95 n.setModified(true); 96 96 } 97 97 return true; … … 103 103 OldState os = it.next(); 104 104 n.setCoor(os.latlon); 105 n. modified=os.modified;105 n.setModified(os.modified); 106 106 } 107 107 } -
/trunk/src/org/openstreetmap/josm/data/Preferences.java
r2024 r2060 13 13 import java.io.OutputStreamWriter; 14 14 import java.io.PrintWriter; 15 import java.nio.channels.FileChannel; 15 16 import java.util.ArrayList; 16 17 import java.util.Arrays; … … 44 45 45 46 /** 46 * Internal storage for the preference ddirectory.47 * Internal storage for the preference directory. 47 48 * Do not access this variable directly! 48 49 * @see #getPreferencesDirFile() … … 118 119 } 119 120 121 public File getPreferenceFile() { 122 return new File(getPreferencesDirFile(), "preferences"); 123 } 124 120 125 public File getPluginsDirFile() { 121 126 return new File(getPreferencesDirFile(), "plugins"); … … 253 258 properties.put(key, value); 254 259 } 255 save(); 260 try { 261 save(); 262 } catch(IOException e){ 263 System.out.println(tr("Warning: failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile())); 264 } 256 265 firePreferenceChanged(key, value); 257 266 return true; … … 286 295 * in log. 287 296 */ 288 public void save() { 297 public void save() throws IOException { 289 298 /* currently unused, but may help to fix configuration issues in future */ 290 299 properties.put("josm.version", AboutAction.getVersionString()); 300 301 setSystemProperties(); 302 File prefFile = new File(getPreferencesDirFile(), "preferences"); 303 304 // Backup old preferences if there are old preferences 305 if(prefFile.exists()) { 306 copyFile(prefFile, new File(prefFile + "_backup")); 307 } 308 309 final PrintWriter out = new PrintWriter(new OutputStreamWriter( 310 new FileOutputStream(prefFile + "_tmp"), "utf-8"), false); 311 for (final Entry<String, String> e : properties.entrySet()) { 312 String s = defaults.get(e.getKey()); 313 /* don't save default values */ 314 if(s == null || !s.equals(e.getValue())) { 315 out.println(e.getKey() + "=" + e.getValue()); 316 } 317 } 318 out.close(); 319 320 File tmpFile = new File(prefFile + "_tmp"); 321 copyFile(tmpFile, prefFile); 322 tmpFile.delete(); 323 } 324 325 /** 326 * Simple file copy function that will overwrite the target file 327 * Taken from http://www.rgagnon.com/javadetails/java-0064.html (CC-NC-BY-SA) 328 * @param in 329 * @param out 330 * @throws IOException 331 */ 332 public static void copyFile(File in, File out) throws IOException { 333 FileChannel inChannel = new FileInputStream(in).getChannel(); 334 FileChannel outChannel = new FileOutputStream(out).getChannel(); 291 335 try { 292 setSystemProperties(); 293 final PrintWriter out = new PrintWriter(new OutputStreamWriter( 294 new FileOutputStream(getPreferencesDir() + "preferences"), "utf-8"), false); 295 for (final Entry<String, String> e : properties.entrySet()) { 296 String s = defaults.get(e.getKey()); 297 /* don't save default values */ 298 if(s == null || !s.equals(e.getValue())) { 299 out.println(e.getKey() + "=" + e.getValue()); 300 } 301 } 302 out.close(); 303 } catch (final IOException e) { 304 e.printStackTrace(); 305 // do not message anything, since this can be called from strange 306 // places. 307 } 308 } 336 inChannel.transferTo(0, inChannel.size(), 337 outChannel); 338 } 339 catch (IOException e) { 340 throw e; 341 } 342 finally { 343 if (inChannel != null) { 344 inChannel.close(); 345 } 346 if (outChannel != null) { 347 outChannel.close(); 348 } 349 } 350 } 351 309 352 310 353 public void load() throws IOException { … … 327 370 } 328 371 329 public void init(Boolean reset) 330 { 372 public void init(boolean reset){ 331 373 // get the preferences. 332 374 File prefDir = getPreferencesDirFile(); 333 375 if (prefDir.exists()) { 334 376 if(!prefDir.isDirectory()) { 377 System.err.println(tr("Warning: Failed to initialize preferences. Preference directory ''{0}'' isn't a directory.", prefDir.getAbsoluteFile())); 335 378 JOptionPane.showMessageDialog( 336 379 Main.parent, 337 tr(" Cannot openpreferences directory: {0}",Main.pref.getPreferencesDir()),380 tr("<html>Failed to initialize preferences.<br>Preference directory ''{0}'' isn't a directory.</html>", prefDir.getAbsoluteFile()), 338 381 tr("Error"), 339 382 JOptionPane.ERROR_MESSAGE … … 342 385 } 343 386 } else { 344 prefDir.mkdirs(); 345 } 346 347 if (!new File(getPreferencesDir()+"preferences").exists()) { 348 resetToDefault(); 349 } 350 387 if (! prefDir.mkdirs()) { 388 System.err.println(tr("Warning: Failed to initialize preferences. Failed to create missing preference directory: {0}", prefDir.getAbsoluteFile())); 389 JOptionPane.showMessageDialog( 390 Main.parent, 391 tr("<html>Failed to initialize preferences.<br>Failed to create missing preference directory: {0}</html>",prefDir.getAbsoluteFile()), 392 tr("Error"), 393 JOptionPane.ERROR_MESSAGE 394 ); 395 return; 396 } 397 } 398 399 File preferenceFile = getPreferenceFile(); 351 400 try { 352 if (reset) { 401 if (!preferenceFile.exists()) { 402 System.out.println(tr("Warning: Missing preference file ''{0}''. Creating a default preference file.", preferenceFile.getAbsoluteFile())); 353 403 resetToDefault(); 354 } else { 355 load(); 356 } 357 } catch (final IOException e1) { 358 e1.printStackTrace(); 359 String backup = getPreferencesDir() + "preferences.bak"; 404 save(); 405 } else if (reset) { 406 System.out.println(tr("Warning: Replacing existing preference file ''{0}'' with default preference file.", preferenceFile.getAbsoluteFile())); 407 resetToDefault(); 408 save(); 409 } 410 } catch(IOException e) { 411 e.printStackTrace(); 360 412 JOptionPane.showMessageDialog( 361 413 Main.parent, 362 tr("Preference s file had errors. Making backup of old one to {0}.", backup),414 tr("<html>Failed to initialize preferences.<br>Failed to reset preference file to default: {0}</html>",getPreferenceFile().getAbsoluteFile()), 363 415 tr("Error"), 364 416 JOptionPane.ERROR_MESSAGE 365 417 ); 366 new File(getPreferencesDir() + "preferences").renameTo(new File(backup)); 367 save(); 368 } 369 } 370 371 public final void resetToDefault() { 418 return; 419 } 420 try { 421 load(); 422 } catch (IOException e) { 423 e.printStackTrace(); 424 File backupFile = new File(prefDir,"preferences.bak"); 425 JOptionPane.showMessageDialog( 426 Main.parent, 427 tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> and creating a new default preference file.</html>", backupFile.getAbsoluteFile()), 428 tr("Error"), 429 JOptionPane.ERROR_MESSAGE 430 ); 431 preferenceFile.renameTo(backupFile); 432 try { 433 resetToDefault(); 434 save(); 435 } catch(IOException e1) { 436 e1.printStackTrace(); 437 System.err.println(tr("Warning: Failed to initialize preferences.Failed to reset preference file to default: {0}", getPreferenceFile())); 438 } 439 } 440 } 441 442 public final void resetToDefault(){ 372 443 properties.clear(); 373 444 put("layerlist.visible", true); … … 380 451 put("laf", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 381 452 } 382 save(); 453 } 454 455 public File getBookmarksFile() { 456 return new File(getPreferencesDir(),"bookmarks"); 383 457 } 384 458 385 459 public Collection<Bookmark> loadBookmarks() throws IOException { 386 File bookmarkFile = new File(getPreferencesDir()+"bookmarks");460 File bookmarkFile = getBookmarksFile(); 387 461 if (!bookmarkFile.exists()) { 388 462 bookmarkFile.createNewFile(); -
/trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r2024 r2060 42 42 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 43 43 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 44 data.setModified(true);45 44 data.fireDataChange(); 46 45 } … … 62 61 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 63 62 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 64 data.setModified(data.uploadedModified || !commands.isEmpty());65 63 data.fireDataChange(); 66 64 } … … 81 79 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 82 80 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 83 data.setModified(true);84 81 data.fireDataChange(); 85 82 } -
/trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2024 r2060 83 83 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 84 84 for (OsmPrimitive osm : allPrimitives()) 85 if (osm. visible&& !osm.deleted) {85 if (osm.isVisible() && !osm.isDeleted()) { 86 86 o.add(osm); 87 87 } … … 92 92 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 93 93 for (OsmPrimitive osm : allPrimitives()) 94 if (osm. visible&& !osm.deleted&& !osm.incomplete) {94 if (osm.isVisible() && !osm.isDeleted() && !osm.incomplete) { 95 95 o.add(osm); 96 96 } … … 101 101 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 102 102 for (OsmPrimitive osm : allPrimitives()) 103 if (osm. visible&& !osm.deleted&& !osm.incomplete && !(osm instanceof Relation)) {103 if (osm.isVisible() && !osm.isDeleted() && !osm.incomplete && !(osm instanceof Relation)) { 104 104 o.add(osm); 105 105 } … … 230 230 return sel; 231 231 for (OsmPrimitive osm : list) 232 if (osm.isSelected() && !osm. deleted) {232 if (osm.isSelected() && !osm.isDeleted()) { 233 233 sel.add(osm); 234 234 } … … 290 290 String as = h.get(a); 291 291 if (as == null) { 292 as = a.getName() != null ? a.getName() : Long.toString(a. id);292 as = a.getName() != null ? a.getName() : Long.toString(a.getId()); 293 293 h.put(a, as); 294 294 } 295 295 String bs = h.get(b); 296 296 if (bs == null) { 297 bs = b.getName() != null ? b.getName() : Long.toString(b. id);297 bs = b.getName() != null ? b.getName() : Long.toString(b.getId()); 298 298 h.put(b, bs); 299 299 } … … 320 320 throw new IllegalArgumentException(tr("parameter {0} > 0 required. Got {1}.", "id", id)); 321 321 for (OsmPrimitive primitive : nodes) { 322 if (primitive. id== id) return primitive;322 if (primitive.getId() == id) return primitive; 323 323 } 324 324 for (OsmPrimitive primitive : ways) { 325 if (primitive. id== id) return primitive;325 if (primitive.getId() == id) return primitive; 326 326 } 327 327 for (OsmPrimitive primitive : relations) { 328 if (primitive. id== id) return primitive;328 if (primitive.getId() == id) return primitive; 329 329 } 330 330 return null; … … 334 334 HashSet<Long> ret = new HashSet<Long>(); 335 335 for (OsmPrimitive primitive : nodes) { 336 ret.add(primitive. id);336 ret.add(primitive.getId()); 337 337 } 338 338 for (OsmPrimitive primitive : ways) { 339 ret.add(primitive. id);339 ret.add(primitive.getId()); 340 340 } 341 341 for (OsmPrimitive primitive : relations) { 342 ret.add(primitive. id);342 ret.add(primitive.getId()); 343 343 } 344 344 return ret; … … 346 346 347 347 /** 348 * Replies the set of ids of all complete primitiv ies (i.e. those with348 * Replies the set of ids of all complete primitives (i.e. those with 349 349 * ! primitive.incomplete) 350 350 * 351 * @return the set of ids of all complete primitiv ies351 * @return the set of ids of all complete primitives 352 352 */ 353 353 public Set<Long> getCompletePrimitiveIds() { … … 355 355 for (OsmPrimitive primitive : nodes) { 356 356 if (!primitive.incomplete) { 357 ret.add(primitive. id);357 ret.add(primitive.getId()); 358 358 } 359 359 } 360 360 for (OsmPrimitive primitive : ways) { 361 361 if (! primitive.incomplete) { 362 ret.add(primitive. id);362 ret.add(primitive.getId()); 363 363 } 364 364 } 365 365 for (OsmPrimitive primitive : relations) { 366 366 if (! primitive.incomplete) { 367 ret.add(primitive. id);367 ret.add(primitive.getId()); 368 368 } 369 369 } … … 451 451 return parents; 452 452 } 453 454 /** 455 * Replies true if there is at least one primitive in this dataset with 456 * {@see OsmPrimitive#isModified()} == <code>true</code>. 457 * 458 * @return true if there is at least one primitive in this dataset with 459 * {@see OsmPrimitive#isModified()} == <code>true</code>. 460 */ 461 public boolean isModified() { 462 for (Node n: nodes) { 463 if (n.isModified()) return true; 464 } 465 for (Way w: ways) { 466 if (w.isModified()) return true; 467 } 468 for (Relation r: relations) { 469 if (r.isModified()) return true; 470 } 471 return false; 472 } 453 473 } -
/trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2024 r2060 69 69 * new to the server! To create a new object, call the default constructor of 70 70 * the respective class. 71 */ 71 * 72 * @deprecated use {@see #getId()}. Don't assign an id, create a primitive with 73 * the respective constructors. 74 */ 75 @Deprecated 72 76 public long id = 0; 73 77 … … 77 81 * Deleted objects are deleted from the server. If the objects are added (id=0), 78 82 * the modified is ignored and the object is added to the server. 79 */ 83 * 84 * @deprecated Please use {@see #setModified()} and {@see #getModified()} 85 */ 86 @Deprecated 80 87 public boolean modified = false; 81 88 82 89 /** 83 90 * <code>true</code>, if the object has been deleted. 84 */ 91 * 92 * @deprecated use {@see #delete()} and {@see #isDeleted()} 93 */ 94 @Deprecated 85 95 public boolean deleted = false; 86 96 … … 89 99 * introduced with the 0.4 API to be able to communicate deleted objects 90 100 * (they will have visible=false). 91 */ 101 * 102 * @deprecated use {@see #isVisible()} and {@see #setVisible(boolean)} 103 */ 104 @Deprecated 92 105 public boolean visible = true; 93 106 … … 100 113 /** 101 114 * If set to true, this object is currently selected. 115 * 116 * @deprecated use {@see #isSelected()} and {@see #setSelected(boolean)} 102 117 */ 103 118 @Deprecated … … 121 136 public boolean isSelected() { 122 137 return selected; 138 } 139 140 /** 141 * Marks this primitive as being modified. 142 * 143 * @param modified true, if this primitive is to be modified 144 */ 145 public void setModified(boolean modified) { 146 this.modified = modified; 147 } 148 149 /** 150 * Replies <code>true</code> if the object has been modified since it was loaded from 151 * the server. In this case, on next upload, this object will be updated. 152 * 153 * @return <code>true</code> if the object has been modified since it was loaded from 154 * the server 155 */ 156 public boolean isModified() { 157 return modified; 158 } 159 160 /** 161 * Replies <code>true</code>, if the object has been deleted. 162 * 163 * @return <code>true</code>, if the object has been deleted. 164 * @see #delete(boolean) 165 */ 166 public boolean isDeleted() { 167 return deleted; 168 } 169 170 /** 171 * Replies true if this primitive is either unknown to the server (i.e. its id 172 * is 0) or it is known to the server and it hasn't be deleted on the server. 173 * Replies false, if this primitive is known on the server and has been deleted 174 * on the server. 175 * 176 * @see #setVisible(boolean) 177 */ 178 public boolean isVisible() { 179 return visible; 180 } 181 182 /** 183 * Sets whether this primitive is visible, i.e. whether it is known on the server 184 * and not deleted on the server. 185 * 186 * @see #isVisible() 187 * @throws IllegalStateException thrown if visible is set to false on an primitive with 188 * id==0 189 */ 190 public void setVisible(boolean visible) throws IllegalStateException{ 191 if (id == 0 && visible == false) 192 throw new IllegalStateException(tr("a primitive with id=0 can't be invisible")); 193 this.visible = visible; 194 } 195 196 /** 197 * Replies the id of this primitive. 198 * 199 * @return the id of this primitive. 200 */ 201 public long getId() { 202 return id; 123 203 } 124 204 … … 502 582 */ 503 583 public abstract String getDisplayName(NameFormatter formatter); 584 504 585 } 586 587 -
/trunk/src/org/openstreetmap/josm/data/osm/User.java
r2024 r2060 39 39 return user; 40 40 } 41 42 @Override 43 public int hashCode() { 44 final int prime = 31; 45 int result = 1; 46 result = prime * result + ((name == null) ? 0 : name.hashCode()); 47 result = prime * result + ((uid == null) ? 0 : uid.hashCode()); 48 return result; 49 } 50 51 @Override 52 public boolean equals(Object obj) { 53 if (this == obj) 54 return true; 55 if (obj == null) 56 return false; 57 if (getClass() != obj.getClass()) 58 return false; 59 User other = (User) obj; 60 if (name == null) { 61 if (other.name != null) 62 return false; 63 } else if (!name.equals(other.name)) 64 return false; 65 if (uid == null) { 66 if (other.uid != null) 67 return false; 68 } else if (!uid.equals(other.uid)) 69 return false; 70 return true; 71 } 41 72 } -
/trunk/src/org/openstreetmap/josm/data/osm/visitor/CreateOsmChangeVisitor.java
r2024 r2060 47 47 48 48 public void visit(Node n) { 49 if (n. deleted) {49 if (n.isDeleted()) { 50 50 switchMode("delete"); 51 51 osmwriter.setWithBody(false); 52 52 osmwriter.visit(n); 53 53 } else { 54 switchMode((n. id== 0) ? "create" : "modify");54 switchMode((n.getId() == 0) ? "create" : "modify"); 55 55 osmwriter.setWithBody(true); 56 56 osmwriter.visit(n); … … 58 58 } 59 59 public void visit(Way w) { 60 if (w. deleted) {60 if (w.isDeleted()) { 61 61 switchMode("delete"); 62 62 osmwriter.setWithBody(false); 63 63 osmwriter.visit(w); 64 64 } else { 65 switchMode((w. id== 0) ? "create" : "modify");65 switchMode((w.getId() == 0) ? "create" : "modify"); 66 66 osmwriter.setWithBody(true); 67 67 osmwriter.visit(w); … … 69 69 } 70 70 public void visit(Relation r) { 71 if (r. deleted) {71 if (r.isDeleted()) { 72 72 switchMode("delete"); 73 73 osmwriter.setWithBody(false); 74 74 osmwriter.visit(r); 75 75 } else { 76 switchMode((r. id== 0) ? "create" : "modify");76 switchMode((r.getId() == 0) ? "create" : "modify"); 77 77 osmwriter.setWithBody(true); 78 78 osmwriter.visit(r); -
/trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2024 r2060 529 529 for (RelationMember m : r.getMembers()) 530 530 { 531 if (m.isNode() && !m.getMember().incomplete && !m.getMember(). deleted)531 if (m.isNode() && !m.getMember().incomplete && !m.getMember().isDeleted()) 532 532 { 533 533 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) : null, true, true); … … 550 550 for (RelationMember m : r.getMembers()) 551 551 { 552 if (m.isWay() && !m.getMember().incomplete && !m.getMember(). deleted) /* nodes drawn on second call */552 if (m.isWay() && !m.getMember().incomplete && !m.getMember().isDeleted()) /* nodes drawn on second call */ 553 553 { 554 554 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) … … 580 580 // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 581 581 r.putError(tr("Empty member in relation."), true); 582 } else if(m.getMember(). deleted) {582 } else if(m.getMember().isDeleted()) { 583 583 r.putError(tr("Deleted member ''{0}'' in relation.", 584 584 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); … … 834 834 //TODO Remove useless nullcheck when RelationMember.member is encalupsed 835 835 r.putError(tr("Empty member in relation."), true); 836 } else if(m.getMember(). deleted) {836 } else if(m.getMember().isDeleted()) { 837 837 r.putError(tr("Deleted member ''{0}'' in relation.", 838 838 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); … … 1379 1379 for (final Relation osm : data.relations) 1380 1380 { 1381 if(!osm. deleted&& !osm.incomplete && osm.mappaintVisibleCode != viewid)1381 if(!osm.isDeleted() && !osm.incomplete && osm.mappaintVisibleCode != viewid) 1382 1382 { 1383 1383 osm.visit(this); … … 1396 1396 for (final Way osm : data.ways) 1397 1397 { 1398 if (!osm.incomplete && !osm. deleted1398 if (!osm.incomplete && !osm.isDeleted() 1399 1399 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1400 1400 { … … 1437 1437 // profilerN = 0; 1438 1438 for (final OsmPrimitive osm : data.ways) 1439 if (!osm.incomplete && !osm. deleted&& !osm.isSelected()1439 if (!osm.incomplete && !osm.isDeleted() && !osm.isSelected() 1440 1440 && osm.mappaintVisibleCode != viewid ) 1441 1441 { … … 1456 1456 //profilerN = 0; 1457 1457 for (final OsmPrimitive osm : data.getSelected()) { 1458 if (!osm.incomplete && !osm. deleted&& !(osm instanceof Node)1458 if (!osm.incomplete && !osm.isDeleted() && !(osm instanceof Node) 1459 1459 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1460 1460 { … … 1476 1476 //profilerN = 0; 1477 1477 for (final OsmPrimitive osm : data.nodes) 1478 if (!osm.incomplete && !osm. deleted1478 if (!osm.incomplete && !osm.isDeleted() 1479 1479 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1480 1480 { … … 1496 1496 currentColor = nodeColor; 1497 1497 for (final OsmPrimitive osm : data.ways) 1498 if (!osm.incomplete && !osm. deleted1498 if (!osm.incomplete && !osm.isDeleted() 1499 1499 && osm.mappaintVisibleCode != viewid ) 1500 1500 { -
/trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r2024 r2060 94 94 for (RelationMember member: r.getMembers()) { 95 95 newMembers.add( 96 new RelationMember(member.getRole(), mappedPrimitives.get(member.getMember()))); 96 new RelationMember(member.getRole(), mappedPrimitives.get(member.getMember()))); 97 97 98 98 } … … 117 117 OsmPrimitive clone = null; 118 118 if (primitive instanceof Node) { 119 clone = new Node(primitive. id);119 clone = new Node(primitive.getId()); 120 120 } else if (primitive instanceof Way) { 121 clone = new Way(primitive. id);121 clone = new Way(primitive.getId()); 122 122 } else if (primitive instanceof Relation) { 123 clone = new Relation(primitive. id);123 clone = new Relation(primitive.getId()); 124 124 } 125 125 clone.incomplete = true; … … 176 176 177 177 protected boolean isNew(OsmPrimitive primitive) { 178 return primitive. id== 0;178 return primitive.getId() == 0; 179 179 } 180 180 -
/trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r2024 r2060 62 62 this.theirDataSet = theirDataSet; 63 63 64 for (Node n : myDataSet.nodes) if (n. id!= 0) {65 nodeshash.put(n. id, n);66 } 67 for (Way w : myDataSet.ways) if (w. id!= 0) {68 wayshash.put(w. id, w);69 } 70 for (Relation r : myDataSet.relations) if (r. id!= 0) {71 relshash.put(r. id, r);64 for (Node n : myDataSet.nodes) if (n.getId() != 0) { 65 nodeshash.put(n.getId(), n); 66 } 67 for (Way w : myDataSet.ways) if (w.getId() != 0) { 68 wayshash.put(w.getId(), w); 69 } 70 for (Relation r : myDataSet.relations) if (r.getId() != 0) { 71 relshash.put(r.getId(), r); 72 72 } 73 73 conflicts = new ConflictCollection(); … … 98 98 HashMap<Long, P> primitivesWithDefinedIds) { 99 99 100 if (other. id> 0 ) {100 if (other.getId() > 0 ) { 101 101 // try to merge onto a matching primitive with the same 102 102 // defined id … … 109 109 // 110 110 for (P my : myPrimitives) { 111 if (my. id>0 ) {111 if (my.getId() >0 ) { 112 112 continue; 113 113 } 114 114 if (my.hasEqualSemanticAttributes(other)) { 115 if (my. deleted!= other.deleted) {115 if (my.isDeleted() != other.isDeleted()) { 116 116 // differences in deleted state have to be merged manually 117 117 // … … 120 120 // copy the technical attributes from other 121 121 // version 122 my. visible = other.visible;122 my.setVisible(other.isVisible()); 123 123 my.user = other.user; 124 124 my.setTimestamp(other.getTimestamp()); 125 my. modified= other.modified;125 my.setModified(other.isModified()); 126 126 merged.put(other, my); 127 127 } … … 186 186 Node mergedNode = (Node) merged.get(myNode); 187 187 if (mergedNode != null) { 188 if (!mergedNode. deleted) {188 if (!mergedNode.isDeleted()) { 189 189 newNodes.add(mergedNode); 190 190 } … … 207 207 newMembers.add(myMember); 208 208 } else { 209 if (! mergedMember. deleted) {209 if (! mergedMember.isDeleted()) { 210 210 RelationMember newMember = new RelationMember(myMember.getRole(), mergedMember); 211 211 newMembers.add(newMember); … … 234 234 // merge other into an existing primitive with the same id, if possible 235 235 // 236 if (myPrimitivesWithDefinedIds.containsKey(other. id)) {237 P my = myPrimitivesWithDefinedIds.get(other. id);236 if (myPrimitivesWithDefinedIds.containsKey(other.getId())) { 237 P my = myPrimitivesWithDefinedIds.get(other.getId()); 238 238 if (my.version <= other.version) { 239 if (! my. visible&& other.visible) {239 if (! my.isVisible() && other.isVisible()) { 240 240 // should not happen 241 241 // … … 243 243 + "their primitive with lower version {2} is not visible. " 244 244 + "Can't deal with this inconsistency. Keeping my primitive. ", 245 Long.toString(my. id),Long.toString(my.version), Long.toString(other.version)245 Long.toString(my.getId()),Long.toString(my.version), Long.toString(other.version) 246 246 )); 247 247 merged.put(other, my); 248 } else if (my. visible&& ! other.visible) {248 } else if (my.isVisible() && ! other.isVisible()) { 249 249 // this is always a conflict because the user has to decide whether 250 250 // he wants to create a clone of its local primitive or whether he … … 270 270 // 271 271 merged.put(other, my); 272 } else if (my. deleted&& ! other.deleted&& my.version == other.version) {272 } else if (my.isDeleted() && ! other.isDeleted() && my.version == other.version) { 273 273 // same version, but my is deleted. Assume mine takes precedence 274 274 // otherwise too many conflicts when refreshing from the server 275 275 merged.put(other, my); 276 } else if (my. deleted!= other.deleted) {276 } else if (my.isDeleted() != other.isDeleted()) { 277 277 // differences in deleted state have to be resolved manually 278 278 // 279 279 conflicts.add(my,other); 280 } else if (! my. modified&& other.modified) {280 } else if (! my.isModified() && other.isModified()) { 281 281 // my not modified. We can assume that other is the most recent version. 282 282 // clone it onto my. But check first, whether other is deleted. if so, 283 283 // make sure that my is not references anymore in myDataSet. 284 284 // 285 if (other. deleted) {285 if (other.isDeleted()) { 286 286 myDataSet.unlinkReferencesToPrimitive(my); 287 287 } 288 288 my.cloneFrom(other); 289 289 merged.put(other, my); 290 } else if (! my. modified&& !other.modified&& my.version == other.version) {290 } else if (! my.isModified() && !other.isModified() && my.version == other.version) { 291 291 // both not modified. Keep mine 292 292 // 293 293 merged.put(other,my); 294 } else if (! my. modified&& !other.modified&& my.version < other.version) {294 } else if (! my.isModified() && !other.isModified() && my.version < other.version) { 295 295 // my not modified but other is newer. clone other onto mine. 296 296 // 297 297 my.cloneFrom(other); 298 298 merged.put(other,my); 299 } else if (my. modified&& ! other.modified&& my.version == other.version) {299 } else if (my.isModified() && ! other.isModified() && my.version == other.version) { 300 300 // my is same as other but mine is modified 301 301 // => keep mine … … 312 312 // 313 313 my.cloneFrom(other); 314 my. modified= true;314 my.setModified(true); 315 315 merged.put(other, my); 316 316 } -
/trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2024 r2060 56 56 /** 57 57 * Preferences 58 */ 58 */ 59 59 protected Color inactiveColor; 60 60 protected Color selectedColor; … … 124 124 125 125 ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, 126 Main.pref.getBoolean("mappaint.use-antialiasing", false) ? 127 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); 126 Main.pref.getBoolean("mappaint.use-antialiasing", false) ? 127 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); 128 128 } 129 129 … … 149 149 //profilerN = 0; 150 150 for (final OsmPrimitive osm : data.relations) 151 if (!osm. deleted&& !osm.isSelected())151 if (!osm.isDeleted() && !osm.isSelected()) 152 152 { 153 153 osm.visit(this); 154 // profilerN++; 154 // profilerN++; 155 155 } 156 156 … … 163 163 //profilerN = 0; 164 164 for (final OsmPrimitive osm : data.ways) 165 if (!osm. deleted&& !osm.isSelected() && osm.isTagged())165 if (!osm.isDeleted() && !osm.isSelected() && osm.isTagged()) 166 166 { 167 167 osm.visit(this); 168 // profilerN++; 168 // profilerN++; 169 169 } 170 170 displaySegments(); 171 171 172 172 for (final OsmPrimitive osm : data.ways) 173 if (!osm. deleted&& !osm.isSelected() && !osm.isTagged())173 if (!osm.isDeleted() && !osm.isSelected() && !osm.isTagged()) 174 174 { 175 175 osm.visit(this); 176 // profilerN++; 176 // profilerN++; 177 177 } 178 178 displaySegments(); … … 187 187 //profilerN = 0; 188 188 for (final OsmPrimitive osm : data.getSelected()) 189 if (!osm. deleted)189 if (!osm.isDeleted()) 190 190 { 191 191 osm.visit(this); 192 // profilerN++; 192 // profilerN++; 193 193 } 194 194 displaySegments(); … … 202 202 //profilerN = 0; 203 203 for (final OsmPrimitive osm : data.nodes) 204 if (!osm. deleted&& !osm.isSelected())204 if (!osm.isDeleted() && !osm.isSelected()) 205 205 { 206 206 osm.visit(this); 207 // profilerN++; 207 // profilerN++; 208 208 } 209 209 … … 217 217 if(virtualNodeSize != 0) 218 218 { 219 // profilerN = 0; 219 // profilerN = 0; 220 220 currentColor = nodeColor; 221 221 for (final OsmPrimitive osm : data.ways) 222 if (!osm. deleted)223 224 225 // profilerN++; 226 222 if (!osm.isDeleted()) 223 { 224 visitVirtual((Way)osm); 225 // profilerN++; 226 } 227 227 displaySegments(); 228 228 229 // if(profiler) 230 // { 231 // System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 232 // profilerLast = java.lang.System.currentTimeMillis(); 233 // } 229 // if(profiler) 230 // { 231 // System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 232 // profilerLast = java.lang.System.currentTimeMillis(); 233 // } 234 234 } 235 235 … … 249 249 if (n.incomplete) return; 250 250 251 if (inactive) 251 if (inactive) { 252 252 drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 253 else if (n.highlighted) 253 } else if (n.highlighted) { 254 254 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 255 else if (n.isSelected()) 255 } else if (n.isSelected()) { 256 256 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 257 else if(n.isTagged()) 257 } else if(n.isTagged()) { 258 258 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 259 else259 } else { 260 260 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 261 } 261 262 } 262 263 263 264 public static Boolean isLargeSegment(Point p1, Point p2, int space) 264 265 { 265 int xd = p1.x-p2.x; if(xd < 0) xd = -xd; 266 int yd = p1.y-p2.y; if(yd < 0) yd = -yd; 266 int xd = p1.x-p2.x; if(xd < 0) { 267 xd = -xd; 268 } 269 int yd = p1.y-p2.y; if(yd < 0) { 270 yd = -yd; 271 } 267 272 return (xd+yd > space); 268 273 } … … 325 330 Point p = nc.getPoint(it.next()); 326 331 drawSegment(lastP, p, wayColor, 327 showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow); 328 if (showOrderNumber) 332 showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow); 333 if (showOrderNumber) { 329 334 drawOrderNumber(lastP, p, orderNumber); 335 } 330 336 lastP = p; 331 337 } … … 334 340 335 341 private Stroke relatedWayStroke = new BasicStroke( 336 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); 342 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); 337 343 public void visit(Relation r) { 338 344 if (r.incomplete) return; … … 349 355 350 356 for (RelationMember m : r.getMembers()) { 351 if (m.getMember().incomplete || m.getMember().deleted) continue; 357 if (m.getMember().incomplete || m.getMember().isDeleted()) { 358 continue; 359 } 352 360 353 361 if (m.isNode()) { 354 362 Point p = nc.getPoint(m.getNode()); 355 363 if (p.x < 0 || p.y < 0 356 || p.x > nc.getWidth() || p.y > nc.getHeight()) continue; 364 || p.x > nc.getWidth() || p.y > nc.getHeight()) { 365 continue; 366 } 357 367 358 368 g.drawOval(p.x-3, p.y-3, 6, 6); … … 362 372 boolean first = true; 363 373 for (Node n : m.getWay().getNodes()) { 364 if (n.incomplete || n.deleted) continue; 374 if (n.incomplete || n.isDeleted()) { 375 continue; 376 } 365 377 Point p = nc.getPoint(n); 366 378 if (first) { … … 418 430 g.fillRect(p.x - radius, p.y - radius, size, size); 419 431 g.drawRect(p.x - radius, p.y - radius, size, size); 420 } else 432 } else { 421 433 g.drawRect(p.x - radius, p.y - radius, size, size); 434 } 422 435 } 423 436 } … … 427 440 */ 428 441 protected void drawSegment(Point p1, Point p2, Color col, boolean showDirection) { 429 if (col != currentColor) displaySegments(col); 442 if (col != currentColor) { 443 displaySegments(col); 444 } 430 445 431 446 if (isSegmentVisible(p1, p2)) { -
/trunk/src/org/openstreetmap/josm/gui/BookmarkList.java
r2024 r2060 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.data.Preferences; 16 17 import sun.security.action.GetBooleanAction; 16 18 17 19 /** … … 44 46 JOptionPane.showMessageDialog( 45 47 Main.parent, 46 tr("<html>Could not read bookmarks.<br>{0}</html>", e.getMessage()), 48 tr("<html>Could not read bookmarks from<br>''{0}''<br>Error was: {1}</html>", 49 Main.pref.getBookmarksFile(), 50 e.getMessage() 51 ), 47 52 tr("Error"), 48 53 JOptionPane.ERROR_MESSAGE -
/trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r2024 r2060 27 27 * 28 28 */ 29 public class ConditionalOptionPaneUtil { 29 @Deprecated public class ConditionalOptionPaneUtil { 30 30 static public final int DIALOG_DISABLED_OPTION = Integer.MIN_VALUE; 31 31 -
/trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r2024 r2060 17 17 import org.openstreetmap.josm.io.OsmApiException; 18 18 import org.openstreetmap.josm.io.OsmApiInitializationException; 19 import org.openstreetmap.josm.io.OsmChangesetCloseException; 19 20 import org.openstreetmap.josm.io.OsmTransferException; 20 21 … … 39 40 JOptionPane.showMessageDialog( 40 41 Main.parent, 41 tr( "Failed to initialize communication with the OSM server {0}.\n" 42 + "Check the server URL in your preferences and your internet connection.", 42 tr( "<html>Failed to initialize communication with the OSM server {0}.<br>" 43 + "Check the server URL in your preferences and your internet connection.</html>", 44 Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api") 45 ), 46 tr("Error"), 47 JOptionPane.ERROR_MESSAGE 48 ); 49 } 50 51 /** 52 * handles an exception caught during OSM API initialization 53 * 54 * @param e the exception 55 */ 56 public static void explainOsmChangesetCloseException(OsmChangesetCloseException e) { 57 e.printStackTrace(); 58 String changsetId = e.getChangeset() == null ? tr("unknown") : Long.toString(e.getChangeset().getId()); 59 JOptionPane.showMessageDialog( 60 Main.parent, 61 tr( "<html>Failed to close changeset ''{0}'' on the OSM server ''{1}''.<br>" 62 + "The changeset will automatically be closed by the server after a timeout.</html>", 63 changsetId, 43 64 Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api") 44 65 ), … … 275 296 return; 276 297 } 298 if (e instanceof OsmChangesetCloseException){ 299 explainOsmChangesetCloseException((OsmChangesetCloseException)e); 300 return; 301 } 302 277 303 if (e instanceof OsmApiException) { 278 304 OsmApiException oae = (OsmApiException)e; -
/trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2024 r2060 1 1 package org.openstreetmap.josm.gui; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 3 5 import java.awt.Component; 6 import java.awt.Container; 4 7 import java.awt.Dimension; 8 import java.awt.Frame; 5 9 import java.awt.GridBagLayout; 6 10 import java.awt.Toolkit; … … 11 15 import javax.swing.Action; 12 16 import javax.swing.JButton; 17 import javax.swing.JCheckBox; 13 18 import javax.swing.JComponent; 14 19 import javax.swing.JDialog; … … 19 24 import javax.swing.KeyStroke; 20 25 26 import org.openstreetmap.josm.Main; 21 27 import org.openstreetmap.josm.tools.GBC; 22 28 import org.openstreetmap.josm.tools.ImageProvider; … … 25 31 public class ExtendedDialog extends JDialog { 26 32 private int result = 0; 33 public static final int DialogNotShown = -99; 34 public static final int DialogClosedOtherwise = 0; 35 private boolean toggleable = false; 36 private String togglePref = ""; 37 private String toggleCheckboxText = tr("Do not show again"); 38 private JCheckBox toggleCheckbox = null; 27 39 private Component parent; 40 private Component content; 28 41 private final String[] bTexts; 42 private String[] bIcons; 43 /** 44 * set to true if the content of the extended dialog should 45 * be placed in a {@see JScrollPane} 46 */ 47 private boolean placeContentInScrollPane; 29 48 30 49 // For easy access when inherited 31 protected Object contentConstraints = GBC.eol().anchor(GBC.CENTER).fill(GBC. HORIZONTAL).insets(5,10,5,0);50 protected Object contentConstraints = GBC.eol().anchor(GBC.CENTER).fill(GBC.BOTH).insets(5,10,5,0); 32 51 protected ArrayList<JButton> buttons = new ArrayList<JButton>(); 52 53 /** 54 * This method sets up the most basic options for the dialog. Add all more 55 * advanced features with dedicated methods. 56 * Possible features: 57 * <ul> 58 * <li><code>setButtonIcons</code></li> 59 * <li><code>setContent</code></li> 60 * <li><code>toggleEnable</code></li> 61 * <li><code>toggleDisable</code></li> 62 * <li><code>setToggleCheckboxText</code></li> 63 * </ul> 64 * 65 * When done, call <code>showDialog</code> to display it. You can receive 66 * the user's choice using <code>getValue</code>. Have a look at this function 67 * for possible return values. 68 * 69 * @param parent The parent element that will be used for position and maximum size 70 * @param title The text that will be shown in the window titlebar 71 * @param buttonTexts String Array of the text that will appear on the buttons. The first button is the default one. 72 */ 73 public ExtendedDialog(Component parent, String title, String[] buttonTexts) { 74 super(JOptionPane.getFrameForComponent(parent), title, true); 75 this.parent = parent; 76 bTexts = buttonTexts; 77 } 78 79 /** 80 * Same as above but lets you define if the dialog should be modal. 81 */ 82 public ExtendedDialog(Component parent, String title, String[] buttonTexts, 83 boolean modal) { 84 super(JOptionPane.getFrameForComponent(parent), title, modal); 85 this.parent = parent; 86 bTexts = buttonTexts; 87 } 33 88 34 89 /** … … 40 95 * @param buttonIcons The path to the icons that will be displayed on the buttons. Path is relative to JOSM's image directory. File extensions need to be included. If a button should not have an icon pass null. 41 96 */ 42 public ExtendedDialog(Component parent, String title, Component content, String[] buttonTexts, String[] buttonIcons) { 97 @Deprecated public ExtendedDialog(Component parent, String title, Component content, 98 String[] buttonTexts, String[] buttonIcons) { 43 99 super(JOptionPane.getFrameForComponent(parent), title, true /* modal */); 44 100 this.parent = parent; 45 101 bTexts = buttonTexts; 46 setupDialog(content, buttonIcons); 102 this.content = content; 103 this.bIcons = buttonIcons; 104 setupDialog(); 47 105 setVisible(true); 48 106 } 49 107 50 public ExtendedDialog(Component parent, String title, Component content, String[] buttonTexts) { 108 @Deprecated public ExtendedDialog(Component parent, String title, Component content, 109 String[] buttonTexts) { 51 110 this(parent, title, content, buttonTexts, null); 52 111 } … … 55 114 * Sets up the dialog and displays the given message in a breakable label 56 115 */ 57 public ExtendedDialog(Component parent, String title, String message, String[] buttonTexts, String[] buttonIcons) { 58 super(JOptionPane.getFrameForComponent(parent), title, true); 59 60 JMultilineLabel lbl = new JMultilineLabel(message); 61 // Make it not wider than 2/3 of the screen 62 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 63 lbl.setMaxWidth(Math.round(screenSize.width*2/3)); 64 65 this.parent = parent; 66 bTexts = buttonTexts; 67 setupDialog(lbl, buttonIcons); 116 @Deprecated public ExtendedDialog(Component parent, String title, String message, 117 String[] buttonTexts, String[] buttonIcons) { 118 this(parent, title, string2label(message), buttonTexts, buttonIcons); 119 } 120 121 @Deprecated public ExtendedDialog(Component parent, String title, String message, 122 String[] buttonTexts) { 123 this(parent, title, message, buttonTexts, null); 124 } 125 126 /** 127 * Allows decorating the buttons with icons. Expects an String[] with paths 128 * to images relative to JOSM/images. 129 * @param buttonIcons 130 */ 131 public void setButtonIcons(String[] buttonIcons) { 132 this.bIcons = buttonIcons; 133 } 134 135 /** 136 * Sets the content that will be displayed in the message dialog. 137 * 138 * Note that depending on your other settings more UI elements may appear. 139 * The content is played on top of the other elements though. 140 * 141 * @param content Any element that can be displayed in the message dialog 142 */ 143 public void setContent(Component content) { 144 setContent(content, true); 145 } 146 147 /** 148 * Sets the content that will be displayed in the message dialog. 149 * 150 * Note that depending on your other settings more UI elements may appear. 151 * The content is played on top of the other elements though. 152 * 153 * @param content Any element that can be displayed in the message dialog 154 * @param placeContentInScrollPane if true, places the content in a JScrollPane 155 * 156 */ 157 public void setContent(Component content, boolean placeContentInScrollPane) { 158 this.content = content; 159 this.placeContentInScrollPane = placeContentInScrollPane; 160 } 161 162 /** 163 * Sets the message that will be displayed. The String will be automatically 164 * wrapped if it is too long. 165 * 166 * Note that depending on your other settings more UI elements may appear. 167 * The content is played on top of the other elements though. 168 * 169 * @param message The text that should be shown to the user 170 */ 171 public void setContent(String message) { 172 setContent(string2label(message), true); 173 } 174 175 /** 176 * Show the dialog to the user. Call this after you have set all options 177 * for the dialog. You can retrieve the result using <code>getValue</code> 178 */ 179 public void showDialog() { 180 // Check if the user has set the dialog to not be shown again 181 if(toggleCheckState(togglePref)) { 182 result = ExtendedDialog.DialogNotShown; 183 return; 184 } 185 186 setupDialog(); 68 187 setVisible(true); 69 } 70 71 public ExtendedDialog(Component parent, String title, String message, String[] buttonTexts) { 72 this(parent, title, message, buttonTexts, null); 73 } 74 75 /** 76 * Constructor that doesn't make the dialog visible immediately. Intended for when inheriting. 77 */ 78 public ExtendedDialog(Component parent, String title, String[] buttonTexts, boolean modal) { 79 super(JOptionPane.getFrameForComponent(parent), title, modal); 80 this.parent = parent; 81 bTexts = buttonTexts; 82 } 83 84 protected void setupDialog(Component content, String[] buttonIcons) { 188 toggleSaveState(); 189 } 190 191 /** 192 * @return int * The selected button. The count starts with 1. 193 * * A return value of ExtendedDialog.DialogClosedOtherwise means the dialog has been closed otherwise. 194 * * A return value of ExtendedDialog.DialogNotShown means the 195 * dialog has been toggled off in the past 196 */ 197 public int getValue() { 198 return result; 199 } 200 201 @Deprecated protected void setupDialog(Component content, String[] buttonIcons) { 202 this.setContent(content); 203 this.setButtonIcons(buttonIcons); 204 this.setupDialog(); 205 } 206 207 protected void setupDialog() { 85 208 setupEscListener(); 86 209 … … 96 219 97 220 button = new JButton(action); 98 if(b uttonIcons != null && buttonIcons[i] != null) {99 button.setIcon(ImageProvider.get(b uttonIcons[i]));221 if(bIcons != null && bIcons[i] != null) { 222 button.setIcon(ImageProvider.get(bIcons[i])); 100 223 } 101 224 … … 109 232 JPanel cp = new JPanel(new GridBagLayout()); 110 233 cp.add(content, contentConstraints); 234 235 if(toggleable) { 236 toggleCheckbox = new JCheckBox(toggleCheckboxText); 237 boolean showDialog = Main.pref.getBoolean("message."+ togglePref, true); 238 toggleCheckbox.setSelected(!showDialog); 239 cp.add(toggleCheckbox, GBC.eol().anchor(GBC.LINE_START).insets(5,5,5,5)); 240 } 241 111 242 cp.add(buttonsPanel, GBC.eol().anchor(GBC.CENTER).insets(5,5,5,5)); 112 113 JScrollPane pane = new JScrollPane(cp); 114 pane.setBorder(null); 115 setContentPane(pane); 116 243 if (placeContentInScrollPane) { 244 JScrollPane pane = new JScrollPane(cp); 245 pane.setBorder(null); 246 setContentPane(pane); 247 } else { 248 setContentPane(cp); 249 } 117 250 pack(); 118 251 … … 138 271 setSize(d); 139 272 setLocationRelativeTo(parent); 140 }141 142 /**143 * @return int The selected button. The count starts with 1.144 * A return value of 0 means the dialog has been closed otherwise.145 */146 public int getValue() {147 return result;148 273 } 149 274 … … 188 313 // We need to set it to zero again, in case the dialog has been re-used 189 314 // and the result differs from its default value 190 result = 0;315 result = ExtendedDialog.DialogClosedOtherwise; 191 316 setVisible(false); 192 317 } … … 202 327 super.setVisible(visible); 203 328 if (visible) { 204 toFront(); 205 } 329 repaint(); 330 } 331 } 332 333 /** 334 * Calling this will offer the user a "Do not show again" checkbox for the 335 * dialog. Default is to not offer the choice; the dialog will be shown 336 * every time. If the dialog is not shown due to the previous choice of the 337 * user, the result <code>ExtendedDialog.DialogNotShown</code> is returned 338 * @param togglePref The preference to save the checkbox state to 339 */ 340 public void toggleEnable(String togglePref) { 341 this.toggleable = true; 342 this.togglePref = togglePref; 343 } 344 345 /** 346 * Call this if you "accidentally" called toggleEnable. This doesn't need 347 * to be called for every dialog, as it's the default anyway. 348 */ 349 public void toggleDisable() { 350 this.toggleable = false; 351 } 352 353 /** 354 * Overwrites the default "Don't show again" text of the toggle checkbox 355 * if you want to give more information. Only has an effect if 356 * <code>toggleEnable</code> is set. 357 * @param text 358 */ 359 public void setToggleCheckboxText(String text) { 360 this.toggleCheckboxText = text; 361 } 362 363 /** 364 * This function returns true if the dialog has been set to "do not show again" 365 * @return true if dialog should not be shown again 366 */ 367 private boolean toggleCheckState(String togglePref) { 368 toggleable = togglePref != null && !togglePref.equals(""); 369 370 // No identifier given, so return false (= show the dialog) 371 if(!toggleable) 372 return false; 373 374 this.togglePref = togglePref; 375 // The pref is true, if the dialog should be shown. 376 return !(Main.pref.getBoolean("message."+ togglePref, true)); 377 } 378 379 /** 380 * This function checks the state of the "Do not show again" checkbox and 381 * writes the corresponding pref 382 */ 383 private void toggleSaveState() { 384 if(!toggleable || toggleCheckbox == null) 385 return; 386 Main.pref.put("message."+ togglePref, !toggleCheckbox.isSelected()); 387 } 388 389 /** 390 * Convenience function that converts a given string into a JMultilineLabel 391 * @param msg 392 * @return JMultilineLabel 393 */ 394 private static JMultilineLabel string2label(String msg) { 395 JMultilineLabel lbl = new JMultilineLabel(msg); 396 // Make it not wider than 2/3 of the screen 397 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 398 lbl.setMaxWidth(Math.round(screenSize.width*2/3)); 399 return lbl; 206 400 } 207 401 } -
/trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r2024 r2060 9 9 import java.io.PrintStream; 10 10 import java.io.Reader; 11 11 import java.util.Arrays; 12 import java.util.List; 13 14 import javax.swing.BorderFactory; 15 16 import org.openstreetmap.josm.Main; 12 17 import org.openstreetmap.josm.actions.OpenFileAction; 13 18 … … 67 72 68 73 /* Constructor for JOSM file drop */ 69 public FileDrop(final java.awt.Component c) 70 { this( 71 null, // Logging stream 72 c, // Drop target 73 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border 74 true, // Recursive 75 new FileDrop.Listener() 76 { 77 public void filesDropped( java.io.File[] files ) 78 { 79 OpenFileAction ofa = new OpenFileAction(); 80 for( int i = 0; i < files.length; i++ ) 81 { 82 ofa.openFile(files[i]); 83 } // end for: through each dropped file 84 } // end filesDropped 85 }); // end FileDrop.Listener 74 public FileDrop(final java.awt.Component c){ 75 this( 76 null, // Logging stream 77 c, // Drop target 78 BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border 79 true, // Recursive 80 new FileDrop.Listener(){ 81 public void filesDropped( java.io.File[] files ){ 82 // start asynchronous loading of files 83 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(Arrays.asList(files)); 84 Main.worker.submit(task); 85 } 86 } 87 ); 86 88 } 87 88 89 89 90 /** … … 341 342 342 343 // Get a useful list 343 java.util.List fileList = (java.util.List)344 List fileList = (java.util.List) 344 345 tr.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor); 345 346 346 347 // Convert list to array 347 final java.io.File[] files = (File[]) fileList.toArray();;348 final File[] files = (File[]) fileList.toArray(); 348 349 349 350 // Alert listener to drop. -
/trunk/src/org/openstreetmap/josm/gui/MainApplet.java
r2024 r2060 10 10 import java.awt.event.KeyEvent; 11 11 import java.io.File; 12 import java.io.IOException; 12 13 import java.net.URL; 13 14 import java.util.Arrays; … … 36 37 public UploadPreferencesAction() { 37 38 super(tr("Upload Preferences"), "upload-preferences", tr("Upload the current preferences to the server"), 38 Shortcut.registerShortcut("applet:uploadprefs", tr("Upload Preferences"), KeyEvent.VK_U, Shortcut.GROUP_HOTKEY), true); 39 Shortcut.registerShortcut("applet:uploadprefs", tr("Upload Preferences"), KeyEvent.VK_U, Shortcut.GROUP_HOTKEY), true); 39 40 } 40 41 public void actionPerformed(ActionEvent e) { … … 70 71 for (String[] s : paramInfo) { 71 72 Collection<String> p = readParameter(s[0], args.get(s[0])); 72 if (p != null) 73 if (p != null) { 73 74 args.put(s[0], p); 75 } 74 76 } 75 77 if (!args.containsKey("geometry") && getParameter("width") != null && getParameter("height") != null) { … … 98 100 Main.pref = new ServerSidePreferences(getCodeBase()); 99 101 ((ServerSidePreferences)Main.pref).download(username, password); 100 101 102 Main.preConstructorInit(args); 102 103 Main.parent = this; … … 124 125 String param = getParameter(s); 125 126 if (param != null) { 126 if (v == null) 127 if (v == null) { 127 128 v = new LinkedList<String>(); 129 } 128 130 v.addAll(Arrays.asList(param.split(";"))); 129 131 } -
/trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r2024 r2060 47 47 mainFrame.addWindowListener(new WindowAdapter(){ 48 48 @Override public void windowClosing(final WindowEvent arg0) { 49 if ( Main.breakBecauseUnsavedChanges())49 if (!Main.saveUnsavedModifications()) 50 50 return; 51 51 Main.saveGuiGeometry(); … … 73 73 final Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); 74 74 for (String arg : argArray) { 75 if (!arg.startsWith("--")) 75 if (!arg.startsWith("--")) { 76 76 arg = "--download="+arg; 77 } 77 78 int i = arg.indexOf('='); 78 79 String key = i == -1 ? arg.substring(2) : arg.substring(2,i); 79 80 String value = i == -1 ? "" : arg.substring(i+1); 80 81 Collection<String> v = args.get(key); 81 if (v == null) 82 if (v == null) { 82 83 v = new LinkedList<String>(); 84 } 83 85 v.add(value); 84 86 args.put(key, v); … … 88 90 89 91 // Check if passed as parameter 90 if (args.containsKey("language")) 92 if (args.containsKey("language")) { 91 93 I18n.set((String)(args.get("language").toArray()[0])); 92 else94 } else { 93 95 I18n.set(Main.pref.get("language", null)); 96 } 94 97 95 98 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { … … 143 146 144 147 if (((!args.containsKey("no-maximize") && !args.containsKey("geometry") 145 && Main.pref.get("gui.geometry").length() == 0) || args.containsKey("maximize")) 146 && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH)) 148 && Main.pref.get("gui.geometry").length() == 0) || args.containsKey("maximize")) 149 && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH)) { 147 150 mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); 151 } 148 152 149 153 EventQueue.invokeLater(new Runnable() { … … 161 165 public static void removeObsoletePreferences() { 162 166 String[] obsolete = { 163 "sample.preference.that.does.not.exist", // sample comment, expiry date should go here 164 "osm-server.version", // remove this around 10/2009 165 "osm-server.additional-versions", // remove this around 10/2009 166 null 167 "sample.preference.that.does.not.exist", // sample comment, expiry date should go here 168 "osm-server.version", // remove this around 10/2009 169 "osm-server.additional-versions", // remove this around 10/2009 170 null 167 171 }; 168 172 for (String i : obsolete) { 169 if (i == null) continue; 173 if (i == null) { 174 continue; 175 } 170 176 if (Main.pref.hasKey(i)) { 171 177 Main.pref.removeFromCollection(i, Main.pref.get(i)); -
/trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r2024 r2060 173 173 continue; 174 174 } 175 if (osms != null && osms.equals(osmStatus) && ms.modifiers == oldModifiers) {175 if (osms.equals(osmStatus) && ms.modifiers == oldModifiers) { 176 176 continue; 177 177 } … … 194 194 final StringBuilder text = new StringBuilder(); 195 195 String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 196 if (osm. id== 0 || osm.modified) {196 if (osm.getId() == 0 || osm.isModified()) { 197 197 name = "<i><b>"+ osm.getDisplayName(DefaultNameFormatter.getInstance())+"*</b></i>"; 198 198 } 199 199 text.append(name); 200 if (osm. id!= 0) {201 text.append("<br>id="+osm. id);200 if (osm.getId() != 0) { 201 text.append("<br>id="+osm.getId()); 202 202 } 203 203 for (Entry<String, String> e : osm.entrySet()) { -
/trunk/src/org/openstreetmap/josm/gui/MapView.java
r2024 r2060 44 44 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 45 45 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener;47 46 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 48 47 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; … … 152 151 */ 153 152 public void addLayer(Layer layer) { 154 if (layer instanceof OsmDataLayer) {155 OsmDataLayer editLayer = (OsmDataLayer)layer;156 editLayer.listenerModified.add(new ModifiedChangedListener(){157 public void modifiedChanged(boolean value, OsmDataLayer source) {158 JOptionPane.getFrameForComponent(Main.parent).setTitle((value?"*":"")159 +tr("Java OpenStreetMap Editor"));160 }161 });162 }163 153 if (layer instanceof MarkerLayer && playHeadMarker == null) { 164 154 playHeadMarker = PlayHeadMarker.create(); … … 510 500 } 511 501 } 502 if (layer instanceof OsmDataLayer) { 503 refreshTitle((OsmDataLayer)layer); 504 } 512 505 513 506 /* This only makes the buttons look disabled. Disabling the actions as well requires … … 600 593 if (evt.getPropertyName().equals(Layer.VISIBLE_PROP)) { 601 594 repaint(); 595 } else if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP) 596 || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) { 597 OsmDataLayer layer = (OsmDataLayer)evt.getSource(); 598 if (layer == getEditLayer()) { 599 refreshTitle(layer); 600 } 601 } 602 } 603 604 protected void refreshTitle(OsmDataLayer layer) { 605 boolean dirty = layer.requiresSaveToFile() || layer.requiresUploadToServer(); 606 if (dirty) { 607 JOptionPane.getFrameForComponent(Main.parent).setTitle("* " + tr("Java OpenStreetMap Editor")); 608 } else { 609 JOptionPane.getFrameForComponent(Main.parent).setTitle(tr("Java OpenStreetMap Editor")); 602 610 } 603 611 } -
/trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2024 r2060 74 74 double dist = getDist100Pixel(); 75 75 return dist >= 2000 ? Math.round(dist/100)/10 +" km" : (dist >= 1 76 ? Math.round(dist*10)/10 +" m" : "< 1 m"); 76 ? Math.round(dist*10)/10 +" m" : "< 1 m"); 77 77 } 78 78 … … 112 112 center.east() - getWidth()/2.0*scale, 113 113 center.north() - getHeight()/2.0*scale), 114 new EastNorth( 115 center.east() + getWidth()/2.0*scale, 116 center.north() + getHeight()/2.0*scale)); 114 new EastNorth( 115 center.east() + getWidth()/2.0*scale, 116 center.north() + getHeight()/2.0*scale)); 117 117 }; 118 118 … … 121 121 Bounds b = getProjection().getWorldBoundsLatLon(); 122 122 return new ProjectionBounds(getProjection().latlon2eastNorth(b.min), 123 getProjection().latlon2eastNorth(b.max)); 123 getProjection().latlon2eastNorth(b.max)); 124 124 }; 125 125 … … 130 130 center.east() - getWidth()/2.0*scale, 131 131 center.north() - getHeight()/2.0*scale)), 132 getProjection().eastNorth2latlon(new EastNorth( 133 center.east() + getWidth()/2.0*scale, 134 center.north() + getHeight()/2.0*scale))); 132 getProjection().eastNorth2latlon(new EastNorth( 133 center.east() + getWidth()/2.0*scale, 134 center.north() + getHeight()/2.0*scale))); 135 135 }; 136 136 … … 189 189 if(lon < b.min.lon()) {changed = true; lon = b.min.lon(); } 190 190 else if(lon > b.max.lon()) {changed = true; lon = b.max.lon(); } 191 if(changed) 192 newCenter = new CachedLatLon(lat, lon).getEastNorth(); 191 if(changed) { 192 newCenter = new CachedLatLon(lat, lon).getEastNorth(); 193 } 193 194 if (!newCenter.equals(center)) { 194 195 EastNorth oldCenter = center; … … 211 212 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.max.lon())); 212 213 d = e2.east() - e1.east(); 213 if(d < width*newScale) 214 if(d < width*newScale) { 214 215 newScale = Math.max(newScaleH, d/width); 216 } 215 217 } 216 218 else 217 219 { 218 220 d = d/(l1.greatCircleDistance(l2)*height*10); 219 if(newScale < d) 221 if(newScale < d) { 220 222 newScale = d; 223 } 221 224 } 222 225 if (scale != newScale) { … … 296 299 return null; 297 300 for (Node n : ds.nodes) { 298 if (n. deleted|| n.incomplete) {301 if (n.isDeleted() || n.incomplete) { 299 302 continue; 300 303 } … … 307 310 // when multiple nodes on one point, prefer new or selected nodes 308 311 else if(dist == minDistanceSq && minPrimitive != null 309 && ((n. id== 0 && n.isSelected())310 || (!minPrimitive.isSelected() && (n.isSelected() || n. id== 0)))) {312 && ((n.getId() == 0 && n.isSelected()) 313 || (!minPrimitive.isSelected() && (n.isSelected() || n.getId() == 0)))) { 311 314 minPrimitive = n; 312 315 } … … 327 330 return null; 328 331 for (Way w : ds.ways) { 329 if (w. deleted|| w.incomplete) {332 if (w.isDeleted() || w.incomplete) { 330 333 continue; 331 334 } … … 334 337 for (Node n : w.getNodes()) { 335 338 i++; 336 if (n. deleted|| n.incomplete) {339 if (n.isDeleted() || n.incomplete) { 337 340 continue; 338 341 } … … 451 454 return null; 452 455 for (Way w : ds.ways) { 453 if (w. deleted|| w.incomplete) {456 if (w.isDeleted() || w.incomplete) { 454 457 continue; 455 458 } 456 459 Node lastN = null; 457 460 for (Node n : w.getNodes()) { 458 if (n. deleted|| n.incomplete) {461 if (n.isDeleted() || n.incomplete) { 459 462 continue; 460 463 } … … 477 480 } 478 481 for (Node n : ds.nodes) { 479 if (!n. deleted&& !n.incomplete482 if (!n.isDeleted() && !n.incomplete 480 483 && getPoint(n).distanceSq(p) < snapDistance) { 481 484 nearest.add(n); … … 499 502 return null; 500 503 for (Node n : ds.nodes) { 501 if (!n. deleted&& !n.incomplete504 if (!n.isDeleted() && !n.incomplete 502 505 && getPoint(n).distanceSq(p) < snapDistance) { 503 506 nearest.add(n); -
/trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java
r2024 r2060 85 85 setSize(Main.pref.getInteger("progressdialog.size", 600), 120); 86 86 } 87 88 @Override89 public void setVisible(boolean visible) {90 super.setVisible(visible);91 if (visible) {92 // make sure this dialog is always on top of the main JOSM window93 // and all the other windows (relation editors, detached dialogs, etc.)94 //95 toFront();96 }97 }98 87 } -
/trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r2024 r2060 45 45 */ 46 46 public PleaseWaitRunnable(String title, boolean ignoreException) { 47 this(title, new PleaseWaitProgressMonitor(), ignoreException); 47 this(title, new PleaseWaitProgressMonitor(title), ignoreException); 48 48 } 49 49 50 50 public PleaseWaitRunnable(String title, ProgressMonitor progressMonitor, boolean ignoreException) { 51 51 this.title = title; 52 this.progressMonitor = progressMonitor == null?new PleaseWaitProgressMonitor():progressMonitor; 52 this.progressMonitor = progressMonitor == null?new PleaseWaitProgressMonitor(title):progressMonitor; 53 53 this.ignoreException = ignoreException; 54 54 this.progressMonitor.addCancelListener(this); -
/trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r2024 r2060 286 286 // nodes 287 287 for (Node n : nc.getCurrentDataSet().nodes) { 288 if (!n. deleted&& !n.incomplete && r.contains(nc.getPoint(n))) {288 if (!n.isDeleted() && !n.incomplete && r.contains(nc.getPoint(n))) { 289 289 selection.add(n); 290 290 } … … 293 293 // ways 294 294 for (Way w : nc.getCurrentDataSet().ways) { 295 if (w. deleted|| w.getNodesCount() == 0 || w.incomplete) {295 if (w.isDeleted() || w.getNodesCount() == 0 || w.incomplete) { 296 296 continue; 297 297 } -
/trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r2024 r2060 56 56 */ 57 57 public abstract class ListMergeModel<T> extends Observable { 58 private static final Logger logger = Logger.getLogger(ListMergeModel.class.getName()); 58 //private static final Logger logger = Logger.getLogger(ListMergeModel.class.getName()); 59 59 60 60 public static final String FROZEN_PROP = ListMergeModel.class.getName() + ".frozen"; -
/trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r2024 r2060 45 45 */ 46 46 public abstract class ListMerger<T> extends JPanel implements PropertyChangeListener, Observer { 47 private static final Logger logger = Logger.getLogger(ListMerger.class.getName()); 47 //private static final Logger logger = Logger.getLogger(ListMerger.class.getName()); 48 48 49 49 protected JTable myEntriesTable; -
/trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r2024 r2060 29 29 */ 30 30 public class NodeListTableCellRenderer extends JLabel implements TableCellRenderer { 31 static private final Logger logger = Logger.getLogger(NodeListTableCellRenderer.class.getName()); 32 private static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000"); 31 //static private final Logger logger = Logger.getLogger(NodeListTableCellRenderer.class.getName()); 32 //private static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000"); 33 33 public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 34 34 public final static Color BGCOLOR_EMPTY_ROW = new Color(234,234,234); … … 67 67 // 68 68 sb.append("<strong>id</strong>=") 69 .append(primitive. id)69 .append(primitive.getId()) 70 70 .append("<br>"); 71 71 … … 168 168 reset(); 169 169 switch(column) { 170 case 0: 171 renderRowId(getModel(table),row, isSelected); 172 break; 173 case 1: 174 if (node == null) { 175 renderEmptyRow(); 176 } else { 177 renderNode(getModel(table), node, row, isSelected); 178 } 179 break; 180 default: 181 // should not happen 182 throw new RuntimeException(tr("unexpected column index. Got {0}", column)); 170 case 0: 171 renderRowId(getModel(table),row, isSelected); 172 break; 173 case 1: 174 if (node == null) { 175 renderEmptyRow(); 176 } else { 177 renderNode(getModel(table), node, row, isSelected); 178 } 179 break; 180 default: 181 // should not happen 182 throw new RuntimeException(tr("unexpected column index. Got {0}", column)); 183 183 } 184 184 return this; -
/trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2024 r2060 47 47 import org.openstreetmap.josm.gui.MapView; 48 48 import org.openstreetmap.josm.gui.SideButton; 49 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 49 50 import org.openstreetmap.josm.gui.layer.Layer; 50 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 61 62 */ 62 63 public class LayerListDialog extends ToggleDialog { 63 static private final Logger logger = Logger.getLogger(LayerListDialog.class.getName()); 64 //static private final Logger logger = Logger.getLogger(LayerListDialog.class.getName()); 64 65 65 66 /** the unique instance of the dialog */ … … 299 300 } 300 301 301 protected boolean confirmSkipSaving(OsmDataLayer layer) { 302 int result = new ExtendedDialog(Main.parent, 303 tr("Unsaved Changes"), 304 tr("There are unsaved changes in the layer''{0}''. Delete the layer anwyay?",layer.getName()), 305 new String[] {tr("Delete Layer"), tr("Cancel")}, 306 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 307 308 return result == 1; 309 } 310 311 protected boolean confirmDeleteLayer(Layer layer) { 312 return ConditionalOptionPaneUtil.showConfirmationDialog( 313 "delete_layer", 314 Main.parent, 315 tr("Do you really want to delete layer ''{0}''?", layer.getName()), 316 tr("Confirmation"), 317 JOptionPane.YES_NO_OPTION, 318 JOptionPane.QUESTION_MESSAGE, 319 JOptionPane.YES_OPTION); 320 } 321 322 protected DeleteDecision confirmDeleteMultipleLayer(Layer layer, int idx, int numLayers) { 323 String options[] = new String[] { 324 tr("Yes"), 325 tr("No"), 326 tr("Delete all"), 327 tr("Cancel") 328 }; 329 int ret = ConditionalOptionPaneUtil.showOptionDialog( 330 "delete_layer", 331 Main.parent, 332 tr("Do you really want to delete layer ''{0}''?", layer.getName()), 333 tr("Deleting layer {0} of {1}", idx+1, numLayers), 334 JOptionPane.DEFAULT_OPTION, 335 JOptionPane.QUESTION_MESSAGE, 336 options, 337 options[0] 338 ); 339 switch(ret) { 340 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return DeleteDecision.deleteAll; 341 case JOptionPane.CLOSED_OPTION: return DeleteDecision.cancel; 342 case 0: return DeleteDecision.deleteCurrent; 343 case 1: return DeleteDecision.dontDeleteCurrent; 344 case 2: return DeleteDecision.deleteAll; 345 case 3: return DeleteDecision.cancel; 346 default: 347 // shouldn't happen. This is the safest option. 348 return DeleteDecision.cancel; 349 } 350 } 351 352 353 public void deleteSingleLayer(Layer layer) { 354 if (layer == null) 302 protected boolean enforceUploadOrSaveModifiedData(List<Layer> selectedLayers) { 303 SaveLayersDialog dialog = new SaveLayersDialog(Main.parent); 304 List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>(); 305 for (Layer l: selectedLayers) { 306 if (! (l instanceof OsmDataLayer)) { 307 continue; 308 } 309 OsmDataLayer odl = (OsmDataLayer)l; 310 if (odl.requiresSaveToFile() || odl.requiresUploadToServer()) { 311 layersWithUnmodifiedChanges.add(odl); 312 } 313 } 314 dialog.prepareForSavingAndUpdatingLayersBeforeDelete(); 315 if (!layersWithUnmodifiedChanges.isEmpty()) { 316 dialog.getModel().populate(layersWithUnmodifiedChanges); 317 dialog.setVisible(true); 318 switch(dialog.getUserAction()) { 319 case CANCEL: return false; 320 case PROCEED: return true; 321 default: return false; 322 } 323 } 324 return true; 325 } 326 327 public void actionPerformed(ActionEvent e) { 328 List<Layer> selectedLayers; 329 if (this.layer == null) { 330 selectedLayers = getModel().getSelectedLayers(); 331 } else { 332 selectedLayers = Collections.singletonList(this.layer); 333 } 334 if (selectedLayers.isEmpty()) 355 335 return; 356 if (layer instanceof OsmDataLayer) { 357 OsmDataLayer dataLayer = (OsmDataLayer)layer; 358 if (dataLayer.isModified()) { 359 if (! confirmSkipSaving(dataLayer)) 360 return; 361 } 362 else if (!confirmDeleteLayer(dataLayer)) 363 return; 364 } else { 365 if (!confirmDeleteLayer(layer)) 366 return; 367 } 368 // model and view are going to be updated via LayerChangeListener 369 // 370 Main.main.removeLayer(layer); 371 } 372 373 public void deleteMultipleLayers(List<Layer> layers) { 374 boolean doAskConfirmation = true; 375 for (int i=0; i < layers.size(); i++) { 376 Layer layer = layers.get(i); 377 if (layer instanceof OsmDataLayer) { 378 OsmDataLayer dataLayer = (OsmDataLayer)layer; 379 if (dataLayer.isModified() && ! confirmSkipSaving(dataLayer)) { 380 continue; 381 } 382 } 383 if (doAskConfirmation) { 384 DeleteDecision decision = confirmDeleteMultipleLayer(layer, i, layers.size()); 385 switch(decision) { 386 case deleteCurrent: /* do nothing */ break; 387 case deleteAll: doAskConfirmation = false; break; 388 case dontDeleteCurrent: continue; 389 case cancel: return; 390 } 391 } 392 // model and view are going to be updated via LayerChangeListener 393 // 394 Main.main.removeLayer(layer); 395 } 396 } 397 398 public void actionPerformed(ActionEvent e) { 399 if (this.layer == null) { 400 List<Layer> selectedLayers = getModel().getSelectedLayers(); 401 if (selectedLayers.isEmpty()) 402 return; 403 if (selectedLayers.size() == 1) { 404 deleteSingleLayer(selectedLayers.get(0)); 405 } else { 406 deleteMultipleLayers(selectedLayers); 407 } 408 } else { 409 deleteSingleLayer(this.layer); 336 if (! enforceUploadOrSaveModifiedData(selectedLayers)) 337 return; 338 for(Layer l: selectedLayers) { 339 Main.main.removeLayer(l); 410 340 } 411 341 } -
/trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2024 r2060 306 306 void membershipEdit(int row) { 307 307 Relation relation = (Relation)membershipData.getValueAt(row, 0); 308 Main.ma in.map.relationListDialog.selectRelation(relation);308 Main.map.relationListDialog.selectRelation(relation); 309 309 RelationEditor.getEditor( 310 310 Main.map.mapView.getEditLayer(), … … 474 474 c.setFont(c.getFont().deriveFont(Font.ITALIC)); 475 475 } else { 476 final Map.Entry entry = (Map.Entry) v.entrySet().iterator().next(); 476 final Map.Entry entry = (Map.Entry) v.entrySet().iterator().next(); 477 477 str = (String) entry.getKey(); 478 478 } … … 636 636 } 637 637 638 LinkedList<TaggingPreset> p = new LinkedList<TaggingPreset>();639 638 presets.removeAll(); 640 639 int total = nodes+ways+relations+closedways; … … 751 750 if (Main.main.getCurrentDataSet() != null) { 752 751 for (Relation r : Main.main.getCurrentDataSet().relations) { 753 if (!r. deleted&& !r.incomplete) {752 if (!r.isDeleted() && !r.incomplete) { 754 753 for (RelationMember m : r.getMembers()) { 755 754 if (newSelection.contains(m.getMember())) { … … 831 830 protected void deleteFromRelation(int row) { 832 831 Relation cur = (Relation)membershipData.getValueAt(row, 0); 833 int result = new ExtendedDialog(Main.parent, 832 833 ExtendedDialog ed = new ExtendedDialog(Main.parent, 834 834 tr("Change relation"), 835 tr("Really delete selection from relation {0}?", cur.getDisplayName(DefaultNameFormatter.getInstance())), 836 new String[] {tr("Delete from relation"), tr("Cancel")}, 837 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 838 839 if(result != 1) 835 new String[] {tr("Delete from relation"), tr("Cancel")}); 836 ed.setButtonIcons(new String[] {"dialogs/delete.png", "cancel.png"}); 837 ed.setContent(tr("Really delete selection from relation {0}?", cur.getDisplayName(DefaultNameFormatter.getInstance()))); 838 ed.showDialog(); 839 840 if(ed.getValue() != 1) 840 841 return; 841 842 842 843 Relation rel = new Relation(cur); 843 844 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 844 int index = 0; 845 for (RelationMember rm : cur.getMembers()) { 846 for (OsmPrimitive osm : sel) { 847 if (rm.getMember() == osm) 848 { 849 rel.removeMember(index); 850 break; 851 } 852 } 853 index++; 845 for (OsmPrimitive primitive: sel) { 846 rel.removeMembersFor(primitive); 854 847 } 855 848 Main.main.undoRedo.add(new ChangeCommand(cur, rel)); -
/trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2024 r2060 135 135 int i = 0; 136 136 for (OsmPrimitive e : DataSet.sort(Main.main.getCurrentDataSet().relations)) { 137 if (!e. deleted&& !e.incomplete) {137 if (!e.isDeleted() && !e.incomplete) { 138 138 list.setElementAt(e, i++); 139 139 } … … 381 381 Relation copy = new Relation(); 382 382 copy.cloneFrom(original); 383 // FIXME: id is going to be hidden. How to reset a primitive? 384 // 383 385 copy.id = 0; 384 copy. modified= true;386 copy.setModified(true); 385 387 RelationEditor editor = RelationEditor.getEditor( 386 388 Main.main.getEditLayer(), -
/trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r2024 r2060 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.BorderLayout; 8 import java.awt.FlowLayout; 9 import java.awt.event.ActionEvent; 7 10 import java.awt.event.KeyEvent; 11 import java.awt.event.MouseAdapter; 8 12 import java.awt.event.MouseEvent; 9 import java.awt.event.MouseListener; 10 import java.util.Arrays; 13 import java.io.UnsupportedEncodingException; 14 import java.net.URLEncoder; 15 import java.text.NumberFormat; 16 import java.util.ArrayList; 11 17 import java.util.Collection; 12 import java.util.Co mparator;18 import java.util.Collections; 13 19 import java.util.HashMap; 20 import java.util.HashSet; 21 import java.util.Iterator; 14 22 import java.util.LinkedList; 15 23 import java.util.List; 24 import java.util.Map; 25 import java.util.Set; 26 27 import javax.swing.AbstractAction; 28 import javax.swing.JOptionPane; 29 import javax.swing.JPanel; 16 30 import javax.swing.JScrollPane; 17 31 import javax.swing.JTable; 18 32 import javax.swing.ListSelectionModel; 33 import javax.swing.event.ListSelectionEvent; 34 import javax.swing.event.ListSelectionListener; 19 35 import javax.swing.table.DefaultTableModel; 20 36 21 37 import org.openstreetmap.josm.Main; 38 import org.openstreetmap.josm.actions.AbstractInfoAction; 22 39 import org.openstreetmap.josm.data.SelectionChangedListener; 23 40 import org.openstreetmap.josm.data.osm.DataSet; 24 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 42 import org.openstreetmap.josm.data.osm.User; 43 import org.openstreetmap.josm.gui.SideButton; 26 44 import org.openstreetmap.josm.gui.layer.Layer; 27 45 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 28 46 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 47 import org.openstreetmap.josm.tools.ImageProvider; 29 48 import org.openstreetmap.josm.tools.Shortcut; 30 49 … … 33 52 * selection area, along with the number of objects. 34 53 * 35 * @author Frederik Ramm <frederik@remote.org>36 54 */ 37 public class UserListDialog extends ToggleDialog implements SelectionChangedListener, MouseListener,LayerChangeListener {55 public class UserListDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener { 38 56 39 57 /** 40 58 * The display list. 41 59 */ 42 private final DefaultTableModel data = new DefaultTableModel() { 43 @Override public boolean isCellEditable(int row, int column) { 44 return false; 45 } 46 @Override public Class<?> getColumnClass(int columnIndex) { 47 return columnIndex == 0 ? String.class : Integer.class; 48 } 49 }; 50 51 private JTable userTable = new JTable(data); 52 53 private static User anonymousUser = User.get("(anonymous users)"); 60 private JTable userTable; 61 private UserTableModel model; 62 private SelectUsersPrimitivesAction selectionUsersPrimitivesAction; 63 private ShowUserInfoAction showUserInfoAction; 54 64 55 65 public UserListDialog() { … … 57 67 Shortcut.registerShortcut("subwindow:authors", tr("Toggle: {0}", tr("Authors")), KeyEvent.VK_A, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150); 58 68 59 data.setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%"}); 60 userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 61 add(new JScrollPane(userTable), BorderLayout.CENTER); 62 if (Main.main.getCurrentDataSet() != null) { 63 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 64 } 65 userTable.addMouseListener(this); 69 build(); 66 70 DataSet.selListeners.add(this); 67 71 Layer.listeners.add(this); 68 72 } 69 73 70 @Override public void setVisible(boolean b) { 71 super.setVisible(b); 72 if (b && Main.main.getCurrentDataSet() != null) { 73 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 74 } 74 protected JPanel buildButtonRow() { 75 JPanel pnl = new JPanel(); 76 pnl.setLayout(new FlowLayout(FlowLayout.LEFT)); 77 78 // -- select users primitives action 79 // 80 selectionUsersPrimitivesAction = new SelectUsersPrimitivesAction(); 81 userTable.getSelectionModel().addListSelectionListener(selectionUsersPrimitivesAction); 82 pnl.add(new SideButton(selectionUsersPrimitivesAction)); 83 84 // -- info action 85 // 86 showUserInfoAction = new ShowUserInfoAction(); 87 userTable.getSelectionModel().addListSelectionListener(showUserInfoAction); 88 pnl.add(new SideButton(showUserInfoAction)); 89 return pnl; 90 } 91 92 protected void build() { 93 JPanel pnl = new JPanel(); 94 pnl.setLayout(new BorderLayout()); 95 model = new UserTableModel(); 96 userTable = new JTable(model); 97 userTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 98 pnl.add(new JScrollPane(userTable), BorderLayout.CENTER); 99 100 // -- the button row 101 pnl.add(buildButtonRow(), BorderLayout.SOUTH); 102 userTable.addMouseListener(new DoubleClickAdapter()); 103 add(pnl, BorderLayout.CENTER); 75 104 } 76 105 … … 80 109 */ 81 110 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 82 if (!isVisible()) 83 return; 84 85 class UserCount { 86 User user; 87 int count; 88 UserCount(User user, int count) { this.user=user; this.count=count; } 89 } 90 91 if (data == null) 92 return; // selection changed may be received in base class constructor before init 93 94 data.setRowCount(0); 95 96 HashMap<User,UserCount> counters = new HashMap<User,UserCount>(); 97 int all = 0; 98 for (OsmPrimitive p : newSelection) { 99 User u = p.user; 100 if (u == null) { 101 u = anonymousUser; 102 } 103 UserCount uc = counters.get(u); 104 if (uc == null) { 105 counters.put(u, uc = new UserCount(u, 0)); 106 } 107 uc.count++; 108 all++; 109 } 110 UserCount[] ucArr = new UserCount[counters.size()]; 111 counters.values().toArray(ucArr); 112 Arrays.sort(ucArr, new Comparator<UserCount>() { 113 public int compare(UserCount a, UserCount b) { 114 return (a.count<b.count) ? 1 : (a.count>b.count) ? -1 : 0; 115 } 116 }); 117 118 for (UserCount uc : ucArr) { 119 data.addRow(new Object[] { uc.user.name, uc.count, uc.count * 100 / all }); 120 } 121 122 if(ucArr.length != 0) { 123 setTitle(tr("Authors: {0}", ucArr.length)); 111 refresh(newSelection); 112 } 113 114 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 115 if (newLayer instanceof OsmDataLayer) { 116 refresh(((OsmDataLayer) newLayer).data.getSelected()); 117 } else { 118 refresh(null); 119 } 120 } 121 122 public void layerAdded(Layer newLayer) { 123 // do nothing 124 } 125 126 public void layerRemoved(Layer oldLayer) { 127 // do nothing 128 } 129 130 public void refresh(Collection<? extends OsmPrimitive> fromPrimitives) { 131 model.populate(fromPrimitives); 132 if(model.getRowCount() != 0) { 133 setTitle(trn("{0} Author", "{0} Authors", model.getRowCount() , model.getRowCount())); 124 134 } else { 125 135 setTitle(tr("Authors")); … … 127 137 } 128 138 129 public void mouseClicked(MouseEvent e) { 130 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount()==2) { 131 int index = userTable.getSelectedRow(); 132 String userName = (String) data.getValueAt(index, 0); 133 if (userName==null) 134 return; 139 class SelectUsersPrimitivesAction extends AbstractAction implements ListSelectionListener{ 140 public SelectUsersPrimitivesAction() { 141 putValue(NAME, tr("Select")); 142 putValue(SHORT_DESCRIPTION, tr("Select primitives submitted by this user")); 143 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select")); 144 updateEnabledState(); 145 } 146 147 public void select() { 148 int indexes[] = userTable.getSelectedRows(); 149 if (indexes == null || indexes.length == 0) return; 150 model.selectPrimitivesOwnedBy(userTable.getSelectedRows()); 151 } 152 153 public void actionPerformed(ActionEvent e) { 154 select(); 155 } 156 157 protected void updateEnabledState() { 158 setEnabled(userTable != null && userTable.getSelectedRowCount() > 0); 159 } 160 161 public void valueChanged(ListSelectionEvent e) { 162 updateEnabledState(); 163 } 164 } 165 166 /** 167 * Action for launching the info page of a user 168 */ 169 class ShowUserInfoAction extends AbstractInfoAction implements ListSelectionListener { 170 171 public ShowUserInfoAction() { 172 putValue(NAME, tr("Show info")); 173 putValue(SHORT_DESCRIPTION, tr("Launches a browser with information about the user")); 174 putValue(SMALL_ICON, ImageProvider.get("about")); 175 updateEnabledState(); 176 } 177 178 @Override 179 public void actionPerformed(ActionEvent e) { 180 int rows[] = userTable.getSelectedRows(); 181 if (rows == null || rows.length == 0) return; 182 List<User> users = model.getSelectedUsers(rows); 183 if (users.isEmpty()) return; 184 if (users.size() > 10) { 185 System.out.println(tr("Warning: only launching info browsers for the first {0} of {1} selected users", 10, users.size())); 186 } 187 int num = Math.min(10, users.size()); 188 Iterator<User> it = users.iterator(); 189 while(it.hasNext() && num > 0) { 190 String url = createInfoUrl(it.next()); 191 if (url == null) { 192 break; 193 } 194 launchBrowser(url); 195 num--; 196 } 197 } 198 199 @Override 200 protected String createInfoUrl(Object infoObject) { 201 User user = (User)infoObject; 202 try { 203 return getBaseUserUrl() + "/" + URLEncoder.encode(user.name, "UTF-8"); 204 } catch(UnsupportedEncodingException e) { 205 e.printStackTrace(); 206 JOptionPane.showMessageDialog( 207 Main.parent, 208 tr("<html>Failed to create an URL because the encoding ''{0}'' was<br>" 209 + "was missing on this system.</html>", "UTF-8"), 210 tr("Missing encoding"), 211 JOptionPane.ERROR_MESSAGE 212 ); 213 return null; 214 } 215 } 216 217 @Override 218 protected void updateEnabledState() { 219 setEnabled(userTable != null && userTable.getSelectedRowCount() > 0); 220 } 221 222 public void valueChanged(ListSelectionEvent e) { 223 updateEnabledState(); 224 } 225 } 226 227 class DoubleClickAdapter extends MouseAdapter { 228 @Override 229 public void mouseClicked(MouseEvent e) { 230 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount()==2) { 231 selectionUsersPrimitivesAction.select(); 232 } 233 } 234 } 235 236 /** 237 * Action for selecting the primitives contributed by the currently selected 238 * users. 239 * 240 */ 241 private static class UserInfo implements Comparable<UserInfo> { 242 public User user; 243 public int count; 244 public double percent; 245 UserInfo(User user, int count, double percent) { 246 this.user=user; 247 this.count=count; 248 this.percent = percent; 249 } 250 public int compareTo(UserInfo o) { 251 if (count < o.count) return 1; 252 if (count > o.count) return -1; 253 if (user== null || user.name == null) return 1; 254 if (o.user == null || o.user.name == null) return -1; 255 return user.name.compareTo(o.user.name); 256 } 257 258 public String getName() { 259 if (user == null) return null; 260 return user.name; 261 } 262 } 263 264 /** 265 * The table model for the users 266 * 267 */ 268 class UserTableModel extends DefaultTableModel { 269 private ArrayList<UserInfo> data; 270 271 public UserTableModel() { 272 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%"}); 273 data = new ArrayList<UserInfo>(); 274 } 275 276 protected Map<User, Integer> computeStatistics(Collection<? extends OsmPrimitive> primitives) { 277 HashMap<User, Integer> ret = new HashMap<User, Integer>(); 278 if (primitives == null || primitives.isEmpty()) return ret; 279 for (OsmPrimitive primitive: primitives) { 280 if (primitive.user == null) { 281 continue; 282 } 283 if (ret.containsKey(primitive.user)) { 284 ret.put(primitive.user, ret.get(primitive.user) + 1); 285 } else { 286 ret.put(primitive.user, 1); 287 } 288 } 289 return ret; 290 } 291 292 public void populate(Collection<? extends OsmPrimitive> primitives) { 293 Map<User,Integer> statistics = computeStatistics(primitives); 294 data.clear(); 295 if (primitives != null) { 296 for (Map.Entry<User, Integer> entry: statistics.entrySet()) { 297 data.add(new UserInfo(entry.getKey(), entry.getValue(), (double)entry.getValue() / (double)primitives.size())); 298 } 299 } 300 Collections.sort(data); 301 fireTableDataChanged(); 302 } 303 304 @Override 305 public int getRowCount() { 306 if (data == null) return 0; 307 return data.size(); 308 } 309 310 @Override 311 public Object getValueAt(int row, int column) { 312 UserInfo info = data.get(row); 313 switch(column) { 314 case 0: /* author */ return info.getName() == null ? "" : info.getName(); 315 case 1: /* count */ return info.count; 316 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 317 } 318 return null; 319 } 320 321 @Override 322 public boolean isCellEditable(int row, int column) { 323 return false; 324 } 325 326 public void selectPrimitivesOwnedBy(int [] rows) { 327 Set<User> users= new HashSet<User>(); 328 for (int index: rows) { 329 if (data.get(index).user == null) { 330 continue; 331 } 332 users.add(data.get(index).user); 333 } 135 334 Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected(); 136 335 Collection<OsmPrimitive> byUser = new LinkedList<OsmPrimitive>(); 137 336 for (OsmPrimitive p : selected) { 138 if (p.user!= null && userName.equals(p.user.name)) { 337 if (p.user == null) { 338 continue; 339 } 340 if (users.contains(p.user)) { 139 341 byUser.add(p); 140 342 } … … 142 344 Main.main.getCurrentDataSet().setSelected(byUser); 143 345 } 144 } 145 146 public void mouseEntered(MouseEvent e) { 147 } 148 149 public void mouseExited(MouseEvent e) { 150 } 151 152 public void mousePressed(MouseEvent e) { 153 } 154 155 public void mouseReleased(MouseEvent e) { 156 } 157 158 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 159 if (newLayer instanceof OsmDataLayer) { 160 OsmDataLayer dataLayer = (OsmDataLayer)newLayer; 161 selectionChanged(dataLayer.data.getSelected()); 162 163 } 164 } 165 166 public void layerAdded(Layer newLayer) { 167 // do nothing 168 } 169 170 public void layerRemoved(Layer oldLayer) { 171 // do nothing 346 347 public List<User> getSelectedUsers(int rows[]) { 348 LinkedList<User> ret = new LinkedList<User>(); 349 if (rows == null || rows.length == 0) return ret; 350 for (int row: rows) { 351 if (data.get(row).user == null) { 352 continue; 353 } 354 ret.add(data.get(row).user); 355 } 356 return ret; 357 } 172 358 } 173 359 } -
/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2024 r2060 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.awt.event.ComponentAdapter;14 import java.awt.event.ComponentEvent;15 13 import java.awt.event.FocusAdapter; 16 14 import java.awt.event.FocusEvent; … … 68 66 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 69 67 import org.openstreetmap.josm.gui.SideButton; 70 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache;71 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList;72 68 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 73 69 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 74 70 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 71 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 72 import org.openstreetmap.josm.gui.tagging.TagCellEditor; 73 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 74 import org.openstreetmap.josm.gui.tagging.TagTable; 75 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 76 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 75 77 import org.openstreetmap.josm.io.OsmApi; 76 78 import org.openstreetmap.josm.io.OsmServerObjectReader; … … 123 125 // 124 126 acCache = AutoCompletionCache.getCacheForLayer(getLayer()); 125 acCache.initFrom JOSMDataset();127 acCache.initFromDataSet(); 126 128 acList = new AutoCompletionList(); 127 129 … … 268 270 final JScrollPane scrollPane = new JScrollPane(tagTable); 269 271 270 // this adapters ensures that the width of the tag table columns is adjusted271 // to the width of the scroll pane viewport. Also tried to overwrite272 // getPreferredViewportSize() in JTable, but did not work.273 //274 scrollPane.addComponentListener(new ComponentAdapter() {275 @Override276 public void componentResized(ComponentEvent e) {277 super.componentResized(e);278 Dimension d = scrollPane.getViewport().getExtentSize();279 tagTable.adjustColumnWidth(d.width);280 }281 });282 283 272 GridBagConstraints gc = new GridBagConstraints(); 284 273 gc.gridx = 0; … … 330 319 331 320 final JScrollPane scrollPane = new JScrollPane(memberTable); 332 // this adapters ensures that the width of the tag table columns is adjusted333 // to the width of the scroll pane viewport. Also tried to overwrite334 // getPreferredViewportSize() in JTable, but did not work.335 //336 scrollPane.addComponentListener(new ComponentAdapter() {337 @Override338 public void componentResized(ComponentEvent e) {339 super.componentResized(e);340 Dimension d = scrollPane.getViewport().getExtentSize();341 memberTable.adjustColumnWidth(d.width);342 }343 });344 321 345 322 GridBagConstraints gc = new GridBagConstraints(); … … 1355 1332 1356 1333 protected void updateEnabledState() { 1357 setEnabled(getRelation() != null && getRelation(). id> 0);1334 setEnabled(getRelation() != null && getRelation().getId() > 0); 1358 1335 } 1359 1336 } … … 1559 1536 try { 1560 1537 progressMonitor.indeterminateSubTask(""); 1561 OsmServerObjectReader reader = new OsmServerObjectReader(getRelation(). id, OsmPrimitiveType.RELATION,1538 OsmServerObjectReader reader = new OsmServerObjectReader(getRelation().getId(), OsmPrimitiveType.RELATION, 1562 1539 true); 1563 1540 DataSet dataSet = reader.parseOsm(progressMonitor -
/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberRoleCellEditor.java
r2024 r2060 9 9 import javax.swing.table.TableCellEditor; 10 10 11 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache; 12 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionItemPritority; 13 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList; 14 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionListItem; 11 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 12 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 13 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; 14 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 15 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 15 16 16 17 public class MemberRoleCellEditor extends AbstractCellEditor implements TableCellEditor { -
/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r2024 r2060 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Container; 7 import java.awt.Dimension; 6 8 import java.awt.event.ActionEvent; 7 9 import java.awt.event.KeyEvent; … … 13 15 import javax.swing.JPopupMenu; 14 16 import javax.swing.JTable; 17 import javax.swing.JViewport; 15 18 import javax.swing.KeyStroke; 16 19 import javax.swing.ListSelectionModel; … … 72 75 } 73 76 74 /** 75 * adjusts the width of the columns for the tag name and the tag value to the width of the 76 * scroll panes viewport. 77 * 78 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected 79 * 80 * @param scrollPaneWidth the width of the scroll panes viewport 81 */ 82 public void adjustColumnWidth(int scrollPaneWidth) { 83 TableColumnModel tcm = getColumnModel(); 84 int width = scrollPaneWidth; 85 width = width / 3; 86 if (width > 0) { 87 tcm.getColumn(0).setMinWidth(width); 88 tcm.getColumn(0).setMaxWidth(width); 89 tcm.getColumn(1).setMinWidth(width); 90 tcm.getColumn(1).setMaxWidth(width); 91 tcm.getColumn(2).setMinWidth(width); 92 tcm.getColumn(2).setMaxWidth(width); 93 94 } 77 @Override 78 public Dimension getPreferredSize(){ 79 Container c = getParent(); 80 while(c != null && ! (c instanceof JViewport)) { 81 c = c.getParent(); 82 } 83 if (c != null) { 84 Dimension d = super.getPreferredSize(); 85 d.width = c.getSize().width; 86 return d; 87 } 88 return super.getPreferredSize(); 95 89 } 96 90 -
/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java
r2024 r2060 107 107 getLayer(), 108 108 full, 109 new PleaseWaitProgressMonitor() 109 new PleaseWaitProgressMonitor(tr("Loading parent relations")) 110 110 ); 111 111 task.setContinuation( -
/trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2024 r2060 296 296 return p.equals(reference); 297 297 } 298 299 public HistoryOsmPrimitive getPrimitive(int row) { 300 return history.get(row); 301 } 298 302 } 299 303 -
/trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r2024 r2060 5 5 6 6 import java.awt.BorderLayout; 7 import java.awt.event.ActionEvent; 8 import java.awt.event.MouseEvent; 7 9 import java.text.SimpleDateFormat; 8 10 import java.util.Observable; … … 12 14 import javax.swing.JPanel; 13 15 16 import org.openstreetmap.josm.actions.AbstractInfoAction; 14 17 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 18 import org.openstreetmap.josm.tools.ImageProvider; 15 19 16 20 /** … … 42 46 if (primitive == null) 43 47 return ""; 48 String url = AbstractInfoAction.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId(); 44 49 String text = tr( 45 "<html>Version <strong>{0}</strong> created on <strong>{1}</strong> by <strong>{2}</strong> </html>",50 "<html>Version <strong>{0}</strong> created on <strong>{1}</strong> by <strong>{2}</strong> in changeset <strong>{3}</strong>", 46 51 Long.toString(primitive.getVersion()), 47 52 new SimpleDateFormat().format(primitive.getTimestamp()), 48 primitive.getUser() 53 primitive.getUser(), 54 primitive.getChangesetId() 49 55 ); 50 56 return text; -
/trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r2024 r2060 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.event.ActionEvent; 4 7 import java.awt.event.MouseAdapter; 5 8 import java.awt.event.MouseEvent; … … 9 12 10 13 import javax.swing.DefaultListSelectionModel; 14 import javax.swing.JPopupMenu; 11 15 import javax.swing.JTable; 12 16 import javax.swing.ListSelectionModel; 13 17 import javax.swing.event.ListSelectionEvent; 14 18 import javax.swing.event.ListSelectionListener; 19 20 import org.openstreetmap.josm.actions.AbstractInfoAction; 21 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 22 import org.openstreetmap.josm.tools.ImageProvider; 15 23 16 24 /** … … 22 30 23 31 private static Logger logger = Logger.getLogger(VersionTable.class.getName()); 32 private VersionTablePopupMenu popupMenu; 24 33 25 34 protected void build() { … … 27 36 addMouseListener(new MouseHandler()); 28 37 getSelectionModel().addListSelectionListener(new SelectionHandler()); 38 popupMenu = new VersionTablePopupMenu(); 39 addMouseListener(new PopupMenuTrigger()); 29 40 } 30 41 … … 36 47 37 48 protected void handleSelectReferencePointInTime(int row) { 38 getVesionTableModel().setReferencePointInTime(row); 49 getVersionTableModel().setReferencePointInTime(row); 39 50 } 40 51 41 52 protected void handleSelectCurrentPointInTime(int row) { 42 getVesionTableModel().setCurrentPointInTime(row); 53 getVersionTableModel().setCurrentPointInTime(row); 43 54 } 44 55 45 protected HistoryBrowserModel.VersionTableModel getVesionTableModel() { 56 protected HistoryBrowserModel.VersionTableModel getVersionTableModel() { 46 57 return (HistoryBrowserModel.VersionTableModel) getModel(); 47 58 } … … 73 84 repaint(); 74 85 } 86 87 protected void showPopupMenu(MouseEvent evt) { 88 HistoryBrowserModel.VersionTableModel model = getVersionTableModel(); 89 int row = getSelectedRow(); 90 if (row == -1) { 91 row = rowAtPoint(evt.getPoint()); 92 } 93 HistoryOsmPrimitive primitive = model.getPrimitive(row); 94 popupMenu.prepare(primitive); 95 popupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); 96 } 97 98 class PopupMenuTrigger extends MouseAdapter { 99 @Override 100 public void mousePressed(MouseEvent e) { 101 showPopup(e); 102 } 103 @Override 104 public void mouseReleased(MouseEvent e) { 105 showPopup(e); 106 } 107 private void showPopup(MouseEvent e) { 108 if (e.isPopupTrigger()) { 109 showPopupMenu(e); 110 } 111 } 112 } 113 114 class ChangesetInfoAction extends AbstractInfoAction { 115 private HistoryOsmPrimitive primitive; 116 117 public ChangesetInfoAction() { 118 putValue(NAME, tr("Changeset info")); 119 putValue(SHORT_DESCRIPTION, tr("Launch browser with information about the changeset")); 120 putValue(SMALL_ICON, ImageProvider.get("about")); 121 } 122 123 @Override 124 protected String createInfoUrl(Object infoObject) { 125 HistoryOsmPrimitive primitive = (HistoryOsmPrimitive) infoObject; 126 return getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId(); 127 } 128 129 @Override 130 public void actionPerformed(ActionEvent e) { 131 if (!isEnabled()) 132 return; 133 String url = createInfoUrl(primitive); 134 launchBrowser(url); 135 } 136 137 public void prepare(HistoryOsmPrimitive primitive) { 138 putValue(NAME, tr("Show changeset {0}", primitive.getChangesetId())); 139 this.primitive = primitive; 140 } 141 } 142 143 class VersionTablePopupMenu extends JPopupMenu { 144 145 private ChangesetInfoAction changesetInfoAction; 146 147 protected void build() { 148 changesetInfoAction = new ChangesetInfoAction(); 149 add(changesetInfoAction); 150 } 151 public VersionTablePopupMenu() { 152 super(); 153 build(); 154 } 155 156 public void prepare(HistoryOsmPrimitive primitive) { 157 changesetInfoAction.prepare(primitive); 158 invalidate(); 159 } 160 } 75 161 } -
/trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2024 r2060 895 895 } 896 896 } 897 new DownloadOsmTaskList().download(false, toDownload, new PleaseWaitProgressMonitor()); 897 new DownloadOsmTaskList().download(false, toDownload, new PleaseWaitProgressMonitor(tr("Download data"))); 898 898 } 899 899 } -
/trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r2024 r2060 45 45 46 46 /** keeps track of property change listeners */ 47 pr ivatePropertyChangeSupport propertyChangeSupport;47 protected PropertyChangeSupport propertyChangeSupport; 48 48 49 49 /** -
/trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2024 r2060 71 71 */ 72 72 public class OsmDataLayer extends Layer { 73 static public final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk"; 74 static public final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer"; 75 76 private boolean requiresSaveToFile = false; 77 private boolean requiresUploadToServer = false; 78 79 protected void setRequiresSaveToFile(boolean newValue) { 80 boolean oldValue = requiresSaveToFile; 81 requiresSaveToFile = newValue; 82 if (oldValue != newValue) { 83 propertyChangeSupport.firePropertyChange(REQUIRES_SAVE_TO_DISK_PROP, oldValue, newValue); 84 } 85 } 86 87 protected void setRequiresUploadToServer(boolean newValue) { 88 boolean oldValue = requiresUploadToServer; 89 requiresUploadToServer = newValue; 90 if (oldValue != newValue) { 91 propertyChangeSupport.firePropertyChange(REQUIRES_UPLOAD_TO_SERVER_PROP, oldValue, newValue); 92 } 93 } 73 94 74 95 /** the global counter for created data layers */ … … 96 117 private void inc(final OsmPrimitive osm, final int i) { 97 118 normal[i]++; 98 if (osm. deleted) {119 if (osm.isDeleted()) { 99 120 deleted[i]++; 100 121 } … … 113 134 } 114 135 115 public interface ModifiedChangedListener {116 void modifiedChanged(boolean value, OsmDataLayer source);117 }118 136 public interface CommandQueueListener { 119 137 void commandChanged(int queueSize, int redoSize); … … 130 148 private ConflictCollection conflicts; 131 149 132 /**133 * Whether the data of this layer was modified during the session.134 */135 private boolean modified = false;136 /**137 * Whether the data was modified due an upload of the data to the server.138 */139 public boolean uploadedModified = false;140 141 public final LinkedList<ModifiedChangedListener> listenerModified = new LinkedList<ModifiedChangedListener>();142 150 public final LinkedList<DataChangeListener> listenerDataChanged = new LinkedList<DataChangeListener>(); 143 151 … … 310 318 @Override public void visitBoundingBox(final BoundingXYVisitor v) { 311 319 for (final Node n : data.nodes) 312 if (!n. deleted&& !n.incomplete) {320 if (!n.isDeleted() && !n.incomplete) { 313 321 v.visit(n); 314 322 } 315 }316 317 /**318 * Cleanup the layer after save to disk. Just marks the layer as unmodified.319 * Leaves the undo/redo stack unchanged.320 *321 */322 public void cleanupAfterSaveToDisk() {323 setModified(false);324 323 } 325 324 … … 333 332 */ 334 333 public void cleanupAfterUpload(final Collection<OsmPrimitive> processed) { 335 336 334 // return immediately if an upload attempt failed 337 335 if (processed == null || processed.isEmpty()) … … 351 349 cleanIterator(it, processedSet); 352 350 } 353 354 setModified(true);355 351 } 356 352 … … 367 363 if (!processed.remove(osm)) 368 364 return; 369 osm. modified= false;370 if (osm. deleted) {365 osm.setModified(false); 366 if (osm.isDeleted()) { 371 367 it.remove(); 372 }373 }374 375 public boolean isModified() {376 return modified;377 }378 379 public void setModified(final boolean modified) {380 if (modified == this.modified)381 return;382 this.modified = modified;383 for (final ModifiedChangedListener l : listenerModified) {384 l.modifiedChanged(modified, this);385 368 } 386 369 } … … 392 375 int size = 0; 393 376 for (final OsmPrimitive osm : list) 394 if (!osm. deleted) {377 if (!osm.isDeleted()) { 395 378 size++; 396 379 } … … 446 429 447 430 public void fireDataChange() { 431 setRequiresSaveToFile(true); 432 setRequiresUploadToServer(true); 448 433 for (DataChangeListener dcl : listenerDataChanged) { 449 434 dcl.dataChanged(this); … … 456 441 HashSet<Node> doneNodes = new HashSet<Node>(); 457 442 for (Way w : data.ways) { 458 if (w.incomplete || w. deleted) {443 if (w.incomplete || w.isDeleted()) { 459 444 continue; 460 445 } … … 468 453 ArrayList<WayPoint> trkseg = null; 469 454 for (Node n : w.getNodes()) { 470 if (n.incomplete || n. deleted) {455 if (n.incomplete || n.isDeleted()) { 471 456 trkseg = null; 472 457 continue; … … 492 477 // records them? 493 478 for (Node n : data.nodes) { 494 if (n.incomplete || n. deleted|| doneNodes.contains(n)) {479 if (n.incomplete || n.isDeleted() || doneNodes.contains(n)) { 495 480 continue; 496 481 } … … 546 531 return conflicts; 547 532 } 533 534 /** 535 * Replies true if the data managed by this layer needs to be uploaded to 536 * the server because it contains at least one modified primitive. 537 * 538 * @return true if the data managed by this layer needs to be uploaded to 539 * the server because it contains at least one modified primitive; false, 540 * otherwise 541 */ 542 public boolean requiresUploadToServer() { 543 return requiresUploadToServer; 544 } 545 546 /** 547 * Replies true if the data managed by this layer needs to be saved to 548 * a file. Only replies true if a file is assigned to this layer and 549 * if the data managed by this layer has been modified since the last 550 * save operation to the file. 551 * 552 * @return true if the data managed by this layer needs to be saved to 553 * a file 554 */ 555 public boolean requiresSaveToFile() { 556 return getAssociatedFile() != null && requiresSaveToFile; 557 } 558 559 /** 560 * Initializes the layer after a successful load of OSM data from a file 561 * 562 */ 563 public void onPostLoadFromFile() { 564 setRequiresSaveToFile(false); 565 setRequiresUploadToServer(data.isModified()); 566 } 567 568 /** 569 * Initializes the layer after a successful save of OSM data to a file 570 * 571 */ 572 public void onPostSaveToFile() { 573 setRequiresSaveToFile(false); 574 setRequiresUploadToServer(data.isModified()); 575 } 576 577 /** 578 * Initializes the layer after a successful upload to the server 579 * 580 */ 581 public void onPostUploadToServer() { 582 setRequiresUploadToServer(false); 583 // keep requiresSaveToDisk unchanged 584 } 548 585 } -
/trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r2024 r2060 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.ScrollPane; 9 import java.awt.event.MouseWheelEvent; 10 import java.awt.event.MouseWheelListener; 9 11 import java.util.ArrayList; 10 12 import java.util.Collection; … … 33 35 * @author imi 34 36 */ 35 public class PreferenceDialog extends JTabbedPane { 37 public class PreferenceDialog extends JTabbedPane implements MouseWheelListener { 36 38 37 39 private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>(); … … 116 118 public PreferenceDialog() { 117 119 super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); 120 121 super.addMouseWheelListener(this); 118 122 119 123 for (PreferenceSettingFactory factory:settingsFactory) { … … 174 178 settingsFactory.add(new AdvancedPreference.Factory()); 175 179 } 180 181 /** 182 * This mouse wheel listener reacts when a scroll is carried out over the 183 * tab strip and scrolls one tab/down or up, selecting it immediately. 184 */ 185 public void mouseWheelMoved(MouseWheelEvent wev) { 186 // Ensure the cursor is over the tab strip 187 if(super.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0) 188 return; 189 190 // Get currently selected tab 191 int newTab = super.getSelectedIndex() + wev.getWheelRotation(); 192 193 // Ensure the new tab index is sound 194 newTab = newTab < 0 ? 0 : newTab; 195 newTab = newTab >= super.getTabCount() ? super.getTabCount() - 1 : newTab; 196 197 // select new tab 198 super.setSelectedIndex(newTab); 199 } 176 200 } -
/trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r2024 r2060 28 28 29 29 private PleaseWaitDialog dialog; 30 private String windowTitle; 30 31 31 32 public PleaseWaitProgressMonitor() { 33 this(""); 34 } 35 36 public PleaseWaitProgressMonitor(String windowTitle) { 32 37 this(JOptionPane.getFrameForComponent(Main.map)); 38 this.windowTitle = windowTitle; 33 39 } 34 40 … … 86 92 throw new ProgressException("PleaseWaitDialog parent must be either Frame or Dialog"); 87 93 94 if (windowTitle != null) { 95 dialog.setTitle(windowTitle); 96 } 88 97 dialog.cancel.setEnabled(true); 89 98 dialog.setCustomText(""); -
/trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r2024 r2060 18 18 import java.util.Collection; 19 19 import java.util.HashMap; 20 import java.util.HashSet;21 20 import java.util.LinkedHashMap; 22 21 import java.util.LinkedList; 23 22 import java.util.List; 24 import java.util.Set; 23 import java.util.TreeSet; 25 24 26 25 import javax.swing.AbstractAction; … … 45 44 import org.openstreetmap.josm.gui.ExtendedDialog; 46 45 import org.openstreetmap.josm.gui.QuadStateCheckBox; 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 47 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 48 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; 49 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 47 50 import org.openstreetmap.josm.io.MirroredInputStream; 48 51 import org.openstreetmap.josm.tools.GBC; … … 65 68 public String locale_name; 66 69 70 private static AutoCompletionList autoCompletionList; 71 72 public static AutoCompletionList getPresetAutocompletionList() { 73 if (autoCompletionList == null) { 74 autoCompletionList = new AutoCompletionList(); 75 } 76 return autoCompletionList; 77 } 78 67 79 public static abstract class Item { 80 protected void initAutoCompletionField(AutoCompletingTextField field, String key) { 81 OsmDataLayer layer = Main.main.getEditLayer(); 82 if (layer == null) return; 83 field.setAutoCompletionList(getPresetAutocompletionList()); 84 } 85 68 86 public boolean focus = false; 69 87 abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel); … … 73 91 74 92 public static class Usage { 75 Set<String> values; 76 Boolean hadKeys = false; 77 Boolean hadEmpty = false; 78 public Boolean allSimilar() 79 { 93 TreeSet<String> values; 94 boolean hadKeys = false; 95 boolean hadEmpty = false; 96 public boolean hasUniqueValue() { 80 97 return values.size() == 1 && !hadEmpty; 81 98 } 82 public Boolean unused() 83 { 99 100 public boolean unused() { 84 101 return values.size() == 0; 85 102 } 86 public String getFirst() 87 { 88 return (String)(values.toArray()[0]); 89 } 90 public Boolean hadKeys() 91 { 103 public String getFirst() { 104 return values.first(); 105 } 106 107 public boolean hadKeys() { 92 108 return hadKeys; 93 109 } … … 98 114 static Usage determineTextUsage(Collection<OsmPrimitive> sel, String key) { 99 115 Usage returnValue = new Usage(); 100 returnValue.values = new HashSet<String>();116 returnValue.values = new TreeSet<String>(); 101 117 for (OsmPrimitive s : sel) { 102 118 String v = s.get(key); … … 106 122 returnValue.hadEmpty = true; 107 123 } 108 returnValue.hadKeys = returnValue.had Keys | s.hasKeys();124 returnValue.hadKeys = ! returnValue.values.isEmpty() | returnValue.hadEmpty; 109 125 } 110 126 return returnValue; … … 114 130 115 131 Usage returnValue = new Usage(); 116 returnValue.values = new HashSet<String>();132 returnValue.values = new TreeSet<String>(); 117 133 for (OsmPrimitive s : sel) { 118 134 returnValue.values.add(OsmUtils.getNamedOsmBoolean(s.get(key))); … … 133 149 private JComponent value; 134 150 151 135 152 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 136 153 137 154 // find out if our key is already used in the selection. 138 155 Usage usage = determineTextUsage(sel, key); 139 if (usage.unused()) 140 {141 value = new JTextField();156 if (usage.unused()){ 157 AutoCompletingTextField textField = new AutoCompletingTextField(); 158 initAutoCompletionField(textField, key); 142 159 if (use_last_as_default && lastValue.containsKey(key)) { 143 ((JTextField)value).setText(lastValue.get(key));160 textField.setText(lastValue.get(key)); 144 161 } else { 145 ((JTextField)value).setText(default_); 146 } 162 textField.setText(default_); 163 } 164 value = textField; 147 165 originalValue = null; 148 } else if (usage. allSimilar()) {166 } else if (usage.hasUniqueValue()) { 149 167 // all objects use the same value 150 value= newJTextField();151 for (String s : usage.values) {152 ((JTextField) value).setText(s);153 }154 originalValue = ((JTextField)value).getText();168 AutoCompletingTextField textField = new AutoCompletingTextField(); 169 initAutoCompletionField(textField, key); 170 textField.setText(usage.getFirst()); 171 value = textField; 172 originalValue = usage.getFirst(); 155 173 } else { 156 174 // the objects have different values 157 value = new JComboBox(usage.values.toArray()); 158 ((JComboBox)value).setEditable(true); 159 ((JComboBox)value).getEditor().setItem(DIFFERENT); 175 AutoCompletingTextField textField = new AutoCompletingTextField(); 176 initAutoCompletionField(textField, key); 177 JComboBox comboBox = new JComboBox(usage.values.toArray()); 178 comboBox.setEditable(true); 179 comboBox.setEditor(textField); 180 comboBox.getEditor().setItem(DIFFERENT); 181 value=comboBox; 160 182 originalValue = DIFFERENT; 161 183 } … … 300 322 301 323 lhm = new LinkedHashMap<String,String>(); 302 if (!usage.allSimilar() && !usage.unused()) 303 { 324 if (!usage.hasUniqueValue() && !usage.unused()){ 304 325 lhm.put(DIFFERENT, DIFFERENT); 305 326 } … … 309 330 tr(display_array[i]) : display_array[i]); 310 331 } 311 if(!usage.unused()) 312 { 332 if(!usage.unused()){ 313 333 for (String s : usage.values) { 314 334 if (!lhm.containsKey(s)) { … … 326 346 combo = new JComboBox(lhm.values().toArray()); 327 347 combo.setEditable(editable); 328 if (usage.allSimilar() && !usage.unused()) 329 { 348 AutoCompletingTextField tf = new AutoCompletingTextField(); 349 initAutoCompletionField(tf, key); 350 tf.getAutoCompletionList().add(Arrays.asList(display_array), AutoCompletionItemPritority.IS_IN_STANDARD); 351 combo.setEditor(tf); 352 353 if (usage.hasUniqueValue() && !usage.unused()){ 330 354 originalValue=usage.getFirst(); 331 355 combo.setSelectedItem(lhm.get(originalValue)); 332 356 } 333 357 // use default only in case it is a totally new entry 334 else if(default_ != null && !usage.hadKeys()) 335 { 358 else if(default_ != null && !usage.hadKeys()) { 336 359 combo.setSelectedItem(default_); 337 360 originalValue=DIFFERENT; 338 361 } 339 else if(usage.unused()) 340 { 362 else if(usage.unused()){ 341 363 combo.setSelectedItem(""); 342 364 originalValue=""; 343 365 } 344 else 345 { 366 else{ 346 367 combo.setSelectedItem(DIFFERENT); 347 368 originalValue=DIFFERENT; … … 625 646 } 626 647 648 protected void refreshAutocompletionList(final OsmDataLayer layer) { 649 Runnable task = new Runnable() { 650 public void run() { 651 System.out.print("refreshing preset auto completion list ..."); 652 AutoCompletionCache.getCacheForLayer(layer).initFromDataSet(); 653 AutoCompletionCache.getCacheForLayer(layer).populateWithValues( getPresetAutocompletionList(), false /* don't append */); 654 System.out.println("DONE"); 655 } 656 }; 657 new Thread(task).run(); 658 659 } 627 660 public PresetPanel createPanel(Collection<OsmPrimitive> selected) { 628 661 if (data == null) 629 662 return null; 663 OsmDataLayer layer = Main.main.getEditLayer(); 664 if (layer != null) { 665 refreshAutocompletionList(layer); 666 } 630 667 PresetPanel p = new PresetPanel(); 631 668 LinkedList<Item> l = new LinkedList<Item>(); 632 if(types != null) 633 { 669 if(types != null){ 634 670 JPanel pp = new JPanel(); 635 for(String t : types) 636 { 671 for(String t : types){ 637 672 JLabel la = new JLabel(ImageProvider.get("Mf_" + t)); 638 673 la.setToolTipText(tr("Elements of type {0} are supported.", tr(t))); … … 642 677 } 643 678 644 for (Item i : data) 645 { 679 for (Item i : data){ 646 680 if(i instanceof Link) { 647 681 l.add(i); 648 } else 649 { 682 } else { 650 683 if(i.addToPanel(p, selected)) { 651 684 p.hasElements = true; … … 683 716 true); 684 717 contentConstraints = GBC.eol().fill().insets(5,10,5,0); 685 setupDialog(content, new String[] {"ok.png", "cancel.png" }); 718 setButtonIcons(new String[] {"ok.png", "cancel.png" }); 719 setContent(content); 720 setupDialog(); 686 721 buttons.get(0).setEnabled(!disableApply); 687 722 buttons.get(0).setToolTipText(title); -
/trunk/src/org/openstreetmap/josm/io/DiffResultReader.java
r2024 r2060 93 93 94 94 public void visit(Node n) { 95 String key = "node:" + (newIdMap.containsKey(n) ? newIdMap.get(n) : n. id);95 String key = "node:" + (newIdMap.containsKey(n) ? newIdMap.get(n) : n.getId()); 96 96 System.out.println("key: "+key); 97 97 Long[] nv = versions.get(key); 98 98 if (nv != null) { 99 99 processed.add(n); 100 if (!n. deleted) {100 if (!n.isDeleted()) { 101 101 n.id = nv[0]; n.version = nv[1].intValue(); 102 102 } … … 104 104 } 105 105 public void visit(Way w) { 106 String key = "way:" + (newIdMap.containsKey(w) ? newIdMap.get(w) : w. id);106 String key = "way:" + (newIdMap.containsKey(w) ? newIdMap.get(w) : w.getId()); 107 107 Long[] nv = versions.get(key); 108 108 if (nv != null) { 109 109 processed.add(w); 110 if (!w. deleted) {110 if (!w.isDeleted()) { 111 111 w.id = nv[0]; w.version = nv[1].intValue(); 112 112 } … … 114 114 } 115 115 public void visit(Relation r) { 116 String key = "relation:" + (newIdMap.containsKey(r) ? newIdMap.get(r) : r. id);116 String key = "relation:" + (newIdMap.containsKey(r) ? newIdMap.get(r) : r.getId()); 117 117 Long[] nv = versions.get(key); 118 118 if (nv != null) { 119 119 processed.add(r); 120 if (!r. deleted) {120 if (!r.isDeleted()) { 121 121 r.id = nv[0]; r.version = nv[1].intValue(); 122 122 } -
/trunk/src/org/openstreetmap/josm/io/GpxExporter.java
r2024 r2060 112 112 p.add(keywords, GBC.eop().fill(GBC.HORIZONTAL)); 113 113 114 int answer = new ExtendedDialog(Main.parent, tr("Export options"), p, new String[] { tr("Export and Save"), 115 tr("Cancel") }, new String[] { "exportgpx.png", "cancel.png" }).getValue(); 116 if (answer != 1) 114 ExtendedDialog ed = new ExtendedDialog(Main.parent, 115 tr("Export options"), 116 new String[] { tr("Export and Save"), tr("Cancel") }); 117 ed.setButtonIcons(new String[] { "exportgpx.png", "cancel.png" }); 118 ed.setContent(p); 119 ed.showDialog(); 120 121 if (ed.getValue() != 1) 117 122 return; 118 123 -
/trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2024 r2060 168 168 public MultiFetchServerObjectReader append(Node node) { 169 169 if (node == null) return this; 170 if (node. id== 0) return this;171 remember(node. id, OsmPrimitiveType.NODE);170 if (node.getId() == 0) return this; 171 remember(node.getId(), OsmPrimitiveType.NODE); 172 172 return this; 173 173 } … … 182 182 public MultiFetchServerObjectReader append(Way way) { 183 183 if (way == null) return this; 184 if (way. id== 0) return this;184 if (way.getId() == 0) return this; 185 185 for (Node node: way.getNodes()) { 186 if (node. id> 0) {187 remember(node. id, OsmPrimitiveType.NODE);188 } 189 } 190 remember(way. id, OsmPrimitiveType.WAY);186 if (node.getId() > 0) { 187 remember(node.getId(), OsmPrimitiveType.NODE); 188 } 189 } 190 remember(way.getId(), OsmPrimitiveType.WAY); 191 191 return this; 192 192 } … … 201 201 public MultiFetchServerObjectReader append(Relation relation) { 202 202 if (relation == null) return this; 203 if (relation. id== 0) return this;204 remember(relation. id, OsmPrimitiveType.RELATION);203 if (relation.getId() == 0) return this; 204 remember(relation.getId(), OsmPrimitiveType.RELATION); 205 205 for (RelationMember member : relation.getMembers()) { 206 206 if (OsmPrimitiveType.from(member.member).equals(OsmPrimitiveType.RELATION)) { 207 207 // avoid infinite recursion in case of cyclic dependencies in relations 208 208 // 209 if (relations.contains(member.member. id)) {209 if (relations.contains(member.member.getId())) { 210 210 continue; 211 211 } … … 373 373 String msg = ""; 374 374 switch(type) { 375 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 376 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 377 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 375 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 376 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 377 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 378 378 } 379 379 progressMonitor.setCustomText(msg); … … 411 411 String msg = ""; 412 412 switch(type) { 413 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 414 case WAY: msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 415 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 413 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 414 case WAY: msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 415 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 416 416 } 417 417 progressMonitor.setCustomText(msg); -
/trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2024 r2060 145 145 146 146 /** 147 * Returns true if the negotiated version supports changesets.148 * @return true if the negotiated version supports changesets.149 */ 150 public boolean has ChangesetSupport() {147 * Returns true if the negotiated version supports diff uploads. 148 * @return true if the negotiated version supports diff uploads 149 */ 150 public boolean hasSupportForDiffUploads() { 151 151 return ((version != null) && (version.compareTo("0.6")>=0)); 152 152 } … … 157 157 * @exception OsmApiInitializationException thrown, if an exception occurs 158 158 */ 159 public void initialize() throws OsmApiInitializationException { 159 public void initialize(ProgressMonitor monitor) throws OsmApiInitializationException { 160 160 if (initialized) 161 161 return; 162 cancel = false; 162 163 initAuthentication(); 163 164 try { 164 String s = sendRequest("GET", "capabilities", null); 165 String s = sendRequest("GET", "capabilities", null,monitor); 165 166 InputSource inputSource = new InputSource(new StringReader(s)); 166 167 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, new CapabilitiesParser()); … … 227 228 * @throws OsmTransferException if something goes wrong 228 229 */ 229 public void createPrimitive(OsmPrimitive osm) throws OsmTransferException { 230 initialize(); 230 public void createPrimitive(OsmPrimitive osm, ProgressMonitor monitor) throws OsmTransferException { 231 initialize(monitor); 231 232 String ret = ""; 232 233 try { 233 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/create", toXml(osm, true)); 234 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/create", toXml(osm, true),monitor); 234 235 osm.id = Long.parseLong(ret.trim()); 235 236 osm.version = 1; … … 247 248 * @throws OsmTransferException if something goes wrong 248 249 */ 249 public void modifyPrimitive(OsmPrimitive osm) throws OsmTransferException { 250 initialize(); 250 public void modifyPrimitive(OsmPrimitive osm, ProgressMonitor monitor) throws OsmTransferException { 251 initialize(monitor); 251 252 if (version.equals("0.5")) { 252 253 // legacy mode does not return the new object version. 253 sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm. id, toXml(osm, true));254 sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true),monitor); 254 255 } else { 255 256 String ret = null; 256 257 // normal mode (0.6 and up) returns new object version. 257 258 try { 258 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm. id, toXml(osm, true));259 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true), monitor); 259 260 osm.version = Integer.parseInt(ret.trim()); 260 261 } catch(NumberFormatException e) { 261 throw new OsmTransferException(tr("unexpected format of new version of modified primitive ''{0}'', got ''{1}''", osm. id, ret));262 throw new OsmTransferException(tr("unexpected format of new version of modified primitive ''{0}'', got ''{1}''", osm.getId(), ret)); 262 263 } 263 264 } … … 270 271 */ 271 272 public void deletePrimitive(OsmPrimitive osm, ProgressMonitor monitor) throws OsmTransferException { 272 initialize(); 273 initialize(monitor); 273 274 // can't use a the individual DELETE method in the 0.6 API. Java doesn't allow 274 275 // submitting a DELETE request with content, the 0.6 API requires it, however. Falling back … … 279 280 280 281 /** 281 * Creates a new changeset on the server to use for subsequent calls. 282 * @param comment the "commit comment" for the new changeset 282 * Creates the changeset to be used for subsequent uploads. 283 * 284 * If changesetProcessingType is {@see ChangesetProcessingType#USE_NEW} creates a new changeset based 285 * on <code>changeset</code>. Otherwise uses the changeset given by {@see OsmApi#getCurrentChangeset()}. 286 * If this changeset is null or has an id of value 0, a new changeset is created too. 287 * 288 * @param changeset the changeset to be used for uploading if <code>changesetProcessingType</code> is 289 * {@see ChangesetProcessingType#USE_NEW} 290 * @param changesetProcessingType how to handel changesets; set to {@see ChangesetProcessingType#USE_NEW} if null 291 * @param progressMonitor the progress monitor 283 292 * @throws OsmTransferException signifying a non-200 return code, or connection errors 284 293 */ 285 public void createChangeset(String comment, ProgressMonitor progressMonitor) throws OsmTransferException { 286 progressMonitor.beginTask((tr("Opening changeset..."))); 294 public void createChangeset(Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 295 if (changesetProcessingType == null) { 296 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 297 } 287 298 try { 288 changeset = new Changeset(); 289 Properties sysProp = System.getProperties(); 290 Object ua = sysProp.get("http.agent"); 291 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 292 changeset.put("comment", comment); 293 createPrimitive(changeset); 299 progressMonitor.beginTask((tr("Creating changeset..."))); 300 if (changesetProcessingType.isUseNew()) { 301 Properties sysProp = System.getProperties(); 302 Object ua = sysProp.get("http.agent"); 303 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 304 createPrimitive(changeset, progressMonitor); 305 this.changeset = changeset; 306 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",changeset.getId()))); 307 } else { 308 if (this.changeset == null || this.changeset.getId() == 0) { 309 progressMonitor.setCustomText((tr("No currently open changeset. Opening a new changeset..."))); 310 System.out.println(tr("Warning: could not reuse an existing changeset as requested. Opening a new one.")); 311 Properties sysProp = System.getProperties(); 312 Object ua = sysProp.get("http.agent"); 313 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 314 createPrimitive(changeset, progressMonitor); 315 this.changeset = changeset; 316 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 317 } else { 318 progressMonitor.setCustomText((tr("Reusing existing changeset {0}", this.changeset.getId()))); 319 } 320 } 294 321 } finally { 295 322 progressMonitor.finishTask(); … … 300 327 * Closes a changeset on the server. 301 328 * 329 * @param changesetProcessingType how changesets are currently handled 330 * @param progressMonitor the progress monitor 331 * 302 332 * @throws OsmTransferException if something goes wrong. 303 333 */ 304 public void stopChangeset(ProgressMonitor progressMonitor) throws OsmTransferException { 305 progressMonitor.beginTask(tr("Closing changeset...")); 334 public void stopChangeset(ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 335 if (changesetProcessingType == null) { 336 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 337 } 306 338 try { 307 initialize(); 308 sendRequest("PUT", "changeset" + "/" + changeset.id + "/close", null); 309 changeset = null; 339 progressMonitor.beginTask(tr("Closing changeset...")); 340 initialize(progressMonitor); 341 if (changesetProcessingType.isCloseAfterUpload()) { 342 progressMonitor.setCustomText(tr("Closing changeset {0}...", changeset.getId())); 343 if (this.changeset != null && this.changeset.getId() > 0) { 344 sendRequest("PUT", "changeset" + "/" + changeset.getId() + "/close", null, progressMonitor); 345 changeset = null; 346 } 347 } else { 348 progressMonitor.setCustomText(tr("Leaving changeset {0} open...", changeset.getId())); 349 } 310 350 } finally { 311 351 progressMonitor.finishTask(); … … 327 367 throw new OsmTransferException(tr("No changeset present for diff upload")); 328 368 329 initialize(); 369 initialize(progressMonitor); 330 370 final ArrayList<OsmPrimitive> processed = new ArrayList<OsmPrimitive>(); 331 371 … … 341 381 String diff = duv.getDocument(); 342 382 try { 343 String diffresult = sendRequest("POST", "changeset/" + changeset. id+ "/upload", diff);383 String diffresult = sendRequest("POST", "changeset/" + changeset.getId() + "/upload", diff,progressMonitor); 344 384 DiffResultReader.parseDiffResult(diffresult, list, processed, duv.getNewIdMap(), 345 385 progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); … … 358 398 359 399 360 private void sleepAndListen() throws OsmTransferCancelledException { 400 private void sleepAndListen(int retry, ProgressMonitor monitor) throws OsmTransferCancelledException { 361 401 System.out.print(tr("Waiting 10 seconds ... ")); 362 402 for(int i=0; i < 10; i++) { 403 if (monitor != null) { 404 monitor.setCustomText(tr("Starting retry {0} of {1} in {2} seconds ...", getMaxRetries() - retry,getMaxRetries(), 10-i)); 405 } 363 406 if (cancel || isAuthCancelled()) 364 407 throw new OsmTransferCancelledException(); … … 395 438 * been exhausted), or rewrapping a Java exception. 396 439 */ 397 private String sendRequest(String requestMethod, String urlSuffix, 398 String requestBody) throws OsmTransferException { 440 private String sendRequest(String requestMethod, String urlSuffix,String requestBody, ProgressMonitor monitor) throws OsmTransferException { 399 441 400 442 StringBuffer responseBody = new StringBuffer(); … … 436 478 if (retCode >= 500) { 437 479 if (retries-- > 0) { 438 sleepAndListen(); 439 int maxRetries = getMaxRetries(); 440 System.out.println(tr("Starting retry {0} of {1}.", maxRetries - retries,maxRetries)); 480 sleepAndListen(retries, monitor); 481 System.out.println(tr("Starting retry {0} of {1}.", getMaxRetries() - retries,getMaxRetries())); 441 482 continue; 442 483 } -
/trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r2024 r2060 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.gui.ExtendedDialog; 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 25 26 import org.openstreetmap.josm.tools.Base64; 26 27 import org.openstreetmap.josm.tools.GBC; … … 94 95 95 96 public void cancel() { 96 //TODO97 //Main.pleaseWaitDlg.currentAction.setText(tr("Aborting..."));98 97 cancel = true; 99 98 if (activeConnection != null) { … … 112 111 try { 113 112 synchronized (credentialsManager) { 114 auth = credentialsManager.lookup(CredentialsManager.Key.USERNAME) + ":" + 115 113 auth = credentialsManager.lookup(CredentialsManager.Key.USERNAME) + ":" + 114 credentialsManager.lookup(CredentialsManager.Key.PASSWORD); 116 115 } 117 116 } catch (CredentialsManager.CMException e) { … … 139 138 String secret = Main.pref.get("osm-server." + key.toString(), null); 140 139 if (secret == null) throw new CredentialsManager.NoContentException(); 141 return secret; 140 return secret; 142 141 } 143 142 public void store(CredentialsManager.Key key, String secret) { … … 171 170 p.add(warning, GBC.eop()); 172 171 173 JCheckBox savePassword = new JCheckBox(tr("Save user and password (unencrypted)"), 174 172 JCheckBox savePassword = new JCheckBox(tr("Save user and password (unencrypted)"), 173 !username.equals("") && !password.equals("")); 175 174 p.add(savePassword, GBC.eop()); 176 175 177 int choice = new ExtendedDialog( 178 Main.parent, 179 tr("Enter Password"), 180 p, 181 new String[] {tr("Login"), tr("Cancel")}, 182 new String[] {"ok.png", "cancel.png"}).getValue(); 183 184 if (choice != 1) { 176 ExtendedDialog dialog = new ExtendedDialog( 177 Main.parent, 178 tr("Enter Password"), 179 new String[] {tr("Login"), tr("Cancel")} 180 ); 181 dialog.setContent(p); 182 dialog.setButtonIcons( new String[] {"ok.png", "cancel.png"}); 183 dialog.showDialog(); 184 185 if (dialog.getValue() != 1) { 185 186 caller.authCancelled = true; 186 187 return null; … … 223 224 oldServerURL = ""; 224 225 } 225 if (oldServerURL.equals("")) oldServerURL = "http://api.openstreetmap.org/api"; 226 if (oldServerURL.equals("")) { 227 oldServerURL = "http://api.openstreetmap.org/api"; 228 } 226 229 try { 227 230 oldUsername = lookup(Key.USERNAME); … … 258 261 String newPassword = String.valueOf(osmDataPassword.getPassword()); 259 262 if (!oldServerURL.equals(newServerURL)) { 260 store(Key.OSM_SERVER_URL, newServerURL); 263 store(Key.OSM_SERVER_URL, newServerURL); 261 264 } 262 265 if (!oldUsername.equals(newUsername)) { -
/trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r2024 r2060 76 76 tmpFile.delete(); 77 77 } 78 layer. cleanupAfterSaveToDisk();78 layer.onPostSaveToFile(); 79 79 } catch (IOException e) { 80 80 e.printStackTrace(); -
/trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r2024 r2060 10 10 import java.io.IOException; 11 11 import java.io.InputStream; 12 13 import javax.swing.SwingUtilities; 12 14 13 15 import org.openstreetmap.josm.Main; … … 47 49 OsmReader osm = OsmReader.parseDataSetOsm(in, NullProgressMonitor.INSTANCE); 48 50 DataSet dataSet = osm.getDs(); 49 OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile); 50 Main.main.addLayer(layer); 51 layer.fireDataChange(); 51 final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile); 52 // FIXME: remove UI stuff from IO subsystem 53 // 54 Runnable uiStuff = new Runnable() { 55 public void run() { 56 Main.main.addLayer(layer); 57 layer.fireDataChange(); 58 layer.onPostLoadFromFile(); 59 } 60 }; 61 if (SwingUtilities.isEventDispatchThread()) { 62 uiStuff.run(); 63 } else { 64 SwingUtilities.invokeLater(uiStuff); 65 } 52 66 } 53 67 } -
/trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r2024 r2060 40 40 protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException { 41 41 try { 42 api.initialize(); 42 api.initialize(progressMonitor); 43 43 urlStr = api.getBaseUrl() + urlStr; 44 44 return getInputStreamRaw(urlStr, progressMonitor); -
/trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2024 r2060 82 82 * 83 83 * @param primitives the collection of primitives to upload 84 * @param changeset the changeset to be used if <code>changesetProcessingType</code> indicates that 85 * a new changeset should be opened 86 * @param changesetProcessingType how we handle changesets 84 87 * @param progressMonitor the progress monitor 85 88 * @throws OsmTransferException thrown if an exception occurs 86 89 */ 87 protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException { 90 protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 88 91 try { 89 92 progressMonitor.setTicksCount(primitives.size()); 90 api.createChangeset( getChangesetComment(),progressMonitor.createSubTaskMonitor(0, false));93 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false)); 91 94 uploadStartTime = System.currentTimeMillis(); 92 95 for (OsmPrimitive osm : primitives) { … … 95 98 String msg = ""; 96 99 switch(OsmPrimitiveType.from(osm)) { 97 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 98 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; 99 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break; 100 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 101 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; 102 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break; 100 103 } 101 104 progressMonitor.subTask( … … 105 108 primitives.size(), 106 109 time_left_str, 107 osm.getName() == null ? osm. id: osm.getName(),108 osm. id));110 osm.getName() == null ? osm.getId() : osm.getName(), 111 osm.getId())); 109 112 makeApiRequest(osm,progressMonitor); 110 113 processed.add(osm); … … 117 120 } finally { 118 121 try { 119 api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false)); 122 // starting the changeset may have failed, for instance because the user 123 // cancelled the upload task. Only close the changeset if we currently have 124 // an open changeset 125 126 if (api.getCurrentChangeset() != null && api.getCurrentChangeset().getId() > 0) { 127 api.stopChangeset(changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 128 } 120 129 } catch(Exception e) { 121 Changeset changeset = api.getCurrentChangeset(); 122 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.id)); 123 logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}", 124 changesetId, e.toString())); 130 OsmChangesetCloseException closeException = new OsmChangesetCloseException(e); 131 closeException.setChangeset(api.getCurrentChangeset()); 132 throw closeException; 125 133 } 126 134 } … … 134 142 * @throws OsmTransferException thrown if an exception occurs 135 143 */ 136 protected void uploadChangesAsDiffUpload(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException { 144 protected void uploadChangesAsDiffUpload(Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 137 145 // upload everything in one changeset 138 146 // 139 147 try { 140 api.createChangeset( getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));148 api.createChangeset(changeset, changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 141 149 processed.addAll(api.uploadDiff(primitives, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false))); 142 150 } catch(OsmTransferException e) { … … 146 154 } finally { 147 155 try { 148 api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false)); 156 api.stopChangeset(changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 149 157 } catch (Exception ee) { 150 Changeset changeset = api.getCurrentChangeset(); 151 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.id)); 152 logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}", 153 changesetId, ee.toString())); 158 OsmChangesetCloseException closeException = new OsmChangesetCloseException(ee); 159 closeException.setChangeset(api.getCurrentChangeset()); 160 throw closeException; 154 161 } 155 162 } … … 162 169 * @param primitives list of objects to send 163 170 */ 164 public void uploadOsm(String apiVersion, Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException { 171 public void uploadOsm(String apiVersion, Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 165 172 processed = new LinkedList<OsmPrimitive>(); 166 173 167 api.initialize(); 168 169 progressMonitor.beginTask(""); 174 api.initialize(progressMonitor); 170 175 171 176 try { 172 // check whether we can use changeset177 // check whether we can use diff upload 173 178 // 174 boolean canUseChangeset = api.hasChangesetSupport(); 175 boolean useChangeset = Main.pref.getBoolean("osm-server.atomic-upload", apiVersion.compareTo("0.6")>=0); 176 if (useChangeset && ! canUseChangeset) { 177 System.out.println(tr("WARNING: preference ''{0}'' or api version ''{1}'' of dataset requires to use changesets, but API is not able to handle them. Ignoring changesets.", "osm-server.atomic-upload", apiVersion)); 178 useChangeset = false; 179 } 180 181 if (useChangeset) { 182 uploadChangesAsDiffUpload(primitives, progressMonitor); 179 boolean casUseDiffUploads = api.hasSupportForDiffUploads(); 180 boolean useDiffUpload = Main.pref.getBoolean("osm-server.atomic-upload", apiVersion.compareTo("0.6")>=0); 181 if (useDiffUpload && ! casUseDiffUploads) { 182 System.out.println(tr("WARNING: preference ''{0}'' or api version ''{1}'' of dataset requires to use diff uploads, but API is not able to handle them. Ignoring diff upload.", "osm-server.atomic-upload", apiVersion)); 183 useDiffUpload = false; 184 } 185 186 if (useDiffUpload) { 187 progressMonitor.beginTask(tr("Starting to upload in one request ...")); 188 uploadChangesAsDiffUpload(primitives,changeset, changesetProcessingType, progressMonitor); 183 189 } else { 184 uploadChangesIndividually(primitives, progressMonitor); 190 progressMonitor.beginTask(tr("Starting to upload with one request per primitive ...")); 191 uploadChangesIndividually(primitives,changeset,changesetProcessingType, progressMonitor); 185 192 } 186 193 } finally { … … 190 197 191 198 void makeApiRequest(OsmPrimitive osm, ProgressMonitor progressMonitor) throws OsmTransferException { 192 if (osm. deleted) {199 if (osm.isDeleted()) { 193 200 api.deletePrimitive(osm, progressMonitor); 194 } else if (osm. id== 0) {195 api.createPrimitive(osm); 201 } else if (osm.getId() == 0) { 202 api.createPrimitive(osm, progressMonitor); 196 203 } else { 197 api.modifyPrimitive(osm); 198 } 199 } 200 201 public void disconnectActiveConnection() {202 if (api != null && api.activeConnection != null) {203 api. activeConnection.disconnect();204 api.modifyPrimitive(osm,progressMonitor); 205 } 206 } 207 208 public void cancel() { 209 if (api != null) { 210 api.cancel(); 204 211 } 205 212 } -
/trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r2024 r2060 85 85 86 86 private boolean shouldWrite(OsmPrimitive osm) { 87 return osm. id!= 0 || !osm.deleted;87 return osm.getId() != 0 || !osm.isDeleted(); 88 88 } 89 89 … … 155 155 */ 156 156 private long getUsedId(OsmPrimitive osm) { 157 if (osm. id!= 0)158 return osm. id;157 if (osm.getId() != 0) 158 return osm.getId(); 159 159 if (usedNewIds.containsKey(osm)) 160 160 return usedNewIds.get(osm); … … 169 169 } 170 170 for (Entry<String, String> e : osm.entrySet()) { 171 if ((osm instanceof Changeset) || !("created_by".equals(e.getKey()))) 171 if ((osm instanceof Changeset) || !("created_by".equals(e.getKey()))) { 172 172 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) + 173 173 "' v='"+XmlWriter.encode(e.getValue())+ "' />"); 174 } 174 175 } 175 176 out.println(" </" + tagname + ">"); … … 193 194 if (!osmConform) { 194 195 String action = null; 195 if (osm. deleted) {196 if (osm.isDeleted()) { 196 197 action = "delete"; 197 } else if (osm. modified) {198 } else if (osm.isModified()) { 198 199 action = "modify"; 199 200 } … … 209 210 out.print(" user='"+XmlWriter.encode(osm.user.name)+"'"); 210 211 } 211 out.print(" visible='"+osm. visible+"'");212 out.print(" visible='"+osm.isVisible()+"'"); 212 213 if (osm.version != -1) { 213 214 out.print(" version='"+osm.version+"'"); 214 215 } 215 if (this.changeset != null && this.changeset. id!= 0) {216 out.print(" changeset='"+this.changeset. id+"'" );216 if (this.changeset != null && this.changeset.getId() != 0) { 217 out.print(" changeset='"+this.changeset.getId()+"'" ); 217 218 } 218 219 } -
/trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r2024 r2060 97 97 done = true; 98 98 } else { 99 int answer= new ExtendedDialog(Main.parent,99 ExtendedDialog ed = new ExtendedDialog(Main.parent, 100 100 tr("Update"), 101 tr("Update the following plugins:\n\n{0}", toUpdateStr.toString()), 102 new String[] {tr("Update Plugins"), tr("Cancel")}, 103 new String[] {"dialogs/refresh.png", "cancel.png"}).getValue(); 104 if (answer == 1) { 101 new String[] {tr("Update Plugins"), tr("Cancel")}); 102 ed.setButtonIcons(new String[] {"dialogs/refresh.png", "cancel.png"}); 103 ed.setContent(tr("Update the following plugins:\n\n{0}", toUpdateStr.toString())); 104 ed.showDialog(); 105 106 if (ed.getValue() == 1) { 105 107 PluginDownloader.update(toUpdate); 106 108 done = true; … … 133 135 } 134 136 if (!toDownload.isEmpty()) { 135 int answer= new ExtendedDialog(Main.parent,137 ExtendedDialog ed = new ExtendedDialog(Main.parent, 136 138 tr("Download missing plugins"), 137 tr("Download the following plugins?\n\n{0}", msg), 138 new String[] {tr("Download Plugins"), tr("Cancel")}, 139 new String[] {"download.png", "cancel.png"}).getValue(); 139 new String[] {tr("Download Plugins"), tr("Cancel")}); 140 ed.setButtonIcons(new String[] {"download.png", "cancel.png"}); 141 ed.setContent(tr("Download the following plugins?\n\n{0}", msg)); 142 ed.showDialog(); 143 140 144 Collection<PluginInformation> error = 141 ( answer!= 1 ? toDownload : new PluginDownloader().download(toDownload));145 (ed.getValue() != 1 ? toDownload : new PluginDownloader().download(toDownload)); 142 146 for (PluginInformation pd : error) { 143 147 pluginMap.put(pd.name, false); -
/trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r2024 r2060 48 48 //System.out.println("Going to handle method "+method+" (short: "+method.getName()+") with event "+args[0]); 49 49 if (method.getName().equals("handleQuit")) { 50 handled = !Main.breakBecauseUnsavedChanges();50 handled = Main.saveUnsavedModifications(); 51 51 } else if (method.getName().equals("handleAbout")) { 52 52 Main.main.menu.about.actionPerformed(null); -
/trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r2024 r2060 127 127 128 128 OsmServerWriter writer = new OsmServerWriter(); 129 writer.uploadOsm("0.6", primitives, NullProgressMonitor.INSTANCE); 129 writer.uploadOsm("0.6", primitives, null,null, NullProgressMonitor.INSTANCE); 130 130 } 131 131 -
/trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r2024 r2060 129 129 primitives.addAll(ds.relations); 130 130 OsmServerWriter writer = new OsmServerWriter(); 131 writer.uploadOsm("0.6", primitives, NullProgressMonitor.INSTANCE); 131 writer.uploadOsm("0.6", primitives, null, null, NullProgressMonitor.INSTANCE); 132 132 } 133 133
Note:
See TracChangeset
for help on using the changeset viewer.