Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CommonAttributeSearchAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 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.commonpropertiessearch;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.concurrent.ExecutionException;
23 import java.util.logging.Level;
24 import javax.swing.SwingWorker;
25 import org.openide.DialogDisplayer;
26 import org.openide.NotifyDescriptor;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.util.actions.CallableSystemAction;
33 
37 final public class CommonAttributeSearchAction extends CallableSystemAction {
38 
40 
41  private static CommonAttributeSearchAction instance = null;
42  private static final long serialVersionUID = 1L;
43 
49  public static synchronized CommonAttributeSearchAction getDefault() {
50  if (instance == null) {
51  instance = new CommonAttributeSearchAction();
52  }
53  return instance;
54  }
55 
61  super();
62  this.setEnabled(false);
63  }
64 
65  @Override
66  public boolean isEnabled() {
67  return super.isEnabled() && Case.isCaseOpen();
68  }
69 
70  @Override
71  public void actionPerformed(ActionEvent event) {
73  }
74 
75  @Override
76  public void performAction() {
78  }
79 
83  @NbBundle.Messages({
84  "CommonAttributeSearchAction.openPanel.intro=The find common properties feature is not available because:",
85  "CommonAttributeSearchAction.openPanel.resolution=\n\nAddress one of these issues to enable this feature.",
86  "CommonAttributeSearchAction.openPanel.noCaseOpen=\n - No case is open.",
87  "CommonAttributeSearchAction.openPanel.notEnoughDataSources=\n - There are not multiple data sources in the current case.",
88  "CommonAttributeSearchAction.openPanel.centralRepoDisabled=\n - The Central Repository is disabled.",
89  "CommonAttributeSearchAction.openPanel.caseNotInCentralRepo=\n - The current case is not in the Central Repository.",
90  "CommonAttributeSearchAction.openPanel.notEnoughCases=\n - Fewer than 2 cases exist in the Central Repository.",
91  "CommonAttributeSearchAction.openPanel.centralRepoInvalid=\n - The Central Repository configuration is invalid."})
92  private void createAndShowPanel() {
93  new SwingWorker<Boolean, Void>() {
94 
95  String reason = Bundle.CommonAttributeSearchAction_openPanel_intro();
96 
97  @Override
98  protected Boolean doInBackground() throws Exception {
99  // Test whether we should open the common files panel
100  if (!Case.isCaseOpen()) {
101  reason += Bundle.CommonAttributeSearchAction_openPanel_noCaseOpen();
102  return false;
103  }
104  if (Case.getCurrentCase().getDataSources().size() > 1) {
105  // There are enough data sources to run the intra case seach
106  return true;
107  } else {
108  reason += Bundle.CommonAttributeSearchAction_openPanel_notEnoughDataSources();
109  }
110  if (!CentralRepository.isEnabled()) {
111  reason += Bundle.CommonAttributeSearchAction_openPanel_centralRepoDisabled();
112  return false;
113  }
114  if (CentralRepository.getInstance() == null) {
115  reason += Bundle.CommonAttributeSearchAction_openPanel_centralRepoInvalid();
116  return false;
117  }
118  if (CentralRepository.getInstance().getCases().size() < 2) {
119  reason += Bundle.CommonAttributeSearchAction_openPanel_notEnoughCases();
120  return false;
121  }
123  reason += Bundle.CommonAttributeSearchAction_openPanel_caseNotInCentralRepo();
124  return false;
125  }
126  return true;
127  }
128 
129  @Override
130 
131  protected void done() {
132  super.done();
133  try {
134  boolean openPanel = get();
135  if (openPanel) {
136  CommonAttributePanel commonAttributePanel = new CommonAttributePanel();
137  //In order to update errors the CommonAttributePanel needs to observe its sub panels
138  commonAttributePanel.observeSubPanels();
139  commonAttributePanel.setVisible(true);
140  } else {
141  reason += Bundle.CommonAttributeSearchAction_openPanel_resolution();
142  NotifyDescriptor descriptor = new NotifyDescriptor.Message(reason, NotifyDescriptor.INFORMATION_MESSAGE);
143  DialogDisplayer.getDefault().notify(descriptor);
144  }
145  } catch (InterruptedException | ExecutionException ex) {
146  LOGGER.log(Level.SEVERE, "Unexpected exception while opening Find Common Properties", ex); //NON-NLS
147  }
148  }
149  }
150  .execute();
151  }
152 
153  @NbBundle.Messages({
154  "CommonAttributeSearchAction.getName.text=Find Common Properties"})
155  @Override
156  public String getName() {
157  return Bundle.CommonAttributeSearchAction_getName_text();
158  }
159 
160  @Override
161  public HelpCtx getHelpCtx() {
162  return HelpCtx.DEFAULT_HELP;
163  }
164 }
List< Content > getDataSources()
Definition: Case.java:1438
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.