blob: 37088ce55529c6bdc5916d46cd33cb0699385709 [file] [log] [blame]
/*******************************************************************************
* <copyright>
*
* Copyright (c) 2013, 2013 SAP AG.
* 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:
* SAP AG - initial API, implementation and documentation
*
* </copyright>
*
*******************************************************************************/
package org.eclipse.fmc.blockdiagram.editor.wizards;
import org.eclipse.core.resources.IContainer;
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;
/**
*
* @author Benjamin Schmeling
*
*/
public class FMCWizardUtils {
public static IContainer createProjectIfNecessary() throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if (root.getProjects().length == 0) {
IProgressMonitor progressMonitor = new NullProgressMonitor();
root.getProjects();
final String PROJECT_NAME = "FMCProject";
IProject project = root.getProject(PROJECT_NAME);
project.create(progressMonitor);
project.open(progressMonitor);
return project;
} else if (root.getProjects().length == 1) {
return root.getProjects()[0];
}
return null;
}
}