- Timestamp:
- 2014-04-29T16:38:07+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r7005 r7029 179 179 } 180 180 181 private void savelayer(AutosaveLayerInfo info) throws IOException{181 private void savelayer(AutosaveLayerInfo info) { 182 182 if (!info.layer.getName().equals(info.layerName)) { 183 183 setLayerFileName(info); … … 263 263 if (info.layer == osmLayer) { 264 264 265 try { 266 savelayer(info); 267 File lastFile = info.backupFiles.pollLast(); 268 if (lastFile != null) { 269 moveToDeletedLayersFolder(lastFile); 265 savelayer(info); 266 File lastFile = info.backupFiles.pollLast(); 267 if (lastFile != null) { 268 moveToDeletedLayersFolder(lastFile); 269 } 270 for (File file: info.backupFiles) { 271 if (file.delete()) { 272 getPidFile(file).delete(); 270 273 } 271 for (File file: info.backupFiles) {272 if (file.delete()) {273 getPidFile(file).delete();274 }275 }276 } catch (IOException e) {277 Main.error(tr("Error while creating backup of removed layer: {0}", e.getMessage()));278 274 } 279 275 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r7018 r7029 131 131 @SuppressWarnings("unchecked") 132 132 protected ListMergeModel<Node>.EntriesTableModel getModel(JTable table) { 133 return (ListMergeModel .EntriesTableModel)table.getModel();133 return (ListMergeModel<Node>.EntriesTableModel)table.getModel(); 134 134 } 135 135 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java
r7018 r7029 147 147 @SuppressWarnings("unchecked") 148 148 protected ListMergeModel<Node>.EntriesTableModel getModel(JTable table) { 149 return (ListMergeModel .EntriesTableModel)table.getModel();149 return (ListMergeModel<Node>.EntriesTableModel)table.getModel(); 150 150 } 151 151 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r7021 r7029 563 563 } 564 564 565 /**566 * Returns the index of the relation567 * @param rel The relation to look for568 *569 * @return index of relation (null if it cannot be found)570 */571 public Integer getRelationIndex(Relation rel) {572 int i = relations.indexOf(rel);573 if (i<0)574 return null;575 return i;576 }577 578 565 private Integer getVisibleRelationIndex(Relation rel) { 579 566 int i = getVisibleRelations().indexOf(rel); … … 631 618 } 632 619 620 /** 621 * Replies the list of selected relations. Empty list, if there are no selected relations. 622 * @return the list of selected, non-new relations. 623 */ 633 624 public Collection<Relation> getSelectedRelations() { 634 625 return model.getSelectedRelations(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r7005 r7029 53 53 import javax.swing.JPopupMenu; 54 54 import javax.swing.KeyStroke; 55 import javax.swing.ListCellRenderer; 55 56 import javax.swing.table.DefaultTableModel; 56 57 import javax.swing.text.JTextComponent; … … 87 88 // Selection that we are editing by using both dialogs 88 89 Collection<OsmPrimitive> sel; 89 90 90 91 private String changedKey; 91 92 private String objKey; … … 127 128 128 129 final AddTagsDialog addDialog = new AddTagsDialog(); 129 130 130 131 addDialog.showDialog(); 131 132 132 133 addDialog.destroyActions(); 133 134 if (addDialog.getValue() == 1) … … 136 137 addDialog.undoAllTagsAdding(); 137 138 } 138 139 139 140 /** 140 141 * Edit the value in the tags table row … … 150 151 String key = tagData.getValueAt(row, 0).toString(); 151 152 objKey=key; 152 153 153 154 @SuppressWarnings("unchecked") 154 155 final EditTagDialog editDialog = new EditTagDialog(key, row, … … 158 159 editDialog.performTagEdit(); 159 160 } 160 161 161 162 /** 162 163 * If during last editProperty call user changed the key name, this key will be returned … … 166 167 return changedKey; 167 168 } 168 169 169 170 public void resetChangedKey() { 170 171 changedKey = null; … … 233 234 } 234 235 }; 235 236 DefaultListCellRenderer cellRenderer = new DefaultListCellRenderer() { 237 @Override public Component getListCellRendererComponent(JList list, 238 Object value, int index, boolean isSelected, boolean cellHasFocus){ 239 Component c = super.getListCellRendererComponent(list, value, 240 index, isSelected, cellHasFocus); 236 237 ListCellRenderer<AutoCompletionListItem> cellRenderer = new ListCellRenderer<AutoCompletionListItem>() { 238 final DefaultListCellRenderer def = new DefaultListCellRenderer(); 239 @Override 240 public Component getListCellRendererComponent(JList<? extends AutoCompletionListItem> list, 241 AutoCompletionListItem value, int index, boolean isSelected, boolean cellHasFocus){ 242 Component c = def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 241 243 if (c instanceof JLabel) { 242 String str = ((AutoCompletionListItem) value).getValue();244 String str = value.getValue(); 243 245 if (valueCount.containsKey(objKey)) { 244 246 Map<String, Integer> m = valueCount.get(objKey); … … 253 255 } 254 256 }; 255 257 256 258 private EditTagDialog(String key, int row, Map<String, Integer> map, final boolean initialFocusOnKey) { 257 259 super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"),tr("Cancel")}); … … 262 264 this.row = row; 263 265 this.m = map; 264 266 265 267 JPanel mainPanel = new JPanel(new BorderLayout()); 266 268 267 269 String msg = "<html>"+trn("This will change {0} object.", 268 270 "This will change up to {0} objects.", sel.size(), sel.size()) … … 292 294 293 295 final String selection= m.size()!=1?tr("<different>"):m.entrySet().iterator().next().getKey(); 294 296 295 297 values = new AutoCompletingComboBox(selection); 296 298 values.setRenderer(cellRenderer); … … 311 313 }); 312 314 addFocusAdapter(autocomplete, usedValuesAwareComparator); 313 315 314 316 setContent(mainPanel, false); 315 317 316 318 addWindowListener(new WindowAdapter() { 317 319 @Override … … 325 327 }); 326 328 } 327 329 328 330 /** 329 331 * Edit tags of multiple selected objects according to selected ComboBox values … … 406 408 AutoCompletingComboBox values; 407 409 Component componentUnderMouse; 408 410 409 411 public AbstractTagsDialog(Component parent, String title, String[] buttonTexts) { 410 412 super(parent, title, buttonTexts); … … 422 424 // https://bugs.openjdk.java.net/browse/JDK-6200438 423 425 // https://bugs.openjdk.java.net/browse/JDK-6464548 424 426 425 427 setRememberWindowGeometry(getClass().getName() + ".geometry", 426 428 WindowGeometry.centerInWindow(Main.parent, size)); … … 448 450 super.setVisible(visible); 449 451 } 450 452 451 453 private void selectACComboBoxSavingUnixBuffer(AutoCompletingComboBox cb) { 452 454 // select compbobox with saving unix system selection (middle mouse paste) … … 462 464 } 463 465 } 464 466 465 467 public void selectKeysComboBox() { 466 468 selectACComboBoxSavingUnixBuffer(keys); 467 469 } 468 470 469 471 public void selectValuesCombobox() { 470 472 selectACComboBoxSavingUnixBuffer(values); 471 473 } 472 474 473 475 /** 474 476 * Create a focus handling adapter and apply in to the editor component of value … … 497 499 return focus; 498 500 } 499 501 500 502 protected JPopupMenu popupMenu = new JPopupMenu() { 501 503 JCheckBoxMenuItem fixTagLanguageCb = new JCheckBoxMenuItem( … … 516 518 class AddTagsDialog extends AbstractTagsDialog { 517 519 List<JosmAction> recentTagsActions = new ArrayList<>(); 518 520 519 521 // Counter of added commands for possible undo 520 522 private int commandCount; … … 525 527 setCancelButton(2); 526 528 configureContextsensitiveHelp("/Dialog/AddValue", true /* show help button */); 527 529 528 530 JPanel mainPanel = new JPanel(new GridBagLayout()); 529 531 keys = new AutoCompletingComboBox(); 530 532 values = new AutoCompletingComboBox(); 531 533 532 534 mainPanel.add(new JLabel("<html>"+trn("This will change up to {0} object.", 533 535 "This will change up to {0} objects.", sel.size(),sel.size()) … … 580 582 recentTagsToShow = MAX_LRU_TAGS_NUMBER; 581 583 } 582 584 583 585 // Add tag on Shift-Enter 584 586 mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( … … 591 593 } 592 594 }); 593 595 594 596 suggestRecentlyAddedTags(mainPanel, recentTagsToShow, focus); 595 597 596 598 setContent(mainPanel, false); 597 599 598 600 selectKeysComboBox(); 599 601 600 602 popupMenu.add(new AbstractAction(tr("Set number of recently added tags")) { 601 603 @Override … … 616 618 popupMenu.add(rememberLastTags); 617 619 } 618 620 619 621 private void selectNumberOfTags() { 620 622 String s = JOptionPane.showInputDialog(this, tr("Please enter the number of recently added tags to display")); … … 630 632 JOptionPane.showMessageDialog(this, tr("Please enter integer number between 0 and {0}", MAX_LRU_TAGS_NUMBER)); 631 633 } 632 634 633 635 private void suggestRecentlyAddedTags(JPanel mainPanel, int tagsToShow, final FocusAdapter focus) { 634 636 if (!(tagsToShow > 0 && !recentTags.isEmpty())) … … 636 638 637 639 mainPanel.add(new JLabel(tr("Recently added tags")), GBC.eol()); 638 640 639 641 int count = 1; 640 642 // We store the maximum number (9) of recent tags to allow dynamic change of number of tags shown in the preferences. … … 753 755 changedKey = key; 754 756 } 755 757 756 758 public void undoAllTagsAdding() { 757 759 Main.main.undoRedo.undo(commandCount); -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r7021 r7029 221 221 return; 222 222 for (Object sel: sels) { 223 ((DefaultListModel )bookmarks.getModel()).removeElement(sel);223 ((DefaultListModel<Bookmark>)bookmarks.getModel()).removeElement(sel); 224 224 } 225 225 bookmarks.save(); -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r7017 r7029 37 37 import javax.swing.JScrollPane; 38 38 import javax.swing.KeyStroke; 39 import javax.swing.ListCellRenderer; 39 40 import javax.swing.WindowConstants; 40 41 import javax.swing.event.TableModelEvent; … … 175 176 lstLayers = new JList<>(); 176 177 lstLayers.setCellRenderer( 177 new DefaultListCellRenderer() { 178 new ListCellRenderer<SaveLayerInfo>() { 179 final DefaultListCellRenderer def = new DefaultListCellRenderer(); 178 180 @Override 179 public Component getListCellRendererComponent(JList list, Object value, int index,181 public Component getListCellRendererComponent(JList<? extends SaveLayerInfo> list, SaveLayerInfo info, int index, 180 182 boolean isSelected, boolean cellHasFocus) { 181 SaveLayerInfo info = (SaveLayerInfo)value; 182 setIcon(info.getLayer().getIcon()); 183 setText(info.getName()); 184 return this; 183 def.setIcon(info.getLayer().getIcon()); 184 def.setText(info.getName()); 185 return def; 185 186 } 186 187 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r7005 r7029 115 115 String defaultValue = layerName == null ? getDefaultLabelPattern():""; 116 116 TemplateEntryProperty parent = layerName == null ? null : forMarker(null); 117 try { 118 result = new TemplateEntryProperty(key, defaultValue, parent); 119 CACHE.put(key, result); 120 } catch (ParseError e) { 121 Main.warn("Unable to parse template engine pattern ''{0}'' for property {1}", defaultValue, key); 122 } 117 result = new TemplateEntryProperty(key, defaultValue, parent); 118 CACHE.put(key, result); 123 119 } 124 120 return result; … … 134 130 String defaultValue = layerName == null?"?{ '{name}' | '{desc}' | '{" + Marker.MARKER_FORMATTED_OFFSET + "}' }":""; 135 131 TemplateEntryProperty parent = layerName == null ? null : forAudioMarker(null); 136 try { 137 result = new TemplateEntryProperty(key, defaultValue, parent); 138 CACHE.put(key, result); 139 } catch (ParseError e) { 140 Main.warn("Unable to parse template engine pattern ''{0}'' for property {1}", defaultValue, key); 141 } 132 result = new TemplateEntryProperty(key, defaultValue, parent); 133 CACHE.put(key, result); 142 134 } 143 135 return result; … … 146 138 private TemplateEntryProperty parent; 147 139 148 149 private TemplateEntryProperty(String key, String defaultValue, TemplateEntryProperty parent) throws ParseError { 140 private TemplateEntryProperty(String key, String defaultValue, TemplateEntryProperty parent) { 150 141 super(key, defaultValue); 151 142 this.parent = parent; -
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r7005 r7029 181 181 public Cascade clone() { 182 182 @SuppressWarnings("unchecked") 183 HashMap<String, Object> clonedProp = (HashMap ) ((HashMap) this.prop).clone();183 HashMap<String, Object> clonedProp = (HashMap<String, Object>) ((HashMap) this.prop).clone(); 184 184 Cascade c = new Cascade(); 185 185 c.prop = clonedProp; -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r7005 r7029 43 43 } 44 44 45 public void exportData(File file, Layer layer, boolean noBackup) throws I OException {45 public void exportData(File file, Layer layer, boolean noBackup) throws IllegalArgumentException { 46 46 if (layer instanceof OsmDataLayer) { 47 47 save(file, (OsmDataLayer) layer, noBackup); -
trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java
r6552 r7029 179 179 } 180 180 181 protected void addDataFile(OutputStream out) throws IOException{181 protected void addDataFile(OutputStream out) { 182 182 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 183 183 GpxWriter w = new GpxWriter(new PrintWriter(writer)); -
trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java
r6552 r7029 17 17 import javax.swing.SwingConstants; 18 18 19 import org.openstreetmap.josm.tools.Utils;20 import org.w3c.dom.Element;21 22 19 import org.openstreetmap.josm.Main; 23 20 import org.openstreetmap.josm.data.gpx.GpxData; … … 28 25 import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport; 29 26 import org.openstreetmap.josm.tools.GBC; 27 import org.openstreetmap.josm.tools.Utils; 28 import org.w3c.dom.Element; 30 29 31 30 public class MarkerSessionExporter implements SessionLayerExporter { … … 85 84 } 86 85 87 protected void addDataFile(OutputStream out) throws IOException{86 protected void addDataFile(OutputStream out) { 88 87 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 89 88 MarkerWriter w = new MarkerWriter(new PrintWriter(writer)); -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
r6890 r7029 33 33 import javax.swing.SwingConstants; 34 34 35 import org.openstreetmap.josm.tools.Utils;36 import org.w3c.dom.Element;37 38 35 import org.openstreetmap.josm.actions.SaveAction; 39 36 import org.openstreetmap.josm.gui.layer.Layer; … … 46 43 import org.openstreetmap.josm.tools.GBC; 47 44 import org.openstreetmap.josm.tools.ImageProvider; 45 import org.openstreetmap.josm.tools.Utils; 46 import org.w3c.dom.Element; 48 47 49 48 public class OsmDataSessionExporter implements SessionLayerExporter { … … 213 212 } 214 213 215 protected void addDataFile(OutputStream out) throws IOException{214 protected void addDataFile(OutputStream out) { 216 215 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 217 216 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion()); -
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r7025 r7029 4 4 import java.io.File; 5 5 import java.io.IOException; 6 import java.net.MalformedURLException;7 6 import java.net.URL; 8 7 -
trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java
r7026 r7029 6 6 import java.awt.Desktop; 7 7 import java.io.IOException; 8 import java.net.MalformedURLException;9 8 import java.net.URI; 10 9 … … 23 22 // Hide default constructor for utils classes 24 23 } 25 24 26 25 private static void displayUrlFallback(URI uri) throws IOException { 27 26 if (Main.platform == null) … … 31 30 32 31 /** 33 * Displays an external URI using platform associated software. 34 * A web resource will launch platform's browser, an audio file URI will launch audio player, etc. 32 * Displays an external URI using platform associated software. 33 * A web resource will launch platform's browser, an audio file URI will launch audio player, etc. 35 34 * @param uri The URI to display 36 35 * @return <code>null</code> for success or a string in case of an error. … … 78 77 79 78 /** 80 * Displays an external URL using platform associated software. 81 * A web resource will launch platform's browser, an audio file URL will launch audio player, etc. 79 * Displays an external URL using platform associated software. 80 * A web resource will launch platform's browser, an audio file URL will launch audio player, etc. 82 81 * @param url The URL to display 83 82 * @return <code>null</code> for success or a string in case of an error.
Note:
See TracChangeset
for help on using the changeset viewer.