Source Code Cross Referenced for EditorAction.java in  » Testing » abbot-1.0.1 » abbot » editor » actions » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » abbot 1.0.1 » abbot.editor.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot.editor.actions;
002:
003:        import java.awt.event.*;
004:        import java.net.URL;
005:
006:        import javax.swing.*;
007:
008:        import abbot.Log;
009:        import abbot.Platform;
010:        import abbot.editor.*;
011:        import abbot.editor.widgets.*;
012:        import abbot.i18n.Strings;
013:
014:        /** Encapsulate GUI attributes for an editor action. */
015:
016:        public abstract class EditorAction extends AbstractAction implements 
017:                EditorConstants {
018:
019:            /** Key to refer to the action in ActionMaps; <strong>not</strong> the
020:                same as the NAME property which is typically used for labels.
021:             */
022:            public static final String ACTION_KEY = "action-key";
023:            public static final String LARGE_ICON = "large-icon";
024:            public static final String MNEMONIC_INDEX = "mnemonic-index";
025:
026:            public EditorAction(String actionKey) {
027:                super (actionKey);
028:                putValue(ACTION_KEY, actionKey);
029:
030:                String key = ACTION_PREFIX + actionKey;
031:
032:                Mnemonic mnemonic = Mnemonic.getMnemonic(Strings.get(key));
033:                mnemonic.setMnemonic(this );
034:                if (mnemonic.index != -1)
035:                    putValue(MNEMONIC_INDEX, new Integer(mnemonic.index));
036:                // Check deprecated usage
037:                if (mnemonic.keycode == KeyEvent.VK_UNDEFINED) {
038:                    int mn = getMnemonic(key);
039:                    if (mn != KeyEvent.VK_UNDEFINED)
040:                        putValue(MNEMONIC_KEY, new Integer(mn));
041:                }
042:
043:                String desc = Strings.get(key + ".desc", true);
044:                if (!"".equals(desc) && desc != null) {
045:                    putValue(SHORT_DESCRIPTION, TextFormat.tooltip(desc));
046:                }
047:                String longDesc = Strings.get(key + ".ldesc", true);
048:                if (!"".equals(longDesc) && longDesc != null) {
049:                    putValue(LONG_DESCRIPTION, TextFormat.tooltip(longDesc));
050:                } else {
051:                    putValue(LONG_DESCRIPTION, getValue(SHORT_DESCRIPTION));
052:                }
053:
054:                String iconName = Strings.get(key + ".icon", true);
055:                if (!"".equals(iconName) && iconName != null) {
056:                    putValue(SMALL_ICON, getIcon(iconName, 16));
057:                    putValue(LARGE_ICON, getIcon(iconName, 24));
058:                }
059:
060:                String accelerator = Strings.get(key + ".acc", true);
061:                if (!"".equals(accelerator) && accelerator != null) {
062:                    accelerator = abbot.tester.AWTConstants.MENU_SHORTCUT_STRING
063:                            + accelerator;
064:                    try {
065:                        // In case the accelerator given is garbage...
066:                        putValue(ACCELERATOR_KEY, KeyStroke
067:                                .getKeyStroke(accelerator));
068:                    } catch (Exception e) {
069:                        Log.warn("Bad accelerator '" + accelerator + "': " + e);
070:                    }
071:                }
072:            }
073:
074:            /** @deprecated Encode the mnemonic into the localized label instead. */
075:            public static int getMnemonic(String key) {
076:                int code = KeyEvent.VK_UNDEFINED;
077:                // No (visible) mnemonics on OSX
078:                if (Platform.isOSX())
079:                    return code;
080:
081:                String mnemonic = Strings.get(key + ".mn", true);
082:                if (!"".equals(mnemonic) && mnemonic != null) {
083:                    if (!mnemonic.startsWith("VK_")) {
084:                        mnemonic = "VK_" + mnemonic;
085:                    }
086:                    try {
087:                        code = abbot.util.AWT.getKeyCode(mnemonic);
088:                    } catch (IllegalArgumentException e) {
089:                        String msg = Strings.get("editor.bad_mnemonic",
090:                                new Object[] { mnemonic, key + ".mn",
091:                                        java.util.Locale.getDefault(),
092:                                        e.toString() });
093:                        // TODO: format this into an email message
094:                        Log.warn(msg);
095:                    }
096:                }
097:                return code;
098:            }
099:
100:            /** 
101:             * Returns the Icon associated with the given name from the available
102:             * resources. 
103:             * 
104:             * @param name Base name of the icon file e.g., help for help16.gif
105:             * @param size Size in pixels of the icon from the filename, or zero if
106:             * none, e.g. 16 for help16.gif or 0 for help.gif.
107:             * @return an ImageIcon or null if no corresponding icon resource is found.
108:             */
109:            private ImageIcon getIcon(String name, int size) {
110:                String ABBOT_IMAGE_DIR = "/abbot/editor/icons/";
111:                String base = ABBOT_IMAGE_DIR + name;
112:                URL url = getClass().getResource(base + ".gif");
113:                if (url == null) {
114:                    url = getClass().getResource(base + size + ".gif");
115:                }
116:                ImageIcon icon = url != null ? new ImageIcon(url) : null;
117:                return icon;
118:            }
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.