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, 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.ade.containerpage.shared; 029 030import org.opencms.gwt.shared.CmsListInfoBean; 031import org.opencms.gwt.shared.CmsTemplateContextInfo; 032import org.opencms.util.CmsUUID; 033 034import java.util.List; 035import java.util.Map; 036import java.util.Set; 037 038import com.google.gwt.user.client.rpc.IsSerializable; 039 040/** 041 * Convenience class to provide server-side information to the client.<p> 042 * 043 * @since 8.0.0 044 */ 045public final class CmsCntPageData implements IsSerializable { 046 047 /** The element delte modes. */ 048 public enum ElementDeleteMode { 049 /** Don't ask, delete no longer referenced element resources. */ 050 alwaysDelete, 051 /** Don't ask, keep no longer referenced element resources. */ 052 alwaysKeep, 053 /** Ask if no longer referenced element resources should be deleted. Delete is preselected. */ 054 askDelete, 055 /** Ask if no longer referenced element resources should be deleted. Keep is preselected. */ 056 askKeep 057 } 058 059 /** Enum representing the different ways dropping elements on a container page can be handled. */ 060 public enum ElementReuseMode { 061 062 /** The user will be asked whether they want the 'copy' or 'reuse' behavior. */ 063 ask, 064 065 /** The dropped element will be copied, and the container page will link to the copy. */ 066 copy, 067 068 /** The container page will link to the dropped element. */ 069 reuse 070 } 071 072 /** Name of the used dictionary. */ 073 public static final String DICT_NAME = "org_opencms_ade_containerpage"; 074 075 /** Key 'detailElementId' for the detail content id. */ 076 public static final String JSONKEY_DETAIL_ELEMENT_ID = "detailElementId"; 077 078 /** Key 'isDetailOnly' used within the JSON representation of a container object. */ 079 public static final String JSONKEY_DETAILONLY = "isDetailOnly"; 080 081 /** Key 'isDetailView' used within the JSON representation of a container object. */ 082 public static final String JSONKEY_DETAILVIEW = "isDetailView"; 083 084 /** Key 'elementId' for the element id. */ 085 public static final String JSONKEY_ELEMENT_ID = "elementId"; 086 087 /** Key 'elements' used within the JSON representation of a container object. */ 088 public static final String JSONKEY_ELEMENTS = "elements"; 089 090 /** Key 'isDetailViewContainer' used within the JSON representation of a container object. */ 091 public static final String JSONKEY_ISDETAILVIEWCONTAINER = "isDetailViewContainer"; 092 093 /** Key 'maxElements' used within the JSON representation of a container object. */ 094 public static final String JSONKEY_MAXELEMENTS = "maxElements"; 095 096 /** Key 'name' used within the JSON representation of a container object. */ 097 public static final String JSONKEY_NAME = "name"; 098 099 /** JSON key for presets. */ 100 public static final String JSONKEY_PRESETS = "presets"; 101 102 /** Key 'type' used within the JSON representation of a container object. */ 103 public static final String JSONKEY_TYPE = "type"; 104 105 /** Key 'width' used within the JSON representation of a container object. */ 106 public static final String JSONKEY_WIDTH = "width"; 107 108 /** The editor back-link URI. */ 109 private static final String BACKLINK_URI = "/system/modules/org.opencms.ade.containerpage/editor-backlink.html"; 110 111 /** Temporary flag to disable the option to edit settings in content editor. */ 112 private boolean m_allowSettingsInEditor; 113 114 /** The app title to display in the toolbar. */ 115 private String m_appTitle; 116 117 /** The element delete mode. */ 118 private ElementDeleteMode m_deleteMode; 119 120 /** The detail view container resource path. */ 121 private String m_detailContainerPage; 122 123 /** The detail structure id, if available. */ 124 private CmsUUID m_detailId; 125 126 /** The set of names of types for which the current page is registered as a detail page. */ 127 private Set<String> m_detailTypes; 128 129 /** Flag which determines whether small elements should be editable initially. */ 130 private boolean m_editSmallElementsInitially; 131 132 /** The current element view. */ 133 private CmsElementViewInfo m_elementView; 134 135 /** The element views. */ 136 private List<CmsElementViewInfo> m_elementViews; 137 138 /** True if the page is used for model groups. */ 139 private boolean m_isModelGroup; 140 141 /** True if the container page is a model page. */ 142 private boolean m_isModelPage; 143 144 /** The date at which the container page was last modified. */ 145 private long m_lastModified; 146 147 /** The time when the page was loaded. */ 148 private long m_loadTime; 149 150 /** The content locale. */ 151 private String m_locale; 152 153 /** The locale link beans. */ 154 private Map<String, CmsLocaleLinkBean> m_localeLinkBeans; 155 156 /** The lock information, if the page is locked by another user. */ 157 private String m_lockInfo; 158 159 /** The main locale to this page in case it is part of a locale group. */ 160 private String m_mainLocale; 161 162 /** The model group base element id. */ 163 private String m_modelGroupEmenetId; 164 165 /** The reason why the user is not able to edit the current container page. */ 166 private String m_noEditReason; 167 168 /** The online link to the current page. */ 169 private String m_onlineLink; 170 171 /** The current page info. */ 172 private CmsListInfoBean m_pageInfo; 173 174 /** The original request parameters. */ 175 private String m_requestParams; 176 177 /** The element reuse mode. */ 178 private ElementReuseMode m_reuseMode; 179 180 /** The RPC context. */ 181 private CmsContainerPageRpcContext m_rpcContext; 182 183 /** Flag indicating if the current user has the sitemap manager role. */ 184 private boolean m_sitemapManager; 185 186 /** The current sitemap URI. */ 187 private String m_sitemapUri; 188 189 /** The template context information. */ 190 private CmsTemplateContextInfo m_templateContextInfo; 191 192 /** Flag indicating to use the classic XmlContent editor. */ 193 private boolean m_useClassicEditor; 194 195 /** The detail container page id (may be null). */ 196 private CmsUUID m_detailContainerPageId; 197 198 /** 199 * Constructor.<p> 200 * 201 * @param onlineLink the online link to the current page 202 * @param noEditReason the reason why the current user is not allowed to edit the current container page 203 * @param requestParams the original request parameters 204 * @param sitemapUri the current sitemap URI 205 * @param sitemapManager if the user has the sitemap manager role 206 * @param detailId the detail resource id, if available 207 * @param detailContainerPage the detail view container resource path 208 * @param detailContainerPageId the detail view container page structure id 209 * @param detailTypes the set of names of types for which this page is registered as detail page 210 * @param lastModified the last modification date of the page 211 * @param lockInfo lock information, if the page is locked by another user 212 * @param pageInfo the current page info 213 * @param locale the content locale 214 * @param useClassicEditor <code>true</code> to use the classic XmlContent editor 215 * @param contextInfo the template context information 216 * @param showSmallElementsInitially flag which controls whether small elements should be shown initially 217 * @param elementViews the element views 218 * @param elementView the current element view 219 * @param reuseMode the element reuse mode 220 * @param deleteMode the element delete mode 221 * @param isModelPage true if this is a model page 222 * @param isModelGroup true if the page is used for model groups 223 * @param modelGroupEmenetId the model group base element id 224 * @param mainLocale the main locale to this page in case it is part of a locale group 225 * @param localeLinkBeans beans for links to other pages in the locale group 226 * @param appTitle the title to display in the toolbar 227 * @param loadTime the current time 228 */ 229 public CmsCntPageData( 230 String onlineLink, 231 String noEditReason, 232 String requestParams, 233 String sitemapUri, 234 boolean sitemapManager, 235 CmsUUID detailId, 236 String detailContainerPage, 237 CmsUUID detailContainerPageId, 238 Set<String> detailTypes, 239 long lastModified, 240 String lockInfo, 241 CmsListInfoBean pageInfo, 242 String locale, 243 boolean useClassicEditor, 244 CmsTemplateContextInfo contextInfo, 245 boolean showSmallElementsInitially, 246 List<CmsElementViewInfo> elementViews, 247 CmsElementViewInfo elementView, 248 ElementReuseMode reuseMode, 249 ElementDeleteMode deleteMode, 250 boolean isModelPage, 251 boolean isModelGroup, 252 String modelGroupEmenetId, 253 String mainLocale, 254 Map<String, CmsLocaleLinkBean> localeLinkBeans, 255 String appTitle, 256 long loadTime) { 257 258 m_onlineLink = onlineLink; 259 m_noEditReason = noEditReason; 260 m_requestParams = requestParams; 261 m_sitemapUri = sitemapUri; 262 m_sitemapManager = sitemapManager; 263 m_lastModified = lastModified; 264 m_lockInfo = lockInfo; 265 m_pageInfo = pageInfo; 266 m_locale = locale; 267 m_detailId = detailId; 268 m_detailContainerPage = detailContainerPage; 269 m_detailContainerPageId = detailContainerPageId; 270 m_detailTypes = detailTypes; 271 m_useClassicEditor = useClassicEditor; 272 m_templateContextInfo = contextInfo; 273 m_editSmallElementsInitially = showSmallElementsInitially; 274 m_elementViews = elementViews; 275 m_elementView = elementView; 276 m_reuseMode = reuseMode; 277 m_deleteMode = deleteMode; 278 m_isModelPage = isModelPage; 279 m_isModelGroup = isModelGroup; 280 m_modelGroupEmenetId = modelGroupEmenetId; 281 m_mainLocale = mainLocale; 282 m_localeLinkBeans = localeLinkBeans; 283 m_appTitle = appTitle; 284 m_loadTime = loadTime; 285 } 286 287 /** 288 * Serialization constructor.<p> 289 */ 290 protected CmsCntPageData() { 291 292 // empty 293 } 294 295 /** 296 * Returns whether editing settings in the content editor is allowed.<p> 297 * 298 * @return <code>true</code> in case editing settings in the content editor is allowed 299 */ 300 public boolean allowSettingsInEditor() { 301 302 return m_allowSettingsInEditor; 303 } 304 305 /** 306 * Gets the title to display in the toolbar.<p> 307 * 308 * @return the title for the toolbar 309 */ 310 public String getAppTitle() { 311 312 return m_appTitle; 313 } 314 315 /** 316 * Returns the xml-content editor back-link URI.<p> 317 * 318 * @return the back-link URI 319 */ 320 public String getBacklinkUri() { 321 322 return BACKLINK_URI; 323 } 324 325 /** 326 * Gets the date at which the page was last modified.<p> 327 * 328 * @return the date at which the page was last modified 329 */ 330 public long getDateLastModified() { 331 332 return m_lastModified; 333 } 334 335 /** 336 * Returns the element delete mode.<p> 337 * 338 * @return the element delete mode 339 */ 340 public ElementDeleteMode getDeleteMode() { 341 342 return m_deleteMode; 343 } 344 345 /** 346 * Returns the detail view container resource path.<p> 347 * 348 * @return the detail view container resource path 349 */ 350 public String getDetailContainerPage() { 351 352 return m_detailContainerPage; 353 } 354 355 /** 356 * Gets the structure id of the detail container page (or null if we are not on on a detail page, or there is no detail container page). 357 * 358 * @return the structure id of the detail container page 359 */ 360 public CmsUUID getDetailContainerPageId() { 361 362 return m_detailContainerPageId; 363 } 364 365 /** 366 * Returns the detail structure id, if available.<p> 367 * 368 * @return the detail structure id 369 */ 370 public CmsUUID getDetailId() { 371 372 return m_detailId; 373 } 374 375 /** 376 * Gets the set of names of types for which the container page is registered as a detail page. 377 * 378 * @return the set of names of detail types 379 */ 380 public Set<String> getDetailTypes() { 381 382 return m_detailTypes; 383 } 384 385 /** 386 * Gets the element reuse mode.<p> 387 * 388 * @return the element reuse mode 389 */ 390 public ElementReuseMode getElementReuseMode() { 391 392 return m_reuseMode; 393 } 394 395 /** 396 * Returns the current element view.<p> 397 * 398 * @return the current element view 399 */ 400 public CmsElementViewInfo getElementView() { 401 402 return m_elementView; 403 } 404 405 /** 406 * Returns the available element views.<p> 407 * 408 * @return the element views 409 */ 410 public List<CmsElementViewInfo> getElementViews() { 411 412 return m_elementViews; 413 } 414 415 /** 416 * Returns the time off page load.<p> 417 * 418 * @return the time stamp 419 */ 420 public long getLoadTime() { 421 422 return m_loadTime; 423 } 424 425 /** 426 * Returns the content locale.<p> 427 * 428 * @return the locale 429 */ 430 public String getLocale() { 431 432 return m_locale; 433 } 434 435 /** 436 * Gets the locale link beans, with localized language names as keys.<p> 437 * 438 * The beans represent links to different locale variants of this page. 439 * 440 * @return the locale link bean map for this 441 */ 442 public Map<String, CmsLocaleLinkBean> getLocaleLinkBeans() { 443 444 return m_localeLinkBeans; 445 } 446 447 /** 448 * Returns the lock information, if the page is locked by another user.<p> 449 * 450 * @return the lock infomation 451 */ 452 public String getLockInfo() { 453 454 return m_lockInfo; 455 } 456 457 /** 458 * Returns the main locale to this page in case it is part of a locale group.<p> 459 * 460 * @return the main locale to this page in case it is part of a locale group 461 */ 462 public String getMainLocale() { 463 464 return m_mainLocale; 465 } 466 467 /** 468 * Returns the model group base element id.<p> 469 * 470 * @return the model group base element id 471 */ 472 public String getModelGroupElementId() { 473 474 return m_modelGroupEmenetId; 475 } 476 477 /** 478 * Returns the no-edit reason.<p> 479 * 480 * @return the no-edit reason, if empty editing is allowed 481 */ 482 public String getNoEditReason() { 483 484 return m_noEditReason; 485 } 486 487 /** 488 * Returns the online link to the current page.<p> 489 * 490 * @return the online link to the current page 491 */ 492 public String getOnlineLink() { 493 494 return m_onlineLink; 495 } 496 497 /** 498 * Returns the current page info.<p> 499 * 500 * @return the current page info 501 */ 502 public CmsListInfoBean getPageInfo() { 503 504 return m_pageInfo; 505 } 506 507 /** 508 * Returns the request parameters.<p> 509 * 510 * @return the request parameters 511 */ 512 public String getRequestParams() { 513 514 return m_requestParams; 515 } 516 517 /** 518 * Gets the RPC context.<p> 519 * 520 * @return the RPC context 521 */ 522 public CmsContainerPageRpcContext getRpcContext() { 523 524 return m_rpcContext; 525 } 526 527 /** 528 * Returns the sitemap URI.<p> 529 * 530 * @return the sitemap URI 531 */ 532 public String getSitemapUri() { 533 534 return m_sitemapUri; 535 } 536 537 /** 538 * Gets the template context information.<p> 539 * 540 * @return the template context information 541 */ 542 public CmsTemplateContextInfo getTemplateContextInfo() { 543 544 return m_templateContextInfo; 545 } 546 547 /** 548 * Returns true if small elements should be editable initially.<p> 549 * 550 * @return true if small elements should be editable initially 551 */ 552 public boolean isEditSmallElementsInitially() { 553 554 return m_editSmallElementsInitially; 555 } 556 557 /** 558 * Returns if the page is used for model groups.<p> 559 * 560 * @return true if the page is used for model groups 561 */ 562 public boolean isModelGroup() { 563 564 return m_isModelGroup; 565 } 566 567 /** 568 * True if the container page is a model page.<P> 569 * 570 * @return true if this is a model page 571 */ 572 public boolean isModelPage() { 573 574 return m_isModelPage; 575 } 576 577 /** 578 * Returns if the current user has the sitemap manager role.<p> 579 * 580 * @return if the current user has the sitemap manager role 581 */ 582 public boolean isSitemapManager() { 583 584 return m_sitemapManager; 585 } 586 587 /** 588 * Returns if the classic XmlContent editor should be used.<p> 589 * 590 * @return <code>true</code> if the classic XmlContent editor should be used 591 */ 592 public boolean isUseClassicEditor() { 593 594 return m_useClassicEditor; 595 } 596 597 /** 598 * Sets whether editing settings in the content editor is allowed.<p> 599 * 600 * @param allowSettingsInEditor <code>true</code> to set editing settings in the content editor is allowed 601 */ 602 public void setAllowSettingsInEditor(boolean allowSettingsInEditor) { 603 604 m_allowSettingsInEditor = allowSettingsInEditor; 605 } 606 607 /** 608 * Sets the RPC context.<p> 609 * 610 * @param context the RPC context 611 */ 612 public void setRpcContext(CmsContainerPageRpcContext context) { 613 614 m_rpcContext = context; 615 } 616 617}