22 package org.sleuthkit.autopsy.rejview;
24 import com.williballenthin.rejistry.RegistryParseException;
25 import com.williballenthin.rejistry.ValueData;
26 import java.awt.BorderLayout;
27 import java.io.UnsupportedEncodingException;
28 import java.util.logging.Level;
29 import javax.swing.BorderFactory;
30 import javax.swing.JComponent;
31 import javax.swing.JLabel;
32 import javax.swing.JScrollPane;
33 import javax.swing.SwingConstants;
34 import org.openide.util.NbBundle.Messages;
45 @Messages({
"RejTreeValueView.template.name=Name:",
46 "RejTreeValueView.template.type=Type:",
47 "RejTreeValueView.failedToDecode.valueName=FAILED TO DECODE VALUE NAME",
48 "RejTreeValueView.failedToDecode.valueType=FAILED TO PARSE VALUE TYPE",
49 "RejTreeValueView.failedToParse.value=FAILED TO PARSE VALUE VALUE",
50 "RejTreeValueView.metadataBorder.title=Metadata",
51 "RejTreeValueView.valueBorder.title=Value",})
53 super(
new BorderLayout());
58 String metadataTemplate =
"<html><i>"
59 + Bundle.RejTreeValueView_template_name()
60 +
"</i><b> %1$s</b><br/><i>"
61 + Bundle.RejTreeValueView_template_type()
62 +
" </i> %2$s</html>";
69 String valueTemplate =
"<html>%1$s</html>";
71 valueName = node.getValue().getName();
72 }
catch (UnsupportedEncodingException ex) {
73 logger.log(Level.WARNING,
"Failed to get value name", ex);
74 valueName = Bundle.RejTreeValueView_failedToDecode_valueName();
78 valueType = node.getValue().getValueType().toString();
79 }
catch (RegistryParseException ex) {
80 logger.log(Level.WARNING,
"Failed to get value type", ex);
81 valueType = Bundle.RejTreeValueView_failedToDecode_valueType();
84 JLabel metadataLabel =
new JLabel(String.format(metadataTemplate, valueName, valueType), JLabel.LEFT);
85 metadataLabel.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_metadataBorder_title()));
86 metadataLabel.setVerticalAlignment(SwingConstants.TOP);
89 JComponent valueComponent;
91 ValueData data = node.getValue().getValue();
94 switch (data.getValueType()) {
97 String valueValue = data.getAsString();
98 JLabel valueLabel =
new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT);
99 valueLabel.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_valueBorder_title()));
100 valueLabel.setVerticalAlignment(SwingConstants.TOP);
101 valueComponent = valueLabel;
105 StringBuilder sb =
new StringBuilder();
106 for (String s : data.getAsStringList()) {
110 String valueValue = sb.toString();
111 JLabel valueLabel =
new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT);
112 valueLabel.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_valueBorder_title()));
113 valueLabel.setVerticalAlignment(SwingConstants.TOP);
114 valueComponent = valueLabel;
119 case REG_BIG_ENDIAN: {
120 String valueValue = String.format(
"0x%x", data.getAsNumber());
121 JLabel valueLabel =
new JLabel(String.format(valueTemplate, valueValue), JLabel.LEFT);
122 valueLabel.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_valueBorder_title()));
123 valueLabel.setVerticalAlignment(SwingConstants.TOP);
124 valueComponent = valueLabel;
128 HexView hexView =
new HexView(data.getAsRawData());
129 hexView.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_valueBorder_title()));
130 valueComponent = hexView;
134 }
catch (RegistryParseException | UnsupportedEncodingException ex) {
135 logger.log(Level.WARNING,
"Failure getting or parsing value value", ex);
136 JLabel valueLabel =
new JLabel(String.format(valueTemplate, Bundle.RejTreeValueView_failedToParse_value()), JLabel.LEFT);
137 valueLabel.setBorder(BorderFactory.createTitledBorder(Bundle.RejTreeValueView_valueBorder_title()));
138 valueLabel.setVerticalAlignment(SwingConstants.TOP);
139 valueComponent = valueLabel;
142 this.add(metadataLabel, BorderLayout.NORTH);
143 this.add(
new JScrollPane(valueComponent), BorderLayout.CENTER);
static final long serialVersionUID
RejTreeValueView(RejTreeValueNode node)
static final Logger logger
synchronized static Logger getLogger(String name)