table_obj.js

来自「proe5.0野火版下载(中文版免费下载)」· JavaScript 代码 · 共 1,808 行 · 第 1/4 页

JS
1,808
字号
/*---------------------------------------------------------------------------*\||  Module Details:||  Name:    table_obj.js||  Purpose: file contains table creation methods for reports.||  History:||  Date      Release Name  Ver.  Comments|  --------- ------- ----- ----- ----------------------------------------------|  14-Jun-04 K-03-04 Moti   $$1   Created.|  30-Jun-04 K-03-05 Moti   $$2   Added column visibility functionality|  19-Jul-04 K-03-06 Moti   $$3   Removed timer. Fixed tabulating of header|  26-Jul-04 K-03-07 Moti   $$4   Added Export functionality.|  04-Aug-04 K-03-08 Moti   $$5   Added empty table message functionality.|  25-Aug-04 K-03-09 Moti   $$6   Fixed debug error crash function|  19-Sep-04 K-03-10 Moti   $$7   Added two new commands for smt|  28-Oct-04 K-03-13 Moti   $$8   Fixed genericSortFunction.|  01-Feb-05 K-03-19 Moti   $$9   Changed report_export prototype..|                                 Fixed un-needed sorting.|  27-Feb-05 K-03-20 Moti   $$10  Added setColumnVerticalAlignment.|  22-Mar-05 K-03-21 Moti   $$11  Added comma_delimited option to export report|  17-Apr-05 K-03-22+Moti   $$12  Used cellToTextCB.|  21-Apr-05 K-03-23 Moti   $$13   Change format of export.|  01-May-05 K-03-24 Moti   $$14  Changed cursor of headers to pointer.|  05-Jul-05 K-03-28 Moti   $$15  Added HEADER_ prefix to headers id.|  09-Aug-05 K-03-31 Moti   $$16  Added diff_rep_attach_as_secondary.|  10-Jan-06 L-01-01 Moti   $$17  Added support for sorting by different column|  03-Aug-06 L-01-16 dzel   $$18  Added setTableCellInfo().|  11-May-08 L-03-09 IKAL   $$19  Added toggleTableCollapsed().|  31-Jul-08 L-03-15 IKAL   $$20  Added addTableScrollbar().|  03-Sep-08 L-03-17 Moti   $$21  Added setTableCollapsed().||  INSERT COMMENT ABOVE THIS LINE|\*---------------------------------------------------------------------------*//* ------------------ Global variabals --------------------------*/var textRows = new Array () ;var tables = new Array () ;var current_table_id = '' ;var SpGif = '' ;var DownArrowGif = '' ;var UpArrowGif = '' ;var HorzArrowGif = '' ;var CollapseImage = '' ;var ExpandImage = '' ;var SHOW = "Yes" ;var HIDE = "No" ;var ALLOW_SORT = "Yes" ;var DONT_ALLOW_SORT = "No" ;var SORT_DECENDING = -1 ;var SORT_NOT_SORTED = 0 ;var SORT_ACENDING = 1 ;var SORT_ACENDING_REVERSE = 2 ;var HTML_FORMAT = 0 ;var TEXT_FORMAT_TABS = 1 ;var TEXT_FORMAT_COMMA = 2 ;/* ------------------  Pro/E Javascript Bridge ------------------*/function ProExec(cmd) {  if (top.window.external && top.window.external.ptc)     return top.window.external.ptc(cmd);  return null;}          // The Pro/E Javascript Bridge - Non Blocking callfunction ProECommandVoid(cmd) { return ProExec("0" + cmd); }// The Pro/E Javascript Bridge - Blocking callfunction ProECommand(cmd) { return ProExec("1" + cmd); }function debug_error_crash (msg , func_name){  var full_command = 'report_js_debug_info?' + func_name + '?crash?' + msg ;  ProECommandVoid ( full_command ) ;}function export_report_to_file ( text , file_name ){  var full_command = 'report_export?Type=text?File=' + file_name + 	'@' + text ;  ProECommandVoid ( full_command ) ;}function smt_highlight_rule_violation ( info ){  var full_command = 'smt_highlight_rule_violation?' + info ;  ProECommandVoid ( full_command ) ;}function smt_highlight_features_by_val ( info ){  var full_command = 'smt_highlight_features_by_val?' + info ;  ProECommandVoid ( full_command ) ;}function diff_rep_attach_as_secondary ( info ){  var full_command = 'diff_rep_attach_as_secondary?' + info ;  ProECommandVoid ( full_command ) ;}/* ------------------ Data functions --------------------------*/function escape_id ( table_id ){  var result = table_id ;  var index = result.indexOf ( "ESC" ) ;  while ( index >= 0 )  {    var tmp = result.substring ( 0 , index ) + "CSE" +       result.substring ( index + 3 ) ;    result = tmp ;    index = result.indexOf ( "ESC" ) ;  }  return result ;}/*--------------------------------------------------------------------------*\| Function: TableDefinition| Purpose:  datastructure of table| Input:    table_id   - table string identifier| Output:   | Return:   \*--------------------------------------------------------------------------*/function TableDefinition (table_id){  // first check that the id is unique  if ( getTableIndexByID (table_id) == -1 )  {    var escaped_id = escape_id ( table_id ) ;    while ( getEscapedTableIndexByID ( escaped_id ) != -1 )    {      escaped_id += '_' ;    }    this.tableHeadersData = new Array () ;    this.tableRowsData = new Array () ;           this.table_id = table_id ;    this.escaped_table_id = escaped_id ;    this.tableHeight = -1 ;    this.sortIndex = -1 ;    this.showRowsCBs = new Array () ;    this.tableTitle = null ;    this.visibleHeaders = true ;    this.defaultColor = null ;    this.emptyMsgs = new Array () ;    this.collapsible = false ;    this.collapsed = false ;  }}/*--------------------------------------------------------------------------*\| Function: TextRowDefinition| Purpose:  datastructure of TextRow| Input:    table_index   - table index before we should display the text| Output:   | Return:   \*--------------------------------------------------------------------------*/function TextRowDefinition ( text , table_index ){  this.text = text ;  this.beforeIndex = table_index ;       }/*--------------------------------------------------------------------------*\| Function: CBDefinition| Purpose:  datastructure of CB function| Input:    cb_func    - callback function which will be called|           type       - type of callback func ( currently only "IsShowRow" )|           data1      - first data of user|           data2      - second data of user| Output:   | Return:   \*--------------------------------------------------------------------------*/function CBDefinition ( cb_func , type , data1 , data2 ){  this.cbFunc = cb_func ;  this.type = type ;  this.data1 = data1 ;  this.data2 = data2 ;}/*--------------------------------------------------------------------------*\| Function: TableCell| Purpose:  datastructure of table cell| Input:    text    - text of the cell| Output:   | Return:   \*--------------------------------------------------------------------------*/function TableCell ( text ){  this.text = text ;  this.colSpan = -1 ;  this.rowSpan = -1 ;  this.bold = false ;  this.font = null ;  this.align = null ;  this.valign = null ;}/*--------------------------------------------------------------------------*\| Function: TableRow| Purpose:  datastructure of table row| Input:    function gets undefined number of arguments|           argument[0..] - table data| Output:   | Return:   \*--------------------------------------------------------------------------*/function TableRow ( row_data_array , insert_order ){  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )  {    var num = row_data_array.length ;    var table = tables[index] ;    if ( num >= 0 )    {      if ( num <= table.tableHeadersData.length )      {	this.insert_order = insert_order ;	this.col = new Array () ;	this.visible = SHOW ;	this.anchor = false;	this.color = null ;	for ( var i = 0 ; i < num ; i ++ )	  this.col[i] = new TableCell ( row_data_array[i] ) ;      }      else	debug_error_crash ("Error: too many parameters passed to TableRow" , 			   "TableRow" ) ;    }    else      debug_error_crash ("Error: 0 parameters passed to TableRow" , 			 "TableRow" ) ;        this.table = table ;  }}/*--------------------------------------------------------------------------*\| Function: TableHeader| Purpose:  datastructure of table header| Input:    header_name - header label|           header_unique_name - legal unique string for this table headers|           header_cmp_func - compare function for sorting|           allow_sort - should this column show the sort arrow|           visible    - is this column visible ( default "Yes" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function TableHeader ( args ){  num = args.length ;  this.headerName = args[0] ;  this.headerUniqueName = args[1] ;  if ( num > 2 )    this.headerCmpFunc = args[2] ;  else    this.headerCmpFunc = null ;      if ( num > 3 )    this.allow_sort = args[3] ;  else    this.allow_sort = DONT_ALLOW_SORT ;  if ( num > 4 )    this.visible = args[4] ;  else    this.visible = SHOW ;  this.colClass = 'tabledatafont' ;  this.colAlign = 'left' ;  this.colVAlign = 'middle' ;  this.textFormatVisibility = SHOW ;  this.cellToTextCB = null ;  this.showHeader = true;  this.sortByColumnIndex = -1;  this.sort_order = SORT_NOT_SORTED}/* --------------------------  functions --------------------------*//*--------------------------------------------------------------------------*\| Function: Initialize_images| Purpose:  function initialize the images that used by the js code| Input:    sp_gif - sp.gif file full path|           down_arrow_gif - downarrow.gif file full path|           up_arrow_gif - uparrow.gif file full path|           horz_arrow_gif - horzarrow.gif file full path| Output:   | Return:   \*--------------------------------------------------------------------------*/function Initialize_images ( sp_gif , down_arrow_gif , up_arrow_gif ,                              horz_arrow_gif , collapse_image , expand_image ){  SpGif = sp_gif ;  DownArrowGif = down_arrow_gif ;  UpArrowGif = up_arrow_gif ;  HorzArrowGif = horz_arrow_gif ;  CollapseImage = collapse_image ;  ExpandImage = expand_image ;}/*--------------------------------------------------------------------------*\| Function: appendToArray| Purpose:  function appends object to array| Input:    arr    - array target to append to|           item   - item to append| Output:   | Return:   \*--------------------------------------------------------------------------*/function appendToArray ( arr , item ){  arr[arr.length] = item ;}/*--------------------------------------------------------------------------*\| Function: addTableScrollbar| Purpose:  function adds a scrollbar to array| Input:    height - the height of the table| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTableScrollbar ( height ){  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )  {    var table = tables[index] ;    table.tableHeight = height ;  }}/*--------------------------------------------------------------------------*\| Function: setTableCollapsed| Purpose:  function sets table to be collapsed by default| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function setTableCollapsed (){  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )  {    var table = tables[index] ;    table.collapsible = true ;    table.collapsed = true ;  }}/*--------------------------------------------------------------------------*\| Function: addTable| Purpose:  function begins a new table | Input:    table_id   - table string identifier must be unique| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTable (table_id){  var index = getTableIndexByID (table_id) ;      if ( index == -1 )  {    var table = new TableDefinition ( table_id ) ;    appendToArray ( tables , table ) ;    current_table_id = table_id ;  }  else  {    debug_error_crash ( 'Error: table name "' + table_id + '" is not unique.',			"addTable" ) ;  }}/*--------------------------------------------------------------------------*\| Function: addTextRow| Purpose:  function adds new text row | Input:    text   - text to add| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTextRow ( text ){  var index = tables.length ;  var row = new TextRowDefinition ( text , index ) ;  appendToArray ( textRows , row ) ;}/*--------------------------------------------------------------------------*\| Function: | Purpose:  function finds the index of the heade in the headers array| Input:    headers - hedars objects array|           name    - name to check| Output:   | Return:   header index or -1 if not found\*--------------------------------------------------------------------------*/function getHeaderIndexByID ( headers , name ){  var result = -1 ;  for ( var i = 0 ; i < headers.length ; i ++ )  {    if ( headers[i].headerUniqueName == name )    {      result = i ;      break ;    }  }  return result ;}/*--------------------------------------------------------------------------*\| Function: isUniqueHeaderName| Purpose:  function checks that the header name is unique in the given table| Input:    headers - hedars objects array|           name    - name to check| Output:   | Return:   1/0 unique/not-unique

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?