1  /**
     2   * com.sekati.log.ConsoleItem
     3   * @version 1.1.3
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8  
     9  import com.sekati.display.BaseClip;
    10  import com.sekati.log.ConsoleStyle;
    11  import com.sekati.utils.Delegate;
    12  
    13  /**
    14   * Console Item UI
    15   * {@code Usage:
    16   * 	var meta:MovieClip = ClassUtils.createEmptyMovieClip (com.sekati.log.ConsoleItem, this, "consoleMetaItem", {_x:5, _y:5, _isMeta:true});
    17   *	var data0:Object = {id:0, type:"status", origin:"_level0", message:"Generic status report.", benchmark:0.3339};
    18   * 	var c0:MovieClip = ClassUtils.createEmptyMovieClip (com.sekati.log.ConsoleItem, this, "consoleItem0", {_x:5, _y:21, _data:data0});
    19   * }
    20   * @see {@link com.sekati.log.Console}
    21   */
    22  class com.sekati.log.ConsoleItem extends BaseClip {
    23  
    24  	// data = {id:Number, type:String, origin:String, message:String, benchmark:Number, _isMeta:Boolean}
    25  	public var _data:Object;
    26  	private var _cs:ConsoleStyle;
    27  	private var _style:Object;
    28  	public var _bg:MovieClip;
    29  	public var _line:MovieClip;
    30  	public var _idTf:TextField;
    31  	public var _typeTf:TextField;
    32  	public var _originTf:TextField;
    33  	public var _messageTf:TextField;
    34  	public var _benchmarkTf:TextField;
    35  
    36  	/**
    37  	 * ConsoleItem Constructor.
    38  	 */
    39  	public function ConsoleItem() {	
    40  		//trace("ConsoleItem: "+_this._name+".__RUID = "+_this.__RUID+";");
    41  		_cs = ConsoleStyle.getInstance( );
    42  		_style = (!_data._isMeta) ? _cs.CSS.item : _cs.CSS.meta_item;
    43  		
    44  		// rect	- createStyledRect (target:MovieClip, layout:Object, color:Object)
    45  		_bg = _cs.createStyledRectangle( _this, _style.bg );
    46  		_line = _cs.createStyledRectangle( _this, _style.line );
    47  		
    48  		// text - createStyledTextField (target:MovieClip, layout:Object, color:Object, str:String)
    49  		_idTf = _cs.createStyledTextField( _this, _style.textfields.id, _data.id );
    50  		_typeTf = _cs.createStyledTextField( _this, _style.textfields.type, _data.type );
    51  		_originTf = _cs.createStyledTextField( _this, _style.textfields.origin, _data.origin );
    52  		_messageTf = _cs.createStyledTextField( _this, _style.textfields.message, _data.message );
    53  		_benchmarkTf = _cs.createStyledTextField( _this, _style.textfields.benchmark, _data.benchmark );
    54  		
    55  		// alignments
    56  		//_bg._height = _messageTf._height;
    57  		//_line._y = _messageTf._height;
    58  		var tallestTf:TextField = (_messageTf._height > _originTf._height) ? _messageTf : _originTf;
    59  		_bg._height = tallestTf._height;
    60  		_line._y = tallestTf._height;	
    61  				
    62  		// event
    63  		_bg.onPress = Delegate.create( _this, toClipboard );
    64  		//_bg.useHandCursor = false;		
    65  	}
    66  
    67  	/**
    68  	 * Copy string data to clipboard.
    69  	 * @return Void
    70  	 */	
    71  	private function toClipboard():Void {
    72  		System.setClipboard( toString( ) );
    73  	}
    74  
    75  	/**
    76  	 * Return ConsoleItem string data 
    77  	 * @return String
    78  	 */
    79  	public function toString():String {
    80  		var tab:String = "\t";
    81  		var str:String = _idTf.text + tab + _typeTf.text + tab + _originTf.text + tab + _messageTf.text + tab + _benchmarkTf.text;
    82  		return str;		
    83  	}
    84  
    85  	/**
    86  	 * calls superclasses BaseClip.destroy and executes its own destroy behaviors.
    87  	 * @return Void
    88  	 */
    89  	public function destroy():Void {
    90  		super.destroy( );
    91  		//trace(_this._name+" ConsoleItem destroy()");
    92  	}	
    93  }