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.debugbar;
018
019import org.apache.wicket.Component;
020import org.apache.wicket.Page;
021import org.apache.wicket.devutils.inspector.InspectorPage;
022import org.apache.wicket.model.IModel;
023import org.apache.wicket.model.Model;
024import org.apache.wicket.request.mapper.parameter.PageParameters;
025import org.apache.wicket.request.resource.PackageResourceReference;
026import org.apache.wicket.request.resource.ResourceReference;
027
028/**
029 * A panel that adds a link to the inspector to the debug bar.
030 * 
031 * @author Jeremy Thomerson
032 */
033public class InspectorDebugPanel extends StandardDebugPanel
034{
035        private static final long serialVersionUID = 1L;
036
037        /** */
038        public static final IDebugBarContributor DEBUG_BAR_CONTRIB = new IDebugBarContributor()
039        {
040                private static final long serialVersionUID = 1L;
041
042                @Override
043                public Component createComponent(final String id, final DebugBar debugBar)
044                {
045                        return new InspectorDebugPanel(id);
046                }
047
048        };
049
050        /**
051         * Construct.
052         * 
053         * @param id
054         *          The component id
055         */
056        public InspectorDebugPanel(final String id)
057        {
058                super(id);
059        }
060
061        @Override
062        protected Class<? extends Page> getLinkPageClass()
063        {
064                return InspectorPage.class;
065        }
066
067        @Override
068        protected ResourceReference getImageResourceReference()
069        {
070                return new PackageResourceReference(InspectorPage.class, "bug.png");
071        }
072
073        @Override
074        protected IModel<String> getDataModel()
075        {
076                return new Model<>("Inspector");
077        }
078
079        @Override
080        protected PageParameters getLinkPageParameters()
081        {
082                PageParameters params = new PageParameters();
083                params.add("pageId", getPage().getId());
084                return params;
085        }
086}