Exemplo n.º 1
0
 @Override
 public void initializeUI(UIBuilder builder) throws Exception {
   initContainers(builder.getUIContext());
   initProviders();
   initConfigureMetadata();
   builder.add(jpaVersion).add(container).add(provider).add(configureMetadata);
 }
Exemplo n.º 2
0
 @Override
 public void initializeUI(UIBuilder builder) throws Exception {
   setupTargetClass(builder.getUIContext());
   properties.setValueChoices(
       new Callable<Iterable<String>>() {
         @Override
         public Iterable<String> call() throws Exception {
           List<String> strings = new ArrayList<>();
           JavaResource javaResource = targetClass.getValue();
           JavaClassSource targetClass = javaResource.getJavaType();
           List<PropertySource<JavaClassSource>> properties = targetClass.getProperties();
           for (PropertySource<JavaClassSource> property : properties) {
             strings.add(property.getName());
           }
           return strings;
         }
       });
   properties.setEnabled(
       new Callable<Boolean>() {
         @Override
         public Boolean call() {
           return (targetClass.getValue() != null);
         }
       });
   builder.add(targetClass).add(builderPattern).add(properties);
 }
Exemplo n.º 3
0
 private void configureTargetLocationInput(final UIBuilder builder) {
   UISelection<Resource<?>> currentSelection = builder.getUIContext().getInitialSelection();
   if (!currentSelection.isEmpty()) {
     Resource<?> resource = currentSelection.get();
     if (resource instanceof DirectoryResource) {
       targetLocation.setDefaultValue((DirectoryResource) resource);
     }
   } else {
     targetLocation.setDefaultValue(
         resourceFactory.create(DirectoryResource.class, OperatingSystemUtils.getUserHomeDir()));
   }
 }
Exemplo n.º 4
0
  private void configureProjectTypeInput(final UIBuilder builder) {
    if (builder.getUIContext().getProvider().isGUI()) {
      type.setItemLabelConverter(
          new Converter<ProjectType, String>() {
            @Override
            public String convert(ProjectType source) {
              return source == null ? null : source.getType();
            }
          });
    }

    // Add Project types
    List<ProjectType> projectTypes = new ArrayList<>();
    for (ProjectType projectType : type.getValueChoices()) {
      boolean buildable = false;
      for (ProjectProvider buildSystem : buildSystems) {
        if (isProjectTypeBuildable(projectType, buildSystem)) {
          projectTypes.add(projectType);
          buildable = true;
          break;
        }
      }

      if (!buildable)
        log.log(
            Level.FINE,
            "ProjectType ["
                + projectType.getType()
                + "] "
                + "deactivated because it cannot be built with any registered ProjectProvider instances ["
                + buildSystems
                + "].");
    }

    Collections.sort(
        projectTypes,
        new Comparator<ProjectType>() {
          @Override
          public int compare(ProjectType left, ProjectType right) {
            return new Integer(left.priority()).compareTo(right.priority());
          }
        });

    if (!projectTypes.isEmpty()) {
      type.setDefaultValue(projectTypes.get(0));
    }
    type.setValueChoices(projectTypes);
  }
  @Override
  public void initializeUI(UIBuilder builder) throws Exception {
    super.initializeUI(builder);

    UIContext context = builder.getUIContext();
    Project project = getSelectedProject(context);
    JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);

    final List<JavaResource> entities = persistenceOperations.getProjectEntities(project);
    forEntity.setValueChoices(entities);
    setDefaultTargetEntity(context.<FileResource<?>>getInitialSelection(), entities);

    getTargetPackage().setDescription("Repository package name");
    getTargetPackage()
        .setDefaultValue(javaSourceFacet.getBasePackage() + DEFAULT_REPOSITORY_PACKAGE);

    repositoryType.setDefaultValue(SpringBootRepositoryType.PAGING_AND_SORTING);

    builder.add(forEntity);
    builder.add(repositoryType);
  }
Exemplo n.º 6
0
  @Override
  public void initializeUI(UIBuilder builder) throws Exception {
    final UIContext context = builder.getUIContext();
    copyPipelineToProject.setValue(Boolean.TRUE);
    pipeline.setCompleter(
        new UICompleter<PipelineDTO>() {
          @Override
          public Iterable<PipelineDTO> getCompletionProposals(
              UIContext context, InputComponent<?, PipelineDTO> input, String value) {
            return getPipelines(context, true);
          }
        });
    pipeline.setValueConverter(
        new Converter<String, PipelineDTO>() {
          @Override
          public PipelineDTO convert(String text) {
            return getPipelineForValue(context, text);
          }
        });
    pipeline.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChanged(ValueChangeEvent event) {
            String value = event.getNewValue() != null ? event.getNewValue().toString() : null;
            if (value != null) {
              String description = getDescriptionForFlow(value);
              pipeline.setNote(description != null ? description : "");
            } else {
              pipeline.setNote("");
            }
            boolean canCopy = Strings.isNotBlank(value);
            copyPipelineToProject.setEnabled(canCopy);
          }
        });
    if (getCurrentSelectedProject(context) != null) {
      PipelineDTO defaultValue = getPipelineForValue(context, DEFAULT_MAVEN_FLOW);
      if (defaultValue != null) {
        pipeline.setDefaultValue(defaultValue);
        pipeline.setValue(defaultValue);
      }
    }
    chatRoom.setCompleter(
        new UICompleter<String>() {
          @Override
          public Iterable<String> getCompletionProposals(
              UIContext context, InputComponent<?, String> input, String value) {
            return filterCompletions(getChatRoomNames(), value);
          }
        });
    chatRoom.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChanged(ValueChangeEvent event) {
            String value = event.getNewValue() != null ? event.getNewValue().toString() : null;
            if (value != null) {
              String description = getDescriptionForChatRoom(value);
              chatRoom.setNote(description != null ? description : "");
            } else {
              chatRoom.setNote("");
            }
          }
        });
    issueProjectName.setCompleter(
        new UICompleter<String>() {
          @Override
          public Iterable<String> getCompletionProposals(
              UIContext context, InputComponent<?, String> input, String value) {
            return filterCompletions(getIssueProjectNames(), value);
          }
        });
    issueProjectName.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChanged(ValueChangeEvent event) {
            String value = event.getNewValue() != null ? event.getNewValue().toString() : null;
            if (value != null) {
              String description = getDescriptionForIssueProject(value);
              issueProjectName.setNote(description != null ? description : "");
            } else {
              issueProjectName.setNote("");
            }
          }
        });

    // lets initialise the data from the current config if it exists
    ProjectConfig config = null;
    Project project = getCurrentSelectedProject(context);
    File configFile = getProjectConfigFile(context, getSelectedProject(context));
    if (configFile != null && configFile.exists()) {
      config = ProjectConfigs.parseProjectConfig(configFile);
    }
    if (config != null) {
      PipelineDTO flow = getPipelineForValue(context, config.getPipeline());
      if (flow != null) {
        CommandHelpers.setInitialComponentValue(this.pipeline, flow);
      }
      CommandHelpers.setInitialComponentValue(chatRoom, config.getChatRoom());
      CommandHelpers.setInitialComponentValue(issueProjectName, config.getIssueProjectName());
      CommandHelpers.setInitialComponentValue(codeReview, config.getCodeReview());
    }
    inputComponents = new ArrayList<>();
    File jenkinsFile = CommandHelpers.getProjectContextFile(context, project, "Jenkinsfile");
    boolean hasJenkinsFile = Files.isFile(jenkinsFile);
    LOG.debug("Has Jenkinsfile " + hasJenkinsFile + " with file: " + jenkinsFile);
    if (!hasJenkinsFile) {
      inputComponents.addAll(
          CommandHelpers.addInputComponents(builder, pipeline, copyPipelineToProject));
    }
    inputComponents.addAll(
        CommandHelpers.addInputComponents(builder, chatRoom, issueProjectName, codeReview));
  }