@ApiStatus.Internal
  void apply(@NotNull Project project, @Nullable String targetName) {
    boolean localTarget = targetName == null;
    boolean targetChanged = !Objects.equals(myTargetName, targetName);
    if (targetChanged) {
      myTargetName = targetName;
      mavenHomeComponent.getComponent().getButton().setVisible(localTarget);
      mavenHomeOnTargetHelpLabel.setVisible(!localTarget);
      String mavenHomeInputLabel;
      if (localTarget) {
        mavenHomeInputLabel = MavenConfigurableBundle.message("maven.settings.environment.home.directory");
      }
      else {
        TargetEnvironmentsManager targetManager = TargetEnvironmentsManager.getInstance(project);
        TargetEnvironmentConfiguration targetEnvironmentConfiguration = targetManager.getTargets().findByName(targetName);
        String typeId = targetEnvironmentConfiguration != null ? targetEnvironmentConfiguration.getTypeId() : null;
        TargetEnvironmentType<?> targetEnvironmentType = null;
        if (typeId != null) {
          targetEnvironmentType = TargetEnvironmentType.EXTENSION_NAME.findFirstSafe(type -> type.getId().equals(typeId));
        }
        if (targetEnvironmentType != null) {
          // wrap the text to avoid label ellipsis
          mavenHomeInputLabel = MessageFormat.format("<html><body><nobr>{0}</nobr></body></html>",
                                                     MavenConfigurableBundle.message("maven.settings.on.targets.environment.home.directory",
                                                                                     targetEnvironmentType.getDisplayName()));
        }
        else {
          mavenHomeInputLabel = MavenConfigurableBundle.message("maven.settings.environment.home.directory");
        }
      }
      mavenHomeComponent.setText(mavenHomeInputLabel);
      reloadMavenHomeComponents(project, targetName);
    }
    else if (!localTarget) {
      reloadMavenHomeComponents(project, targetName);
    }
  }
@ApiStatus.Internal
  void apply(@NotNull Project project, @Nullable String targetName)