Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenCommVisualizationToolAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-18 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.communications;
20 
21 import java.awt.Component;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import javax.swing.ImageIcon;
25 import javax.swing.JButton;
26 import org.openide.awt.ActionID;
27 import org.openide.awt.ActionReference;
28 import org.openide.awt.ActionReferences;
29 import org.openide.awt.ActionRegistration;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32 import org.openide.util.NbBundle.Messages;
33 import org.openide.util.actions.CallableSystemAction;
34 import org.openide.windows.TopComponent;
35 import org.openide.windows.WindowManager;
38 
43 @ActionID(category = "Tools",
44  id = "org.sleuthkit.autopsy.communicationsVisualization.OpenCVTAction")
45 @ActionRegistration(displayName = "#CTL_OpenCVTAction", lazy = false)
46 @ActionReferences(value = {
47  @ActionReference(path = "Menu/Tools", position = 102)
48  ,
49  @ActionReference(path = "Toolbars/Case", position = 102)})
50 @Messages("CTL_OpenCVTAction=Communications")
51 public final class OpenCommVisualizationToolAction extends CallableSystemAction {
52 
53  private static final long serialVersionUID = 1L;
54  private final PropertyChangeListener pcl;
55  private final JButton toolbarButton = new JButton(getName(),
56  new ImageIcon(getClass().getResource("images/emblem-web24.png"))); //NON-NLS
57 
59  toolbarButton.addActionListener(actionEvent -> performAction());
60  setEnabled(false); //disabled by default. Will be enabled in Case.java when a case is opened.
61  pcl = (PropertyChangeEvent evt) -> {
62  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
63  setEnabled(RuntimeProperties.runningWithGUI() && evt.getNewValue() != null);
64  }
65  };
67 
68  }
69 
70  @Override
71  public void performAction() {
72  final TopComponent tc = WindowManager.getDefault().findTopComponent("CVTTopComponent");
73  if (tc != null) {
74  if (tc.isOpened() == false) {
75  tc.open();
76  }
77  tc.toFront();
78  tc.requestActive();
79  }
80  }
81 
87  @Override
88  public void setEnabled(boolean value) {
89  super.setEnabled(value);
90  toolbarButton.setEnabled(value);
91  }
92 
93  @Override
94  @NbBundle.Messages("OpenCVTAction.displayName=Communications")
95  public String getName() {
96  return Bundle.OpenCVTAction_displayName();
97  }
98 
104  @Override
105  public Component getToolbarPresenter() {
106  return toolbarButton;
107  }
108 
109  @Override
110  public HelpCtx getHelpCtx() {
111  return HelpCtx.DEFAULT_HELP;
112  }
113 
114  @Override
115  public boolean asynchronous() {
116  return false; // run on edt
117  }
118 }
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:671

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