KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > globalactions > SelectAllAction


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.globalactions;
17
18 import java.awt.KeyboardFocusManager JavaDoc;
19 import java.awt.Toolkit JavaDoc;
20 import java.awt.event.ActionEvent JavaDoc;
21 import java.awt.event.KeyEvent JavaDoc;
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24
25 import javax.swing.JComponent JavaDoc;
26 import javax.swing.KeyStroke JavaDoc;
27
28 import org.columba.api.gui.frame.IFrameMediator;
29 import org.columba.core.gui.action.AbstractColumbaAction;
30 import org.columba.core.resourceloader.GlobalResourceLoader;
31
32 public class SelectAllAction extends AbstractColumbaAction implements
33         PropertyChangeListener JavaDoc {
34
35     private JComponent JavaDoc focusOwner = null;
36
37     public SelectAllAction(IFrameMediator controller) {
38         super(controller, GlobalResourceLoader.getString(null, null,
39                 "menu_edit_selectall"));
40
41         // tooltip text
42
putValue(SHORT_DESCRIPTION, GlobalResourceLoader.getString(null, null,
43                 "menu_edit_selectall_tooltip"));
44
45         // shortcut key
46
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A,
47                 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
48
49         setEnabled(true);
50
51         KeyboardFocusManager JavaDoc manager = KeyboardFocusManager
52                 .getCurrentKeyboardFocusManager();
53
54         manager.addPropertyChangeListener("permanentFocusOwner", this);
55
56     }
57
58     public void propertyChange(PropertyChangeEvent JavaDoc e) {
59         Object JavaDoc o = e.getNewValue();
60         if (o instanceof JComponent JavaDoc)
61             focusOwner = (JComponent JavaDoc) o;
62         else
63             focusOwner = null;
64
65     }
66
67     /**
68      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
69      */

70     public void actionPerformed(ActionEvent JavaDoc evt) {
71         if (focusOwner == null)
72             return;
73     }
74 }
75
Popular Tags