Changeset 6654 in josm


Ignore:
Timestamp:
2014-01-06T21:46:07+01:00 (11 years ago)
Author:
simon04
Message:

fix #9514 fix #9484 fix #9502 - Upload dialog: make source field behave like comment field, provide link "obtain from current layers" to insert current layers in field, display Bing layer as "Bing"

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r6631 r6654  
    234234                final HashMap<String, String> tags = new HashMap<String, String>(layer.data.getChangeSetTags());
    235235                if (!tags.containsKey("source")) {
    236                     tags.put("source", Main.map.mapView.getLayerInformationForSourceTag());
     236                    tags.put("source", dialog.getLastChangesetSourceFromHistory());
    237237                }
    238238                if (!tags.containsKey("comment")) {
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r6567 r6654  
    4545import org.openstreetmap.josm.data.coor.EastNorth;
    4646import org.openstreetmap.josm.data.coor.LatLon;
     47import org.openstreetmap.josm.data.imagery.ImageryInfo;
    4748import org.openstreetmap.josm.data.osm.DataSet;
    4849import org.openstreetmap.josm.data.osm.DataSource;
     
    979980        }
    980981        for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) {
    981             layerInfo.add(i.getName());
     982            layerInfo.add(ImageryInfo.ImageryType.BING.equals(i.getInfo().getImageryType()) ? "Bing" : i.getName());
    982983        }
    983984        return Utils.join("; ", layerInfo);
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r6631 r6654  
    2121import javax.swing.Action;
    2222import javax.swing.BorderFactory;
    23 import javax.swing.JLabel;
     23import javax.swing.JEditorPane;
    2424import javax.swing.JPanel;
     25import javax.swing.event.HyperlinkEvent;
     26import javax.swing.event.HyperlinkListener;
    2527
    2628import org.openstreetmap.josm.Main;
    2729import org.openstreetmap.josm.data.osm.Changeset;
    2830import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
     31import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
    2932import org.openstreetmap.josm.tools.CheckParameterUtil;
    3033import org.openstreetmap.josm.tools.GBC;
     
    5457        pnl.setLayout(new GridBagLayout());
    5558
    56         pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3));
     59        final JEditorPane commentLabel = JosmEditorPane.createJLabelLikePane();
     60        commentLabel.setText("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
     61        pnl.add(commentLabel, GBC.eol().insets(0, 5, 10, 3));
    5762        hcbUploadComment.setToolTipText(tr("Enter an upload comment"));
    5863        hcbUploadComment.setMaxTextLength(Changeset.MAX_COMMENT_LENGTH);
     
    6570        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    6671
    67         pnl.add(new JLabel(tr("Specify the data source for the changes:")), GBC.eol().insets(0, 8, 10, 3));
     72        final JEditorPane sourceLabel = JosmEditorPane.createJLabelLikePane();
     73        sourceLabel.setText("<html><b>" + tr("Specify the data source for the changes")
     74                + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>");
     75        sourceLabel.addHyperlinkListener(new HyperlinkListener() {
     76            @Override
     77            public void hyperlinkUpdate(HyperlinkEvent e) {
     78                if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
     79                    hcbUploadSource.setText(Main.map.mapView.getLayerInformationForSourceTag());
     80                }
     81            }
     82        });
     83        pnl.add(sourceLabel, GBC.eol().insets(0, 8, 10, 3));
     84
    6885        hcbUploadSource.setToolTipText(tr("Enter a source"));
    69         List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey")));
     86        List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey", "Bing")));
    7087        Collections.reverse(sourceHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    7188        hcbUploadSource.setPossibleItems(sourceHistory);
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r6631 r6654  
    590590    }
    591591
    592     public String getLastChangesetCommentFromHistory() {
    593         Collection<String> history = Main.pref.getCollection(BasicUploadSettingsPanel.HISTORY_KEY, new ArrayList<String>());
     592    private String getLastChangesetTagFromHistory(String historyKey) {
     593        Collection<String> history = Main.pref.getCollection(historyKey, new ArrayList<String>());
    594594        int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0));
    595595        if (age < Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, 4 * 3600 * 1000) && history != null && !history.isEmpty()) {
     
    599599        }
    600600    }
     601
     602    public String getLastChangesetCommentFromHistory() {
     603        return getLastChangesetTagFromHistory(BasicUploadSettingsPanel.HISTORY_KEY);
     604    }
     605
     606    public String getLastChangesetSourceFromHistory() {
     607        return getLastChangesetTagFromHistory(BasicUploadSettingsPanel.SOURCE_HISTORY_KEY);
     608    }
    601609}
  • trunk/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java

    r6084 r6654  
    66
    77import java.awt.BorderLayout;
    8 import java.awt.Font;
    98import java.beans.PropertyChangeEvent;
    109import java.beans.PropertyChangeListener;
    11 import java.text.MessageFormat;
    1210
    1311import javax.swing.BorderFactory;
    1412import javax.swing.JLabel;
    1513import javax.swing.JPanel;
    16 import javax.swing.UIManager;
    1714import javax.swing.event.HyperlinkEvent;
    1815import javax.swing.event.HyperlinkListener;
    19 import javax.swing.text.html.StyleSheet;
    2016
    2117import org.openstreetmap.josm.data.osm.Changeset;
    2218import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
    23 import org.openstreetmap.josm.gui.widgets.JosmHTMLEditorKit;
    2419import org.openstreetmap.josm.io.OsmApi;
    2520import org.openstreetmap.josm.tools.ImageProvider;
     
    10499
    105100    protected void build() {
    106         jepMessage = new JosmEditorPane("text/html", "");
    107         jepMessage.setOpaque(false);
    108         jepMessage.setEditable(false);
     101        jepMessage = JosmEditorPane.createJLabelLikePane();
    109102        jepMessage.addHyperlinkListener(this);
    110         Font f = UIManager.getFont("Label.font");
    111         StyleSheet ss = new StyleSheet();
    112         String rule = MessageFormat.format(
    113                 "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
    114                 f.getName(),
    115                 f.getSize(),
    116                 f.isBold() ? "bold" : "normal",
    117                         f.isItalic() ? "italic" : "normal"
    118         );
    119         rule = "body {" + rule + "}";
    120         rule = MessageFormat.format(
    121                 "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
    122                 f.getName(),
    123                 f.getSize(),
    124                 "bold",
    125                 f.isItalic() ? "italic" : "normal"
    126         );
    127         rule = "strong {" + rule + "}";
    128         ss.addRule(rule);
    129         ss.addRule("a {text-decoration: underline; color: blue}");
    130         JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
    131         kit.setStyleSheet(ss);
    132         jepMessage.setEditorKit(kit);
    133103
    134104        setLayout(new BorderLayout());
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

    r5887 r6654  
    22package org.openstreetmap.josm.gui.widgets;
    33
     4import java.awt.Font;
    45import java.io.IOException;
    56import java.io.InputStream;
    67import java.net.URL;
    78import java.net.URLConnection;
     9import java.text.MessageFormat;
    810
    911import javax.swing.JEditorPane;
     12import javax.swing.UIManager;
     13import javax.swing.text.html.StyleSheet;
    1014
    1115import org.openstreetmap.josm.tools.Utils;
     
    7579        return result;
    7680    }
     81
     82    /**
     83     * Creates a {@link JosmEditorPane} which is meant to be used as a powerful replacement of {@link javax.swing.JLabel}.
     84     */
     85    public static JosmEditorPane createJLabelLikePane() {
     86        final JosmEditorPane pane = new JosmEditorPane("text/html", "");
     87        pane.setOpaque(false);
     88        pane.setEditable(false);
     89
     90        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
     91        final Font f = UIManager.getFont("Label.font");
     92        final StyleSheet ss = new StyleSheet();
     93        final String rule = MessageFormat.format(
     94                "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
     95                f.getName(),
     96                f.getSize(),
     97                "bold",
     98                f.isItalic() ? "italic" : "normal"
     99        );
     100        ss.addRule("strong {" + rule + "}");
     101        ss.addRule("a {text-decoration: underline; color: blue}");
     102        kit.setStyleSheet(ss);
     103        pane.setEditorKit(kit);
     104
     105        return pane;
     106    }
    77107}
Note: See TracChangeset for help on using the changeset viewer.