コード例 #1
0
  /**
   * Preselect project names for the remote projects. This method will either use an existing shared
   * project and disable the option to change the preselected values or just generate a unique
   * project name for new projects.
   *
   * <p>This method does <b>not</b> preselect values for existing projects unless they are already
   * shared ! This can do more harm than indented when the user is so eager and just ignores all
   * warnings that will be presented before he can finish the wizard.
   */
  private void preselectProjectNames() {

    final Set<String> reservedProjectNames = new HashSet<String>();

    for (Entry<String, ProjectOptionComposite> entry : projectOptionComposites.entrySet()) {

      String projectID = entry.getKey();
      ProjectOptionComposite projectOptionComposite = entry.getValue();

      de.fu_berlin.inf.dpp.filesystem.IProject project = session.getProject(projectID);

      if (project == null) continue;

      projectOptionComposite.setProjectName(true, project.getName());
      projectOptionComposite.setEnabled(false);
      reservedProjectNames.add(project.getName());
    }

    for (Entry<String, ProjectOptionComposite> entry : projectOptionComposites.entrySet()) {

      String projectID = entry.getKey();
      ProjectOptionComposite projectOptionComposite = entry.getValue();

      de.fu_berlin.inf.dpp.filesystem.IProject project = session.getProject(projectID);

      if (project != null) continue;

      String projectNameProposal =
          findProjectNameProposal(
              remoteProjectNames.get(projectID), reservedProjectNames.toArray(new String[0]));

      projectOptionComposite.setProjectName(false, projectNameProposal);
      reservedProjectNames.add(projectNameProposal);
    }
  }
コード例 #2
0
  /**
   * Scans the current Eclipse Workspace for project artifacts.
   *
   * @return string containing a warning message if artifacts are found, <code>null</code> otherwise
   */
  private String findAndReportProjectArtifacts() {
    IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();

    if (workspacePath == null) return null;

    File workspaceDirectory = workspacePath.toFile();

    List<String> dirtyProjectNames = new ArrayList<String>();

    for (ProjectOptionComposite composite : projectOptionComposites.values()) {

      if (composite.useExistingProject()) continue;

      String projectName = composite.getProjectName();

      if (projectName.isEmpty()) continue;

      if (new File(workspaceDirectory, projectName).exists()) dirtyProjectNames.add(projectName);
    }

    String warningMessage = null;

    if (!dirtyProjectNames.isEmpty()) {
      warningMessage =
          MessageFormat.format(
              Messages.EnterProjectNamePage_warning_project_artifacts_found,
              StringUtils.join(dirtyProjectNames, ", "));
    }

    return warningMessage;
  }
コード例 #3
0
  private void attachListeners() {
    for (ProjectOptionComposite composite : projectOptionComposites.values()) {

      composite.addProjectOptionListener(
          new ProjectOptionListener() {
            @Override
            public void projectNameChanged(ProjectNameChangedEvent event) {
              updatePageComplete(event.projectID);
            }
          });
    }
  }
コード例 #4
0
  private List<String> getCurrentProjectNames(String... projectIDsToExclude) {
    final List<String> currentProjectNames = new ArrayList<String>();

    final Set<String> excludedProjectIDs = new HashSet<String>(Arrays.asList(projectIDsToExclude));

    for (Entry<String, ProjectOptionComposite> entry : projectOptionComposites.entrySet()) {

      String projectID = entry.getKey();
      ProjectOptionComposite projectOptionComposite = entry.getValue();

      if (excludedProjectIDs.contains(projectID)) continue;

      currentProjectNames.add(projectOptionComposite.getProjectName());
    }

    return currentProjectNames;
  }
コード例 #5
0
  /**
   * Checks if the project options for the given project id are valid.
   *
   * @return an error message if the options are not valid, otherwise the error message is <code>
   *     null</code>
   */
  private String isProjectSelectionValid(String projectID) {

    ProjectOptionComposite projectOptionComposite = projectOptionComposites.get(projectID);

    String projectName = projectOptionComposite.getProjectName();

    if (projectName.isEmpty())
      return Messages.EnterProjectNamePage_set_project_name
          + " for remote project "
          + remoteProjectNames.get(projectID);

    IStatus status = ResourcesPlugin.getWorkspace().validateName(projectName, IResource.PROJECT);

    if (!status.isOK())
      // FIXME display remote project name
      return status.getMessage();

    List<String> currentProjectNames = getCurrentProjectNames(projectID);

    if (currentProjectNames.contains(projectName))
      // FIXME display the project ... do not let the user guess
      return MessageFormat.format(
          Messages.EnterProjectNamePage_error_projectname_in_use, projectName);

    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

    if (projectOptionComposite.useExistingProject() && !project.exists())
      // FIXME crap error message
      return Messages.EnterProjectNamePage_error_wrong_name
          + " "
          + projectOptionComposite.getProjectName();

    if (!projectOptionComposite.useExistingProject() && project.exists())
      // FIXME we are working with tabs ! always display the remote
      // project name
      return MessageFormat.format(
          Messages.EnterProjectNamePage_error_projectname_exists, projectName);

    return null;
  }