Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 itemis AG (http://www.itemis.eu) 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 /
  
  package org.eclipse.xtext.ui.util;
  
 import static org.eclipse.xtext.ui.util.JREContainerProvider.*;
 
 import java.util.List;
 
 import  org.eclipse.core.resources.IFolder;
 import  org.eclipse.core.resources.IProject;
 import  org.eclipse.core.runtime.CoreException;
 import  org.eclipse.core.runtime.IPath;
 import  org.eclipse.core.runtime.Path;
 import  org.eclipse.core.runtime.SubMonitor;
 import  org.eclipse.jdt.core.IClasspathEntry;
 import  org.eclipse.jdt.core.IJavaProject;
 import  org.eclipse.jdt.core.JavaCore;
 import  org.eclipse.jdt.core.JavaModelException;
 import  org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
 import  org.eclipse.jdt.launching.JavaRuntime;
 import  org.eclipse.swt.widgets.Shell;
 import  org.eclipse.ui.IWorkingSet;

Author(s):
Sebastian Zarnekow - Initial contribution and API
 
 public class JavaProjectFactory extends ProjectFactory {
 
 	private static final Logger logger = Logger.getLogger(JavaProjectFactory.class);
 
 	protected void enhanceProject(IProject project, SubMonitor monitor, Shell shellthrows CoreException {
 		super.enhanceProject(projectmonitorshell);
 		if (.contains(JavaCore.BUILDER_ID)) {
 			SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
 			try {
 				IJavaProject javaProject = JavaCore.create(project);
 				List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
 				for (final IProject referencedProject : project.getReferencingProjects()) {
 					final IClasspathEntry referencedProjectClasspathEntry = JavaCore.newProjectEntry(referencedProject
 							.getFullPath());
 					classpathEntries.add(referencedProjectClasspathEntry);
 				}
 				for (final String folderName : ) {
 					final IFolder sourceFolder = project.getFolder(folderName);
 					final IClasspathEntry srcClasspathEntry = JavaCore.newSourceEntry(sourceFolder.getFullPath());
 					classpathEntries.add(srcClasspathEntry);
 				}
 
 				IClasspathEntry defaultJREContainerEntry = getDefaultJREContainerEntry();
 				classpathEntries.add(defaultJREContainerEntry);
 				addMoreClasspathEntriesTo(classpathEntries);
 				
 				javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]),
 						subMonitor.newChild(1));
 				javaProject.setOutputLocation(new Path("/" + project.getName() + "/bin"), subMonitor.newChild(1)); //$NON-NLS-1$ //$NON-NLS-2$
 				
 				String executionEnvironmentId = JavaRuntime.getExecutionEnvironmentId(defaultJREContainerEntry.getPath());
 				if (executionEnvironmentId != null) {
 					BuildPathSupport.setEEComplianceOptions(javaProjectexecutionEnvironmentIdnull);
 				}
 			} catch (JavaModelException e) {
 				.error(e.getMessage(), e);
 			}
 		}
 	}
 
 	protected void addMoreClasspathEntriesTo(List<IClasspathEntry> classpathEntries) {
 	}
 
 	public JavaProjectFactory addBuilderIds(String... builderIds) {
 		return (JavaProjectFactorysuper.addBuilderIds(builderIds);
 	}
 
 	public JavaProjectFactory addFolders(List<Stringfolders) {
 		return (JavaProjectFactorysuper.addFolders(folders);
 	}
 
 	public JavaProjectFactory setProjectName(String projectName) {
 		return (JavaProjectFactorysuper.setProjectName(projectName);
 	}
 
 	public JavaProjectFactory addProjectNatures(String... projectNatures) {
 		return (JavaProjectFactorysuper.addProjectNatures(projectNatures);
 	}
 
	public JavaProjectFactory addReferencedProjects(List<IProject> referencedProjects) {
		return (JavaProjectFactorysuper.addReferencedProjects(referencedProjects);
	}
	public JavaProjectFactory setLocation(IPath location) {
		return (JavaProjectFactorysuper.setLocation(location);
	}
	public JavaProjectFactory addWorkingSets(List<IWorkingSet> workingSets) {
		return (JavaProjectFactorysuper.addWorkingSets(workingSets);
	}
New to GrepCode? Check out our FAQ X