24 package org.sleuthkit.autopsy.keywordsearch;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.MouseEvent;
29 import java.beans.PropertyChangeEvent;
30 import java.beans.PropertyChangeListener;
31 import java.util.logging.Level;
34 import javax.swing.SwingUtilities;
35 import javax.swing.event.PopupMenuEvent;
36 import javax.swing.event.PopupMenuListener;
43 class DropdownToolbar
extends javax.swing.JPanel {
45 private static final Logger logger = Logger.getLogger(DropdownToolbar.class.getName());
46 private KeywordPropertyChangeListener listener;
47 private boolean active =
false;
48 private static DropdownToolbar instance;
49 private DropdownSingleTermSearchPanel dropPanel = null;
52 private DropdownToolbar() {
54 customizeComponents();
60 public synchronized static DropdownToolbar getDefault() {
61 if (instance == null) {
62 instance =
new DropdownToolbar();
67 private void customizeComponents() {
68 listener =
new KeywordPropertyChangeListener();
69 KeywordSearch.getServer().addServerActionListener(listener);
70 Case.addPropertyChangeListener(listener);
72 DropdownListSearchPanel listsPanel = DropdownListSearchPanel.getDefault();
73 listsPanel.addSearchButtonActionListener(
new ActionListener() {
75 public void actionPerformed(ActionEvent e) {
76 listsMenu.setVisible(
false);
80 listsMenu.setSize(listsPanel.getPreferredSize().width + 6, listsPanel.getPreferredSize().height + 6);
81 listsMenu.add(listsPanel);
82 listsMenu.addPopupMenuListener(
new PopupMenuListener() {
84 public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
85 listsButton.setSelected(
true);
89 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
90 listsButton.setSelected(
false);
94 public void popupMenuCanceled(PopupMenuEvent e) {
95 listsButton.setSelected(
false);
99 dropPanel = DropdownSingleTermSearchPanel.getDefault();
100 dropPanel.addSearchButtonActionListener(
new ActionListener() {
102 public void actionPerformed(ActionEvent e) {
103 searchMenu.setVisible(
false);
106 searchMenu.setSize(dropPanel.getPreferredSize().width + 6, dropPanel.getPreferredSize().height + 6);
107 searchMenu.add(dropPanel);
108 searchMenu.addPopupMenuListener(
new PopupMenuListener() {
110 public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
111 searchDropButton.setSelected(
true);
115 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
116 searchDropButton.setSelected(
false);
120 public void popupMenuCanceled(PopupMenuEvent e) {
121 searchDropButton.setSelected(
false);
134 @SuppressWarnings(
"unchecked")
136 private
void initComponents() {
138 listsMenu =
new javax.swing.JPopupMenu();
139 searchMenu =
new javax.swing.JPopupMenu();
140 listsButton =
new javax.swing.JButton();
141 searchDropButton =
new javax.swing.JButton();
142 jSeparator1 =
new javax.swing.JSeparator();
146 listsButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon.png")));
147 listsButton.setText(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleName"));
148 listsButton.setBorderPainted(
false);
149 listsButton.setContentAreaFilled(
false);
150 listsButton.setEnabled(
false);
151 listsButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-rollover.png")));
152 listsButton.setRolloverSelectedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-pressed.png")));
153 listsButton.addMouseListener(
new java.awt.event.MouseAdapter() {
154 public void mousePressed(java.awt.event.MouseEvent evt) {
155 listsButtonMousePressed(evt);
158 listsButton.addActionListener(
new java.awt.event.ActionListener() {
159 public void actionPerformed(java.awt.event.ActionEvent evt) {
160 listsButtonActionPerformed(evt);
164 searchDropButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon.png")));
165 searchDropButton.setText(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"KeywordSearchPanel.searchDropButton.text"));
166 searchDropButton.setBorderPainted(
false);
167 searchDropButton.setContentAreaFilled(
false);
168 searchDropButton.setEnabled(
false);
169 searchDropButton.setMaximumSize(
new java.awt.Dimension(146, 27));
170 searchDropButton.setMinimumSize(
new java.awt.Dimension(146, 27));
171 searchDropButton.setPreferredSize(
new java.awt.Dimension(146, 27));
172 searchDropButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-rollover.png")));
173 searchDropButton.setRolloverSelectedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-pressed.png")));
174 searchDropButton.addMouseListener(
new java.awt.event.MouseAdapter() {
175 public void mousePressed(java.awt.event.MouseEvent evt) {
176 searchDropButtonMousePressed(evt);
180 jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
182 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
183 this.setLayout(layout);
184 layout.setHorizontalGroup(
185 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
186 .addGroup(layout.createSequentialGroup()
187 .addComponent(listsButton)
188 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
189 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
191 .addComponent(searchDropButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
194 layout.setVerticalGroup(
195 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addGroup(layout.createSequentialGroup()
197 .addGap(0, 0, Short.MAX_VALUE)
198 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
199 .addComponent(listsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
200 .addComponent(searchDropButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
201 .addComponent(jSeparator1)))
205 private void listsButtonMousePressed(java.awt.event.MouseEvent evt) {
206 maybeShowListsPopup(evt);
209 private void listsButtonActionPerformed(java.awt.event.ActionEvent evt) {
213 private void searchDropButtonMousePressed(java.awt.event.MouseEvent evt) {
214 maybeShowSearchPopup(evt);
218 private javax.swing.JSeparator jSeparator1;
219 private javax.swing.JButton listsButton;
220 private javax.swing.JPopupMenu listsMenu;
221 private javax.swing.JButton searchDropButton;
222 private javax.swing.JPopupMenu searchMenu;
229 String changed = evt.getPropertyName();
230 Object oldValue = evt.getOldValue();
231 Object newValue = evt.getNewValue();
234 dropPanel.resetSearchBox();
235 if (newValue == null) {
250 logger.log(Level.SEVERE,
"Error executing Solr query, " + ex);
253 logger.log(Level.SEVERE,
"Error executing Solr query, " + se.getMessage());
264 searchDropButton.setEnabled(enabled);
265 listsButton.setEnabled(enabled);
270 private void maybeShowListsPopup(MouseEvent evt) {
274 if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
277 listsMenu.show(listsButton, listsButton.getWidth() - listsMenu.getWidth(), listsButton.getHeight() - 1);
280 private void maybeShowSearchPopup(MouseEvent evt) {
284 if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
287 searchMenu.show(searchDropButton, searchDropButton.getWidth() - searchMenu.getWidth(), searchDropButton.getHeight() - 1);
int queryNumIndexedFiles()
static void fireNumIndexedFilesChange(Integer oldNum, Integer newNum)
static synchronized Server getServer()
static final String CORE_EVT