Horus Doc || Java GUI Reference || Doxygen's quick Index  

InterfaceChoice Class Reference

A CorbaObjectChoice for interface's. More...

Inheritance diagram for InterfaceChoice::

CorbaObjectChoice MatrixChoice TagListChoice List of all members.

Public Methods

 InterfaceChoice (TypeCode tc)
String name ()
 Name of the type. More...

JComponent inputRes ()
 Dialog component where the user specifies the parameter. More...

JComponent inputObj ()
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...

Request createRequest (String op) throws InvalidChoiceException
void dragOver (DropTargetDragEvent event)
void drop (DropTargetDropEvent event)
void dragEnter (DropTargetDragEvent event)
void dragExit (DropTargetEvent event)
void dropActionChanged (DropTargetDragEvent event)

Detailed Description

A CorbaObjectChoice for interface's.


Constructor & Destructor Documentation

InterfaceChoice::InterfaceChoice TypeCode    tc [inline]
 

00037 {
00038     super(tc);
00039     try {
00040         _id = tc.id();
00041         _name = tc.name();
00042     }catch(org.omg.CORBA.TypeCodePackage.BadKind e){
00043         //???
00044     }
00045 }


Member Function Documentation

String InterfaceChoice::name   [inline, virtual]
 

Name of the type.

Reimplemented from CorbaObjectChoice.

00048 {
00049     return "interface "+_name;
00050 }

JComponent InterfaceChoice::inputRes   [inline, virtual]
 

Dialog component where the user specifies the parameter.

Reimplemented from CorbaObjectChoice.

00053 {
00054     if(_input == null) {
00055         StubComboBoxModel model = new StubComboBoxModel(_id);
00056         _input = new JComboBox(model);
00057         //addStubs(_input);
00058 
00059         _input.setEditable(true);
00060         _input.getEditor().getEditorComponent().addFocusListener(new SelectOnFocus());
00061 
00062         _input.setSelectedIndex(-1);
00063         _input.getEditor().setItem("");
00064     }
00065 
00066     return _input;
00067 }

JComponent InterfaceChoice::inputObj   [inline]
 

00070 {
00071     if(_input == null) {
00072         StubComboBoxModel model = new StubComboBoxModel(_id);
00073         _input = new JComboBox(model);
00074         //addStubs(_input);
00075 
00076         //Component[] comps = _input.getComponents();
00077         //for(int i=0; i<comps.length; i++)
00078         //    new DropTarget(comps[i], (DropTargetListener)this);
00079     }
00080     return _input;
00081 }

JComponent InterfaceChoice::inputArg   [inline, virtual]
 

Dialog component where the user specifies the result.

Reimplemented from CorbaObjectChoice.

Reimplemented in MatrixChoice, and TagListChoice.

00084 {
00085     if(_input == null) {
00086         StubComboBoxModel model = new StubComboBoxModel(_id);
00087         model.addElement("_nil");
00088         _input = new JComboBox(model);
00089         //addStubs(_input);
00090 
00091         //Component[] comps = _input.getComponents();
00092         //for(int i=0; i<comps.length; i++)
00093         //    new DropTarget(comps[i], (DropTargetListener)this);
00094     }
00095     return _input;
00096 }

String InterfaceChoice::getResult Any    resAny [inline, virtual]
 

Request management: extract result from Any (and convert it to String).

Reimplemented from CorbaObjectChoice.

00099 {
00100     org.omg.CORBA.Object obj = resAny.create_input_stream().read_Object();
00101     return toString(obj);
00102 
00103     /*String resName = null;
00104 
00105     try {
00106         //result = HxCorba."name"Helper.extract(resAny);
00107 
00108         Class helper = Class.forName("HxCorba."+_name+"Helper");
00109         Class[] argTypes = { Any.class };
00110         Method methExt = helper.getMethod("extract", argTypes);
00111         java.lang.Object[] args = { resAny };
00112         java.lang.Object obj = methExt.invoke(null, args);
00113 
00114         resName = toString(obj);
00115 
00116     }catch(Exception e) {
00117         ErrorStreamArea.println(e+": Cannot find helper class for "+_name);
00118     }
00119 
00120     return resName;*/
00121 }

void InterfaceChoice::setArgument Any    argsAny [inline, virtual]
 

Request management: add argument to Any.

Reimplemented from CorbaObjectChoice.

00124 {
00125     org.omg.CORBA.Object obj = (org.omg.CORBA.Object)asObject();
00126 
00127     org.omg.CORBA.portable.OutputStream out = argsAny.create_output_stream();
00128     out.write_Object(obj);
00129     argsAny.read_value(out.create_input_stream(), typeCode());
00130 
00131     /*try {
00132         //HxCorba."name"Helper.insert(argsAny, this);
00133 
00134         Class helper = Class.forName("HxCorba."+_name+"Helper");
00135         Class[] argTypes = { Any.class, Class.forName("HxCorba."+_name) };
00136         Method methIns = helper.getMethod("insert", argTypes);
00137         java.lang.Object[] args = { argsAny, obj };
00138         methIns.invoke(null, args);
00139 
00140     }catch(Exception e) {
00141         ErrorStreamArea.println(e+": Cannot find helper class for "+_name);
00142     }*/
00143 }

String InterfaceChoice::toString java.lang.Object    obj [inline]
 

Converts that object to string.

Useful method to implement getResult.

Reimplemented from CorbaObjectChoice.

00146 {
00147     if(obj == null) return null;
00148 
00149     // This seems to an (incorrect) NullPointer exception on linux...
00150     //String resName = _input.getSelectedItem().toString();
00151     String resName;
00152     if (_input.getSelectedItem() == null)
00153         resName = new String("");
00154     else
00155         resName = _input.getSelectedItem().toString();
00156 
00157     if(resName.length() == 0)
00158         resName = _name+"+";
00159 
00160     resName = StubRepository.instance().
00161         addStub(_id, resName, (org.omg.CORBA.Object)obj);
00162     return resName;
00163 }

java.lang.Object InterfaceChoice::asObject String    name [inline, virtual]
 

Returns the object introduced as that text.

Useful method to implement setArgument.

Reimplemented from CorbaObjectChoice.

Reimplemented in MatrixChoice, and TagListChoice.

00166 {
00167     if(name.equals("_nil")) return null;
00168 
00169     java.lang.Object obj = StubRepository.instance().getStub(_id, name);
00170     if(obj == null)
00171         throw new InvalidChoiceException(_name+" \""+name+"\" doesn't exists");
00172 
00173     return obj;
00174 }

Request InterfaceChoice::createRequest String    op [inline]
 

00177 {
00178     if(_input.getSelectedItem() == null)
00179         throw new InvalidChoiceException("Interface not selected");
00180 
00181     String name = _input.getSelectedItem().toString();
00182     ObjectImpl obj = (ObjectImpl)StubRepository.instance().getStub(_id, name);
00183     return obj._request(op);
00184 }

void InterfaceChoice::dragOver DropTargetDragEvent    event [inline]
 

00189 {
00190     //System.out.println("over "+event.getDropTargetContext().getComponent());
00191     boolean acceptable = event.isDataFlavorSupported(HxCorbaDataFlavor.objectFlavor);
00192 
00193     if(acceptable) {
00194         event.acceptDrag(event.getDropAction());
00195         //setDragPosition(event.getLocation());
00196     }else
00197         event.rejectDrag();
00198 }

void InterfaceChoice::drop DropTargetDropEvent    event [inline]
 

00202 {
00203     boolean acceptable = event.isDataFlavorSupported(HxCorbaDataFlavor.objectFlavor);
00204 
00205     if(!acceptable) {
00206         event.rejectDrop();
00207         return;
00208     }
00209 
00210     try {
00211         event.acceptDrop(event.getDropAction());
00212         Transferable transferable = event.getTransferable();
00213         ObjectTransfer data = (ObjectTransfer)transferable.getTransferData(
00214             HxCorbaDataFlavor.objectFlavor);
00215 
00216         //if(_dropName != null) _input.removeItem(_dropName);
00217         //_dropName = null;
00218 
00219         //if(data.getType().equals(_id)) {
00220         //    _dropName = "drop:"+data.getName();
00221         //    _dropStub = data;
00222         //    _input.addItem(_dropName);
00223             //_input.setSelectedItem(_dropName);
00224         //}
00225         //else System.out.println("wrong type");
00226 
00227         event.getDropTargetContext().dropComplete(true);
00228     }
00229     catch (java.io.IOException exception) {
00230         exception.printStackTrace();
00231         event.rejectDrop();
00232     }catch (UnsupportedFlavorException ufException ) {
00233         ufException.printStackTrace();
00234         event.rejectDrop();
00235     }
00236 }

void InterfaceChoice::dragEnter DropTargetDragEvent    event [inline]
 

00239 {}

void InterfaceChoice::dragExit DropTargetEvent    event [inline]
 

00240 {}

void InterfaceChoice::dropActionChanged DropTargetDragEvent    event [inline]
 

00241 {}


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:22 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001