Java Code Examples for org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock#flush()

The following examples show how to use org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock#flush() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SARLProjectConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Configure the source folders for a SARL project.
 *
 *
 * @param project the project.
 * @param createFolders indicates if the folders must be created or not.
 * @param monitor the monitor.
 * @since 0.8
 * @see #addSarlNatures(IProject, IProgressMonitor)
 * @see #configureSARLProject(IProject, boolean, boolean, boolean, IProgressMonitor)
 */
public static void configureSARLSourceFolders(IProject project, boolean createFolders, IProgressMonitor monitor) {
	try {
		final SubMonitor subMonitor = SubMonitor.convert(monitor, 8);

		final OutParameter<IFolder[]> sourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testSourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> generationFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testGenerationFolders = new OutParameter<>();
		final OutParameter<IFolder> testOutputFolder = new OutParameter<>();
		ensureSourceFolders(project, createFolders, subMonitor,
				sourceFolders, testSourceFolders,
				generationFolders, testGenerationFolders,
				null,
				null,
				null,
				testOutputFolder);

		final IJavaProject javaProject = JavaCore.create(project);
		subMonitor.worked(1);

		// Build path
		BuildPathsBlock.flush(
				buildClassPathEntries(javaProject,
						sourceFolders.get(),
						testSourceFolders.get(),
						generationFolders.get(),
						testGenerationFolders.get(),
						testOutputFolder.get().getFullPath(),
						true, false),
				javaProject.getOutputLocation(), javaProject, null, subMonitor.newChild(1));

		subMonitor.done();
	} catch (CoreException exception) {
		SARLEclipsePlugin.getDefault().log(exception);
	}
}
 
Example 2
Source File: SARLProjectConfigurator.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Configure the SARL project.
 *
 * <p>This function does the following:<ul>
 * <li>Add the SARL nature to the project;</li>
 * <li>Create the standard SARL folders if {@code createFolders} is evaluated to true;</li>
 * <li>Set the output configuration of the project from the
 * {@link SARLPreferences#setSpecificSARLConfigurationFor(IProject, IPath) general SARL configuration};</li>
 * <li>Reset the Java configuration in order to follow the SARL configuration, if {@code configureJabvaNature}
 * is evaluated to true.</li>
 * </ul>
 *
 * @param project the project.
 * @param addNatures indicates if the natures must be added to the project by calling {@link #addSarlNatures(IProject, IProgressMonitor)}.
 * @param configureJavaNature indicates if the Java configuration elements must be configured.
 * @param createFolders indicates if the folders must be created or not.
 * @param monitor the monitor.
 * @see #addSarlNatures(IProject, IProgressMonitor)
 * @see #configureSARLSourceFolders(IProject, boolean, IProgressMonitor)
 */
public static void configureSARLProject(IProject project, boolean addNatures,
		boolean configureJavaNature, boolean createFolders, IProgressMonitor monitor) {
	try {
		final SubMonitor subMonitor = SubMonitor.convert(monitor, 11);
		// Add Natures
		final IStatus status = Status.OK_STATUS;
		if (addNatures) {
			addSarlNatures(project, subMonitor.newChild(1));
			if (status != null && !status.isOK()) {
				SARLEclipsePlugin.getDefault().getLog().log(status);
			}
		}

		// Ensure SARL specific folders.
		final OutParameter<IFolder[]> sourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testSourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> generationFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testGenerationFolders = new OutParameter<>();
		final OutParameter<IFolder> generationFolder = new OutParameter<>();
		final OutParameter<IFolder> testGenerationFolder = new OutParameter<>();
		final OutParameter<IFolder> outputFolder = new OutParameter<>();
		final OutParameter<IFolder> testOutputFolder = new OutParameter<>();
		ensureSourceFolders(project, createFolders, subMonitor,
				sourceFolders, testSourceFolders,
				generationFolders, testGenerationFolders,
				generationFolder, testGenerationFolder,
				outputFolder, testOutputFolder);

		// SARL specific configuration
		final IFolder testGenerationFolderFolder = testGenerationFolder.get();
		final IPath testGenerationFolderPath = testGenerationFolderFolder == null ? null
				: testGenerationFolderFolder.getProjectRelativePath();
		SARLPreferences.setSpecificSARLConfigurationFor(project,
				generationFolder.get().getProjectRelativePath(),
				testGenerationFolderPath);
		subMonitor.worked(1);

		// Create the Java project
		if (configureJavaNature) {

			if (!addNatures) {
				addNatures(project, subMonitor.newChild(1), JavaCore.NATURE_ID);
			}

			final IJavaProject javaProject = JavaCore.create(project);
			subMonitor.worked(1);

			// Build path
			BuildPathsBlock.flush(
					buildClassPathEntries(javaProject,
							sourceFolders.get(),
							testSourceFolders.get(),
							generationFolders.get(),
							testGenerationFolders.get(),
							testOutputFolder.get().getFullPath(),
							false, true),
					outputFolder.get().getFullPath(), javaProject, null, subMonitor.newChild(1));
		}
		subMonitor.done();
	} catch (CoreException exception) {
		SARLEclipsePlugin.getDefault().log(exception);
	}
}
 
Example 3
Source File: ProjectClasspathFactory.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void flushBuildPath(final Repository repository, final IProgressMonitor monitor) throws CoreException, JavaModelException {
    final IJavaProject javaProject = asJavaProject(repository);
    BuildPathsBlock.flush(Arrays.asList(CPListElement.createFromExisting(javaProject)), javaProject.getOutputLocation(), javaProject, null, monitor);
}