001: /* FCKeditor.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Mon Dec 26 20:57:21 2005, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: }}IS_RIGHT
016: */
017: package org.zkforge.fckez;
018:
019: import org.zkoss.lang.Objects;
020:
021: import org.zkoss.zk.ui.AbstractComponent;
022: import org.zkoss.zk.ui.Executions;
023: import org.zkoss.zk.ui.event.Events;
024: import org.zkoss.zk.ui.ext.client.Inputable;
025: import org.zkoss.zk.au.Command;
026: import org.zkoss.zk.au.out.AuScript;
027: import org.zkoss.zk.au.in.GenericCommand;
028:
029: /**
030: * The component used to represent <a
031: * href="http://www.fckeditor.net/">FCKeditor&tl;/a>
032: *
033: * @author tomyeh
034: * @version $Revision: 1.6 $ $Date: 2006/03/31 08:38:55 $
035: */
036: public class FCKeditor extends AbstractComponent {
037: private String _value = "";
038:
039: private String _width = "100%";
040:
041: private String _height = "200px";
042:
043: private String _tbset;
044:
045: private String _customPath;
046:
047: /** Used by setTextByClient() to disable sending back the value */
048: private String _txtByClient;
049:
050: /**
051: * Returns the value in this FCKeditor.
052: */
053: public String getValue() {
054: return _value;
055: }
056:
057: /**
058: * Sets the value for this FCKeditor.
059: */
060: public void setValue(String value) {
061: if (value == null)
062: value = "";
063: if (!value.equals(_value)) {
064: _value = value;
065: if (_txtByClient == null
066: || !Objects.equals(_txtByClient, value)) {
067: _txtByClient = null;
068: smartUpdate("value", value);
069: }
070: }
071: }
072:
073: /**
074: * Returns the toolbar set of this FCKeditor.
075: * <p>
076: * Default: null
077: */
078: public String getToolbarSet() {
079: return _tbset;
080: }
081:
082: /**
083: * Sets the value for this FCKeditor.
084: */
085: public void setToolbarSet(String tbset) {
086: if (tbset != null && tbset.length() == 0)
087: tbset = null;
088: if (!Objects.equals(tbset, _tbset)) {
089: _tbset = tbset;
090: smartUpdate("tbset", tbset);
091: }
092: }
093:
094: /**
095: * Returns the width of this FCKeditor.
096: * <p>
097: * Default: 100%
098: */
099: public String getWidth() {
100: return _width;
101: }
102:
103: /**
104: * Sets the width of this FCKeditor.
105: */
106: public void setWidth(String width) {
107: if (width != null && width.length() == 0)
108: width = null;
109: if (!Objects.equals(width, _width)) {
110: _width = width;
111: smartUpdate("width", width);
112: }
113: }
114:
115: /**
116: * Returns the height of this FCKeditor.
117: * <p>
118: * Default: 200px
119: */
120: public String getHeight() {
121: return _height;
122: }
123:
124: /**
125: * Sets the height of this FCKeditor.
126: */
127: public void setHeight(String height) {
128: if (height != null && height.length() == 0)
129: height = null;
130: if (!Objects.equals(height, _height)) {
131: _height = height;
132: smartUpdate("height", height);
133: }
134: }
135:
136: /**
137: * Returns the HTML attributes for this tag.
138: * <p>
139: * Used only for component development, not for application developers.
140: */
141: public String getOuterAttrs() {
142: return Events.isListened(this , "onChange", true) ? " z.onChange=\"true\""
143: : null;
144: }
145:
146: /**
147: * Set the url of the custom configuration .js file. See FCKeditor's
148: * <a href="http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Configurations_File">
149: * Configurtions File</a> for details.
150: * @param url the url path for the customized configuration path
151: */
152: public void setCustomConfigurationsPath(String url) {
153: _customPath = url;
154: }
155:
156: /**
157: * Get the url of the custom configuration .js file. See FCKeditor's
158: * <a href="http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Configurations_File">
159: * Configurtions File</a> for details.
160: */
161: public String getCustomConfigurationsPath() {
162: return _customPath;
163: }
164:
165: /**
166: * Returns the configuration in String.
167: * <p>
168: * Used only for component development, not for application developers.
169: */
170: public String getConfigString() {
171: if (_customPath != null && _customPath.length() > 0) {
172: return "CustomConfigurationsPath="
173: + Executions.encodeURL(_customPath);
174: }
175: return "";
176: }
177:
178: // -- Super --//
179: /** Not childable. */
180: public boolean isChildable() {
181: return false;
182: }
183:
184: protected Object newExtraCtrl() {
185: return new Inputable() {
186: /** Called by the browser to notify the content is changed. */
187: public void setTextByClient(String text) {
188: _txtByClient = text;
189: try {
190: setValue(text);
191: } finally {
192: _txtByClient = null;
193: }
194: }
195: };
196: }
197:
198: /**
199: *
200: * Used to catch "onSave" command from brower side.
201: * <p>
202: * Used only for component development, not for application developers.
203: */
204:
205: static {
206: new GenericCommand("onSave", Command.IGNORE_OLD_EQUIV);
207: };
208: }
|