Changeset 15600 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-12-19T00:30:56+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18429 - Allow users to automatically get the source tags (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r15117 r15600  
    2222import javax.swing.JCheckBox;
    2323import javax.swing.JEditorPane;
     24import javax.swing.JLabel;
    2425import javax.swing.JPanel;
    2526import javax.swing.event.ChangeEvent;
     
    8283        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    8384
    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 -> {
    8790            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();
    9192            }
    9293        });
    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();
     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));
    94107
    95108        hcbUploadSource.setToolTipText(tr("Enter a source"));
     
    100113        hcbUploadSource.getEditorComponent().addFocusListener(sourceModelListener);
    101114        pnl.add(hcbUploadSource, GBC.eol().fill(GBC.HORIZONTAL));
     115        if (obtainSourceAutomatically.isSelected()) {
     116            automaticallyAddSource();
     117        }
    102118        return pnl;
     119    }
     120
     121    /**
     122     * Add the source tags
     123     */
     124    protected void automaticallyAddSource() {
     125        final String source = MainApplication.getMap().mapView.getLayerInformationForSourceTag();
     126        hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH));
     127        changesetSourceModel.setComment(hcbUploadSource.getText()); // Fix #9965
    103128    }
    104129
Note: See TracChangeset for help on using the changeset viewer.