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.workplace.editors; 029 030import org.opencms.file.CmsResource; 031import org.opencms.util.CmsUUID; 032 033import java.util.Locale; 034 035/** 036 * Stores editor session data.<p> 037 * 038 * @since 8.0. 039 */ 040public class CmsEditorSessionInfo { 041 042 /** The editor session info key prefix. */ 043 public static final String PREFIX_EDITOR_SESSION_INFO = "editorSessionInfo"; 044 045 /** The back link for closing the editor. */ 046 private String m_backLink; 047 048 /** Flag indicating if in direct edit mode. */ 049 private boolean m_directEdit; 050 051 /** The id of the edited resource. */ 052 private CmsUUID m_editedStructureId; 053 054 /** The locale currently edited. */ 055 private Locale m_elementLocale; 056 057 /** 058 * Constructor.<p> 059 * 060 * @param editedStructureId the id of the edited resource 061 */ 062 public CmsEditorSessionInfo(CmsUUID editedStructureId) { 063 064 m_editedStructureId = editedStructureId; 065 } 066 067 /** 068 * Returns the session info key for the bean.<p> 069 * 070 * @param editedResource the edited resource 071 * 072 * @return the session info key for the bean 073 */ 074 protected static String getEditorSessionInfoKey(CmsResource editedResource) { 075 076 return PREFIX_EDITOR_SESSION_INFO + editedResource.getStructureId().getStringValue(); 077 } 078 079 /** 080 * Returns the back link for closing the editor.<p> 081 * 082 * @return the back link for closing the editor 083 */ 084 public String getBackLink() { 085 086 return m_backLink; 087 } 088 089 /** 090 * Returns the id of the edited resource.<p> 091 * 092 * @return the id of the edited resource 093 */ 094 public CmsUUID getEditedStructureId() { 095 096 return m_editedStructureId; 097 } 098 099 /** 100 * Returns the session info key for the bean.<p> 101 * 102 * @return the session info key for the bean 103 */ 104 public String getEditorSessionInfoKey() { 105 106 return PREFIX_EDITOR_SESSION_INFO + m_editedStructureId.getStringValue(); 107 } 108 109 /** 110 * Returns the element locale currently edited.<p> 111 * 112 * @return the element locale 113 */ 114 public Locale getElementLocale() { 115 116 return m_elementLocale; 117 } 118 119 /** 120 * Returns if in direct edit mode.<p> 121 * 122 * @return <code>true</code> if in direct edit mode 123 */ 124 public boolean isDirectEdit() { 125 126 return m_directEdit; 127 } 128 129 /** 130 * Sets the back link for closing the editor.<p> 131 * 132 * @param backLink the back link for closing the editor to set 133 */ 134 public void setBackLink(String backLink) { 135 136 m_backLink = backLink; 137 } 138 139 /** 140 * Sets the flag indicating if in direct edit mode.<p> 141 * 142 * @param directEdit the flag indicating if in direct edit mode 143 */ 144 public void setDirectEdit(boolean directEdit) { 145 146 m_directEdit = directEdit; 147 } 148 149 /** 150 * Sets the id of the edited resource.<p> 151 * 152 * @param editedStructureId the id of the edited resource to set 153 */ 154 public void setEditedStructureId(CmsUUID editedStructureId) { 155 156 m_editedStructureId = editedStructureId; 157 } 158 159 /** 160 * Sets the element locale currently edited.<p> 161 * 162 * @param elementLocale the element locale to set 163 */ 164 public void setElementLocale(Locale elementLocale) { 165 166 m_elementLocale = elementLocale; 167 } 168 169}