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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 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.templates.rcp;
011:
012:        import java.io.File;
013:        import java.util.ArrayList;
014:
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.core.runtime.IProgressMonitor;
017:        import org.eclipse.jface.wizard.Wizard;
018:        import org.eclipse.jface.wizard.WizardPage;
019:        import org.eclipse.pde.core.plugin.IPluginBase;
020:        import org.eclipse.pde.core.plugin.IPluginElement;
021:        import org.eclipse.pde.core.plugin.IPluginExtension;
022:        import org.eclipse.pde.core.plugin.IPluginModelBase;
023:        import org.eclipse.pde.core.plugin.IPluginModelFactory;
024:        import org.eclipse.pde.core.plugin.IPluginReference;
025:        import org.eclipse.pde.internal.ui.templates.IHelpContextIds;
026:        import org.eclipse.pde.internal.ui.templates.PDETemplateMessages;
027:        import org.eclipse.pde.internal.ui.templates.PDETemplateSection;
028:        import org.eclipse.pde.internal.ui.templates.PluginReference;
029:        import org.eclipse.pde.ui.IFieldData;
030:
031:        public class IntroTemplate extends PDETemplateSection {
032:
033:            private static final String DYNAMIC_SELECTED = "dynamic"; //$NON-NLS-1$
034:
035:            private static final String STATIC_SELECTED = "static"; //$NON-NLS-1$
036:
037:            private static final String KEY_GENERATE_DYNAMIC_CONTENT = "IntroTemplate.generateDynamicContent"; //$NON-NLS-1$
038:
039:            private String packageName;
040:            private String introID;
041:            private static final String APPLICATION_CLASS = "Application"; //$NON-NLS-1$
042:
043:            public IntroTemplate() {
044:                super ();
045:                setPageCount(1);
046:                createOptions();
047:            }
048:
049:            private void createOptions() {
050:
051:                addOption(KEY_PRODUCT_NAME,
052:                        PDETemplateMessages.IntroTemplate_productName,
053:                        VALUE_PRODUCT_NAME, 0);
054:
055:                addOption(
056:                        KEY_GENERATE_DYNAMIC_CONTENT,
057:                        PDETemplateMessages.IntroTemplate_generate,
058:                        new String[][] {
059:                                {
060:                                        STATIC_SELECTED,
061:                                        PDETemplateMessages.IntroTemplate_generateStaticContent },
062:                                {
063:                                        DYNAMIC_SELECTED,
064:                                        PDETemplateMessages.IntroTemplate_generateDynamicContent } },
065:                        STATIC_SELECTED, 0);
066:            }
067:
068:            public void addPages(Wizard wizard) {
069:                WizardPage page = createPage(0, IHelpContextIds.TEMPLATE_INTRO);
070:                page.setTitle(PDETemplateMessages.IntroTemplate_title);
071:                page.setDescription(PDETemplateMessages.IntroTemplate_desc);
072:                wizard.addPage(page);
073:                markPagesAdded();
074:            }
075:
076:            public boolean isDependentOnParentWizard() {
077:                return true;
078:            }
079:
080:            public String getSectionId() {
081:                return "intro"; //$NON-NLS-1$
082:            }
083:
084:            protected void initializeFields(IFieldData data) {
085:                // In a new project wizard, we don't know this yet - the
086:                // model has not been created
087:                String pluginId = data.getId();
088:                initializeOption(KEY_PACKAGE_NAME,
089:                        getFormattedPackageName(pluginId) + ".intro"); //$NON-NLS-1$
090:                packageName = getFormattedPackageName(pluginId) + ".intro"; //$NON-NLS-1$
091:                introID = getFormattedPackageName(pluginId) + ".intro"; //$NON-NLS-1$
092:            }
093:
094:            public void initializeFields(IPluginModelBase model) {
095:                // In the new extension wizard, the model exists so 
096:                // we can initialize directly from it
097:                String pluginId = model.getPluginBase().getId();
098:                initializeOption(KEY_PACKAGE_NAME,
099:                        getFormattedPackageName(pluginId) + ".intro"); //$NON-NLS-1$
100:                packageName = getFormattedPackageName(pluginId) + ".intro"; //$NON-NLS-1$
101:                introID = getFormattedPackageName(pluginId) + ".intro"; //$NON-NLS-1$
102:            }
103:
104:            protected void updateModel(IProgressMonitor monitor)
105:                    throws CoreException {
106:
107:                IPluginBase plugin = model.getPluginBase();
108:                IPluginModelFactory factory = model.getPluginFactory();
109:
110:                // org.eclipse.core.runtime.applications
111:                IPluginExtension extension = createExtension(
112:                        "org.eclipse.core.runtime.applications", true); //$NON-NLS-1$
113:                extension.setId(VALUE_APPLICATION_ID);
114:
115:                IPluginElement element = model.getPluginFactory()
116:                        .createElement(extension);
117:                element.setName("application"); //$NON-NLS-1$
118:                extension.add(element);
119:
120:                IPluginElement run = model.getPluginFactory().createElement(
121:                        element);
122:                run.setName("run"); //$NON-NLS-1$
123:                run
124:                        .setAttribute(
125:                                "class", getStringOption(KEY_PACKAGE_NAME) + "." + APPLICATION_CLASS); //$NON-NLS-1$ //$NON-NLS-2$
126:                element.add(run);
127:
128:                if (!extension.isInTheModel())
129:                    plugin.add(extension);
130:
131:                // org.eclipse.ui.perspectives
132:                IPluginExtension perspectivesExtension = createExtension(
133:                        "org.eclipse.ui.perspectives", true); //$NON-NLS-1$
134:                IPluginElement perspectiveElement = model.getPluginFactory()
135:                        .createElement(perspectivesExtension);
136:                perspectiveElement.setName("perspective"); //$NON-NLS-1$
137:                perspectiveElement
138:                        .setAttribute(
139:                                "class", getStringOption(KEY_PACKAGE_NAME) + ".Perspective"); //$NON-NLS-1$ //$NON-NLS-2$
140:                perspectiveElement.setAttribute("name", VALUE_PERSPECTIVE_NAME); //$NON-NLS-1$
141:                perspectiveElement.setAttribute(
142:                        "id", plugin.getId() + ".perspective"); //$NON-NLS-1$ //$NON-NLS-2$
143:                perspectivesExtension.add(perspectiveElement);
144:
145:                if (!perspectivesExtension.isInTheModel())
146:                    plugin.add(perspectivesExtension);
147:
148:                createProductExtension();
149:
150:                // org.eclipse.ui.intro
151:                IPluginExtension extension2 = createExtension(
152:                        "org.eclipse.ui.intro", true); //$NON-NLS-1$
153:
154:                IPluginElement introElement = factory.createElement(extension2);
155:                introElement.setName("intro"); //$NON-NLS-1$
156:                introElement.setAttribute("id", introID); //$NON-NLS-1$
157:                introElement.setAttribute("class", //$NON-NLS-1$
158:                        "org.eclipse.ui.intro.config.CustomizableIntroPart"); //$NON-NLS-1$
159:                extension2.add(introElement);
160:
161:                IPluginElement introProductBindingElement = factory
162:                        .createElement(extension2);
163:                introProductBindingElement.setName("introProductBinding"); //$NON-NLS-1$
164:                introProductBindingElement.setAttribute("introId", introID);//$NON-NLS-1$
165:
166:                introProductBindingElement.setAttribute(
167:                        "productId", plugin.getId() //$NON-NLS-1$
168:                                + '.' + VALUE_PRODUCT_ID);
169:                extension2.add(introProductBindingElement);
170:
171:                if (!extension2.isInTheModel())
172:                    plugin.add(extension2);
173:
174:                // org.eclipse.ui.intro.config
175:                IPluginExtension extension3 = createExtension(
176:                        "org.eclipse.ui.intro.config", true); //$NON-NLS-1$
177:
178:                IPluginElement configurationElement = factory
179:                        .createElement(extension3);
180:                configurationElement.setName("config"); //$NON-NLS-1$
181:                configurationElement.setAttribute("id", plugin.getId() + '.' //$NON-NLS-1$
182:                        + "configId"); //$NON-NLS-1$
183:                configurationElement.setAttribute("introId", introID);//$NON-NLS-1$            
184:                configurationElement
185:                        .setAttribute("content", "introContent.xml"); //$NON-NLS-1$ //$NON-NLS-2$
186:                IPluginElement presentationElement = factory
187:                        .createElement(configurationElement);
188:                presentationElement.setName("presentation"); //$NON-NLS-1$
189:                presentationElement.setAttribute("home-page-id", "root"); //$NON-NLS-1$ //$NON-NLS-2$
190:                IPluginElement implementationElement = factory
191:                        .createElement(presentationElement);
192:                implementationElement.setName("implementation"); //$NON-NLS-1$
193:                implementationElement.setAttribute("os", "win32,linux,macosx"); //$NON-NLS-1$ //$NON-NLS-2$
194:                if (getTargetVersion() == 3.0)
195:                    implementationElement.setAttribute(
196:                            "style", "content/shared.css"); //$NON-NLS-1$//$NON-NLS-2$
197:
198:                implementationElement.setAttribute("kind", "html"); //$NON-NLS-1$ //$NON-NLS-2$
199:                presentationElement.add(implementationElement);
200:                configurationElement.add(presentationElement);
201:                extension3.add(configurationElement);
202:
203:                if (!extension3.isInTheModel())
204:                    plugin.add(extension3);
205:
206:                // org.eclipse.ui.intro.configExtension
207:                if (getValue(KEY_GENERATE_DYNAMIC_CONTENT).toString().equals(
208:                        DYNAMIC_SELECTED)) {
209:                    IPluginExtension extension4 = createExtension(
210:                            "org.eclipse.ui.intro.configExtension", true); //$NON-NLS-1$
211:
212:                    IPluginElement configExtensionElement = factory
213:                            .createElement(extension4);
214:                    configExtensionElement.setName("configExtension"); //$NON-NLS-1$
215:                    configExtensionElement.setAttribute(
216:                            "configId", plugin.getId() + '.' + "configId"); //$NON-NLS-1$ //$NON-NLS-2$
217:                    configExtensionElement.setAttribute("content", "ext.xml"); //$NON-NLS-1$ //$NON-NLS-2$
218:                    extension4.add(configExtensionElement);
219:
220:                    if (!extension4.isInTheModel())
221:                        plugin.add(extension4);
222:                }
223:
224:            }
225:
226:            private void createProductExtension() throws CoreException {
227:                IPluginBase plugin = model.getPluginBase();
228:                IPluginExtension extension = createExtension(
229:                        "org.eclipse.core.runtime.products", true); //$NON-NLS-1$
230:                extension.setId(VALUE_PRODUCT_ID);
231:
232:                IPluginElement element = model.getFactory().createElement(
233:                        extension);
234:                element.setName("product"); //$NON-NLS-1$
235:                element.setAttribute("name", getStringOption(KEY_PRODUCT_NAME)); //$NON-NLS-1$		
236:                element
237:                        .setAttribute(
238:                                "application", plugin.getId() + "." + VALUE_APPLICATION_ID); //$NON-NLS-1$ //$NON-NLS-2$
239:
240:                IPluginElement property = model.getFactory().createElement(
241:                        element);
242:
243:                property = model.getFactory().createElement(element);
244:                property.setName("property"); //$NON-NLS-1$
245:                property.setAttribute("name", "windowImages"); //$NON-NLS-1$ //$NON-NLS-2$
246:                property
247:                        .setAttribute(
248:                                "value", "icons/alt_window_16.gif,icons/alt_window_32.gif"); //$NON-NLS-1$ //$NON-NLS-2$
249:                element.add(property);
250:
251:                extension.add(element);
252:
253:                if (!extension.isInTheModel())
254:                    plugin.add(extension);
255:            }
256:
257:            protected boolean isOkToCreateFolder(File sourceFolder) {
258:                return true;
259:            }
260:
261:            /**
262:             * @see AbstractTemplateSection#isOkToCreateFile(File)
263:             */
264:            protected boolean isOkToCreateFile(File sourceFile) {
265:
266:                if (getValue(KEY_GENERATE_DYNAMIC_CONTENT).toString().equals(
267:                        STATIC_SELECTED)
268:                        && (sourceFile.getName().equals(
269:                                "DynamicContentProvider.java") || //$NON-NLS-1$
270:                                sourceFile.getName().equals("concept3.xhtml") || //$NON-NLS-1$
271:                                sourceFile.getName().equals("extContent.xhtml") || //$NON-NLS-1$
272:                        sourceFile.getName().equals("ext.xml"))) { //$NON-NLS-1$
273:                    return false;
274:                }
275:
276:                return true;
277:            }
278:
279:            public String getUsedExtensionPoint() {
280:                return "org.eclipse.ui.intro"; // need more then one extension point //$NON-NLS-1$
281:            }
282:
283:            public IPluginReference[] getDependencies(String schemaVersion) {
284:                ArrayList result = new ArrayList();
285:
286:                result
287:                        .add(new PluginReference(
288:                                "org.eclipse.ui.intro", null, 0)); //$NON-NLS-1$
289:                result.add(new PluginReference(
290:                        "org.eclipse.core.runtime", null, 0)); //$NON-NLS-1$
291:                result.add(new PluginReference("org.eclipse.ui", null, 0)); //$NON-NLS-1$
292:
293:                if (getValue(KEY_GENERATE_DYNAMIC_CONTENT).toString().equals(
294:                        DYNAMIC_SELECTED)) {
295:                    result.add(new PluginReference(
296:                            "org.eclipse.ui.forms", null, 0)); //$NON-NLS-1$
297:                    result.add(new PluginReference("org.eclipse.swt", null, 0)); //$NON-NLS-1$
298:                }
299:
300:                return (IPluginReference[]) result
301:                        .toArray(new IPluginReference[result.size()]);
302:            }
303:
304:            public int getNumberOfWorkUnits() {
305:                return super .getNumberOfWorkUnits() + 1;
306:            }
307:
308:            public Object getValue(String valueName) {
309:
310:                if (valueName.equals(KEY_PACKAGE_NAME)) {
311:                    return packageName;
312:                }
313:
314:                return super .getValue(valueName);
315:            }
316:
317:            public String getStringOption(String name) {
318:
319:                if (name.equals(KEY_PACKAGE_NAME)) {
320:                    return packageName;
321:                }
322:
323:                return super .getStringOption(name);
324:            }
325:
326:            public String[] getNewFiles() {
327:                if (getValue(KEY_GENERATE_DYNAMIC_CONTENT).toString().equals(
328:                        STATIC_SELECTED)) {
329:                    return new String[] {
330:                            "icons/", "content/", "splash.bmp", "introContent.xml" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
331:                }
332:                return new String[] {
333:                        "icons/", "content/", "splash.bmp", "introContent.xml", "ext.xml" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
334:            }
335:
336:            /* (non-Javadoc)
337:             * @see org.eclipse.pde.internal.ui.templates.PDETemplateSection#copyBrandingDirectory()
338:             */
339:            protected boolean copyBrandingDirectory() {
340:                return true;
341:            }
342:        }
w__w___w_.j__av__a2__s_._co___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.