Package net.xoetrope.xui.helper

Source Code of net.xoetrope.xui.helper.XAttributedComponentHelper

/*
* XAttributeComponentHelper.java
*
* Created on 07 November 2006, 14:30
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package net.xoetrope.xui.helper;

import net.xoetrope.xui.WidgetAdapter;
import net.xoetrope.xui.XProject;

/**
* A helper for setting common properties
* <p>Copyright (c) Xoetrope Ltd., 2002-2003</p>
* <p>License: see license.txt</p>
*/
public class XAttributedComponentHelper
{
  /**
   * Set one or more attributes of the component.
   * <OL>
   * <LI>alignment, value=(Left|Right|Center|Leading|Trailing)</LI>
   * <LI>border, value=0, to tun off the border</LI>
   * <LI>margin, value=the size in pixels of the margin (the space between the border and the text)</LI>
   * <LI>tooltip, value=the tooltip text</LI>
   * <LI>format, value=integer|curreny|date|decimal or a mask for a mask format</LI>
   * <LI>editable, value=(true|false) set the edit to being editable</LI>
   * </OL>
   * @param project the current project
   * @param attribName the name of the attribute
   * @param attribValue the value of the attribute
   * @return 0 for success, non zero for failure or to require some further action
   */
  public static int setAttribute( XProject project, Object comp, String attribName, Object attribValue )
  {
    WidgetAdapter adapter = WidgetAdapter.getInstance();
   
    if ( attribName.equals( "preferredsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setPreferredSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "minimumsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setMinimumSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "maximumsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setMaximumSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "tooltip" ))
      adapter.setTooltip( comp, XuiUtilities.translate( project, attribValue.toString()));
    else if ( attribName.equals( "opaque" ))
      adapter.setOpaque( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "visible" ))
      adapter.setVisible( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "enabled" ))
      adapter.setEnabled( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "alignment" ))
      adapter.setHorizontalAlignment( comp, attribValue.toString());
    else if ( attribName.equals( "border" ))
      adapter.setBorderType( comp, attribValue.toString());
   
    return -1;
  }
}
TOP

Related Classes of net.xoetrope.xui.helper.XAttributedComponentHelper

TOP
Copyright © 2018 www.massapi.com. 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.