initial commit

This commit is contained in:
Athou
2013-03-20 20:33:42 +01:00
commit 7b3c53fcb9
82 changed files with 3346 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="utf-8">
</head>
<body>
<wicket:child />
</body>
</html>

View File

@@ -0,0 +1,19 @@
package com.commafeed.frontend.pages;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebPage;
import com.commafeed.frontend.components.auth.Role;
import de.agilecoders.wicket.Bootstrap;
@AuthorizeInstantiation(Role.USER)
public abstract class BasePage extends WebPage {
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
Bootstrap.renderHead(response);
}
}

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div wicket:id="tree"></div>
</div>
<div class="span10">
<div wicket:id="entries"></div>
</div>
</div>
</div>
</wicket:extend>
</body>
</html>

View File

@@ -0,0 +1,115 @@
package com.commafeed.frontend.pages.feed;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import com.commafeed.backend.dao.FeedCategoryService;
import com.commafeed.backend.dao.FeedSubscriptionService;
import com.commafeed.frontend.CommaFeedSession;
import com.commafeed.frontend.components.CssTreeView;
import com.commafeed.frontend.components.CssTreeView.ITreeProvider;
import com.commafeed.frontend.pages.BasePage;
import com.commafeed.frontend.utils.ModelFactory.MF;
import com.commafeed.frontend.utils.stateless.StatelessAjaxLink;
import com.commafeed.model.FeedCategory;
import com.commafeed.model.FeedSubscription;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
public class FeedViewPage extends BasePage {
@Inject
FeedSubscriptionService feedSubscriptionService;
@Inject
FeedCategoryService feedCategoryService;
public FeedViewPage() {
add(newTree("tree"));
add(new Label("entries", Model.of("")));
}
private Component newTree(String markupId) {
ITreeProvider<FeedCategory, FeedSubscription> provider = new ITreeProvider<FeedCategory, FeedSubscription>() {
private List<FeedCategory> cats;
private List<FeedSubscription> subsWithoutCategory;
private void init() {
if (cats == null) {
cats = feedCategoryService.findAll(CommaFeedSession.get()
.getUser());
}
if (subsWithoutCategory == null) {
subsWithoutCategory = feedSubscriptionService.findByField(
MF.i(MF.p(FeedSubscription.class).getCategory()),
null);
}
}
@Override
public Collection<FeedCategory> getChildren(final FeedCategory node) {
init();
return Lists.newArrayList(Collections2.filter(cats,
new Predicate<FeedCategory>() {
@Override
public boolean apply(FeedCategory cat) {
return (node == null && cat.getParent() == null)
|| (cat.getParent() != null
&& node != null && cat
.getParent().getId() == node
.getId());
}
}));
}
@Override
public Collection<FeedSubscription> getLeaves(FeedCategory node) {
init();
if (node == null) {
return subsWithoutCategory;
}
return node.getSubscriptions();
}
@Override
public IModel<String> getChildLabel(FeedCategory node) {
return Model.of(node.getName());
}
@Override
public IModel<FeedSubscription> model(FeedSubscription object) {
return Model.of(object);
}
@Override
public void detach() {
cats = null;
}
};
return new CssTreeView<FeedCategory, FeedSubscription>(markupId,
provider) {
@Override
protected Component newLink(String markupId,
final IModel<FeedSubscription> model) {
return new StatelessAjaxLink<Void>(markupId) {
@Override
public void onClick(AjaxRequestTarget target) {
System.out.println(model.getObject().getId());
}
}.setBody(Model.of(model.getObject().getTitle()));
}
};
}
}

View File

@@ -0,0 +1,7 @@
package com.commafeed.frontend.pages.home;
import com.commafeed.frontend.pages.BasePage;
public class HomePage extends BasePage {
}