Ticket #3764: 3764.patch

File 3764.patch, 19.1 KB (added by simon04, 11 years ago)
  • src/org/openstreetmap/josm/Main.java

    diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
    index ecc19d7..3c90e3e 100644
    a b import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;  
    8787import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    8888import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
    8989import org.openstreetmap.josm.gui.util.RedirectInputMap;
     90import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    9091import org.openstreetmap.josm.io.OsmApi;
    9192import org.openstreetmap.josm.tools.CheckParameterUtil;
    9293import org.openstreetmap.josm.tools.I18n;
    abstract public class Main {  
    10781079                    version.startsWith("1.9") || version.startsWith("9"))
    10791080                return;
    10801081            if (version.startsWith("1.5") || version.startsWith("5")) {
    1081                 JLabel ho = new JLabel("<html>"+
     1082                JMultilineLabel ho = new JMultilineLabel("<html>"+
    10821083                        tr("<h2>JOSM requires Java version 6.</h2>"+
    10831084                                "Detected Java version: {0}.<br>"+
    10841085                                "You can <ul><li>update your Java (JRE) or</li>"+
  • src/org/openstreetmap/josm/actions/AboutAction.java

    diff --git a/src/org/openstreetmap/josm/actions/AboutAction.java b/src/org/openstreetmap/josm/actions/AboutAction.java
    index 08dc17b..1b96bd3 100644
    a b import javax.swing.JOptionPane;  
    1414import javax.swing.JPanel;
    1515import javax.swing.JScrollPane;
    1616import javax.swing.JTabbedPane;
     17import javax.swing.text.DefaultEditorKit;
    1718
    1819import org.openstreetmap.josm.Main;
    1920import org.openstreetmap.josm.data.Version;
    2021import org.openstreetmap.josm.gui.util.GuiHelper;
     22import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2123import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    2224import org.openstreetmap.josm.gui.widgets.UrlLabel;
    2325import org.openstreetmap.josm.plugins.PluginHandler;
    public class AboutAction extends JosmAction {  
    7375        license.setCaretPosition(0);
    7476
    7577        JPanel info = new JPanel(new GridBagLayout());
    76         JLabel caption = new JLabel("JOSM – " + tr("Java OpenStreetMap Editor"));
    77         caption.setFont(GuiHelper.getTitleFont());
    78         info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
    79         info.add(GBC.glue(0,10), GBC.eol());
    80         info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
    81         info.add(GBC.glue(0,5), GBC.eol());
    82         info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
    83         info.add(GBC.glue(0,5), GBC.eol());
    84         info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));
    85         info.add(GBC.glue(0,10), GBC.eol());
     78        final JMultilineLabel label = new JMultilineLabel("<html>" +
     79                "<h1>" + "JOSM – " + tr("Java OpenStreetMap Editor") + "</h1>" +
     80                "<p style='font-size:75%'></p>" +
     81                "<p>" + tr("Version {0}", version.getVersionString()) + "</p>" +
     82                "<p style='font-size:50%'></p>" +
     83                "<p>" + tr("Last change at {0}", version.getTime()) + "</p>" +
     84                "<p style='font-size:50%'></p>" +
     85                "<p>" + tr("Java Version {0}", System.getProperty("java.version")) + "</p>" +
     86                "<p style='font-size:50%'></p>" +
     87                "</html>");
     88        info.add(label, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0));
    8689        info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
    8790        info.add(new UrlLabel(Main.JOSM_WEBSITE,2), GBC.eol().fill(GBC.HORIZONTAL));
    8891        info.add(GBC.glue(0,5), GBC.eol());
  • src/org/openstreetmap/josm/command/Command.java

    diff --git a/src/org/openstreetmap/josm/command/Command.java b/src/org/openstreetmap/josm/command/Command.java
    index 108c29c..fb47b2d 100644
    a b import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;  
    2626import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    2727import org.openstreetmap.josm.gui.layer.Layer;
    2828import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     29import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2930import org.openstreetmap.josm.tools.CheckParameterUtil;
    3031
    3132/**
    abstract public class Command extends PseudoCommand {  
    210211        }
    211212        if (outside) {
    212213            JPanel msg = new JPanel(new GridBagLayout());
    213             msg.add(new JLabel("<html>" + outsideDialogMessage + "</html>"));
     214            msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>"));
    214215            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    215216                    operation + "_outside_nodes",
    216217                    Main.parent,
    abstract public class Command extends PseudoCommand {  
    224225        }
    225226        if (incomplete) {
    226227            JPanel msg = new JPanel(new GridBagLayout());
    227             msg.add(new JLabel("<html>" + incompleteDialogMessage + "</html>"));
     228            msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>"));
    228229            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    229230                    operation + "_incomplete",
    230231                    Main.parent,
  • src/org/openstreetmap/josm/command/DeleteCommand.java

    diff --git a/src/org/openstreetmap/josm/command/DeleteCommand.java b/src/org/openstreetmap/josm/command/DeleteCommand.java
    index a63f4f0..38703a1 100644
    a b import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;  
    3737import org.openstreetmap.josm.gui.DefaultNameFormatter;
    3838import org.openstreetmap.josm.gui.actionsupport.DeleteFromRelationConfirmationDialog;
    3939import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     40import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    4041import org.openstreetmap.josm.tools.CheckParameterUtil;
    4142import org.openstreetmap.josm.tools.ImageProvider;
    4243import org.openstreetmap.josm.tools.Utils;
    public class DeleteCommand extends Command {  
    465466
    466467    private static boolean confirmRelationDeletion(Collection<Relation> relations) {
    467468        JPanel msg = new JPanel(new GridBagLayout());
    468         msg.add(new JLabel("<html>" + trn(
     469        msg.add(new JMultilineLabel("<html>" + trn(
    469470                "You are about to delete {0} relation: {1}"
    470471                + "<br/>"
    471472                + "This step is rarely necessary and cannot be undone easily after being uploaded to the server."
  • src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java

    diff --git a/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java b/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
    index 2dd5843..1d99441 100644
    a b import javax.swing.JPanel;  
    1818import javax.swing.JRadioButton;
    1919
    2020import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2122import org.openstreetmap.josm.tools.GBC;
    2223import org.openstreetmap.josm.tools.Utils;
    2324
    public final class ConditionalOptionPaneUtil {  
    270271            if (message instanceof Component) {
    271272                add((Component) message, GBC.eop());
    272273            } else if (message != null) {
    273                 add(new JLabel(message.toString()), GBC.eop());
     274                add(new JMultilineLabel(message.toString()), GBC.eop());
    274275            }
    275276            add(cbShowPermanentDialog, GBC.eol());
    276277            add(cbShowSessionDialog, GBC.eol());
  • src/org/openstreetmap/josm/gui/SplashScreen.java

    diff --git a/src/org/openstreetmap/josm/gui/SplashScreen.java b/src/org/openstreetmap/josm/gui/SplashScreen.java
    index 6dd4bab..4a7c87f 100644
    a b public class SplashScreen extends JFrame {  
    6464        innerContentPane.add(logo, gbc);
    6565
    6666        // Add the name of this application
    67         JLabel caption = new JLabel("JOSM - " + tr("Java OpenStreetMap Editor"));
     67        JLabel caption = new JLabel("JOSM " + tr("Java OpenStreetMap Editor"));
    6868        caption.setFont(GuiHelper.getTitleFont());
    6969        gbc.gridheight = 1;
    7070        gbc.gridx = 1;
  • src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java b/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
    index 3a3a022..c102484 100644
    a b import javax.swing.event.HyperlinkListener;  
    2828import org.openstreetmap.josm.Main;
    2929import org.openstreetmap.josm.data.osm.Changeset;
    3030import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
     31import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    3132import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
    3233import org.openstreetmap.josm.tools.CheckParameterUtil;
    3334import org.openstreetmap.josm.tools.GBC;
    public class BasicUploadSettingsPanel extends JPanel {  
    5556    protected JPanel buildUploadCommentPanel() {
    5657        JPanel pnl = new JPanel(new GridBagLayout());
    5758
    58         final JEditorPane commentLabel = JosmEditorPane.createJLabelLikePane();
    59         commentLabel.setText("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
     59        final JEditorPane commentLabel = new JMultilineLabel("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
    6060        pnl.add(commentLabel, GBC.eol().insets(0, 5, 10, 3).fill(GBC.HORIZONTAL));
    6161        hcbUploadComment.setToolTipText(tr("Enter an upload comment"));
    6262        hcbUploadComment.setMaxTextLength(Changeset.MAX_COMMENT_LENGTH);
    public class BasicUploadSettingsPanel extends JPanel {  
    6868        hcbUploadComment.getEditor().getEditorComponent().addFocusListener(commentModelListener);
    6969        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    7070
    71         final JEditorPane sourceLabel = JosmEditorPane.createJLabelLikePane();
    72         sourceLabel.setText("<html><b>" + tr("Specify the data source for the changes")
     71        final JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes")
    7372                + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>");
    7473        sourceLabel.addHyperlinkListener(new HyperlinkListener() {
    7574            @Override
  • src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java b/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java
    index 2fd44a4..53afe08 100644
    a b import javax.swing.event.HyperlinkEvent;  
    1515import javax.swing.event.HyperlinkListener;
    1616
    1717import org.openstreetmap.josm.data.osm.Changeset;
     18import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    1819import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
    1920import org.openstreetmap.josm.io.OsmApi;
    2021import org.openstreetmap.josm.tools.ImageProvider;
    import org.openstreetmap.josm.tools.ImageProvider;  
    2324public class UploadParameterSummaryPanel extends JPanel implements HyperlinkListener, PropertyChangeListener{
    2425    private UploadStrategySpecification spec = new UploadStrategySpecification();
    2526    private int numObjects;
    26     private JosmEditorPane jepMessage;
     27    private JMultilineLabel jepMessage;
    2728    private JLabel lblWarning;
    2829
    2930    private Changeset selectedChangeset;
    public class UploadParameterSummaryPanel extends JPanel implements HyperlinkList  
    9899    }
    99100
    100101    protected void build() {
    101         jepMessage = JosmEditorPane.createJLabelLikePane();
     102        jepMessage = new JMultilineLabel("");
    102103        jepMessage.addHyperlinkListener(this);
    103104
    104105        setLayout(new BorderLayout());
  • src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java b/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
    index df8082e..31f562b 100644
    a b public class UploadStrategySelectionPanel extends JPanel implements PropertyChan  
    107107        gc.weightx = 0.0;
    108108        gc.weighty = 0.0;
    109109        gc.gridwidth = 2;
    110         JLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
     110        JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    111111        lbl.setText(tr("Upload data in one request"));
    112112        pnl.add(lbl, gc);
    113113        gc.gridx = 3;
    public class UploadStrategySelectionPanel extends JPanel implements PropertyChan  
    319319        int maxChunkSize = OsmApi.getOsmApi().getCapabilities().getMaxChangesetSize();
    320320        if (maxChunkSize > 0 && numUploadedObjects > maxChunkSize) {
    321321            rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY).setEnabled(false);
    322             JLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    323             lbl.setIcon(ImageProvider.get("warning-small.png"));
     322            JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    324323            lbl.setText(tr("Upload in one request not possible (too many objects to upload)"));
    325324            lbl.setToolTipText(tr("<html>Cannot upload {0} objects in one request because the<br>"
    326325                    + "max. changeset size {1} on server ''{2}'' is exceeded.</html>",
    public class UploadStrategySelectionPanel extends JPanel implements PropertyChan  
    340339
    341340        } else {
    342341            rbStrategy.get(UploadStrategy.SINGLE_REQUEST_STRATEGY).setEnabled(true);
    343             JLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
     342            JMultilineLabel lbl = lblStrategies.get(UploadStrategy.SINGLE_REQUEST_STRATEGY);
    344343            lbl.setText(tr("Upload data in one request"));
    345             lbl.setIcon(null);
    346344            lbl.setToolTipText("");
    347345            lblNumRequests.get(UploadStrategy.SINGLE_REQUEST_STRATEGY).setVisible(true);
    348346
  • src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java b/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
    index 8bfe243..71945ba 100644
    a b public class OAuthAuthenticationPreferencesPanel extends JPanel implements Prope  
    188188            gc.insets = new Insets(0,0,3,0);
    189189            gc.fill = GridBagConstraints.HORIZONTAL;
    190190            gc.weightx = 1.0;
    191             JLabel lbl;
     191            JMultilineLabel lbl;
    192192            add(lbl = new JMultilineLabel(tr("You do not have an Access Token yet to access the OSM server using OAuth. Please authorize first.")), gc);
    193193            lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    194194
    public class OAuthAuthenticationPreferencesPanel extends JPanel implements Prope  
    227227            gc.fill = GridBagConstraints.HORIZONTAL;
    228228            gc.weightx = 1.0;
    229229            gc.gridwidth = 2;
    230             JLabel lbl;
     230            JMultilineLabel lbl;
    231231            add(lbl = new JMultilineLabel(tr("You already have an Access Token to access the OSM server using OAuth.")), gc);
    232232            lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    233233
  • src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java

    diff --git a/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java b/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java
    index b7b6362..c954168 100644
    a b package org.openstreetmap.josm.gui.widgets;  
    44import java.awt.Dimension;
    55import java.awt.Rectangle;
    66
     7import javax.swing.JEditorPane;
    78import javax.swing.JLabel;
    89import javax.swing.plaf.basic.BasicHTML;
     10import javax.swing.text.Caret;
    911import javax.swing.text.View;
    1012
    1113/**
    import javax.swing.text.View;  
    1820 *
    1921 * @since 6340
    2022 */
    21 public class JMultilineLabel extends JLabel {
     23public class JMultilineLabel extends JEditorPane {
    2224    private int maxWidth = Integer.MAX_VALUE;
    2325    private Rectangle oldbounds = null;
    2426    private Dimension oldPreferred = null;
    public class JMultilineLabel extends JLabel {  
    3234     * @param text The text to display
    3335     */
    3436    public JMultilineLabel(String text) {
     37        this(text, true);
     38    }
     39
     40    public JMultilineLabel(String text, boolean allBold) {
    3541        super();
     42        JosmEditorPane.makeJLabelLike(this, allBold);
    3643        String html = text.trim().replaceAll("\n", "<br>");
    3744        if (!html.startsWith("<html>")) {
    3845            html = "<html>" + html + "</html>";
  • src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

    diff --git a/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java b/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
    index 3c66559..4bef38c 100644
    a b import javax.swing.JEditorPane;  
    1212import javax.swing.UIManager;
    1313import javax.swing.text.html.StyleSheet;
    1414
     15import org.openstreetmap.josm.gui.util.GuiHelper;
    1516import org.openstreetmap.josm.tools.Utils;
    1617
    1718/**
    public class JosmEditorPane extends JEditorPane {  
    8081    }
    8182
    8283    /**
    83      * Creates a {@link JosmEditorPane} which is meant to be used as a powerful replacement of {@link javax.swing.JLabel}.
     84     * Adapts an {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}.
    8485     */
    85     public static JosmEditorPane createJLabelLikePane() {
    86         final JosmEditorPane pane = new JosmEditorPane("text/html", "");
     86    public static void makeJLabelLike(JEditorPane pane, boolean allBold) {
     87        pane.setContentType("text/html");
    8788        pane.setOpaque(false);
    8889        pane.setEditable(false);
    8990
    9091        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
    9192        final Font f = UIManager.getFont("Label.font");
    9293        final StyleSheet ss = new StyleSheet();
    93         final String rule = MessageFormat.format(
     94        ss.addRule((allBold ? "html" : "strong, b") + " {" + getFontRule(f) + "}");
     95        ss.addRule("a {text-decoration: underline; color: blue}");
     96        ss.addRule("h1 {" + getFontRule(GuiHelper.getTitleFont()) + "}");
     97        kit.setStyleSheet(ss);
     98        pane.setEditorKit(kit);
     99    }
     100
     101    private static String getFontRule(Font f) {
     102        return MessageFormat.format(
    94103                "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
    95104                f.getName(),
    96105                f.getSize(),
    97106                "bold",
    98107                f.isItalic() ? "italic" : "normal"
    99108        );
    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;
    106109    }
    107110}