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.unusedcontentfinder; 029 030import org.opencms.main.CmsLog; 031import org.opencms.ui.A_CmsUI; 032import org.opencms.ui.apps.A_CmsWorkplaceApp; 033import org.opencms.ui.apps.CmsFileExplorer; 034import org.opencms.ui.apps.I_CmsAppUIContext; 035import org.opencms.ui.apps.Messages; 036import org.opencms.ui.components.CmsComponentState; 037import org.opencms.util.CmsStringUtil; 038 039import java.util.LinkedHashMap; 040import java.util.List; 041 042import org.apache.commons.logging.Log; 043 044import com.vaadin.server.Sizeable.Unit; 045import com.vaadin.ui.Component; 046import com.vaadin.ui.HorizontalSplitPanel; 047 048/** 049 * Vaadin app to find unused contents.<p> 050 */ 051public class CmsUnusedContentFinderApp extends A_CmsWorkplaceApp { 052 053 /** The log object for this class. */ 054 static final Log LOG = CmsLog.getLog(CmsUnusedContentFinderApp.class); 055 056 /** The unused content finder composite. */ 057 private CmsUnusedContentFinderComposite m_unusedContentFinderComposite; 058 059 /** 060 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext) 061 */ 062 @Override 063 public void initUI(I_CmsAppUIContext context) { 064 065 context.addPublishButton(changed -> { 066 if (m_unusedContentFinderComposite != null) { 067 m_unusedContentFinderComposite.search(false); 068 } 069 }); 070 super.initUI(context); 071 } 072 073 /** 074 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getBreadCrumbForState(java.lang.String) 075 */ 076 @Override 077 protected LinkedHashMap<String, String> getBreadCrumbForState(String state) { 078 079 LinkedHashMap<String, String> crumbs = new LinkedHashMap<>(); 080 crumbs.put( 081 "", 082 Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_UNUSED_CONTENT_FINDER_TITLE_0)); 083 return crumbs; 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 m_rootLayout.setMainHeightFull(true); 093 HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); 094 splitPanel.setSizeFull(); 095 m_unusedContentFinderComposite = new CmsUnusedContentFinderComposite(); 096 splitPanel.setFirstComponent(m_unusedContentFinderComposite.getFormComponent()); 097 splitPanel.setSecondComponent(m_unusedContentFinderComposite.getResultComponent()); 098 splitPanel.setSplitPosition(CmsFileExplorer.LAYOUT_SPLIT_POSITION, Unit.PIXELS); 099 m_infoLayout.addComponent(m_unusedContentFinderComposite.getResultFilterComponent()); 100 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(state)) { 101 CmsComponentState componentState = new CmsComponentState(state); 102 m_unusedContentFinderComposite.setState(componentState); 103 m_unusedContentFinderComposite.search(false); 104 } 105 return splitPanel; 106 } 107 108 /** 109 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String) 110 */ 111 @Override 112 protected List<NavEntry> getSubNavEntries(String state) { 113 114 return null; 115 } 116}