Changeset 15117 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-05-26T19:47:06+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r15011 r15117 19 19 import java.util.concurrent.TimeUnit; 20 20 21 import javax.swing.Action;22 21 import javax.swing.BorderFactory; 23 22 import javax.swing.JCheckBox; … … 162 161 } 163 162 164 public void setUploadTagDownFocusTraversalHandlers(final Actionhandler) {163 void setUploadTagDownFocusTraversalHandlers(final ActionListener handler) { 165 164 setHistoryComboBoxDownFocusTraversalHandler(handler, hcbUploadComment); 166 165 setHistoryComboBoxDownFocusTraversalHandler(handler, hcbUploadSource); 167 166 } 168 167 169 p ublic void setHistoryComboBoxDownFocusTraversalHandler(final Action handler, finalHistoryComboBox hcb) {168 private static void setHistoryComboBoxDownFocusTraversalHandler(ActionListener handler, HistoryComboBox hcb) { 170 169 hcb.getEditor().addActionListener(handler); 171 170 hcb.getEditorComponent().addKeyListener(new HistoryComboBoxKeyAdapter(hcb, handler)); … … 177 176 public void rememberUserInput() { 178 177 // store the history of comments 179 hcbUploadComment.addCurrentItemToHistory(); 180 Config.getPref().putList(HISTORY_KEY, hcbUploadComment.getHistory()); 181 Config.getPref().putLong(HISTORY_LAST_USED_KEY, TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); 178 if (getHistoryMaxAgeKey() > 0) { 179 hcbUploadComment.addCurrentItemToHistory(); 180 Config.getPref().putList(HISTORY_KEY, hcbUploadComment.getHistory()); 181 Config.getPref().putLong(HISTORY_LAST_USED_KEY, TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); 182 } 182 183 // store the history of sources 183 184 hcbUploadSource.addCurrentItemToHistory(); … … 232 233 } 233 234 235 static long getHistoryMaxAgeKey() { 236 return Config.getPref().getLong(HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toSeconds(4)); 237 } 238 239 static long getHistoryLastUsedKey() { 240 return Config.getPref().getLong(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0); 241 } 242 234 243 static final class HistoryComboBoxKeyAdapter extends KeyAdapter { 235 244 private final HistoryComboBox hcb; 236 private final Action handler;237 238 HistoryComboBoxKeyAdapter(HistoryComboBox hcb, Action handler) {245 private final ActionListener handler; 246 247 HistoryComboBoxKeyAdapter(HistoryComboBox hcb, ActionListener handler) { 239 248 this.hcb = hcb; 240 249 this.handler = handler; -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r15051 r15117 27 27 import java.util.Map.Entry; 28 28 import java.util.Optional; 29 import java.util.concurrent.TimeUnit;30 29 import java.util.stream.Collectors; 31 30 … … 238 237 ); 239 238 240 pnlBasicUploadSettings.setUploadTagDownFocusTraversalHandlers( 241 new AbstractAction() { 242 @Override 243 public void actionPerformed(ActionEvent e) { 244 btnUpload.requestFocusInWindow(); 245 } 246 } 247 ); 239 pnlBasicUploadSettings.setUploadTagDownFocusTraversalHandlers(e -> btnUpload.requestFocusInWindow()); 248 240 249 241 setMinimumSize(new Dimension(600, 350)); … … 778 770 private static String getLastChangesetTagFromHistory(String historyKey, List<String> def) { 779 771 Collection<String> history = Config.getPref().getList(historyKey, def); 780 long age = System.currentTimeMillis() / 1000 - Config.getPref().getLong(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0); 781 if (age < Config.getPref().getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toSeconds(4)) 782 && !history.isEmpty()) { 772 long age = System.currentTimeMillis() / 1000 - BasicUploadSettingsPanel.getHistoryLastUsedKey(); 773 if (age < BasicUploadSettingsPanel.getHistoryMaxAgeKey() && !history.isEmpty()) { 783 774 return history.iterator().next(); 784 775 }
Note:
See TracChangeset
for help on using the changeset viewer.