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.inspector;
018
019import org.apache.wicket.Application;
020import org.apache.wicket.Page;
021import org.apache.wicket.PageReference;
022import org.apache.wicket.Session;
023import org.apache.wicket.devutils.DevUtilsPage;
024import org.apache.wicket.markup.html.basic.Label;
025import org.apache.wicket.markup.html.image.Image;
026import org.apache.wicket.markup.html.link.BookmarkablePageLink;
027import org.apache.wicket.model.IModel;
028import org.apache.wicket.request.mapper.parameter.PageParameters;
029import org.apache.wicket.request.resource.PackageResourceReference;
030
031
032/**
033 * A page that shows interesting attributes of the Wicket environment, including the current session
034 * and the component tree for the current page.
035 * 
036 * @author Jonathan Locke
037 */
038public final class InspectorPage extends DevUtilsPage
039{
040        private static final long serialVersionUID = 1L;
041
042        /**
043         * Constructor.
044         * 
045         * @param parameters
046         *            The page id of any page to be analyzed
047         */
048        public InspectorPage(final PageParameters parameters)
049        {
050                this(new PageReference(parameters.get("pageId").toInt()));
051        }
052
053        public InspectorPage(PageReference reference)
054        {
055                add(new ApplicationView("application", Application.get()));
056                add(new SessionView("session", Session.get()));
057                
058                IModel<Page> page = () -> {
059                        return reference.getPage();
060                };
061                
062                add(new EnhancedPageView("page", page));
063                add(new Image("bug", new PackageResourceReference(InspectorPage.class, "bug.png")));
064                add(new BookmarkablePageLink<>("allsessions", LiveSessionsPage.class));
065                add(new Label("wicketVersion", getApplication().getFrameworkSettings().getVersion()));
066        }
067
068        /**
069         * @see org.apache.wicket.Component#isVersioned()
070         */
071        @Override
072        public boolean isVersioned()
073        {
074                return false;
075        }
076}