Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceComboBoxModel.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2018 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.guiutils;
21 
22 import javax.swing.AbstractListModel;
23 import javax.swing.ComboBoxModel;
24 import javax.swing.event.ListDataListener;
25 
29 public class DataSourceComboBoxModel extends AbstractListModel<String> implements ComboBoxModel<String> {
30 
31  private static final long serialVersionUID = 1L;
32  private final String[] dataSourceList;
33  private String selection = null;
34 
39  this.dataSourceList = new String[0];
40  }
41 
47  public DataSourceComboBoxModel(String... theDataSoureList) {
48  dataSourceList = theDataSoureList.clone();
49  }
50 
51  @Override
52  public void setSelectedItem(Object anItem) {
53  selection = (String) anItem;
54  }
55 
56  @Override
57  public Object getSelectedItem() {
58  return selection;
59  }
60 
61  @Override
62  public int getSize() {
63  return dataSourceList.length;
64  }
65 
66  @Override
67  public String getElementAt(int index) {
68  return dataSourceList[index];
69  }
70 
71  @Override
72  public void addListDataListener(ListDataListener listener) {
73  this.listenerList.add(ListDataListener.class, listener);
74  }
75 
76  @Override
77  public void removeListDataListener(ListDataListener listener) {
78  this.listenerList.remove(ListDataListener.class, listener);
79  }
80 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.