Source Code Cross Referenced for ResourceAction.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » texteditor » 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 » IDE Eclipse » ui workbench » org.eclipse.ui.texteditor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.texteditor;
011:
012:        import java.util.MissingResourceException;
013:        import java.util.ResourceBundle;
014:
015:        import org.eclipse.jface.action.Action;
016:        import org.eclipse.jface.resource.ImageDescriptor;
017:
018:        import org.eclipse.ui.PlatformUI;
019:
020:        /**
021:         * An action which configures its label, image, tooltip, and description from
022:         * a resource bundle using known keys.
023:         * <p>
024:         * Clients may subclass this abstract class to define new kinds of actions. As
025:         * with <code>Action</code>, subclasses must implement the
026:         * <code>IAction.run</code> method to carry out the action's semantics.
027:         * </p>
028:         */
029:        public abstract class ResourceAction extends Action {
030:
031:            /**
032:             * Retrieves and returns the value with the given key from the given resource
033:             * bundle, or returns the given default value if there is no such resource.
034:             * Convenience method for dealing gracefully with missing resources.
035:             *
036:             * @param bundle the resource bundle
037:             * @param key the resource key
038:             * @param defaultValue the default value, or <code>null</code>
039:             * @return the resource value, or the given default value (which may be
040:             *   <code>null</code>)
041:             */
042:            protected static String getString(ResourceBundle bundle,
043:                    String key, String defaultValue) {
044:
045:                String value = defaultValue;
046:                try {
047:                    value = bundle.getString(key);
048:                } catch (MissingResourceException x) {
049:                }
050:
051:                return value;
052:            }
053:
054:            /**
055:             * Creates a new action that configures itself from the given resource
056:             * bundle.
057:             * <p>
058:             * The following keys, prepended by the given option prefix,
059:             * are used for retrieving resources from the given bundle:
060:             * <ul>
061:             *   <li><code>"label"</code> - <code>setText</code></li>
062:             *   <li><code>"tooltip"</code> - <code>setToolTipText</code></li>
063:             *   <li><code>"image"</code> - <code>setImageDescriptor</code></li>
064:             *   <li><code>"description"</code> - <code>setDescription</code></li>
065:             * </ul>
066:             * </p>
067:             *
068:             * @param bundle the resource bundle
069:             * @param prefix a prefix to be prepended to the various resource keys, or
070:             *   <code>null</code> if none
071:             * @param	style one of <code>IAction.AS_PUSH_BUTTON</code>, <code>IAction.AS_CHECK_BOX</code>,
072:             *			and <code>IAction.AS_RADIO_BUTTON</code>.
073:             *
074:             * @see ResourceAction#ResourceAction(ResourceBundle, String)
075:             * @see org.eclipse.jface.action.IAction#AS_CHECK_BOX
076:             * @see org.eclipse.jface.action.IAction#AS_DROP_DOWN_MENU
077:             * @see org.eclipse.jface.action.IAction#AS_PUSH_BUTTON
078:             * @see org.eclipse.jface.action.IAction#AS_RADIO_BUTTON
079:             * @since 2.1
080:             */
081:            public ResourceAction(ResourceBundle bundle, String prefix,
082:                    int style) {
083:                super (null, style);
084:                initialize(bundle, prefix);
085:            }
086:
087:            /**
088:             * Creates a new action that configures itself from the given resource
089:             * bundle.
090:             * <p>
091:             * The following keys, prepended by the given option prefix,
092:             * are used for retrieving resources from the given bundle:
093:             * <ul>
094:             *   <li><code>"label"</code> - <code>setText</code></li>
095:             *   <li><code>"tooltip"</code> - <code>setToolTipText</code></li>
096:             *   <li><code>"image"</code> - <code>setImageDescriptor</code></li>
097:             *   <li><code>"description"</code> - <code>setDescription</code></li>
098:             * </ul>
099:             * </p>
100:             *
101:             * @param bundle the resource bundle
102:             * @param prefix a prefix to be prepended to the various resource keys, or
103:             *   <code>null</code> if none
104:             */
105:            public ResourceAction(ResourceBundle bundle, String prefix) {
106:                super ();
107:                initialize(bundle, prefix);
108:            }
109:
110:            /**
111:             * Sets the action's help context id.
112:             *
113:             * @param contextId the help context id
114:             */
115:            public final void setHelpContextId(String contextId) {
116:                PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
117:                        contextId);
118:            }
119:
120:            /**
121:             * Initializes this action using the given bundle and prefix.
122:             *
123:             * @param bundle the resource bundle
124:             * @param prefix a prefix to be prepended to the various resource keys, or <code>null</code> if none
125:             * @since 2.1
126:             */
127:            protected void initialize(ResourceBundle bundle, String prefix) {
128:                String labelKey = "label"; //$NON-NLS-1$
129:                String tooltipKey = "tooltip"; //$NON-NLS-1$
130:                String imageKey = "image"; //$NON-NLS-1$
131:                String descriptionKey = "description"; //$NON-NLS-1$
132:
133:                if (prefix != null && prefix.length() > 0) {
134:                    labelKey = prefix + labelKey;
135:                    tooltipKey = prefix + tooltipKey;
136:                    imageKey = prefix + imageKey;
137:                    descriptionKey = prefix + descriptionKey;
138:                }
139:
140:                setText(getString(bundle, labelKey, labelKey));
141:                setToolTipText(getString(bundle, tooltipKey, null));
142:                setDescription(getString(bundle, descriptionKey, null));
143:
144:                String file = getString(bundle, imageKey, null);
145:                if (file != null && file.trim().length() > 0)
146:                    setImageDescriptor(ImageDescriptor.createFromFile(
147:                            getClass(), file));
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.