001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWorkplaceCustomFoot.java,v $
003: * Date : $Date: 2008-02-27 12:05:45 $
004: * Version: $Revision: 1.4 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace;
033:
034: import org.opencms.main.CmsException;
035: import org.opencms.main.OpenCms;
036: import org.opencms.util.CmsMacroResolver;
037: import org.opencms.util.CmsStringUtil;
038:
039: /**
040: * A custom foot configuration to create a specially designed foot for the OpenCms workplace.<p>
041: *
042: * @author Andreas Zahner
043: *
044: * @version $Revision: 1.4 $
045: *
046: * @since 6.9.2
047: */
048: public class CmsWorkplaceCustomFoot {
049:
050: /** The default foot frame font color. */
051: public static final String DEFAUL_COLOR = "WindowText";
052:
053: /** The default foot frame background color. */
054: public static final String DEFAULT_BACKGROUNDCOLOR = "ThreeDFace";
055:
056: /** The default workplace foot text to display. */
057: public static final String DEFAULT_TEXT = "%("
058: + CmsMacroResolver.KEY_LOCALIZED_PREFIX
059: + Messages.GUI_LABEL_USER_0 + ") %("
060: + CmsMacroResolver.KEY_CURRENT_USER_FULLNAME + ") %("
061: + CmsMacroResolver.KEY_LOCALIZED_PREFIX
062: + Messages.GUI_LABEL_LOGINTIME_0 + ") %("
063: + CmsMacroResolver.KEY_CURRENT_USER_LASTLOGIN + ") %("
064: + CmsMacroResolver.KEY_LOCALIZED_PREFIX
065: + Messages.GUI_LABEL_LOGINADDRESS_0 + ") %("
066: + CmsMacroResolver.KEY_OPENCMS + "remoteaddress) ";
067:
068: /** The default workplace foot text to display. */
069: public static final String DEFAULT_TEXT_WITH_OU = DEFAULT_TEXT
070: + "[%(" + CmsMacroResolver.KEY_LOCALIZED_PREFIX
071: + Messages.GUI_LABEL_OU_0 + ") %("
072: + CmsMacroResolver.KEY_CURRENT_ORGUNIT_DESCRIPTION + ")] ";
073:
074: /** The background color of the foot frame. */
075: private String m_backgroundColor;
076:
077: /** The font color of the foot frame. */
078: private String m_color;
079:
080: /** Indicates if the default text should be replaced or kept. */
081: private boolean m_replaceDefault;
082:
083: /** The additional text of the foot frame. */
084: private String m_text;
085:
086: /** The text shown in the foot frame (can contain macros). */
087: private String m_textShown;
088:
089: /**
090: * Empty constructor.<p>
091: */
092: public CmsWorkplaceCustomFoot() {
093:
094: // initialize members with default or empty values
095: m_backgroundColor = DEFAULT_BACKGROUNDCOLOR;
096: m_color = DEFAUL_COLOR;
097: m_text = "";
098: }
099:
100: /**
101: * Returns the background color of the foot frame.<p>
102: *
103: * @return the background color of the foot frame
104: */
105: public String getBackgroundColor() {
106:
107: return m_backgroundColor;
108: }
109:
110: /**
111: * Returns the font color of the foot frame.<p>
112: *
113: * @return the font color of the foot frame
114: */
115: public String getColor() {
116:
117: return m_color;
118: }
119:
120: /**
121: * Returns the additional text of the foot frame.<p>
122: *
123: * @return the additional text of the foot frame
124: */
125: public String getText() {
126:
127: return m_text;
128: }
129:
130: /**
131: * Returns the text of the foot frame with resolved macros.<p>
132: *
133: * @param wp the initialized workplace dialog
134: * @return the text of the foot frame with resolved macros
135: */
136: public String getTextResolved(CmsWorkplace wp) {
137:
138: CmsMacroResolver resolver = CmsMacroResolver.newInstance();
139: resolver.setCmsObject(wp.getCms());
140: resolver.setJspPageContext(wp.getJsp().getJspContext());
141: resolver.setMessages(wp.getMessages());
142: if (m_textShown == null) {
143: // create the shown text containing macros
144: StringBuffer text = new StringBuffer(512);
145: if (!isReplaceDefault()) {
146: // the default text should be shown
147: try {
148: if (OpenCms.getOrgUnitManager()
149: .getOrganizationalUnits(wp.getCms(), "",
150: true).isEmpty()) {
151: text.append(DEFAULT_TEXT).append(" ");
152: } else {
153: text.append(DEFAULT_TEXT_WITH_OU).append(" ");
154: }
155: } catch (CmsException e) {
156: text.append(DEFAULT_TEXT).append(" ");
157: }
158: }
159: text.append(m_text);
160: m_textShown = text.toString();
161: }
162: // return the resolved text
163: return resolver.resolveMacros(m_textShown);
164: }
165:
166: /**
167: * Returns if the default text should be replaced or kept.<p>
168: *
169: * @return true if the default text should be replaced, otherwise false
170: */
171: public boolean isReplaceDefault() {
172:
173: return m_replaceDefault;
174: }
175:
176: /**
177: * Sets the background color of the foot frame.<p>
178: *
179: * @param backgroundColor the background color of the foot frame
180: */
181: public void setBackgroundColor(String backgroundColor) {
182:
183: if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(backgroundColor)) {
184: m_backgroundColor = backgroundColor;
185: }
186: }
187:
188: /**
189: * Sets the font color of the foot frame.<p>
190: *
191: * @param color the font color of the foot frame
192: */
193: public void setColor(String color) {
194:
195: if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(color)) {
196: m_color = color;
197: }
198: }
199:
200: /**
201: * Sets the additional text of the foot frame.<p>
202: *
203: * @param text the additional text of the foot frame
204: * @param replaceDefault flag indicating if the default text should be replaced or kept
205: */
206: public void setText(String text, String replaceDefault) {
207:
208: m_replaceDefault = Boolean.valueOf(replaceDefault)
209: .booleanValue();
210: m_text = text;
211: }
212:
213: }
|