Autopsy  4.16.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.ui;
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 = 105),
42  @ActionReference(path = "Toolbars/Case", position = 105)})
43 @ActionRegistration(displayName = "#CTL_OpenDiscoveryAction", lazy = false)
44 @NbBundle.Messages({"CTL_OpenDiscoveryAction=Discovery"})
45 public final class OpenDiscoveryAction extends CallableSystemAction implements Presenter.Toolbar {
46 
47  private static final String DISPLAY_NAME = Bundle.CTL_OpenDiscoveryAction();
48  private static final long serialVersionUID = 1L;
49  private final JButton toolbarButton = new JButton();
50 
55  toolbarButton.addActionListener(OpenDiscoveryAction.this::actionPerformed);
56  this.setEnabled(false);
57  }
58 
59  @Override
60  public boolean isEnabled() {
61  return Case.isCaseOpen();
62  }
63 
64  @Override
65  public void performAction() {
66  SwingUtilities.invokeLater(() -> {
67  final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
68  discDialog.cancelSearch();
69  DiscoveryUiUtils.displayErrorMessage(discDialog);
70  discDialog.setVisible(true);
71  });
72  }
73 
79  @Override
80  public Component getToolbarPresenter() {
81  ImageIcon icon = new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/discovery-icon-24.png")); //NON-NLS
82  toolbarButton.setIcon(icon);
83  toolbarButton.setText(this.getName());
84  return toolbarButton;
85  }
86 
92  @Override
93  public void setEnabled(boolean value) {
94  super.setEnabled(value);
95  toolbarButton.setEnabled(value);
96  }
97 
98  @Override
99  public String getName() {
100  return DISPLAY_NAME;
101  }
102 
103  @Override
104  public HelpCtx getHelpCtx() {
105  return HelpCtx.DEFAULT_HELP;
106  }
107 
108  @Override
109  public boolean asynchronous() {
110  return false; // run on edt
111  }
112 }

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