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 * Return actions in given document context for given category. 104 * 105 * @param removeFiltered: if true, do not return filtered actions. Useful to display filtered actions as disabled 106 * (by using using value false). 107 * @param postFilter: if true, do not filter actions. Actions will need to be filtered or disabled at render time. 108 * Useful to filter actions when filtering context is available at render time only (for instance when 109 * displaying actions in listings inside a JSF iteration done at render time). 110 * @since 8.2 111 */ 112 List<Action> getDocumentActions(DocumentModel document, String category, boolean removeFiltered, 113 boolean postFilter); 114 115 /** 116 * Return action in given document context for given id. 117 * <p> 118 * Returns null if action is not found or filtered (depending on additional parameters). 119 * 120 * @param removeFiltered: if true, do not return filtered actions. Useful to display filtered actions as disabled 121 * (by using using value false). 122 * @param postFilter: if true, do not filter actions. Actions will need to be filtered or disabled at render time. 123 * Useful to filter actions when filtering context is available at render time only (for instance when 124 * displaying actions in listings inside a JSF iteration done at render time). 125 * @since 8.2 126 */ 127 Action getDocumentAction(DocumentModel document, String actionId, boolean includeFiltered, boolean postFilter); 128 129 /** 130 * Return actions in given action context for given category. 131 * 132 * @param removeFiltered: if true, do not return filtered actions. Useful to display filtered actions as disabled 133 * (by using using value false). 134 * @param postFilter: if true, do not filter actions. Actions will need to be filtered or disabled at render time. 135 * Useful to filter actions when filtering context is available at render time only (for instance when 136 * displaying actions in listings inside a JSF iteration done at render time). 137 * @since 8.2 138 */ 139 List<Action> getActions(ActionContext context, String category, boolean includeFiltered, boolean postFilter); 140 141 /** 142 * Return action in given action context for given id. 143 * <p> 144 * Returns null if action is not found or filtered (depending on additional parameters). 145 * 146 * @param removeFiltered: if true, do not return filtered actions. Useful to display filtered actions as disabled 147 * (by using using value false). 148 * @param postFilter: if true, do not filter actions. Actions will need to be filtered or disabled at render time. 149 * Useful to filter actions when filtering context is available at render time only (for instance when 150 * displaying actions in listings inside a JSF iteration done at render time). 151 * @since 8.2 152 */ 153 Action getAction(ActionContext context, String actionId, boolean includeFiltered, boolean postFilter); 154 155 /** 156 * Returns true if filters evaluation for given action, in given document context, grants access. 157 * 158 * @since 8.2 159 */ 160 boolean isAvailableForDocument(DocumentModel document, Action action); 161 162 /** 163 * Returns true if filters evaluation for given action, in given action context, grants access. 164 * 165 * @since 8.2 166 */ 167 boolean isAvailable(ActionContext context, Action action); 168 169 /** 170 * Returns all filtered actions for a given category and given resolution context. 171 * <p> 172 * Actions are filtered according to filters set on the actions definitions. 173 * <p> 174 * Since 5.8, the category can be a list of categories, separated by commas. 175 */ 176 List<Action> getActionsList(String category, ActionContext context); 177 178 /** 179 * Returns all filtered actions for a given category and given resolution context, creating a new context for the 180 * filters resolution. 181 * <p> 182 * Actions are filtered according to filters set on the actions definitions. 183 * <p> 184 * Since 5.8, the category can be a list of categories, separated by commas. 185 * 186 * @since 5.7 187 */ 188 List<Action> getActionsList(String category, Boolean removeFiltered); 189 190 /** 191 * Returns all filtered actions for a given category and a context built with given current document context, 192 * creating a new context for the filters resolution. 193 * <p> 194 * Actions are filtered according to filters set on the actions definitions. 195 * <p> 196 * Since 5.8, the category can be a list of categories, separated by commas. 197 * 198 * @since 5.7.3 199 */ 200 List<Action> getActionsListForDocument(String category, DocumentModel document, boolean removeFiltered); 201 202 /** 203 * Returns all filtered actions for a given category and given resolution context. 204 * <p> 205 * Actions are filtered according to filters set on the actions definitions. 206 * <p> 207 * Since 5.8, the category can be a list of categories, separated by commas. 208 * 209 * @since 5.7 210 */ 211 List<Action> getActionsList(String category, ActionContext context, boolean removeFiltered); 212 213 /** 214 * Returns all filtered actions for a given category, creating a new context for the filters resolution. 215 * <p> 216 * Since 5.8, the category can be a list of categories, separated by commas. 217 * 218 * @see #getActionsList(String, ActionContext) 219 */ 220 List<Action> getActionsList(String category); 221 222 /** 223 * Returns all actions for a given category and given resolution context. 224 * <p> 225 * Actions are not filtered according to filters set on the actions definitions: actions that should have been 226 * removed are just marked as non-available. 227 * <p> 228 * Since 5.8, the category can be a list of categories, separated by commas. 229 * 230 * @deprecated since 5.7, use {@link #getActionsList(String, ActionContext, boolean)} 231 */ 232 @Deprecated 233 List<Action> getUnfiltredActionsList(String category, ActionContext context); 234 235 /** 236 * Returns all actions for a given category, creating a new context for the filters resolution. 237 * <p> 238 * Since 5.8, the category can be a list of categories, separated by commas. 239 * 240 * @see #getUnfiltredActionsList(String, ActionContext) 241 * @deprecated since 5.7, use {@link #getActionsList(String, ActionContext, boolean)} 242 */ 243 @Deprecated 244 List<Action> getUnfiltredActionsList(String category); 245 246 /** 247 * Returns all actions for a given category, without filtering. 248 */ 249 List<Action> getAllActions(String category); 250 251 /** 252 * Returns filtered actions for the category {@link #DEFAULT_TABS_CATEGORY} 253 */ 254 List<Action> getTabsList(); 255 256 /** 257 * Returns filtered actions for a category computed from the current tab action id and the suffix 258 * {@link #SUBTAB_CATEGORY_SUFFIX}. 259 */ 260 List<Action> getSubTabsList(); 261 262 /** 263 * Returns the current action for category {@link #DEFAULT_TABS_CATEGORY} 264 */ 265 Action getCurrentTabAction(); 266 267 /** 268 * Sets the current action for category {@link #DEFAULT_TABS_CATEGORY} 269 */ 270 void setCurrentTabAction(Action tabAction); 271 272 /** 273 * Returns the current sub tab for a category computed from the current tab action id and the suffix 274 * {@link #SUBTAB_CATEGORY_SUFFIX}. 275 */ 276 Action getCurrentSubTabAction(); 277 278 /** 279 * Sets the current sub tab for a category computed from the current tab action id and the suffix 280 * {@link #SUBTAB_CATEGORY_SUFFIX}. 281 */ 282 void setCurrentSubTabAction(Action tabAction); 283 284 /** 285 * Returns the current action id for category {@link #DEFAULT_TABS_CATEGORY} 286 */ 287 String getCurrentTabId(); 288 289 /** 290 * Sets the current action id for category {@link #DEFAULT_TABS_CATEGORY}. 291 * <p> 292 * Does nothing if tabId is null, but resets current tab for this category when using an empty string instead. 293 */ 294 void setCurrentTabId(String tabId); 295 296 /** 297 * Returns the current sub tab id for a category computed from the current tab action id and the suffix 298 * {@link #SUBTAB_CATEGORY_SUFFIX}. 299 */ 300 String getCurrentSubTabId(); 301 302 /** 303 * Sets the current sub tab id for a category computed from the current tab action id and the suffix 304 * {@link #SUBTAB_CATEGORY_SUFFIX}. 305 * <p> 306 * Does nothing if sub tab id is null, but resets current tab for this category when using an empty string instead. 307 */ 308 void setCurrentSubTabId(String tabId); 309 310 /** 311 * Resets actions resolved for category {@link #DEFAULT_TABS_CATEGORY} so that they're recomputed. Also calls 312 * {@link #resetCurrentTab()} 313 */ 314 void resetTabList(); 315 316 /** 317 * Resets current tab information (includes sub tab information) for category {@link #DEFAULT_TABS_CATEGORY}. 318 */ 319 void resetCurrentTab(); 320 321 /** 322 * Returns the current action for given category. 323 */ 324 Action getCurrentTabAction(String category); 325 326 /** 327 * Returns the current sub tab action for given parent action, computing the category from parent action id with 328 * suffix {@link #SUBTAB_CATEGORY_SUFFIX}. 329 */ 330 Action getCurrentSubTabAction(String parentActionId); 331 332 /** 333 * Sets the current action for given category. 334 * <p> 335 * If given action is null, it resets the current action for this category. 336 */ 337 void setCurrentTabAction(String category, Action tabAction); 338 339 /** 340 * Returns the current action id for given category 341 */ 342 String getCurrentTabId(String category); 343 344 /** 345 * Indicates if the current tab id is set for given category 346 * 347 * @since 5.5 348 */ 349 boolean hasCurrentTabId(String category); 350 351 /** 352 * Sets the current action for given category, with additional sub tabs. 353 */ 354 void setCurrentTabId(String category, String tabId, String... subTabIds); 355 356 /** 357 * Returns current tab ids as a string, encoded as is: CATEGORY_1:ACTION_ID_1,CATEGORY_2:ACTION_ID_2,... 358 * 359 * @since 5.4.2 360 */ 361 String getCurrentTabIds(); 362 363 /** 364 * Sets current tab ids as a String, splitting on commas ',' and parsing each action information as is: 365 * CATEGORY:ACTION_ID[:OPTIONAL_SUB_ACTION_ID[:OPTIONAL_SUB_ACTION_ID]...] 366 * <p> 367 * If category is omitted or empty, the category {@link #DEFAULT_TABS_CATEGORY} will be used (if there is no subtab 368 * information). 369 * <p> 370 * The resulting string looks like: CATEGORY_1:ACTION_ID_1,CATEGORY_2:ACTION_ID_2_SUB_ACTION_ID_2,... 371 * 372 * @since 5.4.2 373 */ 374 void setCurrentTabIds(String tabIds); 375 376 /** 377 * Resets all current tabs information. 378 * 379 * @since 5.4.2 380 */ 381 void resetCurrentTabs(); 382 383 /** 384 * Resets current tabs for given category, taking subtabs into account by resetting actions in categories computed 385 * from reset actions id with suffix {@link #SUBTAB_CATEGORY_SUFFIX}. 386 */ 387 void resetCurrentTabs(String category); 388 389 /** 390 * Calls {@link #setCurrentTabAndNavigate(DocumentModel, String)} for the current document. 391 * <p> 392 * Given action should hold the category {@link #DEFAULT_TABS_CATEGORY} 393 * 394 * @see NavigationContext#getCurrentDocument() 395 */ 396 String setCurrentTabAndNavigate(String currentTabActionId); 397 398 /** 399 * Navigate to the given document and opens the view page of the given document selecting the given tab. 400 * <p> 401 * Given action should hold the category {@link #DEFAULT_TABS_CATEGORY} 402 * 403 * @param document to document which will be shown in the view page 404 * @param currentTabActionId the tab that will be selected in the view page 405 * @return the JSF view for the given document. 406 */ 407 String setCurrentTabAndNavigate(DocumentModel document, String currentTabActionId); 408 409 /** 410 * @since 5.6 411 * @see ActionManager#checkFilter(String, ActionContext) 412 */ 413 boolean checkFilter(String filterId); 414 415 /** 416 * @since 5.7 417 * @see ActionManager#getAction(String, ActionContext, boolean) 418 */ 419 Action getAction(String actionId, boolean removeFiltered); 420 421 /** 422 * Return action with given id, with context filled with given document. 423 * 424 * @since 5.7.3 425 * @see ActionManager#getAction(String, ActionContext, boolean) 426 */ 427 Action getActionForDocument(String actionId, DocumentModel document, boolean removeFiltered); 428 429 /** 430 * @since 5.6 431 * @see ActionManager#getAction(String, ActionContext, boolean) 432 */ 433 Action getAction(String actionId, ActionContext context, boolean removeFiltered); 434 435 /** 436 * Returns true if ajaxified behaviour of tabs is activated on the server, and if history push state is supported by 437 * browser. 438 * 439 * @since 5.8 440 * @see #AJAX_TAB_PROPERTY 441 * @see #canUseAjaxTabs() 442 */ 443 boolean useAjaxTabs(); 444 445 /** 446 * Returns true if history push state is supported by browser. 447 * 448 * @since 5.8 449 * @see #useAjaxTabs() 450 */ 451 boolean canUseAjaxTabs(); 452 453 @Deprecated 454 List<Action> getSubViewActionsList(); 455 456 /** 457 * @deprecated use {@link #setCurrentTabId()} or {@link #setCurrentTabAction(String, Action)} 458 */ 459 @Deprecated 460 void setCurrentTabAction(String currentTabActionId); 461 462 /** 463 * @deprecated since 5.4: useless, and does nothing 464 */ 465 @Deprecated 466 void selectTabAction(); 467 468 /** 469 * @deprecated should be handled by a workflow related (or at least document) action listener. 470 */ 471 @Deprecated 472 String getCurrentLifeCycleState(); 473 474 /** 475 * @deprecated since 5.4.2: useless 476 */ 477 @Deprecated 478 void setTabsList(List<Action> tabsList); 479 480 /** 481 * @deprecated since 5.4.2: useless 482 */ 483 @Deprecated 484 void setSubTabsList(List<Action> tabsList); 485 486}