Ticket #6734: patch.diff
File patch.diff, 6.2 KB (added by , 13 years ago) |
---|
-
src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
11 11 import java.awt.event.ActionEvent; 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; 16 18 import java.util.TreeSet; … … 23 25 import javax.swing.JPanel; 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; 31 35 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; … … 36 40 import org.openstreetmap.josm.gui.ExtendedDialog; 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; 41 46 import org.openstreetmap.josm.gui.widgets.OsmPrimitiveTypesComboBox; … … 56 61 putValue("help", ht("/Action/DownloadObject")); 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 61 89 JPanel all = new JPanel(); … … 66 94 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)); 76 112 JCheckBox layer = new JCheckBox(tr("Separate Layer")); … … 90 126 .addComponent(cbType, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) 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) 96 132 .addComponent(help) … … 104 140 ) 105 141 .addGroup(layout.createParallelGroup() 106 142 .addComponent(cbType) 107 .addComponent( tfId))143 .addComponent(cbId)) 108 144 ) 109 145 .addComponent(referrers) 110 146 .addComponent(layer) … … 141 177 ); 142 178 return; 143 179 } 144 180 remindPrimitivesHistory(cbId); 145 181 processItems(layer.isSelected(), cbType.getType(), tfId.getIds(), referrers.isSelected()); 146 182 } 147 183 … … 198 234 del.add(id); 199 235 } 200 236 } 201 if ( del != null &&!del.isEmpty()) {237 if (!del.isEmpty()) { 202 238 final ExtendedDialog dlg = reportProblemDialog(del, 203 239 trn("Object deleted", "Objects deleted", del.size()), 204 240 trn( … … 248 284 .setIcon(msgType) 249 285 .setContent(p, false); 250 286 } 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 287 } -
src/org/openstreetmap/josm/gui/widgets/OsmPrimitiveTypesComboBox.java
8 8 /** 9 9 * @author Matthias Julius 10 10 */ 11 public class OsmPrimitiveTypesComboBox extends JComboBox {11 public class OsmPrimitiveTypesComboBox extends JComboBox<Object> { 12 12 13 13 public OsmPrimitiveTypesComboBox() { 14 14 for (OsmPrimitiveType type: OsmPrimitiveType.values()){