001/* 002 * (C) Copyright 2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: WebActions.java 25545 2007-09-28 15:03:26Z btatar $ 020 */ 021 022package org.nuxeo.ecm.platform.ui.web.api; 023 024import java.util.List; 025 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.ecm.platform.actions.Action; 028import org.nuxeo.ecm.platform.actions.ActionContext; 029import org.nuxeo.ecm.platform.actions.ejb.ActionManager; 030 031/** 032 * Component that handles actions retrieval as well as current tab(s) selection. 033 * 034 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 035 */ 036public interface WebActions { 037 038 public static final String NULL_TAB_ID = ""; 039 040 /** 041 * The category of actions for default tabs 042 */ 043 public static final String DEFAULT_TABS_CATEGORY = "VIEW_ACTION_LIST"; 044 045 /** 046 * The category of actions for main tabs 047 * 048 * @since 5.5 049 */ 050 public static final String MAIN_TABS_CATEGORY = "MAIN_TABS"; 051 052 public static final String SUBTAB_CATEGORY_SUFFIX = "_sub_tab"; 053 054 /** 055 * Identifier of main tab for the "Documents management" area 056 * 057 * @since 5.5 058 */ 059 public static final String DOCUMENTS_MAIN_TAB_ID = "documents"; 060 061 /** 062 * Request parameter used for tab ids settings 063 * 064 * @since 5.5 065 */ 066 public static final String TAB_IDS_PARAMETER = "tabIds"; 067 068 /** 069 * Request parameter used for main tab id settings 070 * 071 * @since 5.5 072 */ 073 public static final String MAIN_TAB_ID_PARAMETER = "mainTabId"; 074 075 /** 076 * Event raised when the current tab has changed, with 2 parameters: first parameter is a String representing the 077 * tab category, and second parameter is a String representing the new tab id (or null if current tab is reset for 078 * this category). 079 * 080 * @since 5.4.2 081 */ 082 public static final String CURRENT_TAB_CHANGED_EVENT = "currentTabChanged"; 083 084 /** 085 * Event raised when the current tab is selected, with 2 parameters: first parameter is a String representing the 086 * tab category, and second parameter is a String representing the new tab id (or null if current tab is reset for 087 * this category). 088 * <p> 089 * This event is sent also when current tab did not change. 090 * 091 * @since 5.6 092 */ 093 public static final String CURRENT_TAB_SELECTED_EVENT = "currentTabSelected"; 094 095 /** 096 * Framework property to control ajaxified behaviour of document tabs. 097 * 098 * @since 5.8 099 */ 100 public static final String AJAX_TAB_PROPERTY = "nuxeo.jsf.useAjaxTabs"; 101 102 /** 103 * Returns all filtered actions for a given category and given resolution context. 104 * <p> 105 * Actions are filtered according to filters set on the actions definitions. 106 * <p> 107 * Since 5.8, the category can be a list of categories, separated by commas. 108 */ 109 List<Action> getActionsList(String category, ActionContext context); 110 111 /** 112 * Returns all filtered actions for a given category and given resolution context, creating a new context for the 113 * filters resolution. 114 * <p> 115 * Actions are filtered according to filters set on the actions definitions. 116 * <p> 117 * Since 5.8, the category can be a list of categories, separated by commas. 118 * 119 * @since 5.7 120 */ 121 List<Action> getActionsList(String category, Boolean hideUnavailableAction); 122 123 /** 124 * Returns all filtered actions for a given category and a context built with given current document context, 125 * creating a new context for the filters resolution. 126 * <p> 127 * Actions are filtered according to filters set on the actions definitions. 128 * <p> 129 * Since 5.8, the category can be a list of categories, separated by commas. 130 * 131 * @since 5.7.3 132 */ 133 List<Action> getActionsListForDocument(String category, DocumentModel document, boolean hideUnavailableAction); 134 135 /** 136 * Returns all filtered actions for a given category and given resolution context. 137 * <p> 138 * Actions are filtered according to filters set on the actions definitions. 139 * <p> 140 * Since 5.8, the category can be a list of categories, separated by commas. 141 * 142 * @since 5.7 143 */ 144 List<Action> getActionsList(String category, ActionContext context, boolean hideUnavailableAction); 145 146 /** 147 * Returns all filtered actions for a given category, creating a new context for the filters resolution. 148 * <p> 149 * Since 5.8, the category can be a list of categories, separated by commas. 150 * 151 * @see #getActionsList(String, ActionContext) 152 */ 153 List<Action> getActionsList(String category); 154 155 /** 156 * Returns all actions for a given category and given resolution context. 157 * <p> 158 * Actions are not filtered according to filters set on the actions definitions: actions that should have been 159 * removed are just marked as non-available. 160 * <p> 161 * Since 5.8, the category can be a list of categories, separated by commas. 162 * 163 * @deprecated since 5.7, use {@link #getActionsList(String, ActionContext, boolean)} 164 */ 165 @Deprecated 166 List<Action> getUnfiltredActionsList(String category, ActionContext context); 167 168 /** 169 * Returns all actions for a given category, creating a new context for the filters resolution. 170 * <p> 171 * Since 5.8, the category can be a list of categories, separated by commas. 172 * 173 * @see #getUnfiltredActionsList(String, ActionContext) 174 * @deprecated since 5.7, use {@link #getActionsList(String, ActionContext, boolean)} 175 */ 176 @Deprecated 177 List<Action> getUnfiltredActionsList(String category); 178 179 /** 180 * Returns all actions for a given category, without filtering. 181 */ 182 List<Action> getAllActions(String category); 183 184 /** 185 * Returns filtered actions for the category {@link #DEFAULT_TABS_CATEGORY} 186 */ 187 List<Action> getTabsList(); 188 189 /** 190 * Returns filtered actions for a category computed from the current tab action id and the suffix 191 * {@link #SUBTAB_CATEGORY_SUFFIX}. 192 */ 193 List<Action> getSubTabsList(); 194 195 /** 196 * Returns the current action for category {@link #DEFAULT_TABS_CATEGORY} 197 */ 198 Action getCurrentTabAction(); 199 200 /** 201 * Sets the current action for category {@link #DEFAULT_TABS_CATEGORY} 202 */ 203 void setCurrentTabAction(Action tabAction); 204 205 /** 206 * Returns the current sub tab for a category computed from the current tab action id and the suffix 207 * {@link #SUBTAB_CATEGORY_SUFFIX}. 208 */ 209 Action getCurrentSubTabAction(); 210 211 /** 212 * Sets the current sub tab for a category computed from the current tab action id and the suffix 213 * {@link #SUBTAB_CATEGORY_SUFFIX}. 214 */ 215 void setCurrentSubTabAction(Action tabAction); 216 217 /** 218 * Returns the current action id for category {@link #DEFAULT_TABS_CATEGORY} 219 */ 220 String getCurrentTabId(); 221 222 /** 223 * Sets the current action id for category {@link #DEFAULT_TABS_CATEGORY}. 224 * <p> 225 * Does nothing if tabId is null, but resets current tab for this category when using an empty string instead. 226 */ 227 void setCurrentTabId(String tabId); 228 229 /** 230 * Returns the current sub tab id for a category computed from the current tab action id and the suffix 231 * {@link #SUBTAB_CATEGORY_SUFFIX}. 232 */ 233 String getCurrentSubTabId(); 234 235 /** 236 * Sets the current sub tab id for a category computed from the current tab action id and the suffix 237 * {@link #SUBTAB_CATEGORY_SUFFIX}. 238 * <p> 239 * Does nothing if sub tab id is null, but resets current tab for this category when using an empty string instead. 240 */ 241 void setCurrentSubTabId(String tabId); 242 243 /** 244 * Resets actions resolved for category {@link #DEFAULT_TABS_CATEGORY} so that they're recomputed. Also calls 245 * {@link #resetCurrentTab()} 246 */ 247 void resetTabList(); 248 249 /** 250 * Resets current tab information (includes sub tab information) for category {@link #DEFAULT_TABS_CATEGORY}. 251 */ 252 void resetCurrentTab(); 253 254 /** 255 * Returns the current action for given category. 256 */ 257 Action getCurrentTabAction(String category); 258 259 /** 260 * Returns the current sub tab action for given parent action, computing the category from parent action id with 261 * suffix {@link #SUBTAB_CATEGORY_SUFFIX}. 262 */ 263 Action getCurrentSubTabAction(String parentActionId); 264 265 /** 266 * Sets the current action for given category. 267 * <p> 268 * If given action is null, it resets the current action for this category. 269 */ 270 void setCurrentTabAction(String category, Action tabAction); 271 272 /** 273 * Returns the current action id for given category 274 */ 275 String getCurrentTabId(String category); 276 277 /** 278 * Indicates if the current tab id is set for given category 279 * 280 * @since 5.5 281 */ 282 boolean hasCurrentTabId(String category); 283 284 /** 285 * Sets the current action for given category, with additional sub tabs. 286 */ 287 void setCurrentTabId(String category, String tabId, String... subTabIds); 288 289 /** 290 * Returns current tab ids as a string, encoded as is: CATEGORY_1:ACTION_ID_1,CATEGORY_2:ACTION_ID_2,... 291 * 292 * @since 5.4.2 293 */ 294 String getCurrentTabIds(); 295 296 /** 297 * Sets current tab ids as a String, splitting on commas ',' and parsing each action information as is: 298 * CATEGORY:ACTION_ID[:OPTIONAL_SUB_ACTION_ID[:OPTIONAL_SUB_ACTION_ID]...] 299 * <p> 300 * If category is omitted or empty, the category {@link #DEFAULT_TABS_CATEGORY} will be used (if there is no subtab 301 * information). 302 * <p> 303 * The resulting string looks like: CATEGORY_1:ACTION_ID_1,CATEGORY_2:ACTION_ID_2_SUB_ACTION_ID_2,... 304 * 305 * @since 5.4.2 306 */ 307 void setCurrentTabIds(String tabIds); 308 309 /** 310 * Resets all current tabs information. 311 * 312 * @since 5.4.2 313 */ 314 void resetCurrentTabs(); 315 316 /** 317 * Resets current tabs for given category, taking subtabs into account by resetting actions in categories computed 318 * from reset actions id with suffix {@link #SUBTAB_CATEGORY_SUFFIX}. 319 */ 320 void resetCurrentTabs(String category); 321 322 /** 323 * Calls {@link #setCurrentTabAndNavigate(DocumentModel, String)} for the current document. 324 * <p> 325 * Given action should hold the category {@link #DEFAULT_TABS_CATEGORY} 326 * 327 * @see NavigationContext#getCurrentDocument() 328 */ 329 String setCurrentTabAndNavigate(String currentTabActionId); 330 331 /** 332 * Navigate to the given document and opens the view page of the given document selecting the given tab. 333 * <p> 334 * Given action should hold the category {@link #DEFAULT_TABS_CATEGORY} 335 * 336 * @param document to document which will be shown in the view page 337 * @param currentTabActionId the tab that will be selected in the view page 338 * @return the JSF view for the given document. 339 */ 340 String setCurrentTabAndNavigate(DocumentModel document, String currentTabActionId); 341 342 /** 343 * @since 5.6 344 * @see ActionManager#checkFilter(String, ActionContext) 345 */ 346 boolean checkFilter(String filterId); 347 348 /** 349 * @since 5.7 350 * @see ActionManager#getAction(String, ActionContext, boolean) 351 */ 352 Action getAction(String actionId, boolean hideUnavailableAction); 353 354 /** 355 * Return action with given id, with context filled with given document. 356 * 357 * @since 5.7.3 358 * @see ActionManager#getAction(String, ActionContext, boolean) 359 */ 360 Action getActionForDocument(String actionId, DocumentModel document, boolean hideUnavailableAction); 361 362 /** 363 * @since 5.6 364 * @see ActionManager#getAction(String, ActionContext, boolean) 365 */ 366 Action getAction(String actionId, ActionContext context, boolean hideUnavailableAction); 367 368 /** 369 * Returns true if ajaxified behaviour of tabs is activated on the server, and if history push state is supported by 370 * browser. 371 * 372 * @since 5.8 373 * @see #AJAX_TAB_PROPERTY 374 * @see #canUseAjaxTabs() 375 */ 376 boolean useAjaxTabs(); 377 378 /** 379 * Returns true if history push state is supported by browser. 380 * 381 * @since 5.8 382 * @see #useAjaxTabs() 383 */ 384 boolean canUseAjaxTabs(); 385 386 @Deprecated 387 List<Action> getSubViewActionsList(); 388 389 /** 390 * @deprecated use {@link #setCurrentTabId()} or {@link #setCurrentTabAction(String, Action)} 391 */ 392 @Deprecated 393 void setCurrentTabAction(String currentTabActionId); 394 395 /** 396 * @deprecated since 5.4: useless, and does nothing 397 */ 398 @Deprecated 399 void selectTabAction(); 400 401 /** 402 * @deprecated should be handled by a workflow related (or at least document) action listener. 403 */ 404 @Deprecated 405 String getCurrentLifeCycleState(); 406 407 /** 408 * @deprecated since 5.4.2: useless 409 */ 410 @Deprecated 411 void setTabsList(List<Action> tabsList); 412 413 /** 414 * @deprecated since 5.4.2: useless 415 */ 416 @Deprecated 417 void setSubTabsList(List<Action> tabsList); 418 419}