Changeset 4343 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-08-26T22:21:19+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
r4096 r4343 12 12 import java.awt.event.KeyEvent; 13 13 import java.lang.reflect.InvocationTargetException; 14 import java.util.Collections; 15 import java.util.LinkedList; 14 16 import java.util.List; 15 17 import java.util.Set; … … 24 26 import javax.swing.JScrollPane; 25 27 import javax.swing.JTextArea; 28 import javax.swing.JTextField; 26 29 import javax.swing.KeyStroke; 27 30 import javax.swing.SwingUtilities; 28 31 import javax.swing.border.EtchedBorder; 32 import javax.swing.plaf.basic.BasicComboBoxEditor; 29 33 30 34 import org.openstreetmap.josm.Main; … … 37 41 import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask; 38 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 39 44 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 40 45 import org.openstreetmap.josm.gui.widgets.OsmIdTextField; … … 57 62 } 58 63 64 /** 65 * Restore the current history from the preferences 66 * 67 * @param cbHistory 68 */ 69 protected void restorePrimitivesHistory(HistoryComboBox cbHistory) { 70 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(getClass().getName() + ".primitivesHistory", new LinkedList<String>())); 71 // we have to reverse the history, because ComboBoxHistory will reverse it again 72 // in addElement() 73 // 74 Collections.reverse(cmtHistory); 75 cbHistory.setPossibleItems(cmtHistory); 76 } 77 78 /** 79 * Remind the current history in the preferences 80 * @param cbHistory 81 */ 82 protected void remindPrimitivesHistory(HistoryComboBox cbHistory) { 83 cbHistory.addCurrentItemToHistory(); 84 Main.pref.putCollection(getClass().getName() + ".primitivesHistory", cbHistory.getHistory()); 85 } 86 59 87 public void actionPerformed(ActionEvent e) { 60 88 … … 67 95 JLabel lbl1 = new JLabel(tr("Object type:")); 68 96 OsmPrimitiveTypesComboBox cbType = new OsmPrimitiveTypesComboBox(); 69 cbType.addItem( new SimpleListItem("mixed", trc("osm object types", "mixed")));97 cbType.addItem(trc("osm object types", "mixed")); 70 98 cbType.setToolTipText(tr("Choose the OSM object type")); 71 99 JLabel lbl2 = new JLabel(tr("Object ID:")); 72 OsmIdTextField tfId = new OsmIdTextField(); 73 tfId.setToolTipText(tr("Enter the ID of the object that should be downloaded")); 100 final OsmIdTextField tfId = new OsmIdTextField(); 101 HistoryComboBox cbId = new HistoryComboBox(); 102 cbId.setEditor(new BasicComboBoxEditor() { 103 @Override 104 protected JTextField createEditorComponent() { 105 return tfId; 106 } 107 }); 108 cbId.setToolTipText(tr("Enter the ID of the object that should be downloaded")); 109 restorePrimitivesHistory(cbId); 74 110 // forward the enter key stroke to the download button 75 111 tfId.getKeymap().removeKeyStrokeBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false)); … … 91 127 .addGroup(layout.createParallelGroup() 92 128 .addComponent(lbl2) 93 .addComponent( tfId, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))129 .addComponent(cbId, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) 94 130 .addComponent(referrers) 95 131 .addComponent(layer) … … 105 141 .addGroup(layout.createParallelGroup() 106 142 .addComponent(cbType) 107 .addComponent( tfId))143 .addComponent(cbId)) 108 144 ) 109 145 .addComponent(referrers) … … 142 178 return; 143 179 } 144 145 processItems(layer.isSelected(), cbType.getType(), tfId.getIds(), referrers.isSelected()); 146 } 147 148 void processItems(boolean newLayer, OsmPrimitiveType type, 149 final List<PrimitiveId> ids, 150 boolean downloadReferrers) { 180 remindPrimitivesHistory(cbId); 181 processItems(layer.isSelected(), tfId.getIds(), referrers.isSelected()); 182 } 183 184 void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers) { 151 185 OsmDataLayer layer = getEditLayer(); 152 186 if ((layer == null) || newLayer) { … … 199 233 } 200 234 } 201 if ( del != null &&!del.isEmpty()) {235 if (!del.isEmpty()) { 202 236 final ExtendedDialog dlg = reportProblemDialog(del, 203 237 trn("Object deleted", "Objects deleted", del.size()), … … 249 283 .setContent(p, false); 250 284 } 251 252 private static class SimpleListItem {253 final String data;254 final String text;255 256 public SimpleListItem(String data, String text) {257 this.data = data;258 this.text = text;259 }260 261 @Override public String toString() {262 return text;263 }264 }265 285 } -
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r4278 r4343 152 152 { 153 153 String prefKey = getPrefKey(url, destDir); 154 // FIXME: replace with normal getCollection after july 2011 155 Collection<String> localPath = Main.pref.getCollectionOld(prefKey, ";"); 154 Collection<String> localPath = Main.pref.getCollection(prefKey); 156 155 if(localPath.size() == 2) { 157 156 String[] lp = (String[]) localPath.toArray();
Note:
See TracChangeset
for help on using the changeset viewer.