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;
33 import javax.swing.SwingUtilities;
34 import javax.swing.event.PopupMenuEvent;
35 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;
51 private DropdownToolbar() {
53 customizeComponents();
56 public synchronized static DropdownToolbar getDefault() {
57 if (instance == null) {
58 instance =
new DropdownToolbar();
63 private void customizeComponents() {
64 listener =
new KeywordPropertyChangeListener();
65 KeywordSearch.getServer().addServerActionListener(listener);
66 Case.addPropertyChangeListener(listener);
68 DropdownListSearchPanel listsPanel = DropdownListSearchPanel.getDefault();
69 listsPanel.addSearchButtonActionListener(
new ActionListener() {
71 public void actionPerformed(ActionEvent e) {
72 listsMenu.setVisible(
false);
76 listsMenu.setSize(listsPanel.getPreferredSize().width + 6, listsPanel.getPreferredSize().height + 6);
77 listsMenu.add(listsPanel);
78 listsMenu.addPopupMenuListener(
new PopupMenuListener() {
80 public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
81 listsButton.setSelected(
true);
85 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
86 listsButton.setSelected(
false);
90 public void popupMenuCanceled(PopupMenuEvent e) {
91 listsButton.setSelected(
false);
95 dropPanel = DropdownSingleTermSearchPanel.getDefault();
96 dropPanel.addSearchButtonActionListener(
new ActionListener() {
98 public void actionPerformed(ActionEvent e) {
99 searchMenu.setVisible(
false);
102 searchMenu.setSize(dropPanel.getPreferredSize().width + 6, dropPanel.getPreferredSize().height + 6);
103 searchMenu.add(dropPanel);
104 searchMenu.addPopupMenuListener(
new PopupMenuListener() {
106 public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
107 searchDropButton.setSelected(
true);
111 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
112 searchDropButton.setSelected(
false);
116 public void popupMenuCanceled(PopupMenuEvent e) {
117 searchDropButton.setSelected(
false);
128 @SuppressWarnings(
"unchecked")
130 private
void initComponents() {
132 listsMenu =
new javax.swing.JPopupMenu();
133 searchMenu =
new javax.swing.JPopupMenu();
134 listsButton =
new javax.swing.JButton();
135 searchDropButton =
new javax.swing.JButton();
136 jSeparator1 =
new javax.swing.JSeparator();
140 listsButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon.png")));
141 listsButton.setText(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"ListBundleName"));
142 listsButton.setBorderPainted(
false);
143 listsButton.setContentAreaFilled(
false);
144 listsButton.setEnabled(
false);
145 listsButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-rollover.png")));
146 listsButton.setRolloverSelectedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/watchbutton-icon-pressed.png")));
147 listsButton.addMouseListener(
new java.awt.event.MouseAdapter() {
148 public void mousePressed(java.awt.event.MouseEvent evt) {
149 listsButtonMousePressed(evt);
152 listsButton.addActionListener(
new java.awt.event.ActionListener() {
153 public void actionPerformed(java.awt.event.ActionEvent evt) {
154 listsButtonActionPerformed(evt);
158 searchDropButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon.png")));
159 searchDropButton.setText(
org.openide.util.NbBundle.getMessage(DropdownToolbar.class,
"KeywordSearchPanel.searchDropButton.text"));
160 searchDropButton.setBorderPainted(
false);
161 searchDropButton.setContentAreaFilled(
false);
162 searchDropButton.setEnabled(
false);
163 searchDropButton.setMaximumSize(
new java.awt.Dimension(146, 27));
164 searchDropButton.setMinimumSize(
new java.awt.Dimension(146, 27));
165 searchDropButton.setPreferredSize(
new java.awt.Dimension(146, 27));
166 searchDropButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-rollover.png")));
167 searchDropButton.setRolloverSelectedIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/searchbutton-icon-pressed.png")));
168 searchDropButton.addMouseListener(
new java.awt.event.MouseAdapter() {
169 public void mousePressed(java.awt.event.MouseEvent evt) {
170 searchDropButtonMousePressed(evt);
174 jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
176 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
177 this.setLayout(layout);
178 layout.setHorizontalGroup(
179 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180 .addGroup(layout.createSequentialGroup()
181 .addComponent(listsButton)
182 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
183 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
185 .addComponent(searchDropButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
188 layout.setVerticalGroup(
189 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190 .addGroup(layout.createSequentialGroup()
191 .addGap(0, 0, Short.MAX_VALUE)
192 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
193 .addComponent(listsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
194 .addComponent(searchDropButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
195 .addComponent(jSeparator1)))
199 private void listsButtonMousePressed(java.awt.event.MouseEvent evt) {
200 maybeShowListsPopup(evt);
203 private void listsButtonActionPerformed(java.awt.event.ActionEvent evt) {
207 private void searchDropButtonMousePressed(java.awt.event.MouseEvent evt) {
208 maybeShowSearchPopup(evt);
212 private javax.swing.JSeparator jSeparator1;
213 private javax.swing.JButton listsButton;
214 private javax.swing.JPopupMenu listsMenu;
215 private javax.swing.JButton searchDropButton;
216 private javax.swing.JPopupMenu searchMenu;
223 String changed = evt.getPropertyName();
225 dropPanel.resetSearchBox();
235 logger.log(Level.SEVERE,
"Error executing Solr query, {0}", ex);
237 logger.log(Level.SEVERE,
"Error executing Solr query, {0}", se.getMessage());
248 searchDropButton.setEnabled(enabled);
249 listsButton.setEnabled(enabled);
254 private void maybeShowListsPopup(MouseEvent evt) {
258 if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
261 listsMenu.show(listsButton, listsButton.getWidth() - listsMenu.getWidth(), listsButton.getHeight() - 1);
264 private void maybeShowSearchPopup(MouseEvent evt) {
268 if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
271 searchMenu.show(searchDropButton, searchDropButton.getWidth() - searchMenu.getWidth(), searchDropButton.getHeight() - 1);
int queryNumIndexedFiles()
static void fireNumIndexedFilesChange(Integer oldNum, Integer newNum)
static synchronized Server getServer()
static boolean coreComponentsAreActive()
static final String CORE_EVT