19 package org.sleuthkit.autopsy.geolocation;
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;
38 final class WaypointDetailPanel
extends JPanel {
40 private static final long serialVersionUID = 1L;
41 private static final Logger logger = Logger.getLogger(WaypointDetailPanel.class.getName());
43 private final List<ActionListener> listeners;
45 private MapWaypoint waypoint;
50 WaypointDetailPanel() {
53 listeners =
new ArrayList<>();
54 mainPanel.setBackground(detailsPane.getBackground());
62 void setWaypoint(MapWaypoint waypoint) {
63 this.waypoint = waypoint;
65 ImageIcon image = waypoint.getImage();
67 imageLabel.setIcon(image);
69 detailsPane.setText(waypoint.getHTMLFormattedWaypointDetails());
77 void addActionListener(ActionListener listener) {
78 listeners.add(listener);
86 void showPopupMenu(MouseEvent evt) {
87 if(evt.isPopupTrigger()) {
89 showPopupMenu(evt.getPoint());
90 }
catch (TskCoreException ex) {
91 logger.log(Level.WARNING,
"Unable to show popup menu for selected waypoint");
103 void showPopupMenu(Point point)
throws TskCoreException {
104 JMenuItem[] items = waypoint.getMenuItems();
105 JPopupMenu popupMenu =
new JPopupMenu();
106 for(JMenuItem menu: items) {
111 popupMenu.add(
new JSeparator());
114 popupMenu.show(
this, point.x, point.y);
122 @SuppressWarnings(
"unchecked")
124 private
void initComponents() {
125 java.awt.GridBagConstraints gridBagConstraints;
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();
134 setMaximumSize(
new java.awt.Dimension(300, 300));
135 setLayout(
new java.awt.GridBagLayout());
137 buttonPanel.setLayout(
new java.awt.BorderLayout());
139 closeButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/close-icon.png")));
140 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(WaypointDetailPanel.class,
"WaypointDetailPanel.closeButton.text"));
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);
148 buttonPanel.add(closeButton, java.awt.BorderLayout.EAST);
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);
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);
163 public void mouseReleased(java.awt.event.MouseEvent evt) {
164 mainPanelMouseReleased(evt);
167 mainPanel.setLayout(
new java.awt.GridBagLayout());
169 org.openide.awt.Mnemonics.setLocalizedText(imageLabel,
org.openide.util.NbBundle.getMessage(WaypointDetailPanel.class,
"WaypointDetailPanel.imageLabel.text"));
170 imageLabel.addMouseListener(
new java.awt.event.MouseAdapter() {
171 public void mousePressed(java.awt.event.MouseEvent evt) {
172 imageLabelMousePressed(evt);
174 public void mouseReleased(java.awt.event.MouseEvent evt) {
175 imageLabelMouseReleased(evt);
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);
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);
191 public void mouseReleased(java.awt.event.MouseEvent evt) {
192 detailsPaneMouseReleased(evt);
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);
203 scrollPane.setViewportView(mainPanel);
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);
215 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
216 for (ActionListener listener : listeners) {
217 listener.actionPerformed(evt);
221 private void mainPanelMousePressed(java.awt.event.MouseEvent evt) {
225 private void mainPanelMouseReleased(java.awt.event.MouseEvent evt) {
229 private void detailsPaneMousePressed(java.awt.event.MouseEvent evt) {
233 private void detailsPaneMouseReleased(java.awt.event.MouseEvent evt) {
237 private void imageLabelMousePressed(java.awt.event.MouseEvent evt) {
241 private void imageLabelMouseReleased(java.awt.event.MouseEvent evt) {
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;