1 /*** 2 * Copyright (C) 2008 Jeremy Thomerson (jthomerson@users.sourceforge.net) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package net.sf.vcaperture.web; 18 19 import net.sf.vcaperture.model.IApplicationContext; 20 import net.sf.vcaperture.util.spring.ApplicationContextFactory; 21 import net.sf.vcaperture.web.components.StaticImage; 22 import net.sf.vcaperture.web.models.CapitalizeEveryLetterModel; 23 import net.sf.vcaperture.web.panels.BreadCrumbsPanel; 24 import net.sf.vcaperture.web.panels.FooterBar; 25 import net.sf.vcaperture.web.urls.ViewDirectoryLink; 26 27 import org.apache.wicket.behavior.HeaderContributor; 28 import org.apache.wicket.markup.html.WebMarkupContainer; 29 import org.apache.wicket.markup.html.WebPage; 30 import org.apache.wicket.markup.html.basic.Label; 31 import org.apache.wicket.markup.html.link.BookmarkablePageLink; 32 import org.apache.wicket.model.IModel; 33 import org.apache.wicket.model.Model; 34 import org.apache.wicket.model.PropertyModel; 35 import org.apache.wicket.model.StringResourceModel; 36 37 /*** 38 * The base page for all web pages within the application. 39 * 40 * @author Jeremy Thomerson (jthomerson@users.sourceforge.net) 41 */ 42 public abstract class ApertureBasePage extends WebPage { 43 44 private static final long serialVersionUID = 1L; 45 46 protected static final String COMPONENT_NAME_PAGE_TITLE = "pageTitle"; 47 48 public ApertureBasePage() { 49 constructComponentsInternal(); 50 } 51 52 public ApertureBasePage(IModel model) { 53 super(model); 54 constructComponentsInternal(); 55 } 56 57 private void constructComponentsInternal() { 58 add(new Label(COMPONENT_NAME_PAGE_TITLE, new StringResourceModel("page.title", this, new Model(this)))); 59 add(HeaderContributor.forCss("/resources/styles/global.css")); 60 add(createHeader()); 61 add(createSubheader()); 62 add(new FooterBar("footer")); 63 } 64 65 private WebMarkupContainer createSubheader() { 66 WebMarkupContainer cont = new WebMarkupContainer("subheader"); 67 PropertyModel projectNameModel = new PropertyModel(this, "project"); 68 ViewDirectoryLink vdl = new ViewDirectoryLink("project", projectNameModel, new Model("")); 69 vdl.add(new Label("project", projectNameModel)); 70 cont.add(vdl); 71 cont.add(new BreadCrumbsPanel("relativePath", projectNameModel, new PropertyModel(this, "relativePath"))); 72 return cont; 73 } 74 75 private WebMarkupContainer createHeader() { 76 WebMarkupContainer header = new WebMarkupContainer("header"); 77 BookmarkablePageLink home = new BookmarkablePageLink("home", getApplication().getHomePage()); 78 home.add(new StaticImage("logo", new StringResourceModel("app.logo", this, null))); 79 home.add(new Label("title", new CapitalizeEveryLetterModel(new StringResourceModel("app.title", this, null))).setRenderBodyOnly(true)); 80 header.add(home); 81 return header; 82 } 83 84 public ApertureWebApp getWebApp() { 85 return (ApertureWebApp) getApplication(); 86 } 87 88 public IApplicationContext getContext() { 89 return ApplicationContextFactory.getFactory().getContext(); 90 } 91 92 public String getProject() { 93 return null; 94 } 95 96 public String getRelativePath() { 97 return null; 98 } 99 }