$PBExportHeader$pfc_n_cst_dwsrv_sort.sru $PBExportComments$PFC DataWindow Sort service forward global type pfc_n_cst_dwsrv_sort from n_cst_dwsrv end type end forward global type pfc_n_cst_dwsrv_sort from n_cst_dwsrv event type integer pfc_clicked ( integer ai_xpos, integer ai_ypos, long al_row, ref dwobject adwo_obj ) event type integer pfc_sortdlg ( ) end type global pfc_n_cst_dwsrv_sort pfc_n_cst_dwsrv_sort type variables Public: // Style constants. // Defined in ancestor - constant integer DEFAULT = 0 constant integer DRAGDROP = 1 constant integer SIMPLE = 2 constant integer DROPDOWNLISTBOX = 3 Protected: boolean ib_columnheadersort boolean ib_visibleonly=true boolean ib_displayvalues integer ii_style string is_excludecolumns[] string is_sortcolumn string is_sortorder end variables forward prototypes public function boolean of_getusedisplay () public function boolean of_getvisibleonly () public function integer of_setsort (string as_format) public function string of_getsort () public function integer of_setvisibleonly (boolean ab_visible) public function integer of_sort () public function integer of_getexclude (ref string as_excludecols[]) public function integer of_setexclude (string as_excludecols[]) public function integer of_setusedisplay (boolean ab_usedisplay) protected function boolean of_usesdisplayvalue (string as_column) protected function integer of_buildsortattrib (ref n_cst_sortattrib anv_sortattrib) protected function integer of_ParseSortAttrib (string as_originalsort, ref n_cst_sortattrib anv_sortattrib) public function integer of_setstyle (integer ai_style) public function integer of_getstyle () public function integer of_setcolumnheader (boolean ab_switch) public function boolean of_getcolumnheader () public function integer of_getregisterable (ref string as_allcolumns[]) public function integer of_getinfo (ref n_cst_infoattrib anv_infoattrib) public function integer of_getpropertyinfo (ref n_cst_propertyattrib anv_attrib) end prototypes event pfc_clicked;call super::pfc_clicked;////////////////////////////////////////////////////////////////////////////// // // Function: pfc_clicked // // Access: Public // // Arguments: (passed arguments of dw Clicked event) // xpos (integer) The x-position of the mouse // ypos (integer) The y-position of the mouse // row (long) The row number clicked on, if any // dwo (dwobject) The dwobject clicked on ) // cntl_clicked (boolean) Indicates that the user pressed Ctnl/Click // // Returns: Integer // 1 if it succeeds. // 0 if no action was required. // -1 if an error occurs. // // Description: Causes sorting when the user clicks on the header // of a datawindow, emulating the WIN95 style. // Click causes new sort (alternately Asc/Desc if same column). // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// string ls_headername string ls_colname integer li_rc integer li_suffixlen integer li_headerlen string ls_sortstring // Validate the dwo reference. IF IsNull(adwo_obj) OR NOT IsValid(adwo_obj) THEN Return -1 END IF // Check if the service is set to sort on column headers. IF NOT of_GetColumnHeader() THEN Return 0 // Only valid on header column. If adwo_obj.Name = 'datawindow' THEN Return 0 IF adwo_obj.Band <> "header" THEN Return 0 // Get column header information. ls_headername = adwo_obj.Name li_headerlen = Len(ls_headername) li_suffixlen = Len(is_defaultheadersuffix) // Extract the columname from the header label // (by taking out the header suffix). IF Right(ls_headername, li_suffixlen) <> is_defaultheadersuffix THEN // Cannot determine the column name from the header. Return -1 END IF ls_colname = Left (ls_headername, li_headerlen - li_suffixlen) // Validate the column name. If IsNull(ls_colname) or Len(Trim(ls_colname))=0 Then Return -1 End If // Check the previous sort click. IF is_sortcolumn = ls_colname THEN // Second sort click on the same column, reverse sort order. IF is_sortorder = " A" THEN is_sortorder = " D" ELSE is_sortorder = " A" END IF ELSE // Clicked on a different column. is_sortcolumn = ls_colname is_sortorder = " A" END IF // Build the sort string. IF of_GetUseDisplay() And of_UsesDisplayValue(ls_colname) THEN ls_sortstring = "LookUpDisplay(" + ls_colname + ") " + is_sortorder ELSE ls_sortstring = is_sortcolumn + is_sortorder END IF // Perform the SetSort operation (check the rc). li_rc = of_SetSort (ls_sortstring) If li_rc < 0 Then Return li_rc // Perform the actual Sort operation (check the rc). li_rc = of_Sort() If li_rc < 0 Then Return li_rc Return 1 end event event pfc_sortdlg;call super::pfc_sortdlg;////////////////////////////////////////////////////////////////////////////// // // Event: pfc_SortDlg // // (Arguments: None) // // Returns: Integer // 1 if it succeeds. // 0 if operation was cancelled by the user. // -1 if an error occurs. // // Description: Sorts a datawindow based on the sort constructed // by the user thru one of the PFC Sort dialogs. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // 5.0.04 Set focus back on the datawindow. // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_rc string ls_nullformat SetNull (ls_nullformat) // Check required reference. If IsNull(idw_requestor) or Not IsValid(idw_requestor) Then Return -1 End If // This will open a sort dialog. li_rc = of_SetSort (ls_nullformat) // Set focus back on the datawindow. idw_requestor.SetFocus() // Check if the user cancelled the operation (li_rc =0) // or if otherwise failed(li_rc <-1). IF li_rc <= 0 THEN Return li_rc // Sort the requesting datawindow. Return of_Sort() end event public function boolean of_getusedisplay ();////////////////////////////////////////////////////////////////////////////// // // Function: of_GetUseDisplay // // Access: Public // // Arguments: None // // Returns: Boolean // TRUE: Use display values in sort // FALSE: Do not use display values in sort // // Description: To determine whether to use display values in // sorts. Set by of_SetUseDisplay. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// Return ib_displayvalues end function public function boolean of_getvisibleonly ();////////////////////////////////////////////////////////////////////////////// // // Function: of_GetVisibleOnly // // Access: Public // // Arguments: None // // Returns: Boolean // // Description: To get the state of using visible columns only, set in // of_SetVisibleOnly // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// Return ib_visibleonly end function public function integer of_setsort (string as_format);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetSort // // Access: Public // // Arguments: // as_format: A string whose value is valid sort criteria for the DataWindow. // The expression includes column names or numbers. A column number // must be preceded by a pound sign (#). If format is NULL, // function prompts you to enter the sort criteria. // // Returns: Integer // 1 if it succeeds. // 0 User Cancelled out of a dialog window. // -1 if an error occurs. // // Description: Set the sort. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // 6.0 Use of constants within services. // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_rc n_cst_sortattrib lnv_sortattrib n_cst_returnattrib lnv_return // Check the datawindow reference. If IsNull(idw_Requestor) Or Not IsValid(idw_Requestor) Then Return -1 // If the parameter is not null, then peform a regular SetSort operation. IF Not IsNull (as_format) THEN Return idw_Requestor.SetSort (as_format) END IF // Passed argument was Null (as_format is null), // call the appropriate SetSort Dialog. CHOOSE CASE ii_style CASE DEFAULT // 0 = Powerscript default sort style dialog. li_rc = idw_Requestor.SetSort (as_format) // Check if the dialog was close via the Cancel button. If li_rc = -1 Then li_rc = 0 Return li_rc CASE DRAGDROP, SIMPLE, DROPDOWNLISTBOX // Call one of the PFC sort dialog windows. IF of_BuildSortAttrib(lnv_sortattrib) <> 1 THEN Return -1 IF ii_style = 1 THEN // 1 = Drag and Drop style dialog. OpenWithParm (w_sortdragdrop, lnv_sortattrib) ELSEIF ii_style = 2 THEN // 2 = Simple (single column) style dialog. OpenWithParm (w_sortsingle, lnv_sortattrib) ELSE // 3 = DDLB style dialog. OpenWithParm (w_sortmulti, lnv_sortattrib) END IF // Get the return PowerObject. lnv_return = Message.PowerObjectParm // Check if the dialog was close via the Cancel button. IF lnv_return.ii_rc <> 1 Then Return lnv_return.ii_rc Return idw_Requestor.SetSort (lnv_return.is_rs) END CHOOSE // Invalid option. Return -1 end function public function string of_getsort ();////////////////////////////////////////////////////////////////////////////// // // Function: of_GetSort // // Access: Public // // Arguments: None // // Returns: String // The sort expression // // Description: Get the current sort expression on the datawindow. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Check the datawindow reference. If IsNull(idw_Requestor) Or Not IsValid(idw_Requestor) Then Return '' // Return the current sort for the datawindow. Return idw_Requestor.Describe ("DataWindow.Table.Sort") end function public function integer of_setvisibleonly (boolean ab_visible);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetVisibleOnly // // Access: Public // // Arguments: // ab_visible: When TRUE, only include visible columns in Sort dialogs. // // Returns: Integer // 1 if successful, otherwise -1 // // Description: Sets the state of use visible columns only. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Verify passed arguments. IF IsNull(ab_visible) THEN Return -1 ib_visibleonly = ab_visible Return 1 end function public function integer of_sort ();////////////////////////////////////////////////////////////////////////////// // // Function: of_Sort // // Access: Public // // Arguments: None // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: Sorts a datawindow and fires a message to the datawindow // to indicate that the current row may have changed. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_rc li_rc = idw_Requestor.Sort() // Tell the datawindow that the buffer has changed and that the // current row may have new data. idw_Requestor.Event pfc_rowchanged() Return li_rc end function public function integer of_getexclude (ref string as_excludecols[]);////////////////////////////////////////////////////////////////////////////// // // Function: of_GetExclude // // Access: Public // // Arguments: // as_exclude_cols A string array, passed by reference, that will // hold the exclude columns returned. // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: To get the list of exclude columns set in of_SetExclude. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// as_excludecols = is_excludecolumns Return 1 end function public function integer of_setexclude (string as_excludecols[]);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetExclude // // Access: Public // // Arguments: // as_excludecols: An array of columnnames to be excluded from // sort dialogs. // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: Establishes a list of columns to be excluded from // sort dialogs. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// is_excludecolumns = as_excludecols Return 1 end function public function integer of_setusedisplay (boolean ab_usedisplay);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetUseDisplay // // Access: Public // // Arguments: // ab_use_display: An indicator to use/not use display values in sorts. // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: Sets an indicator to use/not use display values in sorts. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Verify passed arguments. IF IsNull(ab_usedisplay) THEN Return -1 ib_displayvalues = ab_usedisplay Return 1 end function protected function boolean of_usesdisplayvalue (string as_column);////////////////////////////////////////////////////////////////////////////// // // Function: of_UsesDisplayValue // // Access: protected // // Arguments: // as_column: A datawindow columnname/computename for which you want to // determine if there is a display value // // Returns: boolean // TRUE: The column has a display value // FALSE: The column does not have a display value or does not exist // // Description: Determine if a datawindow column has a display value. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// string ls_editstyle string ls_codetable // Check parameters. If IsNull(as_column) or Len(Trim(as_column))=0 Then Return False ls_editstyle = Lower(idw_Requestor.Describe (as_column + ".Edit.Style")) ls_codetable = Lower(idw_Requestor.Describe (as_column + "." + ls_editstyle + ".CodeTable")) IF ls_editstyle = 'dddw' or ls_editstyle = 'ddlb' or ls_codetable = 'yes' THEN Return True END IF Return False end function protected function integer of_buildsortattrib (ref n_cst_sortattrib anv_sortattrib);////////////////////////////////////////////////////////////////////////////// // // Function: of_BuildSortAttrib // // Access: Protected // // Arguments: // anv_sortattrib: A NVO attribute class, passed by reference, that // will hold sort information used by the Sort dialogs. // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: Prepares the sort information required by the // Specify Sort dialogs. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_numcols integer li_i integer li_j integer li_k integer li_numcomputes integer li_exclude string ls_computes[] string ls_dbname string ls_sortcolumns_all[] // Hold all sort columns prior to any exclusions. string ls_sortcolumns_exc[] // Hold sort columns after excluding appropriate ones. boolean lb_exclude n_cst_string lnv_string // Validate dw reference. If IsNull(idw_Requestor) Or Not IsValid(idw_Requestor) Then Return -1 // Get the current sort for the datawindow. anv_sortattrib.is_sort = of_GetSort() // Remove space after the comma(s) (convert ', ' to ','). anv_sortattrib.is_sort = lnv_string.of_GlobalReplace (anv_sortattrib.is_sort, ', ', ',') // Parse the original sort into separate elements. of_ParseSortAttrib ( anv_sortattrib.is_sort, anv_sortattrib ) // Get all the column names on the datawindow. li_numcols = of_GetObjects(ls_sortcolumns_all, "column", "*", ib_visibleonly) // Get all the computed column names on the datawindow and add them to the array. li_numcomputes = of_GetObjects( ls_computes, "compute", "*", ib_visibleonly) FOR li_i = 1 to li_numcomputes li_numcols++ ls_sortcolumns_all[li_numcols] = ls_computes[li_i] NEXT // See if any columns were set to be excluded from the sort display // and create a new list of sort columns. li_exclude = UpperBound(is_excludecolumns) FOR li_j = 1 to li_numcols lb_exclude = FALSE FOR li_i = 1 to li_exclude IF Lower(is_excludecolumns [li_i]) = Lower(ls_sortcolumns_all[li_j]) THEN lb_exclude = TRUE EXIT END IF NEXT IF Not lb_exclude THEN li_k++ ls_sortcolumns_exc[li_k] = ls_sortcolumns_all[li_j] END IF NEXT // Copy the list of appropriate sort columns to the nvo. anv_sortattrib.is_sortcolumns = ls_sortcolumns_exc li_numcols = UpperBound(anv_sortattrib.is_sortcolumns) // Get the column displayname. CHOOSE CASE of_GetColumnnameSource ( ) CASE 0 // Use dw Column Names FOR li_i = 1 to li_numcols anv_sortattrib.is_colnamedisplay[li_i] = anv_sortattrib.is_sortcolumns[li_i] NEXT CASE 1 // Use Database Names FOR li_i = 1 to li_numcols ls_dbname = idw_Requestor.Describe ( anv_sortattrib.is_sortcolumns[li_i] + ".DbName" ) IF ls_dbname = "" OR ls_dbname = "!" THEN ls_dbname = anv_sortattrib.is_sortcolumns[li_i] anv_sortattrib.is_colnamedisplay[li_i] = ls_dbname NEXT CASE 2 // Use Column Headers FOR li_i = 1 to li_numcols anv_sortattrib.is_colnamedisplay[li_i] = & of_GetHeaderName ( anv_sortattrib.is_sortcolumns[li_i] ) NEXT END CHOOSE // Determine if LookUpDisplay should automatically be added when creating sort strings // using the PFC SetSort Dialogs. FOR li_i = 1 to li_numcols IF of_GetUseDisplay() THEN anv_sortattrib.ib_usedisplay[li_i] = of_UsesDisplayValue(anv_sortattrib.is_sortcolumns[li_i]) ELSE anv_sortattrib.ib_usedisplay[li_i] = FALSE END IF NEXT Return 1 end function protected function integer of_ParseSortAttrib (string as_originalsort, ref n_cst_sortattrib anv_sortattrib);////////////////////////////////////////////////////////////////////////////// // // Function: of_ParseSortAttrib // // Access: Protected // // Arguments: // as_originalsort: A string containing the original sort statement // anv_sortattrib: A NVO attribute class, passed by reference, that // will hold sort information used by the Sort dialogs. // // Returns: Integer // 1 if it succeeds and -1 if an error occurs. // // Description: Parses a sort statement into individual parts. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_num_cols integer li_i string ls_parse n_cst_string lnv_string // Parse the original sort string into separate elements, // in order to display the original sort when the user // opens a sort dialog. lnv_string.of_ParseToArray ( as_originalsort, ",", anv_sortattrib.is_origcolumns ) // Loop around all array entries. li_num_cols = UpperBound ( anv_sortattrib.is_origcolumns ) FOR li_i = 1 to li_num_cols ls_parse = anv_sortattrib.is_origcolumns[li_i] // Remove the LookUpDisplay function if it was used in the sort. If Pos(Lower(ls_parse), Lower("LookUpDisplay(")) > 0 Then ls_parse = lnv_string.of_GlobalReplace ( ls_parse, "LookUpDisplay(", "" ) ls_parse = lnv_string.of_GlobalReplace ( ls_parse, ")", "" ) ls_parse = Trim ( ls_parse ) End If anv_sortattrib.is_origcolumns[li_i] = lnv_string.of_GetToken (ls_parse, " ") anv_sortattrib.is_origorder[li_i] = ls_parse NEXT Return 1 end function public function integer of_setstyle (integer ai_style);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetStyle // // Access: Public // // Arguments: // ai_sort_style (integer) A value that determines the style // of sort dialog. // Values are: // 0 = PowerBuilder default sort style dialog (Default) // 1 = Drag and Drop style dialog // 2 = Simple (single column) style dialog // 3 = DDLB style dialog // // Returns: Integer // 1 if successful, otherwise -1 // // Description: Sets the style of sort dialog to be used when // of_Sort is called. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // 6.0 Use of constants within services. // Default style now has dialog help. // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Check to see if the passed style number is valid. IF IsNull(ai_style) THEN Return -1 End If CHOOSE CASE ai_style CASE DEFAULT, DRAGDROP, SIMPLE, DROPDOWNLISTBOX ii_style = ai_style if ii_style = DEFAULT then if isValid (idw_requestor) then if len (idw_requestor.dataobject) > 0 then idw_requestor.object.datawindow.help.command = 1 idw_requestor.object.datawindow.help.file = "pfcdlg.hlp" idw_requestor.object.datawindow.help.typeid.setsort = "1200" idw_requestor.object.datawindow.help.typeid.setsortexpr = "800" end if end if end if Return 1 END CHOOSE Return -1 end function public function integer of_getstyle ();////////////////////////////////////////////////////////////////////////////// // // Function: of_GetStyle // // Access: Public // // Arguments: None // // Returns: Integer // 0 = PowerBuilder default sort style dialog (Default) // 1 = Drag and Drop style dialog // 2 = Simple (single column) style dialog // 3 = DDLB style dialog // // Description: Determine the sort dialog style that was set // by of_SetSortStyle // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// Return ii_style end function public function integer of_setcolumnheader (boolean ab_switch);////////////////////////////////////////////////////////////////////////////// // // Function: of_SetColumnHeader // // Access: Public // // Arguments: // ab_switch States if the service should sort when the user clicks // on a column header. // // Returns: Integer // 1 if successful, otherwise -1 // // Description: States if the service should sort when the user clicks // on a column header. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Check arguments. IF IsNull(ab_switch) THEN Return -1 ib_columnheadersort = ab_switch Return 1 end function public function boolean of_getcolumnheader ();////////////////////////////////////////////////////////////////////////////// // // Function: of_GetColumnHeader // // Access: Public // // Arguments: None // // Returns: Boolean // True if the service is set to sort when the user clicks // on a column header. // // Description: Determine if the service is set to sort when the user clicks // on a column header. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// Return ib_columnheadersort end function public function integer of_getregisterable (ref string as_allcolumns[]);////////////////////////////////////////////////////////////////////////////// // // Function: of_GetRegisterable // // Access: Public // // Arguments: // as_allcolumns[] Passed by reference, that will hold all the columns // (including computed columns) that the service can use to perform sorts. // // Returns: Integer // # of entries // -1 if an error occurs // // Description: // To get the list of all the columns (including computed columns) that the service // can use to perform sorts. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 6.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// integer li_numcols integer li_numcomputes integer li_i string ls_sortcolumns_all[] string ls_computes[] // Get all the column names on the datawindow. li_numcols = of_GetObjects(ls_sortcolumns_all, "column", "*", ib_visibleonly) // Get all the computed column names on the datawindow and add them to the array. li_numcomputes = of_GetObjects( ls_computes, "compute", "*", ib_visibleonly) FOR li_i = 1 to li_numcomputes li_numcols++ ls_sortcolumns_all[li_numcols] = ls_computes[li_i] NEXT as_allcolumns = ls_sortcolumns_all Return UpperBound(as_allcolumns) end function public function integer of_getinfo (ref n_cst_infoattrib anv_infoattrib);////////////////////////////////////////////////////////////////////////////// // // Function: of_GetInfo // // Access: Public // // Arguments: // anv_infoattrib (By reference) The Information attributes. // // Returns: Integer // 1 for success. // -1 for error. // // Description: // Gets the Service Information. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 6.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// // Populate Information. anv_infoattrib.is_name = 'Sort' anv_infoattrib.is_description = & 'Provides Sort dialogs to facilitate the sorting of datawindow rows.' Return 1 end function public function integer of_getpropertyinfo (ref n_cst_propertyattrib anv_attrib);////////////////////////////////////////////////////////////////////////////// // // Function: of_GetPropertyInfo // // Access: Public // // Arguments: // anv_attrib (By ref.) The Property Information attributes. // // Returns: Integer // 1 for success. // -1 for error. // // Description: // Gets the Service Property Information. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 6.0 Initial version // ////////////////////////////////////////////////////////////////////////////// // /* * Open Source PowerBuilder Foundation Class Libraries * * Copyright (c) 2004-2005, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted in accordance with the GNU Lesser General * Public License Version 2.1, February 1999 * * http://www.gnu.org/copyleft/lesser.html * * ==================================================================== * * This software consists of voluntary contributions made by many * individuals and was originally based on software copyright (c) * 1996-2004 Sybase, Inc. http://www.sybase.com. For more * information on the Open Source PowerBuilder Foundation Class * Libraries see http://pfc.codexchange.sybase.com */ // ////////////////////////////////////////////////////////////////////////////// n_cst_infoattrib lnv_infoattrib // Get the first two attributes from the Main Information attributes. of_GetInfo(lnv_infoattrib) anv_attrib.is_name = lnv_infoattrib.is_name anv_attrib.is_description = lnv_infoattrib.is_description // Set the rest of the attributes. anv_attrib.is_propertypage = {'u_tabpg_dwproperty_srvsort'} anv_attrib.ib_switchbuttons = True Return 1 end function on pfc_n_cst_dwsrv_sort.create TriggerEvent( this, "constructor" ) end on on pfc_n_cst_dwsrv_sort.destroy TriggerEvent( this, "destructor" ) end on
File: pfc_n_cst_dwsrv_sort.sru
Size: 47220
Date: Tue, 22 Jan 2008 23:29:19 +0100
Size: 47220
Date: Tue, 22 Jan 2008 23:29:19 +0100
- n_cst_dwsrv pfc_n_cst_dwsrv_sort(sru)
- of_buildsortattrib (ref n_cst_sortattrib anv_sortattrib) returns integer
- of_getcolumnheader () returns boolean
- of_getexclude (ref string as_excludecols[]) returns integer
- of_getinfo (ref n_cst_infoattrib anv_infoattrib) returns integer
- of_getpropertyinfo (ref n_cst_propertyattrib anv_attrib) returns integer
- of_getregisterable (ref string as_allcolumns[]) returns integer
- of_getsort () returns string
- of_getstyle () returns integer
- of_getusedisplay () returns boolean
- of_getvisibleonly () returns boolean
- of_parsesortattrib (string as_originalsort, ref n_cst_sortattrib anv_sortattrib) returns integer
- of_setcolumnheader (boolean ab_switch) returns integer
- of_setexclude (string as_excludecols[]) returns integer
- of_setsort (string as_format) returns integer
- of_setstyle (integer ai_style) returns integer
- of_setusedisplay (boolean ab_usedisplay) returns integer
- of_setvisibleonly (boolean ab_visible) returns integer
- of_sort () returns integer
- of_usesdisplayvalue (string as_column) returns boolean