Package net.xoetrope.xml

Examples of net.xoetrope.xml.XmlElement


  {
    BufferedReader r = null;
    try {
      r = currentProject.getBufferedReader( file, null );
      if ( r != null ) {
        XmlElement element = XmlSource.read( r );
        loadXStyle( element, null );
        baseStyle = getStyle( "base" );
      }
    }
    catch ( Exception ex ) {
View Full Code Here


     * @todo set the number of styles based upon the number of children instead
     * of adding them one by one. The addStle method needs to be modified on this
     * basis also. (see XStyle and XStyleEx)
     */
    while ( e.hasMoreElements() ) {
      XmlElement eleStyle = ( XmlElement )e.nextElement();
      String elementName = eleStyle.getName();
      if ( elementName.equals( "style" )) {
        String temp = element.getAttribute( "name" );
        if (( path != null ) && ( path.length() > 0 ))
          temp = path + "/" + element.getAttribute( "name" );
        loadXStyle( eleStyle, temp );
      }
      else
        xstyle.setStyle( xstyle.getStyleIndex( elementName ), eleStyle.getAttribute( "value" ) );
    }
    xstyle.setClosed( true );

    String styleName = element.getAttribute( "name" );
    if (( path != null ) && ( path.length() > 0 ))
View Full Code Here

    meta.setBackground( java.awt.Color.red );

    try {
      FileInputStream is = new FileInputStream( "c:\\cvs\\xui\\Resource\\configres\\moreinfo.xml" );
      InputStreamReader isr = new InputStreamReader( is, project.getDefaultEncoding() );
      XmlElement src = XmlSource.read( new BufferedReader( isr ) );
      ( ( XMetaContentHolder )meta ).setContent( "c:\\cvs\\xui\\Resource\\configres\\moreinfo.xml", src );
    }
    catch ( Exception ex ) {
      ex.printStackTrace();
    }
View Full Code Here

   * @param reader the reader from which to read the file
   */
  public void read( String key, Reader reader )
  {
    try {
      XmlElement regRoot = XmlSource.read( reader );

      Vector componentNodes = regRoot.getChildren();
      int numComponents = componentNodes.size();
      for ( int i = 0; i < numComponents; i++ ) {
        XmlElement componentNode = ( XmlElement )componentNodes.elementAt( i );
        try {
          String componentName = componentNode.getAttribute( "name" );
          String iconName = componentNode.getAttribute( "icon" );
          String reflect = componentNode.getAttribute( "reflect" );
          String tag = componentNode.getName().toLowerCase();
          if ( !tag.equals( "component" ))
            continue;
          ComponentAdapter oldCa = (ComponentAdapter)propertiesRegister.get( componentName );
          ComponentAdapter ca = oldCa;
          if ( oldCa == null ) {
            if (( reflect != null ) && reflect.equals( "true" )) {
              ca = addReflectionAdapter( key, componentName, iconName, componentNode.getAttribute( "class" ), componentNode.getAttribute( "ui" ));
              // Make sure there aren't duplicates of this property.
              propertiesRegister.remove( componentName );
              propertiesRegister.put( componentName, ca );
              continue;
            }
            ca = addComponentAdapter( key, componentName, iconName, componentNode.getAttribute( "class" ), componentNode.getAttribute( "ui" ));
          }
          Vector propertyNodes = componentNode.getChildren();
          int numProperties = propertyNodes.size();
          for ( int j = 0; j < numProperties; j++ ) {
            XmlElement propertyNode = componentNode.elementAt( j );
            String type = propertyNode.getAttribute( "type" );
            String name = propertyNode.getAttribute( "name" );
            String method = propertyNode.getAttribute( "method" );
            String attribStr = propertyNode.getAttribute( "attrib" );
            boolean attributed = (( attribStr != null ) && ( attribStr.equals( "true" )));
            String paramType = "String";
            if ( type == null )
              type = "both";
           
            if(( name != null ) && ( method != null )){
              if ( type.equals( "get" ) || type.equals( "both" )) {
                String getMethod = method;
                if (( getMethod == null ) || ( getMethod.length() == 0 ))
                  getMethod = "get" + name.substring( 0, 1 ).toUpperCase() + name.substring( 1 );
                else if ( type.equals( "both" ))
                  getMethod = "get" + method.substring( 0, 1 ).toUpperCase() + method.substring( 1 );

                Vector params = propertyNode.getChildren();
                if ( params.size() > 0 )
                  paramType = ((XmlElement)params.elementAt( 0 )).getAttribute( "type" );

                ca.addProperty( "get", name, getMethod, paramType, attributed, true, null );
              }

              if ( type.equals( "set" ) || type.equals( "both" )) {
                String setMethod = method;
                if (( setMethod == null ) || ( setMethod.length() == 0 ))
                  setMethod = "set" + name.substring( 0, 1 ).toUpperCase() + name.substring( 1 );
                else if ( type.equals( "both" ))
                  setMethod = "set" + method.substring( 0, 1 ).toUpperCase() + method.substring( 1 );

                Vector params = propertyNode.getChildren();
                if ( params.size() > 0 )
                  paramType = ((XmlElement)params.elementAt( 0 )).getAttribute( "type" );

                ca.addProperty( "set", name, setMethod, paramType, attributed, true, null );
              }
View Full Code Here

   
    if ( isMainProject ) {
      try {
        BufferedReader projectsReader = currentProject.getBufferedReader( "projects.xml" );
        if ( projectsReader != null ) {
          XmlElement projects = XmlSource.read( projectsReader );
          if ( projects != null ) {
            Vector childProjects = projects.getChildren();
            int numChildProjects = childProjects.size();
            for ( int i = 0; i < numChildProjects; i++ ) {
              XmlElement childProject = (XmlElement)childProjects.elementAt( i );
             
              // Initialize the new project
              loadSecondaryProject( childProject );
            }
          }
View Full Code Here

  public void activateCustomize()
  {
    int numCustomizations = postCreateCustomizations.size();
    for ( int i = 0; i < numCustomizations; i++ ) {
      PostActivateCustomization pac = (PostActivateCustomization)postCreateCustomizations.get( i );
      XmlElement customization = (XmlElement)customizations.get( pac.propertySet );
      applyCustomizations( pac.comp, customization, PRE_ACTIVATE_TIME );
    }
    postCreateCustomizations.clear();
  }
View Full Code Here

   * @param propertySetName the reference name for the customizations
   * @param applyTime the time to apply the customization
   */
  public int customize( Object comp, String propertySetName, int applyTime )
  { 
    XmlElement customization = (XmlElement)customizations.get( propertySetName );
    return applyCustomizations( comp, customization, applyTime );
  }
View Full Code Here

      return Integer.MIN_VALUE;
   
    Vector propertyNodes = propertySet.getChildren();
    int numProperties = propertyNodes.size();
    for ( int i = 0; i < numProperties; i++ ) {
      XmlElement propertyNode = (XmlElement)propertyNodes.elementAt( i );
      String methodName = propertyNode.getName();
      methodName = "set" + methodName.substring( 0, 1 ).toUpperCase() + methodName.substring( 1 );
      String adaptorName = propertyNode.getAttribute( "adaptor" );
      String scope = propertyNode.getAttribute( "scope" );
     
      // Check if the property represents an object type that needs to be
      // instantiated and customized itself before being applied to the
      // component
      String className = propertyNode.getAttribute( "class" );
      if (( className != null ) && ( className.length() > 0 )) {
        try {
          Object[] args = getArguments( propertyNode.getAttribute( "args" ), comp );
          Object obj = ReflectionHelper.constructViaReflection( className, args );
          rc += applyCustomizations( obj, propertyNode, applyTime );
         
          // Now set/apply the object
          if ( adaptorName == null )
            ReflectionHelper.setViaReflection( methodName, comp, obj );
          else {
            Object[] objs = new Object[ 1 ];
            objs[ 0 ] = obj; 
            ((CustomizationAdapter)adaptors.get( adaptorName )).adapt( methodName, comp, objs, scope );         
          }
        }
        catch ( Exception ex )
        {
          ex.printStackTrace();
        }
      }
      else {
        // Apply simple properties
        Object[] args = getArguments( propertyNode.getAttribute( "args" ), comp );
       
        if ( adaptorName == null )
          ReflectionHelper.setViaReflection( methodName, comp, args );
        else
          ((CustomizationAdapter)adaptors.get( adaptorName )).adapt( methodName, comp, args, scope );         
View Full Code Here

   * @param validationName The name of the validation
   * @param mask The event mask to be applied to the validation
   */
  public XValidator getValidation( String validationName, int mask, Object page )
  {
    XmlElement element = (XmlElement)validations.get( validationName );
    if ( BuildProperties.DEBUG ) {
      if ( element == null ) {
        DebugLogger.logError( "Cannot find the validation rule: " + validationName );
        return null;
      }
    }

    String type = element.getAttribute( "type" );
    String className = null;
    if ( type.equals( "minmax" ))
      className = "net.xoetrope.xui.validation.XMinMaxValidator";
    else if ( type.equals( "mandatory" ))
      className = "net.xoetrope.xui.validation.XMandatoryValidator";// mandatoryValidator = new XMandatoryValidator( currentProject, validationName, mask );
    else if ( type.equals( "custom" ))
      className = element.getAttribute( "class" );
   
    if ( className != null ) {
      XBaseValidator validator = null;
      try {
        Object[] values = new Object[ 1 ];
View Full Code Here

   * @param reader the reader from which to read the file
   */
  public void read( String key, Reader reader )
  {
    try {
      XmlElement regRoot = XmlSource.read( reader );

      String validationStyle = regRoot.getAttribute( "style" );
      if ( validationStyle != null ) {
        XStyleEx exStyle = (XStyleEx)currentProject.getStyleManager().getStyle( validationStyle );
        Color[] colors = new Color[ 3 ];
        colors[ 0 ] = (Color)exStyle.getStyleAsColor( "colornormal" );
        colors[ 1 ] = (Color)exStyle.getStyleAsColor( "colorwarn" );
        colors[ 2 ] = (Color)exStyle.getStyleAsColor( "colorfail" );
        XBaseValidator.setValidationColors( colors );
      }

      Enumeration e = regRoot.getChildren().elements();
      validations = new Hashtable();
      while ( e.hasMoreElements() ) {
        XmlElement ele = (XmlElement)e.nextElement();
        String name = ele.getAttribute( "name" );
        validations.put( name, ele );
      }
    }
    catch ( Exception ex ) {
      if ( BuildProperties.DEBUG )
View Full Code Here

TOP

Related Classes of net.xoetrope.xml.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.