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 GmbH & Co. KG, 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.workplace.list; 029 030import org.opencms.util.CmsStringUtil; 031import org.opencms.workplace.CmsWorkplace; 032import org.opencms.workplace.tools.A_CmsHtmlIconButton; 033import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum; 034 035/** 036 * Default implementation of a independent action for a html list.<p> 037 * 038 * @since 6.0.0 039 */ 040public class CmsListIndependentAction extends A_CmsListAction { 041 042 /** List independent action id constant. */ 043 public static final String ACTION_EXPLORER_SWITCH_ID = "iaes"; 044 045 /** 046 * Default Constructor.<p> 047 * 048 * @param id unique id 049 */ 050 public CmsListIndependentAction(String id) { 051 052 super(id); 053 } 054 055 /** 056 * Help method to resolve the on clic text to use.<p> 057 * 058 * @param wp the workplace context 059 * 060 * @return the on clic text 061 */ 062 protected String resolveOnClic(CmsWorkplace wp) { 063 064 return "listIndepAction('" 065 + getListId() 066 + "','" 067 + getId() 068 + "', '" 069 + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale()))) 070 + "');"; 071 } 072 073 /** 074 * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#buttonHtml(CmsWorkplace) 075 */ 076 public String buttonHtml(CmsWorkplace wp) { 077 078 if (!isVisible()) { 079 return ""; 080 } 081 return A_CmsHtmlIconButton.defaultButtonHtml( 082 CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT, 083 getId(), 084 getName().key(wp.getLocale()), 085 getHelpText().key(wp.getLocale()), 086 isEnabled(), 087 getIconPath(), 088 null, 089 resolveOnClic(wp)); 090 } 091 092 /** 093 * Returns the default explorer switch action for explorer list dialogs.<p> 094 * 095 * @return the default explorer switch action 096 */ 097 public static CmsListIndependentAction getDefaultExplorerSwitchAction() { 098 099 CmsListIndependentAction defAction = new CmsListIndependentAction(ACTION_EXPLORER_SWITCH_ID); 100 defAction.setName(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_NAME_0)); 101 defAction.setHelpText(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_HELP_0)); 102 defAction.setConfirmationMessage(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_CONF_0)); 103 defAction.setIconPath("list/explorer.png"); 104 defAction.setEnabled(true); 105 defAction.setVisible(true); 106 return defAction; 107 } 108}