001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.devutils;
018
019import org.apache.wicket.devutils.debugbar.DebugBar;
020import org.apache.wicket.markup.head.CssHeaderItem;
021import org.apache.wicket.markup.head.IHeaderResponse;
022import org.apache.wicket.markup.html.WebPage;
023import org.apache.wicket.markup.html.debug.PageView;
024import org.apache.wicket.model.IModel;
025import org.apache.wicket.request.mapper.parameter.PageParameters;
026import org.apache.wicket.request.resource.CssResourceReference;
027
028/**
029 * All pages in the wicket-devutils package should extend this page so that they automatically get
030 * checked to make sure that the utilities are enabled in the application debug settings.
031 * 
032 * @author Jeremy Thomerson
033 */
034public class DevUtilsPage extends WebPage
035{
036        private static final long serialVersionUID = 1L;
037
038        /**
039         * Construct.
040         */
041        public DevUtilsPage()
042        {
043                super();
044        }
045
046        /**
047         * Construct.
048         * 
049         * @param model
050         */
051        public DevUtilsPage(final IModel<?> model)
052        {
053                super(model);
054        }
055
056        /**
057         * Construct.
058         * 
059         * @param parameters
060         */
061        public DevUtilsPage(final PageParameters parameters)
062        {
063                super(parameters);
064        }
065
066        @Override
067        protected void onInitialize() {
068                super.onInitialize();
069
070                add(new DebugBar("debug"));
071        }
072
073        @Override
074        protected void onBeforeRender()
075        {
076                super.onBeforeRender();
077                DevelopmentUtilitiesNotEnabledException.check();
078        }
079        
080        @Override
081        public void renderHead(IHeaderResponse response)
082        {
083                super.renderHead(response);
084                response.render(
085                        CssHeaderItem.forReference(new CssResourceReference(PageView.class, "pageview.css")));
086        }
087}