User: ko5tik  
  Date: 02/04/14 07:27:40

  Modified:    src/java/xtags TagParameter.java
  Log:
  delegated TagParameter changes to property editors.
  
  Revision  Changes    Path
  1.4       +53 -0     xdocletgui/src/java/xtags/TagParameter.java
  
  Index: TagParameter.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdocletgui/src/java/xtags/TagParameter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- TagParameter.java 12 Apr 2002 17:01:17 -0000      1.3
  +++ TagParameter.java 14 Apr 2002 14:27:40 -0000      1.4
  @@ -39,13 +39,18 @@
   import java.util.Iterator;
   import java.util.NoSuchElementException;
   import java.util.Properties;
  +import java.util.Hashtable;
  +import java.beans.*;
   
   import xjavadoc.XClass;
   import xjavadoc.XProgramElement;
  +import xjavadoc.XTag;
  +
   import xtags.condition.Condition;
   import xtags.condition.Or;
   import xtags.condition.And;
   
  +import xtags.editor.*;
   /**
    * A TagParameter instance knows about under what conditions it is appliccable.
    * Each instance (created from xdoclet.xml) is shared among all classes and
  @@ -99,6 +104,11 @@
         */
        private static Properties _types = new Properties();
   
  +     /**
  +      * mapping between types and property editors
  +      */
  +     private static Properties _editors = new Properties();
  +
   
        /**
         * Describe what the TagParameter constructor does
  @@ -197,6 +207,45 @@
   
   
        /**
  +      * return property editor suitable for this parameter
  +      *
  +      * @param programElement Describe what the parameter does
  +      * @param xtag Describe what the parameter does
  +      * @return The PropertyEditor value
  +      * @todo-javadoc Write javadocs for method parameter
  +      * @todo-javadoc Write javadocs for method parameter
  +      */
  +     public PropertyEditor getPropertyEditor(XProgramElement programElement, XTag 
xtag) {
  +             PropertyEditor pe;
  +             // first look of we have options configured
  +             if (hasOptions()) {
  +                     return new OptionPropertyEditor(getOptions(programElement), 
xtag.attributeValue(getName()));
  +             }
  +             try {
  +                     // try to locate property editor for configured value class
  +                     _log.debug("looking for class: " + getValueClass().getName());
  +                     Class clazz = (Class)_editors.get(getValueClass().getName());
  +                     if (clazz != null) {
  +                             pe = (PropertyEditor)clazz.newInstance();
  +                     }
  +                     else {
  +                             // last ressort. delegate to property manager
  +                             pe = PropertyEditorManager.findEditor(getValueClass());
  +                     }
  +                     if (pe != null) {
  +                             pe.setAsText(xtag.attributeValue(getName()));
  +                     }
  +
  +                     return pe;
  +             } catch (Exception ex) {
  +                     _log.error("got exception while looking for proerty editor", 
ex);
  +             }
  +
  +             return null;
  +     }
  +
  +
  +     /**
         * Describe what the method does
         *
         * @return Describe the return value
  @@ -255,6 +304,10 @@
                _types.setProperty("int", "java.lang.Integer");
                _types.setProperty("text", "java.lang.String");
                _types.setProperty("bool", "java.lang.Boolean");
  +
  +             _editors.put(Integer.class.getName(), 
xtags.editor.IntegerPropertyEditor.class);
  +             _editors.put(Boolean.class.getName(), 
xtags.editor.BooleanPropertyEditor.class);
  +
        }
   
   }
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to