Changeset 6901 in josm for trunk


Ignore:
Timestamp:
2014-03-07T11:35:00+01:00 (10 years ago)
Author:
Don-vip
Message:

see #3764 - make UI messages copy-able (patch by simon04)

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

Legend:

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

    r6900 r6901  
    3737import javax.swing.JComponent;
    3838import javax.swing.JFrame;
    39 import javax.swing.JLabel;
    4039import javax.swing.JOptionPane;
    4140import javax.swing.JPanel;
     
    8887import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
    8988import org.openstreetmap.josm.gui.util.RedirectInputMap;
     89import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    9090import org.openstreetmap.josm.io.OsmApi;
    9191import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    11231123                return;
    11241124            if (version.startsWith("1.5") || version.startsWith("5")) {
    1125                 JLabel ho = new JLabel("<html>"+
     1125                JMultilineLabel ho = new JMultilineLabel("<html>"+
    11261126                        tr("<h2>JOSM requires Java version 6.</h2>"+
    11271127                                "Detected Java version: {0}.<br>"+
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r6897 r6901  
    1919import org.openstreetmap.josm.data.Version;
    2020import org.openstreetmap.josm.gui.util.GuiHelper;
     21import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2122import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    2223import org.openstreetmap.josm.gui.widgets.UrlLabel;
     
    7475
    7576        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());
     77        final JMultilineLabel label = new JMultilineLabel("<html>" +
     78                "<h1>" + "JOSM – " + tr("Java OpenStreetMap Editor") + "</h1>" +
     79                "<p style='font-size:75%'></p>" +
     80                "<p>" + tr("Version {0}", version.getVersionString()) + "</p>" +
     81                "<p style='font-size:50%'></p>" +
     82                "<p>" + tr("Last change at {0}", version.getTime()) + "</p>" +
     83                "<p style='font-size:50%'></p>" +
     84                "<p>" + tr("Java Version {0}", System.getProperty("java.version")) + "</p>" +
     85                "<p style='font-size:50%'></p>" +
     86                "</html>");
     87        info.add(label, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0));
    8688        info.add(new JLabel(tr("Homepage")), GBC.std().insets(10,0,10,0));
    8789        info.add(new UrlLabel(Main.getJOSMWebsite(),2), GBC.eol().fill(GBC.HORIZONTAL));
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r6883 r6901  
    1010import java.util.Map.Entry;
    1111
    12 import javax.swing.JLabel;
    1312import javax.swing.JOptionPane;
    1413import javax.swing.JPanel;
     
    2625import org.openstreetmap.josm.gui.layer.Layer;
    2726import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     27import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2828import org.openstreetmap.josm.tools.CheckParameterUtil;
    2929
     
    210210        if (outside) {
    211211            JPanel msg = new JPanel(new GridBagLayout());
    212             msg.add(new JLabel("<html>" + outsideDialogMessage + "</html>"));
     212            msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>"));
    213213            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    214214                    operation + "_outside_nodes",
     
    224224        if (incomplete) {
    225225            JPanel msg = new JPanel(new GridBagLayout());
    226             msg.add(new JLabel("<html>" + incompleteDialogMessage + "</html>"));
     226            msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>"));
    227227            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
    228228                    operation + "_incomplete",
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r6881 r6901  
    2020
    2121import javax.swing.Icon;
    22 import javax.swing.JLabel;
    2322import javax.swing.JOptionPane;
    2423import javax.swing.JPanel;
     
    3837import org.openstreetmap.josm.gui.actionsupport.DeleteFromRelationConfirmationDialog;
    3938import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     39import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    4040import org.openstreetmap.josm.tools.CheckParameterUtil;
    4141import org.openstreetmap.josm.tools.ImageProvider;
     
    464464    private static boolean confirmRelationDeletion(Collection<Relation> relations) {
    465465        JPanel msg = new JPanel(new GridBagLayout());
    466         msg.add(new JLabel("<html>" + trn(
     466        msg.add(new JMultilineLabel("<html>" + trn(
    467467                "You are about to delete {0} relation: {1}"
    468468                + "<br/>"
  • trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java

    r6889 r6901  
    1313
    1414import javax.swing.ButtonGroup;
    15 import javax.swing.JLabel;
    1615import javax.swing.JOptionPane;
    1716import javax.swing.JPanel;
     
    1918
    2019import org.openstreetmap.josm.Main;
     20import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2121import org.openstreetmap.josm.tools.GBC;
    2222import org.openstreetmap.josm.tools.Utils;
     
    271271                add((Component) message, GBC.eop());
    272272            } else if (message != null) {
    273                 add(new JLabel(message.toString()), GBC.eop());
     273                add(new JMultilineLabel(message.toString()), GBC.eop());
    274274            }
    275275            add(cbShowPermanentDialog, GBC.eol());
  • trunk/src/org/openstreetmap/josm/gui/SplashScreen.java

    r6889 r6901  
    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;
     
    107107    }
    108108
     109    /**
     110     * Returns the progress monitor.
     111     * @return The progress monitor
     112     */
    109113    public ProgressMonitor getProgressMonitor() {
    110114        return progressMonitor;
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r6660 r6901  
    2929import org.openstreetmap.josm.data.osm.Changeset;
    3030import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    31 import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
     31import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    3232import org.openstreetmap.josm.tools.CheckParameterUtil;
    3333import org.openstreetmap.josm.tools.GBC;
     
    5656        JPanel pnl = new JPanel(new GridBagLayout());
    5757
    58         final JEditorPane commentLabel = JosmEditorPane.createJLabelLikePane();
    59         commentLabel.setText("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
     58        final JEditorPane commentLabel = new JMultilineLabel("<html><b>" + tr("Provide a brief comment for the changes you are uploading:"));
    6059        pnl.add(commentLabel, GBC.eol().insets(0, 5, 10, 3).fill(GBC.HORIZONTAL));
    6160        hcbUploadComment.setToolTipText(tr("Enter an upload comment"));
     
    6968        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    7069
    71         final JEditorPane sourceLabel = JosmEditorPane.createJLabelLikePane();
    72         sourceLabel.setText("<html><b>" + tr("Specify the data source for the changes")
     70        final JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes")
    7371                + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>");
    7472        sourceLabel.addHyperlinkListener(new HyperlinkListener() {
  • trunk/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java

    r6822 r6901  
    1616
    1717import org.openstreetmap.josm.data.osm.Changeset;
    18 import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
     18import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    1919import org.openstreetmap.josm.io.OsmApi;
    2020import org.openstreetmap.josm.tools.ImageProvider;
     
    2424    private UploadStrategySpecification spec = new UploadStrategySpecification();
    2525    private int numObjects;
    26     private JosmEditorPane jepMessage;
     26    private JMultilineLabel jepMessage;
    2727    private JLabel lblWarning;
    2828
     
    9999
    100100    protected void build() {
    101         jepMessage = JosmEditorPane.createJLabelLikePane();
     101        jepMessage = new JMultilineLabel("");
    102102        jepMessage.addHyperlinkListener(this);
    103103
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    r6889 r6901  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.io;
     3
    34import static org.openstreetmap.josm.tools.I18n.tr;
    45import static org.openstreetmap.josm.tools.I18n.trn;
     
    3031
    3132import org.openstreetmap.josm.Main;
    32 import org.openstreetmap.josm.io.OsmApi;
    33 import org.openstreetmap.josm.tools.ImageProvider;
    3433import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    3534import org.openstreetmap.josm.gui.widgets.JosmTextField;
     35import org.openstreetmap.josm.io.OsmApi;
    3636
    3737/**
     
    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);
     
    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>"
     
    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);
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java

    r6890 r6901  
    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));
     
    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));
  • trunk/src/org/openstreetmap/josm/gui/widgets/JMultilineLabel.java

    r6365 r6901  
    55import java.awt.Rectangle;
    66
    7 import javax.swing.JLabel;
     7import javax.swing.JEditorPane;
    88import javax.swing.plaf.basic.BasicHTML;
    99import javax.swing.text.View;
     
    1616 * Note that this won't work if JMultilineLabel is put into a JScrollBox or
    1717 * similar as the bounds will never change. Instead scrollbars will be displayed.
    18  * 
     18 *
    1919 * @since 6340
    2020 */
    21 public class JMultilineLabel extends JLabel {
     21public class JMultilineLabel extends JEditorPane {
    2222    private int maxWidth = Integer.MAX_VALUE;
    2323    private Rectangle oldbounds = null;
     
    3333     */
    3434    public JMultilineLabel(String text) {
    35         super();
     35        this(text, true);
     36    }
     37
     38    public JMultilineLabel(String text, boolean allBold) {
     39        JosmEditorPane.makeJLabelLike(this, allBold);
    3640        String html = text.trim().replaceAll("\n", "<br>");
    3741        if (!html.startsWith("<html>")) {
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

    r6654 r6901  
    1313import javax.swing.text.html.StyleSheet;
    1414
     15import org.openstreetmap.josm.gui.util.GuiHelper;
    1516import org.openstreetmap.josm.tools.Utils;
    1617
     
    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);
     
    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(),
     
    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}
Note: See TracChangeset for help on using the changeset viewer.