Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportWizardDataSourceSelectionPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.report.infrastructure;
20 
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.JButton;
26 import javax.swing.event.ChangeListener;
27 import org.openide.WizardDescriptor;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30 import org.openide.util.NbPreferences;
35 import org.sleuthkit.datamodel.Content;
36 import org.sleuthkit.datamodel.TskCoreException;
37 
42 public class ReportWizardDataSourceSelectionPanel implements WizardDescriptor.FinishablePanel<WizardDescriptor> {
43 
44  private static final Logger logger = Logger.getLogger(ReportWizardDataSourceSelectionPanel.class.getName());
45 
47  private WizardDescriptor wiz;
48 
49  private final JButton finishButton;
50  private final JButton nextButton;
51 
52  @NbBundle.Messages({
53  "ReportWizardDataSourceSelectionPanel.nextButton.text=Next",
54  "ReportWizardDataSourceSelectionPanel.finishButton.text=Finish"
55  })
57  nextButton = new JButton(Bundle.ReportWizardDataSourceSelectionPanel_nextButton_text());
58  finishButton = new JButton(Bundle.ReportWizardDataSourceSelectionPanel_finishButton_text());
59  finishButton.setEnabled(false);
60  nextButton.setEnabled(false);
61 
62  finishButton.addActionListener(createFinishButtonActionListener());
63  nextButton.addActionListener(createNextButtonActionListener());
64  }
65 
66  @NbBundle.Messages({
67  "ReportWizardDataSourceSelectionPanel.confirmEmptySelection=Are you sure you want to proceed with no selections?"
68  })
69  private ActionListener createNextButtonActionListener() {
70  return (ActionEvent e) -> {
71  if(!dataSourcesSelectionPanel.getSelectedElements().isEmpty()) {
72  wiz.doNextClick();
73  } else if(MessageNotifyUtil.Message.confirm(Bundle.ReportWizardDataSourceSelectionPanel_confirmEmptySelection())) {
74  wiz.doNextClick();
75  }
76  };
77  }
78 
79  private ActionListener createFinishButtonActionListener() {
80  return (ActionEvent e) -> {
81  if(!dataSourcesSelectionPanel.getSelectedElements().isEmpty()) {
82  wiz.doFinishClick();
83  } else if(MessageNotifyUtil.Message.confirm(Bundle.ReportWizardDataSourceSelectionPanel_confirmEmptySelection())) {
84  wiz.doFinishClick();
85  }
86  };
87  }
88 
89  @NbBundle.Messages({
90  "ReportWizardDataSourceSelectionPanel.title=Select which data source(s) to include"
91  })
92  @Override
94  if (dataSourcesSelectionPanel == null) {
95  dataSourcesSelectionPanel = new CheckBoxListPanel<>();
96  dataSourcesSelectionPanel.setName(Bundle.ReportWizardDataSourceSelectionPanel_title());
97  try {
98  List<Content> dataSources = Case.getCurrentCase().getDataSources();
99  for (Content dataSource : dataSources) {
100  String dataSourceName = dataSource.getName();
101  long dataSourceId = dataSource.getId();
102  dataSourcesSelectionPanel.addElement(dataSourceName, null, dataSourceId);
103  }
104  } catch (TskCoreException ex) {
105  logger.log(Level.SEVERE, "Unable to get list of data sources from the case", ex);
106  }
107  }
109  }
110 
111  @Override
112  public HelpCtx getHelp() {
113  return HelpCtx.DEFAULT_HELP;
114  }
115 
116  @Override
117  public void readSettings(WizardDescriptor data) {
118  this.wiz = data;
119  wiz.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, nextButton, finishButton, WizardDescriptor.CANCEL_OPTION});
120 
121  boolean generalModule = NbPreferences.forModule(ReportWizardPanel1.class).getBoolean("generalModule", true); //NON-NLS
122  nextButton.setEnabled(!generalModule);
123  finishButton.setEnabled(generalModule);
124  }
125 
126  @Override
127  public void storeSettings(WizardDescriptor data) {
128  List<Long> selectedDataSources = getComponent().getSelectedElements();
129  data.putProperty("dataSourceSelections", selectedDataSources);
130  }
131 
132  @Override
133  public boolean isValid() {
134  return true;
135  }
136 
137  @Override
138  public void addChangeListener(ChangeListener cl) {
139  // Nothing to do
140  }
141 
142  @Override
143  public void removeChangeListener(ChangeListener cl) {
144  // Nothing to do
145  }
146 
147  @Override
148  public boolean isFinishPanel() {
149  return true;
150  }
151 }
List< Content > getDataSources()
Definition: Case.java:1703
void addElement(String displayName, Icon icon, T obj)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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