Inheritance diagram for StructChoice::
Public Methods | |
StructChoice (TypeCode tc) | |
String | name () |
Name of the type. More... | |
JComponent | inputRes () |
Dialog component where the user specifies the parameter. More... | |
JComponent | inputArg () |
Dialog component where the user specifies the result. More... | |
String | getResult (Any resAny) |
Request management: extract result from Any (and convert it to String). More... | |
void | setArgument (Any argsAny) throws InvalidChoiceException |
Request management: add argument to Any. More... | |
String | toString (java.lang.Object obj) |
Converts that object to string. More... | |
java.lang.Object | asObject (String name) throws InvalidChoiceException |
Returns the object introduced as that text. More... |
|
00026 { 00027 super(tc); 00028 try { 00029 _name = tc.name(); 00030 _id = tc.id(); 00031 _fNames = new String[tc.member_count()]; 00032 _fields = new CorbaObjectChoice[tc.member_count()]; 00033 for(int i=0; i<_fields.length; i++) { 00034 _fNames[i] = tc.member_name(i); 00035 _fields[i] = ChoiceFactory.getChoice(tc.member_type(i)); 00036 } 00037 }catch(Exception e) { 00038 System.out.println(""+e); 00039 e.printStackTrace(); 00040 } 00041 } |
|
Name of the type.
Reimplemented from CorbaObjectChoice.
00044 { 00045 return "struct "+_name; 00046 } |
|
Dialog component where the user specifies the parameter.
Reimplemented from CorbaObjectChoice.
00049 { 00050 if(_input == null) { 00051 StubComboBoxModel model = new StubComboBoxModel(_id); 00052 _input = new JComboBox(model); 00053 00054 _input.setEditable(true); 00055 _input.getEditor().getEditorComponent().addFocusListener(new HxJava.Util.SelectOnFocus()); 00056 00057 _input.setSelectedIndex(-1); 00058 _input.getEditor().setItem(""); 00059 } 00060 00061 return _input; 00062 } |
|
Dialog component where the user specifies the result.
Reimplemented from CorbaObjectChoice. Reimplemented in PointChoice, and SizesChoice.
00065 { 00066 if(_input == null) { 00067 StubComboBoxModel model = new StubComboBoxModel(_id); 00068 _input = new JComboBox(model); 00069 } 00070 return _input; 00071 } |
|
Request management: extract result from Any (and convert it to String).
Reimplemented from CorbaObjectChoice.
00074 { 00075 String resName = null; 00076 00077 try { 00078 //result = HxCorba."name"Helper.extract(resAny); 00079 00080 Class helper = Class.forName("HxCorba."+_name+"Helper"); 00081 Class[] argTypes = { Class.forName("org.omg.CORBA.Any") }; 00082 Method methExt = helper.getMethod("extract", argTypes); 00083 java.lang.Object[] args = { resAny }; 00084 java.lang.Object obj = methExt.invoke(null, args); 00085 00086 resName = toString(obj); 00087 00088 }catch(Exception e) { 00089 ErrorStreamArea.println(e+": Cannot find helper class for "+_name); 00090 } 00091 00092 return resName; 00093 } |
|
Request management: add argument to Any.
Reimplemented from CorbaObjectChoice.
00096 { 00097 java.lang.Object obj = asObject(); 00098 00099 try { 00100 //HxCorba."name"Helper.insert(argsAny, this); 00101 00102 Class helper = Class.forName("HxCorba."+_name+"Helper"); 00103 Class[] argTypes = { Class.forName("org.omg.CORBA.Any"), 00104 Class.forName("HxCorba."+_name) }; 00105 Method methIns = helper.getMethod("insert", argTypes); 00106 java.lang.Object[] args = { argsAny, obj }; 00107 methIns.invoke(null, args); 00108 }catch(Exception e) { 00109 ErrorStreamArea.println(e+": Cannot find helper class for "+_name); 00110 } 00111 } |
|
Converts that object to string. Useful method to implement getResult. Reimplemented from CorbaObjectChoice.
00114 { 00115 String resName = _input.getSelectedItem().toString(); 00116 if(resName.length() == 0) resName = _name+"*"; 00117 00118 StubRepository.instance().addStub(_id, resName, obj); 00119 00120 String result = null; 00121 try { 00122 Class c = obj.getClass(); 00123 result = "{"; 00124 for(int i=0; i<_fields.length; i++) { 00125 java.lang.Object fieldObj = c.getField(_fNames[i]).get(obj); 00126 String fVal = _fields[i].toString(fieldObj); 00127 result = result+_fNames[i]+": "+fVal+", "; 00128 } 00129 result = result+"}"; 00130 00131 }catch(Exception e){ 00132 System.out.println(""+e); 00133 } 00134 00135 return result; 00136 } |
|
Returns the object introduced as that text. Useful method to implement setArgument. Reimplemented from CorbaObjectChoice. Reimplemented in PointChoice, and SizesChoice.
00139 { 00140 java.lang.Object obj = StubRepository.instance().getStub(_id, name); 00141 if(obj == null) 00142 throw new InvalidChoiceException(_name+" \""+name+"\" doesn't exists"); 00143 00144 return obj; 00145 } |