19 package org.sleuthkit.autopsy.centralrepository;
21 import org.openide.windows.WindowManager;
29 @SuppressWarnings(
"PMD.SingularField")
30 final class CentralRepoCommentDialog extends javax.swing.JDialog {
32 private final CorrelationAttribute correlationAttribute;
33 private boolean commentUpdated =
false;
41 CentralRepoCommentDialog(CorrelationAttribute correlationAttribute, String title) {
42 super(WindowManager.getDefault().getMainWindow(), title);
46 CorrelationAttributeInstance instance = correlationAttribute.getInstances().get(0);
48 pathLabel.setText(instance.getFilePath());
49 commentTextArea.setText(instance.getComment());
51 this.correlationAttribute = correlationAttribute;
59 setSize(getPreferredSize());
60 setLocationRelativeTo(this.getParent());
61 setAlwaysOnTop(
false);
71 boolean isCommentUpdated() {
72 return commentUpdated;
80 @SuppressWarnings(
"unchecked")
82 private
void initComponents() {
84 jScrollPane1 =
new javax.swing.JScrollPane();
85 commentTextArea =
new javax.swing.JTextArea();
86 okButton =
new javax.swing.JButton();
87 cancelButton =
new javax.swing.JButton();
88 fileLabel =
new javax.swing.JLabel();
89 pathLabel =
new javax.swing.JLabel();
90 commentLabel =
new javax.swing.JLabel();
92 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
93 setSize(getPreferredSize());
95 commentTextArea.setColumns(20);
96 commentTextArea.setLineWrap(
true);
97 commentTextArea.setRows(5);
98 commentTextArea.setTabSize(4);
99 commentTextArea.setWrapStyleWord(
true);
100 jScrollPane1.setViewportView(commentTextArea);
102 org.openide.awt.Mnemonics.setLocalizedText(okButton,
org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class,
"CentralRepoCommentDialog.okButton.text"));
103 okButton.addActionListener(
new java.awt.event.ActionListener() {
104 public void actionPerformed(java.awt.event.ActionEvent evt) {
105 okButtonActionPerformed(evt);
109 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class,
"CentralRepoCommentDialog.cancelButton.text"));
110 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
111 public void actionPerformed(java.awt.event.ActionEvent evt) {
112 cancelButtonActionPerformed(evt);
116 org.openide.awt.Mnemonics.setLocalizedText(fileLabel,
org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class,
"CentralRepoCommentDialog.fileLabel.text"));
118 org.openide.awt.Mnemonics.setLocalizedText(pathLabel,
org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class,
"CentralRepoCommentDialog.pathLabel.text"));
120 org.openide.awt.Mnemonics.setLocalizedText(commentLabel,
org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class,
"CentralRepoCommentDialog.commentLabel.text"));
122 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
123 getContentPane().setLayout(layout);
124 layout.setHorizontalGroup(
125 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
126 .addGroup(layout.createSequentialGroup()
128 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
129 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
130 .addGroup(layout.createSequentialGroup()
131 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132 .addGroup(layout.createSequentialGroup()
133 .addComponent(fileLabel)
134 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
135 .addComponent(pathLabel))
136 .addComponent(commentLabel))
137 .addGap(0, 451, Short.MAX_VALUE))
138 .addGroup(layout.createSequentialGroup()
139 .addGap(0, 0, Short.MAX_VALUE)
140 .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
141 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142 .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
145 layout.setVerticalGroup(
146 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147 .addGroup(layout.createSequentialGroup()
149 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
150 .addComponent(fileLabel)
151 .addComponent(pathLabel))
153 .addComponent(commentLabel)
154 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
155 .addComponent(jScrollPane1)
156 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
157 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
158 .addComponent(okButton)
159 .addComponent(cancelButton))
166 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
170 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
171 String comment = commentTextArea.getText();
172 correlationAttribute.getInstances().get(0).setComment(comment);
173 commentUpdated =
true;
179 private javax.swing.JButton cancelButton;
180 private javax.swing.JLabel commentLabel;
181 private javax.swing.JTextArea commentTextArea;
182 private javax.swing.JLabel fileLabel;
183 private javax.swing.JScrollPane jScrollPane1;
184 private javax.swing.JButton okButton;
185 private javax.swing.JLabel pathLabel;