Changeset 18485 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2022-06-09T19:22:55+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SessionSaveAction.java
r18481 r18485 81 81 private static final String TOOLTIP_DEFAULT = tr("Save the current session."); 82 82 83 protected FileFilter joz = new ExtensionFileFilter("joz", "joz", tr("Session file (archive) (*.joz)"));84 protected FileFilter jos = new ExtensionFileFilter("jos", "jos", tr("Session file (*.jos)"));83 protected transient FileFilter joz = new ExtensionFileFilter("joz", "joz", tr("Session file (archive) (*.joz)")); 84 protected transient FileFilter jos = new ExtensionFileFilter("jos", "jos", tr("Session file (*.jos)")); 85 85 86 86 private File removeFileOnSuccess; 87 87 88 88 private static String tooltip = TOOLTIP_DEFAULT; 89 protectedstatic File sessionFile;90 protectedstatic boolean isZipSessionFile;91 protectedstatic List<WeakReference<Layer>> layersInSessionFile;89 static File sessionFile; 90 static boolean isZipSessionFile; 91 static List<WeakReference<Layer>> layersInSessionFile; 92 92 93 93 private static final SessionSaveAction instance = new SessionSaveAction(); … … 97 97 * @return the instance 98 98 */ 99 public static finalSessionSaveAction getInstance() {99 public static SessionSaveAction getInstance() { 100 100 return instance; 101 101 } … … 132 132 try { 133 133 saveSession(false, false); 134 } catch (UserCancelException ignore) {135 Logging.trace( ignore);134 } catch (UserCancelException exception) { 135 Logging.trace(exception); 136 136 } 137 137 } … … 203 203 setCurrentLayers(layersOut); 204 204 205 206 if (fn.indexOf('.') == -1) { 207 sessionFile = new File(sessionFile.getPath() + (isZipSessionFile ? ".joz" : ".jos")); 208 if (!SaveActionBase.confirmOverwrite(sessionFile)) { 209 throw new UserCancelException(); 210 } 211 } 205 updateSessionFile(fn); 212 206 213 207 Stream<Layer> layersToSaveStream = layersOut.stream() … … 219 213 220 214 boolean success = true; 221 if (forceSaveAll || SAVE_LOCAL_FILES_PROPERTY.get()) {215 if (forceSaveAll || Boolean.TRUE.equals(SAVE_LOCAL_FILES_PROPERTY.get())) { 222 216 // individual files must be saved before the session file as the location may change 223 217 if (layersToSaveStream … … 394 388 395 389 int numNoExporter = 0; 396 WHILE:while (numNoExporter != noExporter.size()) {390 while (numNoExporter != noExporter.size()) { 397 391 numNoExporter = noExporter.size(); 398 for (Layer layer : layers) { 399 if (noExporter.contains(layer)) continue; 400 for (Layer depLayer : dependencies.get(layer)) { 401 if (noExporter.contains(depLayer)) { 402 noExporter.add(layer); 403 exporters.put(layer, null); 404 break WHILE; 405 } 392 updateExporters(noExporter); 393 } 394 } 395 396 private void updateExporters(Collection<Layer> noExporter) { 397 for (Layer layer : layers) { 398 if (noExporter.contains(layer)) continue; 399 for (Layer depLayer : dependencies.get(layer)) { 400 if (noExporter.contains(depLayer)) { 401 noExporter.add(layer); 402 exporters.put(layer, null); 403 return; 406 404 } 407 405 } … … 436 434 op.add(tabs, GBC.eol().fill()); 437 435 JCheckBox chkSaveLocal = new JCheckBox(tr("Save all local files to disk"), SAVE_LOCAL_FILES_PROPERTY.get()); 438 chkSaveLocal.addChangeListener(l -> { 439 SAVE_LOCAL_FILES_PROPERTY.put(chkSaveLocal.isSelected()); 440 }); 436 chkSaveLocal.addChangeListener(l -> SAVE_LOCAL_FILES_PROPERTY.put(chkSaveLocal.isSelected())); 441 437 op.add(chkSaveLocal); 442 438 return op; … … 496 492 497 493 /** 494 * Update the session file 495 * @param fileName The filename to use. If there are no periods in the file, we update the extension. 496 * @throws UserCancelException If the user does not want to overwrite a previously existing file. 497 */ 498 private static void updateSessionFile(String fileName) throws UserCancelException { 499 if (fileName.indexOf('.') == -1) { 500 sessionFile = new File(sessionFile.getPath() + (isZipSessionFile ? ".joz" : ".jos")); 501 if (!SaveActionBase.confirmOverwrite(sessionFile)) { 502 throw new UserCancelException(); 503 } 504 } 505 } 506 507 /** 498 508 * Sets the current session file and the layers included in that file 499 509 * @param file file … … 528 538 public static void setCurrentLayers(List<Layer> layers) { 529 539 layersInSessionFile = layers.stream() 530 .filter( l -> l instanceof AbstractModifiableLayer)540 .filter(AbstractModifiableLayer.class::isInstance) 531 541 .map(WeakReference::new) 532 542 .collect(Collectors.toList()); -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r18468 r18485 402 402 mouseDownButton = e.getButton(); 403 403 // return early 404 if (!mv.isActiveLayerVisible() || !(Boolean) this.getValue("active") || mouseDownButton != MouseEvent.BUTTON1)404 if (!mv.isActiveLayerVisible() || Boolean.FALSE.equals(this.getValue("active")) || mouseDownButton != MouseEvent.BUTTON1) 405 405 return; 406 406 … … 744 744 dh += Math.PI/2; 745 745 break; 746 default: 747 // Just in case we cannot clamp 746 748 } 747 749 clampedEastNorth = currentEN.rotate(startEN, -dh); … … 1149 1151 // special case: for cycle groups of 2, we can toggle to the 1150 1152 // true nearest primitive on mousePressed right away 1151 if (cycleList.size() == 2 && !waitForMouseUpParameter) { 1152 if (!(osm.equals(old) || osm.isNew() || platformMenuShortcutKeyMask)) { 1153 if (cycleList.size() == 2 && !waitForMouseUpParameter 1154 // This was a nested if statement (see commented code below) 1155 && (!(osm.equals(old) || osm.isNew() || platformMenuShortcutKeyMask))) { 1153 1156 cyclePrims = false; 1154 1157 osm = old; 1155 }// else defer toggling to mouseRelease time in those cases:1158 // else defer toggling to mouseRelease time in those cases: 1156 1159 /* 1157 1160 * osm == old -- the true nearest node is the -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/Feature.java
r18473 r18485 57 57 * 58 58 * @param layer The layer the feature is part of (required for tags) 59 * @param record The record to create the feature from59 * @param protobufRecord The record to create the feature from 60 60 * @throws IOException - if an IO error occurs 61 61 */ 62 public Feature(Layer layer, ProtobufRecord record) throws IOException {62 public Feature(Layer layer, ProtobufRecord protobufRecord) throws IOException { 63 63 long tId = 0; 64 64 GeometryTypes geometryTypeTemp = GeometryTypes.UNKNOWN; … … 69 69 // By avoiding array copies in TagMap, Feature#init goes from 339 MB to 188 MB. 70 70 ArrayList<String> tagList = null; 71 try (ProtobufParser parser = new ProtobufParser( record.getBytes())) {71 try (ProtobufParser parser = new ProtobufParser(protobufRecord.getBytes())) { 72 72 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(4); 73 73 while (parser.hasNext()) { … … 111 111 this.id = tId; 112 112 this.geometryType = geometryTypeTemp; 113 record.close();113 protobufRecord.close(); 114 114 if (tagList != null && !tagList.isEmpty()) { 115 115 this.tags = new TagMap(tagList.toArray(EMPTY_STRING_ARRAY)); … … 128 128 * @return The new key (if {@code null}, then a value was parsed and added to tags) 129 129 */ 130 private String parseTagValue(String key, Layer layer, Number number, List<String> tagList) {130 private static String parseTagValue(String key, Layer layer, Number number, List<String> tagList) { 131 131 if (key == null) { 132 132 key = layer.getKey(number.intValue());
Note:
See TracChangeset
for help on using the changeset viewer.