[7937] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[8469] | 2 | package org.openstreetmap.josm.gui.dialogs;
|
---|
[7937] | 3 |
|
---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 5 |
|
---|
| 6 | import java.awt.Dimension;
|
---|
[15775] | 7 | import java.awt.Font;
|
---|
[7937] | 8 | import java.awt.GridBagLayout;
|
---|
| 9 |
|
---|
| 10 | import javax.swing.JLabel;
|
---|
| 11 | import javax.swing.JPanel;
|
---|
| 12 | import javax.swing.JScrollPane;
|
---|
| 13 |
|
---|
| 14 | import org.openstreetmap.josm.gui.ExtendedDialog;
|
---|
[14153] | 15 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
[7937] | 16 | import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
|
---|
| 17 | import org.openstreetmap.josm.tools.GBC;
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * Generic dialog with message and scrolling area
|
---|
| 21 | * @author Alexei
|
---|
[8426] | 22 | * @since 5114
|
---|
[7937] | 23 | */
|
---|
| 24 | public class LogShowDialog extends ExtendedDialog {
|
---|
| 25 |
|
---|
[8426] | 26 | /**
|
---|
| 27 | * Constructs a new {@code LogShowDialog}.
|
---|
| 28 | * @param title The text that will be shown in the window titlebar
|
---|
| 29 | * @param msg Single-line Label
|
---|
| 30 | * @param log Multi-line log
|
---|
| 31 | */
|
---|
[8419] | 32 | public LogShowDialog(String title, String msg, String log) {
|
---|
[14153] | 33 | super(MainApplication.getMainFrame(), title, tr("OK"));
|
---|
[12279] | 34 | setButtonIcons("ok");
|
---|
[7937] | 35 | setContent(build(msg, log));
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | protected final JPanel build(String msg, String log) {
|
---|
| 39 | JPanel p = new JPanel(new GridBagLayout());
|
---|
| 40 | JLabel lbl = new JLabel(msg);
|
---|
[8419] | 41 |
|
---|
[15775] | 42 | lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN, 14));
|
---|
[8419] | 43 |
|
---|
[8510] | 44 | p.add(lbl, GBC.eol().insets(5, 0, 5, 0));
|
---|
[7937] | 45 | JosmEditorPane txt = new JosmEditorPane();
|
---|
| 46 | txt.setContentType("text/html");
|
---|
| 47 | txt.setText(log);
|
---|
| 48 | txt.setEditable(false);
|
---|
| 49 | txt.setOpaque(false);
|
---|
[8419] | 50 |
|
---|
[8426] | 51 | lbl.setLabelFor(txt);
|
---|
| 52 |
|
---|
[7937] | 53 | JScrollPane sp = new JScrollPane(txt);
|
---|
| 54 | sp.setOpaque(false);
|
---|
[8510] | 55 | sp.setPreferredSize(new Dimension(600, 300));
|
---|
[8419] | 56 |
|
---|
[8510] | 57 | p.add(sp, GBC.eop().insets(5, 15, 0, 0).fill(GBC.HORIZONTAL));
|
---|
[7937] | 58 |
|
---|
| 59 | return p;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|