Lines 11-23
Link Here
|
11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
12 |
package org.eclipse.ide4edu.javalite.ui.view; |
12 |
package org.eclipse.ide4edu.javalite.ui.view; |
13 |
|
13 |
|
|
|
14 |
import java.net.URI; |
15 |
|
16 |
import org.eclipse.core.resources.IProject; |
14 |
import org.eclipse.core.resources.IWorkspaceRoot; |
17 |
import org.eclipse.core.resources.IWorkspaceRoot; |
15 |
import org.eclipse.core.resources.ResourcesPlugin; |
18 |
import org.eclipse.core.resources.ResourcesPlugin; |
16 |
import org.eclipse.core.runtime.CoreException; |
19 |
import org.eclipse.core.runtime.CoreException; |
|
|
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
21 |
import org.eclipse.core.runtime.NullProgressMonitor; |
22 |
import org.eclipse.jdt.core.IJavaProject; |
23 |
import org.eclipse.jdt.core.JavaCore; |
17 |
import org.eclipse.jdt.internal.ui.JavaPluginImages; |
24 |
import org.eclipse.jdt.internal.ui.JavaPluginImages; |
18 |
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; |
25 |
import org.eclipse.jdt.ui.PreferenceConstants; |
19 |
import org.eclipse.jdt.ui.actions.AbstractOpenWizardAction; |
26 |
import org.eclipse.jdt.ui.actions.AbstractOpenWizardAction; |
20 |
import org.eclipse.jface.dialogs.MessageDialog; |
27 |
import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage; |
21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
28 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 |
import org.eclipse.swt.widgets.Shell; |
29 |
import org.eclipse.swt.widgets.Shell; |
23 |
import org.eclipse.ui.INewWizard; |
30 |
import org.eclipse.ui.INewWizard; |
Lines 38-44
Link Here
|
38 |
setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWCLASS); |
45 |
setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWCLASS); |
39 |
//PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION); |
46 |
//PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION); |
40 |
|
47 |
|
41 |
fPage= new NewLiteClassWizardPage(); |
48 |
fPage= new NewLiteClassWizardPage(null); |
42 |
fOpenEditorOnFinish= true; |
49 |
fOpenEditorOnFinish= true; |
43 |
} |
50 |
} |
44 |
|
51 |
|
Lines 67-85
Link Here
|
67 |
* @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard() |
74 |
* @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard() |
68 |
*/ |
75 |
*/ |
69 |
protected final INewWizard createWizard() throws CoreException { |
76 |
protected final INewWizard createWizard() throws CoreException { |
70 |
return new NewLiteClassCreationWizard(fPage, fOpenEditorOnFinish); |
77 |
// If there is more then one project in the workspace and none is |
|
|
78 |
// selected, show the project chooser. |
79 |
boolean openProjectChooser = false; |
80 |
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
81 |
if (workspaceRoot.getProjects().length >= 2 && getSelection().size() == 0) { |
82 |
openProjectChooser = true; |
83 |
} |
84 |
return new NewLiteClassCreationWizard(fPage, openProjectChooser, fOpenEditorOnFinish); |
71 |
} |
85 |
} |
72 |
|
86 |
|
73 |
protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell shell) { |
87 |
protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell shell) { |
74 |
IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); |
88 |
IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); |
75 |
if (workspaceRoot.getProjects().length == 0) { |
89 |
if (workspaceRoot.getProjects().length == 0) { |
76 |
String title= NewWizardMessages.AbstractOpenWizardAction_noproject_title; |
90 |
|
77 |
String message= NewWizardMessages.AbstractOpenWizardAction_noproject_message; |
91 |
// Set the preferences to not create src and bin folders when we |
78 |
if (MessageDialog.openQuestion(shell, title, message)) { |
92 |
// automatically create a new project. |
79 |
new OpenNewLiteJavaProjectWizardAction().run(); |
93 |
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ, false); |
80 |
return workspaceRoot.getProjects().length != 0; |
94 |
|
|
|
95 |
// Create the default assignment project |
96 |
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("MyAssignment"); |
97 |
URI locationURI = null; |
98 |
IProgressMonitor monitor = new NullProgressMonitor(); |
99 |
try { |
100 |
JavaCapabilityConfigurationPage.createProject(project, locationURI, monitor); |
101 |
JavaCapabilityConfigurationPage jcc = new JavaCapabilityConfigurationPage(); |
102 |
IJavaProject jProject = JavaCore.create(project); |
103 |
jcc.init(jProject, null, null, false); |
104 |
jcc.configureJavaProject(null); |
105 |
} catch (Exception e) { |
106 |
return false; |
81 |
} |
107 |
} |
82 |
return false; |
108 |
return true; |
83 |
} |
109 |
} |
84 |
return true; |
110 |
return true; |
85 |
} |
111 |
} |