| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.wizard.ui.feature; |
| |
| import java.lang.reflect.InvocationTargetException; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.core.runtime.IPath; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.osbp.wizard.ui.basic.AbstractNonPluginProjectCreator; |
| import org.eclipse.osbp.wizard.ui.basic.BasicProjectFactory; |
| import org.eclipse.osbp.wizard.ui.basic.BasicProjectInfo; |
| import org.eclipse.xtext.ui.util.PluginProjectFactory; |
| import org.eclipse.xtext.ui.util.ProjectFactory; |
| import org.eclipse.xtext.ui.wizard.IProjectInfo; |
| |
| /** |
| * Creator for a new Application Project. |
| */ |
| public class FeatureProjectCreator extends AbstractNonPluginProjectCreator { |
| |
| /** |
| * Execute one model project for each existing project post fixes. |
| * |
| * @param projectInfo |
| * the project info |
| * @param monitor |
| * the monitor |
| * @throws InvocationTargetException |
| * the invocation target exception |
| * @throws CoreException |
| * the core exception |
| * @throws InterruptedException |
| * the interrupted exception |
| */ |
| public static void execute(BasicProjectInfo projectInfo, IProgressMonitor monitor) throws InvocationTargetException, CoreException, InterruptedException { |
| // generate a new application project |
| projectInfo.useForFeatureFactory(); |
| FeatureProjectCreator instance = new FeatureProjectCreator(projectInfo); |
| instance.execute(monitor); |
| // return to the product project factory |
| projectInfo.useForProductFactory(); |
| } |
| |
| /** |
| * Instantiates a new aggregator project creator. |
| * |
| * @param projectInfo |
| * the project info |
| */ |
| private FeatureProjectCreator(BasicProjectInfo projectInfo) { |
| super(); |
| super.setProjectInfo(projectInfo); |
| } |
| |
| @Override |
| protected BasicProjectInfo getProjectInfo() { |
| return (BasicProjectInfo) super.getProjectInfo(); |
| } |
| |
| /** |
| * Do not use this method! |
| */ |
| @Deprecated |
| @Override |
| public void setProjectInfo(IProjectInfo projectInfo) { |
| System.err.println(); |
| } |
| |
| @Override |
| protected ProjectFactory configureProjectFactory(ProjectFactory factory) { |
| // ----------- !!!!DONĀ“T MOVE THIS!!!! -------------- |
| // This path manipulation is mandatory to put the product plugin project as subfolder of the aggregator. |
| // The setting of this new location path to projectInfo has to be before the call of super.configureProjectFactory(factory). |
| IPath path = Platform.getLocation().append(getProjectInfo().getBasicProjectName()).append(getProjectInfo().getProjectName()); |
| getProjectInfo().setLocationPath(path.makeAbsolute()); |
| // --------------------------------------------------- |
| ProjectFactory result = super.configureProjectFactory(factory); |
| ((BasicProjectFactory) result).configureFrom(getProjectInfo()); |
| ((BasicProjectFactory) result).setRule(getRule()); |
| return result; |
| } |
| |
| /** |
| * @return a specific model project factory |
| */ |
| @Override |
| protected PluginProjectFactory createProjectFactory() { |
| return new FeatureProjectFactory(); // super.createProjectFactory(); |
| } |
| |
| @Override |
| protected String getEncoding() throws CoreException { |
| return super.getEncoding(); |
| } |
| |
| /** |
| * Enhance the model project and display the progress on the monitor. |
| * |
| * @param project |
| * @param monitor |
| */ |
| @Override |
| protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException { |
| enhanceProject(project, monitor, "feature"); |
| } |
| |
| } |