Ticket #18429: 18429.patch
File 18429.patch, 4.0 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
21 21 import javax.swing.BorderFactory; 22 22 import javax.swing.JCheckBox; 23 23 import javax.swing.JEditorPane; 24 import javax.swing.JLabel; 24 25 import javax.swing.JPanel; 25 26 import javax.swing.event.ChangeEvent; 26 27 import javax.swing.event.ChangeListener; … … 81 82 hcbUploadComment.getEditorComponent().addFocusListener(commentModelListener); 82 83 pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL)); 83 84 84 JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes") 85 + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>"); 86 sourceLabel.addHyperlinkListener(e -> { 85 JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes") + ":</b>"); 86 pnl.add(sourceLabel, GBC.eol().insets(0, 8, 10, 0).fill(GBC.HORIZONTAL)); 87 JEditorPane obtainSourceOnce = new JMultilineLabel( 88 "<html><a href=\"urn:changeset-source\">" + tr("just once") + "</a></html>"); 89 obtainSourceOnce.addHyperlinkListener(e -> { 87 90 if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { 88 final String source = MainApplication.getMap().mapView.getLayerInformationForSourceTag(); 89 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH)); 90 changesetSourceModel.setComment(hcbUploadSource.getText()); // Fix #9965 91 automaticallyAddSource(); 91 92 } 92 93 }); 93 pnl.add(sourceLabel, GBC.eol().insets(0, 8, 10, 3).fill(GBC.HORIZONTAL)); 94 JCheckBox obtainSourceAutomatically = new JCheckBox(tr("Automatically obtain source from current layers")); 95 obtainSourceAutomatically.setSelected(Config.getPref().getBoolean("upload.source.obtainautomatically", false)); 96 obtainSourceAutomatically.addActionListener(e -> { 97 if (obtainSourceAutomatically.isSelected()) 98 automaticallyAddSource(); 94 99 100 obtainSourceOnce.setVisible(!obtainSourceAutomatically.isSelected()); 101 }); 102 JPanel obtainSource = new JPanel(new GridBagLayout()); 103 obtainSource.add(obtainSourceAutomatically, GBC.std().anchor(GBC.WEST)); 104 obtainSource.add(obtainSourceOnce, GBC.std().anchor(GBC.WEST)); 105 obtainSource.add(new JLabel(), GBC.eol().fill(GBC.HORIZONTAL)); 106 pnl.add(obtainSource, GBC.eol().insets(0, 0, 10, 3).fill(GBC.HORIZONTAL)); 107 95 108 hcbUploadSource.setToolTipText(tr("Enter a source")); 96 109 hcbUploadSource.setMaxTextLength(Changeset.MAX_CHANGESET_TAG_LENGTH); 97 110 populateHistoryComboBox(hcbUploadSource, SOURCE_HISTORY_KEY, getDefaultSources()); … … 99 112 hcbUploadSource.getEditor().addActionListener(sourceModelListener); 100 113 hcbUploadSource.getEditorComponent().addFocusListener(sourceModelListener); 101 114 pnl.add(hcbUploadSource, GBC.eol().fill(GBC.HORIZONTAL)); 115 if (obtainSourceAutomatically.isSelected()) { 116 automaticallyAddSource(); 117 } 102 118 return pnl; 103 119 } 104 120 105 121 /** 122 * Add the source tags 123 * 124 * @param resetIfSame If {@code true} reset if the last source and this source 125 * are the same 126 */ 127 protected void automaticallyAddSource() { 128 final String source = MainApplication.getMap().mapView.getLayerInformationForSourceTag(); 129 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH)); 130 changesetSourceModel.setComment(hcbUploadSource.getText()); // Fix #9965 131 } 132 133 /** 106 134 * Refreshes contents of upload history combo boxes from preferences. 107 135 */ 108 136 protected void refreshHistoryComboBoxes() {