/**
 *  Copyright (c) 2015-2017 Angelo ZERR.
 *  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:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */
package ts.eclipse.ide.angular2.internal.cli.wizards;

import java.util.ArrayList;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;

import ts.eclipse.ide.angular2.cli.AngularCLIPlugin;
import ts.eclipse.ide.angular2.internal.cli.AngularCLIMessages;
import ts.eclipse.ide.ui.wizards.AbstractWizardNewTypeScriptProjectCreationPage;

/**
 * Main wizard page to create an Angular2 project.
 *
 */
public class WizardNewNgProjectCreationPage extends AbstractWizardNewTypeScriptProjectCreationPage {

	public static final String projectNameRegexp = "^[a-zA-Z][.0-9a-zA-Z]*(-[.0-9a-zA-Z]*)*$";
	public static final String[] unsupportedProjectNames = new String[] { "test", "ember", "ember-cli", "vendor",
			"app" };

	public WizardNewNgProjectCreationPage(String pageName, BasicNewResourceWizard wizard) {
		super(pageName, wizard);
	}

	@Override
	protected ArrayList<IStatus> validatePageImpl() {
		ArrayList<IStatus> status = super.validatePageImpl();
		if (status == null)
			status = new ArrayList<>();
		status.add(validateNgProjectName(getProjectName()));
		return status;
	}

	private IStatus validateNgProjectName(String name) {
		IStatus status = Status.OK_STATUS;
		for (int i = 0, cnt = unsupportedProjectNames.length; i < cnt; i++) {
			if (unsupportedProjectNames[i].equals(name)) {
				status = new Status(IStatus.WARNING, AngularCLIPlugin.PLUGIN_ID,
						NLS.bind(AngularCLIMessages.NewAngular2ProjectWizard_unsupportedProjectNames, name));
				break;
			}
		}
		if (status.isOK()) {
			String[] parts = name.split("-");
			for (int i = 0, cnt = parts.length; i < cnt; i++) {
				if (!parts[i].matches(projectNameRegexp)) {
					status = new Status(IStatus.WARNING, AngularCLIPlugin.PLUGIN_ID,
							NLS.bind(AngularCLIMessages.NewAngular2ProjectWizard_invalidProjectName, name));
					break;
				}
			}
		}
		return status;
	}

}

@@ -457,39 +457,8 @@
 %0D%0A%0D%0A
-import java.util.ArrayList;%0D%0A%0D%0A
 impo
@@ -755,24 +755,68 @@
 IMessages;%0D%0A
+import ts.eclipse.ide.ui.utils.StatusUtil;%0D%0A
 import ts.ec
@@ -1224,25 +1224,31 @@
 %5B%5D %7B
- 
+%0D%0A%09%09
 %22test%22,
- 
+%0D%0A%09%09
 %22ember%22,
  %22em
@@ -1243,17 +1243,20 @@
 %22ember%22,
- 
+%0D%0A%09%09
 %22ember-c
@@ -1259,17 +1259,20 @@
 er-cli%22,
- 
+%0D%0A%09%09
 %22vendor%22
@@ -1280,15 +1280,16 @@
 %0D%0A%09%09
-%09
 %22app%22
- 
+%0D%0A%09
 %7D;%0D%0A
@@ -1437,34 +1437,23 @@
 otected 
-ArrayList%3C
 IStatus
-%3E
  validat
@@ -1473,196 +1473,169 @@
 %0D%0A%09%09
-ArrayList%3CIStatus%3E status = super.validatePageImpl();%0D%0A%09%09if (status == null)%0D%0A%09%09%09status = new ArrayList%3C%3E();%0D%0A%09%09status.add(validateNgProjectName(getProjectName()));%0D%0A%09%09return status;%0D%0A%09%7D%0D%0A
+return StatusUtil.getMoreSevere(super.validatePageImpl(), validateNgProjectName(getProjectName()));%0D%0A%09%7D%0D%0A%0D%0A%09/** Validates the name of the Angular-CLI Project. */
 %0D%0A%09p

Update Angular2 Project wizard to match changes in typescript.java. See Springrbua/typescript.java@aaa93b0e61e7711a967a00d78a4c585592e4f329