Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenDiscoveryAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019-2020 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.discovery;
20 
21 import java.awt.Component;
22 import javax.swing.ImageIcon;
23 import javax.swing.JButton;
24 import javax.swing.SwingUtilities;
25 import org.openide.awt.ActionID;
26 import org.openide.awt.ActionReference;
27 import org.openide.awt.ActionReferences;
28 import org.openide.awt.ActionRegistration;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.NbBundle;
31 import org.openide.util.actions.CallableSystemAction;
32 import org.openide.util.actions.Presenter;
34 
39 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.newpackage.OpenDiscoveryAction")
40 @ActionReferences(value = {
41  @ActionReference(path = "Menu/Tools", position = 103)
42  ,
43  @ActionReference(path = "Toolbars/Case", position = 105)})
44 @ActionRegistration(displayName = "#CTL_OpenDiscoveryAction", lazy = false)
45 @NbBundle.Messages({"CTL_OpenDiscoveryAction=Discovery"})
46 public final class OpenDiscoveryAction extends CallableSystemAction implements Presenter.Toolbar {
47 
48  private static final String DISPLAY_NAME = Bundle.CTL_OpenDiscoveryAction();
49  private static final long serialVersionUID = 1L;
50  private final JButton toolbarButton = new JButton();
51 
56  toolbarButton.addActionListener(OpenDiscoveryAction.this::actionPerformed);
57  this.setEnabled(false);
58  }
59 
60  @Override
61  public boolean isEnabled() {
62  return Case.isCaseOpen();
63  }
64 
65  @NbBundle.Messages({"OpenDiscoveryAction.resultsIncomplete.text=Discovery results may be incomplete"})
66 
67  @Override
68  public void performAction() {
69  SwingUtilities.invokeLater(() -> {
70  final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
71  discDialog.cancelSearch();
72  DiscoveryUiUtils.displayErrorMessage(discDialog);
73  discDialog.setVisible(true);
74  });
75  }
76 
82  @Override
83  public Component getToolbarPresenter() {
84  ImageIcon icon = new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/discovery-icon-24.png")); //NON-NLS
85  toolbarButton.setIcon(icon);
86  toolbarButton.setText(this.getName());
87  return toolbarButton;
88  }
89 
95  @Override
96  public void setEnabled(boolean value) {
97  super.setEnabled(value);
98  toolbarButton.setEnabled(value);
99  }
100 
101  @Override
102  public String getName() {
103  return DISPLAY_NAME;
104  }
105 
106  @Override
107  public HelpCtx getHelpCtx() {
108  return HelpCtx.DEFAULT_HELP;
109  }
110 
111  @Override
112  public boolean asynchronous() {
113  return false; // run on edt
114  }
115 }

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