org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock Java Examples

The following examples show how to use org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock. 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: JavaProjectUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
   * Creates a Java project with the specified name and raw classpath.
   *
   * @param projectName
   * @param rawClasspaths
   * @return a new project
   * @throws CoreException
   */
  private static IJavaProject createProject(String projectName,
      IClasspathEntry[] rawClasspaths) throws CoreException {
    IProject project = ProjectUtilities.createProject(projectName);
    NullProgressMonitor monitor = new NullProgressMonitor();
    BuildPathsBlock.addJavaNature(project, monitor);

    IJavaProject javaProject = JavaCore.create(project);
    javaProject.setRawClasspath(rawClasspaths, monitor);
    javaProject.open(monitor);

    /*
     * Should only need a single waitForIdle() call, even though we make 3
     * separate calls to asynchronous JDT methods above. The reason is that each
     * operation creates a Java workspace job with the same scheduling rule, so
     * they should end up running in FIFO order, meaning that each operation
     * will have its prerequisites met before it begins execution.
     */
    // Removing this wait significantly speeds up test execution time, because the Java
    // indexing jobs for the GWT_ROOT-imported projects can take over 5 minutes to complete.
    // This seems to run with no flakiness, but if flakiness continues, try figuring out
    // if there is a Job family for the classpath modify operations that can be waited on instead.
//    JobsUtilities.waitForIdle();

    return javaProject;
  }
 
Example #2
Source File: WebAppProjectCreator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
protected IProject createProject(IProgressMonitor monitor) throws CoreException {
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IProject project = workspaceRoot.getProject(projectName);
  if (!project.exists()) {
    URI uri;
    if (isWorkspaceRootLocationURI(locationURI)) {
      // If you want to put a project in the workspace root then the location
      // needs to be null...
      uri = null;
    } else {
      // Non-default paths need to include the project name
      IPath path = URIUtil.toPath(locationURI).append(projectName);
      uri = URIUtil.toURI(path);
    }

    BuildPathsBlock.createProject(project, uri, monitor);
  }
  return project;
}
 
Example #3
Source File: NewJavaProjectWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a Java project wizard creation page.
 * <p>
 * The Java project wizard reads project name and location from the main page.
 * </p>
 *
 * @param root the workspace root
 * @param mainpage the main page of the wizard
 */
public NewJavaProjectWizardPage(IWorkspaceRoot root, WizardNewProjectCreationPage mainpage) {
	super(PAGE_NAME);

	setTitle(NewWizardMessages.NewJavaProjectWizardPage_title);
	setDescription(NewWizardMessages.NewJavaProjectWizardPage_description);

	fMainPage= mainpage;
	IStatusChangeListener listener= new IStatusChangeListener() {
		public void statusChanged(IStatus status) {
			updateStatus(status);
		}
	};

	fBuildPathsBlock= new BuildPathsBlock(new BusyIndicatorRunnableContext(), listener, 0, false, null);

	fProjectModified= true;
	fOutputLocation= null;
	fClasspathEntries= null;
}
 
Example #4
Source File: JavaProjectTestUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a Java project with the specified name and raw classpath.
 * 
 * @param projectName
 * @param rawClasspaths
 * @return a new project
 * @throws CoreException
 */
public static IJavaProject createProject(String projectName,
    IClasspathEntry[] rawClasspaths) throws CoreException {
  IProject project = ProjectTestUtilities.createProject(projectName);
  NullProgressMonitor monitor = new NullProgressMonitor();
  BuildPathsBlock.addJavaNature(project, monitor);

  IJavaProject javaProject = JavaCore.create(project);
  javaProject.setRawClasspath(rawClasspaths, monitor);
  javaProject.open(monitor);

  return javaProject;
}
 
Example #5
Source File: ProjectTestUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a project with the specified name in the workspace.
 * 
 * @param projectName
 * @return new project
 * @throws CoreException
 */
public static IProject createProject(String projectName) throws CoreException {
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IProject project = workspaceRoot.getProject(projectName);
  if (project.exists()) {
    throw new IllegalStateException("Project " + projectName
        + " already exists in this workspace");
  }

  IProgressMonitor monitor = new NullProgressMonitor();
  BuildPathsBlock.createProject(project, project.getLocationURI(), monitor);
  return project;
}
 
Example #6
Source File: ProjectUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a project with the specified name in the workspace.
 *
 * @param projectName
 * @return new project
 * @throws CoreException
 */
public static IProject createProject(String projectName) throws CoreException {
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IProject project = workspaceRoot.getProject(projectName);
  if (project.exists()) {
    throw new IllegalStateException("Project " + projectName
        + " already exists in this workspace");
  }

  IProgressMonitor monitor = new NullProgressMonitor();
  BuildPathsBlock.createProject(project, project.getLocationURI(), monitor);
  return project;
}
 
Example #7
Source File: NewSourceContainerWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
   * Constructor of the <code>NewSourceContainerWorkbookPage</code> which consists of
   * a tree representing the project, a toolbar with the available actions, an area
   * containing hyperlinks that perform the same actions as those in the toolbar but
   * additionally with some short description.
   *
   * @param classPathList
   * @param outputLocationField
   * @param context a runnable context, can be <code>null</code>
   * @param buildPathsBlock
   */
  public NewSourceContainerWorkbookPage(ListDialogField<CPListElement> classPathList, StringDialogField outputLocationField, IRunnableContext context, BuildPathsBlock buildPathsBlock) {
      fClassPathList= classPathList;
fOutputLocationField= outputLocationField;
fContext= context;
fBuildPathsBlock= buildPathsBlock;

      fUseFolderOutputs= new SelectionButtonDialogField(SWT.CHECK);
      fUseFolderOutputs.setSelection(false);
      fUseFolderOutputs.setLabelText(NewWizardMessages.SourceContainerWorkbookPage_folders_check);

fPackageExplorer= new DialogPackageExplorer();
fHintTextGroup= new HintTextGroup();
   }
 
Example #8
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 #9
Source File: LoggedCreateTargetQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void createJavaProject(IProject project) throws CoreException {
	if (!project.exists()) {
		BuildPathsBlock.createProject(project, null, new NullProgressMonitor());
		BuildPathsBlock.addJavaNature(project, new NullProgressMonitor());
	}
}
 
Example #10
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 #11
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);
}
 
Example #12
Source File: JavaCapabilityConfigurationPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Helper method to create and open a IProject. The project location
 * is configured. No natures are added.
 *
 * @param project The handle of the project to create.
 * @param locationURI The location of the project or <code>null</code> to create the project in the workspace
 * @param monitor a progress monitor to report progress or <code>null</code> if
 *  progress reporting is not desired
 * @throws CoreException if the project couldn't be created
 * @see org.eclipse.core.resources.IProjectDescription#setLocationURI(java.net.URI)
 * @since 3.2
 */
public static void createProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException {
	BuildPathsBlock.createProject(project, locationURI, monitor);
}