Changeset 10137 in josm for trunk/src/org
- Timestamp:
- 2016-04-10T23:53:54+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java
r9970 r10137 30 30 * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3">HTML 4.01 Character References</a> 31 31 * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML 4.01 Code positions</a> 32 * @since 3669 32 33 */ 33 34 public final class Entities { … … 340 341 } 341 342 343 /** 344 * Returns unescaped entity representation. 345 * @param str entity 346 * @return unescaped entity representation 347 */ 342 348 public static String unescape(String str) { 343 349 int firstAmp = str.indexOf('&'); … … 357 363 int amphersandIdx = str.indexOf('&', i + 1); 358 364 if (amphersandIdx != -1 && amphersandIdx < semiColonIdx) { 359 // Then the text looks like &...&...;365 // Then the text looks like "&...&...;" 360 366 res.append(c); 361 367 continue; … … 365 371 int entityContentLen = entityContent.length(); 366 372 if (entityContentLen > 0) { 367 if (entityContent.charAt(0) == '#') { // escaped value content is an integer (decimal or 368 // hexidecimal) 373 if (entityContent.charAt(0) == '#') { // escaped value content is an integer (decimal or hexidecimal) 369 374 if (entityContentLen > 1) { 370 375 char isHexChar = entityContent.charAt(1); -
trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java
r8873 r10137 19 19 public class MultipleNameVisitor extends NameVisitor { 20 20 21 /** 22 * Maximum displayed length, in characters. 23 */ 21 24 public static final int MULTIPLE_NAME_MAX_LENGTH = 80; 22 25 -
trunk/src/org/openstreetmap/josm/data/validation/util/NameVisitor.java
r8509 r10137 19 19 * @author imi 20 20 */ 21 //TODO This class used to be in JOSM but it was removed. MultipleNameVisitor depends on it so I copied it here,22 // but MultipleNameVisitor should be refactored instead of using this class23 21 public class NameVisitor extends AbstractVisitor { 24 22 … … 27 25 */ 28 26 public String className; 27 28 /** 29 * The plural name of the item class 30 */ 29 31 public String classNamePlural; 32 30 33 /** 31 34 * The name of this item. 32 35 */ 33 36 public String name = ""; 37 34 38 /** 35 39 * The icon of this item. … … 38 42 39 43 /** 40 * If the node has a name-key or id-key, this is displayed. If not, (lat,lon) 41 * is displayed. 44 * If the node has a name-key or id-key, this is displayed. If not, (lat,lon) is displayed. 42 45 */ 43 46 @Override … … 69 72 } 70 73 74 /** 75 * Returns an horizontal {@code JLabel} with icon and name. 76 * @return horizontal {@code JLabel} with icon and name 77 */ 71 78 public JLabel toLabel() { 72 79 return new JLabel(name, icon, JLabel.HORIZONTAL); -
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
r9249 r10137 51 51 } 52 52 } catch (MalformedURLException e) { 53 throw new HelpContentReaderException(e );53 throw new HelpContentReaderException(e, 0); 54 54 } catch (IOException e) { 55 HelpContentReaderException ex = new HelpContentReaderException(e); 56 if (con != null) { 57 ex.setResponseCode(con.getResponseCode()); 58 } 59 throw ex; 55 throw new HelpContentReaderException(e, con != null ? con.getResponseCode() : 0); 60 56 } 61 57 } … … 81 77 s = readFromTrac(in, url); 82 78 } catch (IOException e) { 83 throw new HelpContentReaderException(e );79 throw new HelpContentReaderException(e, 0); 84 80 } 85 81 if (dotest && s.isEmpty()) -
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReaderException.java
r10103 r10137 2 2 package org.openstreetmap.josm.gui.help; 3 3 4 /** 5 * Exception thrown when a problem occurs during help contents fetching. 6 * @since 2308 7 */ 4 8 public class HelpContentReaderException extends Exception { 5 private int responseCode; 9 10 private final int responseCode; 6 11 7 12 /** 8 13 * Constructs a new {@code HelpContentReaderException}. 9 14 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 15 * @param responseCode HTTP response code related to the wiki access exception (0 if not applicable) 10 16 */ 11 public HelpContentReaderException(String message ) {17 public HelpContentReaderException(String message, int responseCode) { 12 18 super(message); 19 this.responseCode = responseCode; 13 20 } 14 21 … … 17 24 * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 18 25 * (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.) 26 * @param responseCode HTTP response code related to the wiki access exception (0 if not applicable) 19 27 */ 20 public HelpContentReaderException(Throwable cause ) {28 public HelpContentReaderException(Throwable cause, int responseCode) { 21 29 super(cause); 30 this.responseCode = responseCode; 22 31 } 23 32 … … 28 37 * @return the http response code 29 38 */ 30 public int getResponseCode() {39 public final int getResponseCode() { 31 40 return responseCode; 32 41 } 33 34 /**35 * Sets the HTTP response code36 *37 * @param responseCode the response code38 */39 public void setResponseCode(int responseCode) {40 this.responseCode = responseCode;41 }42 42 } -
trunk/src/org/openstreetmap/josm/gui/help/Helpful.java
r3083 r10137 2 2 package org.openstreetmap.josm.gui.help; 3 3 4 /** 5 * Anything on which we can provide help. 6 * @since 2252 7 */ 4 8 public interface Helpful { 9 10 /** 11 * Returns the help topic on JOSM wiki for this feature. 12 * @return the help topic on JOSM wiki for this feature 13 */ 5 14 String helpTopic(); 6 15 } -
trunk/src/org/openstreetmap/josm/gui/help/MissingHelpContentException.java
r10103 r10137 13 13 */ 14 14 public MissingHelpContentException(String message) { 15 super(message );15 super(message, 0); 16 16 } 17 17 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r8836 r10137 70 70 71 71 protected String formatPluginLocalVersion(PluginInformation pi) { 72 if (pi == null) return tr("unknown"); 72 if (pi == null) 73 return tr("unknown"); 73 74 if (pi.localversion == null || pi.localversion.trim().isEmpty()) 74 75 return tr("unknown"); … … 77 78 78 79 protected String formatCheckboxTooltipText(PluginInformation pi) { 79 if (pi == null) return ""; 80 if (pi == null) 81 return ""; 80 82 if (pi.downloadlink == null) 81 83 return tr("Plugin bundled with JOSM"); … … 107 109 /** 108 110 * A plugin checkbox. 109 *110 111 */ 111 112 private class JPluginCheckBox extends JCheckBox { 112 p ublicfinal transient PluginInformation pi;113 protected final transient PluginInformation pi; 113 114 114 115 JPluginCheckBox(final PluginInformation pi, boolean selected) { … … 122 123 /** 123 124 * Listener called when the user selects/unselects a plugin checkbox. 124 *125 125 */ 126 126 private class PluginCbActionListener implements ActionListener { … … 172 172 } 173 173 174 175 174 /** 176 175 * Alerts the user if an unselected plugin is still required by another plugins … … 181 180 */ 182 181 private static void alertPluginStillRequired(Component parent, String plugin, Set<String> otherPlugins) { 183 StringBuilder sb = new StringBuilder(); 184 sb.append("<html>") 182 StringBuilder sb = new StringBuilder("<html>") 185 183 .append(trn("Plugin {0} is still required by this plugin:", 186 184 "Plugin {0} is still required by these {1} plugins:", -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r10035 r10137 270 270 if (answer != 0 /* OK */) 271 271 return; 272 List<String> sites = pnl.getUpdateSites(); 273 Main.pref.setPluginSites(sites); 272 Main.pref.setPluginSites(pnl.getUpdateSites()); 274 273 } 275 274 … … 497 496 498 497 /** 499 * Applies the current filter condition in the filter text field to the 500 * model 498 * Applies the current filter condition in the filter text field to the model. 501 499 */ 502 500 class SearchFieldAdapter implements DocumentListener { 503 p ublicvoid filter() {501 private void filter() { 504 502 String expr = tfFilter.getText().trim(); 505 503 if (expr.isEmpty()) { … … 597 595 } 598 596 599 p ublicList<String> getUpdateSites() {597 protected List<String> getUpdateSites() { 600 598 if (model.getSize() == 0) 601 599 return Collections.emptyList(); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r9543 r10137 43 43 * 44 44 * For initial authorisation see {@link OAuthAuthorizationWizard}. 45 * 45 * @since 2745 46 46 */ 47 47 public class OAuthAuthenticationPreferencesPanel extends JPanel implements PropertyChangeListener { … … 53 53 private JCheckBox cbShowAdvancedParameters; 54 54 private JCheckBox cbSaveToPreferences; 55 56 /** 57 * Create the panel 58 */ 59 public OAuthAuthenticationPreferencesPanel() { 60 build(); 61 refreshView(); 62 } 55 63 56 64 /** … … 140 148 141 149 /** 142 * Create the panel143 */144 public OAuthAuthenticationPreferencesPanel() {145 build();146 refreshView();147 }148 149 /**150 150 * Sets the URL of the OSM API for which this panel is currently displaying OAuth properties. 151 151 * … … 224 224 private JosmTextField tfAccessTokenSecret; 225 225 226 /** 227 * Constructs a new {@code AlreadyAuthorisedPanel}. 228 */ 229 AlreadyAuthorisedPanel() { 230 build(); 231 refreshView(); 232 } 233 226 234 protected void build() { 227 235 setLayout(new GridBagLayout()); … … 291 299 gc.weighty = 1.0; 292 300 add(new JPanel(), gc); 293 294 } 295 296 public final void refreshView() { 301 } 302 303 protected final void refreshView() { 297 304 String v = OAuthAccessTokenHolder.getInstance().getAccessTokenKey(); 298 305 tfAccessTokenKey.setText(v == null ? "" : v); … … 300 307 tfAccessTokenSecret.setText(v == null ? "" : v); 301 308 cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences()); 302 }303 304 /**305 * Constructs a new {@code AlreadyAuthorisedPanel}.306 */307 AlreadyAuthorisedPanel() {308 build();309 refreshView();310 309 } 311 310 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r9694 r10137 61 61 private transient ApiUrlPropagator propagator; 62 62 63 /** 64 * Constructs a new {@code OsmApiUrlInputPanel}. 65 */ 66 public OsmApiUrlInputPanel() { 67 build(); 68 HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#ApiUrl")); 69 } 70 63 71 protected JComponent buildDefaultServerUrlPanel() { 64 72 cbUseDefaultServerUrl = new JCheckBox(tr("<html>Use the default OSM server URL (<strong>{0}</strong>)</html>", OsmApi.DEFAULT_API_URL)); … … 109 117 tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest); 110 118 add(btnTest = new SideButton(actTest), gc); 111 }112 113 /**114 * Constructs a new {@code OsmApiUrlInputPanel}.115 */116 public OsmApiUrlInputPanel() {117 build();118 HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#ApiUrl"));119 119 } 120 120 … … 152 152 String newUrl = OsmApi.getOsmApi().getServerUrl(); 153 153 154 // When API URL changes, re-initialize API connection so we may adjust 155 // server-dependent settings. 154 // When API URL changes, re-initialize API connection so we may adjust server-dependent settings. 156 155 if (!oldUrl.equals(newUrl)) { 157 156 try { … … 303 302 304 303 class ApiUrlPropagator extends FocusAdapter implements ActionListener { 305 p ublicvoid propagate() {304 protected void propagate() { 306 305 propagate(getStrippedApiUrl()); 307 306 } 308 307 309 p ublicvoid propagate(String url) {308 protected void propagate(String url) { 310 309 firePropertyChange(API_URL_PROP, null, url); 311 310 } -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java
r9231 r10137 7 7 * 8 8 * Instances of this class are not modifiable. 9 * @since 1762 9 10 */ 10 11 public class AutoCompletionItemPriority implements Comparable<AutoCompletionItemPriority> { … … 44 45 private final boolean selected; 45 46 46 47 47 /** 48 * C reate new AutoCompletionItemPriority object.48 * Constructs a new {@code AutoCompletionItemPriority}. 49 49 * 50 50 * @param inDataSet true, if the item is found in the currently active data layer 51 * @param inStandard true, if the item is a standard tag, e.g. from the presets .51 * @param inStandard true, if the item is a standard tag, e.g. from the presets 52 52 * @param selected true, if it is found on an object that is currently selected 53 53 * @param userInput null, if the user hasn't entered this tag so far. A number when … … 62 62 } 63 63 64 /** 65 * Constructs a new {@code AutoCompletionItemPriority}. 66 * 67 * @param inDataSet true, if the item is found in the currently active data layer 68 * @param inStandard true, if the item is a standard tag, e.g. from the presets 69 * @param selected true, if it is found on an object that is currently selected 70 */ 64 71 public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected) { 65 72 this(inDataSet, inStandard, selected, NO_USER_INPUT); 66 73 } 67 74 75 /** 76 * Determines if the item is found in the currently active data layer. 77 * @return {@code true} if the item is found in the currently active data layer 78 */ 68 79 public boolean isInDataSet() { 69 80 return inDataSet; 70 81 } 71 82 83 /** 84 * Determines if the item is a standard tag, e.g. from the presets. 85 * @return {@code true} if the item is a standard tag, e.g. from the presets 86 */ 72 87 public boolean isInStandard() { 73 88 return inStandard; 74 89 } 75 90 91 /** 92 * Determines if it is found on an object that is currently selected. 93 * @return {@code true} if it is found on an object that is currently selected 94 */ 76 95 public boolean isSelected() { 77 96 return selected; 78 97 } 79 98 99 /** 100 * Returns a number when the tag key / value has been entered by the user before. 101 * A lower number means this happened more recently and beats a higher number in priority. 102 * @return a number when the tag key / value has been entered by the user before. 103 * {@code null}, if the user hasn't entered this tag so far. 104 */ 80 105 public Integer getUserInput() { 81 106 return userInput == NO_USER_INPUT ? null : userInput; … … 89 114 public int compareTo(AutoCompletionItemPriority other) { 90 115 int ui = Integer.compare(other.userInput, userInput); 91 if (ui != 0) return ui; 116 if (ui != 0) 117 return ui; 92 118 93 119 int sel = Boolean.valueOf(selected).compareTo(other.selected); 94 if (sel != 0) return sel; 120 if (sel != 0) 121 return sel; 95 122 96 123 int ds = Boolean.valueOf(inDataSet).compareTo(other.inDataSet); 97 if (ds != 0) return ds; 124 if (ds != 0) 125 return ds; 98 126 99 127 int std = Boolean.valueOf(inStandard).compareTo(other.inStandard); 100 if (std != 0) return std; 128 if (std != 0) 129 return std; 101 130 102 131 return 0; -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java
r9078 r10137 28 28 * AutoCompletionList is an {@link AbstractTableModel} which serves the list of filtered 29 29 * items to a {@link JTable}. 30 * 30 * @since 1762 31 31 */ 32 32 public class AutoCompletionList extends AbstractTableModel { … … 67 67 /** 68 68 * clears the current filter 69 *70 69 */ 71 70 public void clearFilter() { … … 135 134 */ 136 135 public void add(Collection<String> values, AutoCompletionItemPriority priority) { 137 if (values == null) return; 138 for (String value: values) { 136 if (values == null) 137 return; 138 for (String value : values) { 139 139 if (value == null) { 140 140 continue; … … 148 148 } 149 149 150 /** 151 * Adds values that have been entered by the user. 152 * @param values values that have been entered by the user 153 */ 150 154 public void addUserInput(Collection<String> values) { 151 if (values == null) return; 155 if (values == null) 156 return; 152 157 int i = 0; 153 for (String value: values) { 154 if (value == null) { 155 continue; 156 } 157 AutoCompletionListItem item = new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i)); 158 appendOrUpdatePriority(item); 159 i++; 158 for (String value : values) { 159 if (value != null) { 160 appendOrUpdatePriority( 161 new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i++))); 162 } 160 163 } 161 164 sort();
Note:
See TracChangeset
for help on using the changeset viewer.