Autopsy  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 
144  @Override
145  public void addPropertyChangeListener(PropertyChangeListener l) {
146  filterPanel.addPropertyChangeListener(l);
147  settingsPanel.addPropertyChangeListener(l);
148  profilePanel.addPropertyChangeListener(l);
149  }
150 
154  @Override
155  public void removePropertyChangeListener(PropertyChangeListener l) {
156  filterPanel.removePropertyChangeListener(l);
157  settingsPanel.removePropertyChangeListener(l);
158  profilePanel.removePropertyChangeListener(l);
159  }
160 
164  @Override
165  public void saveSettings() {
166  saveTabByIndex(tabbedPane.getSelectedIndex());
167  }
168 
174  private void saveTabByIndex(int index) {
175  //Because we can create filters in two seperate windows here we need
176  //to be careful not to save an out of date list over the current list
177  switch (index) {
178  case (INDEX_OF_FILTER_PANEL):
180  break;
181  case (INDEX_OF_PROFILE_PANEL):
182  profilePanel.saveSettings();
183  break;
184  case (INDEX_OF_SETTINGS_PANEL):
185  settingsPanel.saveSettings();
186  break;
187  default:
188  //don't save anything if it wasn't a tab index that should exist
189  }
190  }
191 
195  @Override
196  public void store() {
197  saveSettings();
198  }
199 
203  @Override
204  public void load() {
205  filterPanel.load();
206  settingsPanel.load();
207  profilePanel.load();
208  }
209 
210  boolean valid() {
211  return true;
212  }
213 
217  void cancel() {
218  //doesn't need to do anything
219  }
220 
226  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
227  private void initComponents() {
228 
229  tabbedPane = new javax.swing.JTabbedPane();
230 
231  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
232  this.setLayout(layout);
233  layout.setHorizontalGroup(
234  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addGroup(layout.createSequentialGroup()
236  .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 824, Short.MAX_VALUE)
237  .addGap(0, 0, 0))
238  );
239  layout.setVerticalGroup(
240  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241  .addGroup(layout.createSequentialGroup()
242  .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
243  .addGap(0, 0, 0))
244  );
245  }// </editor-fold>//GEN-END:initComponents
246 
247  // Variables declaration - do not modify//GEN-BEGIN:variables
248  private javax.swing.JTabbedPane tabbedPane;
249  // End of variables declaration//GEN-END:variables
250 }
static synchronized IngestManager getInstance()
void addPropertyChangeListener(PropertyChangeListener l)
void addIngestJobEventListener(final PropertyChangeListener listener)
void removePropertyChangeListener(PropertyChangeListener l)

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