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.annotations.*; 017import org.apache.tapestry5.corelib.base.AbstractInternalPage; 018import org.apache.tapestry5.http.TapestryHttpSymbolConstants; 019import org.apache.tapestry5.ioc.annotations.Inject; 020import org.apache.tapestry5.ioc.annotations.Symbol; 021import org.apache.tapestry5.services.dashboard.DashboardManager; 022 023/** 024 * @see org.apache.tapestry5.services.dashboard.DashboardManager 025 * @since 5.4 026 */ 027@UnknownActivationContextCheck(false) 028@WhitelistAccessOnly 029@ContentType("text/html") 030@Import(stylesheet = "dashboard.css") 031public class T5Dashboard extends AbstractInternalPage 032{ 033 @Inject 034 @Symbol(TapestryHttpSymbolConstants.TAPESTRY_VERSION) 035 @Property 036 private String frameworkVersion; 037 038 @Property 039 @Inject 040 @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE) 041 private boolean productionMode; 042 043 @Inject 044 @Property 045 private DashboardManager dashboardManager; 046 047 @Property 048 private String tabName; 049 050 private String activeTab; 051 052 public String getTabClass() 053 { 054 return tabName.equalsIgnoreCase(activeTab) ? "active" : null; 055 } 056 057 public Block getContent() 058 { 059 return dashboardManager.getTabContent(activeTab); 060 } 061 062 void onActivate() 063 { 064 activeTab = dashboardManager.getTabNames().get(0); 065 } 066 067 boolean onActivate(String tabName) 068 { 069 activeTab = tabName; 070 071 return true; 072 } 073 074 String onPassivate() 075 { 076 return activeTab; 077 } 078}