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: * This is an abstract superclass for classes which provide methods for specific components.
033: *
034: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
035: * @version 1.0
036: */
037: public abstract class ComponentHandler extends EnvironmentMember {
038: /** The components instance. */
039: protected Components components;
040:
041: /**
042: * Creates a new component handler.
043: *
044: * @param env the environment
045: * @param components the components instance
046: */
047: public ComponentHandler(Environment env, Components components) {
048: super (env);
049: this .components = components;
050: }
051:
052: /**
053: * Returns whether this handler is responsible for the given component.
054: *
055: * @param component the component
056: *
057: * @return <code>true</code> if this handler is responsible for the component; otherwise
058: * <code>false</code>.
059: */
060: public abstract boolean handlesComponent(Component component);
061:
062: /**
063: * Returns a name for the component. The precondition for this method is that this component
064: * handler handles the given component.
065: *
066: * @param component the component
067: *
068: * @return a String with the name of the component. The String should not contain any dots.
069: */
070: public abstract String getName(Component component);
071:
072: /** Returns an indicator string, or <code>null</code> if there is no indicator
073: * @param component the component
074: * @return the indicator string (<code>null</code> by default. Please override in subclasses)
075: */
076: public String getIndicatorString(Component component) {
077: return null;
078: }
079:
080: /**
081: * Returns the child components of the component. The precondition for this method is that this
082: * component handler handles the given component.
083: *
084: * @param component the component
085: *
086: * @return the child components; the return value may be <code>null</code>
087: */
088: public abstract Component[] getChildren(Component component);
089:
090: /**
091: * Returns the parent of the component. The precondition for this method is that this component
092: * handler handles the given component.
093: *
094: * @param component the component
095: *
096: * @return the parent; the return value may be <code>null</code>
097: */
098: public abstract Component getParent(Component component);
099:
100: /**
101: * Things that should be done when a component has been added to the components instance. This
102: * method does nothing. It should be overwritten in subclasses.
103: *
104: * @param component the component
105: */
106: public void init(Component component) {
107: }
108:
109: /**
110: * Returns <code>true</code> if the component should always be disabled.
111: *
112: * @return DOCUMENT ME!
113: */
114: public abstract boolean isAlwaysDisabled();
115: }
|