Autopsy 4.22.1
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 */
19package org.sleuthkit.autopsy.discovery.ui;
20
21import java.awt.Component;
22import javax.swing.ImageIcon;
23import javax.swing.JButton;
24import javax.swing.SwingUtilities;
25import org.openide.awt.ActionID;
26import org.openide.awt.ActionReference;
27import org.openide.awt.ActionReferences;
28import org.openide.awt.ActionRegistration;
29import org.openide.util.HelpCtx;
30import org.openide.util.NbBundle;
31import org.openide.util.actions.CallableSystemAction;
32import org.openide.util.actions.Presenter;
33import org.sleuthkit.autopsy.casemodule.Case;
34import org.sleuthkit.autopsy.coreutils.ThreadConfined;
35
40@ActionID(category = "Tools", id = "org.sleuthkit.autopsy.newpackage.OpenDiscoveryAction")
41@ActionReferences(value = {
42 @ActionReference(path = "Menu/Tools", position = 105),
43 @ActionReference(path = "Toolbars/Case", position = 105)})
44@ActionRegistration(displayName = "#CTL_OpenDiscoveryAction", lazy = false)
45@NbBundle.Messages({"CTL_OpenDiscoveryAction=Discovery"})
46public 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 @Override
66 public void performAction() {
67 SwingUtilities.invokeLater(() -> {
68 final DiscoveryDialog discDialog = DiscoveryDialog.getDiscoveryDialogInstance();
69 discDialog.cancelSearch();
70 DiscoveryUiUtils.displayErrorMessage(discDialog);
71 discDialog.setVisible(true);
72 });
73 }
74
81 @Override
82 public Component getToolbarPresenter() {
83 ImageIcon icon = new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/discovery-icon-24.png")); //NON-NLS
84 toolbarButton.setIcon(icon);
85 toolbarButton.setText(this.getName());
86 return toolbarButton;
87 }
88
94 @Override
95 public void setEnabled(boolean value) {
96 super.setEnabled(value);
97 toolbarButton.setEnabled(value);
98 }
99
100 @Override
101 public String getName() {
102 return DISPLAY_NAME;
103 }
104
105 @Override
106 public HelpCtx getHelpCtx() {
107 return HelpCtx.DEFAULT_HELP;
108 }
109
110 @Override
111 public boolean asynchronous() {
112 return false; // run on edt
113 }
114}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.