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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.wizards.plugin;
011:
012:        import java.util.StringTokenizer;
013:
014:        import org.eclipse.core.runtime.IStatus;
015:        import org.eclipse.jface.wizard.IWizardPage;
016:        import org.eclipse.jface.wizard.WizardPage;
017:        import org.eclipse.pde.internal.core.PDECoreMessages;
018:        import org.eclipse.pde.internal.core.util.IdUtil;
019:        import org.eclipse.pde.internal.core.util.VersionUtil;
020:        import org.eclipse.pde.internal.ui.PDEUIMessages;
021:        import org.eclipse.pde.internal.ui.util.PDELabelUtility;
022:        import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
023:        import org.eclipse.pde.ui.IFieldData;
024:        import org.eclipse.swt.SWT;
025:        import org.eclipse.swt.events.ModifyEvent;
026:        import org.eclipse.swt.events.ModifyListener;
027:        import org.eclipse.swt.layout.GridData;
028:        import org.eclipse.swt.widgets.Composite;
029:        import org.eclipse.swt.widgets.Label;
030:        import org.eclipse.swt.widgets.Text;
031:
032:        public abstract class ContentPage extends WizardPage {
033:
034:            protected boolean fInitialized = false;
035:            protected Text fIdText;
036:            protected Text fVersionText;
037:            protected Text fNameText;
038:            protected Text fProviderText;
039:            protected Label fLibraryLabel;
040:            protected Text fLibraryText;
041:
042:            protected NewProjectCreationPage fMainPage;
043:            protected AbstractFieldData fData;
044:            protected IProjectProvider fProjectProvider;
045:
046:            protected final static int PROPERTIES_GROUP = 1;
047:
048:            protected int fChangedGroups = 0;
049:
050:            protected ModifyListener propertiesListener = new ModifyListener() {
051:                public void modifyText(ModifyEvent e) {
052:                    if (fInitialized)
053:                        fChangedGroups |= PROPERTIES_GROUP;
054:                    validatePage();
055:                }
056:            };
057:
058:            public ContentPage(String pageName, IProjectProvider provider,
059:                    NewProjectCreationPage page, AbstractFieldData data) {
060:                super (pageName);
061:                fMainPage = page;
062:                fProjectProvider = provider;
063:                fData = data;
064:            }
065:
066:            protected Text createText(Composite parent, ModifyListener listener) {
067:                Text text = new Text(parent, SWT.BORDER | SWT.SINGLE);
068:                text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
069:                text.addModifyListener(listener);
070:                return text;
071:            }
072:
073:            protected abstract void validatePage();
074:
075:            protected String validateProperties() {
076:
077:                if (!fInitialized) {
078:                    if (!fIdText.getText().trim().equals(
079:                            fProjectProvider.getProjectName())) {
080:                        setMessage(
081:                                PDEUIMessages.ContentPage_illegalCharactersInID,
082:                                INFORMATION);
083:                    } else {
084:                        setMessage(null);
085:                    }
086:                    return null;
087:                }
088:
089:                setMessage(null);
090:                String errorMessage = null;
091:
092:                // Validate ID
093:                errorMessage = validateId();
094:                if (errorMessage != null) {
095:                    return errorMessage;
096:                }
097:
098:                // Validate Version
099:                errorMessage = validateVersion(fVersionText);
100:                if (errorMessage != null) {
101:                    return errorMessage;
102:                }
103:
104:                // Validate Name
105:                errorMessage = validateName();
106:                if (errorMessage != null) {
107:                    return errorMessage;
108:                }
109:
110:                return null;
111:            }
112:
113:            /**
114:             * @param text
115:             * @return
116:             */
117:            protected String validateVersion(Text text) {
118:                if (text.getText().trim().length() == 0) {
119:                    return PDELabelUtility
120:                            .qualifyMessage(
121:                                    PDELabelUtility.getFieldLabel(text),
122:                                    PDEUIMessages.ControlValidationUtility_errorMsgValueMustBeSpecified);
123:                } else if (!isVersionValid(text.getText().trim())) {
124:                    return PDELabelUtility
125:                            .qualifyMessage(
126:                                    PDELabelUtility.getFieldLabel(text),
127:                                    PDECoreMessages.BundleErrorReporter_InvalidFormatInBundleVersion);
128:                }
129:                return null;
130:            }
131:
132:            /**
133:             * @return
134:             */
135:            private String validateName() {
136:                if (fNameText.getText().trim().length() == 0) {
137:                    return PDEUIMessages.ContentPage_noname;
138:                }
139:                return null;
140:            }
141:
142:            private String validateId() {
143:                String id = fIdText.getText().trim();
144:                if (id.length() == 0)
145:                    return PDEUIMessages.ContentPage_noid;
146:
147:                if (!IdUtil.isValidCompositeID(id)) {
148:                    return PDEUIMessages.ContentPage_invalidId;
149:                }
150:                return null;
151:            }
152:
153:            protected boolean isVersionValid(String version) {
154:                return VersionUtil.validateVersion(version).getSeverity() == IStatus.OK;
155:            }
156:
157:            public IWizardPage getNextPage() {
158:                updateData();
159:                return super .getNextPage();
160:            }
161:
162:            /*
163:             * (non-Javadoc)
164:             * 
165:             * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
166:             */
167:            public void setVisible(boolean visible) {
168:                if (visible) {
169:                    // update the library field/label enabled state
170:                    fLibraryLabel.setEnabled(!fData.isSimple());
171:                    fLibraryText.setEnabled(!fData.isSimple());
172:
173:                    String id = computeId();
174:                    // properties group
175:                    if ((fChangedGroups & PROPERTIES_GROUP) == 0) {
176:                        int oldfChanged = fChangedGroups;
177:                        fIdText.setText(id);
178:                        fVersionText.setText("1.0.0"); //$NON-NLS-1$
179:                        fNameText.setText(IdUtil.getValidName(id,
180:                                getNameFieldQualifier()));
181:                        fProviderText.setText(IdUtil.getValidProvider(id));
182:                        presetLibraryField(id);
183:                        fChangedGroups = oldfChanged;
184:                    }
185:                    if (fInitialized)
186:                        validatePage();
187:                    else
188:                        fInitialized = true;
189:                }
190:                super .setVisible(visible);
191:            }
192:
193:            protected String computeId() {
194:                return IdUtil.getValidId(fProjectProvider.getProjectName());
195:            }
196:
197:            private void presetLibraryField(String id) {
198:                double version = Double.parseDouble(fData.getTargetVersion());
199:                if (version >= 3.1) {
200:                    fLibraryText.setText(""); //$NON-NLS-1$
201:                    return;
202:                }
203:
204:                StringTokenizer tok = new StringTokenizer(id, "."); //$NON-NLS-1$
205:                while (tok.hasMoreTokens()) {
206:                    String token = tok.nextToken();
207:                    if (!tok.hasMoreTokens())
208:                        fLibraryText.setText(token + ".jar"); //$NON-NLS-1$
209:                }
210:            }
211:
212:            protected abstract String getNameFieldQualifier();
213:
214:            public void updateData() {
215:                fData.setId(fIdText.getText().trim());
216:                fData.setVersion(fVersionText.getText().trim());
217:                fData.setName(fNameText.getText().trim());
218:                fData.setProvider(fProviderText.getText().trim());
219:                if (!fData.isSimple()) {
220:                    String library = fLibraryText.getText().trim();
221:                    if (library.length() > 0) {
222:                        if (!library.endsWith(".jar") && !library.endsWith("/") && !library.equals(".")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
223:                            library += "/"; //$NON-NLS-1$
224:                        fData.setLibraryName(library);
225:                    } else {
226:                        fData.setLibraryName(null);
227:                    }
228:                }
229:            }
230:
231:            public IFieldData getData() {
232:                return fData;
233:            }
234:
235:            public String getId() {
236:                return fIdText.getText().trim();
237:            }
238:        }
w_ww_.j___a___v_a2__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.