Changeset 2569 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2009-12-04T15:53:55+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r2512 r2569 15 15 import java.util.HashMap; 16 16 import java.util.Observable; 17 import java.util.logging.Logger;18 17 19 18 import javax.swing.AbstractListModel; … … 120 119 return entries.get(MERGED_ENTRIES); 121 120 } 121 122 122 protected ArrayList<T> getMyEntries() { 123 123 return entries.get(MY_ENTRIES); 124 124 } 125 125 126 protected ArrayList<T> getTheirEntries() { 126 127 return entries.get(THEIR_ENTRIES); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r2512 r2569 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 6 7 import java.util.logging.Logger; 7 8 … … 16 17 * The model for merging two lists of relation members 17 18 * 18 *19 19 */ 20 20 public class RelationMemberListMergeModel extends ListMergeModel<RelationMember>{ … … 24 24 @Override 25 25 public boolean isEqualEntry(RelationMember e1, RelationMember e2) { 26 boolean ret = e1.getRole().equals(e2.getRole()); 27 if (!e1.getMember().isNew() ) { 28 ret = ret && (e1.getMember().getId() == e2.getMember().getId()); 29 } else { 30 ret = ret && (e1 == e2); 31 } 32 return ret; 26 return e1.equals(e2); 33 27 } 34 28 … … 119 113 if (! isFrozen()) 120 114 throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Can't build resolution command")); 121 return new RelationMemberConflictResolverCommand(my, their, getMergedEntries()); 115 ArrayList<RelationMember> entries = getMergedEntries(); 116 return new RelationMemberConflictResolverCommand(my, their, entries); 122 117 } 123 118 } -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r2512 r2569 298 298 public void cancel() { 299 299 switch(model.getMode()) { 300 301 300 case EDITING_DATA: cancelWhenInEditingModel(); break; 301 case UPLOADING_AND_SAVING: cancelSafeAndUploadTask(); break; 302 302 } 303 303 } … … 333 333 Mode mode = (Mode)evt.getNewValue(); 334 334 switch(mode) { 335 336 335 case EDITING_DATA: setEnabled(true); break; 336 case UPLOADING_AND_SAVING: setEnabled(false); break; 337 337 } 338 338 } … … 367 367 SaveLayersModel.Mode mode = (SaveLayersModel.Mode)evt.getNewValue(); 368 368 switch(mode) { 369 370 369 case EDITING_DATA: setEnabled(true); break; 370 case UPLOADING_AND_SAVING: setEnabled(false); break; 371 371 } 372 372 } … … 408 408 409 409 currentTask = new UploadLayerTask( 410 UploadDialog.getUploadDialog().getUploadStrategySpecification(), 410 411 layerInfo.getLayer(), 411 412 monitor, -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2512 r2569 2 2 package org.openstreetmap.josm.gui.io; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 50 51 import org.openstreetmap.josm.data.osm.Changeset; 51 52 import org.openstreetmap.josm.data.osm.OsmPrimitive; 53 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 52 54 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 53 55 import org.openstreetmap.josm.gui.SideButton; … … 58 60 import org.openstreetmap.josm.gui.tagging.TagModel; 59 61 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 60 import org.openstreetmap.josm.io.OsmApi;61 62 import org.openstreetmap.josm.tools.GBC; 62 63 import org.openstreetmap.josm.tools.ImageProvider; … … 192 193 JComponent.WHEN_IN_FOCUSED_WINDOW 193 194 ); 194 pnl.add(new SideButton(new ContextSensitiveHelpAction( "/Dialogs/UploadDialog")));195 HelpUtil.setHelpContext(getRootPane(), "/Dialogs/UploadDialog");195 pnl.add(new SideButton(new ContextSensitiveHelpAction(ht("/Dialogs/UploadDialog")))); 196 HelpUtil.setHelpContext(getRootPane(),ht("/Dialogs/UploadDialog")); 196 197 return pnl; 197 198 } … … 293 294 pnlLists.add(spDelete, gcList); 294 295 } 296 pnlChangesetSelection.setNumUploadedObjects(add.size() + update.size() + delete.size()); 295 297 } 296 298 … … 320 322 cs.put("comment", getUploadComment()); 321 323 return cs; 324 } 325 326 /** 327 * Replies the {@see UploadStrategySpecification} the user entered in the dialog. 328 * 329 * @return the {@see UploadStrategySpecification} the user entered in the dialog. 330 */ 331 public UploadStrategySpecification getUploadStrategySpecification() { 332 return pnlChangesetSelection.getUploadStrategySpecification(); 322 333 } 323 334 … … 487 498 488 499 protected void warnIllegalUploadComment() { 489 JOptionPane.showMessageDialog(500 HelpAwareOptionPane.showOptionDialog( 490 501 UploadDialog.this, 491 502 tr("Please enter a comment for this upload changeset (min. 3 characters)"), 492 503 tr("Illegal upload comment"), 493 JOptionPane.ERROR_MESSAGE 504 JOptionPane.ERROR_MESSAGE, 505 ht("/Dialog/UploadDialog#IllegalUploadComment") 494 506 495 507 ); 496 508 } 509 510 protected void warnIllegalChunkSize() { 511 HelpAwareOptionPane.showOptionDialog( 512 UploadDialog.this, 513 tr("Please enter a valid chunk size first"), 514 tr("Illegal chunk size"), 515 JOptionPane.ERROR_MESSAGE, 516 ht("/Dialog/UploadDialog#IllegalChunkSize") 517 ); 518 } 519 520 497 521 public void actionPerformed(ActionEvent e) { 498 522 if (getUploadComment().trim().length() < 3) { … … 502 526 return; 503 527 } 528 UploadStrategySpecification strategy = getUploadStrategySpecification(); 529 if (strategy.getStrategy().equals(UploadStrategy.CHUNKED_DATASET_STRATEGY)) { 530 if (strategy.getChunkSize() == UploadStrategySpecification.UNSPECIFIED_CHUNK_SIZE) { 531 warnIllegalChunkSize(); 532 southTabbedPane.setSelectedIndex(0); 533 pnlChangesetSelection.initEditingOfChunkSize(); 534 return; 535 } 536 } 504 537 setCanceled(false); 505 538 setVisible(false); 506 507 539 } 508 540 } … … 607 639 private OpenChangesetModel model; 608 640 private HistoryComboBox cmt; 609 private JCheckBox cbUseAtomicUpload;641 private UploadStrategySelectionPanel pnlUploadStrategy; 610 642 611 643 /** … … 615 647 * @return the panel 616 648 */ 617 protected JPanel buildAtomicUploadControlPanel() { 618 JPanel pnl = new JPanel(); 619 pnl.setLayout(new GridBagLayout()); 620 GridBagConstraints gc = new GridBagConstraints(); 621 gc.fill = GridBagConstraints.HORIZONTAL; 622 gc.weightx = 1.0; 623 gc.anchor = GridBagConstraints.FIRST_LINE_START; 624 pnl.add(cbUseAtomicUpload = new JCheckBox(tr("Upload all changes in one request")), gc); 625 cbUseAtomicUpload.setToolTipText(tr("Enable to upload all changes in one request, disable to use one request per changed primitive")); 626 boolean useAtomicUpload = Main.pref.getBoolean("osm-server.atomic-upload", true); 627 cbUseAtomicUpload.setSelected(useAtomicUpload); 628 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasSupportForDiffUploads()); 629 return pnl; 649 protected JPanel buildUploadStrategySelectionPanel() { 650 pnlUploadStrategy = new UploadStrategySelectionPanel(); 651 pnlUploadStrategy.initFromPreferences(); 652 return pnlUploadStrategy; 630 653 } 631 654 … … 678 701 gc.weightx = 1.0; 679 702 gc.anchor = GridBagConstraints.FIRST_LINE_START; 680 add(build AtomicUploadControlPanel(), gc);703 add(buildUploadStrategySelectionPanel(), gc); 681 704 682 705 // -- changeset command … … 764 787 cmt.addCurrentItemToHistory(); 765 788 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory()); 766 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected());789 pnlUploadStrategy.saveToPreferences(); 767 790 } 768 791 … … 819 842 } 820 843 844 public void initEditingOfChunkSize() { 845 pnlUploadStrategy.initEditingOfChunkSize(); 846 } 847 821 848 protected void refreshGUI() { 822 849 rbExisting.setEnabled(model.getSize() > 0); … … 848 875 return new Changeset(); 849 876 return cs; 877 } 878 879 /** 880 * Replies the {@see UploadStrategySpecification} the user entered in the dialog. 881 * 882 * @return the {@see UploadStrategySpecification} the user entered in the dialog. 883 */ 884 public UploadStrategySpecification getUploadStrategySpecification() { 885 return pnlUploadStrategy.getUploadStrategySpecification(); 850 886 } 851 887 … … 932 968 public boolean isCloseAfterUpload() { 933 969 return cbCloseAfterUpload.isSelected(); 970 } 971 972 public void setNumUploadedObjects(int numUploadedObjects) { 973 pnlUploadStrategy.setNumUploadedObjects(numUploadedObjects); 934 974 } 935 975 -
trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java
r2512 r2569 44 44 private Collection<OsmPrimitive> toUpload; 45 45 private HashSet<OsmPrimitive> processedPrimitives; 46 private UploadStrategySpecification strategy; 46 47 47 48 /** 48 * 49 * Creates the upload task 50 * 51 * @param strategy the upload strategy specification 49 52 * @param layer the layer. Must not be null. 50 53 * @param monitor a progress monitor. If monitor is null, uses {@see NullProgressMonitor#INSTANCE} … … 52 55 * @param closeChangesetAfterUpload true, if the changeset should be closed after the upload 53 56 * @throws IllegalArgumentException thrown, if layer is null 57 * @throws IllegalArgumentException thrown if strategy is null 54 58 */ 55 public UploadLayerTask( OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset, boolean closeChangesetAfterUpload) {59 public UploadLayerTask(UploadStrategySpecification strategy, OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset, boolean closeChangesetAfterUpload) { 56 60 if (layer == null) 57 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", layer)); 61 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "layer")); 62 if (strategy == null) 63 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "strategy")); 58 64 if (monitor == null) { 59 65 monitor = NullProgressMonitor.INSTANCE; … … 62 68 this.monitor = monitor; 63 69 this.changeset = changeset; 70 this.strategy = strategy; 64 71 this.closeChangesetAfterUpload = closeChangesetAfterUpload; 65 72 processedPrimitives = new HashSet<OsmPrimitive>(); … … 103 110 @Override 104 111 public void run() { 105 monitor. subTask(tr("Preparing primitives to upload ..."));112 monitor.indeterminateSubTask(tr("Preparing primitives to upload ...")); 106 113 APIDataSet ds = new APIDataSet(layer.data); 107 114 try { … … 120 127 ProgressMonitor m = monitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 121 128 if (isCancelled()) return; 122 writer.uploadOsm( layer.data.getVersion(), toUpload, changeset, m);129 writer.uploadOsm(strategy, toUpload, changeset, m); 123 130 processedPrimitives.addAll(writer.getProcessedPrimitives()); 124 131 break;
Note:
See TracChangeset
for help on using the changeset viewer.