Changeset 6365 in josm for trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
- Timestamp:
- 2013-11-05T01:53:15+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r6340 r6365 34 34 /** 35 35 * List class that read and save its content from the bookmark file. 36 * @ author imi36 * @since 6340 37 37 */ 38 38 public class BookmarkList extends JList { … … 40 40 /** 41 41 * Class holding one bookmarkentry. 42 * @author imi43 42 */ 44 43 public static class Bookmark implements Comparable<Bookmark> { … … 46 45 private Bounds area; 47 46 47 /** 48 * Constructs a new {@code Bookmark} with the given contents. 49 * @param list Bookmark contents as a list of 5 elements. First item is the name, then come bounds arguments (minlat, minlon, maxlat, maxlon) 50 * @throws NumberFormatException If the bounds arguments are not numbers 51 * @throws IllegalArgumentException If list contain less than 5 elements 52 */ 48 53 public Bookmark(Collection<String> list) throws NumberFormatException, IllegalArgumentException { 49 54 List<String> array = new ArrayList<String>(list); … … 56 61 57 62 /** 58 * Constructs a new {@code Bookmark}. 63 * Constructs a new empty {@code Bookmark}. 59 64 */ 60 65 public Bookmark() { … … 63 68 } 64 69 70 /** 71 * Constructs a new unamed {@code Bookmark} for the given area. 72 * @param area The bookmark area 73 */ 65 74 public Bookmark(Bounds area) { 66 75 this.area = area; … … 75 84 return name.toLowerCase().compareTo(b.name.toLowerCase()); 76 85 } 77 86 87 @Override 88 public int hashCode() { 89 final int prime = 31; 90 int result = 1; 91 result = prime * result + ((area == null) ? 0 : area.hashCode()); 92 result = prime * result + ((name == null) ? 0 : name.hashCode()); 93 return result; 94 } 95 96 @Override 97 public boolean equals(Object obj) { 98 if (this == obj) 99 return true; 100 if (obj == null) 101 return false; 102 if (getClass() != obj.getClass()) 103 return false; 104 Bookmark other = (Bookmark) obj; 105 if (area == null) { 106 if (other.area != null) 107 return false; 108 } else if (!area.equals(other.area)) 109 return false; 110 if (name == null) { 111 if (other.name != null) 112 return false; 113 } else if (!name.equals(other.name)) 114 return false; 115 return true; 116 } 117 118 /** 119 * Returns the bookmark area 120 * @return The bookmark area 121 */ 78 122 public Bounds getArea() { 79 123 return area; 80 124 } 81 125 126 /** 127 * Returns the bookmark name 128 * @return The bookmark name 129 */ 82 130 public String getName() { 83 131 return name; 84 132 } 85 133 134 /** 135 * Sets the bookmark name 136 * @param name The bookmark name 137 */ 86 138 public void setName(String name) { 87 139 this.name = name; 88 140 } 89 141 142 /** 143 * Sets the bookmark area 144 * @param area The bookmark area 145 */ 90 146 public void setArea(Bounds area) { 91 147 this.area = area; … … 94 150 95 151 /** 96 * Create a bookmark list as well as the Buttons add and remove. 152 * Creates a bookmark list as well as the Buttons add and remove. 97 153 */ 98 154 public BookmarkList() { … … 106 162 * Loads the bookmarks from file. 107 163 */ 108 public void load() { 164 public final void load() { 109 165 DefaultListModel model = (DefaultListModel)getModel(); 110 166 model.removeAllElements(); … … 161 217 save(); 162 218 Main.info("Removing obsolete bookmarks file"); 163 bookmarkFile.delete(); 219 if (!bookmarkFile.delete()) { 220 bookmarkFile.deleteOnExit(); 221 } 164 222 } 165 223 } catch (IOException e) { 166 e.printStackTrace();224 Main.error(e); 167 225 JOptionPane.showMessageDialog( 168 226 Main.parent, … … 179 237 180 238 /** 181 * Save all bookmarks to the preferences file 239 * Saves all bookmarks to the preferences file 182 240 */ 183 241 public void save() {
Note:
See TracChangeset
for help on using the changeset viewer.