1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.xmlhammer.gui.actions;
22
23 import java.awt.Toolkit;
24 import java.awt.event.KeyEvent;
25
26 import javax.swing.ImageIcon;
27 import javax.swing.KeyStroke;
28
29 import org.bounce.RunnableAction;
30 import org.xmlhammer.gui.FindDialog;
31 import org.xmlhammer.gui.XMLHammer;
32
33 /***
34 * An action that can be used to search contents.
35 *
36 * @version $Revision: 1.8 $, $Date: 2007/07/04 19:42:49 $
37 * @author Edwin Dankert <edankert@gmail.com>
38 */
39 public class FindAction extends RunnableAction {
40 private static final long serialVersionUID = 5071286482617302382L;
41 private XMLHammer parent = null;
42 private FindDialog dialog = null;
43
44 /***
45 * The constructor for the action which allows for searching content.
46 */
47 public FindAction(XMLHammer parent) {
48 super( "Find...");
49
50 putValue( MNEMONIC_KEY, new Integer( 'F'));
51 putValue( ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
52 putValue( SMALL_ICON, new ImageIcon( getClass().getResource( "/org/xmlhammer/gui/icons/etool16/search_src.gif")));
53 putValue( SHORT_DESCRIPTION, "Find...");
54
55 this.parent = parent;
56 }
57
58 /***
59 * The implementation of the search action, called
60 * after a user action.
61 */
62 public void run() {
63 if (dialog == null) {
64 dialog = new FindDialog(parent);
65 }
66
67 dialog.setVisible(true);
68 }
69 }