Changeset 28416 in osm for applications/editors/josm/plugins/undelete/src/org
- Timestamp:
- 2012-05-31T13:45:56+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/undelete/src/org/openstreetmap/josm/plugins/undelete/Undelete.java
r28376 r28416 57 57 public Undelete(PluginInformation info) { 58 58 super(info); 59 Undelete = MainMenu.add (Main.main.menu.fileMenu, new UndeleteAction());59 Undelete = MainMenu.addAfter(Main.main.menu.fileMenu, new UndeleteAction(), false, Main.main.menu.updateModified); 60 60 61 61 } … … 83 83 gc.gridy = 0; 84 84 gc.weightx = 0; 85 all.add(new JLabel(tr("Object type:")), gc);86 OsmPrimitiveTypesComboBox cbType = new OsmPrimitiveTypesComboBox();87 cbType.setToolTipText("Choose the OSM object type");88 cbType.setSelectedIndex(Main.pref.getInteger("undelete.lasttype", 0));89 gc.weightx = 1;90 all.add(cbType, gc);91 gc.gridy = 1;92 gc.weightx = 0;93 85 all.add(new JLabel(tr("Object ID:")), gc); 94 86 OsmIdTextField tfId = new OsmIdTextField(); 95 87 tfId.setText(Main.pref.get("undelete.osmid")); 96 tfId.setToolTipText(tr("Enter the ID of the object that should be undeleted"));88 tfId.setToolTipText(tr("Enter the type and ID of the objects that should be undeleted, e.g., ''n1 w2''")); 97 89 // forward the enter key stroke to the undelete button 98 90 tfId.getKeymap().removeKeyStrokeBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false)); 99 91 gc.weightx = 1; 100 92 all.add(tfId, gc); 101 gc.gridy = 2;93 gc.gridy++; 102 94 gc.fill = GridBagConstraints.BOTH; 103 95 gc.weighty = 1.0; 104 96 gc.weightx = 0; 105 gc.gridy = 3;97 gc.gridy++; 106 98 all.add(layer, gc); 107 99 ExtendedDialog dialog = new ExtendedDialog(Main.parent, … … 119 111 dialog.showDialog(); 120 112 if (dialog.getValue() != 1) return; 121 Main.pref.putInteger("undelete.lasttype", cbType.getSelectedIndex());122 113 Main.pref.put("undelete.newlayer", layer.isSelected()); 123 114 Main.pref.put("undelete.osmid", tfId.getText()); 124 List<Long> ids=new ArrayList<Long>(); 125 for (PrimitiveId id: tfId.getIds()) { 126 ids.add(id.getUniqueId()); 127 } 128 undelete(layer.isSelected(), cbType.getType(), ids, 0); 115 undelete(layer.isSelected(), tfId.getIds(), 0); 129 116 } 130 117 } … … 133 120 * Download the given primitive. 134 121 */ 135 public void undelete(boolean newLayer, final OsmPrimitiveType type, final List<Long> ids, final long parent) {122 public void undelete(boolean newLayer, final List<PrimitiveId> ids, final long parent) { 136 123 OsmDataLayer tmpLayer = Main.main.getEditLayer(); 137 124 if ((tmpLayer == null) || newLayer) { … … 144 131 145 132 HistoryLoadTask task = new HistoryLoadTask(); 146 for (long id: ids) 147 { 148 task.add (id, type); 133 for (PrimitiveId id: ids) { 134 task.add(id); 149 135 } 150 136 … … 155 141 Runnable r = new Runnable() { 156 142 @Override 157 143 public void run() { 158 144 List<Node> nodes=new ArrayList<Node>(); 159 for ( longid: ids)145 for (PrimitiveId pid: ids) 160 146 { 147 148 final Long id = pid.getUniqueId(); 149 final OsmPrimitiveType type = pid.getType(); 161 150 162 151 History h = HistoryDataSet.getInstance().getHistory(id, type); … … 171 160 { 172 161 // If the object is not deleted we get the real object 173 DownloadPrimitiveTask download=new DownloadPrimitiveTask( new SimplePrimitiveId(id, type), layer);174 System.out.println(tr("Will get {0}", id));162 DownloadPrimitiveTask download=new DownloadPrimitiveTask(pid, layer); 163 System.out.println(tr("Will get {0}", pid)); 175 164 download.run(); 176 165 177 166 178 System.out.println(tr("Looking for {0}", id));167 System.out.println(tr("Looking for {0}", pid)); 179 168 primitive=datas.getPrimitiveById(id, type); 180 System.out.println(tr("Found {0}", primitive.getId()));169 System.out.println(tr("Found {0}", String.valueOf(primitive.getId()))); 181 170 if (parent>0 && type.equals(OsmPrimitiveType.NODE)) 182 171 { … … 214 203 HistoryWay hWay = (HistoryWay) hPrimitive2; 215 204 //System.out.println(tr("Primitive {0} version {1}: {2} nodes", hPrimitive2.getId(), hPrimitive2.getVersion(), hWay.getNumNodes())); 216 List<Long> nodeIds = hWay.getNodes(); 217 undelete(false, OsmPrimitiveType.NODE, nodeIds, id); 205 List<PrimitiveId> nodeIds = new ArrayList<PrimitiveId>(); 206 for (Long i: hWay.getNodes()) { 207 nodeIds.add(new SimplePrimitiveId(i, OsmPrimitiveType.NODE)); 208 } 209 undelete(false, nodeIds, id); 218 210 219 211 primitive=way; … … 265 257 //HistoryBrowserDialogManager.getInstance().show(h); 266 258 } 267 if ( (parent>0) && (type.equals(OsmPrimitiveType.NODE)))259 if (parent>0 && !ids.isEmpty() && ids.iterator().next().getType().equals(OsmPrimitiveType.NODE)) 268 260 { 269 261 Way parentWay=(Way)datas.getPrimitiveById(parent, OsmPrimitiveType.WAY);
Note:
See TracChangeset
for help on using the changeset viewer.