1 31 32 package org.opencms.workplace.list; 33 34 import org.opencms.i18n.CmsMessageContainer; 35 import org.opencms.util.CmsStringUtil; 36 import org.opencms.workplace.CmsWorkplace; 37 import org.opencms.workplace.tools.A_CmsHtmlIconButton; 38 import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum; 39 40 51 public abstract class A_CmsListSearchAction extends CmsListIndependentAction { 52 53 54 public static final String SEARCH_ACTION_ID = "search"; 55 56 57 public static final String SHOWALL_ACTION_ID = "showall"; 58 59 60 private static final CmsMessageContainer SEARCH_CONFIRMATION = new CmsMessageContainer( 61 Messages.get(), 62 Messages.GUI_LIST_ACTION_SEARCH_CONF_0); 63 64 65 private static final String SEARCH_ICON = "list/search.png"; 66 67 68 private static final CmsMessageContainer SEARCH_NAME = new CmsMessageContainer( 69 Messages.get(), 70 Messages.GUI_LIST_ACTION_SEARCH_NAME_0); 71 72 73 private static final CmsMessageContainer SHOWALL_CONFIRMATION = new CmsMessageContainer( 74 Messages.get(), 75 Messages.GUI_LIST_ACTION_SHOWALL_CONF_0); 76 77 78 private static final CmsMessageContainer SHOWALL_HELPTEXT = new CmsMessageContainer( 79 Messages.get(), 80 Messages.GUI_LIST_ACTION_SHOWALL_HELP_0); 81 82 83 private static final String SHOWALL_ICON = "list/showall.png"; 84 85 86 private static final CmsMessageContainer SHOWALL_NAME = new CmsMessageContainer( 87 Messages.get(), 88 Messages.GUI_LIST_ACTION_SHOWALL_NAME_0); 89 90 91 public final I_CmsListAction m_defaultShowAllAction; 92 93 94 private I_CmsListAction m_showAllAction = null; 95 96 99 protected A_CmsListSearchAction() { 100 101 super(SEARCH_ACTION_ID); 102 setName(SEARCH_NAME); 103 setIconPath(SEARCH_ICON); 104 setConfirmationMessage(SEARCH_CONFIRMATION); 105 setHelpText(null); 106 107 m_defaultShowAllAction = createDefaultShowAllAction(); 108 } 109 110 113 public String buttonHtml(CmsWorkplace wp) { 114 115 if (!isVisible()) { 116 return ""; 117 } 118 String onClic = "listSearchAction('" 119 + getListId() 120 + "', '" 121 + getId() 122 + "', '" 123 + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale()))) 124 + "');"; 125 return A_CmsHtmlIconButton.defaultButtonHtml( 126 wp.getJsp(), 127 CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT, 128 getId(), 129 getName().key(wp.getLocale()), 130 getHelpText().key(wp.getLocale()), 131 isEnabled(), 132 getIconPath(), 133 null, 134 onClic); 135 } 136 137 142 public I_CmsListAction getShowAllAction() { 143 144 return m_showAllAction; 145 } 146 147 150 public void setListId(String listId) { 151 152 super.setListId(listId); 153 m_defaultShowAllAction.setListId(listId); 154 } 155 156 161 public void setShowAllAction(I_CmsListAction showAllAction) { 162 163 m_showAllAction = showAllAction; 164 } 165 166 169 public void useDefaultShowAllAction() { 170 171 m_showAllAction = m_defaultShowAllAction; 172 } 173 174 179 private I_CmsListAction createDefaultShowAllAction() { 180 181 I_CmsListAction defaultShowAllAction = new CmsListIndependentAction(SHOWALL_ACTION_ID) { 182 183 186 public String buttonHtml(CmsWorkplace wp) { 187 188 if (!isVisible()) { 189 return ""; 190 } 191 String onClic = "listSearchAction('" 192 + getListId() 193 + "', '" 194 + getId() 195 + "', '" 196 + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale()))) 197 + "');"; 198 return A_CmsHtmlIconButton.defaultButtonHtml( 199 wp.getJsp(), 200 CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT, 201 getId(), 202 getName().key(wp.getLocale()), 203 getHelpText().key(wp.getLocale()), 204 isEnabled(), 205 getIconPath(), 206 null, 207 onClic); 208 } 209 }; 210 defaultShowAllAction.setName(SHOWALL_NAME); 211 defaultShowAllAction.setHelpText(SHOWALL_HELPTEXT); 212 defaultShowAllAction.setIconPath(SHOWALL_ICON); 213 defaultShowAllAction.setConfirmationMessage(SHOWALL_CONFIRMATION); 214 return defaultShowAllAction; 215 } 216 } | Popular Tags |