001: /*
002: #IFNDEF ALT_LICENSE
003: ThinWire(R) RIA Ajax Framework
004: Copyright (C) 2003-2007 Custom Credit Systems
005:
006: This library is free software; you can redistribute it and/or modify it under
007: the terms of the GNU Lesser General Public License as published by the Free
008: Software Foundation; either version 2.1 of the License, or (at your option) any
009: later version.
010:
011: This library is distributed in the hope that it will be useful, but WITHOUT ANY
012: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015: You should have received a copy of the GNU Lesser General Public License along
016: with this library; if not, write to the Free Software Foundation, Inc., 59
017: Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019: Users who would rather have a commercial license, warranty or support should
020: contact the following company who invented, built and supports the technology:
021:
022: Custom Credit Systems, Richardson, TX 75081, USA.
023: email: info@thinwire.com ph: +1 (888) 644-6405
024: http://www.thinwire.com
025: #ENDIF
026: [ v1.2_RC2 ]
027: */
028: package thinwire.ui;
029:
030: import java.util.List;
031:
032: import thinwire.util.ImageInfo;
033:
034: /**
035: * @author Joshua J. Gertzen
036: */
037: public interface HierarchyComponent<HI extends HierarchyComponent.Item>
038: extends ItemChangeEventComponent {
039: public interface Item<H extends HierarchyComponent, I extends Item> {
040: public static final String PROPERTY_ITEM_IMAGE = "itemImage";
041: public static final String PROPERTY_ITEM_TEXT = "itemText";
042: public static final String PROPERTY_ITEM_USER_OBJECT = "itemUserObject";
043:
044: /**
045: * Get the text that is displayed for the item in the menu.
046: * @return the text that is displayed for the item, or an empty string if none.
047: */
048: public String getText();
049:
050: /**
051: * Set the text that is displayed for the item in the menu.
052: * @param text the text that should be displayed for the item.
053: */
054: public void setText(String text);
055:
056: /**
057: * Get the image file name that is displayed on the left side of the item.
058: * @return the image that is displayed for the item, or an empty string if none.
059: */
060: public String getImage();
061:
062: /**
063: * Set the image file name that is displayed on the left side of the item.
064: * @param image the name of the image file that should be displayed for the item.
065: * @throws IllegalArgumentException if the image file does not exist.
066: * @throws RuntimeException if the system cannot determine the image file's canonical path.
067: */
068: public void setImage(String image);
069:
070: /**
071: * Returns an immutable <code>ImageInfo</code> class that provides information
072: * about the assigned image, such as width, height, format, etc.
073: * @return an immutable <code>ImageInfo</code> describing this item's image.
074: */
075: public ImageInfo getImageInfo();
076:
077: /**
078: * Get the user defined value for this item.
079: * @return the user defined value for this item if one is defined, null otherwise.
080: */
081: public Object getUserObject();
082:
083: /**
084: * Set a user defined value for this item.
085: * @param value an object that should be associated to this item.
086: */
087: public void setUserObject(Object userObject);
088:
089: /**
090: * A convenience method that returns the index of this item in it's parents children List. Equivalent to
091: * <code>item.getParent().getChildren().indexOf(item);</code>.
092: * @return the index of this item in it's parents children List.
093: * @throws IllegalStateException if this item has not yet been added to another Menu.Item or if this item is the root item
094: * for the menu.
095: */
096: public int getIndex();
097:
098: public H getHierarchy();
099:
100: /**
101: * Get the parent object of this item.
102: * @return if this item is the root item, then this returns the Menu, otherwise this returns the parentMenu.Item or null if
103: * this item has not yet been added to another Menu.Item.
104: */
105: public Object getParent();
106:
107: public boolean hasChildren();
108:
109: /**
110: * Get the <code>List</code> that contains the children of this item.
111: * @return the <code>List</code> that contains the children of this item or an empty <code>List</code> if there are no
112: * children.
113: */
114: public List<I> getChildren();
115: }
116:
117: /**
118: * Get the root item of the Menu.
119: * @return the root item of the Menu.
120: */
121: public HI getRootItem();
122: }
|