@Override
public void onClick(AjaxRequestTarget target) {
try {
Project project = ProjectArtifactsPanel.this.getModelObject();
Artifact artifact = getModelObject();
projectService.removeArtifact(project, artifact);
Session.get().success(getString("project.description.artifacts.remove.success"));
} catch (Exception e) {
LOGGER.error("Error occured while removing artifact", e);
Session.get().error(getString("project.description.artifacts.remove.error"));
}
target.add(getPage());
FeedbackUtils.refreshFeedback(target, getPage());
}
@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);