001// Copyright 2013 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry5.corelib.pages; 016 017import org.apache.tapestry5.Block; 018import org.apache.tapestry5.SymbolConstants; 019import org.apache.tapestry5.annotations.*; 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(stack = "core", stylesheet = "dashboard.css") 032public class T5Dashboard 033{ 034 @Inject 035 @Symbol(SymbolConstants.TAPESTRY_VERSION) 036 @Property 037 private String frameworkVersion; 038 039 @Property 040 @Inject 041 @Symbol(SymbolConstants.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}