Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
STIXReportModuleConfigPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-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.modules.stix;
20 
21 import java.io.File;
22 import javax.swing.JFileChooser;
24 
28 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
29 public class STIXReportModuleConfigPanel extends javax.swing.JPanel {
30 
31  String stixFile = null;
32  boolean showAllResults;
33 
38  initComponents();
39 
40  // Set the default path to the last one used
41  if ((ModuleSettings.getConfigSetting("STIX", "defaultPath") != null) //NON-NLS
42  && (!ModuleSettings.getConfigSetting("STIX", "defaultPath").isEmpty())) { //NON-NLS
43  jTextField1.setText(ModuleSettings.getConfigSetting("STIX", "defaultPath")); //NON-NLS
44  stixFile = ModuleSettings.getConfigSetting("STIX", "defaultPath"); //NON-NLS
45  }
46 
47  // Set the results checkbox to the last one used
48  if ((ModuleSettings.getConfigSetting("STIX", "showAllResults") != null) //NON-NLS
49  && (!ModuleSettings.getConfigSetting("STIX", "showAllResults").isEmpty())) { //NON-NLS
50 
51  if (ModuleSettings.getConfigSetting("STIX", "showAllResults").equals("true")) { //NON-NLS
52  jCheckBox1.setSelected(true);
53  showAllResults = true;
54  } else {
55  jCheckBox1.setSelected(false);
56  showAllResults = false;
57  }
58  } else {
59  showAllResults = false;
60  }
61  }
62 
63  public String getStixFile() {
64  return stixFile;
65  }
66 
67  public boolean getShowAllResults() {
68  return showAllResults;
69  }
70 
76  @SuppressWarnings("unchecked")
77  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
78  private void initComponents() {
79 
80  jLabel2 = new javax.swing.JLabel();
81  jTextField1 = new javax.swing.JTextField();
82  jButton1 = new javax.swing.JButton();
83  jCheckBox1 = new javax.swing.JCheckBox();
84 
85  jLabel2.setText(org.openide.util.NbBundle.getMessage(STIXReportModuleConfigPanel.class, "STIXReportModuleConfigPanel.jLabel2.text")); // NOI18N
86 
87  jTextField1.setText(org.openide.util.NbBundle.getMessage(STIXReportModuleConfigPanel.class, "STIXReportModuleConfigPanel.jTextField1.text")); // NOI18N
88  jTextField1.addActionListener(new java.awt.event.ActionListener() {
89  public void actionPerformed(java.awt.event.ActionEvent evt) {
90  jTextField1ActionPerformed(evt);
91  }
92  });
93  jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
94  public void keyReleased(java.awt.event.KeyEvent evt) {
95  jTextField1KeyReleased(evt);
96  }
97  public void keyTyped(java.awt.event.KeyEvent evt) {
98  jTextField1KeyTyped(evt);
99  }
100  });
101 
102  jButton1.setText(org.openide.util.NbBundle.getMessage(STIXReportModuleConfigPanel.class, "STIXReportModuleConfigPanel.jButton1.text")); // NOI18N
103  jButton1.addActionListener(new java.awt.event.ActionListener() {
104  public void actionPerformed(java.awt.event.ActionEvent evt) {
105  jButton1ActionPerformed(evt);
106  }
107  });
108 
109  jCheckBox1.setText(org.openide.util.NbBundle.getMessage(STIXReportModuleConfigPanel.class, "STIXReportModuleConfigPanel.jCheckBox1.text")); // NOI18N
110  jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
111  public void actionPerformed(java.awt.event.ActionEvent evt) {
112  jCheckBox1ActionPerformed(evt);
113  }
114  });
115 
116  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
117  this.setLayout(layout);
118  layout.setHorizontalGroup(
119  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
120  .addGroup(layout.createSequentialGroup()
121  .addContainerGap()
122  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
123  .addComponent(jLabel2)
124  .addGroup(layout.createSequentialGroup()
125  .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
126  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
127  .addComponent(jButton1))
128  .addComponent(jCheckBox1))
129  .addContainerGap(73, Short.MAX_VALUE))
130  );
131  layout.setVerticalGroup(
132  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
133  .addGroup(layout.createSequentialGroup()
134  .addContainerGap()
135  .addComponent(jLabel2)
136  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
137  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
138  .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
139  .addComponent(jButton1))
140  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
141  .addComponent(jCheckBox1)
142  .addContainerGap(225, Short.MAX_VALUE))
143  );
144  }// </editor-fold>//GEN-END:initComponents
145 
146  private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
147 
148  }//GEN-LAST:event_jTextField1ActionPerformed
149 
150  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
151 
152  JFileChooser fileChooser = new JFileChooser();
153  fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
154 
155  File currentSelection = new File(jTextField1.getText());
156  if (currentSelection.exists()) {
157  fileChooser.setCurrentDirectory(currentSelection);
158  }
159 
160  int result = fileChooser.showOpenDialog(this);
161 
162  if (result == JFileChooser.APPROVE_OPTION) {
163  stixFile = fileChooser.getSelectedFile().getAbsolutePath();
164  jTextField1.setText(stixFile);
165  }
166 
167  }//GEN-LAST:event_jButton1ActionPerformed
168 
169  private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped
170 
171  }//GEN-LAST:event_jTextField1KeyTyped
172 
173  private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
174  stixFile = jTextField1.getText();
175  }//GEN-LAST:event_jTextField1KeyReleased
176 
177  private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
178  // TODO add your handling code here:
179  showAllResults = jCheckBox1.isSelected();
180  if (showAllResults) {
181  ModuleSettings.setConfigSetting("STIX", "showAllResults", "true"); //NON-NLS
182  } else {
183  ModuleSettings.setConfigSetting("STIX", "showAllResults", "false"); //NON-NLS
184  }
185  }//GEN-LAST:event_jCheckBox1ActionPerformed
186 
187  // Variables declaration - do not modify//GEN-BEGIN:variables
188  private javax.swing.JButton jButton1;
189  private javax.swing.JCheckBox jCheckBox1;
190  private javax.swing.JLabel jLabel2;
191  private javax.swing.JTextField jTextField1;
192  // End of variables declaration//GEN-END:variables
193 }
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static String getConfigSetting(String moduleName, String settingName)

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.