### Eclipse Workspace Patch 1.0
#P org.eclipse.ide4edu.javalite.ui
Index: src/org/eclipse/ide4edu/javalite/ui/view/OpenNewLiteClassWizardAction.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ide4edu/javalite/plugins/org.eclipse.ide4edu.javalite.ui/src/org/eclipse/ide4edu/javalite/ui/view/OpenNewLiteClassWizardAction.java,v
retrieving revision 1.1
diff -u -r1.1 OpenNewLiteClassWizardAction.java
--- src/org/eclipse/ide4edu/javalite/ui/view/OpenNewLiteClassWizardAction.java 4 Sep 2009 19:57:23 -0000 1.1
+++ src/org/eclipse/ide4edu/javalite/ui/view/OpenNewLiteClassWizardAction.java 9 Oct 2009 21:54:15 -0000
@@ -1,87 +1,101 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Eclipse Foundation - Modified from org.eclipse.jdt.ui.actions.OpenNewClassWizardAction
- *******************************************************************************/
-package org.eclipse.ide4edu.javalite.ui.view;
-
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.internal.ui.JavaPluginImages;
-import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
-import org.eclipse.jdt.ui.actions.AbstractOpenWizardAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.INewWizard;
-
-public class OpenNewLiteClassWizardAction extends AbstractOpenWizardAction {
-
- private NewLiteClassWizardPage fPage;
- private boolean fOpenEditorOnFinish;
-
- /**
- * Creates an instance of the OpenNewClassWizardAction
.
- */
- public OpenNewLiteClassWizardAction() {
- setText("New Java Class");
- setDescription("Create a new Java class.");
- setToolTipText("New Java Class");
- //setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWCLASS);
- setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWCLASS);
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
-
- fPage= new NewLiteClassWizardPage();
- fOpenEditorOnFinish= true;
- }
-
- /**
- * Sets a page to be used by the wizard or null
to use a page initialized with values
- * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
- * @param page the page to use or null
- */
- public void setConfiguredWizardPage(NewLiteClassWizardPage page) {
- fPage= page;
- }
-
- /**
- * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open
- * an editor.
- *
- * @param openEditorOnFinish if set, the wizard will open the created type with the default editor
- *
- * @since 3.3
- */
- public void setOpenEditorOnFinish(boolean openEditorOnFinish) {
- fOpenEditorOnFinish= openEditorOnFinish;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard()
- */
- protected final INewWizard createWizard() throws CoreException {
- return new NewLiteClassCreationWizard(fPage, fOpenEditorOnFinish);
- }
-
- protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell shell) {
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- if (workspaceRoot.getProjects().length == 0) {
- String title= NewWizardMessages.AbstractOpenWizardAction_noproject_title;
- String message= NewWizardMessages.AbstractOpenWizardAction_noproject_message;
- if (MessageDialog.openQuestion(shell, title, message)) {
- new OpenNewLiteJavaProjectWizardAction().run();
- return workspaceRoot.getProjects().length != 0;
- }
- return false;
- }
- return true;
- }
-}
-
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Eclipse Foundation - Modified from org.eclipse.jdt.ui.actions.OpenNewClassWizardAction
+ *******************************************************************************/
+package org.eclipse.ide4edu.javalite.ui.view;
+
+import java.net.URI;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jdt.ui.actions.AbstractOpenWizardAction;
+import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.INewWizard;
+
+public class OpenNewLiteClassWizardAction extends AbstractOpenWizardAction {
+
+ private NewLiteClassWizardPage fPage;
+ private boolean fOpenEditorOnFinish;
+
+ /**
+ * Creates an instance of the OpenNewClassWizardAction
.
+ */
+ public OpenNewLiteClassWizardAction() {
+ setText("New Java Class");
+ setDescription("Create a new Java class.");
+ setToolTipText("New Java Class");
+ //setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWCLASS);
+ setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWCLASS);
+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
+
+ fPage= new NewLiteClassWizardPage();
+ fOpenEditorOnFinish= true;
+ }
+
+ /**
+ * Sets a page to be used by the wizard or null
to use a page initialized with values
+ * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
+ * @param page the page to use or null
+ */
+ public void setConfiguredWizardPage(NewLiteClassWizardPage page) {
+ fPage= page;
+ }
+
+ /**
+ * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open
+ * an editor.
+ *
+ * @param openEditorOnFinish if set, the wizard will open the created type with the default editor
+ *
+ * @since 3.3
+ */
+ public void setOpenEditorOnFinish(boolean openEditorOnFinish) {
+ fOpenEditorOnFinish= openEditorOnFinish;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard()
+ */
+ protected final INewWizard createWizard() throws CoreException {
+ return new NewLiteClassCreationWizard(fPage, fOpenEditorOnFinish);
+ }
+
+ protected boolean doCreateProjectFirstOnEmptyWorkspace(Shell shell) {
+ IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
+ if (workspaceRoot.getProjects().length == 0) {
+
+ // Create the default assignment project
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("MyAssignment");
+ URI locationURI = null;
+ IProgressMonitor monitor = new NullProgressMonitor();
+ try {
+ JavaCapabilityConfigurationPage.createProject(project, locationURI, monitor);
+ JavaCapabilityConfigurationPage jcc = new JavaCapabilityConfigurationPage();
+ IJavaProject jProject = JavaCore.create(project);
+ jcc.init(jProject, null, null, false);
+ jcc.configureJavaProject(null);
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+ return true;
+ }
+}
+