Changeset 8218 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-04-18T12:33:06+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
r8217 r8218 15 15 import org.openstreetmap.josm.data.Bounds; 16 16 import org.openstreetmap.josm.data.notes.Note; 17 import org.openstreetmap.josm.data.preferences.IntegerProperty; 17 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 19 import org.openstreetmap.josm.gui.layer.NoteLayer; … … 30 31 private static final String PATTERN_API_URL = "https?://.*/api/0.6/notes.*"; 31 32 private static final String PATTERN_DUMP_FILE = "https?://.*/(.*\\.osn(.bz2)?)"; 33 /** Property defining the number of notes to be downloaded */ 34 public static final IntegerProperty DOWNLOAD_LIMIT = new IntegerProperty("osm.notes.downloadLimit", 1000); 35 /** Property defining number of days a bug needs to be closed to no longer be downloaded */ 36 public static final IntegerProperty DAYS_CLOSED = new IntegerProperty("osm.notes.daysClosed", 7); 32 37 33 38 private DownloadTask downloadTask; … … 143 148 ProgressMonitor subMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 144 149 try { 145 notesData = reader.parseNotes( null, null, subMonitor);150 notesData = reader.parseNotes(DOWNLOAD_LIMIT.get(), DAYS_CLOSED.get(), subMonitor); 146 151 } catch (BoundingBoxDownloader.MoreNotesException e) { 147 152 notesData = e.notes; -
trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
r7509 r8218 16 16 import javax.swing.JPanel; 17 17 import javax.swing.JRadioButton; 18 import javax.swing.JSeparator; 18 19 19 20 import org.openstreetmap.josm.Main; … … 42 43 private OAuthAuthenticationPreferencesPanel pnlOAuthPreferences; 43 44 /** the panel for messages notifier preferences */ 44 private MessagesNotifierPanel pnlMessagesPreferences;45 private FeaturesPanel pnlFeaturesPreferences; 45 46 46 47 /** … … 94 95 pnlAuthenticationParameteters.add(pnlBasicAuthPreferences, BorderLayout.CENTER); 95 96 96 //-- the panel for messages preferences97 97 gc.gridy = 2; 98 add(new JSeparator(), gc); 99 100 //-- the panel for API feature preferences 101 gc.gridy = 3; 98 102 gc.fill = GridBagConstraints.NONE; 99 pnl MessagesPreferences = new MessagesNotifierPanel();100 add(pnl MessagesPreferences, gc);103 pnlFeaturesPreferences = new FeaturesPanel(); 104 add(pnlFeaturesPreferences, gc); 101 105 } 102 106 … … 125 129 pnlBasicAuthPreferences.initFromPreferences(); 126 130 pnlOAuthPreferences.initFromPreferences(); 127 pnl MessagesPreferences.initFromPreferences();131 pnlFeaturesPreferences.initFromPreferences(); 128 132 } 129 133 … … 152 156 } 153 157 // save message notifications preferences. To be done after authentication preferences. 154 pnl MessagesPreferences.saveToPreferences();158 pnlFeaturesPreferences.saveToPreferences(); 155 159 } 156 160 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/FeaturesPanel.java
r8217 r8218 13 13 import javax.swing.event.ChangeListener; 14 14 15 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; 15 16 import org.openstreetmap.josm.gui.widgets.JosmTextField; 16 17 import org.openstreetmap.josm.io.MessageNotifier; … … 21 22 * @since 6349 22 23 */ 23 public class MessagesNotifierPanel extends JPanel {24 public class FeaturesPanel extends JPanel { 24 25 25 26 private JCheckBox notifier; 26 27 private JLabel intervalLabel; 27 28 private final JosmTextField notifierInterval = new JosmTextField(4); 29 private final JosmTextField notesDaysClosed = new JosmTextField(4); 28 30 29 31 /** 30 32 * Constructs a new {@code MessagesNotifierPanel}. 31 33 */ 32 public MessagesNotifierPanel() {34 public FeaturesPanel() { 33 35 build(); 34 36 initFromPreferences(); … … 50 52 51 53 intervalLabel = new JLabel(tr("Check interval (minutes):")); 52 add(intervalLabel, GBC.std().insets(25, 0,0,0));54 add(intervalLabel, GBC.std().insets(25, 0, 0, 0)); 53 55 54 56 notifierInterval.setToolTipText(tr("Default value: {0}", MessageNotifier.PROP_INTERVAL.getDefaultValue())); 55 57 notifierInterval.setMinimumSize(notifierInterval.getPreferredSize()); 56 58 add(notifierInterval, GBC.eol().insets(5,0,0,0)); 59 60 final JLabel notesDaysClosedLabel = new JLabel(tr("Max age for closed notes (days):")); 61 notesDaysClosedLabel.setToolTipText(tr("Specifies the number of days a note needs to be closed to no longer be downloaded")); 62 add(notesDaysClosedLabel, GBC.std().insets(0, 20, 0, 0)); 63 notesDaysClosed.setToolTipText(tr("Default value: {0}", DownloadNotesTask.DAYS_CLOSED.getDefaultValue())); 64 notesDaysClosed.setMinimumSize(notesDaysClosed.getPreferredSize()); 65 add(notesDaysClosed, GBC.eol().insets(5, 20, 0, 0)); 66 57 67 } 58 68 … … 62 72 notifierInterval.setEnabled(enabled); 63 73 notifierInterval.setEditable(enabled); 74 notesDaysClosed.setEditable(enabled); 64 75 } 65 76 … … 70 81 notifier.setSelected(MessageNotifier.PROP_NOTIFIER_ENABLED.get()); 71 82 notifierInterval.setText(Integer.toString(MessageNotifier.PROP_INTERVAL.get())); 83 notesDaysClosed.setText(Integer.toString(DownloadNotesTask.DAYS_CLOSED.get())); 72 84 } 73 85 … … 79 91 boolean changed = MessageNotifier.PROP_NOTIFIER_ENABLED.put(enabled); 80 92 changed |= MessageNotifier.PROP_INTERVAL.parseAndPut(notifierInterval.getText()); 93 changed |= DownloadNotesTask.DAYS_CLOSED.parseAndPut(notesDaysClosed.getText()); 81 94 // If parameters have changed, restart notifier 82 95 if (changed) { -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r8217 r8218 8 8 import java.util.List; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.Bounds; 12 11 import org.openstreetmap.josm.data.DataSource; … … 162 161 163 162 @Override 164 public List<Note> parseNotes( Integer noteLimit, IntegerdaysClosed, ProgressMonitor progressMonitor) throws OsmTransferException, MoreNotesException {163 public List<Note> parseNotes(int noteLimit, int daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException, MoreNotesException { 165 164 progressMonitor.beginTask("Downloading notes"); 166 noteLimit = checkNoteLimit(noteLimit); 167 daysClosed = checkDaysClosed(daysClosed); 168 String url = new StringBuilder() 169 .append("notes?limit=") 170 .append(noteLimit) 171 .append("&closed=") 172 .append(daysClosed) 173 .append("&bbox=") 174 .append(lon1) 175 .append(",").append(lat1) 176 .append(",").append(lon2) 177 .append(",").append(lat2) 178 .toString(); 165 CheckParameterUtil.ensureThat(noteLimit > 0, "Requested note limit is less than 1."); 166 // see max_number_of_nodes in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml 167 CheckParameterUtil.ensureThat(noteLimit <= 50000, "Requested note limit is over API hard limit of 50000."); 168 CheckParameterUtil.ensureThat(daysClosed >= 0, "Requested note limit is less than 0."); 169 String url = "notes?limit=" + noteLimit + "&closed=" + daysClosed + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2; 179 170 try { 180 171 InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false)); … … 213 204 } 214 205 215 private Integer checkNoteLimit(Integer limit) {216 if (limit == null) {217 limit = Main.pref.getInteger("osm.notes.downloadLimit", 1000);218 }219 if (limit > 50000) {220 // see max_number_of_nodes in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml221 Main.error("Requested note limit is over API hard limit of 50000. Reducing to 50000.");222 limit = 50000;223 }224 if (limit < 1) {225 Main.error("Requested note limit is less than 1. Setting to 1.");226 limit = 1;227 }228 return limit;229 }230 231 private Integer checkDaysClosed(Integer days) {232 if (days == null) {233 days = Main.pref.getInteger("osm.notes.daysClosed", 7);234 }235 if (days < -1) {236 Main.error("Requested days closed must be greater than -1");237 days = -1;238 }239 return days;240 }241 242 206 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r7531 r8218 354 354 * Downloads notes from the API, given API limit parameters 355 355 * 356 * @param noteLimit How many notes to download. Defaults to 1000 if not specified. API has a hard limit of 10000356 * @param noteLimit How many notes to download. 357 357 * @param daysClosed Return notes closed this many days in the past. -1 means all notes, ever. 0 means only unresolved notes. 358 358 * @param progressMonitor Progress monitor for user feedback … … 360 360 * @throws OsmTransferException if any errors happen 361 361 */ 362 public List<Note> parseNotes( Integer noteLimit, IntegerdaysClosed, ProgressMonitor progressMonitor) throws OsmTransferException {362 public List<Note> parseNotes(int noteLimit, int daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException { 363 363 return null; 364 364 }
Note:
See TracChangeset
for help on using the changeset viewer.