resoiurce
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@535 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
eb13300bab
commit
6de193163f
src/main/java/se/su/dsv/scipro/knol/resource/panels
EmbedResourceBookmarkablePanel.htmlEmbedResourceBookmarkablePanel.javaEmbedResourcePanel.htmlEmbedResourcePanel.javaKnolPanel.htmlKnolPanel.javaLinkResourceBookmarkablePanel.htmlLinkResourceBookmarkablePanel.javaLinkResourcePanel.htmlLinkResourcePanel.javaLinkResourcePanel.propertiesResourceBookmarkablePanel.htmlResourceBookmarkablePanel.javaResourceBookmarkablePanel.propertiesResourcesPanel.htmlResourcesPanel.javaResourcesPanel.properties
@ -1,31 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id ="listContainer">
|
||||
<h2>Video Resource</h2>
|
||||
<table>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up.png" class="icon-24" alt="Up"/></a></div>
|
||||
<div class = "centered" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down.png" class="icon-24" alt="Down"/></a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><strong>Tag/s: </strong> <span wicket:id="tag"></span></div>
|
||||
<div><strong>Created: </strong> <span wicket:id="date"></span></div>
|
||||
<div><strong>Created by: </strong> <span wicket:id="user"></span></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><hr/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div wicket:id="embed"></div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,170 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RestartResponseException;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.ExternalLink;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EmbedResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LinkResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.EmbedResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
import se.su.dsv.scipro.knol.resource.page.EmbedWebMarkupContainer;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class EmbedResourceBookmarkablePanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private EmbedResourceDao embedResourceDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
private WebMarkupContainer listContainer = new WebMarkupContainer("listContainer");
|
||||
|
||||
private User user;
|
||||
|
||||
private int point;
|
||||
private EmbedResource embed;
|
||||
|
||||
public EmbedResourceBookmarkablePanel(String id, PageParameters pp) {
|
||||
super(id);
|
||||
Long linkId = pp.getAsLong("embedres");
|
||||
if(linkId == null){
|
||||
failAndRedirect();
|
||||
}
|
||||
else {
|
||||
|
||||
embed = embedResourceDao.load(linkId);
|
||||
if(embed == null)
|
||||
failAndRedirect();
|
||||
}
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer.setOutputMarkupId(true);
|
||||
add(listContainer);
|
||||
// pp.put("res", link.getId());
|
||||
// new BookmarkablePageLink<Void>("up", LinkResourcePage.class, pp);
|
||||
}
|
||||
private void failAndRedirect(){
|
||||
throw new RestartResponseException(SciProApplication.get().getApplicationSettings().getAccessDeniedPage());
|
||||
}
|
||||
|
||||
|
||||
public void loadListView() {
|
||||
final List<Rating> ratingList = embed.getRatingList();
|
||||
boolean rated = false;
|
||||
point = ratableDao.getRating(embed);
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
listContainer.add(new Label("rate", point + ""));
|
||||
listContainer.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated && rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
embed.setRatingList(ratingList);
|
||||
embedResourceDao.save(embed);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
embed.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
embedResourceDao.save(embed);
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
listContainer.add(new AjaxLink<String>("downLink", new Model<String>("Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated && rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
embed.setRatingList(ratingList);
|
||||
embedResourceDao.save(embed);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
embedResourceDao.save(embed);
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
listContainer.add(new Label("date", df.format(embed.getDateCreated())));
|
||||
listContainer.add(new Label("user", embed.getCreator().getFirstName() + " "
|
||||
+ embed.getCreator().getLastName()));
|
||||
listContainer.add(new EmbedWebMarkupContainer("embed", embed.getInfo()));
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : embed.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
listContainer.add(new Label("tag", tags));
|
||||
};
|
||||
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="feedbackPanel"></div>
|
||||
<div class="span-6 last">
|
||||
<form wicket:id="resourceForm">
|
||||
|
||||
<div wicket:id="editContainer">
|
||||
|
||||
<div class ="span-6 last">
|
||||
<strong>Embed Code:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tag/s:</strong>
|
||||
</div>
|
||||
|
||||
<div class ="span-6 last">
|
||||
<select wicket:id="selectedTagList" class = "span-8 last"></select>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="submit" wicket:id="submitButton" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div wicket:id="listContainer">
|
||||
<div wicket:id ="link-item" class="span-20 last">
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong>Rating</strong></td>
|
||||
<td><strong>Up</strong></td>
|
||||
<td><strong>Down</strong></td>
|
||||
<td><strong>Created</strong></td>
|
||||
<td><strong>By User</strong></td>
|
||||
<td><strong>Tag/s</strong></td>
|
||||
<!-- <td><strong>File</strong></td>-->
|
||||
<td><strong>Edit</strong></td>
|
||||
<td><strong>Delete</strong></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td wicket:id="rate"></td>
|
||||
<td><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up.png" class="icon-24" alt="Up"/></a></td>
|
||||
<td><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down.png" class="icon-24" alt="Down"/></a></td>
|
||||
<td wicket:id="date"></td>
|
||||
<td wicket:id="user"></td>
|
||||
<td wicket:id="tag"></td>
|
||||
<!-- <td><span wicket:id="filePanel"></span></td> -->
|
||||
<td><a href="#" wicket:id="editLink"><img src="images/icons/pencil.png" class="icon-24" alt="Edit"/></a></td>
|
||||
<td><a href="#" wicket:id="deleteLink"><img src="images/icons/circle-delete.png" class="icon-24" alt="Delete"/></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div wicket:id="embed"></div>
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,331 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
|
||||
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.form.ChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.ListMultipleChoice;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.util.ListModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EmbedResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.EmbedResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Recipient;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
import se.su.dsv.scipro.knol.resource.page.EmbedWebMarkupContainer;
|
||||
import se.su.dsv.scipro.knol.resource.page.ResourceModel;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class EmbedResourcePanel extends Panel{
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private EmbedResourceDao embedResourceDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
@SpringBean
|
||||
private TagDao tagDao;
|
||||
|
||||
private WebMarkupContainer listContainer;
|
||||
|
||||
private ListView<EmbedResource> linkListView;
|
||||
|
||||
private Collection<Tag> selectedTagList = new ArrayList<Tag>();
|
||||
|
||||
private User user;
|
||||
|
||||
private int point;
|
||||
|
||||
private boolean edit;
|
||||
private WebMarkupContainer editContainer;
|
||||
|
||||
private TextArea<String> info;
|
||||
private TextField<String> linkAddress;
|
||||
private ListMultipleChoice<Tag> userMultipleChoiceList;
|
||||
|
||||
private EmbedResource editLink;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
private ResourceModel resourceModel;
|
||||
|
||||
public EmbedResourcePanel(String id) {
|
||||
super(id);
|
||||
feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
add(feedbackPanel);
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer = new WebMarkupContainer("listContainer");
|
||||
listContainer.add(linkListView);
|
||||
listContainer.setOutputMarkupId(true);
|
||||
|
||||
add(listContainer);
|
||||
add(new LinkResourceForm("resourceForm"));
|
||||
}
|
||||
|
||||
public class LinkResourceForm extends Form<ResourceModel> {
|
||||
public LinkResourceForm(String name) {
|
||||
super(name, new CompoundPropertyModel<ResourceModel>(
|
||||
resourceModel = new ResourceModel()));
|
||||
editContainer = new WebMarkupContainer("editContainer");
|
||||
editContainer.setOutputMarkupId(true);
|
||||
info = new TextArea<String>("info");
|
||||
info.setRequired(true);
|
||||
editContainer.add(info);
|
||||
|
||||
userMultipleChoiceList = new ListMultipleChoice<Tag>(
|
||||
"selectedTagList", new ListModel<Tag>(tagDao.findAll()),
|
||||
new ChoiceRenderer<Tag>("tag")) {
|
||||
private static final long serialVersionUID = -7117603450416845711L;
|
||||
|
||||
@Override
|
||||
protected CharSequence getDefaultChoice(Object selected) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
OnChangeAjaxBehavior userSelectBehaviour = new OnChangeAjaxBehavior() {
|
||||
|
||||
private static final long serialVersionUID = 3412906970812300312L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
selectedTagList = userMultipleChoiceList.getModelObject();
|
||||
}
|
||||
};
|
||||
userMultipleChoiceList.add(userSelectBehaviour);
|
||||
|
||||
userMultipleChoiceList.setOutputMarkupId(true);
|
||||
editContainer.add(userMultipleChoiceList);
|
||||
|
||||
editContainer.add(new AjaxButton("submitButton", new Model<String>(
|
||||
"Save Resource")) {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
EmbedResource link;
|
||||
ResourceModel resourceModel = ((ResourceModel) form
|
||||
.getModelObject());
|
||||
if (edit) {
|
||||
link = editLink;
|
||||
edit = false;
|
||||
} else {
|
||||
link = new EmbedResource();
|
||||
}
|
||||
link.setInfo(resourceModel.getInfo());
|
||||
link.setCreator(user);
|
||||
link.setTagList(new ArrayList<Tag>(resourceModel.getSelectedTagList()));
|
||||
embedResourceDao.save(link);
|
||||
loadListView();
|
||||
resourceModel.setSelectedTagList(new ArrayList<Tag>());
|
||||
resourceModel.setInfo("");
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(feedbackPanel);
|
||||
target.addComponent(listContainer);
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target, final Form form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
add(editContainer);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadListView() {
|
||||
List<EmbedResource> linkList = embedResourceDao.findAll();
|
||||
Collections.sort(linkList, new Comparator<EmbedResource>() {
|
||||
@Override
|
||||
public int compare(EmbedResource o1, EmbedResource o2) {
|
||||
return Integer.valueOf(ratableDao.getRating(o2)).compareTo(
|
||||
Integer.valueOf(ratableDao.getRating(o1)));
|
||||
}
|
||||
});
|
||||
linkListView = new ListView<EmbedResource>("link-item", linkList) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<EmbedResource> item) {
|
||||
final EmbedResource link = item.getModelObject();
|
||||
final List<Rating> ratingList = link.getRatingList();
|
||||
boolean rated = false;
|
||||
point = 0;
|
||||
Rating rating = null;
|
||||
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
}
|
||||
if (r.getRatingValue() == RatingValue.UP) {
|
||||
point++;
|
||||
} else {
|
||||
point--;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
item.add(new Label("rate", point + ""));
|
||||
item.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
embedResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
link.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
embedResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<String>("downLink", new Model<String>(
|
||||
"Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
embedResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
embedResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
item.add(new Label("date", df.format(link.getDateCreated())));
|
||||
item.add(new Label("user", link.getCreator().getFirstName()
|
||||
+ " " + link.getCreator().getLastName()));
|
||||
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : link.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
item.add(new EmbedWebMarkupContainer("embed", link.getInfo()));
|
||||
item.add(new Label("tag", tags));
|
||||
|
||||
item.add(new AjaxLink<Recipient>("deleteLink") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
EmbedResource link2 = embedResourceDao.reLoad(link);
|
||||
if (link2.equals(editLink)) {
|
||||
edit = false;
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
embedResourceDao.delete(link2);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<Recipient>("editLink") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
edit = true;
|
||||
editLink = embedResourceDao.reLoad(link);
|
||||
info.setModelObject(editLink.getInfo());
|
||||
//listChoice = new ListMultipleChoice("choices", MANY_CHOICES)
|
||||
resourceModel.setSelectedTagList(editLink.getTagList());
|
||||
// userMultipleChoiceList.setModelObject(editLink
|
||||
// .getTagList());
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
|
||||
});
|
||||
// item.add(new FileResourcePanel("filePanel",
|
||||
// item.getModelObject()));
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
|
||||
<div wicket:id="listContainer">
|
||||
<h2>Link Resources</h2>
|
||||
<table wicket:id = "link-item" class = "link-resource-border">
|
||||
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up_16x16.png" class="icon-24" alt="Up"/></a></div>
|
||||
<div class = "centered larger-rate-number" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down_16x16.png" class="icon-24" alt="Down"/></a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><a href="#" target="_new" wicket:id="link" class="larger">this body will be replaced</a></div>
|
||||
<div><strong>Info: </strong> <span wicket:id="info"></span></div>
|
||||
<div><strong>Tag/s: </strong> <span wicket:id="tag"></span></div>
|
||||
<div><strong>Created: </strong> <span wicket:id="date"></span></div>
|
||||
<div><strong>Created by: </strong> <span wicket:id="user"></span></div>
|
||||
<div><a href="#" wicket:id="bookmark">Resource Link</a></div>
|
||||
<div><a href="#" wicket:id="showComments"><span wicket:id="commentNumber"></span></a></div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="rating-cell"></td>
|
||||
<td><div wicket:id="commentThread"></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div wicket:id ="navigator"></div>
|
||||
<h2>Video Resources</h2>
|
||||
<div wicket:id ="embed-item" class="span-20 last">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up_16x16.png" class="icon-24" alt="Up"/></a></div>
|
||||
<div class = "centered" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down_16x16.png" class="icon-24" alt="Down"/></a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><strong>Info: </strong> <span wicket:id="info"></span></div>
|
||||
<div><strong>Tag/s: </strong> <span wicket:id="tag"></span></div>
|
||||
<div><strong>Created: </strong> <span wicket:id="date"></span></div>
|
||||
<div><strong>Created by: </strong> <span wicket:id="user"></span></div>
|
||||
<div><a href="#" wicket:id="bookmarkEmbed">Resource Link</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div wicket:id="embed"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,388 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.ListMultipleChoice;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.link.ExternalLink;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.list.PageableListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.commentthread.panel.CommentThreadPanel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CommentThreadDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EmbedResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LinkResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.EmbedResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
import se.su.dsv.scipro.knol.resource.page.EmbedResourcePage;
|
||||
import se.su.dsv.scipro.knol.resource.page.EmbedWebMarkupContainer;
|
||||
import se.su.dsv.scipro.knol.resource.page.LinkResourcePage;
|
||||
import se.su.dsv.scipro.message.panels.CustomPagingNavigator;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class KnolPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private LinkResourceDao linkResourceDao;
|
||||
@SpringBean
|
||||
private EmbedResourceDao embedResourceDao;
|
||||
@SpringBean
|
||||
private CommentThreadDao commentThreadDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
private WebMarkupContainer listContainer;
|
||||
|
||||
private PageableListView<LinkResource> linkListView;
|
||||
private ListView<EmbedResource> embedListView;
|
||||
private AjaxLink<String> expandLink;
|
||||
|
||||
private User user;
|
||||
|
||||
private int point;
|
||||
private CustomPagingNavigator pagingNavigator;
|
||||
|
||||
public KnolPanel(String id) {
|
||||
super(id);
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer = new WebMarkupContainer("listContainer");
|
||||
listContainer.add(linkListView);
|
||||
listContainer.add(embedListView);
|
||||
listContainer.setOutputMarkupId(true);
|
||||
listContainer.add(pagingNavigator = new CustomPagingNavigator(
|
||||
"navigator", linkListView) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return linkListView.size() > 0;
|
||||
}
|
||||
});
|
||||
add(listContainer);
|
||||
}
|
||||
|
||||
public void loadListView() {
|
||||
List<LinkResource> linkList = linkResourceDao.findAll();
|
||||
Collections.sort(linkList, new Comparator<LinkResource>() {
|
||||
@Override
|
||||
public int compare(LinkResource o1, LinkResource o2) {
|
||||
return Integer.valueOf(ratableDao.getRating(o2)).compareTo(
|
||||
Integer.valueOf(ratableDao.getRating(o1)));
|
||||
}
|
||||
});
|
||||
linkListView = new PageableListView<LinkResource>("link-item",
|
||||
linkList, 20) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<LinkResource> item) {
|
||||
final LinkResource link = item.getModelObject();
|
||||
final List<Rating> ratingList = link.getRatingList();
|
||||
boolean rated = false;
|
||||
point = ratableDao.getRating(link);
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
item.add(new Label("rate", point + ""));
|
||||
item.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
link.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
linkResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(embedListView);
|
||||
listContainer.add(pagingNavigator);
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<String>("downLink", new Model<String>(
|
||||
"Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
linkResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(pagingNavigator);
|
||||
listContainer.add(embedListView);
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
item.add(new Label("date", df.format(link.getDateCreated())));
|
||||
item.add(new Label("user", link.getCreator().getFirstName()
|
||||
+ " " + link.getCreator().getLastName()));
|
||||
if (link.getLinkName() == null) {
|
||||
item.add(new ExternalLink("link", link.getLink(), link
|
||||
.getLink()));
|
||||
} else {
|
||||
item.add(new ExternalLink("link", link.getLink(), link
|
||||
.getLinkName()));
|
||||
}
|
||||
item.add(new Label("info", link.getInfo()));
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : link.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
|
||||
final int commentSize;
|
||||
if (commentThreadDao.getCommentThreadByClassAndId(link
|
||||
.getClass().getCanonicalName(), link.getId()) == null) {
|
||||
commentSize = 0;
|
||||
} else {
|
||||
commentSize = commentThreadDao
|
||||
.getCommentThreadByClassAndId(
|
||||
link.getClass().getCanonicalName(),
|
||||
link.getId()).getCommentList().size();
|
||||
}
|
||||
|
||||
item.add(new Label("tag", tags));
|
||||
item.add(LinkResourcePage.getBookmarkablePageLink("bookmark",
|
||||
link));
|
||||
final Label comment = new Label("commentNumber", commentSize
|
||||
+ " comments");
|
||||
|
||||
comment.setOutputMarkupId(true);
|
||||
|
||||
final CommentThreadPanel ctp = new CommentThreadPanel(
|
||||
"commentThread", link.getClass().getCanonicalName(),
|
||||
link.getId(), 5);
|
||||
ctp.setOutputMarkupPlaceholderTag(true);
|
||||
ctp.setVisible(false);
|
||||
item.add(ctp);
|
||||
item.add(new AjaxLink<String>("showComments",
|
||||
new Model<String>("Show Comments")) {
|
||||
|
||||
private boolean clicked = false;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
clicked = !clicked;
|
||||
if (clicked) {
|
||||
comment.setDefaultModelObject("Hide comments");
|
||||
} else {
|
||||
comment.setDefaultModelObject(+commentThreadDao
|
||||
.getCommentThreadByClassAndId(
|
||||
link.getClass().getCanonicalName(),
|
||||
link.getId()).getCommentList()
|
||||
.size()
|
||||
+ " comments");
|
||||
}
|
||||
ctp.setVisible(clicked);
|
||||
target.addComponent(ctp);
|
||||
target.addComponent(comment);
|
||||
}
|
||||
|
||||
}.add(comment));
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
List<EmbedResource> embedList = embedResourceDao.findAll();
|
||||
Collections.sort(embedList, new Comparator<EmbedResource>() {
|
||||
@Override
|
||||
public int compare(EmbedResource o1, EmbedResource o2) {
|
||||
return Integer.valueOf(ratableDao.getRating(o2)).compareTo(
|
||||
Integer.valueOf(ratableDao.getRating(o1)));
|
||||
}
|
||||
});
|
||||
embedListView = new ListView<EmbedResource>("embed-item", embedList) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<EmbedResource> item) {
|
||||
final EmbedResource link = item.getModelObject();
|
||||
final List<Rating> ratingList = link.getRatingList();
|
||||
boolean rated = false;
|
||||
point = 0;
|
||||
Rating rating = null;
|
||||
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
}
|
||||
if (r.getRatingValue() == RatingValue.UP) {
|
||||
point++;
|
||||
} else {
|
||||
point--;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
item.add(new Label("rate", point + ""));
|
||||
item.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
embedResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
link.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
embedResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(pagingNavigator);
|
||||
listContainer.add(embedListView);
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<String>("downLink", new Model<String>(
|
||||
"Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
embedResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
embedResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(pagingNavigator);
|
||||
listContainer.add(embedListView);
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
item.add(new Label("date", df.format(link.getDateCreated())));
|
||||
item.add(new Label("user", link.getCreator().getFirstName()
|
||||
+ " " + link.getCreator().getLastName()));
|
||||
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : link.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
item.add(new EmbedWebMarkupContainer("embed", link.getInfo()));
|
||||
item.add(new Label("info", link.getInfo()));
|
||||
item.add(new Label("tag", tags));
|
||||
item.add(EmbedResourcePage.getBookmarkablePageLink(
|
||||
"bookmarkEmbed", link));
|
||||
|
||||
// item.add(new FileResourcePanel("filePanel",
|
||||
// item.getModelObject()));
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id ="listContainer">
|
||||
<h2>Link Resources</h2>
|
||||
<table>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up.png" class="icon-24" alt="Up"/></a></div>
|
||||
<div class = "centered" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down.png" class="icon-24" alt="Down"/></a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><a href="#" target="_new" wicket:id="link" class="large">this body will be replaced</a></div>
|
||||
<div><strong>Info: </strong> <span wicket:id="info"></span></div>
|
||||
<div><strong>Tag/s: </strong> <span wicket:id="tag"></span></div>
|
||||
<div><strong>Created: </strong> <span wicket:id="date"></span></div>
|
||||
<div><strong>Created by: </strong> <span wicket:id="user"></span></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><hr/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,172 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RestartResponseException;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.ExternalLink;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LinkResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class LinkResourceBookmarkablePanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private LinkResourceDao linkResourceDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
private WebMarkupContainer listContainer = new WebMarkupContainer("listContainer");
|
||||
|
||||
private User user;
|
||||
|
||||
private int point;
|
||||
private LinkResource link;
|
||||
|
||||
public LinkResourceBookmarkablePanel(String id, PageParameters pp) {
|
||||
super(id);
|
||||
Long linkId = pp.getAsLong("linkres");
|
||||
if(linkId == null){
|
||||
failAndRedirect();
|
||||
}
|
||||
else {
|
||||
|
||||
link = linkResourceDao.load(linkId);
|
||||
if(link == null)
|
||||
failAndRedirect();
|
||||
}
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer.setOutputMarkupId(true);
|
||||
add(listContainer);
|
||||
// pp.put("res", link.getId());
|
||||
// new BookmarkablePageLink<Void>("up", LinkResourcePage.class, pp);
|
||||
}
|
||||
private void failAndRedirect(){
|
||||
throw new RestartResponseException(SciProApplication.get().getApplicationSettings().getAccessDeniedPage());
|
||||
}
|
||||
|
||||
|
||||
public void loadListView() {
|
||||
final List<Rating> ratingList = link.getRatingList();
|
||||
boolean rated = false;
|
||||
point = ratableDao.getRating(link);
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
listContainer.add(new Label("rate", point + ""));
|
||||
listContainer.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated && rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
link.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
linkResourceDao.save(link);
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
listContainer.add(new AjaxLink<String>("downLink", new Model<String>("Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated && rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
linkResourceDao.save(link);
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
listContainer.add(new Label("date", df.format(link.getDateCreated())));
|
||||
listContainer.add(new Label("user", link.getCreator().getFirstName() + " "
|
||||
+ link.getCreator().getLastName()));
|
||||
if (link.getLinkName() == null) {
|
||||
listContainer.add(new ExternalLink("link", link.getLink(), link.getLink()));
|
||||
} else {
|
||||
listContainer.add(new ExternalLink("link", link.getLink(), link.getLinkName()));
|
||||
}
|
||||
listContainer.add(new Label("info", link.getInfo()));
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : link.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
listContainer.add(new Label("tag", tags));
|
||||
};
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="feedbackPanel"></div>
|
||||
<div class="span-6 last">
|
||||
<form wicket:id="resourceForm">
|
||||
|
||||
<div wicket:id="editContainer">
|
||||
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Address:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="link" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Name:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tag/s:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<select wicket:id="selectedTagList" class = "span-8 last"></select>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tags:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="submit" wicket:id="submitButton" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="span-20 last">
|
||||
<div wicket:id="listContainer">
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong>Rating</strong></td>
|
||||
<td><strong>Up</strong></td>
|
||||
<td><strong>Down</strong></td>
|
||||
<td><strong>Created</strong></td>
|
||||
<td><strong>By User</strong></td>
|
||||
<td><strong>Link</strong></td>
|
||||
<td><strong>Info</strong></td>
|
||||
<td><strong>Tag/s</strong></td>
|
||||
<!-- <td><strong>File</strong></td>-->
|
||||
<td><strong>Edit</strong></td>
|
||||
<td><strong>Delete</strong></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr wicket:id = "link-item">
|
||||
<td wicket:id="rate"></td>
|
||||
<td><a href="#" wicket:id="upLink"><img src="images/icons/arrow-up.png" class="icon-24" alt="Up"/></a></td>
|
||||
<td><a href="#" wicket:id="downLink"><img src="images/icons/arrow-down.png" class="icon-24" alt="Down"/></a></td>
|
||||
<td wicket:id="date"></td>
|
||||
<td wicket:id="user"></td>
|
||||
<td><a href="#" target="_new" wicket:id="link">this body will be replaced</a></td>
|
||||
<td wicket:id="info"></td>
|
||||
<td wicket:id="tag"></td>
|
||||
<!-- <td><span wicket:id="filePanel"></span></td> -->
|
||||
<td><a href="#" wicket:id="editLink"><img src="images/icons/pencil.png" class="icon-24" alt="Edit"/></a></td>
|
||||
<td><a href="#" wicket:id="deleteLink"><img src="images/icons/circle-delete.png" class="icon-24" alt="Delete"/></a></td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,394 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
|
||||
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.form.ChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.ListMultipleChoice;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.link.ExternalLink;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.util.ListModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LinkResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Recipient;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
import se.su.dsv.scipro.knol.resource.page.EmbedWebMarkupContainer;
|
||||
import se.su.dsv.scipro.knol.resource.page.ResourceModel;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class LinkResourcePanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private ResourceDao resourceDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private LinkResourceDao linkResourceDao;
|
||||
|
||||
@SpringBean
|
||||
private TagDao tagDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
private WebMarkupContainer listContainer;
|
||||
|
||||
private ListView<LinkResource> linkListView;
|
||||
|
||||
private Collection<Tag> selectedTagList = new ArrayList<Tag>();
|
||||
|
||||
private User user;
|
||||
|
||||
private int point;
|
||||
|
||||
private boolean edit = false;
|
||||
private WebMarkupContainer editContainer;
|
||||
|
||||
private TextArea<String> info;
|
||||
private TextField<String> linkAddress, linkName, tags;
|
||||
private ListMultipleChoice<Tag> userMultipleChoiceList;
|
||||
|
||||
private LinkResource editLink;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
private ResourceModel resourceModel;
|
||||
|
||||
public LinkResourcePanel(String id) {
|
||||
super(id);
|
||||
|
||||
feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
add(feedbackPanel);
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer = new WebMarkupContainer("listContainer");
|
||||
listContainer.add(linkListView);
|
||||
listContainer.setOutputMarkupId(true);
|
||||
|
||||
add(listContainer);
|
||||
add(new LinkResourceForm("resourceForm"));
|
||||
}
|
||||
|
||||
public class LinkResourceForm extends Form<ResourceModel> {
|
||||
public LinkResourceForm(String name) {
|
||||
super(name, new CompoundPropertyModel<ResourceModel>(
|
||||
new ResourceModel()));
|
||||
editContainer = new WebMarkupContainer("editContainer");
|
||||
editContainer.setOutputMarkupId(true);
|
||||
editContainer.add(info = new TextArea<String>("info"));
|
||||
linkAddress = new TextField<String>("link");
|
||||
tags = new TextField<String>("tags");
|
||||
linkAddress.setRequired(true);
|
||||
editContainer.add(linkAddress);
|
||||
editContainer.add(tags);
|
||||
editContainer.add(linkName = new TextField<String>("linkName"));
|
||||
|
||||
userMultipleChoiceList = new ListMultipleChoice<Tag>(
|
||||
"selectedTagList", new ListModel<Tag>(tagDao.findAll()),
|
||||
new ChoiceRenderer<Tag>("tag")) {
|
||||
private static final long serialVersionUID = -7117603450416845711L;
|
||||
|
||||
@Override
|
||||
protected CharSequence getDefaultChoice(Object selected) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
OnChangeAjaxBehavior userSelectBehaviour = new OnChangeAjaxBehavior() {
|
||||
|
||||
private static final long serialVersionUID = 3412906970812300312L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
selectedTagList = userMultipleChoiceList.getModelObject();
|
||||
}
|
||||
};
|
||||
userMultipleChoiceList.add(userSelectBehaviour);
|
||||
|
||||
editContainer.add(userMultipleChoiceList);
|
||||
|
||||
editContainer.add(new AjaxButton("submitButton", new Model<String>(
|
||||
"Save Resource")) {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
LinkResource link = new LinkResource();
|
||||
ResourceModel resourceModel = ((ResourceModel) form
|
||||
.getModelObject());
|
||||
if (edit) {
|
||||
link = editLink;
|
||||
link.setLastModified(new Date());
|
||||
edit = false;
|
||||
} else {
|
||||
link = new LinkResource();
|
||||
}
|
||||
String tags = resourceModel.getTags();
|
||||
|
||||
if (tags != null) {
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(
|
||||
tags, ",");
|
||||
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
Tag tag = new Tag();
|
||||
tag.setTag(stringTokenizer.nextToken().trim());
|
||||
tag = tagDao.save(tag);
|
||||
selectedTagList.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
link.setInfo(resourceModel.getInfo());
|
||||
link.setLink(resourceModel.getLink());
|
||||
link.setCreator(user);
|
||||
link.setTagList(new ArrayList<Tag>(selectedTagList));
|
||||
if (resourceModel.getLinkName() != null) {
|
||||
link.setLinkName(resourceModel.getLinkName());
|
||||
}
|
||||
linkResourceDao.save(link);
|
||||
loadListView();
|
||||
resourceModel.setLink("");
|
||||
resourceModel.setLinkName("");
|
||||
resourceModel.setTags("");
|
||||
resourceModel.setSelectedTagList(new ArrayList<Tag>());
|
||||
resourceModel.setInfo("");
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(feedbackPanel);
|
||||
target.addComponent(listContainer);
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
});
|
||||
|
||||
add(editContainer);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadListView() {
|
||||
List<LinkResource> linkList = linkResourceDao.findAll();
|
||||
Collections.sort(linkList, new Comparator<LinkResource>() {
|
||||
@Override
|
||||
public int compare(LinkResource o1, LinkResource o2) {
|
||||
return Integer.valueOf(ratableDao.getRating(o2)).compareTo(
|
||||
Integer.valueOf(ratableDao.getRating(o1)));
|
||||
}
|
||||
});
|
||||
linkListView = new ListView<LinkResource>("link-item", linkList) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<LinkResource> item) {
|
||||
final LinkResource link = item.getModelObject();
|
||||
final List<Rating> ratingList = link.getRatingList();
|
||||
boolean rated = false;
|
||||
point = ratableDao.getRating(link);
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
final boolean finalRated = rated;
|
||||
final Rating rating2 = rating;
|
||||
item.add(new Label("rate", point + ""));
|
||||
item.add(new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
link.setRatingList(ratingList);
|
||||
rating2.setRatingValue(RatingValue.UP);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
linkResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<String>("downLink", new Model<String>(
|
||||
"Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
if (finalRated
|
||||
&& rating2.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
linkResourceDao.save(link);
|
||||
Rating rating3 = ratingDao.reLoad(rating2);
|
||||
ratingDao.delete(rating3);
|
||||
} else {
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
Rating rating3 = ratingDao.save(rating2);
|
||||
ratingList.remove(rating2);
|
||||
ratingList.add(rating3);
|
||||
}
|
||||
|
||||
linkResourceDao.save(link);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
}
|
||||
});
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
item.add(new Label("date", df.format(link.getDateCreated())));
|
||||
item.add(new Label("user", link.getCreator().getFirstName()
|
||||
+ " " + link.getCreator().getLastName()));
|
||||
if (link.getLinkName() == null) {
|
||||
item.add(new ExternalLink("link", link.getLink(), link
|
||||
.getLink()));
|
||||
} else {
|
||||
item.add(new ExternalLink("link", link.getLink(), link
|
||||
.getLinkName()));
|
||||
}
|
||||
item.add(new Label("info", link.getInfo()));
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : link.getTagList()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
item.add(new Label("tag", tags));
|
||||
|
||||
item.add(new AjaxLink<Recipient>("deleteLink") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
LinkResource link2 = linkResourceDao.reLoad(link);
|
||||
if (link2.equals(editLink)) {
|
||||
edit = false;
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
linkResourceDao.delete(link2);
|
||||
loadListView();
|
||||
listContainer.removeAll();
|
||||
listContainer.add(linkListView);
|
||||
target.addComponent(listContainer);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new AjaxLink<Recipient>("editLink") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
edit = true;
|
||||
editLink = linkResourceDao.reLoad(link);
|
||||
linkAddress.setModelObject(editLink.getLink());
|
||||
linkName.setModelObject(editLink.getLinkName());
|
||||
info.setModelObject(editLink.getInfo());
|
||||
// listChoice = new ListMultipleChoice("choices",
|
||||
// MANY_CHOICES)
|
||||
userMultipleChoiceList.setModelObject(editLink
|
||||
.getTagList());
|
||||
// userMultipleChoiceList.setModelObject(editLink
|
||||
// .getTagList());
|
||||
target.addComponent(editContainer);
|
||||
}
|
||||
|
||||
});
|
||||
// item.add(new FileResourcePanel("filePanel",
|
||||
// item.getModelObject()));
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// public void generateRatings(LinkResource resource) {
|
||||
// Resource resource1 = linkResourceDao.reLoad(resource);
|
||||
// List<Rating> ratingList = resource1.getRatingList();
|
||||
// for (Rating r : ratingList) {
|
||||
// if (r.getRatingValue() == RatingValue.UP) {
|
||||
// point++;
|
||||
// } else {
|
||||
// point--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public int getRating(LinkResource resource) {
|
||||
// Resource resource1 = linkResourceDao.reLoad(resource);
|
||||
// List<Rating> ratingList = resource1.getRatingList();
|
||||
// int ratingValue = 0;
|
||||
// for (Rating r : ratingList) {
|
||||
// if (r.getRatingValue() == RatingValue.UP) {
|
||||
// ratingValue++;
|
||||
// } else {
|
||||
// ratingValue--;
|
||||
// }
|
||||
// }
|
||||
// return ratingValue;
|
||||
// }
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
resourceForm.editContainer.link=Link Address
|
||||
Required='${label}' is required
|
@ -0,0 +1,163 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id ="listContainer">
|
||||
<h2>Resource</h2>
|
||||
<table class = "link-resource-border">
|
||||
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img wicket:id="upLinkIcon"/></a></div>
|
||||
<div class = "centered larger-rate-number" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img wicket:id="downLinkIcon" /></a></div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<a href="#" target="new" wicket:id="link" class="larger"></a>
|
||||
<span wicket:id="heading" class="larger"></span>
|
||||
<div class = "right-corner-resource">
|
||||
<div class = "resource-icon">
|
||||
<a href="#" wicket:id="editResource"><img src="images/icons/edit_16x16.png" alt="Edit" title="Edit"/></a>
|
||||
<a href="#" wicket:id="deleteResource"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</div>
|
||||
<div class = "smaller">
|
||||
<strong>Created: </strong> <span wicket:id="date"></span>
|
||||
<br/>
|
||||
<strong>Created by: </strong> <span wicket:id="user"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div><a href="#" target="new" wicket:id="linkAddress"></a></div>
|
||||
<div wicket:id="embedCode"></div>
|
||||
|
||||
|
||||
<div wicket:id="info" class = "info-resource"></div>
|
||||
|
||||
<div><strong>Tags: </strong> <span wicket:id="tag"></span></div>
|
||||
<div ><a href="#" wicket:id="bookmark">Permalink</a></div>
|
||||
|
||||
|
||||
<div><a href="#" wicket:id="showComments"><span wicket:id="commentNumber"></span></a></div>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="rating-cell"></td>
|
||||
<td colspan ="2"><div wicket:id="commentThread"></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div wicket:id="editLinkDialog">
|
||||
<div wicket:id="editLinkDialogContainer">
|
||||
<form wicket:id="editLinkResourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel">
|
||||
</div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Address:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="link" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Name:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Add tags:</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Delete tags:</strong>
|
||||
</div>
|
||||
<div wicket:id="tagListContainer" class ="span-10 last">
|
||||
<span wicket:id="tag-item">
|
||||
<span wicket:id="tagContainer">
|
||||
<span wicket:id="tag"></span>
|
||||
<a href="#" wicket:id="deleteTag"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class ="span-6 last edit-button"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div wicket:id="editEmbedDialog">
|
||||
<div wicket:id="editEmbedDialogContainer">
|
||||
<form wicket:id="editEmbedResourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel">
|
||||
</div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Heading:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Embed Code:</strong>
|
||||
</div>
|
||||
<div class ="span-8 last">
|
||||
Disclaimer: no security checks at the moment.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="embedCode" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tags:</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Delete tags:</strong>
|
||||
</div>
|
||||
<div wicket:id="tagListContainerEmbed" class ="span-10 last">
|
||||
<span wicket:id="tag-embed-item">
|
||||
<span wicket:id="tagEmbedContainer">
|
||||
<span wicket:id="tagEmbed"></span>
|
||||
<a href="#" wicket:id="deleteTagEmbed"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class ="span-6 last edit-button"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,769 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.knol.resource.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RestartResponseException;
|
||||
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.behavior.AttributeAppender;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.ListMultipleChoice;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.link.ExternalLink;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.commentthread.panel.CommentThreadPanel;
|
||||
import se.su.dsv.scipro.components.FormFeedbackPanel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CommentThreadDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Recipient;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
import se.su.dsv.scipro.knol.resource.model.ResourceModel;
|
||||
import se.su.dsv.scipro.knol.resource.page.BookmarkableResourcePage;
|
||||
import se.su.dsv.scipro.knol.resource.page.HtmlWebMarkupContainer;
|
||||
import se.su.dsv.scipro.knol.resource.page.ResourcePage;
|
||||
import se.su.dsv.scipro.knol.resource.page.StaticImage;
|
||||
import se.su.dsv.scipro.security.auth.MetaDataActionStrategy;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class ResourceBookmarkablePanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
@SpringBean
|
||||
private ResourceDao resourceDao;
|
||||
|
||||
@SpringBean
|
||||
private CommentThreadDao commentThreadDao;
|
||||
|
||||
@SpringBean
|
||||
private RatableDao ratableDao;
|
||||
|
||||
private WebMarkupContainer listContainer = new WebMarkupContainer(
|
||||
"listContainer");
|
||||
|
||||
private User user;
|
||||
@SpringBean
|
||||
private TagDao tagDao;
|
||||
private int point;
|
||||
private Resource resource;
|
||||
private WebMarkupContainer editLinkDialogContainer,
|
||||
editEmbedDialogContainer;
|
||||
private Dialog editLinkDialog, editEmbedDialog;
|
||||
private Resource editResource;
|
||||
private ListMultipleChoice<Tag> userMultipleChoiceList;
|
||||
private TextField<String> linkAddress;
|
||||
private TextField<String> linkName;
|
||||
private TextArea<String> info, embedTextArea;
|
||||
private EditLinkResourceForm editLinkResourceForm;
|
||||
private EditEmbedResourceForm editEmbedResourceForm;
|
||||
|
||||
public ResourceBookmarkablePanel(String id, PageParameters pp) {
|
||||
super(id);
|
||||
Long resId = pp.getAsLong("res");
|
||||
if (resId == null) {
|
||||
failAndRedirect();
|
||||
} else {
|
||||
|
||||
resource = resourceDao.load(resId);
|
||||
if (resource == null)
|
||||
failAndRedirect();
|
||||
}
|
||||
user = userDao.load(SciProSession.get().getUser().getId());
|
||||
loadListView();
|
||||
listContainer.setOutputMarkupId(true);
|
||||
add(listContainer);
|
||||
editLinkDialogContainer = new WebMarkupContainer(
|
||||
"editLinkDialogContainer");
|
||||
editLinkDialog = new Dialog("editLinkDialog");
|
||||
editLinkDialog.setModal(true);
|
||||
editLinkDialog.setAutoOpen(false);
|
||||
editLinkDialog.setWidth(470);
|
||||
editLinkDialog.add(editLinkDialogContainer);
|
||||
editLinkDialogContainer.setOutputMarkupId(true);
|
||||
editLinkDialogContainer
|
||||
.add(editLinkResourceForm = new EditLinkResourceForm(
|
||||
"editLinkResourceForm"));
|
||||
add(editLinkDialog);
|
||||
|
||||
editEmbedDialogContainer = new WebMarkupContainer(
|
||||
"editEmbedDialogContainer");
|
||||
editEmbedDialog = new Dialog("editEmbedDialog");
|
||||
editEmbedDialog.setModal(true);
|
||||
editEmbedDialog.setAutoOpen(false);
|
||||
editEmbedDialog.setWidth(470);
|
||||
editEmbedDialog.add(editEmbedDialogContainer);
|
||||
editEmbedDialogContainer.setOutputMarkupId(true);
|
||||
editEmbedDialogContainer
|
||||
.add(editEmbedResourceForm = new EditEmbedResourceForm(
|
||||
"editEmbedResourceForm"));
|
||||
add(editEmbedDialog);
|
||||
}
|
||||
|
||||
private void failAndRedirect() {
|
||||
throw new RestartResponseException(SciProApplication.get()
|
||||
.getApplicationSettings().getAccessDeniedPage());
|
||||
}
|
||||
|
||||
public void loadListView() {
|
||||
resource = resourceDao.reLoad(resource);
|
||||
|
||||
new AddRateButton(resource);
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
listContainer.add(new Label("date",
|
||||
df.format(resource.getDateCreated())));
|
||||
listContainer.add(new Label("user", resource.getCreator()
|
||||
.getFirstName() + " " + resource.getCreator().getLastName()));
|
||||
|
||||
if (resource.getHeading() == null) {
|
||||
listContainer.add(new ExternalLink("link", resource.getLink(),
|
||||
resource.getLink()) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return resource.getEmbedCode() == null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
listContainer.add(new ExternalLink("link", resource.getLink(),
|
||||
resource.getHeading()) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return resource.getEmbedCode() == null;
|
||||
}
|
||||
});
|
||||
}
|
||||
listContainer.add(new ExternalLink("linkAddress", resource.getLink(),
|
||||
resource.getLink()) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return resource.getEmbedCode() == null;
|
||||
}
|
||||
});
|
||||
|
||||
listContainer.add(new Label("info", resource.getInfo()));
|
||||
String tags = "";
|
||||
|
||||
int count = 0;
|
||||
for (Tag tag : resource.getTagSet()) {
|
||||
if (count == 0) {
|
||||
tags = tag.getTag();
|
||||
count++;
|
||||
} else {
|
||||
tags += ", " + tag.getTag();
|
||||
}
|
||||
}
|
||||
|
||||
final int commentSize;
|
||||
if (commentThreadDao.getCommentThreadByClassAndId(resource.getClass()
|
||||
.getCanonicalName(), resource.getId()) == null) {
|
||||
commentSize = 0;
|
||||
} else {
|
||||
commentSize = commentThreadDao
|
||||
.getCommentThreadByClassAndId(
|
||||
resource.getClass().getCanonicalName(),
|
||||
resource.getId()).getCommentList().size();
|
||||
}
|
||||
|
||||
listContainer.add(new Label("tag", tags));
|
||||
listContainer.add(BookmarkableResourcePage.getBookmarkablePageLink(
|
||||
"bookmark", resource));
|
||||
String comments = " Comments";
|
||||
if (commentSize == 1) {
|
||||
comments = " Comment";
|
||||
}
|
||||
final Label comment = new Label("commentNumber", commentSize + comments);
|
||||
|
||||
comment.setOutputMarkupId(true);
|
||||
|
||||
final CommentThreadPanel ctp = new CommentThreadPanel("commentThread",
|
||||
resource.getClass().getCanonicalName(), resource.getId(), 5);
|
||||
ctp.setOutputMarkupPlaceholderTag(true);
|
||||
ctp.setVisible(false);
|
||||
listContainer.add(ctp);
|
||||
listContainer.add(new AjaxLink<String>("showComments",
|
||||
new Model<String>("Show Comments")) {
|
||||
|
||||
private boolean clicked = false;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
clicked = !clicked;
|
||||
if (clicked) {
|
||||
comment.setDefaultModelObject("Hide comments");
|
||||
} else {
|
||||
|
||||
int commentSize = commentThreadDao
|
||||
.getCommentThreadByClassAndId(
|
||||
resource.getClass().getCanonicalName(),
|
||||
resource.getId()).getCommentList().size();
|
||||
String comments = " Comments";
|
||||
if (commentSize == 1) {
|
||||
comments = " Comment";
|
||||
}
|
||||
comment.setDefaultModelObject(commentThreadDao
|
||||
.getCommentThreadByClassAndId(
|
||||
resource.getClass().getCanonicalName(),
|
||||
resource.getId()).getCommentList().size()
|
||||
+ comments);
|
||||
}
|
||||
ctp.setVisible(clicked);
|
||||
target.addComponent(ctp);
|
||||
target.addComponent(comment);
|
||||
}
|
||||
|
||||
}.add(comment));
|
||||
listContainer.add(new Label("heading", resource.getHeading()){
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return resource.getEmbedCode() != null;
|
||||
}
|
||||
});
|
||||
listContainer.add(new HtmlWebMarkupContainer("embedCode", resource
|
||||
.getEmbedCode()) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return resource.getEmbedCode() != null;
|
||||
}
|
||||
|
||||
});
|
||||
listContainer.add(new AjaxLink<Recipient>("deleteResource") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Resource link2 = resourceDao.reLoad(resource);
|
||||
resourceDao.delete(link2);
|
||||
setResponsePage(ResourcePage.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
Resource link2 = resourceDao.reLoad(resource);
|
||||
if (link2.getCreator().equals(
|
||||
userDao.load(SciProSession.get().getUser().getId()))) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
MetaDataActionStrategy.authorize(this, Roles.ADMIN, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
listContainer.add(new AjaxLink<Recipient>("editResource") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
editResource = resourceDao.reLoad(resource);
|
||||
if (resource.getEmbedCode() == null) {
|
||||
info.setDefaultModelObject(editResource.getInfo());
|
||||
editLinkResourceForm.loadTagView(editResource);
|
||||
linkAddress.setDefaultModelObject(editResource
|
||||
.getLink());
|
||||
linkName.setDefaultModelObject(editResource
|
||||
.getHeading());
|
||||
target.addComponent(editLinkDialog);
|
||||
editLinkDialog.open(target);
|
||||
} else {
|
||||
linkName.setDefaultModelObject(editResource
|
||||
.getHeading());
|
||||
info.setDefaultModelObject(editResource.getInfo());
|
||||
editEmbedResourceForm.loadTagView(editResource);
|
||||
embedTextArea.setDefaultModelObject(editResource
|
||||
.getEmbedCode());
|
||||
target.addComponent(editEmbedDialog);
|
||||
editEmbedDialog.open(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
Resource link2 = resourceDao.reLoad(resource);
|
||||
if (link2.getCreator().equals(
|
||||
userDao.load(SciProSession.get().getUser().getId()))) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
MetaDataActionStrategy.authorize(this, Roles.ADMIN, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
private class AddRateButton implements IClusterable {
|
||||
|
||||
private AjaxLink<String> ajaxLinkUp, ajaxLinkDown;
|
||||
|
||||
public AddRateButton(Resource resource) {
|
||||
super();
|
||||
addRateButton(resource);
|
||||
}
|
||||
|
||||
public void addRateButton(final Resource resource) {
|
||||
|
||||
final StaticImage upArrowIcon = new StaticImage("upLinkIcon",
|
||||
new Model<String>("../../images/icons/arrow-up.png"));
|
||||
upArrowIcon.add(new AttributeAppender("class", new Model<String>(
|
||||
"icon-32"), " "));
|
||||
upArrowIcon.add(new AttributeAppender("alt",
|
||||
new Model<String>("up"), " "));
|
||||
final StaticImage upArrowGlowIcon = new StaticImage("upLinkIcon",
|
||||
new Model<String>("../../images/icons/arrow-up-glow.png"));
|
||||
upArrowGlowIcon.add(new AttributeAppender("class",
|
||||
new Model<String>("icon-32"), " "));
|
||||
upArrowGlowIcon.add(new AttributeAppender("alt", new Model<String>(
|
||||
"up"), " "));
|
||||
final StaticImage downArrowIcon = new StaticImage("downLinkIcon",
|
||||
new Model<String>("../../images/icons/arrow-down.png"));
|
||||
downArrowIcon.add(new AttributeAppender("class", new Model<String>(
|
||||
"icon-32"), " "));
|
||||
downArrowIcon.add(new AttributeAppender("alt", new Model<String>(
|
||||
"down"), " "));
|
||||
final StaticImage downArrowGlowIcon = new StaticImage(
|
||||
"downLinkIcon", new Model<String>(
|
||||
"../../images/icons/arrow-down-glow.png"));
|
||||
downArrowGlowIcon.add(new AttributeAppender("class",
|
||||
new Model<String>("icon-32"), " "));
|
||||
downArrowGlowIcon.add(new AttributeAppender("alt",
|
||||
new Model<String>("down"), " "));
|
||||
|
||||
final Label pointLabel;
|
||||
listContainer.add(pointLabel = new Label("rate", ratableDao
|
||||
.getRating(resource) + ""));
|
||||
pointLabel.setOutputMarkupId(true);
|
||||
ajaxLinkUp = new AjaxLink<String>("upLink", new Model<String>("Up")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Resource resourc = resourceDao.reLoad(resource);
|
||||
List<Rating> ratingList = resourc.getRatingList();
|
||||
boolean rated = false;
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
this.removeAll();
|
||||
if (rated && rating.getRatingValue() == RatingValue.UP) {
|
||||
ratingList.remove(rating);
|
||||
resource.setRatingList(ratingList);
|
||||
resourceDao.save(resource);
|
||||
rating = ratingDao.reLoad(rating);
|
||||
ratingDao.delete(rating);
|
||||
add(upArrowIcon);
|
||||
} else {
|
||||
resource.setRatingList(ratingList);
|
||||
rating.setRatingValue(RatingValue.UP);
|
||||
rating = ratingDao.save(rating);
|
||||
ratingList.add(rating);
|
||||
ajaxLinkDown.removeAll();
|
||||
ajaxLinkDown.add(downArrowIcon);
|
||||
add(upArrowGlowIcon);
|
||||
|
||||
}
|
||||
resourc = resourceDao.save(resourc);
|
||||
point = ratableDao.getRating(resourc);
|
||||
target.addComponent(this);
|
||||
target.addComponent(ajaxLinkDown);
|
||||
pointLabel.setDefaultModelObject(point);
|
||||
target.addComponent(pointLabel);
|
||||
}
|
||||
|
||||
};
|
||||
if (isRated(RatingValue.UP, resource))
|
||||
ajaxLinkUp.add(upArrowGlowIcon);
|
||||
else
|
||||
ajaxLinkUp.add(upArrowIcon);
|
||||
listContainer.add(ajaxLinkUp);
|
||||
ajaxLinkUp.setOutputMarkupId(true);
|
||||
|
||||
ajaxLinkDown = new AjaxLink<String>("downLink", new Model<String>(
|
||||
"Down")) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Resource resourc = resourceDao.reLoad(resource);
|
||||
List<Rating> ratingList = resourc.getRatingList();
|
||||
boolean rated = false;
|
||||
Rating rating = null;
|
||||
for (Rating r : ratingList) {
|
||||
if (r.getUser().equals(user)) {
|
||||
rating = r;
|
||||
rated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rating == null) {
|
||||
rating = new Rating();
|
||||
rating.setUser(user);
|
||||
}
|
||||
removeAll();
|
||||
if (rated && rating.getRatingValue() == RatingValue.DOWN) {
|
||||
ratingList.remove(rating);
|
||||
resource.setRatingList(ratingList);
|
||||
resourceDao.save(resourc);
|
||||
rating = ratingDao.reLoad(rating);
|
||||
ratingDao.delete(rating);
|
||||
add(downArrowIcon);
|
||||
|
||||
} else {
|
||||
rating.setRatingValue(RatingValue.DOWN);
|
||||
rating = ratingDao.save(rating);
|
||||
ratingList.add(rating);
|
||||
add(downArrowGlowIcon);
|
||||
ajaxLinkUp.removeAll();
|
||||
ajaxLinkUp.add(upArrowIcon);
|
||||
}
|
||||
|
||||
resourc = resourceDao.save(resourc);
|
||||
point = ratableDao.getRating(resourc);
|
||||
pointLabel.setDefaultModelObject(point);
|
||||
target.addComponent(pointLabel);
|
||||
target.addComponent(this);
|
||||
target.addComponent(ajaxLinkUp);
|
||||
}
|
||||
};
|
||||
ajaxLinkDown.setOutputMarkupId(true);
|
||||
if (isRated(RatingValue.DOWN, resource))
|
||||
ajaxLinkDown.add(downArrowGlowIcon);
|
||||
|
||||
else
|
||||
ajaxLinkDown.add(downArrowIcon);
|
||||
listContainer.add(ajaxLinkDown);
|
||||
|
||||
}
|
||||
|
||||
public boolean isRated(RatingValue ratingValue, Resource resource) {
|
||||
for (Rating r : resource.getRatingList()) {
|
||||
if (r.getUser().equals(user)) {
|
||||
if (r.getRatingValue().equals(ratingValue)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class EditLinkResourceForm extends Form<ResourceModel> {
|
||||
|
||||
private ListView<Tag> tagListView;
|
||||
private List<Tag> tagList;
|
||||
private WebMarkupContainer tagListContainer;
|
||||
|
||||
public EditLinkResourceForm(String name) {
|
||||
super(name, new CompoundPropertyModel<ResourceModel>(
|
||||
new ResourceModel()));
|
||||
final WebMarkupContainer feedbackContainer = new WebMarkupContainer("feedbackContainer");
|
||||
feedbackContainer.setOutputMarkupId(true);
|
||||
WebMarkupContainer feedbackPanel = new FormFeedbackPanel<ResourceModel>("feedbackPanel", this);
|
||||
feedbackContainer.add(feedbackPanel);
|
||||
add(feedbackContainer);
|
||||
loadTagView(editResource);
|
||||
tagListContainer = new WebMarkupContainer("tagListContainer");
|
||||
tagListContainer.setOutputMarkupId(true);
|
||||
add(tagListContainer);
|
||||
tagListContainer.add(tagListView);
|
||||
editLinkDialog.setTitle("Edit Link Resource");
|
||||
|
||||
|
||||
|
||||
linkAddress = new TextField<String>("link");
|
||||
|
||||
final TextField<String> tags = new TextField<String>("tags");
|
||||
linkAddress.setRequired(true);
|
||||
add(linkAddress);
|
||||
add(linkName = new TextField<String>("linkName"));
|
||||
linkName.setRequired(true);
|
||||
add(info = new TextArea<String>("info"));
|
||||
info.setRequired(true);
|
||||
add(tags);
|
||||
tags.setRequired(true);
|
||||
|
||||
|
||||
|
||||
add(new AjaxButton("submitButton", new Model<String>(
|
||||
"Save Resource")) {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
editResource = resourceDao.reLoad(editResource);
|
||||
Resource link = editResource;
|
||||
ResourceModel resourceModel = ((ResourceModel) form
|
||||
.getModelObject());
|
||||
|
||||
String tags = resourceModel.getTags();
|
||||
if (tags != null) {
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(
|
||||
tags, ",");
|
||||
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
String tagString = stringTokenizer.nextToken()
|
||||
.trim();
|
||||
if (null != tagDao.findExactTagQuery(tagString)) {
|
||||
tagList.add(tagDao.findExactTagQuery(tagString));
|
||||
} else if (!tagString.equals("")) {
|
||||
Tag tag = new Tag();
|
||||
tagString = tagString.toLowerCase();
|
||||
tag.setTag(tagString);
|
||||
|
||||
tag = tagDao.save(tag);
|
||||
tagList.add(tag);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
link.setInfo(resourceModel.getInfo());
|
||||
link.setLink(resourceModel.getLink());
|
||||
link.setCreator(user);
|
||||
|
||||
link.setTagSet(new HashSet<Tag>(tagList));
|
||||
link.setLastModified(new Date());
|
||||
if (resourceModel.getLinkName() != null) {
|
||||
link.setHeading(resourceModel.getLinkName());
|
||||
}
|
||||
resourceDao.save(link);
|
||||
|
||||
resourceModel.setLink("");
|
||||
resourceModel.setLinkName("");
|
||||
resourceModel.setTags("");
|
||||
resourceModel.setInfo("");
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
editLinkDialog.close(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form form) {
|
||||
target.addComponent(feedbackContainer);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loadTagView(final Resource resource) {
|
||||
final Resource resource2 = resourceDao.reLoad(resource);
|
||||
tagList = new ArrayList<Tag>();
|
||||
|
||||
if (resource2 != null) {
|
||||
tagList = new ArrayList<Tag>(resource2.getTagSet());
|
||||
tagListContainer.remove(tagListView);
|
||||
}
|
||||
|
||||
tagListView = new ListView<Tag>("tag-item", tagList) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<Tag> item) {
|
||||
final Tag tag = item.getModelObject();
|
||||
final WebMarkupContainer tagContainer = new WebMarkupContainer(
|
||||
"tagContainer");
|
||||
tagContainer.setOutputMarkupId(true);
|
||||
final Label label;
|
||||
tagContainer.add(label = new Label("tag", tag.getTag()));
|
||||
label.setOutputMarkupId(true);
|
||||
|
||||
final AjaxLink<Tag> deleteLink;
|
||||
tagContainer.add(deleteLink = new AjaxLink<Tag>("deleteTag") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
tagList.remove(tag);
|
||||
target.addComponent(tagListContainer);
|
||||
}
|
||||
});
|
||||
deleteLink.setOutputMarkupId(true);
|
||||
item.add(tagContainer);
|
||||
}
|
||||
};
|
||||
if (resource2 != null) {
|
||||
tagListContainer.add(tagListView);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EditEmbedResourceForm extends Form<ResourceModel> {
|
||||
|
||||
private ListView<Tag> tagListView;
|
||||
private List<Tag> tagList;
|
||||
private WebMarkupContainer tagListContainer;
|
||||
|
||||
public EditEmbedResourceForm(String name) {
|
||||
super(name, new CompoundPropertyModel<ResourceModel>(
|
||||
new ResourceModel()));
|
||||
final WebMarkupContainer feedbackContainer = new WebMarkupContainer("feedbackContainer");
|
||||
feedbackContainer.setOutputMarkupId(true);
|
||||
WebMarkupContainer feedbackPanel = new FormFeedbackPanel<ResourceModel>("feedbackPanel", this);
|
||||
feedbackContainer.add(feedbackPanel);
|
||||
add(feedbackContainer);
|
||||
loadTagView(editResource);
|
||||
tagListContainer = new WebMarkupContainer("tagListContainerEmbed");
|
||||
tagListContainer.setOutputMarkupId(true);
|
||||
add(tagListContainer);
|
||||
tagListContainer.add(tagListView);
|
||||
editEmbedDialog.setTitle("Edit Embed Resource");
|
||||
add(linkName = new TextField<String>("linkName"));
|
||||
linkName.setRequired(true);
|
||||
add(embedTextArea = new TextArea<String>("embedCode"));
|
||||
embedTextArea.setRequired(true);
|
||||
add(info = new TextArea<String>("info"));
|
||||
info.setRequired(true);
|
||||
final TextField<String> tags = new TextField<String>("tags");
|
||||
tags.setRequired(true);
|
||||
add(tags);
|
||||
|
||||
add(new AjaxButton("submitButton", new Model<String>(
|
||||
"Save Resource")) {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
editResource = resourceDao.reLoad(editResource);
|
||||
Resource link = editResource;
|
||||
ResourceModel resourceModel = ((ResourceModel) form
|
||||
.getModelObject());
|
||||
|
||||
String tags = resourceModel.getTags();
|
||||
if (tags != null) {
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(
|
||||
tags, ",");
|
||||
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
String tagString = stringTokenizer.nextToken()
|
||||
.trim();
|
||||
if (null != tagDao.findExactTagQuery(tagString)) {
|
||||
tagList.add(tagDao.findExactTagQuery(tagString));
|
||||
} else if (!tagString.equals("")) {
|
||||
Tag tag = new Tag();
|
||||
tagString = tagString.toLowerCase();
|
||||
tag.setTag(tagString);
|
||||
|
||||
tag = tagDao.save(tag);
|
||||
tagList.add(tag);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
link.setHeading(resourceModel.getLinkName());
|
||||
link.setEmbedCode(resourceModel.getEmbedCode());
|
||||
link.setInfo(resourceModel.getInfo());
|
||||
link.setCreator(user);
|
||||
link.setTagSet(new HashSet<Tag>(tagList));
|
||||
|
||||
link.setLastModified(new Date());
|
||||
if (resourceModel.getLinkName() != null) {
|
||||
link.setHeading(resourceModel.getLinkName());
|
||||
}
|
||||
resourceDao.save(link);
|
||||
|
||||
resourceModel.setLink("");
|
||||
resourceModel.setLinkName("");
|
||||
resourceModel.setTags("");
|
||||
resourceModel.setInfo("");
|
||||
listContainer.removeAll();
|
||||
loadListView();
|
||||
target.addComponent(listContainer);
|
||||
editEmbedDialog.close(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form form) {
|
||||
target.addComponent(feedbackContainer);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loadTagView(final Resource resource) {
|
||||
final Resource resource2 = resourceDao.reLoad(resource);
|
||||
tagList = new ArrayList<Tag>();
|
||||
|
||||
if (resource2 != null) {
|
||||
tagList = new ArrayList<Tag>(resource2.getTagSet());
|
||||
tagListContainer.remove(tagListView);
|
||||
}
|
||||
|
||||
tagListView = new ListView<Tag>("tag-embed-item", tagList) {
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<Tag> item) {
|
||||
final Tag tag = item.getModelObject();
|
||||
final WebMarkupContainer tagContainer = new WebMarkupContainer(
|
||||
"tagEmbedContainer");
|
||||
tagContainer.setOutputMarkupId(true);
|
||||
tagContainer.add(new Label("tagEmbed", tag.getTag()));
|
||||
tagContainer.add(new AjaxLink<Tag>("deleteTagEmbed") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
tagList.remove(tag);
|
||||
target.addComponent(tagListContainer);
|
||||
}
|
||||
});
|
||||
item.add(tagContainer);
|
||||
}
|
||||
};
|
||||
if (resource2 != null) {
|
||||
tagListContainer.add(tagListView);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
src/main/java/se/su/dsv/scipro/knol/resource/panels/ResourceBookmarkablePanel.properties
Normal file
10
src/main/java/se/su/dsv/scipro/knol/resource/panels/ResourceBookmarkablePanel.properties
Normal file
@ -0,0 +1,10 @@
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.link=Link Address
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.linkName=Link Name
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.info=Info
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.tags=Tags
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.linkName=Heading
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.embedCode=Embed Code
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.info=Info
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.tags=Tags
|
||||
Required='${label}' is required
|
||||
|
@ -0,0 +1,245 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
|
||||
|
||||
<h2>Resources</h2>
|
||||
<div><a href="#" wicket:id="addLinkResource">Add Link Resource</a></div>
|
||||
<div><a href="#" wicket:id="addEmbedResource">Add Embed Resource</a></div>
|
||||
<div wicket:id="listContainer">
|
||||
<table wicket:id = "link-item" class = "link-resource-border">
|
||||
|
||||
<tr>
|
||||
<td class="rating-cell">
|
||||
<div class = "centered" ><a href="#" wicket:id="upLink"><img wicket:id="upLinkIcon"/></a></div>
|
||||
<div class = "centered larger-rate-number" wicket:id="rate"></div>
|
||||
<div class = "centered" ><a href="#" wicket:id="downLink"><img wicket:id="downLinkIcon" /></a></div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<a href="#" target="new" wicket:id="link" class="larger"></a>
|
||||
<span wicket:id="heading" class="larger"></span>
|
||||
<div class = "right-corner-resource">
|
||||
<div class = "resource-icon">
|
||||
<a href="#" wicket:id="editResource"><img src="images/icons/edit_16x16.png" " alt="Edit" title="Edit"/></a>
|
||||
<a href="#" wicket:id="deleteResource"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</div>
|
||||
<div class = "smaller">
|
||||
<strong>Created: </strong> <span wicket:id="date"></span>
|
||||
<br/>
|
||||
<strong>Created by: </strong> <span wicket:id="user"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div><a href="#" target="new" wicket:id="linkAddress"></a></div>
|
||||
<div wicket:id="embedCode"></div>
|
||||
|
||||
|
||||
|
||||
<div wicket:id="info" class = "info-resource"></div>
|
||||
|
||||
<div><strong>Tags: </strong> <span wicket:id="tag"></span></div>
|
||||
<div ><a href="#" wicket:id="bookmark">Permalink</a></div>
|
||||
|
||||
|
||||
<div><a href="#" wicket:id="showComments"><span wicket:id="commentNumber"></span></a></div>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="rating-cell"></td>
|
||||
<td colspan ="2"><div wicket:id="commentThread"></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div wicket:id ="navigator"></div>
|
||||
</div>
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="dialogContainer">
|
||||
<form wicket:id="resourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel">
|
||||
</div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Address:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="link" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Name:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tags:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div wicket:id="embedDialog">
|
||||
<div wicket:id="embedDialogContainer">
|
||||
<form wicket:id="embedResourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel"></div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Heading:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Embed Code:</strong>
|
||||
</div>
|
||||
<div class ="span-8 last">
|
||||
Disclaimer: no security checks at the moment.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="embedCode" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tags:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div wicket:id="editLinkDialog">
|
||||
<div wicket:id="editLinkDialogContainer">
|
||||
<form wicket:id="editLinkResourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel"></div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Address:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="link" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Link Name:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Tags:</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Delete tags:</strong>
|
||||
</div>
|
||||
<div wicket:id="tagListContainer" class ="span-6 last">
|
||||
<span wicket:id="tag-item">
|
||||
<span wicket:id="tagContainer">
|
||||
<span wicket:id="tag"></span>
|
||||
<a href="#" wicket:id="deleteTag"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class ="span-6 last edit-button"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div wicket:id="editEmbedDialog">
|
||||
<div wicket:id="editEmbedDialogContainer">
|
||||
<form wicket:id="editEmbedResourceForm">
|
||||
<div wicket:id="feedbackContainer">
|
||||
<div class ="span-6 last" wicket:id="feedbackPanel"></div>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Heading:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="linkName" class ="span-6"/>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Embed Code:</strong>
|
||||
</div>
|
||||
<div class ="span-8 last">
|
||||
Disclaimer: no security checks at the moment.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="embedCode" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Info:</strong>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<textarea wicket:id="info" ></textarea>
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Add tags:</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class ="span-6 last">
|
||||
Separate by comma.
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<input type="text" wicket:id="tags" class ="span-6" />
|
||||
</div>
|
||||
<div class ="span-6 last">
|
||||
<strong>Delete tags:</strong>
|
||||
</div>
|
||||
<div wicket:id="tagListContainerEmbed" class ="span-10 last">
|
||||
<span wicket:id="tag-embed-item">
|
||||
<span wicket:id="tagEmbedContainer">
|
||||
<span wicket:id="tagEmbed"></span>
|
||||
<a href="#" wicket:id="deleteTagEmbed"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class ="span-6 last edit-button"><input type="submit" wicket:id="submitButton" /> </div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,18 @@
|
||||
|
||||
dialog.dialogContainer.resourceForm.link=Link Address
|
||||
dialog.dialogContainer.resourceForm.linkName=Link Name
|
||||
dialog.dialogContainer.resourceForm.info=Info
|
||||
dialog.dialogContainer.resourceForm.tags=Tags
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.link=Link Address
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.linkName=Link Name
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.info=Info
|
||||
editLinkDialog.editLinkDialogContainer.editLinkResourceForm.tags=Tags
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.linkName=Heading
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.embedCode=Embed Code
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.info=Info
|
||||
editEmbedDialog.editEmbedDialogContainer.editEmbedResourceForm.tags=Tags
|
||||
embedDialog.embedDialogContainer.embedResourceForm.linkName=Heading
|
||||
embedDialog.embedDialogContainer.embedResourceForm.embedCode=Embed Code
|
||||
embedDialog.embedDialogContainer.embedResourceForm.info=Info
|
||||
embedDialog.embedDialogContainer.embedResourceForm.tags=Tags
|
||||
Required='${label}' is required
|
Loading…
x
Reference in New Issue
Block a user