use of org.apache.wicket.model.LoadableDetachableModel in project hale by halestudio.
the class WelcomePage method addControls.
@Override
protected void addControls(boolean loggedIn) {
super.addControls(loggedIn);
// create a model which loads the list of war bundles dynamically
IModel<List<BundleInfo>> listViewModel = new LoadableDetachableModel<List<BundleInfo>>() {
private static final long serialVersionUID = 8919477639656535497L;
@Override
protected List<BundleInfo> load() {
// get context paths of other war bundles
List<BundleInfo> wars = new ArrayList<BundleInfo>();
Activator aa = Activator.getInstance();
DefaultContextPathStrategy s = new DefaultContextPathStrategy();
for (Bundle b : aa.getWarBundles()) {
if (isHidden(b)) {
continue;
}
BundleInfo bi = new BundleInfo();
bi.name = getHumanReadableName(b);
bi.path = s.getContextPath(b);
wars.add(bi);
}
// sort list
Collections.sort(wars, new Comparator<BundleInfo>() {
@Override
public int compare(BundleInfo o1, BundleInfo o2) {
return o1.name.compareTo(o2.name);
}
});
return wars;
}
};
// fill list view
ListView<BundleInfo> lv = new ListView<BundleInfo>("applications", listViewModel) {
private static final long serialVersionUID = -3861139762631118268L;
@Override
protected void populateItem(ListItem<BundleInfo> item) {
BundleInfo bi = item.getModelObject();
item.add(new ExternalLink("path", bi.path, bi.name));
}
};
add(lv);
}
use of org.apache.wicket.model.LoadableDetachableModel in project the-app by devops-dojo.
the class FeedbackPanel method wrapperContainer.
private Component wrapperContainer() {
WebMarkupContainer wrapperContainer = new WebMarkupContainer("wrapperContainer");
wrapperContainer.add(feedbackPanel());
wrapperContainer.add(new AttributeAppender("class", new LoadableDetachableModel<String>() {
@Override
protected String load() {
if (feedbackPanel.anyMessage(FeedbackMessage.ERROR)) {
return "alert-danger";
}
if (feedbackPanel.anyMessage(FeedbackMessage.SUCCESS)) {
return "alert-success";
}
if (feedbackPanel.anyMessage(FeedbackMessage.INFO)) {
return "alert-info";
}
return "";
}
}, " "));
return wrapperContainer;
}
use of org.apache.wicket.model.LoadableDetachableModel in project webanno by webanno.
the class CurationPage method getAllowedProjects.
private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {
private static final long serialVersionUID = -2518743298741342852L;
@Override
protected List<DecoratedObject<Project>> load() {
User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
List<Project> projectsWithFinishedAnnos = projectService.listProjectsWithFinishedAnnos();
for (Project project : projectService.listProjects()) {
if (SecurityUtil.isCurator(project, projectService, user)) {
DecoratedObject<Project> dp = DecoratedObject.of(project);
if (projectsWithFinishedAnnos.contains(project)) {
dp.setColor("green");
} else {
dp.setColor("red");
}
allowedProject.add(dp);
}
}
return allowedProject;
}
};
}
use of org.apache.wicket.model.LoadableDetachableModel in project webanno by webanno.
the class CorrectionPage method getAllowedProjects.
private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {
private static final long serialVersionUID = -2518743298741342852L;
@Override
protected List<DecoratedObject<Project>> load() {
User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
for (Project project : projectService.listProjects()) {
if (SecurityUtil.isAnnotator(project, projectService, user) && WebAnnoConst.PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
allowedProject.add(DecoratedObject.of(project));
}
}
return allowedProject;
}
};
}
use of org.apache.wicket.model.LoadableDetachableModel in project wicket by apache.
the class EnhancedPageView method newTree.
private AbstractTree<TreeNode> newTree() {
TreeProvider provider = new TreeProvider();
IModel<Set<TreeNode>> expandStateModel = new LoadableDetachableModel<Set<TreeNode>>() {
private static final long serialVersionUID = 1L;
@Override
protected Set<TreeNode> load() {
return expandState;
}
};
AbstractTree<TreeNode> tree = new DefaultTableTree<TreeNode, Void>("tree", visibleColumns, provider, Integer.MAX_VALUE, expandStateModel) {
private static final long serialVersionUID = 1L;
@Override
protected Item<TreeNode> newRowItem(String id, int index, IModel<TreeNode> model) {
return new OddEvenItem<>(id, index, model);
}
};
tree.setOutputMarkupId(true);
return tree;
}
Aggregations