001: /**
002: *
003: */package org.jtestcase.core.model;
004:
005: import java.util.ArrayList;
006: import java.util.List;
007:
008: import org.jtestcase.plugin.guimodel.intf.IUINode;
009: import org.jtestcase.plugin.guimodel.intf.IUINodeSupport;
010:
011: /**
012: * @author fausto
013: *
014: */
015: public class Tests implements IUINode {
016:
017: /**
018: * The list of nested instances in the param
019: */
020: private List nestedClasses;
021:
022: private IUINodeSupport uiSupport = null;
023:
024: private boolean isGUIsupported = false;
025:
026: public Tests() {
027: nestedClasses = new ArrayList();
028: instantiateUISupport();
029: }
030:
031: public void addClass(TestClass testClass) {
032: nestedClasses.add(testClass);
033: if (isGUIsupported())
034: uiSupport.add((IUINode) testClass);
035: }
036:
037: private void instantiateUISupport() {
038: try {
039: uiSupport = (IUINodeSupport) Class.forName(
040: IUINodeSupport.IMPL).newInstance();
041: uiSupport.setNode(this );
042: setGUIsupported(true);
043: } catch (InstantiationException e) {
044: // TODO Auto-generated catch block
045: System.err.println("WARN : NOT USING UI SUPPORT");
046: // e.printStackTrace();
047: } catch (IllegalAccessException e) {
048: // TODO Auto-generated catch block
049: System.err.println("WARN : NOT USING UI SUPPORT");
050: // e.printStackTrace();
051: } catch (ClassNotFoundException e) {
052: // TODO Auto-generated catch block
053: System.err.println("WARN : NOT USING UI SUPPORT");
054: // e.printStackTrace();
055: }
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see treemodel.intf.IUINode#getNodes()
062: */
063: public List getNodes() {
064: // TODO Auto-generated method stub
065: return uiSupport.getNodes();
066: }
067:
068: /*
069: * (non-Javadoc)
070: *
071: * @see treemodel.intf.IUINode#remove(treemodel.intf.IUINode)
072: */
073: public void remove(IUINode toRemove) {
074: uiSupport.remove(toRemove);
075: }
076:
077: /*
078: * (non-Javadoc)
079: *
080: * @see treemodel.intf.IUINode#add(treemodel.intf.IUINode)
081: */
082: public void add(IUINode toAdd) {
083: // TODO Auto-generated method stub
084: // call business delegate method
085: addClass((TestClass) toAdd);
086: }
087:
088: /*
089: * (non-Javadoc)
090: *
091: * @see treemodel.intf.IUINode#getNode()
092: */
093: public IUINode getNode() {
094: // TODO Auto-generated method stub
095: return uiSupport.getNode();
096: }
097:
098: /*
099: * (non-Javadoc)
100: *
101: * @see treemodel.intf.IUINode#getNodeLabel()
102: */
103: public String getNodeLabel() {
104: // TODO Auto-generated method stub
105: return "tests";
106: }
107:
108: /*
109: * (non-Javadoc)
110: *
111: * @see treemodel.intf.IUINode#getNodeImage()
112: */
113: public String getNodeImage() {
114: // TODO Auto-generated method stub
115: return "book.gif";
116: }
117:
118: /*
119: * (non-Javadoc)
120: *
121: * @see treemodel.intf.IUINode#size()
122: */
123: public int size() {
124: // TODO Auto-generated method stub
125: return uiSupport.size();
126: }
127:
128: /*
129: * (non-Javadoc)
130: *
131: * @see treemodel.intf.IUINode#getUISupport()
132: */
133: public Object getUISupport() {
134: // TODO Auto-generated method stub
135: return uiSupport;
136: }
137:
138: public boolean isGUIsupported() {
139: return isGUIsupported;
140: }
141:
142: public void setGUIsupported(boolean isGUIsupported) {
143: this.isGUIsupported = isGUIsupported;
144: }
145:
146: }
|