- Timestamp:
- 2009-09-08T22:56:02+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r2017 r2081 61 61 manifest = true; 62 62 u = new URL("jar:" + Main.class.getProtectionDomain().getCodeSource().getLocation().toString() 63 + "!/META-INF/MANIFEST.MF");63 + "!/META-INF/MANIFEST.MF"); 64 64 } catch (MalformedURLException e) { 65 65 e.printStackTrace(); -
trunk/src/org/openstreetmap/josm/actions/ApiPreconditionChecker.java
r2035 r2081 4 4 5 5 import java.util.Collection; 6 import java.util.LinkedList; 7 import java.util.List; 6 import java.util.Collections; 8 7 import java.util.Map.Entry; 9 8 … … 12 11 import org.openstreetmap.josm.Main; 13 12 import org.openstreetmap.josm.actions.UploadAction.UploadHook; 13 import org.openstreetmap.josm.data.APIDataSet; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 15 import org.openstreetmap.josm.data.osm.Way; … … 21 21 public class ApiPreconditionChecker implements UploadHook { 22 22 23 public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, 24 Collection<OsmPrimitive> delete) { 23 public boolean checkUpload(APIDataSet apiData) { 25 24 OsmApi api = OsmApi.getOsmApi(); 26 25 try { … … 36 35 37 36 if (maxNodes > 0) { 38 if( !checkMaxNodes(a dd, maxNodes))37 if( !checkMaxNodes(apiData.getPrimitivesToAdd(), maxNodes)) 39 38 return false; 40 if( !checkMaxNodes( update, maxNodes))39 if( !checkMaxNodes(apiData.getPrimitivesToUpdate(), maxNodes)) 41 40 return false; 42 if( !checkMaxNodes( delete, maxNodes))41 if( !checkMaxNodes(apiData.getPrimitivesToDelete(), maxNodes)) 43 42 return false; 44 43 } … … 46 45 if (maxElements > 0) { 47 46 int total = 0; 48 total = a dd.size() + update.size() + delete.size();47 total = apiData.getPrimitivesToAdd().size() + apiData.getPrimitivesToUpdate().size() + apiData.getPrimitivesToDelete().size(); 49 48 if(total > maxElements) { 50 49 JOptionPane.showMessageDialog( … … 67 66 } 68 67 69 private boolean checkMaxNodes(Collection<OsmPrimitive> add, long maxNodes) {70 for (OsmPrimitive osmPrimitive : add) {68 private boolean checkMaxNodes(Collection<OsmPrimitive> primitives, long maxNodes) { 69 for (OsmPrimitive osmPrimitive : primitives) { 71 70 for (Entry<String,String> e : osmPrimitive.entrySet()) { 72 71 if(e.getValue().length() > 255) { … … 90 89 JOptionPane.ERROR_MESSAGE 91 90 ); 92 List<OsmPrimitive> newNodes = new LinkedList<OsmPrimitive>(); 93 newNodes.add(osmPrimitive); 94 Main.main.getCurrentDataSet().setSelected(newNodes); 91 Main.main.getCurrentDataSet().setSelected(Collections.singleton(osmPrimitive)); 95 92 return false; 96 93 } … … 109 106 JOptionPane.ERROR_MESSAGE 110 107 ); 111 List<OsmPrimitive> newNodes = new LinkedList<OsmPrimitive>(); 112 newNodes.add(osmPrimitive); 113 114 Main.main.getCurrentDataSet().setSelected(newNodes); 108 Main.main.getCurrentDataSet().setSelected(Collections.singleton(osmPrimitive)); 115 109 return false; 116 110 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2077 r2081 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.awt.BorderLayout; 8 import java.awt.Dimension; 9 import java.awt.GridBagConstraints; 10 import java.awt.GridBagLayout; 5 11 6 import java.awt.event.ActionEvent; 12 import java.awt.event.ActionListener;13 7 import java.awt.event.KeyEvent; 14 8 import java.io.IOException; 15 9 import java.net.HttpURLConnection; 16 10 import java.util.Collection; 17 import java.util.HashMap;18 11 import java.util.LinkedList; 19 import java.util.List;20 import java.util.Map;21 import java.util.Properties;22 12 import java.util.logging.Logger; 23 13 import java.util.regex.Matcher; 24 14 import java.util.regex.Pattern; 25 15 26 import javax.swing.BoxLayout;27 import javax.swing.ButtonGroup;28 import javax.swing.JCheckBox;29 import javax.swing.JLabel;30 import javax.swing.JList;31 16 import javax.swing.JOptionPane; 32 import javax.swing.JPanel;33 import javax.swing.JRadioButton;34 import javax.swing.JScrollPane;35 import javax.swing.JTabbedPane;36 17 37 18 import org.openstreetmap.josm.Main; … … 43 24 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 44 25 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 45 import org.openstreetmap.josm.gui.ExtendedDialog;46 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;47 26 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 48 import org.openstreetmap.josm.gui. historycombobox.SuggestingJHistoryComboBox;27 import org.openstreetmap.josm.gui.io.UploadDialog; 49 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 50 29 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 51 import org.openstreetmap.josm.gui.tagging.TagEditorPanel;52 30 import org.openstreetmap.josm.io.ChangesetProcessingType; 53 31 import org.openstreetmap.josm.io.OsmApi; … … 56 34 import org.openstreetmap.josm.io.OsmChangesetCloseException; 57 35 import org.openstreetmap.josm.io.OsmServerWriter; 58 import org.openstreetmap.josm.tools.GBC;59 36 import org.openstreetmap.josm.tools.Shortcut; 60 import org.openstreetmap.josm.tools.WindowGeometry;61 37 import org.xml.sax.SAXException; 62 38 … … 74 50 public class UploadAction extends JosmAction{ 75 51 static private Logger logger = Logger.getLogger(UploadAction.class.getName()); 76 77 public static final String HISTORY_KEY = "upload.comment.history";78 79 /** Upload Hook */80 public interface UploadHook {81 /**82 * Checks the upload.83 * @param add The added primitives84 * @param update The updated primitives85 * @param delete The deleted primitives86 * @return true, if the upload can continue87 */88 public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete);89 }90 91 52 /** 92 53 * The list of upload hooks. These hooks will be called one after the other … … 99 60 * however, a plugin might also want to insert something after that. 100 61 */ 101 public final LinkedList<UploadHook> uploadHooks = new LinkedList<UploadHook>(); 102 103 public UploadAction() { 104 super(tr("Upload to OSM..."), "upload", tr("Upload all changes to the OSM server."), 105 Shortcut.registerShortcut("file:upload", tr("File: {0}", tr("Upload to OSM...")), KeyEvent.VK_U, Shortcut.GROUPS_ALT1+Shortcut.GROUP_HOTKEY), true); 106 62 public static final LinkedList<UploadHook> uploadHooks = new LinkedList<UploadHook>(); 63 static { 107 64 /** 108 65 * Checks server capabilities before upload. … … 115 72 */ 116 73 uploadHooks.add(new UploadConfirmationHook()); 74 } 75 76 /** 77 * Registers an upload hook. Adds the hook to the end of the list of upload hooks. 78 * 79 * @param hook the upload hook. Ignored if null. 80 */ 81 public static void registerUploadHook(UploadHook hook) { 82 if(hook == null) return; 83 if (!uploadHooks.contains(hook)) { 84 uploadHooks.add(hook); 85 } 86 } 87 88 /** 89 * Unregisters an upload hook. Removes the hook from the list of upload hooks. 90 * 91 * @param hook the upload hook. Ignored if null. 92 */ 93 public static void unregisterUploadHook(UploadHook hook) { 94 if(hook == null) return; 95 if (uploadHooks.contains(hook)) { 96 uploadHooks.remove(hook); 97 } 98 } 99 100 /** Upload Hook */ 101 public interface UploadHook { 102 /** 103 * Checks the upload. 104 * @param apiDataSet the data to upload 105 */ 106 public boolean checkUpload(APIDataSet apiDataSet); 107 } 108 109 110 public UploadAction() { 111 super(tr("Upload to OSM..."), "upload", tr("Upload all changes to the OSM server."), 112 Shortcut.registerShortcut("file:upload", tr("File: {0}", tr("Upload to OSM...")), KeyEvent.VK_U, Shortcut.GROUPS_ALT1+Shortcut.GROUP_HOTKEY), true); 117 113 } 118 114 … … 145 141 // is one of these. 146 142 for(UploadHook hook : uploadHooks) 147 if(!hook.checkUpload(apiData .getPrimitivesToAdd(), apiData.getPrimitivesToUpdate(), apiData.getPrimitivesToDelete()))143 if(!hook.checkUpload(apiData)) 148 144 return false; 149 145 … … 180 176 Main.map.mapView.getEditLayer(), 181 177 apiData.getPrimitives(), 182 UploadConfirmationHook.getUploadDialog Panel().getChangeset(),183 UploadConfirmationHook.getUploadDialog Panel().getChangesetProcessingType()178 UploadConfirmationHook.getUploadDialog().getChangeset(), 179 UploadConfirmationHook.getUploadDialog().getChangesetProcessingType() 184 180 ) 185 181 ); … … 461 457 462 458 static public class UploadConfirmationHook implements UploadHook { 463 static private UploadDialogPanel uploadDialogPanel; 464 465 static public UploadDialogPanel getUploadDialogPanel() { 466 if (uploadDialogPanel == null) { 467 uploadDialogPanel = new UploadDialogPanel(); 468 } 469 return uploadDialogPanel; 470 } 471 472 public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) { 473 final UploadDialogPanel panel = getUploadDialogPanel(); 474 panel.setUploadedPrimitives(add, update, delete); 475 476 ExtendedDialog dialog = new ExtendedDialog( 477 Main.parent, 478 tr("Upload these changes?"), 479 new String[] {tr("Upload Changes"), tr("Cancel")} 480 ) { 481 @Override 482 public void setVisible(boolean visible) { 483 if (visible) { 484 new WindowGeometry( 485 panel.getClass().getName(), 486 WindowGeometry.centerInWindow( 487 JOptionPane.getFrameForComponent(Main.parent), 488 new Dimension(400,600) 489 ) 490 ).apply(this); 491 panel.startUserInput(); 492 } else { 493 new WindowGeometry(this).remember(panel.getClass().getName()); 494 } 495 super.setVisible(visible); 496 } 497 }; 498 499 dialog.setButtonIcons(new String[] {"upload.png", "cancel.png"}); 500 dialog.setContent(panel, false /* no scroll pane */); 501 while(true) { 502 dialog.showDialog(); 503 int result = dialog.getValue(); 504 // cancel pressed 505 if (result != 1) return false; 506 // don't allow empty commit message 507 if (! panel.hasChangesetComment()) { 508 continue; 509 } 510 panel.rememberUserInput(); 511 break; 512 } 459 static private UploadDialog uploadDialog; 460 461 static public UploadDialog getUploadDialog() { 462 if (uploadDialog == null) { 463 uploadDialog = new UploadDialog(); 464 } 465 return uploadDialog; 466 } 467 468 public boolean checkUpload(APIDataSet apiData) { 469 final UploadDialog dialog = getUploadDialog(); 470 dialog.setUploadedPrimitives(apiData.getPrimitivesToAdd(),apiData.getPrimitivesToUpdate(), apiData.getPrimitivesToDelete()); 471 dialog.setVisible(true); 472 if (dialog.isCanceled()) 473 return false; 474 dialog.rememberUserInput(); 513 475 return true; 514 476 } … … 586 548 } 587 549 } 588 589 /**590 * The panel displaying information about primitives to upload and providing591 * UI widgets for entering the changeset comment and other configuration592 * settings.593 *594 */595 static public class UploadDialogPanel extends JPanel {596 597 /** the list with the added primitives */598 private JList lstAdd;599 private JLabel lblAdd;600 private JScrollPane spAdd;601 /** the list with the updated primitives */602 private JList lstUpdate;603 private JLabel lblUpdate;604 private JScrollPane spUpdate;605 /** the list with the deleted primitives */606 private JList lstDelete;607 private JLabel lblDelete;608 private JScrollPane spDelete;609 /** the panel containing the widgets for the lists of primitives */610 private JPanel pnlLists;611 /** checkbox for selecting whether an atomic upload is to be used */612 private JCheckBox cbUseAtomicUpload;613 /** input field for changeset comment */614 private SuggestingJHistoryComboBox cmt;615 /** ui component for editing changeset tags */616 private TagEditorPanel tagEditorPanel;617 /** the tabbed pane used below of the list of primitives */618 private JTabbedPane southTabbedPane;619 /** the button group with the changeset processing types */620 private ButtonGroup bgChangesetHandlingOptions;621 /** radio buttons for selecting a changeset processing type */622 private Map<ChangesetProcessingType, JRadioButton> rbChangesetHandlingOptions;623 624 /**625 * builds the panel with the lists of primitives626 *627 * @return the panel with the lists of primitives628 */629 protected JPanel buildListsPanel() {630 pnlLists = new JPanel();631 pnlLists.setLayout(new GridBagLayout());632 // we don't add the lists yet, see setUploadPrimivies()633 //634 return pnlLists;635 }636 637 /**638 * builds the panel with the ui components for controlling how the changeset639 * should be processed (opening/closing a changeset)640 *641 * @return the panel with the ui components for controlling how the changeset642 * should be processed643 */644 protected JPanel buildChangesetHandlingControlPanel() {645 JPanel pnl = new JPanel();646 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));647 bgChangesetHandlingOptions = new ButtonGroup();648 rbChangesetHandlingOptions = new HashMap<ChangesetProcessingType, JRadioButton>();649 ChangesetProcessingTypeChangedAction a = new ChangesetProcessingTypeChangedAction();650 for(ChangesetProcessingType type: ChangesetProcessingType.values()) {651 rbChangesetHandlingOptions.put(type, new JRadioButton());652 rbChangesetHandlingOptions.get(type).addActionListener(a);653 }654 JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE);655 rb.setText(tr("Use a new changeset and close it"));656 rb.setToolTipText(tr("Select to upload the data using a new changeset and to close the changeset after the upload"));657 658 rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN);659 rb.setText(tr("Use a new changeset and leave it open"));660 rb.setToolTipText(tr("Select to upload the data using a new changeset and to leave the changeset open after the upload"));661 662 pnl.add(new JLabel(tr("Upload to a new or to an existing changeset?")));663 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE));664 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN));665 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE));666 pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN));667 668 for(ChangesetProcessingType type: ChangesetProcessingType.values()) {669 rbChangesetHandlingOptions.get(type).setVisible(false);670 bgChangesetHandlingOptions.add(rbChangesetHandlingOptions.get(type));671 }672 return pnl;673 }674 675 /**676 * build the panel with the widgets for controlling how the changeset should be processed677 * (atomic upload or not, comment, opening/closing changeset)678 *679 * @return680 */681 protected JPanel buildChangesetControlPanel() {682 JPanel pnl = new JPanel();683 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));684 pnl.add(cbUseAtomicUpload = new JCheckBox(tr("upload all changes in one request")));685 cbUseAtomicUpload.setToolTipText(tr("Enable to upload all changes in one request, disable to use one request per changed primitive"));686 boolean useAtomicUpload = Main.pref.getBoolean("osm-server.atomic-upload", true);687 cbUseAtomicUpload.setSelected(useAtomicUpload);688 cbUseAtomicUpload.setEnabled(OsmApi.getOsmApi().hasSupportForDiffUploads());689 690 pnl.add(buildChangesetHandlingControlPanel());691 return pnl;692 }693 694 /**695 * builds the upload control panel696 *697 * @return698 */699 protected JPanel buildUploadControlPanel() {700 JPanel pnl = new JPanel();701 pnl.setLayout(new GridBagLayout());702 pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3));703 cmt = new SuggestingJHistoryComboBox();704 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>()));705 cmt.setHistory(cmtHistory);706 pnl.add(cmt, GBC.eol().fill(GBC.HORIZONTAL));707 708 // configuration options for atomic upload709 //710 pnl.add(buildChangesetControlPanel(), GBC.eol().fill(GridBagConstraints.HORIZONTAL));711 return pnl;712 }713 714 /**715 * builds the gui716 */717 protected void build() {718 setLayout(new GridBagLayout());719 GridBagConstraints gc = new GridBagConstraints();720 721 // first the panel with the list in the upper half722 //723 gc.fill = GridBagConstraints.BOTH;724 gc.weightx = 1.0;725 gc.weighty = 1.0;726 add(buildListsPanel(), gc);727 728 // a tabbed pane with two configuration panels in the729 // lower half730 //731 southTabbedPane = new JTabbedPane();732 southTabbedPane.add(buildUploadControlPanel());733 tagEditorPanel = new TagEditorPanel();734 southTabbedPane.add(tagEditorPanel);735 southTabbedPane.setTitleAt(0, tr("Settings"));736 southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));737 JPanel pnl = new JPanel();738 pnl.setLayout(new BorderLayout());739 pnl.add(southTabbedPane,BorderLayout.CENTER);740 gc.fill = GridBagConstraints.HORIZONTAL;741 gc.gridy = 1;742 gc.weightx = 1.0;743 gc.weighty = 0.0;744 add(pnl, gc);745 }746 747 /**748 * constructor749 */750 protected UploadDialogPanel() {751 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer();752 753 // initialize the three lists for primitives754 //755 lstAdd = new JList();756 lstAdd.setCellRenderer(renderer);757 lstAdd.setVisibleRowCount(Math.min(lstAdd.getModel().getSize(), 10));758 spAdd = new JScrollPane(lstAdd);759 lblAdd = new JLabel(tr("Objects to add:"));760 761 lstUpdate = new JList();762 lstUpdate.setCellRenderer(renderer);763 lstUpdate.setVisibleRowCount(Math.min(lstUpdate.getModel().getSize(), 10));764 spUpdate = new JScrollPane(lstUpdate);765 lblUpdate = new JLabel(tr("Objects to modify:"));766 767 lstDelete = new JList();768 lstDelete.setCellRenderer(renderer);769 lstDelete.setVisibleRowCount(Math.min(lstDelete.getModel().getSize(), 10));770 spDelete = new JScrollPane(lstDelete);771 lblDelete = new JLabel(tr("Objects to delete:"));772 773 // build the GUI774 //775 build();776 }777 778 /**779 * sets the collection of primitives which will be uploaded780 *781 * @param add the collection of primitives to add782 * @param update the collection of primitives to update783 * @param delete the collection of primitives to delete784 */785 public void setUploadedPrimitives(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete) {786 lstAdd.setListData(add.toArray());787 lstUpdate.setListData(update.toArray());788 lstDelete.setListData(delete.toArray());789 790 791 GridBagConstraints gcLabel = new GridBagConstraints();792 gcLabel.fill = GridBagConstraints.HORIZONTAL;793 gcLabel.weightx = 1.0;794 gcLabel.weighty = 0.0;795 gcLabel.anchor = GridBagConstraints.FIRST_LINE_START;796 797 GridBagConstraints gcList = new GridBagConstraints();798 gcList.fill = GridBagConstraints.BOTH;799 gcList.weightx = 1.0;800 gcList.weighty = 1.0;801 gcList.anchor = GridBagConstraints.CENTER;802 pnlLists.removeAll();803 int y = -1;804 if (!add.isEmpty()) {805 y++;806 gcLabel.gridy = y;807 lblAdd.setText(trn("{0} object to add:", "{0} objects to add:", add.size(),add.size()));808 pnlLists.add(lblAdd, gcLabel);809 y++;810 gcList.gridy = y;811 pnlLists.add(spAdd, gcList);812 }813 if (!update.isEmpty()) {814 y++;815 gcLabel.gridy = y;816 lblUpdate.setText(trn("{0} object to modifiy:", "{0} objects to modify:", update.size(),update.size()));817 pnlLists.add(lblUpdate, gcLabel);818 y++;819 gcList.gridy = y;820 pnlLists.add(spUpdate, gcList);821 }822 if (!delete.isEmpty()) {823 y++;824 gcLabel.gridy = y;825 lblDelete.setText(trn("{0} object to delete:", "{0} objects to delete:", delete.size(),delete.size()));826 pnlLists.add(lblDelete, gcLabel);827 y++;828 gcList.gridy = y;829 pnlLists.add(spDelete, gcList);830 }831 }832 833 /**834 * Replies true if a valid changeset comment has been entered in this dialog835 *836 * @return true if a valid changeset comment has been entered in this dialog837 */838 public boolean hasChangesetComment() {839 if (!getChangesetProcessingType().isUseNew())840 return true;841 return cmt.getText().trim().length() >= 3;842 }843 844 /**845 * Remembers the user input in the preference settings846 */847 public void rememberUserInput() {848 // store the history of comments849 cmt.addCurrentItemToHistory();850 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory());851 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected());852 }853 854 /**855 * Initializes the panel for user input856 */857 public void startUserInput() {858 tagEditorPanel.initAutoCompletion(Main.main.getEditLayer());859 initChangesetProcessingType();860 cmt.getEditor().selectAll();861 cmt.requestFocus();862 }863 864 /**865 * Replies the current changeset processing type866 *867 * @return the current changeset processing type868 */869 public ChangesetProcessingType getChangesetProcessingType() {870 ChangesetProcessingType changesetProcessingType = null;871 for (ChangesetProcessingType type: ChangesetProcessingType.values()) {872 if (rbChangesetHandlingOptions.get(type).isSelected()) {873 changesetProcessingType = type;874 break;875 }876 }877 return changesetProcessingType == null ?878 ChangesetProcessingType.USE_NEW_AND_CLOSE :879 changesetProcessingType;880 }881 882 /**883 * Replies the current changeset884 *885 * @return the current changeset886 */887 public Changeset getChangeset() {888 Changeset changeset = new Changeset();889 tagEditorPanel.getModel().applyToPrimitive(changeset);890 changeset.put("comment", cmt.getText());891 return changeset;892 }893 894 /**895 * initializes the panel depending on the possible changeset processing896 * types897 */898 protected void initChangesetProcessingType() {899 for (ChangesetProcessingType type: ChangesetProcessingType.values()) {900 // show options for new changeset, disable others901 //902 rbChangesetHandlingOptions.get(type).setVisible(type.isUseNew());903 }904 if (OsmApi.getOsmApi().getCurrentChangeset() != null) {905 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset();906 for (ChangesetProcessingType type: ChangesetProcessingType.values()) {907 // show options for using existing changeset908 //909 if (!type.isUseNew()) {910 rbChangesetHandlingOptions.get(type).setVisible(true);911 }912 }913 JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE);914 rb.setText(tr("Use the existing changeset {0} and close it after upload",cs.getId()));915 rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to close the changeset after this upload",cs.getId()));916 917 rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN);918 rb.setText(tr("Use the existing changeset {0} and leave it open",cs.getId()));919 rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to leave the changeset open for further uploads",cs.getId()));920 921 rbChangesetHandlingOptions.get(getChangesetProcessingType()).setSelected(true);922 923 } else {924 ChangesetProcessingType type = getChangesetProcessingType();925 if (!type.isUseNew()) {926 type = ChangesetProcessingType.USE_NEW_AND_CLOSE;927 }928 rbChangesetHandlingOptions.get(type).setSelected(true);929 }930 refreshChangesetProcessingType(getChangesetProcessingType());931 }932 933 /**934 * refreshes the panel depending on a changeset processing type935 *936 * @param type the changeset processing type937 */938 protected void refreshChangesetProcessingType(ChangesetProcessingType type) {939 if (type.isUseNew()) {940 southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));941 Changeset cs = new Changeset();942 Properties sysProp = System.getProperties();943 Object ua = sysProp.get("http.agent");944 cs.put("created_by", (ua == null) ? "JOSM" : ua.toString());945 tagEditorPanel.getModel().initFromPrimitive(cs);946 } else {947 Changeset cs = OsmApi.getOsmApi().getCurrentChangeset();948 if (cs != null) {949 southTabbedPane.setTitleAt(1, tr("Tags of changeset {0}", cs.getId()));950 if (cs.get("comment") != null) {951 cmt.setText(cs.get("comment"));952 cs.remove("comment");953 }954 tagEditorPanel.getModel().initFromPrimitive(cs);955 }956 }957 }958 959 class ChangesetProcessingTypeChangedAction implements ActionListener {960 public void actionPerformed(ActionEvent e) {961 ChangesetProcessingType type = getChangesetProcessingType();962 refreshChangesetProcessingType(type);963 }964 }965 }966 550 } -
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r2070 r2081 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import javax.print.attribute.standard.MediaSize.Other; 5 7 6 8 import org.openstreetmap.josm.data.osm.visitor.Visitor; … … 23 25 */ 24 26 public String start_timestamp = null; 27 28 public Changeset() { 29 super(0); 30 } 31 32 public Changeset(long id) { 33 super(id); 34 } 35 36 public Changeset(Changeset clone){ 37 super(clone.getId()); 38 cloneFrom(clone); 39 } 25 40 26 41 @Override … … 49 64 return formatter.format(this); 50 65 } 66 67 68 @Override public void cloneFrom(OsmPrimitive osm) { 69 super.cloneFrom(osm); 70 } 51 71 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r2063 r2081 87 87 } 88 88 89 Main.pref.init(args.containsKey("reset-preferences"));90 91 89 // Check if passed as parameter 92 90 if (args.containsKey("language")) { … … 95 93 I18n.set(Main.pref.get("language", null)); 96 94 } 95 96 Main.pref.init(args.containsKey("reset-preferences")); 97 97 98 98 99 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { … … 115 116 "\t-Djosm.home="+tr("/PATH/TO/JOSM/FOLDER/ ")+tr("Change the folder for all user settings")+"\n\n"+ 116 117 tr("note: For some tasks, JOSM needs a lot of memory. It can be necessary to add the following\n" + 117 118 " Java option to increase the maximum size of allocated memory")+":\n"+ 118 119 "\t-Xmx...m\n\n"+ 119 120 tr("examples")+":\n"+ -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r2040 r2081 299 299 public void cancel() { 300 300 switch(model.getMode()) { 301 302 301 case EDITING_DATA: cancelWhenInEditingModel(); break; 302 case UPLOADING_AND_SAVING: cancelSafeAndUploadTask(); break; 303 303 } 304 304 } … … 334 334 Mode mode = (Mode)evt.getNewValue(); 335 335 switch(mode) { 336 337 336 case EDITING_DATA: setEnabled(true); break; 337 case UPLOADING_AND_SAVING: setEnabled(false); break; 338 338 } 339 339 } … … 368 368 SaveLayersModel.Mode mode = (SaveLayersModel.Mode)evt.getNewValue(); 369 369 switch(mode) { 370 371 370 case EDITING_DATA: setEnabled(true); break; 371 case UPLOADING_AND_SAVING: setEnabled(false); break; 372 372 } 373 373 } … … 411 411 layerInfo.getLayer(), 412 412 monitor, 413 UploadAction.UploadConfirmationHook.getUploadDialog Panel().getChangeset(),414 UploadAction.UploadConfirmationHook.getUploadDialog Panel().getChangesetProcessingType()413 UploadAction.UploadConfirmationHook.getUploadDialog().getChangeset(), 414 UploadAction.UploadConfirmationHook.getUploadDialog().getChangesetProcessingType() 415 415 ); 416 416 currentFuture = worker.submit(currentTask); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r2040 r2081 9 9 import java.util.Collection; 10 10 import java.util.Comparator; 11 import java.util.Iterator; 11 12 import java.util.List; 12 13 import java.util.logging.Logger; … … 216 217 217 218 /** 219 * Deletes all tags with name <code>name</code> 220 * 221 * @param name the name. Ignored if null. 222 */ 223 public void delete(String name) { 224 if (name == null) return; 225 Iterator<TagModel> it = tags.iterator(); 226 while(it.hasNext()) { 227 TagModel tm = it.next(); 228 if (tm.getName().equals(name)) { 229 it.remove(); 230 } 231 } 232 fireTableDataChanged(); 233 setDirty(true); 234 } 235 /** 218 236 * deletes the tags given by tagIndices 219 237 * -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2078 r2081 7 7 import java.util.Collection; 8 8 import java.util.LinkedList; 9 import java.util.List;10 9 import java.util.logging.Logger; 11 10 12 11 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.actions.UploadAction;14 12 import org.openstreetmap.josm.data.osm.Changeset; 15 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 61 59 time_left_str += Integer.toString(seconds_left); 62 60 return time_left_str; 63 }64 65 /**66 * retrieves the most recent changeset comment from the preferences67 *68 * @return the most recent changeset comment69 */70 protected String getChangesetComment() {71 String cmt = "";72 List<String> history = new LinkedList<String>(73 Main.pref.getCollection(UploadAction.HISTORY_KEY, new LinkedList<String>()));74 if(history.size() > 0) {75 cmt = history.get(0);76 }77 return cmt;78 61 } 79 62
Note:
See TracChangeset
for help on using the changeset viewer.