TreeBrowserNode.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. * TreeBrowserNode.java
  10. *
  11. * Copyright (C) 2005 Cognos ULC, an IBM Company. All rights reserved.
  12. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. */
  14. //import com.cognos.developer.schemas.bibus._3.*;
  15. import javax.swing.ImageIcon;
  16. import javax.swing.tree.DefaultMutableTreeNode;
  17. import com.cognos.developer.schemas.bibus._3.BaseClass;
  18. import com.cognos.developer.schemas.bibus._3.OrderEnum;
  19. import com.cognos.developer.schemas.bibus._3.PropEnum;
  20. import com.cognos.developer.schemas.bibus._3.QueryOptions;
  21. import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
  22. import com.cognos.developer.schemas.bibus._3.Sort;
  23. //import org.xml.sax.SAXException;
  24. class TreeBrowserNode extends BaseClass
  25. {
  26. BaseClass myCMObject;
  27. BaseClass[] children;
  28. DefaultMutableTreeNode myContainer;
  29. ImageIcon myIcon;
  30. private boolean childrenPopulated = false;
  31. private boolean detailsPopulated = false;
  32. public TreeBrowserNode(String searchPath, CRNConnect connection)
  33. {
  34. SearchPathMultipleObject cmSearchPath = new SearchPathMultipleObject(searchPath);
  35. try
  36. {
  37. PropEnum[] properties = { PropEnum.defaultName,
  38. PropEnum.searchPath,
  39. PropEnum.objectClass,
  40. PropEnum.hasChildren };
  41. myCMObject = (connection.getCMService().query(
  42. cmSearchPath,
  43. properties,
  44. new Sort[] {},
  45. new QueryOptions()))[0];
  46. String appendString = "/*";
  47. if (searchPath.lastIndexOf("/") == (searchPath.length() - 1))
  48. {
  49. appendString = "*";
  50. }
  51. if (searchPath.lastIndexOf("*") == (searchPath.length() - 1))
  52. {
  53. appendString = "";
  54. }
  55. Sort nodeSortType = new Sort();
  56. Sort nodeSortName = new Sort();
  57. nodeSortType.setOrder(OrderEnum.ascending);
  58. nodeSortType.setPropName(PropEnum.objectClass);
  59. nodeSortName.setOrder(OrderEnum.ascending);
  60. nodeSortName.setPropName(PropEnum.defaultName);
  61. Sort[] nodeSorts = new Sort[] {nodeSortType, nodeSortName};
  62. if(myCMObject.getHasChildren().isValue())
  63. {
  64. cmSearchPath.set_value(searchPath + appendString);
  65. children =
  66. connection.getCMService().query(
  67. cmSearchPath,
  68. properties,
  69. nodeSorts,
  70. new QueryOptions());
  71. }
  72. }
  73. //catch (SAXException saxEx)
  74. //{}
  75. catch (java.rmi.RemoteException remoteEx)
  76. {}
  77. }
  78. public TreeBrowserNode(BaseClass seedForNode, CRNConnect connection)
  79. {
  80. myCMObject = seedForNode;
  81. String searchPath = seedForNode.getSearchPath().getValue();
  82. SearchPathMultipleObject cmSearchPath = new SearchPathMultipleObject(searchPath);
  83. PropEnum[] properties =
  84. { PropEnum.defaultName,
  85. PropEnum.searchPath,
  86. PropEnum.objectClass,
  87. PropEnum.hasChildren
  88. };
  89. Sort nodeSortType = new Sort();
  90. Sort nodeSortName = new Sort();
  91. nodeSortType.setOrder(OrderEnum.ascending);
  92. nodeSortType.setPropName(PropEnum.objectClass);
  93. nodeSortName.setOrder(OrderEnum.ascending);
  94. nodeSortName.setPropName(PropEnum.defaultName);
  95. Sort[] nodeSorts = new Sort[] {nodeSortType, nodeSortName};
  96. String appendString = "/*";
  97. if (searchPath.lastIndexOf("/") == (searchPath.length() - 1))
  98. {
  99. appendString = "*";
  100. }
  101. if (searchPath.lastIndexOf("*") == (searchPath.length() - 1))
  102. {
  103. appendString = "";
  104. }
  105. try
  106. {
  107. if (myCMObject.getHasChildren().isValue())
  108. {
  109. cmSearchPath.set_value(cmSearchPath.get_value() + appendString);
  110. children =
  111. connection.getCMService().query(
  112. cmSearchPath,
  113. properties,
  114. nodeSorts,
  115. new QueryOptions());
  116. }
  117. }
  118. catch (java.rmi.RemoteException remoteEx)
  119. {
  120. }
  121. }
  122. public void setChildrenPopulated(boolean bpop)
  123. {
  124. childrenPopulated = bpop;
  125. }
  126. public boolean getChildrenPopulated()
  127. {
  128. return childrenPopulated;
  129. }
  130. public void setDetailsPopulated(boolean bpop)
  131. {
  132. detailsPopulated = bpop;
  133. }
  134. public boolean getDetailsPopulated()
  135. {
  136. return detailsPopulated;
  137. }
  138. public TreeBrowserNode getChild(int index, CRNConnect connection)
  139. {
  140. TreeBrowserNode returnNode = null;
  141. if (children != null)
  142. {
  143. if (!getChildrenPopulated())
  144. {
  145. children[index] =
  146. new TreeBrowserNode(children[index], connection);
  147. }
  148. returnNode = (TreeBrowserNode)children[index];
  149. }
  150. return returnNode;
  151. }
  152. public int getNumChildren()
  153. {
  154. if (children == null)
  155. {
  156. return 0;
  157. }
  158. return children.length;
  159. }
  160. public String toString()
  161. {
  162. if (myCMObject.getDefaultName() == null)
  163. {
  164. return "NULL";
  165. }
  166. return myCMObject.getDefaultName().getValue();
  167. }
  168. public BaseClass getCMObject()
  169. {
  170. return myCMObject;
  171. }
  172. public void setCMObject(BaseClass newObject)
  173. {
  174. myCMObject = newObject;
  175. }
  176. public DefaultMutableTreeNode getContainer()
  177. {
  178. return myContainer;
  179. }
  180. public void setContainer(DefaultMutableTreeNode treeNode)
  181. {
  182. myContainer = treeNode;
  183. myContainer.setUserObject(this);
  184. }
  185. public void setIcon(ImageIcon icon)
  186. {
  187. myIcon = icon;
  188. }
  189. public ImageIcon getImageIcon()
  190. {
  191. return myIcon;
  192. }
  193. }