1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2002                                              */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 package com.ibm.staf.service.stax;
9 
10 import java.awt.*;
11 import javax.swing.*;
12 import javax.swing.tree.*;
13 import javax.swing.border.*;
14 import java.util.*;
15 
16 public class STAXMonitorTreeNode extends DefaultMutableTreeNode
17 {
18     public static int blockNodeType = 1;
19     public static int processNodeType = 2;
20     public static int commandNodeType = 3;
21     public static int subjobNodeType = 4;
22 
23     public static int blockRunning = 1;
24     public static int blockHeld = 2;
25     public static int blockParentHeld = 3;
26 
27     public int fNodeType = 0;
28     public String fPluginNodeType;
29     public int fBlockStatus = blockRunning;
30     private String processMonitorText = "";
31     private String elapsedTime = "";
32     private String pluginText = "";
33 
34     private ImageIcon icon;
35     private JComponent component = null;
36 
STAXMonitorTreeNode()37     public STAXMonitorTreeNode()
38     {
39         super();
40     }
41 
STAXMonitorTreeNode(Object userObject)42     public STAXMonitorTreeNode(Object userObject)
43     {
44         super(userObject);
45     }
46 
STAXMonitorTreeNode(Object userObject, int nodeType)47     public STAXMonitorTreeNode(Object userObject, int nodeType)
48     {
49         super(userObject);
50         fNodeType = nodeType;
51     }
52 
STAXMonitorTreeNode(Object userObject, String pluginNodeType, ImageIcon image, JComponent component)53     public STAXMonitorTreeNode(Object userObject, String pluginNodeType,
54         ImageIcon image, JComponent component)
55     {
56         super(userObject);
57         fPluginNodeType = pluginNodeType;
58 
59         pluginText = (String)userObject;
60         icon = image;
61 
62         this.component = component;
63     }
64 
setBlockStatus(int status)65     public void setBlockStatus(int status)
66     {
67         fBlockStatus = status;
68 
69         int childCount = getChildCount();
70 
71         for (int i = 0; i < childCount; i++)
72         {
73             STAXMonitorTreeNode child = (STAXMonitorTreeNode)getChildAt(i);
74 
75             if (child.fNodeType == blockNodeType)
76             {
77                 if (child.fBlockStatus != blockHeld)
78                 {
79                     if (fBlockStatus == blockHeld)
80                     {
81                         child.setBlockStatus(blockParentHeld);
82                     }
83                     else if (fBlockStatus == blockParentHeld)
84                     {
85                         child.setBlockStatus(blockParentHeld);
86                     }
87                     else
88                     {
89                         child.setBlockStatus(blockRunning);
90                     }
91                 }
92             }
93         }
94 
95     }
96 
getBlockStatus()97     public int getBlockStatus()
98     {
99         return fBlockStatus;
100     }
101 
setProcessMonitorText(String text)102     public void setProcessMonitorText(String text)
103     {
104         processMonitorText = text;
105     }
106 
setPluginText(String text)107     public void setPluginText(String text)
108     {
109         pluginText = text;
110     }
111 
getPluginText()112     public String getPluginText()
113     {
114         return pluginText;
115     }
116 
getProcessMonitorText()117     public String getProcessMonitorText()
118     {
119         return processMonitorText;
120     }
121 
setElapsedTime(String time)122     public void setElapsedTime(String time)
123     {
124         elapsedTime = time;
125     }
126 
getElapsedTime()127     public String getElapsedTime()
128     {
129         return elapsedTime;
130     }
131 
getIcon()132     public ImageIcon getIcon()
133     {
134         return icon;
135     }
136 
getComponent()137     public JComponent getComponent()
138     {
139         return component;
140     }
141 }