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