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.struct;
025:
026: import jacareto.parse.RecordTokenizer;
027: import jacareto.record.ComponentEventRecordable;
028: import jacareto.system.Environment;
029:
030: import java.awt.event.ComponentEvent;
031:
032: import java.util.Vector;
033:
034: /**
035: * A window has been moved. A structure element can parse a part of a record.
036: *
037: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
038: * @version 1.01
039: */
040: public class WindowMoved extends StructureElement {
041: /**
042: * Creates a new "window moved" structure element.
043: *
044: * @param env the environment
045: * @param children the child structure elements
046: */
047: public WindowMoved(Environment env, StructureElement[] children) {
048: super (env, children);
049: }
050:
051: /**
052: * Parses a record which is tokenized by the given record tokenizer.
053: *
054: * @param env DOCUMENT ME!
055: * @param recordTokenizer the record tokenizer
056: *
057: * @return a structure element, or <code>null</code> if this class cannot parse the record at
058: * the current position
059: */
060: public static StructureElement parse(Environment env,
061: RecordTokenizer recordTokenizer) {
062: Vector childrenToAdd = new Vector(5, 5);
063: StructureElement result = null;
064: StructureElement[] children = null;
065:
066: try {
067: boolean found = false;
068: ComponentEventRecordable lastRecordable = null;
069:
070: do {
071: found = false;
072:
073: ComponentEventRecordable cRecordable = (ComponentEventRecordable) recordTokenizer
074: .get(0);
075:
076: if ((cRecordable.getID() == ComponentEvent.COMPONENT_MOVED)
077: || (cRecordable.getID() == ComponentEvent.COMPONENT_RESIZED)) {
078: if ((lastRecordable == null)
079: || lastRecordable.getSourceName().equals(
080: cRecordable.getSourceName())) {
081: childrenToAdd.add(cRecordable);
082: recordTokenizer.forward();
083: lastRecordable = cRecordable;
084: found = true;
085: }
086: }
087: } while (found);
088: } catch (Throwable t) {
089: ;
090: }
091:
092: if (childrenToAdd.size() > 0) {
093: children = vectorToArray(childrenToAdd);
094: result = new WindowMoved(env, children);
095: }
096:
097: return result;
098: }
099:
100: /**
101: * Returns the name of the element.
102: *
103: * @return the name
104: */
105: public String getElementName() {
106: return language.getString("Structures.WindowMoved.Name");
107: }
108:
109: /**
110: * Returns a description of the element.
111: *
112: * @return the description
113: */
114: public String getElementDescription() {
115: return language.getString("Structures.WindowMoved.Description");
116: }
117:
118: /**
119: * Returns a String which describes the content of the element shortly.
120: *
121: * @return a string with a short description of the element
122: */
123: public String toShortString() {
124: String result = getElementName();
125:
126: return result;
127: }
128:
129: /**
130: * Clones the element.
131: *
132: * @return DOCUMENT ME!
133: */
134: public Object clone() {
135: StructureElement[] clonedChildren = getClonedChildren();
136:
137: return new WindowMoved(env, clonedChildren);
138: }
139: }
|