Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenHostsAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.datamodel.hosts;
20 
21 import java.awt.Frame;
22 import java.beans.PropertyChangeEvent;
23 import java.util.EnumSet;
24 import javax.swing.Action;
25 import org.openide.awt.ActionID;
26 import org.openide.awt.ActionRegistration;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.util.actions.CallableSystemAction;
31 import org.openide.windows.WindowManager;
33 
37 @ActionID(category = "Case", id = "org.sleuthkit.autopsy.datamodel.hosts.OpenHostsAction")
38 @ActionRegistration(displayName = "#CTL_OpenHosts", lazy = false)
39 @Messages({
40  "CTL_OpenHosts=Manage Hosts",})
41 public final class OpenHostsAction extends CallableSystemAction {
42 
43  private static final long serialVersionUID = 1L;
44 
48  OpenHostsAction() {
49  putValue(Action.NAME, Bundle.CTL_OpenHosts());
50  this.setEnabled(false);
51  Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
52  setEnabled(null != evt.getNewValue());
53  });
54  }
55 
56  @Override
57  public void performAction() {
58  Frame parent = WindowManager.getDefault().getMainWindow();
59  ManageHostsDialog dialog = new ManageHostsDialog(parent);
60  dialog.setResizable(false);
61  dialog.setLocationRelativeTo(parent);
62  dialog.setVisible(true);
63  dialog.toFront();
64  }
65 
66  @Override
67  @NbBundle.Messages("OpenHostsAction_displayName=Hosts")
68  public String getName() {
69  return Bundle.OpenHostsAction_displayName();
70  }
71 
72  @Override
73  public HelpCtx getHelpCtx() {
74  return HelpCtx.DEFAULT_HELP;
75  }
76 
77  @Override
78  public boolean asynchronous() {
79  return false; // run on edt
80  }
81 }
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:704

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.