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.extensions.breadcrumb.panel; 018 019import org.apache.wicket.extensions.breadcrumb.BreadCrumbLink; 020import org.apache.wicket.extensions.breadcrumb.IBreadCrumbModel; 021import org.apache.wicket.extensions.breadcrumb.IBreadCrumbParticipant; 022import org.apache.wicket.util.lang.Args; 023 024/** 025 * Bread crumb link specifically for {@link BreadCrumbPanel bread crumb panels}. It uses a 026 * {@link IBreadCrumbPanelFactory bread crumb factory} to function. 027 * 028 * @author Eelco Hillenius 029 */ 030public class BreadCrumbPanelLink extends BreadCrumbLink 031{ 032 private static final long serialVersionUID = 1L; 033 034 /** The bread crumb model. */ 035 private final IBreadCrumbModel breadCrumbModel; 036 037 /** factory for creating bread crumbs panels. */ 038 private final IBreadCrumbPanelFactory breadCrumbPanelFactory; 039 040 /** 041 * Construct. 042 * 043 * @param id 044 * The component id 045 * @param caller 046 * The calling panel which will be used to get the {@link IBreadCrumbModel bread 047 * crumb model} from. 048 * @param panelClass 049 * The class to use for creating instances. Must be of type {@link BreadCrumbPanel}, 050 * and must have constructor 051 * {@link BreadCrumbPanel#BreadCrumbPanel(String, IBreadCrumbModel)} 052 */ 053 public BreadCrumbPanelLink(final String id, final BreadCrumbPanel caller, 054 final Class<? extends BreadCrumbPanel> panelClass) 055 { 056 this(id, caller.getBreadCrumbModel(), new BreadCrumbPanelFactory(panelClass)); 057 } 058 059 /** 060 * Construct. 061 * 062 * @param id 063 * The component id 064 * @param breadCrumbModel 065 * The bread crumb model 066 * @param panelClass 067 * The class to use for creating instances. Must be of type {@link BreadCrumbPanel}, 068 * and must have constructor 069 * {@link BreadCrumbPanel#BreadCrumbPanel(String, IBreadCrumbModel)} 070 */ 071 public BreadCrumbPanelLink(final String id, final IBreadCrumbModel breadCrumbModel, 072 final Class<? extends BreadCrumbPanel> panelClass) 073 { 074 this(id, breadCrumbModel, new BreadCrumbPanelFactory(panelClass)); 075 } 076 077 /** 078 * Construct. 079 * 080 * @param id 081 * The component id 082 * @param breadCrumbModel 083 * The bread crumb model 084 * @param breadCrumbPanelFactory 085 * The factory to create bread crumb panels 086 */ 087 public BreadCrumbPanelLink(final String id, final IBreadCrumbModel breadCrumbModel, 088 final IBreadCrumbPanelFactory breadCrumbPanelFactory) 089 { 090 super(id, breadCrumbModel); 091 092 Args.notNull(breadCrumbModel, "breadCrumbModel"); 093 Args.notNull(breadCrumbPanelFactory, "breadCrumbPanelFactory"); 094 095 this.breadCrumbModel = breadCrumbModel; 096 this.breadCrumbPanelFactory = breadCrumbPanelFactory; 097 } 098 099 /** 100 * Uses the set factory for creating a new instance of {@link IBreadCrumbParticipant}. 101 * 102 * @see org.apache.wicket.extensions.breadcrumb.BreadCrumbLink#getParticipant(java.lang.String) 103 */ 104 @Override 105 protected final IBreadCrumbParticipant getParticipant(final String componentId) 106 { 107 return breadCrumbPanelFactory.create(componentId, breadCrumbModel); 108 } 109}