Autopsy  4.5.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 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 javax.swing.ImageIcon;
23 import javax.swing.JButton;
24 import org.openide.awt.ActionID;
25 import org.openide.awt.ActionReference;
26 import org.openide.awt.ActionReferences;
27 import org.openide.awt.ActionRegistration;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30 import org.openide.util.NbBundle.Messages;
31 import org.openide.util.actions.CallableSystemAction;
32 import org.openide.util.actions.Presenter;
33 import org.openide.windows.TopComponent;
34 import org.openide.windows.WindowManager;
35 
40 @ActionID(category = "Tools",
41  id = "org.sleuthkit.autopsy.communicationsVisualization.OpenCVTAction")
42 @ActionRegistration(displayName = "#CTL_OpenCVTAction", lazy = false)
43 @ActionReferences(value = {
44  @ActionReference(path = "Menu/Tools", position = 102)})
45 @Messages("CTL_OpenCVTAction=Communications")
46 public final class OpenCommVisualizationToolAction extends CallableSystemAction implements Presenter.Toolbar {
47 
48  private static final long serialVersionUID = 1L;
49 
50  private final JButton toolbarButton = new JButton(getName(),
51  new ImageIcon(getClass().getResource("images/emblem-web24.png"))); //NON-NLS
52 
54  toolbarButton.addActionListener(actionEvent -> performAction());
55  setEnabled(false); //disabled by default. Will be enabled in Case.java when a case is opened.
56  }
57 
58  @Override
59  public void performAction() {
60  final TopComponent tc = WindowManager.getDefault().findTopComponent("CVTTopComponent");
61  if (tc != null) {
62  if (tc.isOpened() == false) {
63  tc.open();
64  }
65  tc.toFront();
66  tc.requestActive();
67  }
68  }
69 
75  @Override
76  public void setEnabled(boolean value) {
77  super.setEnabled(value);
78  toolbarButton.setEnabled(value);
79  }
80 
81  @Override
82  @NbBundle.Messages("OpenCVTAction.displayName=Communications")
83  public String getName() {
84  return Bundle.OpenCVTAction_displayName();
85  }
86 
92  @Override
93  public Component getToolbarPresenter() {
94  return toolbarButton;
95  }
96 
97  @Override
98  public HelpCtx getHelpCtx() {
99  return HelpCtx.DEFAULT_HELP;
100  }
101 
102  @Override
103  public boolean asynchronous() {
104  return false; // run on edt
105  }
106 }

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