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.parse.RecordTokenizerState;
028: import jacareto.record.MouseEventRecordable;
029: import jacareto.system.Environment;
030:
031: /**
032: * The scroll bar has been dragged.
033: *
034: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
035: * @version 1.0
036: */
037: public class ScrollBarDrag extends StructureElement {
038: /**
039: * Creates a new "scroll bar drag" structure element.
040: *
041: * @param env the environment
042: * @param children the child structure elements
043: */
044: public ScrollBarDrag(Environment env, StructureElement[] children) {
045: super (env, children);
046: }
047:
048: /**
049: * Parses a record which is tokenized by the given record tokenizer.
050: *
051: * @param env DOCUMENT ME!
052: * @param recordTokenizer the record tokenizer
053: *
054: * @return a structure element, or <code>null</code> if this class cannot parse the record at
055: * the current position
056: */
057: public static StructureElement parse(Environment env,
058: RecordTokenizer recordTokenizer) {
059: StructureElement result = null;
060:
061: RecordTokenizerState rtState = recordTokenizer.saveState();
062:
063: try {
064: MouseDrag drag = (MouseDrag) MouseDrag.parse(env,
065: recordTokenizer);
066:
067: if (drag == null) {
068: return null;
069: }
070:
071: MouseEventRecordable mousePressed = drag.getMousePressed();
072: MouseEventRecordable mouseReleased = drag
073: .getMouseReleased();
074:
075: if ((mousePressed.getSourceClass().equals(
076: "javax.swing.JScrollPane$ScrollBar") && mouseReleased
077: .getSourceClass().equals(
078: "javax.swing.JScrollPane$ScrollBar"))
079: || (mousePressed.getSourceClass().equals(
080: "javax.swing.JScrollBar") && mouseReleased
081: .getSourceClass().equals(
082: "javax.swing.JScrollBar"))) {
083: StructureElement[] children = new StructureElement[1];
084: children[0] = drag;
085: result = new ScrollBarDrag(env, children);
086: } else {
087: recordTokenizer.restoreState(rtState);
088: }
089: } catch (Throwable t) {
090: recordTokenizer.restoreState(rtState);
091: }
092:
093: return result;
094: }
095:
096: /**
097: * Returns the name of the element.
098: *
099: * @return the name
100: */
101: public String getElementName() {
102: return language.getString("Structures.ScrollBarDrag.Name");
103: }
104:
105: /**
106: * Returns a description of the element.
107: *
108: * @return the description
109: */
110: public String getElementDescription() {
111: return language
112: .getString("Structures.ScrollBarDrag.Description");
113: }
114:
115: /**
116: * Returns a String which describes the content of the element shortly.
117: *
118: * @return a string with a short description of the element
119: */
120: public String toShortString() {
121: return getElementName();
122: }
123:
124: /**
125: * Clones the element.
126: *
127: * @return DOCUMENT ME!
128: */
129: public Object clone() {
130: StructureElement[] clonedChildren = getClonedChildren();
131:
132: return new ScrollBarDrag(env, clonedChildren);
133: }
134: }
|