Changeset 2061 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-09-05T11:00:10+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/StopChangesetAction.java
r2058 r2061 28 28 "system:closechangeset", 29 29 tr("File: {0}", tr("Close the current changeset ...")), 30 KeyEvent.VK_ O,31 Shortcut.GROUP_ MENU30 KeyEvent.VK_Q, 31 Shortcut.GROUP_HOTKEY + Shortcut.GROUPS_ALT2 32 32 ), 33 33 true -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2058 r2061 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.BorderLayout; … … 245 246 ); 246 247 switch(ret) { 247 248 249 250 251 252 253 248 case JOptionPane.CLOSED_OPTION: return; 249 case JOptionPane.CANCEL_OPTION: return; 250 case 0: synchronizePrimitive(id); break; 251 case 1: synchronizeDataSet(); break; 252 default: 253 // should not happen 254 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 254 255 } 255 256 } … … 285 286 ); 286 287 switch(ret) { 287 288 289 290 291 292 288 case JOptionPane.CLOSED_OPTION: return; 289 case 1: return; 290 case 0: synchronizeDataSet(); break; 291 default: 292 // should not happen 293 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 293 294 } 294 295 } … … 587 588 static public class UploadDialogPanel extends JPanel { 588 589 590 /** the list with the added primitives */ 589 591 private JList lstAdd; 592 private JLabel lblAdd; 593 private JScrollPane spAdd; 594 /** the list with the updated primitives */ 590 595 private JList lstUpdate; 596 private JLabel lblUpdate; 597 private JScrollPane spUpdate; 598 /** the list with the deleted primitives */ 591 599 private JList lstDelete; 592 private JLabel lblAdd;593 private JLabel lblUpdate;594 600 private JLabel lblDelete; 601 private JScrollPane spDelete; 602 /** the panel containing the widgets for the lists of primitives */ 595 603 private JPanel pnlLists; 604 /** checkbox for selecting whether an atomic upload is to be used */ 596 605 private JCheckBox cbUseAtomicUpload; 606 /** input field for changeset comment */ 597 607 private SuggestingJHistoryComboBox cmt; 608 /** ui component for editing changeset tags */ 598 609 private TagEditorPanel tagEditorPanel; 610 /** the tabbed pane used below of the list of primitives */ 599 611 private JTabbedPane southTabbedPane; 612 /** the button group with the changeset processing types */ 600 613 private ButtonGroup bgChangesetHandlingOptions; 614 /** radio buttons for selecting a changeset processing type */ 601 615 private Map<ChangesetProcessingType, JRadioButton> rbChangesetHandlingOptions; 602 616 617 /** 618 * builds the panel with the lists of primitives 619 * 620 * @return the panel with the lists of primitives 621 */ 603 622 protected JPanel buildListsPanel() { 604 623 pnlLists = new JPanel(); 605 624 pnlLists.setLayout(new GridBagLayout()); 606 625 // we don't add the lists yet, see setUploadPrimivies() 626 // 607 627 return pnlLists; 608 628 } 609 629 630 /** 631 * builds the panel with the ui components for controlling how the changeset 632 * should be processed (opening/closing a changeset) 633 * 634 * @return the panel with the ui components for controlling how the changeset 635 * should be processed 636 */ 610 637 protected JPanel buildChangesetHandlingControlPanel() { 611 638 JPanel pnl = new JPanel(); … … 639 666 } 640 667 668 /** 669 * build the panel with the widgets for controlling how the changeset should be processed 670 * (atomic upload or not, comment, opening/closing changeset) 671 * 672 * @return 673 */ 641 674 protected JPanel buildChangesetControlPanel() { 642 675 JPanel pnl = new JPanel(); … … 652 685 } 653 686 687 /** 688 * builds the upload control panel 689 * 690 * @return 691 */ 654 692 protected JPanel buildUploadControlPanel() { 655 693 JPanel pnl = new JPanel(); … … 667 705 } 668 706 707 /** 708 * builds the gui 709 */ 669 710 protected void build() { 670 711 setLayout(new GridBagLayout()); 671 712 GridBagConstraints gc = new GridBagConstraints(); 713 714 // first the panel with the list in the upper half 715 // 672 716 gc.fill = GridBagConstraints.BOTH; 673 717 gc.weightx = 1.0; … … 675 719 add(buildListsPanel(), gc); 676 720 721 // a tabbed pane with two configuration panels in the 722 // lower half 723 // 677 724 southTabbedPane = new JTabbedPane(); 678 725 southTabbedPane.add(buildUploadControlPanel()); … … 691 738 } 692 739 693 740 /** 741 * constructor 742 */ 694 743 protected UploadDialogPanel() { 695 744 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer(); 696 745 746 // initialize the three lists for primitives 747 // 697 748 lstAdd = new JList(); 698 749 lstAdd.setCellRenderer(renderer); 699 750 lstAdd.setVisibleRowCount(Math.min(lstAdd.getModel().getSize(), 10)); 751 spAdd = new JScrollPane(lstAdd); 752 lblAdd = new JLabel(tr("Objects to add:")); 700 753 701 754 lstUpdate = new JList(); 702 755 lstUpdate.setCellRenderer(renderer); 703 756 lstUpdate.setVisibleRowCount(Math.min(lstUpdate.getModel().getSize(), 10)); 757 spUpdate = new JScrollPane(lstUpdate); 758 lblUpdate = new JLabel(tr("Objects to modify:")); 704 759 705 760 lstDelete = new JList(); 706 761 lstDelete.setCellRenderer(renderer); 707 762 lstDelete.setVisibleRowCount(Math.min(lstDelete.getModel().getSize(), 10)); 763 spDelete = new JScrollPane(lstDelete); 764 lblDelete = new JLabel(tr("Objects to delete:")); 765 766 // build the GUI 767 // 708 768 build(); 709 769 } 710 770 771 /** 772 * sets the collection of primitives which will be uploaded 773 * 774 * @param add the collection of primitives to add 775 * @param update the collection of primitives to update 776 * @param delete the collection of primitives to delete 777 */ 711 778 public void setUploadedPrimitives(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 712 779 lstAdd.setListData(add.toArray()); … … 731 798 y++; 732 799 gcLabel.gridy = y; 733 pnlLists.add(lblAdd = new JLabel(tr("Objects to add:")), gcLabel); 800 lblAdd.setText(trn("{0} object to add:", "{0} objects to add:", add.size(),add.size())); 801 pnlLists.add(lblAdd, gcLabel); 734 802 y++; 735 803 gcList.gridy = y; 736 pnlLists.add( new JScrollPane(lstAdd), gcList);804 pnlLists.add(spAdd, gcList); 737 805 } 738 806 if (!update.isEmpty()) { 739 807 y++; 740 808 gcLabel.gridy = y; 741 pnlLists.add(lblUpdate = new JLabel(tr("Objects to modify:")), gcLabel); 809 lblUpdate.setText(trn("{0} object to modifiy:", "{0} objects to modify:", update.size(),update.size())); 810 pnlLists.add(lblUpdate, gcLabel); 742 811 y++; 743 812 gcList.gridy = y; 744 pnlLists.add( new JScrollPane(lstUpdate), gcList);813 pnlLists.add(spUpdate, gcList); 745 814 } 746 815 if (!delete.isEmpty()) { 747 816 y++; 748 817 gcLabel.gridy = y; 749 pnlLists.add(lblDelete = new JLabel(tr("Objects to delete:")), gcLabel); 818 lblDelete.setText(trn("{0} object to delete:", "{0} objects to delete:", delete.size(),delete.size())); 819 pnlLists.add(lblDelete, gcLabel); 750 820 y++; 751 821 gcList.gridy = y; 752 pnlLists.add(new JScrollPane(lstDelete), gcList); 753 } 754 } 755 822 pnlLists.add(spDelete, gcList); 823 } 824 } 825 826 /** 827 * Replies true if a valid changeset comment has been entered in this dialog 828 * 829 * @return true if a valid changeset comment has been entered in this dialog 830 */ 756 831 public boolean hasChangesetComment() { 757 832 if (!getChangesetProcessingType().isUseNew()) … … 760 835 } 761 836 837 /** 838 * Remembers the user input in the preference settings 839 */ 762 840 public void rememberUserInput() { 763 841 // store the history of comments … … 767 845 } 768 846 847 /** 848 * Initializes the panel for user input 849 */ 769 850 public void startUserInput() { 770 851 tagEditorPanel.initAutoCompletion(Main.main.getEditLayer()); … … 774 855 } 775 856 857 /** 858 * Replies the current changeset processing type 859 * 860 * @return the current changeset processing type 861 */ 776 862 public ChangesetProcessingType getChangesetProcessingType() { 777 863 ChangesetProcessingType changesetProcessingType = null; … … 787 873 } 788 874 875 /** 876 * Replies the current changeset 877 * 878 * @return the current changeset 879 */ 789 880 public Changeset getChangeset() { 790 881 Changeset changeset = new Changeset(); … … 794 885 } 795 886 887 /** 888 * initializes the panel depending on the possible changeset processing 889 * types 890 */ 796 891 protected void initChangesetProcessingType() { 797 892 for (ChangesetProcessingType type: ChangesetProcessingType.values()) { … … 826 921 rbChangesetHandlingOptions.get(type).setSelected(true); 827 922 } 923 refreshChangesetProcessingType(getChangesetProcessingType()); 924 } 925 926 /** 927 * refreshes the panel depending on a changeset processing type 928 * 929 * @param type the changeset processing type 930 */ 931 protected void refreshChangesetProcessingType(ChangesetProcessingType type) { 932 if (type.isUseNew()) { 933 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 934 Changeset cs = new Changeset(); 935 tagEditorPanel.getModel().initFromPrimitive(cs); 936 } else { 937 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset(); 938 if (cs != null) { 939 southTabbedPane.setTitleAt(1, tr("Tags of changeset {0}", cs.getId())); 940 if (cs.get("comment") != null) { 941 cmt.setText(cs.get("comment")); 942 cs.remove("comment"); 943 } 944 tagEditorPanel.getModel().initFromPrimitive(cs); 945 } 946 } 828 947 } 829 948 … … 831 950 public void actionPerformed(ActionEvent e) { 832 951 ChangesetProcessingType type = getChangesetProcessingType(); 833 if (type.isUseNew()) { 834 tagEditorPanel.setEnabled(true); 835 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 836 cmt.setEnabled(true); 837 } else { 838 tagEditorPanel.setEnabled(false); 839 cmt.setEnabled(false); 840 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset(); 841 if (cs != null) { 842 tagEditorPanel.getModel().initFromPrimitive(cs); 843 southTabbedPane.setTitleAt(1, tr("Tags of changeset {0} (read-only)", cs.getId())); 844 cmt.setText(cs.get("comment" == null ? "" : cs.get("comment"))); 845 } 846 } 952 refreshChangesetProcessingType(type); 847 953 } 848 954 }
Note:
See TracChangeset
for help on using the changeset viewer.