001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
018 *
019 * $Id: UIHtmlEditor.java 27532 2007-11-21 15:20:23Z troger $
020 */
021
022package org.nuxeo.ecm.platform.ui.web.component.editor;
023
024import javax.faces.component.UIInput;
025import javax.faces.component.html.HtmlInputText;
026
027/**
028 * Html editor component.
029 *
030 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
031 */
032public class UIHtmlEditor extends HtmlInputText {
033
034    public static final String COMPONENT_TYPE = UIHtmlEditor.class.getName();
035
036    public static final String COMPONENT_FAMILY = UIInput.COMPONENT_FAMILY;
037
038    public UIHtmlEditor() {
039        setRendererType(COMPONENT_TYPE);
040    }
041
042    protected enum PropertyKeys {
043        width, height, cols, rows, editorSelector, disableHtmlInit,
044        // json string for additional configuration to pass through to tinymce editor
045        configuration;
046    }
047
048    // setters & getters
049
050    public Boolean getDisableHtmlInit() {
051        return (Boolean) getStateHelper().eval(PropertyKeys.disableHtmlInit, Boolean.FALSE);
052    }
053
054    public void setDisableHtmlInit(Boolean disableHtmlInit) {
055        getStateHelper().put(PropertyKeys.disableHtmlInit, disableHtmlInit);
056    }
057
058    public String getCols() {
059        return (String) getStateHelper().eval(PropertyKeys.cols, "100");
060    }
061
062    public void setCols(String cols) {
063        getStateHelper().put(PropertyKeys.cols, cols);
064    }
065
066    public String getRows() {
067        return (String) getStateHelper().eval(PropertyKeys.rows, "25");
068    }
069
070    public void setRows(String rows) {
071        getStateHelper().put(PropertyKeys.rows, rows);
072    }
073
074    public String getWidth() {
075        return (String) getStateHelper().eval(PropertyKeys.width, "640");
076    }
077
078    public void setWidth(String width) {
079        getStateHelper().put(PropertyKeys.width, width);
080    }
081
082    public String getHeight() {
083        return (String) getStateHelper().eval(PropertyKeys.height, "400");
084    }
085
086    public void setHeight(String height) {
087        getStateHelper().put(PropertyKeys.height, height);
088    }
089
090    public String getEditorSelector() {
091        return (String) getStateHelper().eval(PropertyKeys.editorSelector, "mceEditor");
092    }
093
094    public void setEditorSelector(String editorSelector) {
095        getStateHelper().put(PropertyKeys.editorSelector, editorSelector);
096    }
097
098    /**
099     * Returns JSON configuration map to pass to tinyMCE
100     *
101     * @since 8.1
102     */
103    public String getConfiguration() {
104        return (String) getStateHelper().eval(PropertyKeys.configuration);
105    }
106
107    /**
108     * @since 8.1
109     */
110    public void setConfiguration(String configuration) {
111        getStateHelper().put(PropertyKeys.configuration, configuration);
112    }
113
114}