1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.tree.nodes;
14
15 import com.eviware.soapui.model.iface.Interface;
16 import com.eviware.soapui.model.iface.InterfaceListener;
17 import com.eviware.soapui.model.iface.Operation;
18 import com.eviware.soapui.model.iface.Request;
19 import com.eviware.soapui.model.tree.AbstractTreeNode;
20 import com.eviware.soapui.model.tree.SoapUITreeNode;
21
22 /***
23 * SoapUITreeNode for Interface implementations
24 *
25 * @author Ole.Matzura
26 */
27
28 public class InterfaceTreeNode extends AbstractTreeNode
29 {
30 private final Interface iface;
31 private InternalInterfaceListener internalInterfaceListener;
32
33 public InterfaceTreeNode( Interface iface )
34 {
35 super( iface, iface.getProject() );
36 this.iface = iface;
37
38 internalInterfaceListener = new InternalInterfaceListener();
39 iface.addInterfaceListener( internalInterfaceListener);
40 }
41
42 public void release()
43 {
44 super.release();
45
46 iface.removeInterfaceListener( internalInterfaceListener );
47 }
48
49 public int getChildCount()
50 {
51 return iface.getOperationCount();
52 }
53
54 public int getIndexOfChild(Object child)
55 {
56 for( int c = 0; c < iface.getOperationCount(); c++ )
57 {
58 if( iface.getOperationAt( c ).getTreeNode() == child ) return c;
59 }
60
61 return -1;
62 }
63
64 public SoapUITreeNode getChildNode(int index)
65 {
66 return iface.getOperationAt(index).getTreeNode();
67 }
68
69 private class InternalInterfaceListener extends InternalTreeNodeListener implements InterfaceListener
70 {
71 public InternalInterfaceListener()
72 {
73 super( getTreeModel() );
74 }
75
76 public void requestAdded(Request request)
77 {
78 notifyNodeInserted( request );
79 }
80
81 public void requestRemoved(Request request)
82 {
83 notifyNodeRemoved( request );
84 }
85
86 public void operationAdded(Operation operation)
87 {
88 notifyNodeInserted( operation );
89 }
90
91 public void operationRemoved(Operation operation)
92 {
93 notifyNodeRemoved( operation );
94 }
95 }
96 }