001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
016 *
017 * $Id: UIHtmlEditor.java 27532 2007-11-21 15:20:23Z troger $
018 */
019
020package org.nuxeo.ecm.platform.ui.web.component.editor;
021
022import javax.faces.component.UIInput;
023import javax.faces.component.html.HtmlInputText;
024
025/**
026 * Html editor component.
027 *
028 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
029 */
030public class UIHtmlEditor extends HtmlInputText {
031
032    public static final String COMPONENT_TYPE = UIHtmlEditor.class.getName();
033
034    public static final String COMPONENT_FAMILY = UIInput.COMPONENT_FAMILY;
035
036    public UIHtmlEditor() {
037        setRendererType(COMPONENT_TYPE);
038    }
039
040    // attributes TODO: add more.
041    protected enum PropertyKeys {
042        width, height, cols, rows, editorSelector, disableHtmlInit;
043    }
044
045    // setters & getters
046
047    public Boolean getDisableHtmlInit() {
048        return (Boolean) getStateHelper().eval(PropertyKeys.disableHtmlInit, Boolean.FALSE);
049    }
050
051    public void setDisableHtmlInit(Boolean disableHtmlInit) {
052        getStateHelper().put(PropertyKeys.disableHtmlInit, disableHtmlInit);
053    }
054
055    public String getCols() {
056        return (String) getStateHelper().eval(PropertyKeys.cols, "100");
057    }
058
059    public void setCols(String cols) {
060        getStateHelper().put(PropertyKeys.cols, cols);
061    }
062
063    public String getRows() {
064        return (String) getStateHelper().eval(PropertyKeys.rows, "25");
065    }
066
067    public void setRows(String rows) {
068        getStateHelper().put(PropertyKeys.rows, rows);
069    }
070
071    public String getWidth() {
072        return (String) getStateHelper().eval(PropertyKeys.width, "640");
073    }
074
075    public void setWidth(String width) {
076        getStateHelper().put(PropertyKeys.width, width);
077    }
078
079    public String getHeight() {
080        return (String) getStateHelper().eval(PropertyKeys.height, "400");
081    }
082
083    public void setHeight(String height) {
084        getStateHelper().put(PropertyKeys.height, height);
085    }
086
087    public String getEditorSelector() {
088        return (String) getStateHelper().eval(PropertyKeys.editorSelector, "mceEditor");
089    }
090
091    public void setEditorSelector(String editorSelector) {
092        getStateHelper().put(PropertyKeys.editorSelector, editorSelector);
093    }
094
095}