001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.actionsupport;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.awt.Dimension;
007import java.awt.GridBagLayout;
008
009import javax.swing.JLabel;
010import javax.swing.JPanel;
011import javax.swing.JScrollPane;
012
013import org.openstreetmap.josm.Main;
014import org.openstreetmap.josm.gui.ExtendedDialog;
015import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
016import org.openstreetmap.josm.tools.GBC;
017
018/**
019 * Generic dialog with message and scrolling area
020 * @author Alexei
021 */
022public class LogShowDialog extends ExtendedDialog {
023
024
025    public LogShowDialog (String title, String msg, String log) {
026        super(Main.parent, title, new String[] {tr("OK")});
027        setButtonIcons(new String[] {"ok.png"});
028        setContent(build(msg, log));
029    }
030
031    protected JPanel build(String msg, String log) {
032        JPanel p = new JPanel(new GridBagLayout());
033        JLabel lbl = new JLabel(msg);
034        
035        lbl.setFont(lbl.getFont().deriveFont(0, 14));
036        
037        p.add(lbl, GBC.eol().insets(5,0,5,0));
038        JosmEditorPane txt = new JosmEditorPane();
039        txt.setContentType("text/html");
040        txt.setText(log);
041        txt.setEditable(false);
042        txt.setOpaque(false);
043        
044        JScrollPane sp = new JScrollPane(txt);
045        sp.setOpaque(false);
046        sp.setPreferredSize(new Dimension(600,300));
047        
048        
049        p.add(sp, GBC.eop().insets(5,15,0,0).fill(GBC.HORIZONTAL));
050
051        return p;
052    }
053}