1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.support.shared;
17
18 import org.fourthline.cling.model.ModelUtil;
19 import org.seamless.swing.Application;
20 import org.seamless.xml.DOM;
21 import org.seamless.xml.DOMParser;
22 import org.w3c.dom.Document;
23
24 import javax.swing.JDialog;
25 import javax.swing.JScrollPane;
26 import javax.swing.JTextArea;
27 import java.awt.Dimension;
28 import java.awt.Frame;
29 import java.util.logging.Logger;
30
31
32
33
34 public class TextExpandDialog extends JDialog {
35
36
37
38 private static Logger log = Logger.getLogger(TextExpandDialog.class.getName());
39
40 public TextExpandDialog(Frame frame, String text) {
41 super(frame);
42 setResizable(true);
43
44 JTextArea textArea = new JTextArea();
45 JScrollPane textPane = new JScrollPane(textArea);
46 textPane.setPreferredSize(new Dimension(500, 400));
47 add(textPane);
48
49 String pretty;
50 if (text.startsWith("<") && text.endsWith(">")) {
51 try {
52 pretty = new DOMParser() {
53 @Override
54 protected DOM createDOM(Document document) {
55 return null;
56 }
57 }.print(text, 2, false);
58 } catch (Exception ex) {
59 log.severe("Error pretty printing XML: " + ex.toString());
60 pretty = text;
61 }
62 } else if (text.startsWith("http-get")) {
63 pretty = ModelUtil.commaToNewline(text);
64 } else {
65 pretty = text;
66 }
67
68 textArea.setEditable(false);
69 textArea.setText(pretty);
70
71 pack();
72 Application.center(this, getOwner());
73 setVisible(true);
74 }
75 }