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:
028: import java.awt.Component;
029:
030: /**
031: * This is a class which provides methods for all components.
032: *
033: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
034: * @version 1.0
035: */
036: public class AWTComponentHandler extends ComponentHandler {
037: /**
038: * Creates a new component handler.
039: *
040: * @param env the environment
041: * @param components the components instance
042: */
043: public AWTComponentHandler(Environment env, Components components) {
044: super (env, components);
045: }
046:
047: /**
048: * Returns whether this handler is responsible for the given component. This class is always
049: * responsible.
050: *
051: * @param component the component
052: *
053: * @return <code>true</code>
054: */
055: public boolean handlesComponent(Component component) {
056: return true;
057: }
058:
059: /**
060: * Returns a name for the component.
061: *
062: * @param component the component
063: *
064: * @return a String with the name of the component
065: */
066: public String getName(Component component) {
067: String result = component.getClass().getName();
068: result = result.substring(result.lastIndexOf('.') + 1);
069:
070: return result;
071: }
072:
073: /**
074: * Returns an empty array
075: *
076: * @param component the component
077: *
078: * @return the empty array
079: */
080: public Component[] getChildren(Component component) {
081: return new Component[0];
082: }
083:
084: /**
085: * Returns the parent of the component.
086: *
087: * @param component the component
088: *
089: * @return the parent; the return value may be <code>null</code>
090: */
091: public Component getParent(Component component) {
092: return component.getParent();
093: }
094:
095: /**
096: * Returns <code>false</code>.
097: *
098: * @return DOCUMENT ME!
099: */
100: public boolean isAlwaysDisabled() {
101: return false;
102: }
103: }
|