KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > uihandler > InputGesture


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
16  */

17
18 package org.netbeans.lib.uihandler;
19
20 import java.util.logging.LogRecord JavaDoc;
21 import java.util.logging.XMLFormatter JavaDoc;
22
23 /** Represents a gesture that initiated the given LogRecord.
24  *
25  * @author Jaroslav Tulach
26  */

27 public enum InputGesture {
28     KEYBOARD, MENU, TOOLBAR;
29     
30     
31     private static final XMLFormatter JavaDoc F = new XMLFormatter JavaDoc();
32     
33     /** Finds the right InputGesture for given LogRecord.
34      * @param rec the record
35      * @return the gesture that initated the record or null if unknown
36      */

37     public static InputGesture valueOf(LogRecord JavaDoc rec) {
38         if ("UI_ACTION_BUTTON_PRESS".equals(rec.getMessage())) {
39             String JavaDoc fullMsg = F.format(rec);
40             if (fullMsg.indexOf("Actions$Menu") >= 0) {
41                 return MENU;
42             }
43             if (fullMsg.indexOf("Actions$Toolbar") >= 0) {
44                 return TOOLBAR;
45             }
46         }
47         if ("UI_ACTION_KEY_PRESS".equals(rec.getMessage())) {
48             return KEYBOARD;
49         }
50         return null;
51     }
52 }
53
Popular Tags