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


001:        /*******************************************************************************
002:         * Copyright (c) 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.templates.ide;
011:
012:        import java.util.StringTokenizer;
013:
014:        import org.eclipse.core.runtime.CoreException;
015:        import org.eclipse.core.runtime.IProgressMonitor;
016:        import org.eclipse.jface.wizard.Wizard;
017:        import org.eclipse.jface.wizard.WizardPage;
018:        import org.eclipse.pde.core.plugin.IPluginBase;
019:        import org.eclipse.pde.core.plugin.IPluginElement;
020:        import org.eclipse.pde.core.plugin.IPluginExtension;
021:        import org.eclipse.pde.core.plugin.IPluginModelBase;
022:        import org.eclipse.pde.core.plugin.IPluginModelFactory;
023:        import org.eclipse.pde.core.plugin.IPluginReference;
024:        import org.eclipse.pde.internal.ui.templates.IHelpContextIds;
025:        import org.eclipse.pde.internal.ui.templates.PDETemplateMessages;
026:        import org.eclipse.pde.internal.ui.templates.PDETemplateSection;
027:        import org.eclipse.pde.internal.ui.templates.PluginReference;
028:        import org.eclipse.pde.ui.IFieldData;
029:
030:        public class ImportWizardTemplate extends PDETemplateSection {
031:            public static final String WIZARD_CLASS_NAME = "wizardClassName"; //$NON-NLS-1$
032:            public static final String WIZARD_CATEGORY_NAME = "wizardCategoryName"; //$NON-NLS-1$
033:            public static final String WIZARD_PAGE_CLASS_NAME = "wizardPageClassName"; //$NON-NLS-1$
034:            public static final String WIZARD_IMPORT_NAME = "wizardImportName"; //$NON-NLS-1$
035:            public static final String WIZARD_FILE_FILTERS = "wizardFileFilters"; //$NON-NLS-1$
036:
037:            private WizardPage page;
038:
039:            /**
040:             * Constructor for ImportWizardTemplate.
041:             */
042:            public ImportWizardTemplate() {
043:                setPageCount(1);
044:                createOptions();
045:            }
046:
047:            /* (non-Javadoc)
048:             * @see org.eclipse.pde.ui.templates.AbstractTemplateSection#getDependencies(java.lang.String)
049:             */
050:            public IPluginReference[] getDependencies(String schemaVersion) {
051:                // Additional dependency required to provide WizardNewFileCreationPage
052:                if (schemaVersion != null) {
053:                    IPluginReference[] dep = new IPluginReference[2];
054:                    dep[0] = new PluginReference("org.eclipse.ui.ide", null, 0); //$NON-NLS-1$
055:                    dep[1] = new PluginReference(
056:                            "org.eclipse.core.resources", null, 0); //$NON-NLS-1$
057:                    return dep;
058:                }
059:                return super .getDependencies(schemaVersion);
060:            }
061:
062:            /* (non-Javadoc)
063:             * @see org.eclipse.pde.ui.templates.OptionTemplateSection#getSectionId()
064:             * @see org.eclipse.pde.internal.ui.wizards.templates.PDETemplateSection#getDirectoryCandidates()
065:             */
066:            public String getSectionId() {
067:                // Identifier used for the folder name within the templates_3.X
068:                // hierarchy  and as part of the lookup key for the template label
069:                // variable.
070:                return "importWizard"; //$NON-NLS-1$
071:            }
072:
073:            /* (non-Javadoc)
074:             * @see org.eclipse.pde.ui.templates.AbstractTemplateSection#getNumberOfWorkUnits()
075:             */
076:            public int getNumberOfWorkUnits() {
077:                return super .getNumberOfWorkUnits() + 1;
078:            }
079:
080:            /**
081:             * Creates the options to be displayed on the template wizard.
082:             * Various string options, blank fields and a multiple choice 
083:             * option are used.
084:             */
085:            private void createOptions() {
086:                String[][] choices = fromCommaSeparated(PDETemplateMessages.ImportWizardTemplate_filterChoices);
087:
088:                addOption(KEY_PACKAGE_NAME,
089:                        PDETemplateMessages.ImportWizardTemplate_packageName,
090:                        (String) null, 0);
091:                addOption(
092:                        WIZARD_CLASS_NAME,
093:                        PDETemplateMessages.ImportWizardTemplate_wizardClass,
094:                        PDETemplateMessages.ImportWizardTemplate_wizardClassName,
095:                        0);
096:                addOption(WIZARD_PAGE_CLASS_NAME,
097:                        PDETemplateMessages.ImportWizardTemplate_pageClass,
098:                        PDETemplateMessages.ImportWizardTemplate_pageClassName,
099:                        0);
100:
101:                addBlankField(0);
102:
103:                addOption(
104:                        WIZARD_CATEGORY_NAME,
105:                        PDETemplateMessages.ImportWizardTemplate_importWizardCategory,
106:                        PDETemplateMessages.ImportWizardTemplate_importWizardCategoryName,
107:                        0);
108:                addOption(
109:                        WIZARD_IMPORT_NAME,
110:                        PDETemplateMessages.ImportWizardTemplate_wizardName,
111:                        PDETemplateMessages.ImportWizardTemplate_wizardDefaultName,
112:                        0);
113:
114:                addBlankField(0);
115:
116:                addOption(WIZARD_FILE_FILTERS,
117:                        PDETemplateMessages.ImportWizardTemplate_filters,
118:                        choices, choices[0][0], 0);
119:            }
120:
121:            /* (non-Javadoc)
122:             * @see org.eclipse.pde.ui.templates.AbstractTemplateSection#addPages(org.eclipse.jface.wizard.Wizard)
123:             */
124:            public void addPages(Wizard wizard) {
125:                int pageIndex = 0;
126:
127:                page = createPage(pageIndex, IHelpContextIds.TEMPLATE_EDITOR);
128:                page.setTitle(PDETemplateMessages.ImportWizardTemplate_title);
129:                page
130:                        .setDescription(PDETemplateMessages.ImportWizardTemplate_desc);
131:
132:                wizard.addPage(page);
133:                markPagesAdded();
134:            }
135:
136:            /* (non-Javadoc)
137:             * @see org.eclipse.pde.ui.templates.BaseOptionTemplateSection#isDependentOnParentWizard()
138:             */
139:            public boolean isDependentOnParentWizard() {
140:                return true;
141:            }
142:
143:            /* (non-Javadoc)
144:             * @see org.eclipse.pde.ui.templates.BaseOptionTemplateSection#initializeFields(org.eclipse.pde.ui.IFieldData)
145:             */
146:            protected void initializeFields(IFieldData data) {
147:                // In a new project wizard, we don't know this yet - the
148:                // model has not been created
149:                String id = data.getId();
150:                initializeOption(KEY_PACKAGE_NAME, getFormattedPackageName(id));
151:            }
152:
153:            /* (non-Javadoc)
154:             * @see org.eclipse.pde.ui.templates.BaseOptionTemplateSection#initializeFields(org.eclipse.pde.core.plugin.IPluginModelBase)
155:             */
156:            public void initializeFields(IPluginModelBase model) {
157:                // In the new extension wizard, the model exists so 
158:                // we can initialize directly from it
159:                String pluginId = model.getPluginBase().getId();
160:                initializeOption(KEY_PACKAGE_NAME,
161:                        getFormattedPackageName(pluginId));
162:            }
163:
164:            /* (non-Javadoc)
165:             * @see org.eclipse.pde.ui.templates.AbstractTemplateSection#updateModel(org.eclipse.core.runtime.IProgressMonitor)
166:             */
167:            protected void updateModel(IProgressMonitor monitor)
168:                    throws CoreException {
169:                // This method creates the extension point structure through the use
170:                // of IPluginElement objects. The element attributes are set based on
171:                // user input from the wizard page as well as values required for the 
172:                // operation of the extension point.
173:                IPluginBase plugin = model.getPluginBase();
174:                IPluginExtension extension = createExtension(
175:                        getUsedExtensionPoint(), true);
176:                IPluginModelFactory factory = model.getPluginFactory();
177:
178:                IPluginElement categoryElement = factory
179:                        .createElement(extension);
180:                categoryElement.setName("category"); //$NON-NLS-1$
181:                categoryElement
182:                        .setAttribute(
183:                                "id", getStringOption(KEY_PACKAGE_NAME) + ".sampleCategory"); //$NON-NLS-1$ //$NON-NLS-2$
184:                categoryElement.setAttribute(
185:                        "name", getStringOption(WIZARD_CATEGORY_NAME)); //$NON-NLS-1$
186:
187:                IPluginElement wizardElement = factory.createElement(extension);
188:                wizardElement.setName("wizard"); //$NON-NLS-1$
189:                wizardElement
190:                        .setAttribute(
191:                                "id", getStringOption(KEY_PACKAGE_NAME) + "." + getStringOption(WIZARD_CLASS_NAME)); //$NON-NLS-1$ //$NON-NLS-2$
192:                wizardElement.setAttribute(
193:                        "name", getStringOption(WIZARD_IMPORT_NAME)); //$NON-NLS-1$
194:                wizardElement
195:                        .setAttribute(
196:                                "class", getStringOption(KEY_PACKAGE_NAME) + "." + getStringOption(WIZARD_CLASS_NAME)); //$NON-NLS-1$ //$NON-NLS-2$
197:                wizardElement
198:                        .setAttribute(
199:                                "category", getStringOption(KEY_PACKAGE_NAME) + ".sampleCategory"); //$NON-NLS-1$ //$NON-NLS-2$
200:                wizardElement.setAttribute("icon", "icons/sample.gif"); //$NON-NLS-1$ //$NON-NLS-2$
201:
202:                IPluginElement descriptionElement = factory
203:                        .createElement(extension);
204:                descriptionElement.setName("description"); //$NON-NLS-1$
205:                descriptionElement
206:                        .setText(PDETemplateMessages.ImportWizardTemplate_wizardDescription);
207:
208:                wizardElement.add(descriptionElement);
209:                extension.add(categoryElement);
210:                extension.add(wizardElement);
211:                if (!extension.isInTheModel())
212:                    plugin.add(extension);
213:            }
214:
215:            /* (non-Javadoc)
216:             * @see org.eclipse.pde.internal.ui.wizards.templates.PDETemplateSection#getNewFiles()
217:             */
218:            public String[] getNewFiles() {
219:                return new String[] { "icons/" }; //$NON-NLS-1$
220:            }
221:
222:            /* (non-Javadoc)
223:             * @see org.eclipse.pde.internal.ui.wizards.templates.PDETemplateSection#getFormattedPackageName(java.lang.String)
224:             */
225:            protected String getFormattedPackageName(String id) {
226:                // Package name addition to create a location for containing
227:                // any classes required by the decorator. 
228:                String packageName = super .getFormattedPackageName(id);
229:                if (packageName.length() != 0)
230:                    return packageName + ".importWizards"; //$NON-NLS-1$
231:                return "importWizards"; //$NON-NLS-1$
232:            }
233:
234:            /* (non-Javadoc)
235:             * @see org.eclipse.pde.ui.templates.ITemplateSection#getUsedExtensionPoint()
236:             */
237:            public String getUsedExtensionPoint() {
238:                return "org.eclipse.ui.importWizards"; //$NON-NLS-1$
239:            }
240:
241:            /**
242:             * Returns a 2-D String array based on a comma seperated
243:             * string of choices. 
244:             * 
245:             * @param iconLocations
246:             * 				comma seperated string of icon placement options
247:             * @return the 2-D array of choices
248:             * 				
249:             */
250:            protected String[][] fromCommaSeparated(String iconLocations) {
251:                StringTokenizer tokens = new StringTokenizer(iconLocations, ","); //$NON-NLS-1$
252:                String[][] choices = new String[tokens.countTokens() / 2][2];
253:                int x = 0, y = 0;
254:                while (tokens.hasMoreTokens()) {
255:                    choices[x][y++] = tokens.nextToken();
256:                    choices[x++][y--] = tokens.nextToken();
257:                }
258:                return choices;
259:            }
260:        }
w___ww._j_a_va__2___s___.c___o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.