1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Dimension;
|
---|
7 | import java.awt.Font;
|
---|
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;
|
---|
15 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
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
|
---|
22 | * @since 5114
|
---|
23 | */
|
---|
24 | public class LogShowDialog extends ExtendedDialog {
|
---|
25 |
|
---|
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 | */
|
---|
32 | public LogShowDialog(String title, String msg, String log) {
|
---|
33 | super(MainApplication.getMainFrame(), title, tr("OK"));
|
---|
34 | setButtonIcons("ok");
|
---|
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);
|
---|
41 |
|
---|
42 | lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN, 14));
|
---|
43 |
|
---|
44 | p.add(lbl, GBC.eol().insets(5, 0, 5, 0));
|
---|
45 | JosmEditorPane txt = new JosmEditorPane();
|
---|
46 | txt.setContentType("text/html");
|
---|
47 | txt.setText(log);
|
---|
48 | txt.setEditable(false);
|
---|
49 | txt.setOpaque(false);
|
---|
50 |
|
---|
51 | lbl.setLabelFor(txt);
|
---|
52 |
|
---|
53 | JScrollPane sp = new JScrollPane(txt);
|
---|
54 | sp.setOpaque(false);
|
---|
55 | sp.setPreferredSize(new Dimension(600, 300));
|
---|
56 |
|
---|
57 | p.add(sp, GBC.eop().insets(5, 15, 0, 0).fill(GBC.HORIZONTAL));
|
---|
58 |
|
---|
59 | return p;
|
---|
60 | }
|
---|
61 | }
|
---|