Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestProfileSelectionPanel.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-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 */
19package org.sleuthkit.autopsy.ingest.runIngestModuleWizard;
20
21import java.awt.Color;
22import java.awt.Component;
23import java.awt.Dimension;
24import java.awt.GridBagConstraints;
25import java.awt.GridBagLayout;
26import java.awt.event.ActionEvent;
27import java.awt.event.ActionListener;
28import java.util.Collections;
29import java.util.List;
30import javax.swing.Box;
31import static javax.swing.Box.createVerticalGlue;
32import javax.swing.ButtonModel;
33import javax.swing.JPanel;
34import javax.swing.JScrollPane;
35import javax.swing.JTextArea;
36import javax.swing.JToggleButton;
37import org.openide.util.NbBundle.Messages;
38import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog;
39import org.sleuthkit.autopsy.ingest.IngestOptionsPanel;
40import org.sleuthkit.autopsy.ingest.IngestProfiles;
41import org.sleuthkit.autopsy.ingest.IngestProfiles.IngestProfile;
42
47@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
48final class IngestProfileSelectionPanel extends JPanel {
49
50 @Messages({"IngestProfileSelectionPanel.customSettings.name=Custom Settings",
51 "IngestProfileSelectionPanel.customSettings.description=configure individual module settings in next step of wizard"})
52
53 private static final long serialVersionUID = 1L;
54 private static final String CUSTOM_SETTINGS_DISPLAY_NAME = Bundle.IngestProfileSelectionPanel_customSettings_name();
55 private static final String CUSTOM_SETTINGS_DESCRIPTION = Bundle.IngestProfileSelectionPanel_customSettings_description();
56 private final IngestProfileSelectionWizardPanel wizardPanel;
57 private String selectedProfile;
58 private List<IngestProfile> profiles = Collections.emptyList();
59 boolean isLastPanel = false;
60
61 //Listener for profile button selection
62 ActionListener buttonGroupActionListener = (ActionEvent e) -> {
63 updateSelectedProfile();
64 };
71 IngestProfileSelectionPanel(IngestProfileSelectionWizardPanel panel, String lastSelectedProfile) {
72 initComponents();
73 wizardPanel = panel;
74 selectedProfile = lastSelectedProfile;
75 isLastPanel = !selectedProfile.equals(wizardPanel.getDefaultContext());
76
77 populateProfilesList();
78 }
79
85 String getLastSelectedProfile() {
86 return selectedProfile;
87 }
88
94 private void updateSelectedProfile() {
95
96 ButtonModel selectedButton = profileListButtonGroup.getSelection();
97 selectedProfile = selectedButton.getActionCommand();
98
99 boolean wasLastPanel = isLastPanel;
100 isLastPanel = !selectedProfile.equals(wizardPanel.getDefaultContext());
101 wizardPanel.fireChangeEvent();
102 this.firePropertyChange("LAST_ENABLED", wasLastPanel, isLastPanel); //NON-NLS
103 }
104
109 private void populateProfilesList() {
110 profiles = getProfiles();
111
112 GridBagLayout gridBagLayout = new GridBagLayout();
113 GridBagConstraints constraints = new GridBagConstraints();
114 constraints.fill = GridBagConstraints.HORIZONTAL;
115 constraints.gridx = 0;
116 constraints.gridy = 0;
117 constraints.weighty = .0;
118 constraints.anchor = GridBagConstraints.LINE_START;
119
120 addButton(CUSTOM_SETTINGS_DISPLAY_NAME, wizardPanel.getDefaultContext(), CUSTOM_SETTINGS_DESCRIPTION, gridBagLayout, constraints);
121
122 profiles.forEach((profile) -> {
123 constraints.weightx = 0;
124 constraints.gridy++;
125 constraints.gridx = 0;
126
127 addButton(profile.toString(), profile.toString(), profile.getDescription(), gridBagLayout, constraints);
128 });
129 //Add vertical glue at the bottom of the scroll panel so spacing
130 //between elements is less dependent on the number of elements
131 constraints.gridy++;
132 constraints.gridx = 0;
133 constraints.weighty = 1;
134 Component vertGlue = createVerticalGlue();
135 profileListPanel.add(vertGlue);
136 gridBagLayout.setConstraints(vertGlue, constraints);
137 profileListPanel.setLayout(gridBagLayout);
138 }
139
149 private void addButton(String profileDisplayName, String profileContextName, String profileDesc, GridBagLayout layout, GridBagConstraints constraints) {
150
151 //Add a spacer
152 Dimension spacerBlockDimension = new Dimension(6, 4); // Space between left edge and button, Space between rows
153 Box.Filler spacer = new Box.Filler(spacerBlockDimension, spacerBlockDimension, spacerBlockDimension);
154 constraints.weightx = 1;
155 layout.setConstraints(spacer, constraints);
156 profileListPanel.add(spacer);
157 constraints.gridx++;
158 constraints.gridy++;
159
160
161 JToggleButton profileButton = new JToggleButton();
162 profileButton.setMaximumSize(new java.awt.Dimension(48, 48));
163 profileButton.setMinimumSize(new java.awt.Dimension(48, 48));
164 profileButton.setPreferredSize(new java.awt.Dimension(48, 48));
165
166 profileButton.setName(profileContextName);
167 profileButton.setActionCommand(profileContextName);
168
169 profileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/timeline/images/magnifier-zoom-in-green.png")));
170 profileButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/checkbox24.png")));
171 profileButton.setFocusable(false);
172 profileButton.setFocusPainted(false);
173 profileButton.addActionListener(buttonGroupActionListener);
174
175 if (profileContextName.equals(selectedProfile)) {
176 profileButton.setSelected(true);
177 }
178
179 profileListButtonGroup.add(profileButton);
180 profileListPanel.add(profileButton);
181 layout.setConstraints(profileButton, constraints);
182 constraints.gridx++;
183 constraints.weightx = 1;
184
185 //Using a JTextArea as though it is a label in order to get multi-line support
186 String displayText = profileDisplayName;
187 if (!profileDesc.isEmpty()) {
188 displayText += " - " + profileDesc;
189 }
190 JTextArea myLabel = new JTextArea(displayText);
191 Color gray = new Color(240, 240, 240); //matches background of panel
192 myLabel.setBackground(gray);
193 myLabel.setEditable(false);
194 myLabel.setWrapStyleWord(true);
195 myLabel.setLineWrap(true);
196
197 //Add space between the button and text
198 Box.Filler buttonTextSpacer = new Box.Filler(spacerBlockDimension, spacerBlockDimension, spacerBlockDimension);
199 layout.setConstraints(buttonTextSpacer, constraints);
200 profileListPanel.add(buttonTextSpacer);
201 constraints.gridx++;
202
203 //Add the text area serving as a label to the right of the button
204 profileListPanel.add(myLabel);
205 layout.setConstraints(myLabel, constraints);
206
207 }
208
214 private List<IngestProfile> getProfiles() {
215 if (profiles.isEmpty()) {
216 fetchProfileList();
217 }
218 return profiles;
219 }
220
224 private void clearListOfCheckBoxes() {
225 profileListButtonGroup = new javax.swing.ButtonGroup();
226 profileListPanel.removeAll();
227 }
228
232 private void fetchProfileList() {
234 }
235
241 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
242 private void initComponents() {
243
244 profileListButtonGroup = new javax.swing.ButtonGroup();
245 ingestSettingsButton = new javax.swing.JButton();
246 profileListScrollPane = new javax.swing.JScrollPane();
247 profileListPanel = new javax.swing.JPanel();
248 profileListLabel = new javax.swing.JLabel();
249
250 setMaximumSize(new java.awt.Dimension(5750, 3000));
251 setPreferredSize(new java.awt.Dimension(625, 450));
252
253 org.openide.awt.Mnemonics.setLocalizedText(ingestSettingsButton, org.openide.util.NbBundle.getMessage(IngestProfileSelectionPanel.class, "IngestProfileSelectionPanel.ingestSettingsButton.text")); // NOI18N
254 ingestSettingsButton.addActionListener(new java.awt.event.ActionListener() {
255 public void actionPerformed(java.awt.event.ActionEvent evt) {
256 ingestSettingsButtonActionPerformed(evt);
257 }
258 });
259
260 profileListScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
261
262 profileListPanel.setAutoscrolls(true);
263 profileListPanel.setLayout(new java.awt.GridBagLayout());
264 profileListScrollPane.setViewportView(profileListPanel);
265
266 org.openide.awt.Mnemonics.setLocalizedText(profileListLabel, org.openide.util.NbBundle.getMessage(IngestProfileSelectionPanel.class, "IngestProfileSelectionPanel.profileListLabel.text")); // NOI18N
267
268 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
269 this.setLayout(layout);
270 layout.setHorizontalGroup(
271 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
272 .addGroup(layout.createSequentialGroup()
273 .addContainerGap()
274 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
275 .addComponent(profileListScrollPane)
276 .addGroup(layout.createSequentialGroup()
277 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
278 .addComponent(ingestSettingsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
279 .addComponent(profileListLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
280 .addGap(0, 523, Short.MAX_VALUE)))
281 .addContainerGap())
282 );
283 layout.setVerticalGroup(
284 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285 .addGroup(layout.createSequentialGroup()
286 .addContainerGap()
287 .addComponent(profileListLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
288 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
289 .addComponent(profileListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
290 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
291 .addComponent(ingestSettingsButton)
292 .addGap(18, 18, 18))
293 );
294 }// </editor-fold>//GEN-END:initComponents
295
302 private void ingestSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ingestSettingsButtonActionPerformed
304 IngestOptionsPanel ingestOptions = new IngestOptionsPanel();
305 ingestOptions.load();
306 dialog.addApplyButtonListener(
307 (ActionEvent e) -> {
308 ingestOptions.store();
309 clearListOfCheckBoxes();
310 fetchProfileList();
311 profileListPanel.revalidate();
312 profileListPanel.repaint();
313 populateProfilesList();
314 dialog.close();
315 }
316 );
317 dialog.display(ingestOptions);
318 }//GEN-LAST:event_ingestSettingsButtonActionPerformed
319
320 // Variables declaration - do not modify//GEN-BEGIN:variables
321 private javax.swing.JButton ingestSettingsButton;
322 private javax.swing.ButtonGroup profileListButtonGroup;
323 private javax.swing.JLabel profileListLabel;
324 private javax.swing.JPanel profileListPanel;
325 private javax.swing.JScrollPane profileListScrollPane;
326 // End of variables declaration//GEN-END:variables
327
328 }
static synchronized List< IngestProfile > getIngestProfiles()

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.