20 package org.sleuthkit.autopsy.report.caseuco;
 
   22 import java.sql.SQLException;
 
   24 import java.util.Map.Entry;
 
   25 import javax.swing.ComboBoxModel;
 
   36 final class ReportCaseUcoConfigPanel 
extends javax.swing.JPanel {
 
   38     private static final long serialVersionUID = 1L;
 
   39     static final long NO_DATA_SOURCE_SELECTED = -1;
 
   40     private ComboBoxModel<String> dataSourcesList = 
new DataSourceComboBoxModel();
 
   41     private final Map<Long, String> dataSourceMap;
 
   42     private final DataSourceLoader dataSourceLoader;
 
   47     ReportCaseUcoConfigPanel() throws NoCurrentCaseException, TskCoreException, SQLException {
 
   49         this.dataSourceLoader = 
new DataSourceLoader();
 
   50         this.dataSourceMap = dataSourceLoader.getDataSourceMap();
 
   52         String[] dataSourcesNames = 
new String[dataSourceMap.size()];
 
   53         if (dataSourcesNames.length > 0) {
 
   54             dataSourcesNames = dataSourceMap.values().toArray(dataSourcesNames);
 
   55             setDatasourceComboboxModel(
new DataSourceComboBoxModel(dataSourcesNames));
 
   57             selectDataSourceComboBox.setEnabled(
true);
 
   58             selectDataSourceComboBox.setSelectedIndex(0);
 
   68     Long getSelectedDataSourceId() {
 
   69         for (Entry<Long, String> entry : this.dataSourceMap.entrySet()) {
 
   70             if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) {
 
   71                 return entry.getKey();
 
   74         return ReportCaseUcoConfigPanel.NO_DATA_SOURCE_SELECTED;
 
   82     @SuppressWarnings(
"unchecked")
 
   84     private 
void initComponents() {
 
   86         selectDataSourceComboBox = 
new javax.swing.JComboBox<>();
 
   87         jLabelSelectDataSource = 
new javax.swing.JLabel();
 
   89         selectDataSourceComboBox.setModel(dataSourcesList);
 
   90         selectDataSourceComboBox.setEnabled(
false);
 
   92         jLabelSelectDataSource.setText(
org.openide.util.NbBundle.getMessage(ReportCaseUcoConfigPanel.class, 
"ReportCaseUcoConfigPanel.jLabelSelectDataSource.text")); 
 
   94         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
   95         this.setLayout(layout);
 
   96         layout.setHorizontalGroup(
 
   97             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
   98             .addGroup(layout.createSequentialGroup()
 
  100                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  101                     .addGroup(layout.createSequentialGroup()
 
  102                         .addComponent(jLabelSelectDataSource)
 
  103                         .addGap(0, 0, Short.MAX_VALUE))
 
  104                     .addComponent(selectDataSourceComboBox, 0, 348, Short.MAX_VALUE))
 
  107         layout.setVerticalGroup(
 
  108             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  109             .addGroup(layout.createSequentialGroup()
 
  111                 .addComponent(jLabelSelectDataSource)
 
  112                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  113                 .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  114                 .addContainerGap(130, Short.MAX_VALUE))
 
  119     private javax.swing.JLabel jLabelSelectDataSource;
 
  120     private javax.swing.JComboBox<String> selectDataSourceComboBox;
 
  129     void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
 
  130         this.dataSourcesList = dataSourceComboBoxModel;
 
  131         this.selectDataSourceComboBox.setModel(dataSourcesList);