1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.mindtree.techworks.insight.gui.preferences;
25
26 import javax.swing.JLabel;
27 import javax.swing.JScrollPane;
28 import javax.swing.JTextField;
29 import javax.swing.JTextPane;
30
31 import com.mindtree.techworks.insight.InsightConstants;
32
33
34
35
36
37
38
39
40
41
42
43
44 public class LogPatternUIPanel extends AbstractPreferencesUIPanel {
45
46
47
48
49 private static final long serialVersionUID = -5115766011595135952L;
50
51
52
53
54 private static final String SUPPORTED_PATTERN =
55 "<p>" +
56 "<i>The following variables may be used in the Pattern and their interpretation are:</i>" +
57 "<ul>" +
58 "<li>%c - category LOGGER</li>" +
59 "<li>%C - Class name CLASS</li>" +
60 "<li>%d - date TIMESTAMP</li>" +
61 "<li>%l - location information FILE</li>" +
62 "<li>%F - location information FILE</li>" +
63 "<li>%L - Line number of caller LINE</li>" +
64 "<li>%m - application message MESSAGE</li>" +
65 "<li>%M - method name of caller METHOD</li>" +
66 "<li>%p - priority LEVEL</li>" +
67 "<li>%r - number of milliseconds elapsed time since start RELATIVETIME</li>" +
68 "<li>%t - thread name THREAD</li>" +
69 "<li>%x - NDC (nested diagnostic context) associated with the thread NDC" +
70 "<li>%n - Line Feed" +
71 "</li>" +
72 "</ul>" +
73 "</p>";
74
75
76
77
78 private static final String PRIMARY_PATTERN_ID = "primaryPattern";
79 private static final String SECONDARY_PATTERN_ID = "secondaryPattern";
80
81
82
83
84 private JTextField primaryPatternField;
85 private JTextField secondaryPatternField;
86
87
88
89
90 private JTextPane detailsPane;
91
92
93
94
95
96 public LogPatternUIPanel() {
97 }
98
99
100
101
102
103 protected void initializeDisplay() {
104 addComponent(new JLabel(InsightConstants.getLiteral("PRIMARY_PATTERN")),0,0,0,0,1,1);
105 this.primaryPatternField = new JTextField();
106 addComponent(primaryPatternField,1,0,1,0, 3, 1);
107 JLabel samplePatternLabel = new JLabel(InsightConstants.getLiteral("SAMPLE_PATTERN") +
108 this.preference.getPreferenceAttributeById(PRIMARY_PATTERN_ID).getDefaultValue());
109 samplePatternLabel.setFont(InsightConstants.DEFAULT_SMALL_FONT);
110 addComponent(samplePatternLabel,2,1,0,0,1,1);
111
112 addComponent(new JLabel(InsightConstants.getLiteral("SECONDARY_PATTERN")),0,2,0,0,1,1);
113 this.secondaryPatternField = new JTextField();
114 addComponent(secondaryPatternField,1,2,1,0, 3, 1);
115
116 this.detailsPane = new JTextPane();
117 detailsPane.setEditable(false);
118 detailsPane.setEnabled(false);
119 detailsPane.setContentType("text/html");
120 detailsPane.setText(SUPPORTED_PATTERN);
121 addComponent(new JScrollPane(detailsPane),0,3,1,1,4,1);
122
123
124 this.primaryPatternField.setText(this.preference.getPreferenceAttributeById(PRIMARY_PATTERN_ID).getValue());
125 this.secondaryPatternField.setText(this.preference.getPreferenceAttributeById(SECONDARY_PATTERN_ID).getValue());
126 }
127
128
129
130
131
132 protected void setPreferenceValues() {
133 this.preference.getPreferenceAttributeById(PRIMARY_PATTERN_ID).setValue(this.primaryPatternField.getText());
134 this.preference.getPreferenceAttributeById(SECONDARY_PATTERN_ID).setValue(this.secondaryPatternField.getText());
135 }
136
137 }