001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps.cacheadmin; 029 030import org.opencms.ui.CmsVaadinUtils; 031import org.opencms.ui.apps.A_CmsWorkplaceApp; 032import org.opencms.ui.apps.Messages; 033import org.opencms.util.CmsStringUtil; 034 035import java.util.LinkedHashMap; 036import java.util.List; 037 038import com.vaadin.ui.Component; 039import com.vaadin.ui.Panel; 040import com.vaadin.ui.themes.ValoTheme; 041import com.vaadin.v7.ui.HorizontalLayout; 042import com.vaadin.v7.ui.VerticalLayout; 043 044/** 045 * Vaadin app for Cache Administration.<p> 046 * Functions: view flex and image caches, flush cashes.<p> 047 */ 048public class CmsCacheAdminApp extends A_CmsWorkplaceApp { 049 050 /**Width of the progressbars to show current memory usage.*/ 051 static final String PROGRESSBAR_WIDTH = "200px"; 052 053 /**width of the statistic info boxes.*/ 054 static final String STATISTIC_INFOBOX_WIDTH = "300px"; 055 056 /** 057 * Panel with java statistics.<p> 058 * 059 * @return vaadin component. 060 */ 061 public static Panel getJavaCacheStatsPanel() { 062 063 Panel java = new Panel(); 064 java.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_JAVA_HEAP_0)); 065 java.setContent(CmsCacheViewApp.getJavaStatisticButton().getInfoLayout()); 066 return java; 067 } 068 069 /** 070 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getBreadCrumbForState(java.lang.String) 071 */ 072 @Override 073 protected LinkedHashMap<String, String> getBreadCrumbForState(String state) { 074 075 LinkedHashMap<String, String> crumbs = new LinkedHashMap<String, String>(); 076 077 // Check if state is empty -> start 078 if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) { 079 crumbs.put("", CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_ADMIN_TOOL_NAME_SHORT_0)); 080 return crumbs; 081 } 082 083 return new LinkedHashMap<String, String>(); //size==1 & state was not empty -> state doesn't match to known path 084 } 085 086 /** 087 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getComponentForState(java.lang.String) 088 */ 089 @Override 090 protected Component getComponentForState(String state) { 091 092 if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) { 093 m_rootLayout.setMainHeightFull(false); 094 return getStartComponent(); 095 } 096 097 return null; 098 } 099 100 /** 101 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String) 102 */ 103 @Override 104 protected List<NavEntry> getSubNavEntries(String state) { 105 106 return null; 107 108 } 109 110 /** 111 * Creates the component to be shown on accessing the app with some statistical information about the caches.<p> 112 * 113 * @return a vaadin vertical layout component 114 */ 115 private Component getStartComponent() { 116 117 VerticalLayout outerouter = new VerticalLayout(); 118 VerticalLayout outer = new VerticalLayout(); 119 outer.setSizeUndefined(); 120 HorizontalLayout layout = new HorizontalLayout(); 121 122 layout.setMargin(true); 123 layout.setSpacing(true); 124 layout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); 125 126 //Statistic about heap space 127 128 layout.addComponent(getJavaCacheStatsPanel()); 129 130 Panel flex = new Panel(); 131 // flex.setWidth("400px"); 132 flex.setContent(CmsCacheViewApp.getFlexStatisticButton().getInfoLayout()); 133 134 flex.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEX_0)); 135 136 HorizontalLayout flush = new HorizontalLayout(); 137 138 flush.addComponent(new CmsFlushCache()); 139 flush.setMargin(true); 140 141 layout.addComponent(flex); 142 143 outer.addComponent(flush); 144 outer.addComponent(layout); 145 outerouter.addStyleName("o-center"); 146 outerouter.addComponent(outer); 147 return outerouter; 148 } 149}