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.Page; 020import org.apache.wicket.devutils.DevUtilsPanel; 021import org.apache.wicket.markup.html.WebMarkupContainer; 022import org.apache.wicket.markup.html.basic.Label; 023import org.apache.wicket.markup.html.image.Image; 024import org.apache.wicket.markup.html.link.BookmarkablePageLink; 025import org.apache.wicket.model.IModel; 026import org.apache.wicket.request.mapper.parameter.PageParameters; 027import org.apache.wicket.request.resource.ResourceReference; 028 029/** 030 * A standard looking debug panel with an img (optional) and a string of data, and the whole thing 031 * is a link. 032 * 033 * @author Jeremy Thomerson 034 */ 035public abstract class StandardDebugPanel extends DevUtilsPanel 036{ 037 private static final long serialVersionUID = 1L; 038 039 /** 040 * Construct. 041 * 042 * @param id 043 */ 044 public StandardDebugPanel(final String id) 045 { 046 super(id); 047 } 048 049 @Override 050 protected void onInitialize() 051 { 052 super.onInitialize(); 053 WebMarkupContainer link = createLink("link"); 054 add(link); 055 ResourceReference img = getImageResourceReference(); 056 if (img == null) 057 { 058 link.add(new WebMarkupContainer("img").setVisibilityAllowed(false)); 059 } 060 else 061 { 062 link.add(new Image("img", img)); 063 } 064 link.add(new Label("data", getDataModel())); 065 } 066 067 protected WebMarkupContainer createLink(final String id) 068 { 069 return new BookmarkablePageLink<>(id, getLinkPageClass(), getLinkPageParameters()); 070 } 071 072 protected abstract IModel<String> getDataModel(); 073 074 protected abstract ResourceReference getImageResourceReference(); 075 076 protected abstract Class<? extends Page> getLinkPageClass(); 077 078 protected PageParameters getLinkPageParameters() 079 { 080 return new PageParameters(); 081 } 082}