Package fr.openwide.maven.artifact.notifier.web.application.common.behavior

Examples of fr.openwide.maven.artifact.notifier.web.application.common.behavior.AuthenticatedOnlyBehavior


 
  public ProjectFormPopupPanel(String id, IModel<Project> projectModel, FormPanelMode mode) {
    super(id, projectModel);
    this.mode = mode;
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here


          @Override
          protected void onConfigure() {
            super.onConfigure();
            setVisible(MavenArtifactNotifierSession.get().hasRoleAdmin());
          }
        }.add(new AuthenticatedOnlyBehavior()));
      }
    };
    add(artifactListView);
   
    add(new WebMarkupContainer("emptyList") {
      private static final long serialVersionUID = 6700720373087584498L;

      @Override
      public void onConfigure() {
        super.onConfigure();
        setVisible(artifactListView.size() <= 0);
      }
    });
   
    // 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
      protected void onError(AjaxRequestTarget target, Form<?> form) {
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(MavenArtifactNotifierSession.get().hasRoleAdmin());
      }
    });
    addArtifactForm.add(new AuthenticatedOnlyBehavior());
    add(addArtifactForm);
  }
View Full Code Here

      @Override
      public boolean isVisible() {
        return false;
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    add(follow);
   
    // Unfollow
    AjaxLink<Project> unfollow = new AjaxLink<Project>("unfollow", projectModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          userService.unfollowProject(MavenArtifactNotifierSession.get().getUser(), getModelObject());
          target.add(getPage());
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing project", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Project project = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && project != null && userService.isFollowedProject(user, project));
      }
     
      // XXX: Disabled for now
      @Override
      public boolean isVisible() {
        return false;
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
    add(unfollow);
   
    add(new ProjectDescriptionPanel("projectDescriptionPanel", projectModel));
    add(new ProjectArtifactsPanel("projectArtifactsPanel", projectModel));
    add(new ProjectLinksPanel("projectLinksPanel", projectModel));
View Full Code Here

 
  public ProjectVersionFormPopupPanel(String id, IModel<ProjectVersion> projectVersionModel, FormPanelMode mode) {
    super(id, projectVersionModel);
    this.mode = mode;
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here

        boolean isDeprecated = artifact == null || ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        setVisible(!isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    add(follow);
   
    // Deprecated
    final IModel<Artifact> relatedArtifactModel = BindingModel.of(getModel(), Binding.artifact().relatedArtifact());
    Link<Void> relatedArtifactLink = ArtifactDescriptionPage.linkDescriptor(relatedArtifactModel).link("deprecated");
    relatedArtifactLink.add(new Behavior() {
      private static final long serialVersionUID = 1L;

      @Override
      public void onConfigure(Component component) {
        super.onConfigure(component);
        Artifact artifact = ArtifactFollowActionsPanel.this.getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        component.setVisibilityAllowed(isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
        component.setEnabled(relatedArtifactModel.getObject() != null);
      }
    });
    relatedArtifactLink.add(new AuthenticatedOnlyBehavior());
    relatedArtifactLink.add(new AttributeModifier("title", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        Artifact relatedArtifact = relatedArtifactModel.getObject();
        StringBuilder sb = new StringBuilder(getString("artifact.description.deprecated"));
        if (relatedArtifact != null) {
          sb.append(" ").append(getString("artifact.deprecation.link.title", relatedArtifactModel));
        }
        return sb.toString();
      }
    }));
    add(relatedArtifactLink);
   
    // Unfollow
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", getModel()) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          refresh(target);
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
    add(unfollow);
   
    add(new WebMarkupContainer("registerTooltip") {
      private static final long serialVersionUID = 1L;
View Full Code Here

  private static final long serialVersionUID = -7586843919098210316L;

  public AuthenticatedOnlyButton(String id) {
    super(id);
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here

  }

  public AuthenticatedOnlyButton(String id, IModel<String> model) {
    super(id, model);
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here

        boolean isDeprecated = artifact == null || ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        setVisible(!isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    add(follow);
   
    // Unfollow
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", artifactModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          target.add(getPage());
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
    add(unfollow);
   
    // Followers count label
    add(new CountLabel("followersCountLabel", "artifact.description.followers", new LoadableDetachableModel<Long>() {
      private static final long serialVersionUID = 1L;
View Full Code Here

    add(addRuleForm);
   
    // Demonstration
    add(new FollowedArtifactNotificationRulesDemoPanel("demoPanel", rulesModel));
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here

  }
 
  public ArtifactVersionFormPopupPanel(String id, IModel<ArtifactVersion> artifactVersionModel) {
    super(id, artifactVersionModel);
   
    add(new AuthenticatedOnlyBehavior());
  }
View Full Code Here

TOP

Related Classes of fr.openwide.maven.artifact.notifier.web.application.common.behavior.AuthenticatedOnlyBehavior

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.