Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenGeolocationAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.geolocation;
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.Messages;
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.windows.TopComponent;
34 import org.openide.windows.WindowManager;
37 
43 @ActionID(category = "Tools",
44  id = "org.sleuthkit.autopsy.geolocation.OpenGeolocationAction")
45 @ActionRegistration(displayName = "#CTL_OpenGeolocation", lazy = false)
46 @ActionReferences(value = {
47  @ActionReference(path = "Menu/Tools", position = 103),
48 @ActionReference(path = "Toolbars/Case", position = 103)})
49 public class OpenGeolocationAction extends CallableSystemAction {
50 
51  private static final long serialVersionUID = 1L;
52  private final JButton toolbarButton = new JButton(getName(),
53  new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/blueGeo24.png"))); //NON-NLS
54 
55  @Messages({
56  "OpenGeolocationAction_name=Geolocation",
57  "OpenGeolocationAction_displayName=Geolocation"
58  })
59 
64  toolbarButton.addActionListener(actionEvent -> performAction());
65  setEnabled(false); //disabled by default. Will be enabled in Case.java when a case is opened.
66 
67  PropertyChangeListener caseChangeListener = (PropertyChangeEvent evt) -> {
68  if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
69  setEnabled(RuntimeProperties.runningWithGUI() && evt.getNewValue() != null);
70  }
71  };
72 
73  Case.addPropertyChangeListener(caseChangeListener);
74  }
75 
76  @Override
77  public void performAction() {
78  final TopComponent topComponent = WindowManager.getDefault().findTopComponent("GeolocationTopComponent");
79  if (topComponent != null) {
80  if (topComponent.isOpened() == false) {
81  topComponent.open();
82  }
83  topComponent.toFront();
84  topComponent.requestActive();
85  }
86  }
87 
93  @Override
94  public void setEnabled(boolean value) {
95  super.setEnabled(value);
96  toolbarButton.setEnabled(value);
97  }
98 
99  @Override
100  public String getName() {
101  return Bundle.OpenGeolocationAction_displayName();
102  }
103 
109  @Override
110  public Component getToolbarPresenter() {
111  return toolbarButton;
112  }
113 
114  @Override
115  public HelpCtx getHelpCtx() {
116  return HelpCtx.DEFAULT_HELP;
117  }
118 
119  @Override
120  public boolean asynchronous() {
121  return false; // run on edt
122  }
123 
124 }
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:454

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