deleted fiels

This commit is contained in:
joha-asc 2011-07-20 15:25:53 +02:00
parent 2db1ac12d0
commit 5f88e45484
3 changed files with 0 additions and 370 deletions
src/main
java/se/su/dsv/scipro/commentthread/panel
resources

@ -1,68 +0,0 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
</head>
<body>
<wicket:panel>
<div wicket:id="container" class="prepend-top last">
<div class="comment last" wicket:id="comment">
<div class="comment-header last">
<div class="last">
<span wicket:id="from" class="comment-posted-by">Dan Kjellman</span>
</div>
<div class="last">
<span class="comment-posted-date">Posted: </span>
<span wicket:id="date" class="comment-posted-date"></span>
<a href="#" wicket:id="editComment">
<img class="icon-12" src="images/icons/edit_16x16.png" " alt="Edit" title="Edit" />
<span class="small"> Edit</span>
</a>
<a href="#" wicket:id="deleteComment">
<img class="icon-12" src="images/icons/delete_16x16.png" alt="Delete" title="Delete" />
<span class="small"> Delete</span>
</a>
</div>
</div>
<div class="comment-bottom-border last"></div>
<div class="comment-area last">
<p wicket:id="message">This is the comment</p>
</div>
</div>
<div wicket:id="navigator" class="comment-pager last"></div>
</div>
<div class="last comment-form">
<form wicket:id="commentForm">
<div class="last">
<strong>Comment:</strong>
</div>
<div class="last">
<textarea wicket:id="textMessage" ></textarea>
</div>
<div class="last">
<button wicket:id="submitButton" class="button">Submit comment
<img src="images/icons/chat_16x16.png" alt=""/>
</button>
</div>
</form>
</div>
<div wicket:id="dialog">
<div wicket:id="dialogContainer" class="comment-form">
<form wicket:id="editCommentForm">
<div>
<textarea wicket:id="editTextMessage" ></textarea>
</div>
<div>
<button wicket:id="submitButton" class="button">Save
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/>
</button>
</div>
</form>
</div>
</div>
</wicket:panel>
</body>
</html>

@ -1,298 +0,0 @@
/**
*
*/
package se.su.dsv.scipro.commentthread.panel;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.PageableListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.odlabs.wiquery.ui.dialog.Dialog;
import se.su.dsv.scipro.SciProSession;
import se.su.dsv.scipro.data.DomainObjectDetachableModel;
import se.su.dsv.scipro.data.dao.interfaces.CommentDao;
import se.su.dsv.scipro.data.dao.interfaces.CommentThreadDao;
import se.su.dsv.scipro.data.dataobjects.Comment;
import se.su.dsv.scipro.data.dataobjects.CommentThread;
import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
import se.su.dsv.scipro.message.panels.CustomPagingNavigator;
import se.su.dsv.scipro.security.auth.roles.Roles;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
*/
public class CommentThreadPanel extends Panel {
private static final long serialVersionUID = 1L;
@SpringBean
private CommentThreadDao commentThreadDao;
@SpringBean
private CommentDao commentDao;
private WebMarkupContainer webMarkupContainer;
private PageableListView<Comment> commentListView;
private CustomPagingNavigator customPagingNavigator;
private int numberOfComments;
private TextArea<String> textArea;
private WebMarkupContainer dialogContainer;
private Dialog dialog;
private final IModel<CommentThread> threadModel;
private final EditCommentForm editCommentForm;
public CommentThreadPanel(final String id, final Commentable keyObject, final int numberOfComments) {
super(id);
final String className = keyObject.getCommentKey();
final Long classId = keyObject.getId();
this.numberOfComments = numberOfComments;
CommentThread commentThread = commentThreadDao.getCommentThread(keyObject);
if (commentThread == null) {
//TODO rewrite so thread is only created on demand, ie when someone's posted
CommentThread ct = new CommentThread(keyObject);
commentThread = commentThreadDao.save(ct);
}
threadModel = new DomainObjectDetachableModel<CommentThread>(commentThreadDao, commentThread);
webMarkupContainer = new WebMarkupContainer("container");
webMarkupContainer.setOutputMarkupId(true);
generateCommentListView();
webMarkupContainer.add(commentListView);
add(webMarkupContainer);
webMarkupContainer.add(customPagingNavigator);
Comment newComment = new Comment( SciProSession.get().getUser(), commentThread );
add(new CommentForm("commentForm", new Model<Comment>(newComment)));
dialogContainer = new WebMarkupContainer("dialogContainer");
dialog = new Dialog("dialog");
dialog.setModal(true);
dialog.setAutoOpen(false);
dialog.setWidth(470);
dialog.add(dialogContainer);
add(dialog);
dialogContainer.setOutputMarkupId(true);
editCommentForm = new EditCommentForm("editCommentForm", new DomainObjectDetachableModel<Comment>(commentDao, new Comment()) );
dialogContainer.add(editCommentForm);
}
private void generateCommentListView() {
threadModel.detach(); //Forces reinit of model object so collection is attached to session, ugly solution, don't copy..
List<Comment> commentList = threadModel.getObject().getCommentsList();
commentListView = new PageableListView<Comment>("comment", commentList, numberOfComments) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<Comment> item) {
final Comment c = item.getModelObject();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
item.add(new Label("date", df.format(c.getDateCreated())));
item.add( c.getCreator().getDisplayComponent("from") );
item.add(new MultiLineLabel("message", new PropertyModel<String>(item.getDefaultModel(), "comment")).setEnabled(false));
item.add(new CommentDeleteLink("deleteComment", c));
item.add(new CommentEditLink("editComment", c));
};
};
customPagingNavigator = new CustomPagingNavigator("navigator", commentListView) {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return commentListView.size() > 0;
}
};
}
public class CommentForm extends Form<Comment> {
private static final long serialVersionUID = 1L;
public CommentForm(final String id, final IModel<Comment> commentModel) {
super(id, commentModel);
textArea = new TextArea<String>("textMessage",new PropertyModel<String>(commentModel,"comment"));
textArea.setOutputMarkupId(true);
add(textArea);
AjaxButton ajaxButton = new AjaxButton("submitButton", new Model<String>("Submit Comment")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
Comment comment = (Comment) form.getDefaultModelObject();
comment = commentDao.save(comment);
/*
* Do not, on purpose set the forms defaultModelObject to the now persisted object,
* we leave the original object so it can be re reused for any number of submits
* *
*/
webMarkupContainer.remove(commentListView);
webMarkupContainer.remove(customPagingNavigator);
textArea.setDefaultModelObject("");
generateCommentListView();
webMarkupContainer.add(commentListView);
webMarkupContainer.add(customPagingNavigator);
target.addComponent(textArea);
target.addComponent(webMarkupContainer);
}
};
ajaxButton.setOutputMarkupId(true);
add(ajaxButton);
}
}
private class CommentDeleteLink extends AjaxLink<Comment> {
private static final long serialVersionUID = 5900025667153930797L;
private Comment comment;
public CommentDeleteLink(String id, Comment comment) {
super(id);
this.comment = comment;
}
@Override
public boolean isVisible() {
SciProSession session = SciProSession.get();
if( session.authorizedForRole(Roles.ADMIN) )
return true;
if( comment.getCreator().equals( session.getUser() ) )
return true;
return false;
}
@Override
public void onClick(AjaxRequestTarget target) {
comment = commentDao.reLoad(comment);
comment.getCommentThread().getComments().remove(comment);
commentDao.delete(comment);
webMarkupContainer.remove(commentListView);
webMarkupContainer.remove(customPagingNavigator);
generateCommentListView();
webMarkupContainer.add(commentListView);
webMarkupContainer.add(customPagingNavigator);
target.addComponent(webMarkupContainer);
}
}
private class CommentEditLink extends AjaxLink<Comment> {
private static final long serialVersionUID = 5900025667153930797L;
private final Comment comment;
public CommentEditLink(final String id, final Comment comment) {
super(id);
this.comment = comment;
}
@Override
public boolean isVisible() {
SciProSession session = SciProSession.get();
if( session.authorizedForRole(Roles.ADMIN) )
return true;
if( comment.getCreator().equals( session.getUser() ) )
return true;
return false;
}
@Override
public void onClick(AjaxRequestTarget target) {
editCommentForm.setDefaultModelObject( comment );
//editCommentForm.setTextAreaDefaultModelObject( comment.getComment());
/*
* TODO Investigate bug that occurs when this panel gets hidden and re-shown
* in resources-view, edit-text-area displays text from the wrong model-object.
*/
dialog.open(target);
target.addComponent(dialog);
}
}
private class EditCommentForm extends Form<Comment> {
private static final long serialVersionUID = 1L;
private final TextArea<String> editTextArea;
public EditCommentForm(final String id, final IModel<Comment> commentModel) {
super(id,commentModel);
editTextArea = new TextArea<String>("editTextMessage",new PropertyModel<String>(commentModel,"comment"));
editTextArea.setOutputMarkupId(true);
add(editTextArea);
dialog.setTitle("Edit Comment");
AjaxButton ajaxButton = new AjaxButton("submitButton", new Model<String>("Save")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
//DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//Date date = new Date();
//df.format(date)
//editComment.setComment(((CommentThreadModel) form.getModelObject()).getEditTextMessage() + "\n\nLast edited: " +df.format(date) + " by: " + user.getFirstName() + " " + user.getLastName()) ;
/*
* !!! We do not have to explicitly save object! It is currently being persisted by cascade!
*/
webMarkupContainer.remove(commentListView);
webMarkupContainer.remove(customPagingNavigator);
generateCommentListView();
webMarkupContainer.add(commentListView);
webMarkupContainer.add(customPagingNavigator);
dialog.close(target);
target.addComponent(webMarkupContainer);
}
};
ajaxButton.setOutputMarkupId(true);
add(ajaxButton);
}
/*
* Attempt to fix weird incorrect-updating of text-area content when panel is used in resources-view
*/
public void setTextAreaDefaultModelObject(String string){
editTextArea.setDefaultModelObject(string);
}
}
}

@ -1,4 +0,0 @@
mail.smtp.host=mail.dsv.su.se
systemFromName=[TEST] SciPro-mailer
sendMailEnabled=true
systemFromEmail=no-reply@thesis.dsv.su.se