Changeset 2613 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-12-11T23:07:59+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r2512 r2613 188 188 map.mapView.removeLayer(layer); 189 189 if (map.mapView.getAllLayers().isEmpty()) { 190 map.tearDownDialogsPane(); 190 191 setMapFrame(null); 191 192 } -
trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java
r2512 r2613 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.event.ActionEvent; … … 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.data.osm.Changeset; 18 import org.openstreetmap.josm.data.osm.ChangesetCache; 18 19 import org.openstreetmap.josm.data.osm.UserInfo; 19 20 import org.openstreetmap.josm.gui.ExceptionDialogUtil; … … 49 50 } 50 51 51 protected void onPostDownloadOpenChangesets(DownloadOpenChangesetsTask task) { 52 if (task.isCancelled() || task.getLastException() != null) return; 53 54 List<Changeset> openChangesets = task.getChangesets(); 52 protected void onPostDownloadOpenChangesets() { 53 List<Changeset> openChangesets = ChangesetCache.getInstance().getOpenChangesets(); 55 54 if (openChangesets.isEmpty()) { 56 55 JOptionPane.showMessageDialog( … … 105 104 ExceptionDialogUtil.explainException(lastException); 106 105 } 107 onPostDownloadOpenChangesets(DownloadOpenChangesetsTask.this); 106 ChangesetCache.getInstance().update(changesets); 107 if (!cancelled && lastException == null) { 108 onPostDownloadOpenChangesets(); 109 } 108 110 } 109 111 } … … 146 148 } 147 149 148 public List<Changeset> getChangesets() {149 return changesets;150 }151 152 150 public Exception getLastException() { 153 151 return lastException; -
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r2604 r2613 7 7 import java.util.Map; 8 8 9 import org.openstreetmap.josm.data.Bounds; 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 import org.openstreetmap.josm.data.osm.visitor.Visitor; … … 68 69 setId(other.getId()); 69 70 this.incomplete = true; 71 this.tags = new HashMap<String, String>(); 70 72 } else { 71 cloneFrom(other); 73 this.id = other.id; 74 mergeFrom(other); 72 75 this.incomplete = false; 73 76 } 74 }75 76 public void cloneFrom(Changeset other) {77 setId(other.getId());78 setUser(other.getUser());79 setCreatedAt(other.getCreatedAt());80 setClosedAt(other.getClosedAt());81 setMin(other.getMin());82 setMax(other.getMax());83 setKeys(other.getKeys());84 setOpen(other.isOpen());85 77 } 86 78 … … 152 144 public LatLon getMax() { 153 145 return max; 146 } 147 148 public Bounds getBounds() { 149 if (min != null && max != null) 150 return new Bounds(min,max); 151 return null; 154 152 } 155 153 … … 237 235 if (id > 0) 238 236 return prime * result + getClass().hashCode(); 239 result = prime * result + ((closedAt == null) ? 0 : closedAt.hashCode()); 240 result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode()); 241 result = prime * result + ((max == null) ? 0 : max.hashCode()); 242 result = prime * result + ((min == null) ? 0 : min.hashCode()); 243 result = prime * result + (open ? 1231 : 1237); 244 result = prime * result + ((tags == null) ? 0 : tags.hashCode()); 245 result = prime * result + ((user == null) ? 0 : user.hashCode()); 246 return result; 237 else 238 return super.hashCode(); 247 239 } 248 240 … … 258 250 if (this.id > 0 && other.id == this.id) 259 251 return true; 260 if (closedAt == null) { 261 if (other.closedAt != null) 262 return false; 263 } else if (!closedAt.equals(other.closedAt)) 264 return false; 265 if (createdAt == null) { 266 if (other.createdAt != null) 267 return false; 268 } else if (!createdAt.equals(other.createdAt)) 269 return false; 270 if (id != other.id) 271 return false; 272 if (max == null) { 273 if (other.max != null) 274 return false; 275 } else if (!max.equals(other.max)) 276 return false; 277 if (min == null) { 278 if (other.min != null) 279 return false; 280 } else if (!min.equals(other.min)) 281 return false; 282 if (open != other.open) 283 return false; 284 if (tags == null) { 285 if (other.tags != null) 286 return false; 287 } else if (!tags.equals(other.tags)) 288 return false; 289 if (user == null) { 290 if (other.user != null) 291 return false; 292 } else if (!user.equals(other.user)) 293 return false; 294 return true; 252 return this == obj; 295 253 } 296 254 … … 318 276 this.min = other.min; 319 277 this.max = other.max; 320 this.tags .clear();321 this. tags.putAll(other.tags);278 this.tags = new HashMap<String, String>(other.tags); 279 this.incomplete = other.incomplete; 322 280 } 323 281 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2610 r2613 20 20 21 21 import org.openstreetmap.josm.data.SelectionChangedListener; 22 22 23 23 24 /** -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r2566 r2613 4 4 5 5 import java.awt.BorderLayout; 6 import java.awt.Component;7 6 import java.awt.Container; 8 7 import java.awt.Dimension; 8 import java.awt.event.MouseWheelEvent; 9 9 import java.awt.event.MouseWheelListener; 10 import java.awt.event.MouseWheelEvent;11 10 import java.util.ArrayList; 12 11 import java.util.List; … … 16 15 import javax.swing.BoxLayout; 17 16 import javax.swing.ButtonGroup; 17 import javax.swing.JPanel; 18 18 import javax.swing.JSplitPane; 19 import javax.swing.JPanel;20 19 import javax.swing.JToolBar; 21 20 import javax.swing.border.Border; 21 import javax.swing.plaf.basic.BasicSplitPaneDivider; 22 22 import javax.swing.plaf.basic.BasicSplitPaneUI; 23 import javax.swing.plaf.basic.BasicSplitPaneDivider;24 23 25 24 import org.openstreetmap.josm.Main; … … 30 29 import org.openstreetmap.josm.actions.mapmode.SelectAction; 31 30 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 31 import org.openstreetmap.josm.gui.dialogs.ChangesetDialog; 32 32 import org.openstreetmap.josm.gui.dialogs.CommandStackDialog; 33 33 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; … … 126 126 splitPane.setBorder(null); 127 127 splitPane.setUI(new BasicSplitPaneUI() { 128 @Override 128 129 public BasicSplitPaneDivider createDefaultDivider() { 129 130 return new BasicSplitPaneDivider(this) { 131 @Override 130 132 public void setBorder(Border b) { 131 133 } … … 148 150 addToggleDialog(new HistoryDialog()); 149 151 addToggleDialog(new SelectionListDialog()); 150 if(Main.pref.getBoolean("displayfilter", false)) 152 if(Main.pref.getBoolean("displayfilter", false)) { 151 153 addToggleDialog(new FilterDialog()); 154 } 152 155 addToggleDialog(new UserListDialog()); 153 156 addToggleDialog(conflictDialog = new ConflictDialog()); 154 157 addToggleDialog(new CommandStackDialog(this)); 155 158 addToggleDialog(relationListDialog = new RelationListDialog()); 159 addToggleDialog(new ChangesetDialog(this)); 156 160 157 161 // status line below the map … … 209 213 public void initializeDialogsPane() { 210 214 dialogsPanel.initialize(allDialogs); 215 } 216 217 /** 218 * 219 */ 220 public void tearDownDialogsPane() { 221 dialogsPanel.tearDown(); 211 222 } 212 223 -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r2512 r2613 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 4 import java.awt.EventQueue; 7 import java.io.FileNotFoundException;8 5 import java.io.IOException; 6 import java.util.logging.Logger; 9 7 10 8 import javax.swing.SwingUtilities; … … 23 21 */ 24 22 public abstract class PleaseWaitRunnable implements Runnable, CancelListener { 23 private final static Logger logger = Logger.getLogger(PleaseWaitRunnable.class.getName()); 25 24 26 25 private boolean cancelled = false; -
trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
r2566 r2613 33 33 34 34 public boolean initialized = false; // read only from outside 35 35 36 36 public void initialize(List<ToggleDialog> pAllDialogs) { 37 37 if (initialized) … … 43 43 add(pAllDialogs.get(i), false); 44 44 } 45 45 46 46 this.add(mSpltPane); 47 47 reconstruct(Action.ELEMENT_SHRINKS, null); 48 48 } 49 49 50 /** 51 * Invoke before the panel is discarded. This will in turn call {@see ToggleDialog#tearDown()} 52 * on every dialog. 53 * 54 */ 55 public void tearDown() { 56 for(ToggleDialog dialog: allDialogs) { 57 dialog.tearDown(); 58 } 59 } 60 50 61 public void add(ToggleDialog dlg) { 51 62 add(dlg, true); 52 63 } 53 64 54 65 public void add(ToggleDialog dlg, boolean doReconstruct) { 55 66 allDialogs.add(dlg); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r2602 r2613 68 68 */ 69 69 protected boolean isCollapsed; 70 70 71 71 /** the preferred height if the toggle dialog is expanded */ 72 72 private int preferredHeight; … … 120 120 isDocked = Main.pref.getBoolean(preferencePrefix+".docked", true); 121 121 isCollapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false); 122 //System.err.println(name+": showing="+isShowing+" docked="+isDocked+" collapsed="+isCollapsed);123 122 } 124 123 … … 214 213 */ 215 214 public void collapse() { 216 // if (isShowing && isDocked && !isCollapsed) {215 // if (isShowing && isDocked && !isCollapsed) { 217 216 if (isDialogInDefaultView()) { 218 217 setContentVisible(false); … … 231 230 */ 232 231 protected void expand() { 233 // if (isShowing && isDocked && isCollapsed) {232 // if (isShowing && isDocked && isCollapsed) { 234 233 if (isDialogInCollapsedView()) { 235 234 setContentVisible(true); … … 529 528 530 529 /** 531 * Change the Geometry of the detached dialog to better fit the content.532 */530 * Change the Geometry of the detached dialog to better fit the content. 531 */ 533 532 protected Rectangle getDetachedGeometry(Rectangle last) { 534 533 return last; … … 552 551 return true; 553 552 } 554 553 555 554 /** 556 555 * primitive stateChangedListener for subclasses … … 559 558 } 560 559 561 /*** 562 * End of override hooks 563 **/ 560 /** 561 * This method is called by hosting panel before the panel with the toggle dialogs 562 * and the toggle dialogs themself are discared, for instance because no layer is 563 * left in JOSM and the main screen turns from the map editor to the MOTD panel. 564 * 565 * Override in subclasses to unregister as listener. After tearDown() is invoked 566 * the dialog should be registered as listener. 567 * 568 * The default implementation is empty. 569 */ 570 public void tearDown() {} 564 571 } -
trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java
r2599 r2613 26 26 import org.openstreetmap.josm.Main; 27 27 import org.openstreetmap.josm.data.osm.Changeset; 28 import org.openstreetmap.josm.data.osm.ChangesetCache; 28 29 import org.openstreetmap.josm.gui.JMultilineLabel; 29 30 import org.openstreetmap.josm.tools.ImageProvider; … … 104 105 gc.weightx = 1.0; 105 106 model = new OpenChangesetComboBoxModel(); 107 ChangesetCache.getInstance().addChangesetCacheListener(model); 106 108 cbOpenChangesets = new JComboBox(model); 107 109 cbOpenChangesets.setToolTipText("Select an open changeset"); … … 171 173 } 172 174 175 public void setSelectedChangesetForNextUpload(Changeset cs) { 176 int idx = model.getIndexOf(cs); 177 if (idx >=0) { 178 rbExisting.setSelected(true); 179 model.setSelectedItem(cs); 180 } 181 } 182 173 183 /** 174 184 * Replies the currently selected changeset. null, if no changeset is … … 203 213 } 204 214 205 public void updateListOfChangesetsAfterUploadOperation(Changeset cs) {206 if (cs == null || cs.isNew()) {207 model.setSelectedItem(null);208 } else if (cs.isOpen()){209 if (cs.get("created_by") == null) {210 cs.put("created_by", getDefaultCreatedBy());211 }212 model.addOrUpdate(cs);213 cs = model.getChangesetById(cs.getId());214 model.setSelectedItem(cs);215 rbExisting.setSelected(true);216 } else if (!cs.isOpen()){217 removeChangeset(cs);218 rbUseNew.setSelected(true);219 }220 }221 222 /**223 * Remove a changeset from the list of open changeset224 *225 * @param cs the changeset to be removed. Ignored if null.226 */227 public void removeChangeset(Changeset cs) {228 if (cs == null) return;229 model.removeChangeset(cs);230 refreshGUI();231 }232 233 215 /* ---------------------------------------------------------------------------- */ 234 216 /* Interface ListDataListener */ … … 256 238 if (rbExisting.isSelected()) { 257 239 firePropertyChange(SELECTED_CHANGESET_PROP, null, cs); 240 if (cs == null) { 241 rbUseNew.setSelected(true); 242 } 258 243 } 259 244 } -
trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java
r2512 r2613 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.BorderLayout; … … 6 8 import java.awt.FlowLayout; 7 9 import java.awt.event.ActionEvent; 10 import java.awt.event.KeyEvent; 11 import java.awt.event.WindowAdapter; 12 import java.awt.event.WindowEvent; 8 13 import java.util.ArrayList; 9 14 import java.util.Collection; … … 12 17 import javax.swing.BorderFactory; 13 18 import javax.swing.DefaultListModel; 19 import javax.swing.JComponent; 14 20 import javax.swing.JDialog; 15 21 import javax.swing.JLabel; … … 18 24 import javax.swing.JPanel; 19 25 import javax.swing.JScrollPane; 26 import javax.swing.KeyStroke; 20 27 import javax.swing.event.ListSelectionEvent; 21 28 import javax.swing.event.ListSelectionListener; … … 26 33 import org.openstreetmap.josm.tools.ImageProvider; 27 34 import org.openstreetmap.josm.tools.WindowGeometry; 28 29 import static org.openstreetmap.josm.tools.I18n.tr;30 35 31 36 /** … … 41 46 /** the list model */ 42 47 private DefaultListModel model; 48 49 private SideButton btnCloseChangesets; 43 50 44 51 protected JPanel buildTopPanel() { … … 66 73 CloseAction closeAction = new CloseAction(); 67 74 lstOpenChangesets.addListSelectionListener(closeAction); 68 pnl.add(new SideButton(closeAction)); 69 pnl.add(new SideButton(new CancelAction())); 75 pnl.add(btnCloseChangesets = new SideButton(closeAction)); 76 btnCloseChangesets.setFocusable(true); 77 btnCloseChangesets.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 78 btnCloseChangesets.getActionMap().put("enter",closeAction); 79 80 // -- cancel action 81 SideButton btn; 82 pnl.add(btn = new SideButton(new CancelAction())); 83 btn.setFocusable(true); 70 84 return pnl; 71 85 } … … 77 91 getContentPane().add(buildCenterPanel(), BorderLayout.CENTER); 78 92 getContentPane().add(buildSouthPanel(), BorderLayout.SOUTH); 93 94 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "escape"); 95 getRootPane().getActionMap().put("escape", new CancelAction()); 96 addWindowListener(new WindowEventHandler()); 79 97 } 80 98 … … 127 145 } 128 146 129 public void actionPerformed(ActionEvent e) {147 public void cancel() { 130 148 setCanceled(true); 131 149 setVisible(false); 132 150 } 151 152 public void actionPerformed(ActionEvent e) { 153 cancel(); 154 } 155 } 156 157 class WindowEventHandler extends WindowAdapter { 158 159 @Override 160 public void windowActivated(WindowEvent arg0) { 161 btnCloseChangesets.requestFocusInWindow(); 162 } 163 164 @Override 165 public void windowClosing(WindowEvent arg0) { 166 new CancelAction().cancel(); 167 } 168 133 169 } 134 170 … … 162 198 for (Changeset cs: changesets) { 163 199 model.addElement(cs); 200 } 201 if (!changesets.isEmpty()) { 202 lstOpenChangesets.getSelectionModel().setSelectionInterval(0, changesets.size()-1); 164 203 } 165 204 } -
trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java
r2599 r2613 11 11 12 12 import org.openstreetmap.josm.data.osm.Changeset; 13 import org.openstreetmap.josm.data.osm.ChangesetCache; 13 14 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 14 15 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 59 60 new Runnable() { 60 61 public void run() { 61 for (Changeset cs: closedChangesets) { 62 UploadDialog.getUploadDialog().updateListOfChangesetsAfterUploadOperation(cs); 63 } 62 ChangesetCache.getInstance().update(closedChangesets); 64 63 } 65 64 } -
trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java
r2599 r2613 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.data.osm.Changeset; 14 import org.openstreetmap.josm.data.osm.ChangesetCache; 14 15 import org.openstreetmap.josm.data.osm.UserInfo; 15 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; … … 70 71 new Runnable() { 71 72 public void run() { 72 model.setChangesets(changesets);73 ChangesetCache.getInstance().update(changesets); 73 74 } 74 75 } -
trunk/src/org/openstreetmap/josm/gui/io/OpenChangesetComboBoxModel.java
r2599 r2613 2 2 package org.openstreetmap.josm.gui.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 4 import java.util.ArrayList; 7 import java.util.Collection;8 5 import java.util.List; 9 6 … … 11 8 12 9 import org.openstreetmap.josm.data.osm.Changeset; 10 import org.openstreetmap.josm.data.osm.ChangesetCache; 11 import org.openstreetmap.josm.data.osm.ChangesetCacheEvent; 12 import org.openstreetmap.josm.data.osm.ChangesetCacheListener; 13 13 14 14 /** … … 16 16 * 17 17 */ 18 public class OpenChangesetComboBoxModel extends DefaultComboBoxModel {18 public class OpenChangesetComboBoxModel extends DefaultComboBoxModel implements ChangesetCacheListener { 19 19 private List<Changeset> changesets; 20 20 private long uid; … … 32 32 } 33 33 34 protected void internalAddOrUpdate(Changeset cs) { 35 Changeset other = getChangesetById(cs.getId()); 36 if (other != null) { 37 cs.cloneFrom(other); 34 public void refresh() { 35 changesets.clear(); 36 changesets.addAll(ChangesetCache.getInstance().getOpenChangesets()); 37 fireContentsChanged(this, 0, getSize()); 38 int idx = changesets.indexOf(selectedChangeset); 39 if (idx < 0) { 40 setSelectedItem(null); 38 41 } else { 39 changesets.add(cs); 40 } 41 } 42 43 public void addOrUpdate(Changeset cs) { 44 if (cs.getId() <= 0 ) 45 throw new IllegalArgumentException(tr("Changeset ID > 0 expected. Got {0}.", cs.getId())); 46 internalAddOrUpdate(cs); 47 fireContentsChanged(this, 0, getSize()); 48 } 49 50 public void remove(long id) { 51 Changeset cs = getChangesetById(id); 52 if (cs != null) { 53 changesets.remove(cs); 54 } 55 fireContentsChanged(this, 0, getSize()); 56 } 57 58 public void setChangesets(Collection<Changeset> changesets) { 59 this.changesets.clear(); 60 if (changesets != null) { 61 for (Changeset cs: changesets) { 62 internalAddOrUpdate(cs); 63 } 64 } 65 fireContentsChanged(this, 0, getSize()); 66 if (getSelectedItem() == null && !this.changesets.isEmpty()) { 67 setSelectedItem(this.changesets.get(0)); 68 } else if (getSelectedItem() != null) { 69 if (changesets.contains(getSelectedItem())) { 70 setSelectedItem(getSelectedItem()); 71 } else if (!this.changesets.isEmpty()){ 72 setSelectedItem(this.changesets.get(0)); 73 } else { 74 setSelectedItem(null); 75 } 76 } else { 77 setSelectedItem(null); 42 setSelectedItem(changesets.get(idx)); 78 43 } 79 44 } … … 95 60 } 96 61 97 public void removeChangeset(Changeset cs) { 98 if (cs == null) return; 99 changesets.remove(cs); 100 if (selectedChangeset == cs) { 101 selectFirstChangeset(); 102 } 103 fireContentsChanged(this, 0, getSize()); 62 /* ------------------------------------------------------------------------------------ */ 63 /* ChangesetCacheListener */ 64 /* ------------------------------------------------------------------------------------ */ 65 public void changesetCacheUpdated(ChangesetCacheEvent event) { 66 refresh(); 104 67 } 68 105 69 /* ------------------------------------------------------------------------------------ */ 106 70 /* ComboBoxModel */ -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2599 r2613 289 289 } 290 290 291 public void setSelectedChangesetForNextUpload(Changeset cs) { 292 pnlChangesetManagement.setSelectedChangesetForNextUpload(cs); 293 } 294 291 295 /** 292 296 * Replies the {@see UploadStrategySpecification} the user entered in the dialog. … … 298 302 spec.setCloseChangesetAfterUpload(pnlChangesetManagement.isCloseChangesetAfterUpload()); 299 303 return spec; 300 }301 302 /**303 * Sets or updates the changeset cs.304 * If cs is null, does nothing.305 * If cs.getId() == 0 does nothing.306 * If cs.getId() > 0 and cs is open, adds it to the list of open307 * changesets. If it is closed, removes it from the list of open308 * changesets.309 *310 * @param cs the changeset311 */312 public void updateListOfChangesetsAfterUploadOperation(Changeset cs) {313 pnlChangesetManagement.updateListOfChangesetsAfterUploadOperation(cs);314 }315 316 /**317 * Removes <code>cs</code> from the list of open changesets in the upload318 * dialog319 *320 * @param cs the changeset. Ignored if null.321 */322 public void removeChangeset(Changeset cs) {323 if (cs == null) return;324 pnlChangesetManagement.removeChangeset(cs);325 304 } 326 305 -
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r2599 r2613 18 18 import org.openstreetmap.josm.data.APIDataSet; 19 19 import org.openstreetmap.josm.data.osm.Changeset; 20 import org.openstreetmap.josm.data.osm.ChangesetCache; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 22 import org.openstreetmap.josm.gui.DefaultNameFormatter; … … 139 140 // make sure the current changeset is removed from the upload dialog. 140 141 // 141 UploadDialog.getUploadDialog().removeChangeset(changeset);142 ChangesetCache.getInstance().update(changeset); 142 143 Changeset newChangeSet = new Changeset(); 143 144 newChangeSet.setKeys(this.changeset.getKeys()); … … 211 212 layer.fireDataChange(); 212 213 layer.onPostUploadToServer(); 213 214 // make sure the upload dialog lists all known open changesets 215 // 216 if (lastException != null && lastException instanceof ChangesetClosedException) { 217 UploadDialog.getUploadDialog().removeChangeset(changeset); 218 } else { 219 UploadDialog.getUploadDialog().updateListOfChangesetsAfterUploadOperation(changeset); 220 } 214 ChangesetCache.getInstance().update(changeset); 221 215 } 222 216 }; … … 298 292 if (uploadCancelled) 299 293 return; 300 if (lastException == null)301 return;302 294 303 295 // depending on the success of the upload operation and on the policy for … … 309 301 Runnable r = new Runnable() { 310 302 public void run() { 303 // if the changeset is still open after this upload we want it to 304 // be selected on the next upload 305 // 306 ChangesetCache.getInstance().update(changeset); 307 if (changeset != null && changeset.isOpen()) { 308 UploadDialog.getUploadDialog().setSelectedChangesetForNextUpload(changeset); 309 } 310 if (lastException == null) 311 return; 311 312 if (lastException instanceof ChangesetClosedException) { 312 313 ChangesetClosedException e = (ChangesetClosedException)lastException; … … 337 338 } 338 339 }; 339 SwingUtilities.invokeLater(r); 340 if (SwingUtilities.isEventDispatchThread()) { 341 r.run(); 342 } else { 343 SwingUtilities.invokeLater(r); 344 } 340 345 } 341 346 -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r2512 r2613 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 4 7 import java.io.InputStream; 8 import java.util.ArrayList; 9 import java.util.Collection; 10 import java.util.Collections; 11 import java.util.Iterator; 5 12 import java.util.List; 6 13 … … 9 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 10 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 11 import static org.openstreetmap.josm.tools.I18n.tr;12 18 13 19 /** … … 68 74 69 75 /** 70 * Reads t ehchangeset with id <code>id</code> from the server76 * Reads the changeset with id <code>id</code> from the server 71 77 * 72 78 * @param id the changeset id. id > 0 required. … … 104 110 105 111 /** 112 * Reads the changeset with id <code>id</code> from the server 113 * 114 * @param ids the list of ids. Ignored if null. Only load changesets for ids > 0. 115 * @param monitor the progress monitor. Set to {@see NullProgressMonitor#INSTANCE} if null 116 * @return the changeset read 117 * @throws OsmTransferException thrown if something goes wrong 118 * @throws IllegalArgumentException if id <= 0 119 */ 120 public List<Changeset> readChangesets(Collection<Integer> ids, ProgressMonitor monitor) throws OsmTransferException { 121 if (ids == null) 122 return Collections.emptyList(); 123 if (monitor == null) { 124 monitor = NullProgressMonitor.INSTANCE; 125 } 126 try { 127 monitor.beginTask(trn("Downloading {0} changeset ...", "Downloading {0} changesets ...",ids.size(),ids.size())); 128 monitor.setTicksCount(ids.size()); 129 List<Changeset> ret = new ArrayList<Changeset>(); 130 int i=0; 131 for (Iterator<Integer> it = ids.iterator(); it.hasNext(); ) { 132 int id = it.next(); 133 if (id <= 0) { 134 continue; 135 } 136 i++; 137 StringBuffer sb = new StringBuffer(); 138 sb.append("changeset/").append(id); 139 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); 140 if (in == null) 141 return null; 142 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {0} ...", i,ids.size(), id)); 143 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 144 if (changesets == null || changesets.isEmpty()) { 145 continue; 146 } 147 ret.addAll(changesets); 148 monitor.worked(1); 149 } 150 return ret; 151 } catch(OsmTransferException e) { 152 throw e; 153 } catch(IllegalDataException e) { 154 throw new OsmTransferException(e); 155 } finally { 156 monitor.finishTask(); 157 } 158 } 159 160 /** 106 161 * not implemented yet 107 162 *
Note:
See TracChangeset
for help on using the changeset viewer.