001: /* Fisheyeitem.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Thu Dec 29 20:49:04 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.dojo;
018:
019: import org.zkoss.lang.Objects;
020: import org.zkoss.xml.HTMLs;
021:
022: import org.zkoss.zk.ui.Component;
023: import org.zkoss.zk.ui.AbstractComponent;
024: import org.zkoss.zk.ui.UiException;
025:
026: /**
027: * A fisheye item.
028: *
029: * @author tomyeh
030: * @version $Revision: 1.7 $ $Date: 2006/03/17 10:36:24 $
031: * @see Fisheyelist
032: */
033: public class Fisheyeitem extends AbstractComponent {
034: private String _image, _label = "";
035:
036: /** Returns the label (never null).
037: * <p>Default: "".
038: */
039: public String getLabel() {
040: return _label;
041: }
042:
043: /** Sets the label.
044: */
045: public void setLabel(String label) {
046: if (label == null)
047: label = "";
048: if (!Objects.equals(_label, label)) {
049: _label = label;
050: smartUpdate("dojo.caption", _label);
051: }
052: }
053:
054: /** Returns the image URI.
055: * <p>Default: null.
056: */
057: public String getImage() {
058: return _image;
059: }
060:
061: /** Sets the image URI.
062: */
063: public void setImage(String image) {
064: if (image != null && image.length() == 0)
065: image = null;
066: if (!Objects.equals(_image, image)) {
067: _image = image;
068: smartUpdate("dojo.iconsrc", _image);
069: }
070: }
071:
072: /** Returns the HTML attributes for this component.
073: * <p>Used only for component development, not for application developers.
074: */
075: public String getOuterAttrs() {
076: final StringBuffer sb = new StringBuffer(128);
077: HTMLs.appendAttribute(sb, "dojo:iconsrc", getDesktop()
078: .getExecution().encodeURL(
079: _image != null ? _image : "~./img/spacer.gif"));
080: HTMLs.appendAttribute(sb, "dojo:caption", _label);
081: return sb.toString();
082: }
083:
084: //-- Component --//
085: public void smartUpdate(String attr, String value) {
086: //FUTURE: use JavaScript to control
087: final Component p = getParent();
088: if (p != null)
089: p.invalidate();
090: }
091:
092: public void setParent(Component parent) {
093: if (parent != null && !(parent instanceof Fisheyelist))
094: throw new UiException(
095: "Unsupported parent for fisheyeitem: " + parent);
096: super .setParent(parent);
097: }
098:
099: /** Not childable. */
100: public boolean isChildable() {
101: return false;
102: }
103: }
|