Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportCaseUcoConfigPanel.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2019-2019 Basis Technology Corp.
6  * Contact: carrier <at> sleuthkit <dot> org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.sleuthkit.autopsy.report.caseuco;
21 
22 import java.sql.SQLException;
23 import java.util.Map;
24 import java.util.Map.Entry;
25 import javax.swing.ComboBoxModel;
29 import org.sleuthkit.datamodel.TskCoreException;
30 
36 final class ReportCaseUcoConfigPanel extends javax.swing.JPanel {
37 
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;
43 
47  ReportCaseUcoConfigPanel() throws NoCurrentCaseException, TskCoreException, SQLException {
48  initComponents();
49  this.dataSourceLoader = new DataSourceLoader();
50  this.dataSourceMap = dataSourceLoader.getDataSourceMap();
51 
52  String[] dataSourcesNames = new String[dataSourceMap.size()];
53  if (dataSourcesNames.length > 0) {
54  dataSourcesNames = dataSourceMap.values().toArray(dataSourcesNames);
55  setDatasourceComboboxModel(new DataSourceComboBoxModel(dataSourcesNames));
56 
57  selectDataSourceComboBox.setEnabled(true);
58  selectDataSourceComboBox.setSelectedIndex(0);
59  }
60  }
61 
68  Long getSelectedDataSourceId() {
69  for (Entry<Long, String> entry : this.dataSourceMap.entrySet()) {
70  if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) {
71  return entry.getKey();
72  }
73  }
74  return ReportCaseUcoConfigPanel.NO_DATA_SOURCE_SELECTED;
75  }
76 
82  @SuppressWarnings("unchecked")
83  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
84  private void initComponents() {
85 
86  selectDataSourceComboBox = new javax.swing.JComboBox<>();
87  jLabelSelectDataSource = new javax.swing.JLabel();
88 
89  selectDataSourceComboBox.setModel(dataSourcesList);
90  selectDataSourceComboBox.setEnabled(false);
91 
92  jLabelSelectDataSource.setText(org.openide.util.NbBundle.getMessage(ReportCaseUcoConfigPanel.class, "ReportCaseUcoConfigPanel.jLabelSelectDataSource.text")); // NOI18N
93 
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()
99  .addGap(21, 21, 21)
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))
105  .addContainerGap())
106  );
107  layout.setVerticalGroup(
108  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109  .addGroup(layout.createSequentialGroup()
110  .addGap(11, 11, 11)
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))
115  );
116  }// </editor-fold>//GEN-END:initComponents
117 
118  // Variables declaration - do not modify//GEN-BEGIN:variables
119  private javax.swing.JLabel jLabelSelectDataSource;
120  private javax.swing.JComboBox<String> selectDataSourceComboBox;
121  // End of variables declaration//GEN-END:variables
122 
129  void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) {
130  this.dataSourcesList = dataSourceComboBoxModel;
131  this.selectDataSourceComboBox.setModel(dataSourcesList);
132  }
133 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.