Package fr.openwide.maven.artifact.notifier.web.application.artifact.component

Examples of fr.openwide.maven.artifact.notifier.web.application.artifact.component.ArtifactDropDownChoice


    });
   
    // Add artifact form
    IModel<Artifact> emptyArtifactModel = new GenericEntityModel<Long, Artifact>(null);
   
    final ArtifactDropDownChoice artifactDropDown = new ArtifactDropDownChoice("artifact", emptyArtifactModel,
        new ProjectArtifactSelect2AjaxAdapter(ArtifactDropDownChoice.CHOICE_RENDERER));
    artifactDropDown.setWidth(DropDownChoiceWidth.NORMAL);
    artifactDropDown.setRequired(true);
    artifactDropDown.setLabel(new ResourceModel("project.description.artifacts.chooseOne"));
    artifactDropDown.add(new LabelPlaceholderBehavior());
    artifactDropDown.add(new AuthenticatedOnlyBehavior());
   
    final Form<Artifact> addArtifactForm = new StatelessForm<Artifact>("addArtifactForm", emptyArtifactModel) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(MavenArtifactNotifierSession.get().hasRoleAdmin());
      }
    };
    addArtifactForm.add(artifactDropDown);
    addArtifactForm.add(new AjaxSubmitLink("addArtifactLink", addArtifactForm) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        Project project = ProjectArtifactsPanel.this.getModelObject();
        Artifact selectedArtifact = artifactDropDown.getModelObject();
       
        if (selectedArtifact != null) {
          if (selectedArtifact.getProject() == null) {
            try {
              projectService.addArtifact(project, selectedArtifact);
              getSession().success(getString("project.description.artifacts.add.success"));
            } catch (Exception e) {
              LOGGER.error("Unknown error occured while adding an artifact to a project", e);
              getSession().error(getString("project.description.artifacts.add.error"));
            }
          } else {
            LOGGER.error("Artifact already added to a project");
            getSession().warn(getString("project.description.artifacts.add.alreadyHasProject"));
          }
        }
        artifactDropDown.setModelObject(null);
        target.add(getPage());
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
View Full Code Here


   
    final MarkupContainer relatedArtifactContainer = new WebMarkupContainer("relatedArtifactContainer");
    relatedArtifactContainer.setOutputMarkupId(true);
    form.add(relatedArtifactContainer);
   
    final ArtifactDropDownChoice relatedArtifactField = new ArtifactDropDownChoice("relatedArtifact",
        BindingModel.of(form.getModel(), Binding.artifact().relatedArtifact()),
        new ArtifactSelect2AjaxAdapter(ArtifactDropDownChoice.CHOICE_RENDERER) {
      private static final long serialVersionUID = 1L;

      @Override
      public List<Artifact> getChoices(int start, int count, String term) {
        List<Artifact> choices = super.getChoices(start, count, term);
        choices.remove(getModelObject());
        return choices;
      }
    });
    relatedArtifactField.setLabel(new ResourceModel("artifact.deprecation.field.relatedArtifact"));
    relatedArtifactContainer.add(relatedArtifactField);
   
    ArtifactDeprecationStatusDropDownChoice deprecatedField = new ArtifactDeprecationStatusDropDownChoice("deprecationStatus",
        BindingModel.of(form.getModel(), Binding.artifact().deprecationStatus()));
    deprecatedField.setWidth(DropDownChoiceWidth.SMALL);
    deprecatedField.setLabel(new ResourceModel("artifact.deprecation.field.deprecationStatus"));
   
    relatedArtifactField.add(new AjaxInputPrerequisiteEnabledBehavior<ArtifactDeprecationStatus>(deprecatedField)
        .setObjectValidPredicate(PREDICATE)
        .setRefreshParent(true));
    form.add(deprecatedField);

    return body;
View Full Code Here

TOP

Related Classes of fr.openwide.maven.artifact.notifier.web.application.artifact.component.ArtifactDropDownChoice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.