Source Code Cross Referenced for WizardElement.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.pde.internal.ui.wizards;
011:
012:        import java.util.MissingResourceException;
013:        import java.util.ResourceBundle;
014:
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.core.runtime.IConfigurationElement;
017:        import org.eclipse.core.runtime.Platform;
018:        import org.eclipse.pde.internal.ui.elements.NamedElement;
019:        import org.eclipse.swt.graphics.Image;
020:        import org.eclipse.ui.IPluginContribution;
021:        import org.osgi.framework.Bundle;
022:
023:        public class WizardElement extends NamedElement implements 
024:                IPluginContribution {
025:            public static final String ATT_NAME = "name"; //$NON-NLS-1$
026:
027:            public static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
028:
029:            public static final String ATT_ICON = "icon"; //$NON-NLS-1$
030:
031:            public static final String ATT_ID = "id"; //$NON-NLS-1$
032:
033:            public static final String ATT_CLASS = "class"; //$NON-NLS-1$
034:
035:            public static final String ATT_TEMPLATE = "template"; //$NON-NLS-1$
036:
037:            public static final String ATT_POINT = "point"; //$NON-NLS-1$
038:
039:            private String description;
040:
041:            private IConfigurationElement configurationElement;
042:
043:            private IConfigurationElement template;
044:
045:            public WizardElement(IConfigurationElement config) {
046:                super (config.getAttribute(ATT_NAME));
047:                this .configurationElement = config;
048:            }
049:
050:            public Object createExecutableExtension() throws CoreException {
051:                return configurationElement
052:                        .createExecutableExtension(ATT_CLASS);
053:            }
054:
055:            public IConfigurationElement getConfigurationElement() {
056:                return configurationElement;
057:            }
058:
059:            public String getDescription() {
060:                if (description == null) {
061:                    IConfigurationElement[] children = configurationElement
062:                            .getChildren(TAG_DESCRIPTION);
063:                    if (children.length > 0) {
064:                        description = expandDescription(children[0].getValue());
065:                    }
066:                }
067:                return description;
068:            }
069:
070:            /**
071:             * We allow replacement variables in description values as well. This is to
072:             * allow extension template descriptin reuse in project template wizards.
073:             * Tokens in form '%token%' will be evaluated against the contributing
074:             * plug-in's resource bundle. As before, to have '%' in the description, one
075:             * need to add '%%'.
076:             */
077:            private String expandDescription(String source) {
078:                if (source == null || source.length() == 0)
079:                    return source;
080:                if (source.indexOf('%') == -1)
081:                    return source;
082:
083:                Bundle bundle = Platform.getBundle(configurationElement
084:                        .getNamespaceIdentifier());
085:                if (bundle == null)
086:                    return source;
087:
088:                ResourceBundle resourceBundle = Platform
089:                        .getResourceBundle(bundle);
090:                if (resourceBundle == null)
091:                    return source;
092:                StringBuffer buf = new StringBuffer();
093:                boolean keyMode = false;
094:                int keyStartIndex = -1;
095:                for (int i = 0; i < source.length(); i++) {
096:                    char c = source.charAt(i);
097:                    if (c == '%') {
098:                        char c2 = source.charAt(i + 1);
099:                        if (c2 == '%') {
100:                            i++;
101:                            buf.append('%');
102:                            continue;
103:                        }
104:                        if (keyMode) {
105:                            keyMode = false;
106:                            String key = source.substring(keyStartIndex, i);
107:                            String value = key;
108:                            try {
109:                                value = resourceBundle.getString(key);
110:                            } catch (MissingResourceException e) {
111:                            }
112:                            buf.append(value);
113:                        } else {
114:                            keyStartIndex = i + 1;
115:                            keyMode = true;
116:                        }
117:                    } else if (!keyMode) {
118:                        buf.append(c);
119:                    }
120:                }
121:                return buf.toString();
122:            }
123:
124:            public String getID() {
125:                return configurationElement.getAttribute(ATT_ID);
126:            }
127:
128:            public void setImage(Image image) {
129:                this .image = image;
130:            }
131:
132:            public String getTemplateId() {
133:                return configurationElement.getAttribute(ATT_TEMPLATE);
134:            }
135:
136:            public boolean isTemplate() {
137:                return getTemplateId() != null;
138:            }
139:
140:            public IConfigurationElement getTemplateElement() {
141:                if (template == null)
142:                    template = findTemplateElement();
143:                return template;
144:            }
145:
146:            private IConfigurationElement findTemplateElement() {
147:                String templateId = getTemplateId();
148:                if (templateId == null)
149:                    return null;
150:                IConfigurationElement[] templates = Platform
151:                        .getExtensionRegistry().getConfigurationElementsFor(
152:                                "org.eclipse.pde.ui.templates"); //$NON-NLS-1$
153:                for (int i = 0; i < templates.length; i++) {
154:                    IConfigurationElement template = templates[i];
155:                    String id = template.getAttribute("id"); //$NON-NLS-1$
156:                    if (id != null && id.equals(templateId))
157:                        return template;
158:                }
159:                return null;
160:            }
161:
162:            public String getContributingId() {
163:                IConfigurationElement tel = getTemplateElement();
164:                return (tel == null) ? null : tel
165:                        .getAttribute("contributingId"); //$NON-NLS-1$
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see org.eclipse.ui.IPluginContribution#getLocalId()
170:             */
171:            public String getLocalId() {
172:                return getID();
173:            }
174:
175:            /* (non-Javadoc)
176:             * @see org.eclipse.ui.IPluginContribution#getPluginId()
177:             */
178:            public String getPluginId() {
179:                return null;
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.