001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.comp;
025:
026: import jacareto.system.Environment;
027: import jacareto.system.EnvironmentMember;
028:
029: import java.awt.Component;
030:
031: /**
032: * <p>
033: * A item of the components instance. Represents a known, not ignored component.
034: * </p>
035: *
036: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a> (Version 1.1)
037: * @version 1.1
038: */
039: class CompItem extends EnvironmentMember {
040: /** The corresponding component. */
041: private Component component;
042:
043: /** The name of the component. */
044: private String name;
045:
046: /** Whether or not this comp item is enabled for capturing. */
047: private boolean isEnabled;
048:
049: /** Whether or not the component should never be enabled. */
050: private boolean isAlwaysDisabled;
051:
052: /** Whether this comp item is visible or not. */
053: private boolean isVisible;
054:
055: /** The children count. */
056: private int childrenCount;
057:
058: /** The children. */
059: private Component[] children;
060:
061: /**
062: * Creates a new components item. The comp item is enabled by default. The children count is 0
063: * at the beginning, the comp item is nor ignored. The comp item is visible if and only if the
064: * component is visible.
065: *
066: * @param env the environment.
067: * @param component the corresponding component
068: * @param name the name of the component
069: */
070: public CompItem(Environment env, Component component, String name) {
071: super (env);
072: this .component = component;
073: this .name = name;
074: setEnabled(true);
075: setAlwaysDisabled(false);
076: setVisible(component.isVisible());
077: setChildrenCount(0);
078: }
079:
080: /**
081: * Returns the corresponding component.
082: *
083: * @return DOCUMENT ME!
084: */
085: public Component getComponent() {
086: return component;
087: }
088:
089: /**
090: * Returns the name of the component.
091: *
092: * @return DOCUMENT ME!
093: */
094: public String getName() {
095: return name;
096: }
097:
098: /**
099: * Specifies that the component should always be disabled.
100: *
101: * @param isAlwaysDisabled DOCUMENT ME!
102: */
103: public void setAlwaysDisabled(boolean isAlwaysDisabled) {
104: this .isAlwaysDisabled = isAlwaysDisabled;
105: }
106:
107: /**
108: * Specifies whether or not the comp item is enabled for capturing. If the component is always
109: * disabled, this method does nothing; the component keeps being disabled.
110: *
111: * @param isEnabled <code>true</code> if the comp item is enabled, otherwise <code>false</code>
112: */
113: public void setEnabled(boolean isEnabled) {
114: this .isEnabled = (!isAlwaysDisabled) && isEnabled;
115: }
116:
117: /**
118: * Returns whether or not the component is enabled.
119: *
120: * @return DOCUMENT ME!
121: */
122: public boolean isEnabled() {
123: return isEnabled;
124: }
125:
126: /**
127: * Returns whether or not the comp item is visible.
128: *
129: * @return DOCUMENT ME!
130: */
131: public boolean isVisible() {
132: return isVisible;
133: }
134:
135: /**
136: * Specifies whether or not the comp item is visible.
137: *
138: * @param isVisible <code>true</code> if the comp item is visible, otherwise <code>false</code>
139: */
140: public void setVisible(boolean isVisible) {
141: this .isVisible = isVisible;
142: }
143:
144: /**
145: * Sets the children count for this component item.
146: *
147: * @param childrenCount the children count
148: */
149: public void setChildrenCount(int childrenCount) {
150: this .childrenCount = childrenCount;
151: }
152:
153: /**
154: * Returns the children count.
155: *
156: * @return DOCUMENT ME!
157: */
158: public int getChildrenCount() {
159: return childrenCount;
160: }
161:
162: /**
163: * Sets the children.
164: *
165: * @param children DOCUMENT ME!
166: */
167: public void setChildren(Component[] children) {
168: this .children = children;
169: }
170:
171: /**
172: * Returns the children.
173: *
174: * @return DOCUMENT ME!
175: */
176: public Component[] getChildren() {
177: return children;
178: }
179: }
|