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