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

TagListChoice Class Reference

A CorbaObjectChoice for TagList's. More...

Inheritance diagram for TagListChoice::

InterfaceChoice CorbaObjectChoice List of all members.

Public Methods

 TagListChoice (org.omg.CORBA.TypeCode tc)
java.lang.Object asObject (String name) throws InvalidChoiceException
 Returns the object introduced as that text. More...


Static Public Methods

JComponent inputArg ()
 Dialog component where the user specifies the result. More...

HxCorba.TagList getTagList (String tagName, String tagValue) throws InvalidChoiceException

Detailed Description

A CorbaObjectChoice for TagList's.


Constructor & Destructor Documentation

TagListChoice::TagListChoice org.omg.CORBA.TypeCode    tc [inline]
 

00024 {
00025     super(tc);
00026     _objectName = null;
00027 }


Member Function Documentation

JComponent TagListChoice::inputArg   [inline, static, virtual]
 

Dialog component where the user specifies the result.

Reimplemented from InterfaceChoice.

00034 {
00035     if(_input == null) {
00036         _input = (JComboBox)super.inputArg();
00037         _input.addItem("name=1");
00038         _input.addItem("name=1.0");
00039         _input.addItem("name=[1]");
00040         _input.addItem("name=[1.0]");
00041         _input.addItem("name=[1 1]");
00042         _input.addItem("name=[1.0 1.0]");
00043         _input.addItem("name=[1 1 1]");
00044         _input.addItem("name=[1.0 1.0 1.0]");
00045 
00046         _input.setEditable(true);
00047         _input.getEditor().getEditorComponent().addFocusListener(new SelectOnFocus());
00048 
00049         //_input.addActionListener(this);
00050         //_input.setActionCommand("Combo");
00051         _input.setSelectedIndex(0);
00052     }
00053     return _input;
00054 }

HxCorba.TagList TagListChoice::getTagList String    tagName,
String    tagValue
[inline, static]
 

00058 {
00059     HxCorba.TagListFactory factory;
00060     try {
00061         org.omg.CORBA.Object obj =
00062             CorbaMediator.instance().getInitialObject("Constructor");
00063         factory = HxCorba.TagListFactoryHelper.narrow(obj);
00064     }catch(Exception e) {
00065         throw new InvalidChoiceException("Cannot find HORUS server");
00066     }
00067 
00068     HxCorba.TagList tl = factory.emptyTagList();
00069 
00070     if(tagValue.startsWith("[") && tagValue.endsWith("]")) {
00071         tagValue = tagValue.substring(1, tagValue.length()-1);
00072         HxCorba.PixValue val = PixValueChoice.getPixValue(tagValue);
00073         tl.addValue(tagName, val);
00074         return tl;
00075     }
00076 
00077     try {
00078         int val = Integer.parseInt(tagValue);
00079         tl.addInt(tagName, val);
00080         return tl;
00081     }catch(NumberFormatException e) {
00082         // maybe a double
00083     }
00084 
00085     try {
00086         double val = Double.parseDouble(tagValue);
00087         tl.addFloat(tagName, val);
00088         return tl;
00089     }catch(NumberFormatException e) {
00090         throw new InvalidChoiceException("Wrong tag value");
00091     }
00092 }

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

Returns the object introduced as that text.

Useful method to implement setArgument.

Reimplemented from InterfaceChoice.

00095 {
00096     if(name.equals(_objectName)) return _object; //already computed
00097 
00098     //if(name.equals("new TagList...")) return null;
00099 
00100     int index = name.indexOf("=");
00101     if(index == -1) _object = super.asObject(name);
00102     else {
00103         try {
00104             String tagName = name.substring(0, index).trim();
00105             String tagValue = name.substring(index+1).trim();
00106             _object = getTagList(tagName, tagValue);
00107         }catch(InvalidChoiceException e) {
00108             _input.requestFocus();
00109             _objectName = null;
00110             throw e;
00111         }
00112     }
00113 
00114     _objectName = name;
00115     return _object;
00116 
00117 }


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:19:53 2004 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001