Changeset 6365 in josm
- Timestamp:
- 2013-11-05T01:53:15+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r6302 r6365 18 18 19 19 /** 20 * Command that basically replaces one OSM primitive by another of the 21 * same type. 20 * Command that basically replaces one OSM primitive by another of the same type. 22 21 * 23 * @ author Imi22 * @since 93 24 23 */ 25 24 public class ChangeCommand extends Command { … … 45 44 CheckParameterUtil.ensureParameterNotNull(osm, "osm"); 46 45 CheckParameterUtil.ensureParameterNotNull(newOsm, "newOsm"); 47 if (newOsm instanceof Way) { 46 if (newOsm instanceof Way && ((Way)newOsm).getNodesCount() == 0) { 48 47 // Do not allow to create empty ways (see #7465) 49 if (((Way)newOsm).getNodesCount() == 0) { 50 throw new IllegalArgumentException(tr("New way {0} has 0 nodes", newOsm)); 51 } 48 throw new IllegalArgumentException(tr("New way {0} has 0 nodes", newOsm)); 52 49 } 53 50 } 54 51 55 @Override public boolean executeCommand() { 52 @Override 53 public boolean executeCommand() { 56 54 super.executeCommand(); 57 55 osm.cloneFrom(newOsm); … … 60 58 } 61 59 62 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 60 @Override 61 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 63 62 modified.add(osm); 64 63 } -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r6364 r6365 222 222 } 223 223 224 private List<TileSource> getTileSources() { 224 private final List<TileSource> getTileSources() { 225 225 List<TileSource> tileSources = new ArrayList<TileSource>(); 226 226 for (TileSourceProvider provider: providers) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r6324 r6365 24 24 public class PropertiesCellRenderer extends DefaultTableCellRenderer { 25 25 26 private void setColors(Component c, String key, boolean isSelected , boolean hasFocus) {26 private void setColors(Component c, String key, boolean isSelected) { 27 27 UIDefaults defaults = javax.swing.UIManager.getDefaults(); 28 28 if (OsmPrimitive.getDiscardableKeys().contains(key)) { … … 71 71 } 72 72 } 73 setColors(c, key, isSelected , hasFocus);73 setColors(c, key, isSelected); 74 74 } 75 75 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r6361 r6365 1241 1241 @Override 1242 1242 public void preferenceChanged(PreferenceChangeEvent e) { 1243 if ("display.discardable-keys".equals(e.getKey())) { 1244 if (Main.main.getCurrentDataSet() != null) { 1245 // Re-load data when display preference change 1246 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 1247 } 1243 if ("display.discardable-keys".equals(e.getKey()) && Main.main.getCurrentDataSet() != null) { 1244 // Re-load data when display preference change 1245 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 1248 1246 } 1249 1247 } -
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() { -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r6364 r6365 102 102 buildMainPanelAboveDownloadSelections(pnl); 103 103 104 slippyMapChooser = new SlippyMapChooser(); 105 104 106 // predefined download selections 105 downloadSelections.add(slippyMapChooser = new SlippyMapChooser());107 downloadSelections.add(slippyMapChooser); 106 108 downloadSelections.add(new BookmarkSelection()); 107 109 downloadSelections.add(new BoundingBoxSelection()); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
r6349 r6365 51 51 GridBagConstraints gc = new GridBagConstraints(); 52 52 53 AuthenticationMethodChangeListener 53 AuthenticationMethodChangeListener authChangeListener = new AuthenticationMethodChangeListener(); 54 54 55 55 // -- radio button for basic authentication … … 83 83 gc.weightx = 1.0; 84 84 gc.weighty = 1.0; 85 add(pnlAuthenticationParameteters = new JPanel(), gc); 85 pnlAuthenticationParameteters = new JPanel(); 86 add(pnlAuthenticationParameteters, gc); 86 87 pnlAuthenticationParameteters.setLayout(new BorderLayout()); 87 88 … … 96 97 gc.gridy = 2; 97 98 gc.fill = GridBagConstraints.NONE; 98 add(pnlMessagesPreferences = new MessagesNotifierPanel(), gc); 99 pnlMessagesPreferences = new MessagesNotifierPanel(); 100 add(pnlMessagesPreferences, gc); 99 101 } 100 102 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/MessagesNotifierPanel.java
r6349 r6365 67 67 * Initializes the panel from preferences 68 68 */ 69 public void initFromPreferences() { 69 public final void initFromPreferences() { 70 70 notifier.setSelected(MessageNotifier.PROP_NOTIFIER_ENABLED.get()); 71 71 notifierInterval.setText(Integer.toString(MessageNotifier.PROP_INTERVAL.get())); -
trunk/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java
r6340 r6365 1 1 // License: GPL. For details, see LICENSE file. 2 3 2 package org.openstreetmap.josm.gui.widgets; 4 3 … … 17 16 * Note that this won't work if JMultilineLabel is put into a JScrollBox or 18 17 * similar as the bounds will never change. Instead scrollbars will be displayed. 18 * 19 * @since 6340 19 20 */ 20 21 public class JMultilineLabel extends JLabel { … … 29 30 * 30 31 * Use setMaxWidth to limit the width of the label. 31 * @param text 32 * @param text The text to display 32 33 */ 33 public JMultilineLabel(String text) 34 { 34 public JMultilineLabel(String text) { 35 35 super(); 36 text= text.trim().replaceAll("\n", "<br>");37 if (!text.startsWith("<html>")) {38 text= "<html>" +text+ "</html>";36 String html = text.trim().replaceAll("\n", "<br>"); 37 if (!html.startsWith("<html>")) { 38 html = "<html>" + html + "</html>"; 39 39 } 40 super.setText( text);40 super.setText(html); 41 41 } 42 42 -
trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java
r6342 r6365 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.widgets; 3 3 … … 16 16 /** 17 17 * Label that contains a clickable link. 18 * @author Imi 19 * 5050: Simplifications by Zverikk included by akks 18 * @since 6340 20 19 */ 21 20 public class UrlLabel extends JLabel implements MouseListener { … … 25 24 26 25 /** 27 * Constructs a new {@code UrlLabel}. 26 * Constructs a new empty {@code UrlLabel}. 28 27 */ 29 28 public UrlLabel() { … … 32 31 } 33 32 33 /** 34 * Constructs a new {@code UrlLabel} for the given URL. 35 * @param url The URL to use, also used as description 36 */ 34 37 public UrlLabel(String url) { 35 38 this (url, url, 0); 36 39 } 37 40 41 /** 42 * Constructs a new {@code UrlLabel} for the given URL and font increase. 43 * @param url The URL to use, also used as description 44 * @param fontPlus The font increase in 1/72 of an inch units. 45 */ 38 46 public UrlLabel(String url, int fontPlus) { 39 47 this (url, url, fontPlus); 40 48 } 41 49 50 /** 51 * Constructs a new {@code UrlLabel} for the given URL and description. 52 * @param url The URL to use 53 * @param description The description to display 54 */ 42 55 public UrlLabel(String url, String description) { 43 56 this (url, description, 0); 44 57 } 45 58 59 /** 60 * Constructs a new {@code UrlLabel} for the given URL, description and font increase. 61 * @param url The URL to use 62 * @param description The description to display 63 * @param fontPlus The font increase in 1/72 of an inch units. 64 */ 46 65 public UrlLabel(String url, String description, int fontPlus) { 47 66 this(); … … 54 73 } 55 74 56 protected void refresh() { 75 protected final void refresh() { 57 76 if (url != null) { 58 77 setText("<html><a href=\""+url+"\">"+description+"</a></html>"); … … 72 91 * @param url the url. Can be null. 73 92 */ 74 public void setUrl(String url) { 93 public final void setUrl(String url) { 75 94 this.url = url; 76 95 refresh(); … … 82 101 * @param description the description 83 102 */ 84 public void setDescription(String description) { 103 public final void setDescription(String description) { 85 104 this.description = description == null? "" : description; 86 105 this.description = this.description.replace("&", "&").replace(">", ">").replace("<", "<"); … … 90 109 @Override 91 110 public void mouseClicked(MouseEvent e) { 92 if (SwingUtilities.isLeftMouseButton(e)111 if (SwingUtilities.isLeftMouseButton(e)) { 93 112 OpenBrowser.displayUrl(url); 94 } else if (SwingUtilities.isRightMouseButton(e)113 } else if (SwingUtilities.isRightMouseButton(e)) { 95 114 Utils.copyToClipboard(url); 96 115 } 97 116 } 117 98 118 @Override 99 public void mousePressed(MouseEvent e) { } 119 public void mousePressed(MouseEvent e) { 120 // Ignored 121 } 122 100 123 @Override 101 public void mouseEntered(MouseEvent e) { } 124 public void mouseEntered(MouseEvent e) { 125 // Ignored 126 } 127 102 128 @Override 103 public void mouseExited(MouseEvent e) { } 129 public void mouseExited(MouseEvent e) { 130 // Ignored 131 } 132 104 133 @Override 105 public void mouseReleased(MouseEvent e) { } 106 134 public void mouseReleased(MouseEvent e) { 135 // Ignored 136 } 107 137 } -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r6360 r6365 46 46 public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("message.notifier.interval", 5); 47 47 48 private static final ScheduledExecutorService executor= Executors.newSingleThreadScheduledExecutor();48 private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor(); 49 49 50 private static final Runnable worker= new Worker();50 private static final Runnable WORKER = new Worker(); 51 51 52 52 private static ScheduledFuture<?> task = null; … … 89 89 int interval = PROP_INTERVAL.get(); 90 90 if (!isRunning() && interval > 0 && isUserEnoughIdentified()) { 91 task = executor.scheduleAtFixedRate(worker, 0, interval * 60, TimeUnit.SECONDS);91 task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval * 60, TimeUnit.SECONDS); 92 92 Main.info("Message notifier active (checks every "+interval+" minute"+(interval>1?"s":"")+")"); 93 93 } -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r6349 r6365 121 121 userInfo.setUnreadMessages(Integer.parseInt(v)); 122 122 } catch(NumberFormatException e) { 123 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "unread", "received", v)); 123 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "unread", "received", v), e); 124 124 } 125 125 } -
trunk/src/org/openstreetmap/josm/io/auth/DefaultAuthenticator.java
r6362 r6365 11 11 /** 12 12 * This is the default authenticator used in JOSM. It delegates lookup of credentials 13 * for the OSM API and an optional proxy server to the currently configured 14 * {@link CredentialsManager}. 15 * 13 * for the OSM API and an optional proxy server to the currently configured {@link CredentialsManager}. 14 * @since 2641 16 15 */ 17 16 public final class DefaultAuthenticator extends Authenticator { 18 17 private static DefaultAuthenticator instance; 19 18 19 /** 20 * Returns the unique instance 21 * @return The unique instance 22 */ 20 23 public static DefaultAuthenticator getInstance() { 21 24 return instance; 22 25 } 23 26 27 /** 28 * Creates the unique instance 29 */ 24 30 public static void createInstance() { 25 31 instance = new DefaultAuthenticator(); … … 33 39 34 40 /** 35 * Called by the Java http stack when either the OSM API server or a proxy requires 36 * authentication. 37 * 41 * Called by the Java HTTP stack when either the OSM API server or a proxy requires authentication. 38 42 */ 39 @Override protected PasswordAuthentication getPasswordAuthentication() { 43 @Override 44 protected PasswordAuthentication getPasswordAuthentication() { 40 45 if (!enabled) 41 46 return null; 42 47 try { 43 if (getRequestorType().equals(Authenticator.RequestorType.SERVER)) { 48 if (getRequestorType().equals(Authenticator.RequestorType.SERVER) && OsmApi.isUsingOAuth()) { 44 49 // if we are working with OAuth we don't prompt for a password 45 if (OsmApi.isUsingOAuth()) 46 return null; 50 return null; 47 51 } 48 52 boolean tried = credentialsTried.get(getRequestorType()) != null;
Note:
See TracChangeset
for help on using the changeset viewer.