Autopsy  4.4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestOptionsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 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.ingest;
20 
21 import java.awt.EventQueue;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import javax.swing.JTabbedPane;
25 import javax.swing.event.ChangeEvent;
26 import javax.swing.event.ChangeListener;
27 import org.openide.util.NbBundle;
31 
36 
37  @NbBundle.Messages({"IngestOptionsPanel.settingsTab.text=Settings",
38  "IngestOptionsPanel.settingsTab.toolTipText=Settings regarding resources available to ingest.",
39  "IngestOptionsPanel.fileFiltersTab.text=File Filters",
40  "IngestOptionsPanel.fileFiltersTab.toolTipText=Settings for creating and editing ingest file filters.",
41  "IngestOptionsPanel.profilesTab.text=Profiles",
42  "IngestOptionsPanel.profilesTab.toolTipText=Settings for creating and editing profiles."})
43 
45  private final static int INDEX_OF_FILTER_PANEL = 0;
46  private IngestSettingsPanel settingsPanel;
47  private final static int INDEX_OF_SETTINGS_PANEL = 2;
48  private ProfileSettingsPanel profilePanel;
49  private final static int INDEX_OF_PROFILE_PANEL = 1;
50  private int indexOfPreviousTab;
57  IngestJobEventPropertyChangeListener ingestJobEventsListener;
58 
59  public IngestOptionsPanel() {
62  indexOfPreviousTab = tabbedPane.getSelectedIndex();
63  }
64 
65  private void customizeComponents() {
67  settingsPanel = new IngestSettingsPanel();
68  profilePanel = new ProfileSettingsPanel();
69 
70  tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.text"), null,
71  filterPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.toolTipText"), INDEX_OF_FILTER_PANEL);
72  tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null,
73  profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), INDEX_OF_PROFILE_PANEL);
74  tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.settingsTab.text"), null,
75  settingsPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.settingsTab.toolTipText"), INDEX_OF_SETTINGS_PANEL);
76  //Listener for when tabbed panes are switched, because we can have two file filter definitions panels open at the same time
77  //we may wind up in a situation where the user has created and saved one in the profiles panel
78  //so we need to refresh the filterPanel in those cases before proceeding.
79  tabbedPane.addChangeListener(new ChangeListener() {
80  @Override
81  public void stateChanged(ChangeEvent e) {
82  if (e.getSource() instanceof JTabbedPane) {
83  //If we are switching to a filter panel we should load
84  //load the filter panel to ensure it is up to date
85  //incase a filter was addded through the Profile->new->create new filter manner
86  if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL && tabbedPane.getSelectedIndex() != indexOfPreviousTab) {
87  filterPanel.load();
88  }
89  //save the contents of whichever Tab we just switched from
90  saveTabByIndex(indexOfPreviousTab);
91  //save the index of the current tab for the next time we switch
92  indexOfPreviousTab = tabbedPane.getSelectedIndex();
93  }
94  }
95  });
96 
98  enableTabs();
99  }
100 
107  private void addIngestJobEventsListener() {
108  ingestJobEventsListener = new IngestJobEventPropertyChangeListener();
109  IngestManager.getInstance().addIngestJobEventListener(ingestJobEventsListener);
110  }
111 
115  private class IngestJobEventPropertyChangeListener implements PropertyChangeListener {
116 
117  @Override
118  public void propertyChange(PropertyChangeEvent evt) {
119  EventQueue.invokeLater(new Runnable() {
120  @Override
121  public void run() {
122  enableTabs();
123  }
124  });
125  }
126  }
127 
132  private void enableTabs() {
133  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
134  tabbedPane.setEnabled(!ingestIsRunning);
135  settingsPanel.enableButtons(!ingestIsRunning);
136  profilePanel.enableButtons(!ingestIsRunning);
137  filterPanel.enableButtons(!ingestIsRunning);
138 
139  }
140 
141  @Override
142  public void addPropertyChangeListener(PropertyChangeListener l) {
143  filterPanel.addPropertyChangeListener(l);
144  settingsPanel.addPropertyChangeListener(l);
145  profilePanel.addPropertyChangeListener(l);
146  }
147 
148  @Override
149  public void removePropertyChangeListener(PropertyChangeListener l) {
150  filterPanel.removePropertyChangeListener(l);
151  settingsPanel.removePropertyChangeListener(l);
152  profilePanel.removePropertyChangeListener(l);
153  }
154 
155  @Override
156  public void saveSettings() {
157  saveTabByIndex(tabbedPane.getSelectedIndex());
158  }
159 
165  private void saveTabByIndex(int index) {
166  //Because we can create filters in two seperate windows here we need
167  //to be careful not to save an out of date list over the current list
168  switch (index) {
169  case (INDEX_OF_FILTER_PANEL):
171  break;
172  case (INDEX_OF_PROFILE_PANEL):
173  profilePanel.saveSettings();
174  break;
175  case (INDEX_OF_SETTINGS_PANEL):
176  settingsPanel.saveSettings();
177  break;
178  default:
179  //don't save anything if it wasn't a tab index that should exist
180  }
181  }
182 
183  @Override
184  public void store() {
185  saveSettings();
186  }
187 
188  @Override
189  public void load() {
190  filterPanel.load();
191  settingsPanel.load();
192  profilePanel.load();
193  }
194 
195  boolean valid() {
196  return true;
197  }
198 
202  void cancel() {
203  //doesn't need to do anything
204  }
205 
211  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
212  private void initComponents() {
213 
214  tabbedPane = new javax.swing.JTabbedPane();
215 
216  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
217  this.setLayout(layout);
218  layout.setHorizontalGroup(
219  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
220  .addGroup(layout.createSequentialGroup()
221  .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 824, Short.MAX_VALUE)
222  .addGap(0, 0, 0))
223  );
224  layout.setVerticalGroup(
225  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
226  .addGroup(layout.createSequentialGroup()
227  .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
228  .addGap(0, 0, 0))
229  );
230  }// </editor-fold>//GEN-END:initComponents
231 
232  // Variables declaration - do not modify//GEN-BEGIN:variables
233  private javax.swing.JTabbedPane tabbedPane;
234  // End of variables declaration//GEN-END:variables
235 }
static synchronized IngestManager getInstance()
void addPropertyChangeListener(PropertyChangeListener l)
void addIngestJobEventListener(final PropertyChangeListener listener)
void removePropertyChangeListener(PropertyChangeListener l)

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.