Interface ProjectConfigurator


public interface ProjectConfigurator
This interface contains a set of methods that allow to configure an existing or future project, for example to add and configure natures when creating a new project.

It is typically used as:

  • a filter to check whether the current ProjectConfigurator can apply
  • a bean to store user configuration while showing wizard page

Project configurators can be contributed via the org.eclipse.ui.ide.projectConfigurators extension point. The lifecycle of project configurators is not specified, so implementing classes must be stateless (i.e. their methods cannot keep any state inside or outside this class). The framework may create multiple instances of those classes for a single import session, or it may reuse the same instances for multiple sessions.

Since:
3.12
  • Method Details

    • findConfigurableLocations

      Set<File> findConfigurableLocations(File root, IProgressMonitor monitor)
      From a given File, detects which directories can/should be imported as projects into the workspace and configured by this configurator. This first set of directories is then presented to the user as import proposals.

      This method must be stateless.

      Parameters:
      root - the root directory on which to start the discovery
      monitor - the progress monitor
      Returns:
      the children (at any depth) that this configurator suggests to import as project
    • removeDirtyDirectories

      default void removeDirtyDirectories(Map<File,List<ProjectConfigurator>> proposals)
      Removes from the set of directories those that should not be proposed to the user for import. Those are typically dirty volatile directories such as build output directories.

      This method must be stateless.

      Parameters:
      proposals - the existing import proposals (key is file and value is the list of configurators that have identified the key as a location they can configure for import). Those can be modified and current method is expected to remove some entries from this map.
    • shouldBeAnEclipseProject

      boolean shouldBeAnEclipseProject(IContainer container, IProgressMonitor monitor)
      Tells whether this configurator thinks that a given IContainer should be also imported as a project into the workspace.

      This method must be stateless (ideally static) and cannot rely on any class state.

      Parameters:
      container - the container to analyze
      monitor - the progress monitor
      Returns:
      true if the given folder is for sure to be considered as a project
    • getFoldersToIgnore

      Set<IFolder> getFoldersToIgnore(IProject project, IProgressMonitor monitor)
      Returns the folders to exclude from the analysis that happens on an IProject.

      This method must be stateless.

      Parameters:
      project - the project to check for content to ignore
      monitor - the progress monitor
      Returns:
      the set of child folders to ignore in import operation. Typically output directories such as bin/ or target/.
    • canConfigure

      boolean canConfigure(IProject project, Set<IPath> ignoredPaths, IProgressMonitor monitor)
      Checks whether this configurator can contribute to the configuration of the given project.

      This method must be stateless.

      Parameters:
      project - the project to check for potential configuration
      ignoredPaths - paths that have to be ignored when checking whether this configurator applies. Those will typically be nested projects (handled separately), or output directories (bin/, target/, ...).
      monitor - the progress monitor
      Returns:
      true iff this configurator can configure the given project
    • configure

      void configure(IProject project, Set<IPath> ignoredPaths, IProgressMonitor monitor)
      Configures a project. This method will only be called if canConfigure(IProject, Set, IProgressMonitor) returned true for the given project.

      This method must be stateless.

      Parameters:
      project - the project to configure
      ignoredPaths - paths that have to be ignored when configuring the project. Those will typically be nested projects, output directories (bin/, target/, ...)
      monitor - the progress monitor