001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://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 * Returns the default explorer switch action for explorer list dialogs.<p> 057 * 058 * @return the default explorer switch action 059 */ 060 public static CmsListIndependentAction getDefaultExplorerSwitchAction() { 061 062 CmsListIndependentAction defAction = new CmsListIndependentAction(ACTION_EXPLORER_SWITCH_ID); 063 defAction.setName(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_NAME_0)); 064 defAction.setHelpText(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_HELP_0)); 065 defAction.setConfirmationMessage(Messages.get().container(Messages.GUI_LIST_ACTION_EXPLORER_SWITCH_CONF_0)); 066 defAction.setIconPath("list/explorer.png"); 067 defAction.setEnabled(true); 068 defAction.setVisible(true); 069 return defAction; 070 } 071 072 /** 073 * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#buttonHtml(CmsWorkplace) 074 */ 075 public String buttonHtml(CmsWorkplace wp) { 076 077 if (!isVisible()) { 078 return ""; 079 } 080 return A_CmsHtmlIconButton.defaultButtonHtml( 081 CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT, 082 getId(), 083 getName().key(wp.getLocale()), 084 getHelpText().key(wp.getLocale()), 085 isEnabled(), 086 getIconPath(), 087 null, 088 resolveOnClic(wp)); 089 } 090 091 /** 092 * Help method to resolve the on clic text to use.<p> 093 * 094 * @param wp the workplace context 095 * 096 * @return the on clic text 097 */ 098 protected String resolveOnClic(CmsWorkplace wp) { 099 100 return "listIndepAction('" 101 + getListId() 102 + "','" 103 + getId() 104 + "', '" 105 + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale()))) 106 + "');"; 107 } 108}