1 /*******************************************************************************
2 * Copyright (c) 2000, 2012 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.ui.wizards;
14 import java.io.IOException;
16 import java.util.ArrayList;
17 import java.util.Arrays;
18 import java.util.HashMap;
19 import java.util.Iterator;
20 import java.util.List;
22 import java.util.Observable;
23 import java.util.Observer;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.events.SelectionEvent;
27 import org.eclipse.swt.events.SelectionListener;
28 import org.eclipse.swt.layout.GridData;
29 import org.eclipse.swt.layout.GridLayout;
30 import org.eclipse.swt.widgets.Combo;
31 import org.eclipse.swt.widgets.Composite;
32 import org.eclipse.swt.widgets.Control;
33 import org.eclipse.swt.widgets.DirectoryDialog;
34 import org.eclipse.swt.widgets.Group;
35 import org.eclipse.swt.widgets.Label;
36 import org.eclipse.swt.widgets.Link;
38 import org.eclipse.core.filesystem.URIUtil;
40 import org.eclipse.core.runtime.CoreException;
41 import org.eclipse.core.runtime.IPath;
42 import org.eclipse.core.runtime.IProgressMonitor;
43 import org.eclipse.core.runtime.IStatus;
44 import org.eclipse.core.runtime.NullProgressMonitor;
45 import org.eclipse.core.runtime.OperationCanceledException;
46 import org.eclipse.core.runtime.Path;
47 import org.eclipse.core.runtime.Platform;
48 import org.eclipse.core.runtime.SubProgressMonitor;
50 import org.eclipse.core.resources.IFolder;
51 import org.eclipse.core.resources.IProject;
52 import org.eclipse.core.resources.IResource;
53 import org.eclipse.core.resources.IWorkspace;
54 import org.eclipse.core.resources.IWorkspaceRoot;
55 import org.eclipse.core.resources.ResourcesPlugin;
57 import org.eclipse.jface.dialogs.Dialog;
58 import org.eclipse.jface.dialogs.IDialogConstants;
59 import org.eclipse.jface.dialogs.IDialogSettings;
60 import org.eclipse.jface.viewers.IStructuredSelection;
61 import org.eclipse.jface.viewers.ITreeSelection;
62 import org.eclipse.jface.viewers.TreePath;
63 import org.eclipse.jface.wizard.WizardPage;
65 import org.eclipse.ui.IWorkbenchPart;
66 import org.eclipse.ui.IWorkingSet;
67 import org.eclipse.ui.PlatformUI;
68 import org.eclipse.ui.dialogs.PreferencesUtil;
69 import org.eclipse.ui.dialogs.WorkingSetConfigurationBlock;
71 import org.eclipse.jdt.core.IClasspathEntry;
72 import org.eclipse.jdt.core.IJavaProject;
73 import org.eclipse.jdt.core.JavaCore;
75 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
76 import org.eclipse.jdt.internal.corext.util.Messages;
78 import org.eclipse.jdt.launching.IVMInstall;
79 import org.eclipse.jdt.launching.IVMInstall2;
80 import org.eclipse.jdt.launching.IVMInstallType;
81 import org.eclipse.jdt.launching.JavaRuntime;
82 import org.eclipse.jdt.launching.VMStandin;
83 import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
85 import org.eclipse.jdt.ui.JavaUI;
86 import org.eclipse.jdt.ui.PreferenceConstants;
88 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
89 import org.eclipse.jdt.internal.ui.JavaPlugin;
90 import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
91 import org.eclipse.jdt.internal.ui.preferences.CompliancePreferencePage;
92 import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage;
93 import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
94 import org.eclipse.jdt.internal.ui.util.CoreUtility;
95 import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
96 import org.eclipse.jdt.internal.ui.wizards.ClassPathDetector;
97 import org.eclipse.jdt.internal.ui.wizards.JavaProjectWizard;
98 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
99 import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
100 import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
101 import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
102 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
103 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
104 import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
105 import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
106 import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
107 import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs;
110 * The first page of the New Java Project wizard. This page is typically used in combination with
111 * {@link NewJavaProjectWizardPageTwo}. Clients can extend this page to modify the UI: Add, remove
112 * or reorder sections.
115 * Clients may instantiate or subclass.
120 public class NewJavaProjectWizardPageOne extends WizardPage {
123 * Request a project name. Fires an event whenever the text field is
124 * changed, regardless of its content.
126 public final class NameGroup extends Observable implements IDialogFieldListener {
128 public final StringDialogField fNameField;
131 // text field for project name
132 fNameField= new StringDialogField();
133 fNameField.generated_3193238318253913111(this);
136 public Control createControl(Composite composite) {
137 Composite nameComposite= new Composite(composite, SWT.NONE);
138 nameComposite.setFont(composite.getFont());
139 return fNameField.generated_253327009741664144(nameComposite);
142 protected void fireEvent() {
147 public String getName() {
148 return fNameField.getText().trim();
151 public void postSetFocus() {
152 fNameField.postSetFocusOnDialogField(getShell().getDisplay());
155 public void setName(String name) {
156 fNameField.setText(name);
160 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
162 public void dialogFieldChanged(DialogField field) {
168 * Request a location. Fires an event whenever the checkbox or the location
169 * field is changed, regardless of whether the change originates from the
170 * user or has been invoked programmatically.
172 public final class LocationGroup extends Observable implements Observer, IStringButtonAdapter, IDialogFieldListener {
174 public final SelectionButtonDialogField fUseDefaults;
175 public final StringButtonDialogField fLocation;
177 public String fPreviousExternalLocation;
179 private static final String DIALOGSTORE_LAST_EXTERNAL_LOC= JavaUI.ID_PLUGIN + ".last.external.project"; //$NON-NLS-1$
181 public LocationGroup() {
182 fUseDefaults= new SelectionButtonDialogField(SWT.CHECK);
183 fUseDefaults.setDialogFieldListener(this);
184 fUseDefaults.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LocationGroup_location_desc);
186 fLocation= new StringButtonDialogField(this);
187 fLocation.generated_5234504517016112488(this);
189 fPreviousExternalLocation= ""; //$NON-NLS-1$
192 public Control createControl(Composite composite) {
193 final int numColumns= 4;
195 final Composite locationComposite= new Composite(composite, SWT.NONE);
196 fLocation.generated_643901326608760342(this, numColumns, locationComposite);
198 return locationComposite;
201 protected void fireEvent() {
206 protected String getDefaultPath(String name) {
207 final IPath path= Platform.getLocation().append(name);
208 return path.toOSString();
212 * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
214 public void update(Observable o, Object arg) {
215 if (isUseDefaultSelected()) {
216 fLocation.setText(getDefaultPath(fNameGroup.getName()));
221 public IPath getLocation() {
222 if (isUseDefaultSelected()) {
223 return Platform.getLocation();
225 return Path.fromOSString(fLocation.getText().trim());
228 public boolean isUseDefaultSelected() {
229 return fUseDefaults.isSelected();
232 public void setLocation(IPath path) {
233 fUseDefaults.setSelection(path == null);
235 fLocation.setText(path.toOSString());
237 fLocation.setText(getDefaultPath(fNameGroup.getName()));
243 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter#changeControlPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
245 public void changeControlPressed(DialogField field) {
246 final DirectoryDialog dialog= new DirectoryDialog(getShell());
247 dialog.setMessage(NewWizardMessages.NewJavaProjectWizardPageOne_directory_message);
248 String directoryName = fLocation.getText().trim();
249 if (directoryName.length() == 0) {
250 String prevLocation= JavaPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LAST_EXTERNAL_LOC);
251 if (prevLocation != null) {
252 directoryName= prevLocation;
256 if (directoryName.length() > 0) {
257 final File path = new File(directoryName);
259 dialog.setFilterPath(directoryName);
261 final String selectedDirectory = dialog.open();
262 if (selectedDirectory != null) {
263 String oldDirectory= fLocation.generated_6444432378694638790(selectedDirectory);
264 String lastSegment= new Path(selectedDirectory).lastSegment();
265 if (lastSegment != null && (fNameGroup.getName().length() == 0 || fNameGroup.getName().equals(oldDirectory))) {
266 fNameGroup.setName(lastSegment);
268 JavaPlugin.getDefault().getDialogSettings().put(DIALOGSTORE_LAST_EXTERNAL_LOC, selectedDirectory);
273 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
275 public void dialogFieldChanged(DialogField field) {
276 if (field == fUseDefaults) {
277 final boolean checked= fUseDefaults.isSelected();
279 fPreviousExternalLocation= fLocation.getText();
280 fLocation.setText(getDefaultPath(fNameGroup.getName()));
281 fLocation.setEnabled(false);
283 fLocation.generated_3726504999918786352(this);
289 public URI generated_4065803390293803522() {
290 if (isUseDefaultSelected()) {
293 return URIUtil.toURI(getLocation());
298 * Request a project layout.
300 public final class LayoutGroup implements Observer, SelectionListener {
302 public final SelectionButtonDialogField fStdRadio;
303 public final SelectionButtonDialogField fSrcBinRadio;
305 public Link fPreferenceLink;
307 public LayoutGroup() {
308 fStdRadio= new SelectionButtonDialogField(SWT.RADIO);
309 fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder);
311 fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO);
312 fSrcBinRadio.generated_2986520533270641386(this);
316 public Control createContent(Composite composite) {
317 fGroup= new Group(composite, SWT.NONE);
318 fGroup.setFont(composite.getFont());
319 fGroup.setLayout(initGridLayout(new GridLayout(3, false), true));
320 fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_title);
322 return fStdRadio.generated_8796833943613112164(this);
327 * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
329 public void update(Observable o, Object arg) {
333 public void updateEnableState() {
334 if (fDetectGroup == null)
337 final boolean detect= fDetectGroup.mustDetect();
338 fStdRadio.setEnabled(!detect);
339 fSrcBinRadio.setEnabled(!detect);
340 if (fPreferenceLink != null) {
341 fPreferenceLink.setEnabled(!detect);
343 if (fGroup != null) {
344 fGroup.setEnabled(!detect);
349 * Return <code>true</code> if the user specified to create 'source' and 'bin' folders.
351 * @return returns <code>true</code> if the user specified to create 'source' and 'bin' folders.
353 public boolean isSrcBin() {
354 return fSrcBinRadio.isSelected();
358 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
360 public void widgetSelected(SelectionEvent e) {
361 widgetDefaultSelected(e);
365 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
367 public void widgetDefaultSelected(SelectionEvent e) {
368 String id= NewJavaProjectPreferencePage.ID;
369 PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null).open();
370 fDetectGroup.handlePossibleJVMChange();
371 fJREGroup.handlePossibleJVMChange();
375 public final class JREGroup implements Observer, SelectionListener, IDialogFieldListener {
377 private static final String LAST_SELECTED_EE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.execution.enviroment"; //$NON-NLS-1$
378 private static final String LAST_SELECTED_JRE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.project.jre"; //$NON-NLS-1$
379 // private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; // used before EE became default
380 public static final String LAST_SELECTED_JRE_KIND2= JavaUI.ID_PLUGIN + ".last.selected.jre.kind2"; //$NON-NLS-1$
382 private static final int DEFAULT_JRE= 0;
383 public static final int PROJECT_JRE= 1;
384 public static final int EE_JRE= 2;
386 public final SelectionButtonDialogField fUseDefaultJRE;
387 public final SelectionButtonDialogField fUseProjectJRE;
388 public final SelectionButtonDialogField fUseEEJRE;
389 public final ComboDialogField fJRECombo;
390 public final ComboDialogField fEECombo;
391 private Group fGroup;
392 public Link fPreferenceLink;
393 public IVMInstall[] fInstalledJVMs;
394 public String[] fJRECompliance;
395 public IExecutionEnvironment[] fInstalledEEs;
396 public String[] fEECompliance;
399 fUseDefaultJRE= new SelectionButtonDialogField(SWT.RADIO);
400 fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
402 fUseProjectJRE= new SelectionButtonDialogField(SWT.RADIO);
403 fUseProjectJRE.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_specific_compliance);
405 fJRECombo= new ComboDialogField(SWT.READ_ONLY);
406 fillInstalledJREs(fJRECombo);
407 fJRECombo.setDialogFieldListener(this);
409 fUseEEJRE= new SelectionButtonDialogField(SWT.RADIO);
410 fUseEEJRE.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_specific_EE);
412 fEECombo= new ComboDialogField(SWT.READ_ONLY);
413 fillExecutionEnvironments(fEECombo);
414 fEECombo.setDialogFieldListener(this);
416 switch (getLastSelectedJREKind()) {
418 fUseDefaultJRE.setSelection(true);
421 fUseProjectJRE.setSelection(true);
424 fUseEEJRE.setSelection(true);
428 fUseProjectJRE.generated_1822827867514341499(this);
429 fUseEEJRE.setDialogFieldListener(this);
432 public Control createControl(Composite composite) {
433 fGroup= new Group(composite, SWT.NONE);
434 fGroup.setFont(composite.getFont());
435 fGroup.setLayout(initGridLayout(new GridLayout(2, false), true));
436 fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title);
438 fUseEEJRE.doFillIntoGrid(fGroup, 1);
439 Combo eeComboControl= fEECombo.getComboControl(fGroup);
440 eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
442 fUseProjectJRE.doFillIntoGrid(fGroup, 1);
443 Combo comboControl= fJRECombo.getComboControl(fGroup);
444 comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
446 fUseDefaultJRE.doFillIntoGrid(fGroup, 1);
448 fPreferenceLink= new Link(fGroup, SWT.NONE);
449 fPreferenceLink.setFont(fGroup.getFont());
450 fPreferenceLink.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_link_description);
451 fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
452 fPreferenceLink.addSelectionListener(this);
459 private void fillInstalledJREs(ComboDialogField comboField) {
460 String selectedItem= getLastSelectedJRE();
461 int selectionIndex= -1;
462 comboField.generated_14267488333256409(JREGroup.this, selectedItem);
465 private void fillExecutionEnvironments(ComboDialogField comboField) {
466 comboField.generated_5411689368033140336(JREGroup.this);
469 public IVMInstall[] getWorkspaceJREs() {
470 List<VMStandin> standins = new ArrayList<VMStandin>();
471 IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
472 for (int i = 0; i < types.length; i++) {
473 IVMInstallType type = types[i];
474 IVMInstall[] installs = type.getVMInstalls();
475 for (int j = 0; j < installs.length; j++) {
476 IVMInstall install = installs[j];
477 standins.add(new VMStandin(install));
480 return standins.toArray(new IVMInstall[standins.size()]);
483 public String getDefaultJVMName() {
484 IVMInstall install= JavaRuntime.getDefaultVMInstall();
485 if (install != null) {
486 return install.getName();
488 return NewWizardMessages.NewJavaProjectWizardPageOne_UnknownDefaultJRE_name;
492 public String getDefaultEEName() {
493 IVMInstall defaultVM= JavaRuntime.getDefaultVMInstall();
495 IExecutionEnvironment[] environments= JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments();
496 if (defaultVM != null) {
497 for (int i= 0; i < environments.length; i++) {
498 IVMInstall eeDefaultVM= environments[i].getDefaultVM();
499 if (eeDefaultVM != null && defaultVM.getId().equals(eeDefaultVM.getId()))
500 return environments[i].getId();
505 if (defaultVM instanceof IVMInstall2) {
506 defaultCC= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVM, JavaCore.VERSION_1_4);
508 defaultCC= JavaCore.VERSION_1_4;
511 for (int i= 0; i < environments.length; i++) {
512 String eeCompliance= JavaModelUtil.getExecutionEnvironmentCompliance(environments[i]);
513 if (defaultCC.endsWith(eeCompliance))
514 return environments[i].getId();
517 return "JavaSE-1.6"; //$NON-NLS-1$
520 private String getDefaultJVMLabel() {
521 return Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_default_compliance, getDefaultJVMName());
524 public void update(Observable o, Object arg) {
528 private void updateEnableState() {
529 final boolean detect= fDetectGroup.mustDetect();
530 fUseDefaultJRE.setEnabled(!detect);
531 fUseProjectJRE.setEnabled(!detect);
532 fUseEEJRE.generated_7787109378699083042(this, detect);
533 if (fGroup != null) {
534 fGroup.setEnabled(!detect);
539 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
541 public void widgetSelected(SelectionEvent e) {
542 widgetDefaultSelected(e);
546 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
548 public void widgetDefaultSelected(SelectionEvent e) {
549 String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
550 String eeID= BuildPathSupport.EE_PREF_PAGE_ID;
551 String complianceId= CompliancePreferencePage.PREF_ID;
552 Map<String, Boolean> data= new HashMap<String, Boolean>();
553 data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
554 PreferencesUtil.createPreferenceDialogOn(getShell(), jreID, new String[] { jreID, complianceId , eeID }, data).open();
556 handlePossibleJVMChange();
557 fDetectGroup.handlePossibleJVMChange();
560 public void handlePossibleJVMChange() {
561 fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
562 fillInstalledJREs(fJRECombo);
563 fillExecutionEnvironments(fEECombo);
567 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
569 public void dialogFieldChanged(DialogField field) {
571 fDetectGroup.handlePossibleJVMChange();
572 if (field == fJRECombo) {
573 if (fUseProjectJRE.isSelected()) {
574 storeSelectionValue(fJRECombo, LAST_SELECTED_JRE_SETTINGS_KEY);
576 } else if (field == fEECombo) {
577 if (fUseEEJRE.isSelected()) {
578 storeSelectionValue(fEECombo, LAST_SELECTED_EE_SETTINGS_KEY);
580 } else if (field == fUseDefaultJRE) {
581 if (fUseDefaultJRE.isSelected()) {
582 JavaPlugin.getDefault().getDialogSettings().put(LAST_SELECTED_JRE_KIND2, DEFAULT_JRE);
583 fUseProjectJRE.setSelection(false);
584 fUseEEJRE.setSelection(false);
587 fUseDefaultJRE.generated_8694771703323010156(this, field);
590 private void storeSelectionValue(ComboDialogField combo, String preferenceKey) {
591 combo.generated_3376758848531533062(preferenceKey);
594 private int getLastSelectedJREKind() {
595 IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
596 if (settings.get(LAST_SELECTED_JRE_KIND2) == null)
599 return settings.getInt(LAST_SELECTED_JRE_KIND2);
602 public String getLastSelectedEE() {
603 IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
604 return settings.get(LAST_SELECTED_EE_SETTINGS_KEY);
607 private String getLastSelectedJRE() {
608 IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
609 return settings.get(LAST_SELECTED_JRE_SETTINGS_KEY);
612 public IVMInstall getSelectedJVM() {
613 if (fUseProjectJRE.isSelected()) {
614 int index= fJRECombo.getSelectionIndex();
615 if (index >= 0 && index < fInstalledJVMs.length) { // paranoia
616 return fInstalledJVMs[index];
618 } else if (fUseEEJRE.isSelected()) {
624 public IPath getJREContainerPath() {
625 if (fUseProjectJRE.isSelected()) {
626 int index= fJRECombo.getSelectionIndex();
627 if (index >= 0 && index < fInstalledJVMs.length) { // paranoia
628 return JavaRuntime.newJREContainerPath(fInstalledJVMs[index]);
630 } else if (fUseEEJRE.isSelected()) {
631 int index= fEECombo.getSelectionIndex();
632 if (index >= 0 && index < fInstalledEEs.length) { // paranoia
633 return JavaRuntime.newJREContainerPath(fInstalledEEs[index]);
639 public String getSelectedCompilerCompliance() {
640 if (fUseProjectJRE.isSelected()) {
641 int index= fJRECombo.getSelectionIndex();
642 if (index >= 0 && index < fJRECompliance.length) { // paranoia
643 return fJRECompliance[index];
645 } else if (fUseEEJRE.isSelected()) {
646 int index= fEECombo.getSelectionIndex();
647 if (index >= 0 && index < fEECompliance.length) { // paranoia
648 return fEECompliance[index];
655 private final class WorkingSetGroup {
657 private WorkingSetConfigurationBlock fWorkingSetBlock;
659 public WorkingSetGroup() {
660 String[] workingSetIds= new String[] { IWorkingSetIDs.JAVA, IWorkingSetIDs.RESOURCE };
661 fWorkingSetBlock= new WorkingSetConfigurationBlock(workingSetIds, JavaPlugin.getDefault().getDialogSettings());
662 //fWorkingSetBlock.setDialogMessage(NewWizardMessages.NewJavaProjectWizardPageOne_WorkingSetSelection_message);
665 public Control createControl(Composite composite) {
666 Group workingSetGroup= new Group(composite, SWT.NONE);
667 workingSetGroup.setFont(composite.getFont());
668 workingSetGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_WorkingSets_group);
669 workingSetGroup.setLayout(new GridLayout(1, false));
671 fWorkingSetBlock.createContent(workingSetGroup);
673 return workingSetGroup;
677 public void setWorkingSets(IWorkingSet[] workingSets) {
678 fWorkingSetBlock.setWorkingSets(workingSets);
681 public IWorkingSet[] getSelectedWorkingSets() {
682 return fWorkingSetBlock.getSelectedWorkingSets();
687 * Show a warning when the project location contains files.
689 private final class DetectGroup extends Observable implements Observer, SelectionListener {
691 private Link fHintText;
693 private boolean fDetect;
695 public DetectGroup() {
699 public Control createControl(Composite parent) {
701 Composite composite= new Composite(parent, SWT.NONE);
702 composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
703 GridLayout layout= new GridLayout(2, false);
704 layout.horizontalSpacing= 10;
705 composite.setLayout(layout);
707 fIcon= new Label(composite, SWT.LEFT);
708 fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
709 GridData gridData= new GridData(SWT.LEFT, SWT.TOP, false, false);
710 fIcon.setLayoutData(gridData);
712 fHintText= new Link(composite, SWT.WRAP);
713 fHintText.setFont(composite.getFont());
714 fHintText.addSelectionListener(this);
715 gridData= new GridData(GridData.FILL, SWT.FILL, true, true);
716 gridData.widthHint= convertWidthInCharsToPixels(50);
717 gridData.heightHint= convertHeightInCharsToPixels(3);
718 fHintText.setLayoutData(gridData);
720 handlePossibleJVMChange();
724 public void handlePossibleJVMChange() {
726 if (JavaRuntime.getDefaultVMInstall() == null) {
727 fHintText.setText(NewWizardMessages.NewJavaProjectWizardPageOne_NoJREFound_link);
728 fHintText.setVisible(true);
729 fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
730 fIcon.setVisible(true);
734 String selectedCompliance= fJREGroup.getSelectedCompilerCompliance();
735 if (selectedCompliance != null) {
736 String defaultCompliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE);
737 if (selectedCompliance.equals(defaultCompliance)) {
738 fHintText.setVisible(false);
739 fIcon.setVisible(false);
741 fHintText.setText(Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_differendWorkspaceCC_message, new String[] { BasicElementLabels.getVersionName(defaultCompliance), BasicElementLabels.getVersionName(selectedCompliance)}));
742 fHintText.setVisible(true);
743 fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
744 fIcon.setVisible(true);
749 selectedCompliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE);
750 IVMInstall selectedJVM= fJREGroup.getSelectedJVM();
751 if (selectedJVM == null) {
752 selectedJVM= JavaRuntime.getDefaultVMInstall();
754 String jvmCompliance= JavaCore.VERSION_1_4;
755 if (selectedJVM instanceof IVMInstall2) {
756 jvmCompliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) selectedJVM, JavaCore.VERSION_1_4);
758 if (!selectedCompliance.equals(jvmCompliance) && (JavaModelUtil.is50OrHigher(selectedCompliance) || JavaModelUtil.is50OrHigher(jvmCompliance))) {
759 fHintText.setText(Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_jre_message, new String[] {BasicElementLabels.getVersionName(selectedCompliance), BasicElementLabels.getVersionName(jvmCompliance)}));
760 fHintText.setVisible(true);
761 fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
762 fIcon.setVisible(true);
764 fHintText.setVisible(false);
765 fIcon.setVisible(false);
770 private boolean computeDetectState() {
771 if (fLocationGroup.isUseDefaultSelected()) {
772 String name= fNameGroup.getName();
773 if (name.length() == 0 || JavaPlugin.getWorkspace().getRoot().findMember(name) != null) {
776 final File directory= fLocationGroup.getLocation().append(name).toFile();
777 return directory.isDirectory();
780 final File directory= fLocationGroup.getLocation().toFile();
781 return directory.isDirectory();
785 public void update(Observable o, Object arg) {
786 if (o instanceof LocationGroup) {
787 boolean oldDetectState= fDetect;
788 fDetect= computeDetectState();
790 if (oldDetectState != fDetect) {
795 fHintText.setVisible(true);
796 fHintText.setText(NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_message);
797 fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
798 fIcon.setVisible(true);
800 handlePossibleJVMChange();
806 public boolean mustDetect() {
811 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
813 public void widgetSelected(SelectionEvent e) {
814 widgetDefaultSelected(e);
818 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
820 public void widgetDefaultSelected(SelectionEvent e) {
821 String jreID= BuildPathSupport.JRE_PREF_PAGE_ID;
822 String eeID= BuildPathSupport.EE_PREF_PAGE_ID;
823 String complianceId= CompliancePreferencePage.PREF_ID;
824 Map<String, Boolean> data= new HashMap<String, Boolean>();
825 data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
826 String id= "JRE".equals(e.text) ? jreID : complianceId; //$NON-NLS-1$
827 PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { jreID, complianceId, eeID }, data).open();
829 fJREGroup.handlePossibleJVMChange();
830 handlePossibleJVMChange();
833 public void generated_6722163234981482426(NewJavaProjectWizardPageOne newjavaprojectwizardpageone) {
834 addObserver(newjavaprojectwizardpageone.fLayoutGroup);
835 addObserver(newjavaprojectwizardpageone.fJREGroup);
836 newjavaprojectwizardpageone.fLocationGroup.addObserver(this);
841 * Validate this page and show appropriate warnings and error NewWizardMessages.
843 private final class Validator implements Observer {
845 public void update(Observable o, Object arg) {
847 final IWorkspace workspace= JavaPlugin.getWorkspace();
849 final String name= fNameGroup.getName();
851 // check whether the project name field is empty
852 if (name.length() == 0) {
853 setErrorMessage(null);
854 setMessage(NewWizardMessages.NewJavaProjectWizardPageOne_Message_enterProjectName);
855 setPageComplete(false);
859 // check whether the project name is valid
860 final IStatus nameStatus= workspace.validateName(name, IResource.PROJECT);
861 if (!nameStatus.isOK()) {
862 setErrorMessage(nameStatus.getMessage());
863 setPageComplete(false);
867 // check whether project already exists
868 final IProject handle= workspace.getRoot().getProject(name);
869 if (handle.exists()) {
870 setErrorMessage(NewWizardMessages.NewJavaProjectWizardPageOne_Message_projectAlreadyExists);
871 setPageComplete(false);
875 IPath projectLocation= ResourcesPlugin.getWorkspace().getRoot().getLocation().append(name);
876 if (projectLocation.toFile().exists()) {
879 String canonicalPath= projectLocation.toFile().getCanonicalPath();
880 projectLocation= new Path(canonicalPath);
881 } catch (IOException e) {
885 String existingName= projectLocation.lastSegment();
886 if (!existingName.equals(fNameGroup.getName())) {
887 setErrorMessage(Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_Message_invalidProjectNameForWorkspaceRoot, BasicElementLabels.getResourceName(existingName)));
888 setPageComplete(false);
894 final String location= fLocationGroup.getLocation().toOSString();
896 // check whether location is empty
897 if (location.length() == 0) {
898 setErrorMessage(null);
899 setMessage(NewWizardMessages.NewJavaProjectWizardPageOne_Message_enterLocation);
900 setPageComplete(false);
904 // check whether the location is a syntactically correct path
905 if (!Path.EMPTY.isValidPath(location)) {
906 setErrorMessage(NewWizardMessages.NewJavaProjectWizardPageOne_Message_invalidDirectory);
907 setPageComplete(false);
911 IPath projectPath= null;
912 if (!fLocationGroup.isUseDefaultSelected()) {
913 projectPath= Path.fromOSString(location);
914 if (!projectPath.toFile().exists()) {
915 // check non-existing external location
916 if (!canCreate(projectPath.toFile())) {
917 setErrorMessage(NewWizardMessages.NewJavaProjectWizardPageOne_Message_cannotCreateAtExternalLocation);
918 setPageComplete(false);
924 // validate the location
925 final IStatus locationStatus= workspace.validateProjectLocation(handle, projectPath);
926 if (!locationStatus.isOK()) {
927 setErrorMessage(locationStatus.getMessage());
928 setPageComplete(false);
932 setPageComplete(true);
934 setErrorMessage(null);
938 private boolean canCreate(File file) {
939 while (!file.exists()) {
940 file= file.getParentFile();
945 return file.canWrite();
949 private static final String PAGE_NAME= "NewJavaProjectWizardPageOne"; //$NON-NLS-1$
951 private final NameGroup fNameGroup;
952 private final LocationGroup fLocationGroup;
953 private final LayoutGroup fLayoutGroup;
954 private final JREGroup fJREGroup;
955 private final DetectGroup fDetectGroup;
956 private final Validator fValidator;
957 private final WorkingSetGroup fWorkingSetGroup;
960 * Creates a new {@link NewJavaProjectWizardPageOne}.
962 public NewJavaProjectWizardPageOne() {
964 setPageComplete(false);
965 setTitle(NewWizardMessages.NewJavaProjectWizardPageOne_page_title);
966 setDescription(NewWizardMessages.NewJavaProjectWizardPageOne_page_description);
968 fNameGroup= new NameGroup();
969 fLocationGroup= new LocationGroup();
970 fJREGroup= new JREGroup();
971 fLayoutGroup= new LayoutGroup();
972 fWorkingSetGroup= new WorkingSetGroup();
973 fDetectGroup= new DetectGroup();
975 // establish connections
976 fNameGroup.addObserver(fLocationGroup);
977 fDetectGroup.generated_6722163234981482426(this);
979 // initialize all elements
980 fNameGroup.notifyObservers();
982 // create and connect validator
983 fValidator= new Validator();
984 fNameGroup.addObserver(fValidator);
985 fLocationGroup.addObserver(fValidator);
987 // initialize defaults
988 setProjectName(""); //$NON-NLS-1$
989 setProjectLocationURI(null);
990 setWorkingSets(new IWorkingSet[0]);
992 initializeDefaultVM();
996 * The wizard owning this page can call this method to initialize the fields from the
997 * current selection and active part.
999 * @param selection used to initialize the fields
1000 * @param activePart the (typically active) part to initialize the fields or <code>null</code>
1002 public void init(IStructuredSelection selection, IWorkbenchPart activePart) {
1003 setWorkingSets(getSelectedWorkingSet(selection, activePart));
1006 private void initializeDefaultVM() {
1007 JavaRuntime.getDefaultVMInstall();
1011 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
1013 public void createControl(Composite parent) {
1014 initializeDialogUnits(parent);
1016 final Composite composite= new Composite(parent, SWT.NULL);
1017 composite.setFont(parent.getFont());
1018 composite.setLayout(initGridLayout(new GridLayout(1, false), true));
1019 composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
1021 // create UI elements
1022 Control nameControl= createNameControl(composite);
1023 nameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1025 Control locationControl= createLocationControl(composite);
1026 locationControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1028 Control jreControl= createJRESelectionControl(composite);
1029 jreControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1031 Control layoutControl= createProjectLayoutControl(composite);
1032 layoutControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1034 Control workingSetControl= createWorkingSetControl(composite);
1035 workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1037 Control infoControl= createInfoControl(composite);
1038 infoControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1040 setControl(composite);
1044 protected void setControl(Control newControl) {
1045 Dialog.applyDialogFont(newControl);
1047 PlatformUI.getWorkbench().getHelpSystem().setHelp(newControl, IJavaHelpContextIds.NEW_JAVAPROJECT_WIZARD_PAGE);
1049 super.setControl(newControl);
1054 * Creates the controls for the name field.
1056 * @param composite the parent composite
1057 * @return the created control
1059 protected Control createNameControl(Composite composite) {
1060 return fNameGroup.createControl(composite);
1064 * Creates the controls for the location field.
1066 * @param composite the parent composite
1067 * @return the created control
1069 protected Control createLocationControl(Composite composite) {
1070 return fLocationGroup.createControl(composite);
1074 * Creates the controls for the JRE selection
1076 * @param composite the parent composite
1077 * @return the created control
1079 protected Control createJRESelectionControl(Composite composite) {
1080 return fJREGroup.createControl(composite);
1084 * Creates the controls for the project layout selection.
1086 * @param composite the parent composite
1087 * @return the created control
1089 protected Control createProjectLayoutControl(Composite composite) {
1090 return fLayoutGroup.createContent(composite);
1094 * Creates the controls for the working set selection.
1096 * @param composite the parent composite
1097 * @return the created control
1099 protected Control createWorkingSetControl(Composite composite) {
1100 return fWorkingSetGroup.createControl(composite);
1104 * Creates the controls for the info section.
1106 * @param composite the parent composite
1107 * @return the created control
1109 protected Control createInfoControl(Composite composite) {
1110 return fDetectGroup.createControl(composite);
1114 * Gets a project name for the new project.
1116 * @return the new project resource handle
1118 public String getProjectName() {
1119 return fNameGroup.getName();
1123 * Sets the name of the new project
1125 * @param name the new name
1127 public void setProjectName(String name) {
1129 throw new IllegalArgumentException();
1131 fNameGroup.setName(name);
1135 * Returns the current project location path as entered by the user, or <code>null</code>
1136 * if the project should be created in the workspace.
1138 * @return the project location path or its anticipated initial value.
1140 public URI getProjectLocationURI() {
1141 return fLocationGroup.generated_4065803390293803522();
1145 * Sets the project location of the new project or <code>null</code> if the project
1146 * should be created in the workspace
1148 * @param uri the new project location
1150 public void setProjectLocationURI(URI uri) {
1151 IPath path= uri != null ? URIUtil.toPath(uri) : null;
1152 fLocationGroup.setLocation(path);
1156 * Returns the compiler compliance to be used for the project, or <code>null</code> to use the workspace
1157 * compiler compliance.
1159 * @return compiler compliance to be used for the project or <code>null</code>
1161 public String getCompilerCompliance() {
1162 return fJREGroup.getSelectedCompilerCompliance();
1166 * Returns the default class path entries to be added on new projects. By default this is the JRE container as
1167 * selected by the user.
1169 * @return returns the default class path entries
1171 public IClasspathEntry[] getDefaultClasspathEntries() {
1172 IPath newPath= fJREGroup.getJREContainerPath();
1173 if (newPath != null) {
1174 return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) };
1176 return PreferenceConstants.getDefaultJRELibrary();
1180 * Returns the source class path entries to be added on new projects.
1181 * The underlying resources may not exist. All entries that are returned must be of kind
1182 * {@link IClasspathEntry#CPE_SOURCE}.
1184 * @return returns the source class path entries for the new project
1186 public IClasspathEntry[] getSourceClasspathEntries() {
1187 IPath sourceFolderPath= new Path(getProjectName()).makeAbsolute();
1189 if (fLayoutGroup.isSrcBin()) {
1190 IPath srcPath= new Path(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_SRCNAME));
1191 if (srcPath.segmentCount() > 0) {
1192 sourceFolderPath= sourceFolderPath.append(srcPath);
1195 return new IClasspathEntry[] { JavaCore.newSourceEntry(sourceFolderPath) };
1199 * Returns the source class path entries to be added on new projects.
1200 * The underlying resource may not exist.
1202 * @return returns the default class path entries
1204 public IPath getOutputLocation() {
1205 IPath outputLocationPath= new Path(getProjectName()).makeAbsolute();
1206 if (fLayoutGroup.isSrcBin()) {
1207 IPath binPath= new Path(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
1208 if (binPath.segmentCount() > 0) {
1209 outputLocationPath= outputLocationPath.append(binPath);
1212 return outputLocationPath;
1216 * Returns the working sets to which the new project should be added.
1218 * @return the selected working sets to which the new project should be added
1220 public IWorkingSet[] getWorkingSets() {
1221 return fWorkingSetGroup.getSelectedWorkingSets();
1225 * Sets the working sets to which the new project should be added.
1227 * @param workingSets the initial selected working sets
1229 public void setWorkingSets(IWorkingSet[] workingSets) {
1230 if (workingSets == null) {
1231 throw new IllegalArgumentException();
1233 fWorkingSetGroup.setWorkingSets(workingSets);
1237 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
1240 public void setVisible(boolean visible) {
1241 super.setVisible(visible);
1243 fNameGroup.postSetFocus();
1247 private GridLayout initGridLayout(GridLayout layout, boolean margins) {
1248 layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
1249 layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
1251 layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
1252 layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
1254 layout.marginWidth= 0;
1255 layout.marginHeight= 0;
1260 public static final IWorkingSet[] EMPTY_WORKING_SET_ARRAY = new IWorkingSet[0];
1262 private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection, IWorkbenchPart activePart) {
1263 IWorkingSet[] selected= getSelectedWorkingSet(selection);
1264 if (selected != null && selected.length > 0) {
1265 for (int i= 0; i < selected.length; i++) {
1266 if (!isValidWorkingSet(selected[i]))
1267 return EMPTY_WORKING_SET_ARRAY;
1272 if (!(activePart instanceof PackageExplorerPart))
1273 return EMPTY_WORKING_SET_ARRAY;
1275 PackageExplorerPart explorerPart= (PackageExplorerPart) activePart;
1276 return explorerPart.generated_8214304763819303281();
1279 private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection) {
1280 if (!(selection instanceof ITreeSelection))
1281 return EMPTY_WORKING_SET_ARRAY;
1283 ITreeSelection treeSelection= (ITreeSelection) selection;
1284 if (treeSelection.isEmpty())
1285 return EMPTY_WORKING_SET_ARRAY;
1287 List<?> elements= treeSelection.toList();
1288 if (elements.size() == 1) {
1289 Object element= elements.get(0);
1290 TreePath[] paths= treeSelection.getPathsFor(element);
1291 if (paths.length != 1)
1292 return EMPTY_WORKING_SET_ARRAY;
1294 TreePath path= paths[0];
1295 if (path.getSegmentCount() == 0)
1296 return EMPTY_WORKING_SET_ARRAY;
1298 Object candidate= path.getSegment(0);
1299 if (!(candidate instanceof IWorkingSet))
1300 return EMPTY_WORKING_SET_ARRAY;
1302 IWorkingSet workingSetCandidate= (IWorkingSet) candidate;
1303 if (isValidWorkingSet(workingSetCandidate))
1304 return new IWorkingSet[] { workingSetCandidate };
1306 return EMPTY_WORKING_SET_ARRAY;
1309 ArrayList<IWorkingSet> result= new ArrayList<IWorkingSet>();
1310 for (Iterator<?> iterator= elements.iterator(); iterator.hasNext();) {
1311 Object element= iterator.next();
1312 if (element instanceof IWorkingSet && isValidWorkingSet((IWorkingSet) element)) {
1313 result.add((IWorkingSet) element);
1316 return result.toArray(new IWorkingSet[result.size()]);
1320 public void generated_2259057468813127729(JavaProjectWizard javaprojectwizard) {
1321 javaprojectwizard.addPage(this);
1323 if (javaprojectwizard.fSecondPage == null)
1324 javaprojectwizard.fSecondPage= new NewJavaProjectWizardPageTwo(this);
1325 javaprojectwizard.addPage(javaprojectwizard.fSecondPage);
1327 init(javaprojectwizard.getSelection(), javaprojectwizard.getActivePart());
1330 public URI generated_1111648697931151717(NewJavaProjectWizardPageTwo newjavaprojectwizardpagetwo) {
1331 String projectName= getProjectName();
1333 newjavaprojectwizardpagetwo.fCurrProject= ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
1334 newjavaprojectwizardpagetwo.fCurrProjectLocation= getProjectLocationURI();
1336 URI realLocation= NewJavaProjectWizardPageTwo.getRealLocation(projectName, newjavaprojectwizardpagetwo.fCurrProjectLocation);
1337 return realLocation;
1340 public void generated_7636879016446437051(NewJavaProjectWizardPageTwo newjavaprojectwizardpagetwo, IJavaProject javaProject, IProgressMonitor monitor) throws CoreException {
1341 if (monitor == null) {
1342 monitor= new NullProgressMonitor();
1344 monitor.beginTask(NewWizardMessages.NewJavaProjectWizardPageTwo_monitor_init_build_path, 2);
1347 IClasspathEntry[] entries= null;
1348 IPath outputLocation= null;
1349 IProject project= javaProject.getProject();
1351 if (newjavaprojectwizardpagetwo.fKeepContent) {
1352 if (!project.getFile(NewJavaProjectWizardPageTwo.FILENAME_CLASSPATH).exists()) {
1353 final ClassPathDetector detector= new ClassPathDetector(newjavaprojectwizardpagetwo.fCurrProject, new SubProgressMonitor(monitor, 2));
1354 entries= detector.getClasspath();
1355 outputLocation= detector.getOutputLocation();
1356 if (entries.length == 0)
1362 List<IClasspathEntry> cpEntries= new ArrayList<IClasspathEntry>();
1363 IWorkspaceRoot root= project.getWorkspace().getRoot();
1365 IClasspathEntry[] sourceClasspathEntries= getSourceClasspathEntries();
1366 for (int i= 0; i < sourceClasspathEntries.length; i++) {
1367 IPath path= sourceClasspathEntries[i].getPath();
1368 if (path.segmentCount() > 1) {
1369 IFolder folder= root.getFolder(path);
1370 CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
1372 cpEntries.add(sourceClasspathEntries[i]);
1375 cpEntries.addAll(Arrays.asList(getDefaultClasspathEntries()));
1377 entries= cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
1379 outputLocation= getOutputLocation();
1380 if (outputLocation.segmentCount() > 1) {
1381 IFolder folder= root.getFolder(outputLocation);
1382 CoreUtility.createDerivedFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
1385 if (monitor.isCanceled()) {
1386 throw new OperationCanceledException();
1389 newjavaprojectwizardpagetwo.init(javaProject, outputLocation, entries, false);
1395 public static boolean isValidWorkingSet(IWorkingSet workingSet) {
1396 String id= workingSet.getId();
1397 if (!IWorkingSetIDs.JAVA.equals(id) && !IWorkingSetIDs.RESOURCE.equals(id))
1400 if (workingSet.isAggregateWorkingSet())