Source Code Cross Referenced for NewProjectCreationPage.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 org.eclipse.core.resources.IProject;
013:        import org.eclipse.core.resources.IResource;
014:        import org.eclipse.core.resources.IWorkspace;
015:        import org.eclipse.core.resources.ResourcesPlugin;
016:        import org.eclipse.core.runtime.IStatus;
017:        import org.eclipse.jdt.ui.PreferenceConstants;
018:        import org.eclipse.jface.dialogs.Dialog;
019:        import org.eclipse.jface.dialogs.IDialogSettings;
020:        import org.eclipse.jface.preference.IPreferenceStore;
021:        import org.eclipse.jface.viewers.IStructuredSelection;
022:        import org.eclipse.pde.internal.core.ICoreConstants;
023:        import org.eclipse.pde.internal.core.PDECore;
024:        import org.eclipse.pde.internal.core.TargetPlatformHelper;
025:        import org.eclipse.pde.internal.ui.IHelpContextIds;
026:        import org.eclipse.pde.internal.ui.PDEUIMessages;
027:        import org.eclipse.swt.SWT;
028:        import org.eclipse.swt.events.ModifyEvent;
029:        import org.eclipse.swt.events.ModifyListener;
030:        import org.eclipse.swt.events.SelectionAdapter;
031:        import org.eclipse.swt.events.SelectionEvent;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.layout.GridLayout;
034:        import org.eclipse.swt.widgets.Button;
035:        import org.eclipse.swt.widgets.Combo;
036:        import org.eclipse.swt.widgets.Composite;
037:        import org.eclipse.swt.widgets.Group;
038:        import org.eclipse.swt.widgets.Label;
039:        import org.eclipse.swt.widgets.Text;
040:        import org.eclipse.ui.PlatformUI;
041:        import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
042:
043:        public class NewProjectCreationPage extends
044:                WizardNewProjectCreationPage {
045:            protected Button fJavaButton;
046:            protected boolean fFragment;
047:            private Label fSourceLabel;
048:            private Text fSourceText;
049:            private Label fOutputlabel;
050:            private Text fOutputText;
051:            private AbstractFieldData fData;
052:            private Button fEclipseButton;
053:            private Combo fTargetCombo;
054:            private Combo fOSGiCombo;
055:            private Button fOSGIButton;
056:            private IStructuredSelection fSelection;
057:
058:            private static final String S_OSGI_PROJECT = "osgiProject"; //$NON-NLS-1$
059:            private static final String S_TARGET_NAME = "targetName"; //$NON-NLS-1$
060:
061:            public NewProjectCreationPage(String pageName,
062:                    AbstractFieldData data, boolean fragment,
063:                    IStructuredSelection selection) {
064:                super (pageName);
065:                fFragment = fragment;
066:                fData = data;
067:                fSelection = selection;
068:            }
069:
070:            public void createControl(Composite parent) {
071:                super .createControl(parent);
072:                Composite control = (Composite) getControl();
073:                GridLayout layout = new GridLayout();
074:                control.setLayout(layout);
075:
076:                createProjectTypeGroup(control);
077:                createFormatGroup(control);
078:                createWorkingSetGroup(
079:                        control,
080:                        fSelection,
081:                        new String[] {
082:                                "org.eclipse.jdt.ui.JavaWorkingSetPage", //$NON-NLS-1$
083:                                "org.eclipse.pde.ui.pluginWorkingSet", "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$ //$NON-NLS-2$
084:
085:                updateRuntimeDependency();
086:
087:                Dialog.applyDialogFont(control);
088:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
089:                        control,
090:                        fFragment ? IHelpContextIds.NEW_FRAGMENT_STRUCTURE_PAGE
091:                                : IHelpContextIds.NEW_PROJECT_STRUCTURE_PAGE);
092:                setControl(control);
093:            }
094:
095:            private void createProjectTypeGroup(Composite container) {
096:                Group group = new Group(container, SWT.NONE);
097:                group.setText(PDEUIMessages.ProjectStructurePage_settings);
098:                GridLayout layout = new GridLayout();
099:                layout.numColumns = 2;
100:                group.setLayout(layout);
101:                group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
102:
103:                fJavaButton = createButton(group, SWT.CHECK, 2, 0);
104:                fJavaButton.setText(PDEUIMessages.ProjectStructurePage_java);
105:                fJavaButton.setSelection(true);
106:                fJavaButton.addSelectionListener(new SelectionAdapter() {
107:                    public void widgetSelected(SelectionEvent e) {
108:                        boolean enabled = fJavaButton.getSelection();
109:                        fSourceLabel.setEnabled(enabled);
110:                        fSourceText.setEnabled(enabled);
111:                        fOutputlabel.setEnabled(enabled);
112:                        fOutputText.setEnabled(enabled);
113:                        setPageComplete(validatePage());
114:                    }
115:                });
116:
117:                fSourceLabel = createLabel(group,
118:                        PDEUIMessages.ProjectStructurePage_source);
119:                fSourceText = createText(group);
120:                IPreferenceStore store = PreferenceConstants
121:                        .getPreferenceStore();
122:                fSourceText.setText(store
123:                        .getString(PreferenceConstants.SRCBIN_SRCNAME));
124:
125:                fOutputlabel = createLabel(group,
126:                        PDEUIMessages.ProjectStructurePage_output);
127:                fOutputText = createText(group);
128:                fOutputText.setText(store
129:                        .getString(PreferenceConstants.SRCBIN_BINNAME));
130:            }
131:
132:            private void createFormatGroup(Composite container) {
133:                Group group = new Group(container, SWT.NONE);
134:                group.setText(PDEUIMessages.NewProjectCreationPage_target);
135:                group.setLayout(new GridLayout(2, false));
136:                group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
137:
138:                Label label = new Label(group, SWT.NONE);
139:                if (fFragment)
140:                    label.setText(PDEUIMessages.NewProjectCreationPage_ftarget);
141:                else
142:                    label.setText(PDEUIMessages.NewProjectCreationPage_ptarget);
143:                GridData gd = new GridData();
144:                gd.horizontalSpan = 2;
145:                label.setLayoutData(gd);
146:
147:                IDialogSettings settings = getDialogSettings();
148:                boolean osgiProject = (settings == null) ? false : settings
149:                        .getBoolean(S_OSGI_PROJECT);
150:
151:                fEclipseButton = createButton(group, SWT.RADIO, 1, 30);
152:                fEclipseButton
153:                        .setText(PDEUIMessages.NewProjectCreationPage_pDependsOnRuntime);
154:                fEclipseButton.setSelection(!osgiProject);
155:                fEclipseButton.addSelectionListener(new SelectionAdapter() {
156:                    public void widgetSelected(SelectionEvent e) {
157:                        updateRuntimeDependency();
158:                    }
159:                });
160:
161:                fTargetCombo = new Combo(group, SWT.READ_ONLY | SWT.SINGLE);
162:                fTargetCombo.setItems(new String[] { ICoreConstants.TARGET33,
163:                        ICoreConstants.TARGET32, ICoreConstants.TARGET31,
164:                        ICoreConstants.TARGET30 });
165:                boolean comboInitialized = false;
166:                if (settings != null && !osgiProject) {
167:                    String text = settings.get(S_TARGET_NAME);
168:                    comboInitialized = (text != null && fTargetCombo
169:                            .indexOf(text) >= 0);
170:                    if (comboInitialized)
171:                        fTargetCombo.setText(text);
172:                }
173:                if (!comboInitialized) {
174:                    if (PDECore.getDefault().areModelsInitialized())
175:                        fTargetCombo.setText(TargetPlatformHelper
176:                                .getTargetVersionString());
177:                    else
178:                        fTargetCombo.setText(ICoreConstants.TARGET33);
179:                }
180:
181:                fOSGIButton = createButton(group, SWT.RADIO, 1, 30);
182:                fOSGIButton
183:                        .setText(PDEUIMessages.NewProjectCreationPage_pPureOSGi);
184:                fOSGIButton.setSelection(osgiProject);
185:
186:                fOSGiCombo = new Combo(group, SWT.READ_ONLY | SWT.SINGLE);
187:                fOSGiCombo.setItems(new String[] { ICoreConstants.EQUINOX,
188:                        PDEUIMessages.NewProjectCreationPage_standard });
189:                comboInitialized = false;
190:                if (settings != null && osgiProject) {
191:                    String text = settings.get(S_TARGET_NAME);
192:                    comboInitialized = (text != null && fOSGiCombo
193:                            .indexOf(text) >= 0);
194:                    if (comboInitialized)
195:                        fOSGiCombo.setText(text);
196:                }
197:                if (!comboInitialized)
198:                    fOSGiCombo.setText(ICoreConstants.EQUINOX);
199:
200:            }
201:
202:            private void updateRuntimeDependency() {
203:                boolean depends = fEclipseButton.getSelection();
204:                fTargetCombo.setEnabled(depends);
205:                fOSGiCombo.setEnabled(!depends);
206:            }
207:
208:            private Button createButton(Composite container, int style,
209:                    int span, int indent) {
210:                Button button = new Button(container, style);
211:                GridData gd = new GridData();
212:                gd.horizontalSpan = span;
213:                gd.horizontalIndent = indent;
214:                button.setLayoutData(gd);
215:                return button;
216:            }
217:
218:            private Label createLabel(Composite container, String text) {
219:                Label label = new Label(container, SWT.NONE);
220:                label.setText(text);
221:                GridData gd = new GridData();
222:                gd.horizontalIndent = 30;
223:                label.setLayoutData(gd);
224:                return label;
225:            }
226:
227:            private Text createText(Composite container) {
228:                Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
229:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
230:                gd.widthHint = 300;
231:                text.setLayoutData(gd);
232:                text.addModifyListener(new ModifyListener() {
233:                    public void modifyText(ModifyEvent e) {
234:                        setPageComplete(validatePage());
235:                    }
236:                });
237:                return text;
238:            }
239:
240:            public void updateData() {
241:                fData.setSimple(!fJavaButton.getSelection());
242:                fData.setSourceFolderName(fSourceText.getText().trim());
243:                fData.setOutputFolderName(fOutputText.getText().trim());
244:                fData.setLegacy(false); //$NON-NLS-1$
245:                fData.setTargetVersion(fTargetCombo.getText());
246:                fData.setHasBundleStructure(fOSGIButton.getSelection()
247:                        || Double.parseDouble(fTargetCombo.getText()) >= 3.1);
248:                fData.setOSGiFramework(fOSGIButton.getSelection() ? fOSGiCombo
249:                        .getText() : null);
250:                fData.setWorkingSets(getSelectedWorkingSets());
251:            }
252:
253:            protected boolean validatePage() {
254:                if (!super .validatePage())
255:                    return false;
256:
257:                String name = getProjectName();
258:                if (name.indexOf('%') > 0) {
259:                    setErrorMessage(PDEUIMessages.NewProjectCreationPage_invalidProjectName);
260:                    return false;
261:                }
262:
263:                String location = getLocationPath().toString();
264:                if (location.indexOf('%') > 0) {
265:                    setErrorMessage(PDEUIMessages.NewProjectCreationPage_invalidLocationPath);
266:                    return false;
267:                }
268:
269:                if (fJavaButton.getSelection()) {
270:                    IWorkspace workspace = ResourcesPlugin.getWorkspace();
271:                    IProject dmy = workspace.getRoot().getProject("project"); //$NON-NLS-1$
272:                    IStatus status;
273:                    if (fSourceText != null
274:                            && fSourceText.getText().length() != 0) {
275:                        status = workspace.validatePath(dmy.getFullPath()
276:                                .append(fSourceText.getText()).toString(),
277:                                IResource.FOLDER);
278:                        if (!status.isOK()) {
279:                            setErrorMessage(status.getMessage());
280:                            return false;
281:                        }
282:                    }
283:                    if (fOutputText != null
284:                            && fOutputText.getText().length() != 0) {
285:                        status = workspace.validatePath(dmy.getFullPath()
286:                                .append(fOutputText.getText()).toString(),
287:                                IResource.FOLDER);
288:                        if (!status.isOK()) {
289:                            setErrorMessage(status.getMessage());
290:                            return false;
291:                        }
292:                    }
293:                }
294:                setErrorMessage(null);
295:                setMessage(null);
296:                return true;
297:            }
298:
299:            protected void saveSettings(IDialogSettings settings) {
300:                boolean eclipseSelected = fEclipseButton.getSelection();
301:                String targetName = eclipseSelected ? fTargetCombo.getText()
302:                        : fOSGiCombo.getText();
303:                settings
304:                        .put(S_TARGET_NAME,
305:                                (eclipseSelected && TargetPlatformHelper
306:                                        .getTargetVersionString().equals(
307:                                                targetName)) ? null
308:                                        : targetName);
309:                settings.put(S_OSGI_PROJECT, !eclipseSelected);
310:            }
311:
312:        }
w__w_w__.j__a__v_a__2___s___.c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.