001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.corelib.pages; 014 015import org.apache.tapestry5.Block; 016import org.apache.tapestry5.SymbolConstants; 017import org.apache.tapestry5.annotations.*; 018import org.apache.tapestry5.corelib.base.AbstractInternalPage; 019import org.apache.tapestry5.http.TapestryHttpSymbolConstants; 020import org.apache.tapestry5.ioc.annotations.Inject; 021import org.apache.tapestry5.ioc.annotations.Symbol; 022import org.apache.tapestry5.services.dashboard.DashboardManager; 023 024/** 025 * @see org.apache.tapestry5.services.dashboard.DashboardManager 026 * @since 5.4 027 */ 028@UnknownActivationContextCheck(false) 029@WhitelistAccessOnly 030@ContentType("text/html") 031@Import(stylesheet = "dashboard.css") 032public class T5Dashboard extends AbstractInternalPage 033{ 034 @Inject 035 @Symbol(SymbolConstants.TAPESTRY_VERSION) 036 @Property 037 private String frameworkVersion; 038 039 @Property 040 @Inject 041 @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE) 042 private boolean productionMode; 043 044 @Inject 045 @Property 046 private DashboardManager dashboardManager; 047 048 @Property 049 private String tabName; 050 051 private String activeTab; 052 053 public String getTabClass() 054 { 055 return tabName.equalsIgnoreCase(activeTab) ? "active" : null; 056 } 057 058 public Block getContent() 059 { 060 return dashboardManager.getTabContent(activeTab); 061 } 062 063 void onActivate() 064 { 065 activeTab = dashboardManager.getTabNames().get(0); 066 } 067 068 boolean onActivate(String tabName) 069 { 070 activeTab = tabName; 071 072 return true; 073 } 074 075 String onPassivate() 076 { 077 return activeTab; 078 } 079}