diff -r f1112f777ce9 -r 96906a986c3b testdev/ite/src/com.nokia.testfw.stf.configeditor/src/com/nokia/testfw/stf/configeditor/editors/ModulesTreeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdev/ite/src/com.nokia.testfw.stf.configeditor/src/com/nokia/testfw/stf/configeditor/editors/ModulesTreeNode.java Tue Mar 30 14:39:29 2010 +0800 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.testfw.stf.configeditor.editors; + +import java.util.ArrayList; +import java.util.List; + +import com.nokia.testfw.stf.configmanager.SectionElementType; + +/** + * Modules tree node + * + */ +public class ModulesTreeNode { + /** + * Node type + */ + private SectionElementType type; + /** + * Node value + */ + private String value; + /** + * Index in config source. + * + * Depens on node type it represents module index in config + * file or testcase file entry index in [New_Module]...[End_Module] + * section of config file. + */ + private int index; + /** + * Parent node + */ + ModulesTreeNode parent = null; + /** + * List of node childrens + */ + private List childrens = null; + /** + * Creates node + */ + public ModulesTreeNode() { + childrens = new ArrayList(); + } + + /** + * Creates node + * @param parent parent node + */ + public ModulesTreeNode(ModulesTreeNode parent) { + childrens = new ArrayList(); + if ( parent != null ) { + this.parent = parent; + parent.childrens.add(this); + } + } + + /** + * Gets node childrens + * @return list of node childrens + */ + public List getChildrens() { + return childrens; + } + + /** + * Adds child node + * @param node child node to add + */ + public void addChildren( ModulesTreeNode node ) { + if ( node != null ) { + node.parent = this; + childrens.add( node ); + } + } + + /** + * Removes child node + * @param node node to remove + */ + public void removeChildrean( ModulesTreeNode node ) { + childrens.remove( node ); + node.parent = null; + } + + /** + * Disposes node + */ + public void dispose() { + if ( parent != null ) { + parent.childrens.remove(this); + this.parent = null; + } + } + + /** + * Gets index value + * @return index value + */ + public int getIndex() { + return index; + } + + /** + * Sets new index value + * @param index new index value + */ + public void setIndex(int index) { + this.index = index; + } + + /** + * Gets parent node + * @return parent node + */ + public ModulesTreeNode getParent() { + return parent; + } + + /** + * Sets new parent node + * @param parent parent node + */ + public void setParent( ModulesTreeNode parent ) { + if ( parent != null ) { + this.parent = parent; + parent.childrens.add( this ); + } + } + + /** + * Gets node type + * @return node type + */ + public SectionElementType getType() { + return type; + } + + /** + * Sets new node type value + * @param type new node type value + */ + public void setType(SectionElementType type) { + this.type = type; + } + + /** + * Gets node value + * @return node value + */ + public String getValue() { + return value; + } + + /** + * Sets new node value + * @param value new node value + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Checks if node has childreans + * @return true if node has childrens, false + * if node does not have childrens + */ + public boolean hasChildren() { + if ( ( childrens != null ) && ( childrens.size() != 0 ) ) { + return true; + } + return false; + } + + /** + * Removes all children nodes + */ + public void removeAllChildreans() { + childrens = new ArrayList(); + } +} \ No newline at end of file