Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
WaypointDetailPanel.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.Point;
22 import java.awt.event.ActionListener;
23 import java.awt.event.MouseEvent;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.ImageIcon;
28 import javax.swing.JMenuItem;
29 import javax.swing.JPanel;
30 import javax.swing.JPopupMenu;
31 import javax.swing.JSeparator;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
38 final class WaypointDetailPanel extends JPanel {
39 
40  private static final long serialVersionUID = 1L;
41  private static final Logger logger = Logger.getLogger(WaypointDetailPanel.class.getName());
42 
43  private final List<ActionListener> listeners;
44 
45  private MapWaypoint waypoint;
46 
50  WaypointDetailPanel() {
51  initComponents();
52 
53  listeners = new ArrayList<>();
54  mainPanel.setBackground(detailsPane.getBackground());
55  }
56 
62  void setWaypoint(MapWaypoint waypoint) {
63  this.waypoint = waypoint;
64 
65  ImageIcon image = waypoint.getImage();
66  if (image != null) {
67  imageLabel.setIcon(image);
68  }
69  detailsPane.setText(waypoint.getHTMLFormattedWaypointDetails());
70  }
71 
77  void addActionListener(ActionListener listener) {
78  listeners.add(listener);
79  }
80 
86  void showPopupMenu(MouseEvent evt) {
87  if(evt.isPopupTrigger()) {
88  try {
89  showPopupMenu(evt.getPoint());
90  } catch (TskCoreException ex) {
91  logger.log(Level.WARNING, "Unable to show popup menu for selected waypoint");
92  }
93  }
94  }
95 
103  void showPopupMenu(Point point) throws TskCoreException {
104  JMenuItem[] items = waypoint.getMenuItems();
105  JPopupMenu popupMenu = new JPopupMenu();
106  for(JMenuItem menu: items) {
107 
108  if(menu != null) {
109  popupMenu.add(menu);
110  } else {
111  popupMenu.add(new JSeparator());
112  }
113  }
114  popupMenu.show(this, point.x, point.y);
115  }
116 
122  @SuppressWarnings("unchecked")
123  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
124  private void initComponents() {
125  java.awt.GridBagConstraints gridBagConstraints;
126 
127  buttonPanel = new javax.swing.JPanel();
128  closeButton = new javax.swing.JButton();
129  scrollPane = new javax.swing.JScrollPane();
130  mainPanel = new javax.swing.JPanel();
131  imageLabel = new javax.swing.JLabel();
132  detailsPane = new javax.swing.JTextPane();
133 
134  setMaximumSize(new java.awt.Dimension(300, 300));
135  setLayout(new java.awt.GridBagLayout());
136 
137  buttonPanel.setLayout(new java.awt.BorderLayout());
138 
139  closeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/close-icon.png"))); // NOI18N
140  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(WaypointDetailPanel.class, "WaypointDetailPanel.closeButton.text")); // NOI18N
141  closeButton.setBorder(null);
142  closeButton.setOpaque(false);
143  closeButton.addActionListener(new java.awt.event.ActionListener() {
144  public void actionPerformed(java.awt.event.ActionEvent evt) {
145  closeButtonActionPerformed(evt);
146  }
147  });
148  buttonPanel.add(closeButton, java.awt.BorderLayout.EAST);
149 
150  gridBagConstraints = new java.awt.GridBagConstraints();
151  gridBagConstraints.gridx = 0;
152  gridBagConstraints.gridy = 0;
153  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
154  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
155  gridBagConstraints.weightx = 1.0;
156  add(buttonPanel, gridBagConstraints);
157 
158  mainPanel.setMaximumSize(new java.awt.Dimension(300, 300));
159  mainPanel.addMouseListener(new java.awt.event.MouseAdapter() {
160  public void mousePressed(java.awt.event.MouseEvent evt) {
161  mainPanelMousePressed(evt);
162  }
163  public void mouseReleased(java.awt.event.MouseEvent evt) {
164  mainPanelMouseReleased(evt);
165  }
166  });
167  mainPanel.setLayout(new java.awt.GridBagLayout());
168 
169  org.openide.awt.Mnemonics.setLocalizedText(imageLabel, org.openide.util.NbBundle.getMessage(WaypointDetailPanel.class, "WaypointDetailPanel.imageLabel.text")); // NOI18N
170  imageLabel.addMouseListener(new java.awt.event.MouseAdapter() {
171  public void mousePressed(java.awt.event.MouseEvent evt) {
172  imageLabelMousePressed(evt);
173  }
174  public void mouseReleased(java.awt.event.MouseEvent evt) {
175  imageLabelMouseReleased(evt);
176  }
177  });
178  gridBagConstraints = new java.awt.GridBagConstraints();
179  gridBagConstraints.gridx = 0;
180  gridBagConstraints.gridy = 0;
181  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
182  mainPanel.add(imageLabel, gridBagConstraints);
183 
184  detailsPane.setEditable(false);
185  detailsPane.setContentType("text/html");
186  detailsPane.setMaximumSize(new java.awt.Dimension(300, 300));
187  detailsPane.addMouseListener(new java.awt.event.MouseAdapter() {
188  public void mousePressed(java.awt.event.MouseEvent evt) {
189  detailsPaneMousePressed(evt);
190  }
191  public void mouseReleased(java.awt.event.MouseEvent evt) {
192  detailsPaneMouseReleased(evt);
193  }
194  });
195  gridBagConstraints = new java.awt.GridBagConstraints();
196  gridBagConstraints.gridx = 0;
197  gridBagConstraints.gridy = 1;
198  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
199  gridBagConstraints.weightx = 1.0;
200  gridBagConstraints.weighty = 1.0;
201  mainPanel.add(detailsPane, gridBagConstraints);
202 
203  scrollPane.setViewportView(mainPanel);
204 
205  gridBagConstraints = new java.awt.GridBagConstraints();
206  gridBagConstraints.gridx = 0;
207  gridBagConstraints.gridy = 1;
208  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
209  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
210  gridBagConstraints.weightx = 1.0;
211  gridBagConstraints.weighty = 1.0;
212  add(scrollPane, gridBagConstraints);
213  }// </editor-fold>//GEN-END:initComponents
214 
215  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
216  for (ActionListener listener : listeners) {
217  listener.actionPerformed(evt);
218  }
219  }//GEN-LAST:event_closeButtonActionPerformed
220 
221  private void mainPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPanelMousePressed
222  showPopupMenu(evt);
223  }//GEN-LAST:event_mainPanelMousePressed
224 
225  private void mainPanelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPanelMouseReleased
226  showPopupMenu(evt);
227  }//GEN-LAST:event_mainPanelMouseReleased
228 
229  private void detailsPaneMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_detailsPaneMousePressed
230  showPopupMenu(evt);
231  }//GEN-LAST:event_detailsPaneMousePressed
232 
233  private void detailsPaneMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_detailsPaneMouseReleased
234  showPopupMenu(evt);
235  }//GEN-LAST:event_detailsPaneMouseReleased
236 
237  private void imageLabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imageLabelMousePressed
238  showPopupMenu(evt);
239  }//GEN-LAST:event_imageLabelMousePressed
240 
241  private void imageLabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imageLabelMouseReleased
242  showPopupMenu(evt);
243  }//GEN-LAST:event_imageLabelMouseReleased
244 
245 
246  // Variables declaration - do not modify//GEN-BEGIN:variables
247  private javax.swing.JPanel buttonPanel;
248  private javax.swing.JButton closeButton;
249  private javax.swing.JTextPane detailsPane;
250  private javax.swing.JLabel imageLabel;
251  private javax.swing.JPanel mainPanel;
252  private javax.swing.JScrollPane scrollPane;
253  // End of variables declaration//GEN-END:variables
254 }

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.