Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CentralRepoCommentDialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.centralrepository;
20 
21 import org.openide.windows.WindowManager;
24 
29 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
30 final class CentralRepoCommentDialog extends javax.swing.JDialog {
31 
32  private final CorrelationAttribute correlationAttribute;
33  private boolean commentUpdated = false;
34 
41  CentralRepoCommentDialog(CorrelationAttribute correlationAttribute, String title) {
42  super(WindowManager.getDefault().getMainWindow(), title);
43 
44  initComponents();
45 
46  CorrelationAttributeInstance instance = correlationAttribute.getInstances().get(0);
47 
48  pathLabel.setText(instance.getFilePath());
49  commentTextArea.setText(instance.getComment());
50 
51  this.correlationAttribute = correlationAttribute;
52  }
53 
57  void display() {
58  setModal(true);
59  setSize(getPreferredSize());
60  setLocationRelativeTo(this.getParent());
61  setAlwaysOnTop(false);
62  pack();
63  setVisible(true);
64  }
65 
71  boolean isCommentUpdated() {
72  return commentUpdated;
73  }
74 
80  @SuppressWarnings("unchecked")
81  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
82  private void initComponents() {
83 
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();
91 
92  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
93  setSize(getPreferredSize());
94 
95  commentTextArea.setColumns(20);
96  commentTextArea.setLineWrap(true);
97  commentTextArea.setRows(5);
98  commentTextArea.setTabSize(4);
99  commentTextArea.setWrapStyleWord(true);
100  jScrollPane1.setViewportView(commentTextArea);
101 
102  org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class, "CentralRepoCommentDialog.okButton.text")); // NOI18N
103  okButton.addActionListener(new java.awt.event.ActionListener() {
104  public void actionPerformed(java.awt.event.ActionEvent evt) {
105  okButtonActionPerformed(evt);
106  }
107  });
108 
109  org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class, "CentralRepoCommentDialog.cancelButton.text")); // NOI18N
110  cancelButton.addActionListener(new java.awt.event.ActionListener() {
111  public void actionPerformed(java.awt.event.ActionEvent evt) {
112  cancelButtonActionPerformed(evt);
113  }
114  });
115 
116  org.openide.awt.Mnemonics.setLocalizedText(fileLabel, org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class, "CentralRepoCommentDialog.fileLabel.text")); // NOI18N
117 
118  org.openide.awt.Mnemonics.setLocalizedText(pathLabel, org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class, "CentralRepoCommentDialog.pathLabel.text")); // NOI18N
119 
120  org.openide.awt.Mnemonics.setLocalizedText(commentLabel, org.openide.util.NbBundle.getMessage(CentralRepoCommentDialog.class, "CentralRepoCommentDialog.commentLabel.text")); // NOI18N
121 
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()
127  .addContainerGap()
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)))
143  .addContainerGap())
144  );
145  layout.setVerticalGroup(
146  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147  .addGroup(layout.createSequentialGroup()
148  .addContainerGap()
149  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
150  .addComponent(fileLabel)
151  .addComponent(pathLabel))
152  .addGap(19, 19, 19)
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))
160  .addContainerGap())
161  );
162 
163  pack();
164  }// </editor-fold>//GEN-END:initComponents
165 
166  private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
167  dispose();
168  }//GEN-LAST:event_cancelButtonActionPerformed
169 
170  private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
171  String comment = commentTextArea.getText();
172  correlationAttribute.getInstances().get(0).setComment(comment);
173  commentUpdated = true;
174 
175  dispose();
176  }//GEN-LAST:event_okButtonActionPerformed
177 
178  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
186  // End of variables declaration//GEN-END:variables
187 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.