1 21 package org.jacorb.ir.gui.typesystem.remote; 22 23 26 27 import org.jacorb.ir.gui.typesystem.*; 28 import java.util.*; 29 import org.omg.CORBA.*; 30 import javax.swing.tree.*; 31 32 public class IRInterface 33 extends IRContainer 34 implements org.jacorb.ir.gui.typesystem.Interface 35 { 36 private IRInterface[] superInterfaces = null; 37 private IRAttribute[] allFields = null; 38 private IROperation[] allOperations = null; 39 40 43 public IRInterface ( ) { 44 super(); 45 } 46 47 51 public IRInterface ( IRObject irObject) { 52 super(irObject); 53 } 54 55 59 public String [] allowedToAdd() { 60 String [] result = { IRAttribute.nodeTypeName(), 61 IROperation.nodeTypeName(), 62 IRConstant.nodeTypeName(), 63 IRTypedef.nodeTypeName(), 64 IRException.nodeTypeName()}; 65 return result; 66 } 67 68 71 72 public String description() 73 { 74 String result = super.description(); 75 Interface[] superinterfaces = getSuperInterfaces(); 76 77 if (superinterfaces.length>0) 78 { 79 result = result + "\nSuper-Interfaces:\t "; 80 for (int i = 0; i<superinterfaces.length; i++) 81 { 82 result = result + ((TypeSystemNode)superinterfaces[i]).getAbsoluteName(); 83 if (!(i==superinterfaces.length-1)) 84 { 85 result = result + ", "; 86 } 87 } 88 } 89 else 90 { 91 result = result + "\nSuper-Interfaces:\t:none"; 92 } 93 return result; 94 } 95 96 100 101 public TypeSystemNode[] getAllFields() 102 { 103 if (this.allFields==null) 104 { 105 Vector fields = new Vector(); 106 Interface[] superInterfaces = this.getSuperInterfaces(); 108 for (int i=0; i<superInterfaces.length; i++) 109 { 110 TypeSystemNode[] nextFields = superInterfaces[i].getAllFields(); 111 for (int n=0; n<nextFields.length; n++) { 112 fields.addElement(nextFields[n]); 113 } 114 } 115 ModelParticipant[] contents = this.contents(); 117 118 for (int i=0; i<contents.length; i++) 119 { 120 if (contents[i] instanceof IRAttribute) { 121 fields.addElement(contents[i]); 122 } 123 } 124 125 this.allFields = new IRAttribute[fields.size()]; 126 int i = 0; 127 for (Enumeration e = fields.elements(); e.hasMoreElements(); ) 128 { 129 allFields[i] = (IRAttribute)e.nextElement(); 130 i++; 131 } 132 } return allFields; 134 } 135 136 140 141 public TypeSystemNode[] getAllOperations() 142 { 143 if (this.allOperations==null) 144 { 145 Vector operations = new Vector(); 146 Interface[] superInterfaces = this.getSuperInterfaces(); 148 for (int i=0; i<superInterfaces.length; i++) 149 { 150 TypeSystemNode[] nextOperations = superInterfaces[i].getAllOperations(); 151 for (int n=0; n<nextOperations.length; n++) 152 { 153 operations.addElement(nextOperations[n]); 154 } 155 } 156 157 159 ModelParticipant[] contents = this.contents(); 160 for (int i=0; i<contents.length; i++) 161 { 162 if (contents[i] instanceof IROperation) 163 { 164 operations.addElement(contents[i]); 165 } 166 } 167 168 this.allOperations = new IROperation[operations.size()]; 169 int i = 0; 170 for (Enumeration e = operations.elements(); e.hasMoreElements(); ) 171 { 172 allOperations[i] = (IROperation)e.nextElement(); 173 i++; 174 } 175 } return allOperations; 177 } 178 179 183 184 public Interface[] getSuperInterfaces() 185 { 186 if (superInterfaces==null) 187 { 188 InterfaceDef interfaceDef = InterfaceDefHelper.narrow((org.omg.CORBA.Object )irObject); 190 InterfaceDef[] baseInterfaces = interfaceDef.base_interfaces(); this.superInterfaces = new IRInterface[baseInterfaces.length]; 192 for (int i=0; i<baseInterfaces.length; i++) 193 { 194 IRInterface superInterface = (IRInterface)RemoteTypeSystem.createTypeSystemNode(baseInterfaces[i]); 196 this.superInterfaces[i] = superInterface; 197 } 198 } 199 return superInterfaces; 200 } 201 202 205 206 public static String nodeTypeName() 207 { 208 return "interface"; 209 } 210 211 214 215 protected void setIRObject(org.omg.CORBA.IRObject irObject) 216 { 217 super.setIRObject(irObject); 218 } 219 } 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | Popular Tags |