try {
App app = (App) getApplication();
add(new HomePageMenuPanel("homePageMenuPanel", this));
ModelContext topicsModelContext = new ModelContext();
topicsModelContext.setDomainModel(app.getDomainModel());
Topics topics = (Topics) app.getEntry("Topics");
Topic modelAndWebTopic = (Topic) topics.getTopic(MODEL_AND_WEB);
if (modelAndWebTopic != null) {
Topics modelAndWebTopicSubtopics = (Topics) modelAndWebTopic
.getSubtopics();
topicsModelContext.setEntities(modelAndWebTopicSubtopics);
} else {
topicsModelContext.setEntities(topics);
}
ViewContext topicsViewContext = new ViewContext();
topicsViewContext.setApp(app);
topicsViewContext.setContextPage(this);
topicsViewContext.setPage(this);
topicsViewContext.setWicketId("topicListPanel");
TopicListPanel topicListPanel = new TopicListPanel(
topicsModelContext, topicsViewContext);
add(topicListPanel);
ModelContext projectsModelContext = new ModelContext();
projectsModelContext.setDomainModel(app.getDomainModel());
Projects projects = (Projects) app.getEntry("Projects");
Projects approvedOrderedProjects = projects.getApprovedProjects()
.getProjectsOrderedBySequence();
projectsModelContext.setEntities(approvedOrderedProjects);
ViewContext projectsViewContext = new ViewContext();
projectsViewContext.setApp(app);
projectsViewContext.setContextPage(this);
projectsViewContext.setPage(this);
projectsViewContext.setWicketId("projectListPanel");
ProjectListPanel projectListPanel = new ProjectListPanel(
projectsModelContext, projectsViewContext);
add(projectListPanel);
ModelContext infoModelContext = new ModelContext();
infoModelContext.setDomainModel(app.getDomainModel());
Infos infos = (Infos) app.getEntry("Infos");
Infos orderedInfos = infos.getInfosOrderedByCreationDate(false);
Info lastInfo = (Info) orderedInfos.first();
infoModelContext.setEntity(lastInfo);
ViewContext infoViewContext = new ViewContext();
infoViewContext.setApp(app);
infoViewContext.setContextPage(this);
infoViewContext.setPage(this);
infoViewContext.setWicketId("lastInfoPanel");
Panel lastInfoMinPanel;
if (lastInfo != null) {
lastInfoMinPanel = new EntityDisplayMinPanel(infoModelContext,
infoViewContext);
} else {
lastInfoMinPanel = new Panel("lastInfoPanel");
lastInfoMinPanel.setVisible(false);
}
add(lastInfoMinPanel);
ModelContext blogEntriesModelContext = new ModelContext();
blogEntriesModelContext.setDomainModel(app.getDomainModel());
Users users = (Users) app.getEntry("Users");
Blogs allApprovedBlogs = users.getAllApprovedBlogs();
Entries allApprovedEntries = allApprovedBlogs
.getAllApprovedEntries();
if (allApprovedEntries != null) {
Entries selectedEntries = allApprovedEntries.getLastEntries(3);
blogEntriesModelContext.setEntities(selectedEntries);
} else {
blogEntriesModelContext.setEntities(allApprovedEntries);
}
ViewContext blogEntriesViewContext = new ViewContext();
blogEntriesViewContext.setApp(app);
blogEntriesViewContext.setContextPage(this);
blogEntriesViewContext.setPage(this);
blogEntriesViewContext.setWicketId("entryListPanel");
EntryListPanel blogEntryListPanel = new EntryListPanel(
blogEntriesModelContext, blogEntriesViewContext);
add(blogEntryListPanel);
if (allApprovedEntries == null) {
blogEntryListPanel.setVisible(false);
}
ModelContext quotesModelContext = new ModelContext();
quotesModelContext.setDomainModel(app.getDomainModel());
Quotes quotes = (Quotes) app.getEntry("Quotes");
quotesModelContext.setEntities(quotes);
ViewContext quotesViewContext = new ViewContext();
quotesViewContext.setApp(app);
quotesViewContext.setContextPage(this);
quotesViewContext.setPage(this);
quotesViewContext.setWicketId("quoteListPanel");
QuoteListPanel quoteListPanel = new QuoteListPanel(
quotesModelContext, quotesViewContext);
add(quoteListPanel);
ModelContext conceptsModelContext = new ModelContext();
conceptsModelContext.setDomainModel(app.getDomainModel());
Models models = (Models) app.getEntry("Models");
Model model = (Model) models.last();
Concepts concepts = null;
if (model != null) {
concepts = model.getConcepts();
}
conceptsModelContext.setEntities(concepts);
ViewContext conceptsViewContext = new ViewContext();
conceptsViewContext.setApp(app);
conceptsViewContext.setContextPage(this);
conceptsViewContext.setPage(this);
conceptsViewContext.setWicketId("conceptListPanel");
ConceptListPanel conceptListPanel = new ConceptListPanel(
conceptsModelContext, conceptsViewContext);
if (model == null) {
conceptListPanel.setVisible(false);
}
add(conceptListPanel);
ModelContext presentationSlideListModelContext = new ModelContext();
presentationSlideListModelContext.setDomainModel(app
.getDomainModel());
Presentations presentations = (Presentations) app
.getEntry("Presentations");
Presentations orderedPresentations = presentations
.getPresentationsOrderedByTitle();
presentationSlideListModelContext.setEntities(orderedPresentations);
presentationSlideListModelContext.setPropertyCode("title");
String sectionTitle = getLocalizer()
.getString("sectionTitle", this);
presentationSlideListModelContext.getMoreArgs().add("sectionTitle",
sectionTitle);
presentationSlideListModelContext.getMoreArgs().add(
"childNeighbor", "slides");
presentationSlideListModelContext.getMoreArgs().add(
"childProperty", "title");
ViewContext presentationSlideListViewContext = new ViewContext();
presentationSlideListViewContext.setApp(app);
presentationSlideListViewContext