001: //Copyright (c) Hans-Joachim Daniels 2005
002: //
003: //This program is free software; you can redistribute it and/or modify
004: //it under the terms of the GNU General Public License as published by
005: //the Free Software Foundation; either version 2 of the License, or
006: //(at your option) any later version.
007: //
008: //This program is distributed in the hope that it will be useful,
009: //but WITHOUT ANY WARRANTY; without even the implied warranty of
010: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: //GNU General Public License for more details.
012: //
013: //You can either finde the file LICENSE or LICENSE.TXT in the source
014: //distribution or in the .jar file of this application
015:
016: package de.uka.ilkd.key.ocl.gf;
017:
018: import java.util.logging.Logger;
019:
020: /**
021: * @author hdaniels
022: * An object of this type knows how it self should be rendered,
023: * via Printname how its children should be rendered.
024: * This means the tooltip information it got from there.
025: * Knows nothing directly of the type of the node, which an object of this class
026: * represents. That's whats GfAstNode is for.
027: */
028: abstract class AstNodeData {
029: protected static Logger logger = Logger
030: .getLogger(DynamicTree2.class.getName());
031:
032: /**
033: * @return the printname associated with this object
034: */
035: public abstract Printname getPrintname();
036:
037: /**
038: * @return the parameter tooltip that this node has as a child
039: * of its parent (who gave it to it depending on its position)
040: */
041: public abstract String getParamTooltip();
042:
043: /**
044: * keeps track of the number of children of this node.
045: * It has to be increased whenever a new child of this node is
046: * added.
047: */
048: public int childNum = 0;
049: /**
050: * The position String in the GF AST for this node
051: * in Haskell notation.
052: */
053: public final String position;
054: /**
055: * the GF node connected to this NodeData, not the JTree node
056: */
057: public final GfAstNode node;
058:
059: /**
060: * If a subtyping witness is missing, then this flag is false
061: */
062: public boolean subtypingStatus = true;
063:
064: /**
065: * if this is the active, selected, focused node
066: */
067: public final boolean selected;
068:
069: /**
070: * The constraint, that is valid on this node.
071: * If this node introduced a node itself and did not just inherit
072: * one, they are just concatenated.
073: * Until now, only the presence of a non-empty string here is used,
074: * so that is not important yet.
075: */
076: public final String constraint;
077:
078: /**
079: * some nodes like coerce should, if possible, be covered from the
080: * users eyes. If this variable is greater than -1, the child
081: * with that number is shown instead of this node.
082: * This node will not appear in the tree.
083: */
084: public int showInstead = -1;
085:
086: /**
087: * A simple setter constructor, that sets the fields of this class (except showInstead)
088: * @param node the GF node connected to this NodeData, not the JTree node
089: * @param pos The position String in the GF AST for this node
090: * in Haskell notation.
091: * @param selected if this is the active, selected, focused node
092: * @param constraint The GF constraint introduced in this node
093: */
094: protected AstNodeData(GfAstNode node, String pos, boolean selected,
095: String constraint) {
096: this .node = node;
097: this .position = pos;
098: this .selected = selected;
099: // I have no better idea, how to clutch them together, since
100: // I don't need the content of this field right now.
101: this .constraint = node.constraint + constraint;
102: }
103:
104: public String toString() {
105: return this.node.getLine();
106: }
107:
108: }
|