Changeset 2040 in josm
- Timestamp:
- 2009-09-03T18:51:04+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 7 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2037 r2040 6 6 import java.awt.BorderLayout; 7 7 import java.awt.Dimension; 8 import java.awt.FlowLayout;9 8 import java.awt.GridBagConstraints; 10 9 import java.awt.GridBagLayout; … … 20 19 import java.util.regex.Pattern; 21 20 21 import javax.swing.BoxLayout; 22 import javax.swing.ButtonGroup; 22 23 import javax.swing.JCheckBox; 23 24 import javax.swing.JLabel; … … 25 26 import javax.swing.JOptionPane; 26 27 import javax.swing.JPanel; 28 import javax.swing.JRadioButton; 27 29 import javax.swing.JScrollPane; 30 import javax.swing.JTabbedPane; 28 31 29 32 import org.openstreetmap.josm.Main; 30 33 import org.openstreetmap.josm.data.APIDataSet; 31 34 import org.openstreetmap.josm.data.conflict.ConflictCollection; 35 import org.openstreetmap.josm.data.osm.Changeset; 32 36 import org.openstreetmap.josm.data.osm.DataSet; 33 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 39 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 40 44 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 45 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 46 import org.openstreetmap.josm.io.ChangesetProcessingType; 41 47 import org.openstreetmap.josm.io.OsmApi; 42 48 import org.openstreetmap.josm.io.OsmApiException; … … 164 170 if (!checkPreUploadConditions(Main.map.mapView.getEditLayer(), apiData)) 165 171 return; 166 Main.worker.execute(createUploadTask(Main.map.mapView.getEditLayer(), apiData.getPrimitives())); 172 Main.worker.execute( 173 createUploadTask( 174 Main.map.mapView.getEditLayer(), 175 apiData.getPrimitives(), 176 UploadConfirmationHook.getUploadDialogPanel().getChangeset(), 177 UploadConfirmationHook.getUploadDialogPanel().getChangesetProcessingType() 178 ) 179 ); 167 180 } 168 181 … … 439 452 440 453 441 class UploadConfirmationHook implements UploadHook { 442 454 static public class UploadConfirmationHook implements UploadHook { 455 static private UploadDialogPanel uploadDialogPanel; 456 457 static public UploadDialogPanel getUploadDialogPanel() { 458 if (uploadDialogPanel == null) { 459 uploadDialogPanel = new UploadDialogPanel(); 460 } 461 return uploadDialogPanel; 462 } 443 463 444 464 public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 445 final UploadDialogPanel panel = new UploadDialogPanel(add, update, delete); 465 final UploadDialogPanel panel = getUploadDialogPanel(); 466 panel.setUploadedPrimitives(add, update, delete); 446 467 447 468 ExtendedDialog dialog = new ExtendedDialog( … … 483 504 } 484 505 485 public UploadDiffTask createUploadTask(OsmDataLayer layer, Collection<OsmPrimitive> toUpload ) {486 return new UploadDiffTask(layer, toUpload );506 public UploadDiffTask createUploadTask(OsmDataLayer layer, Collection<OsmPrimitive> toUpload, Changeset changeset, ChangesetProcessingType changesetProcessingType) { 507 return new UploadDiffTask(layer, toUpload, changeset, changesetProcessingType); 487 508 } 488 509 … … 493 514 private OsmServerWriter writer; 494 515 private OsmDataLayer layer; 495 496 private UploadDiffTask(OsmDataLayer layer, Collection <OsmPrimitive> toUpload) { 516 private Changeset changeset; 517 private ChangesetProcessingType changesetProcessingType; 518 519 private UploadDiffTask(OsmDataLayer layer, Collection <OsmPrimitive> toUpload, Changeset changeset, ChangesetProcessingType changesetProcessingType) { 497 520 super(tr("Uploading data for layer ''{0}''", layer.getName()),false /* don't ignore exceptions */); 498 521 this.toUpload = toUpload; 499 522 this.layer = layer; 523 this.changeset = changeset; 524 this.changesetProcessingType = changesetProcessingType == null ? ChangesetProcessingType.USE_NEW_AND_CLOSE : changesetProcessingType; 500 525 } 501 526 … … 504 529 try { 505 530 ProgressMonitor monitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 506 writer.uploadOsm(layer.data.version, toUpload, monitor);531 writer.uploadOsm(layer.data.version, toUpload, changeset,changesetProcessingType, monitor); 507 532 } catch (Exception sxe) { 508 533 if (uploadCancelled) { … … 554 579 * The panel displaying information about primitives to upload and providing 555 580 * UI widgets for entering the changeset comment and other configuration 556 * sett tings.581 * settings. 557 582 * 558 583 */ 559 static p rivateclass UploadDialogPanel extends JPanel {584 static public class UploadDialogPanel extends JPanel { 560 585 561 586 private JList lstAdd; 562 587 private JList lstUpdate; 563 588 private JList lstDelete; 589 private JLabel lblAdd; 590 private JLabel lblUpdate; 591 private JLabel lblDelete; 564 592 private JCheckBox cbUseAtomicUpload; 565 593 private SuggestingJHistoryComboBox cmt; 566 567 protected int getNumLists() { 568 int ret = 0; 569 if (lstAdd.getModel().getSize() > 0) { 570 ret++; 571 } 572 if (lstUpdate.getModel().getSize() > 0) { 573 ret++; 574 } 575 if (lstDelete.getModel().getSize() > 0) { 576 ret++; 577 } 578 return ret; 579 } 594 private TagEditorPanel tagEditorPanel; 595 private JTabbedPane southTabbedPane; 596 private ButtonGroup bgChangesetHandlingOptions; 597 private JRadioButton rbUseNewAndClose; 598 private JRadioButton rbUseNewAndLeaveOpen; 599 private JRadioButton rbUseExistingAndClose; 600 private JRadioButton rbUseExistingAndLeaveOpen; 601 private ChangesetProcessingType changesetProcessingType; 580 602 581 603 protected JPanel buildListsPanel() { … … 592 614 gcList.fill = GridBagConstraints.BOTH; 593 615 gcList.weightx = 1.0; 594 gcList.weighty = 1.0 / getNumLists();616 gcList.weighty = 1.0; 595 617 gcList.anchor = GridBagConstraints.CENTER; 596 618 597 int y = -1; 598 599 if (lstAdd.getModel().getSize() >0) { 600 y++; 601 gcLabel.gridy = y; 602 pnl.add(new JLabel(tr("Objects to add:")), gcLabel); 603 y++; 604 gcList.gridy = y; 605 pnl.add(new JScrollPane(lstAdd), gcList); 606 } 607 if (lstUpdate.getModel().getSize() >0) { 608 y++; 609 gcLabel.gridy = y; 610 pnl.add(new JLabel(tr("Objects to modify:")), gcLabel); 611 y++; 612 gcList.gridy = y; 613 pnl.add(new JScrollPane(lstUpdate), gcList); 614 } 615 if (lstDelete.getModel().getSize() >0) { 616 y++; 617 gcLabel.gridy = y; 618 pnl.add(new JLabel(tr("Objects to delete:")), gcLabel); 619 y++; 620 gcList.gridy = y; 621 pnl.add(new JScrollPane(lstDelete), gcList); 622 } 619 gcLabel.gridy = 0; 620 pnl.add(lblAdd = new JLabel(tr("Objects to add:")), gcLabel); 621 622 gcList.gridy = 1; 623 pnl.add(new JScrollPane(lstAdd), gcList); 624 625 gcLabel.gridy = 2; 626 pnl.add(lblUpdate = new JLabel(tr("Objects to modify:")), gcLabel); 627 628 gcList.gridy = 3; 629 pnl.add(new JScrollPane(lstUpdate), gcList); 630 631 gcLabel.gridy = 4; 632 pnl.add(lblDelete = new JLabel(tr("Objects to delete:")), gcLabel); 633 634 gcList.gridy = 5; 635 pnl.add(new JScrollPane(lstDelete), gcList); 636 return pnl; 637 } 638 639 protected JPanel buildChangesetHandlingControlPanel() { 640 JPanel pnl = new JPanel(); 641 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 642 bgChangesetHandlingOptions = new ButtonGroup(); 643 644 rbUseNewAndClose = new JRadioButton(tr("Use a new changeset and close it")); 645 rbUseNewAndClose.setToolTipText(tr("Select to upload the data using a new changeset and to close the changeset after the upload")); 646 647 rbUseNewAndLeaveOpen = new JRadioButton(tr("Use a new changeset and leave it open")); 648 rbUseNewAndLeaveOpen.setToolTipText(tr("Select to upload the data using a new changeset and to leave the changeset open after the upload")); 649 650 rbUseExistingAndClose = new JRadioButton(); 651 rbUseExistingAndLeaveOpen = new JRadioButton(); 652 653 pnl.add(new JLabel(tr("Upload to a new or to an existing changeset?"))); 654 pnl.add(rbUseNewAndClose); 655 pnl.add(rbUseNewAndLeaveOpen); 656 pnl.add(rbUseExistingAndClose); 657 pnl.add(rbUseExistingAndLeaveOpen); 658 659 rbUseNewAndClose.setVisible(false); 660 rbUseNewAndLeaveOpen.setVisible(false); 661 rbUseExistingAndClose.setVisible(false); 662 rbUseExistingAndLeaveOpen.setVisible(false); 663 664 bgChangesetHandlingOptions.add(rbUseNewAndClose); 665 bgChangesetHandlingOptions.add(rbUseNewAndLeaveOpen); 666 bgChangesetHandlingOptions.add(rbUseExistingAndClose); 667 bgChangesetHandlingOptions.add(rbUseExistingAndLeaveOpen); 623 668 return pnl; 624 669 } … … 626 671 protected JPanel buildChangesetControlPanel() { 627 672 JPanel pnl = new JPanel(); 628 pnl.setLayout(new FlowLayout(FlowLayout.LEFT));673 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 629 674 pnl.add(cbUseAtomicUpload = new JCheckBox(tr("upload all changes in one request"))); 630 675 cbUseAtomicUpload.setToolTipText(tr("Enable to upload all changes in one request, disable to use one request per changed primitive")); 631 676 boolean useAtomicUpload = Main.pref.getBoolean("osm-server.atomic-upload", true); 632 677 cbUseAtomicUpload.setSelected(useAtomicUpload); 633 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasChangesetSupport()); 678 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasSupportForDiffUploads()); 679 680 pnl.add(buildChangesetHandlingControlPanel()); 634 681 return pnl; 635 682 } … … 651 698 652 699 protected void build() { 653 setLayout(new BorderLayout()); 654 add(buildListsPanel(), BorderLayout.CENTER); 655 add(buildUploadControlPanel(), BorderLayout.SOUTH); 656 } 657 658 public UploadDialogPanel(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 700 setLayout(new GridBagLayout()); 701 GridBagConstraints gc = new GridBagConstraints(); 702 gc.fill = GridBagConstraints.BOTH; 703 gc.weightx = 1.0; 704 gc.weighty = 1.0; 705 add(buildListsPanel(), gc); 706 707 southTabbedPane = new JTabbedPane(); 708 southTabbedPane.add(buildUploadControlPanel()); 709 tagEditorPanel = new TagEditorPanel(); 710 southTabbedPane.add(tagEditorPanel); 711 southTabbedPane.setTitleAt(0, tr("Settings")); 712 southTabbedPane.setTitleAt(1, tr("Changeset Tags")); 713 JPanel pnl = new JPanel(); 714 pnl.setLayout(new BorderLayout()); 715 pnl.add(southTabbedPane,BorderLayout.CENTER); 716 gc.fill = GridBagConstraints.HORIZONTAL; 717 gc.gridy = 1; 718 gc.weightx = 1.0; 719 gc.weighty = 0.0; 720 add(pnl, gc); 721 } 722 723 724 protected UploadDialogPanel() { 659 725 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer(); 660 726 661 lstAdd = new JList( add.toArray());727 lstAdd = new JList(); 662 728 lstAdd.setCellRenderer(renderer); 663 729 lstAdd.setVisibleRowCount(Math.min(lstAdd.getModel().getSize(), 10)); 664 730 665 lstUpdate = new JList( update.toArray());731 lstUpdate = new JList(); 666 732 lstUpdate.setCellRenderer(renderer); 667 733 lstUpdate.setVisibleRowCount(Math.min(lstUpdate.getModel().getSize(), 10)); 668 734 669 lstDelete = new JList( update.toArray());735 lstDelete = new JList(); 670 736 lstDelete.setCellRenderer(renderer); 671 737 lstDelete.setVisibleRowCount(Math.min(lstDelete.getModel().getSize(), 10)); 672 738 build(); 739 } 740 741 public void setUploadedPrimitives(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 742 lstAdd.setListData(add.toArray()); 743 lstAdd.setVisible(!add.isEmpty()); 744 lblAdd.setVisible(!add.isEmpty()); 745 lstUpdate.setListData(update.toArray()); 746 lstUpdate.setVisible(!update.isEmpty()); 747 lblUpdate.setVisible(!update.isEmpty()); 748 lstDelete.setListData(delete.toArray()); 749 lstDelete.setVisible(!delete.isEmpty()); 750 lblDelete.setVisible(!delete.isEmpty()); 673 751 } 674 752 … … 682 760 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory()); 683 761 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected()); 762 763 if (rbUseNewAndClose.isSelected()) { 764 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 765 } else if (rbUseNewAndLeaveOpen.isSelected()) { 766 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN; 767 } else if (rbUseExistingAndClose.isSelected()) { 768 changesetProcessingType = ChangesetProcessingType.USE_EXISTING_AND_CLOSE; 769 } else if (rbUseExistingAndLeaveOpen.isSelected()) { 770 changesetProcessingType = ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN; 771 } 684 772 } 685 773 686 774 public void startUserInput() { 775 rbUseNewAndClose.setVisible(true); 776 rbUseNewAndLeaveOpen.setVisible(true); 777 if (OsmApi.getOsmApi().getCurrentChangeset() != null) { 778 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset(); 779 rbUseExistingAndClose.setVisible(true); 780 rbUseExistingAndLeaveOpen.setVisible(true); 781 782 rbUseExistingAndClose.setText(tr("Use the existing changeset {0} and close it after upload",cs.getId())); 783 rbUseExistingAndClose.setToolTipText(tr("Select to upload to the existing changeset {0} and to close the changeset after this upload",cs.getId())); 784 785 rbUseExistingAndLeaveOpen.setText(tr("Use the existing changeset {0} and leave it open",cs.getId())); 786 rbUseExistingAndLeaveOpen.setToolTipText(tr("Select to upload to the existing changeset {0} and to leave the changeset open for further uploads",cs.getId())); 787 788 if (changesetProcessingType == null) { 789 rbUseNewAndClose.setSelected(true); 790 } else { 791 switch(changesetProcessingType) { 792 case USE_NEW_AND_CLOSE: rbUseNewAndClose.setSelected(true); break; 793 case USE_NEW_AND_LEAVE_OPEN: rbUseNewAndLeaveOpen.setSelected(true); break; 794 case USE_EXISTING_AND_CLOSE: rbUseExistingAndClose.setSelected(true); break; 795 case USE_EXISTING_AND_LEAVE_OPEN: rbUseExistingAndLeaveOpen.setSelected(true); break; 796 } 797 } 798 } else { 799 if (changesetProcessingType == null) { 800 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 801 } 802 rbUseExistingAndClose.setVisible(false); 803 rbUseExistingAndLeaveOpen.setVisible(false); 804 switch(changesetProcessingType) { 805 case USE_NEW_AND_CLOSE: rbUseNewAndClose.setSelected(true); break; 806 case USE_NEW_AND_LEAVE_OPEN: rbUseNewAndLeaveOpen.setSelected(true); break; 807 default: rbUseNewAndClose.setSelected(true); break; 808 } 809 } 687 810 cmt.getEditor().selectAll(); 688 811 cmt.requestFocus(); 689 812 } 813 814 public ChangesetProcessingType getChangesetProcessingType() { 815 if (changesetProcessingType == null) return ChangesetProcessingType.USE_NEW_AND_CLOSE; 816 return changesetProcessingType; 817 } 818 819 public Changeset getChangeset() { 820 Changeset changeset = new Changeset(); 821 tagEditorPanel.getModel().applyToPrimitive(changeset); 822 changeset.put("comment", cmt.getText()); 823 return changeset; 824 } 690 825 } 691 826 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2017 r2040 73 73 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 74 74 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 75 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 76 import org.openstreetmap.josm.gui.tagging.TagCellEditor; 77 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 78 import org.openstreetmap.josm.gui.tagging.TagTable; 75 79 import org.openstreetmap.josm.io.OsmApi; 76 80 import org.openstreetmap.josm.io.OsmServerObjectReader; … … 267 271 268 272 final JScrollPane scrollPane = new JScrollPane(tagTable); 269 270 // this adapters ensures that the width of the tag table columns is adjusted271 // to the width of the scroll pane viewport. Also tried to overwrite272 // getPreferredViewportSize() in JTable, but did not work.273 //274 scrollPane.addComponentListener(new ComponentAdapter() {275 @Override276 public void componentResized(ComponentEvent e) {277 super.componentResized(e);278 Dimension d = scrollPane.getViewport().getExtentSize();279 tagTable.adjustColumnWidth(d.width);280 }281 });282 273 283 274 GridBagConstraints gc = new GridBagConstraints(); … … 1355 1346 1356 1347 protected void updateEnabledState() { 1357 setEnabled(getRelation() != null && getRelation(). id> 0);1348 setEnabled(getRelation() != null && getRelation().getId() > 0); 1358 1349 } 1359 1350 } … … 1559 1550 try { 1560 1551 progressMonitor.indeterminateSubTask(""); 1561 OsmServerObjectReader reader = new OsmServerObjectReader(getRelation(). id, OsmPrimitiveType.RELATION,1552 OsmServerObjectReader reader = new OsmServerObjectReader(getRelation().getId(), OsmPrimitiveType.RELATION, 1562 1553 true); 1563 1554 DataSet dataSet = reader.parseOsm(progressMonitor -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberRoleCellEditor.java
r1916 r2040 13 13 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList; 14 14 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionListItem; 15 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 15 16 16 17 public class MemberRoleCellEditor extends AbstractCellEditor implements TableCellEditor { -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r2025 r2040 33 33 import org.openstreetmap.josm.Main; 34 34 import org.openstreetmap.josm.actions.UploadAction; 35 import org.openstreetmap.josm.actions.UploadAction.UploadConfirmationHook; 35 36 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 36 37 import org.openstreetmap.josm.gui.SideButton; … … 407 408 } 408 409 409 currentTask = new UploadLayerTask(layerInfo.getLayer(), monitor); 410 currentTask = new UploadLayerTask( 411 layerInfo.getLayer(), 412 monitor, 413 UploadAction.UploadConfirmationHook.getUploadDialogPanel().getChangeset(), 414 UploadAction.UploadConfirmationHook.getUploadDialogPanel().getChangesetProcessingType() 415 ); 410 416 currentFuture = worker.submit(currentTask); 411 417 try { -
trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java
r2037 r2040 7 7 8 8 import org.openstreetmap.josm.data.APIDataSet; 9 import org.openstreetmap.josm.data.osm.Changeset; 9 10 import org.openstreetmap.josm.data.osm.DataSet; 10 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 12 13 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 13 14 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 15 import org.openstreetmap.josm.io.ChangesetProcessingType; 14 16 import org.openstreetmap.josm.io.OsmServerWriter; 15 17 … … 33 35 private OsmDataLayer layer; 34 36 private ProgressMonitor monitor; 37 private Changeset changeset; 38 private ChangesetProcessingType changesetProcessingType; 35 39 36 40 /** … … 38 42 * @param layer the layer. Must not be null. 39 43 * @param monitor a progress monitor. If monitor is null, uses {@see NullProgressMonitor#INSTANCE} 44 * @param changeset the changeset to be used if <code>changesetProcessingType</code> indicates that a new 45 * changeset is to be used 46 * @param changesetProcessingType how we handle changesets 40 47 * @throws IllegalArgumentException thrown, if layer is null 41 48 */ 42 public UploadLayerTask(OsmDataLayer layer, ProgressMonitor monitor ) {49 public UploadLayerTask(OsmDataLayer layer, ProgressMonitor monitor, Changeset changeset, ChangesetProcessingType changesetProcessingType) { 43 50 if (layer == null) 44 51 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", layer)); … … 48 55 this.layer = layer; 49 56 this.monitor = monitor; 57 this.changeset = changeset; 58 this.changesetProcessingType = changesetProcessingType == null ? ChangesetProcessingType.USE_NEW_AND_CLOSE : changesetProcessingType; 50 59 } 51 60 … … 60 69 ProgressMonitor m = monitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 61 70 if (isCancelled()) return; 62 writer.uploadOsm(layer.data.version, toUpload, m);71 writer.uploadOsm(layer.data.version, toUpload, changeset, changesetProcessingType, m); 63 72 } catch (Exception sxe) { 64 73 if (isCancelled()) { -
trunk/src/org/openstreetmap/josm/gui/tagging/AutoCompletingTextField.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import java.awt.event.FocusAdapter; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import java.awt.Component; … … 55 55 protected void initAutoCompletionListForKeys(TagEditorModel model, TagModel currentTag) { 56 56 57 if (autoCompletionList == null) {58 logger.warning("autoCompletionList is null. Make sure an instance of AutoCompletionList is injected into TableCellEditor.");57 if (autoCompletionList == null) 58 //logger.warning("autoCompletionList is null. Make sure an instance of AutoCompletionList is injected into TableCellEditor."); 59 59 return; 60 }61 60 autoCompletionList.clear(); 62 61 -
trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.trn; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagModel.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import java.util.ArrayList; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
r2037 r2040 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui. dialogs.relation;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.awt.AWTException; 7 import java.awt.Container; 8 import java.awt.Dimension; 7 9 import java.awt.MouseInfo; 8 10 import java.awt.Point; … … 20 22 import javax.swing.JComponent; 21 23 import javax.swing.JTable; 24 import javax.swing.JViewport; 22 25 import javax.swing.KeyStroke; 23 26 import javax.swing.ListSelectionModel; … … 30 33 import javax.swing.table.TableModel; 31 34 35 import org.openstreetmap.josm.gui.dialogs.relation.RunnableAction; 32 36 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache; 33 37 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList; … … 335 339 } 336 340 337 338 339 /** 340 * adjusts the width of the columns for the tag name and the tag value 341 * to the width of the scroll panes viewport. 342 * 343 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected 344 * 345 * @param scrollPaneWidth the width of the scroll panes viewport 346 */ 347 public void adjustColumnWidth(int scrollPaneWidth) { 348 TableColumnModel tcm = getColumnModel(); 349 int width = scrollPaneWidth; 350 width = width / 2; 351 if (width > 0) { 352 tcm.getColumn(0).setMinWidth(width); 353 tcm.getColumn(0).setMaxWidth(width); 354 tcm.getColumn(1).setMinWidth(width); 355 tcm.getColumn(1).setMaxWidth(width); 356 } 357 } 358 341 @Override 342 public Dimension getPreferredSize(){ 343 Container c = getParent(); 344 while(c != null && ! (c instanceof JViewport)) { 345 c = c.getParent(); 346 } 347 if (c != null) { 348 Dimension d = super.getPreferredSize(); 349 d.width = c.getSize().width; 350 return d; 351 } 352 return super.getPreferredSize(); 353 } 359 354 360 355 @Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2037 r2040 145 145 146 146 /** 147 * Returns true if the negotiated version supports changesets.148 * @return true if the negotiated version supports changesets.149 */ 150 public boolean has ChangesetSupport() {147 * Returns true if the negotiated version supports diff uploads. 148 * @return true if the negotiated version supports diff uploads 149 */ 150 public boolean hasSupportForDiffUploads() { 151 151 return ((version != null) && (version.compareTo("0.6")>=0)); 152 152 } … … 280 280 281 281 /** 282 * Creates a new changeset on the server to use for subsequent calls. 283 * @param comment the "commit comment" for the new changeset 282 * Creates the changeset to be used for subsequent uploads. 283 * 284 * If changesetProcessingType is {@see ChangesetProcessingType#USE_NEW} creates a new changeset based 285 * on <code>changeset</code>. Otherwise uses the changeset given by {@see OsmApi#getCurrentChangeset()}. 286 * If this changeset is null or has an id of value 0, a new changeset is created too. 287 * 288 * @param changeset the changeset to be used for uploading if <code>changesetProcessingType</code> is 289 * {@see ChangesetProcessingType#USE_NEW} 290 * @param changesetProcessingType how to handel changesets; set to {@see ChangesetProcessingType#USE_NEW} if null 291 * @param progressMonitor the progress monitor 284 292 * @throws OsmTransferException signifying a non-200 return code, or connection errors 285 293 */ 286 public void createChangeset(String comment, ProgressMonitor progressMonitor) throws OsmTransferException { 287 progressMonitor.beginTask((tr("Opening changeset..."))); 294 public void createChangeset(Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 295 if (changesetProcessingType == null) { 296 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 297 } 288 298 try { 289 changeset = new Changeset(); 290 Properties sysProp = System.getProperties(); 291 Object ua = sysProp.get("http.agent"); 292 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 293 changeset.put("comment", comment); 294 createPrimitive(changeset, progressMonitor); 299 progressMonitor.beginTask((tr("Creating changeset..."))); 300 if (changesetProcessingType.isUseNew()) { 301 Properties sysProp = System.getProperties(); 302 Object ua = sysProp.get("http.agent"); 303 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 304 createPrimitive(changeset, progressMonitor); 305 this.changeset = changeset; 306 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",changeset.getId()))); 307 } else { 308 if (this.changeset == null || this.changeset.getId() == 0) { 309 progressMonitor.setCustomText((tr("No currently open changeset. Opening a new changeset..."))); 310 System.out.println(tr("Warning: could not reuse an existing changeset as requested. Opening a new one.")); 311 Properties sysProp = System.getProperties(); 312 Object ua = sysProp.get("http.agent"); 313 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 314 createPrimitive(changeset, progressMonitor); 315 this.changeset = changeset; 316 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 317 } else { 318 progressMonitor.setCustomText((tr("Reusing existing changeset {0}", this.changeset.getId()))); 319 } 320 } 295 321 } finally { 296 322 progressMonitor.finishTask(); … … 301 327 * Closes a changeset on the server. 302 328 * 329 * @param changesetProcessingType how changesets are currently handled 330 * @param progressMonitor the progress monitor 331 * 303 332 * @throws OsmTransferException if something goes wrong. 304 333 */ 305 public void stopChangeset(ProgressMonitor progressMonitor) throws OsmTransferException { 306 progressMonitor.beginTask(tr("Closing changeset {0}...", changeset.getId())); 334 public void stopChangeset(ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 335 if (changesetProcessingType == null) { 336 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 337 } 307 338 try { 339 progressMonitor.beginTask(tr("Closing changeset...")); 308 340 initialize(progressMonitor); 309 sendRequest("PUT", "changeset" + "/" + changeset.getId() + "/close", null, progressMonitor); 310 changeset = null; 341 if (changesetProcessingType.isCloseAfterUpload()) { 342 progressMonitor.setCustomText(tr("Closing changeset {0}...", changeset.getId())); 343 if (this.changeset != null && this.changeset.getId() > 0) { 344 sendRequest("PUT", "changeset" + "/" + changeset.getId() + "/close", null, progressMonitor); 345 changeset = null; 346 } 347 } else { 348 progressMonitor.setCustomText(tr("Leaving changeset {0} open...", changeset.getId())); 349 } 311 350 } finally { 312 351 progressMonitor.finishTask(); -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2037 r2040 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.UploadAction; 14 import org.openstreetmap.josm.data.osm.Changeset; 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 81 82 * 82 83 * @param primitives the collection of primitives to upload 84 * @param changeset the changeset to be used if <code>changesetProcessingType</code> indicates that 85 * a new changeset should be opened 86 * @param changesetProcessingType how we handle changesets 83 87 * @param progressMonitor the progress monitor 84 88 * @throws OsmTransferException thrown if an exception occurs 85 89 */ 86 protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException {90 protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 87 91 try { 88 92 progressMonitor.setTicksCount(primitives.size()); 89 api.createChangeset( getChangesetComment(),progressMonitor.createSubTaskMonitor(0, false));93 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false)); 90 94 uploadStartTime = System.currentTimeMillis(); 91 95 for (OsmPrimitive osm : primitives) { … … 121 125 122 126 if (api.getCurrentChangeset() != null && api.getCurrentChangeset().getId() > 0) { 123 api.stopChangeset( progressMonitor.createSubTaskMonitor(0, false));127 api.stopChangeset(changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 124 128 } 125 129 } catch(Exception e) { … … 138 142 * @throws OsmTransferException thrown if an exception occurs 139 143 */ 140 protected void uploadChangesAsDiffUpload(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException {144 protected void uploadChangesAsDiffUpload(Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 141 145 // upload everything in one changeset 142 146 // 143 147 try { 144 api.createChangeset( getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));148 api.createChangeset(changeset, changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 145 149 processed.addAll(api.uploadDiff(primitives, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false))); 146 150 } catch(OsmTransferException e) { … … 150 154 } finally { 151 155 try { 152 api.stopChangeset( progressMonitor.createSubTaskMonitor(0, false));156 api.stopChangeset(changesetProcessingType, progressMonitor.createSubTaskMonitor(0, false)); 153 157 } catch (Exception ee) { 154 158 OsmChangesetCloseException closeException = new OsmChangesetCloseException(ee); … … 165 169 * @param primitives list of objects to send 166 170 */ 167 public void uploadOsm(String apiVersion, Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException {171 public void uploadOsm(String apiVersion, Collection<OsmPrimitive> primitives, Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 168 172 processed = new LinkedList<OsmPrimitive>(); 169 173 … … 171 175 172 176 try { 173 // check whether we can use changeset177 // check whether we can use diff upload 174 178 // 175 boolean ca nUseChangeset = api.hasChangesetSupport();176 boolean use Changeset= Main.pref.getBoolean("osm-server.atomic-upload", apiVersion.compareTo("0.6")>=0);177 if (use Changeset && ! canUseChangeset) {178 System.out.println(tr("WARNING: preference ''{0}'' or api version ''{1}'' of dataset requires to use changesets, but API is not able to handle them. Ignoring changesets.", "osm-server.atomic-upload", apiVersion));179 use Changeset= false;180 } 181 182 if (use Changeset) {179 boolean casUseDiffUploads = api.hasSupportForDiffUploads(); 180 boolean useDiffUpload = Main.pref.getBoolean("osm-server.atomic-upload", apiVersion.compareTo("0.6")>=0); 181 if (useDiffUpload && ! casUseDiffUploads) { 182 System.out.println(tr("WARNING: preference ''{0}'' or api version ''{1}'' of dataset requires to use diff uploads, but API is not able to handle them. Ignoring diff upload.", "osm-server.atomic-upload", apiVersion)); 183 useDiffUpload = false; 184 } 185 186 if (useDiffUpload) { 183 187 progressMonitor.beginTask(tr("Starting to upload in one request ...")); 184 uploadChangesAsDiffUpload(primitives, progressMonitor);188 uploadChangesAsDiffUpload(primitives,changeset, changesetProcessingType, progressMonitor); 185 189 } else { 186 190 progressMonitor.beginTask(tr("Starting to upload with one request per primitive ...")); 187 uploadChangesIndividually(primitives, progressMonitor);191 uploadChangesIndividually(primitives,changeset,changesetProcessingType, progressMonitor); 188 192 } 189 193 } finally {
Note:
See TracChangeset
for help on using the changeset viewer.