|
FusionCharts Import->Export This article shows how to create a Rev application that uses the SpecialFolders Path and the CustomProperties functions to import/export FusionCharts files. In this article I’ll show how this file was created to support Mac and Win. The phrase “Temporary Path, Permanent Solution" describes the technique for managing FusionCharts with a minimal footprint on your system. Consider FileMaker, where a solution I created obtains the path to temporary storage on Mac and Win during a given session. During an FMP session, chart files are imported, which needs be done only once. Then, during each subsequent session these imported files are automatically exported to a temporary storage area depending on the FusionCharts Mode (Free or Trial/Pro). At that point, report information is assembled and a URL string is created. The first part of the URL string is the location of the chart files followed by the chart report info. That URL string is passed to a WebViewer (the FMP) equivalent of Revolutions revBrowser and the chart is rendered. So, I’m on a mission to replicate this functionality in Rev and pass it on to the Rev community. A special thanks to Mark Weider for showing this Rev newbie how CustomProperties work. Mark has just finished a lesson on CustomProperties, which can be found here. During this task of learning Rev’s input/output functionality, I created a stack that shows the Rev developer how to:
This functionality is the first major step prior to rendering the specified chart. In pursuing this task, excellent help was afforded by Mark Weider of ahsoftware.net. A subsequent article will show how FusionCharts along with the required URL string will call a revBrowser or Browser (FireFox, Safari, IE, etc.) to process the passed URL string and render the specified chart. FusionCharts Input/Output Overview
Figure 1 - FusionCharts Input/Output Overview
This action provides visual feedback of the processing to the user. The “Export FusionCharts Files” button exports the FusionCharts files from the cChartFiles CustomProperty as decompressed binary files to a Temporary Folder.
Repeat the steps above, then create 2 additional blue buttons (152 px width and 22 px height) as described above with these 2 labels: “Import FusionCharts Files” and “Export FusionCharts Files”. Preparing Button Skins: White Buttons (Icon)
Figure 9.3 – White Button Snapshot Figure 10 – Overlay Images (card id 1118) Hilight Icons: 1181, 1178 and 1176 Skinning The Cat:
Before following the process below, all the buttons need set as follows: Set Button Skin Process
FusionCharts Tool Tips
ToolTips & ToolTip Calc Examples Note that the ToolTip calculations below, create paginated ToolTips using the paradigm “Text Line 1” & cr & “Text Line 2”, etc. set the ToolTip of Btn "Erase File Name List" to \ "Click Here To Erase" & cr & "The File Name List" When the “Get File Names List” button is clicked:
set the ToolTip of Btn "Get File Names List" to \ "Click Here To Import" & cr & "The FusionCharts" \ & cr & "FileNames Into The"& cr & "Filename List"
This action provides visual feedback of the processing to the user.
set the ToolTip of Btn "Erase Files Imported #" to \ "Click Here To Erase" & cr & "Files Imported #" When the “Import FusionCharts Files” button is clicked:
set the ToolTip of Btn "Import FusionCharts Files" to \ "Click Here To Import" & cr & "FusionCharts Files" When the “Erase File Imported #” button is clicked:
set the ToolTip of Btn "Export FusionCharts Files" to \ "Click Here To Export" & cr & "FusionCharts Files" When the Export FusionCharts Files button is clicked:
This action provides visual feedback of the processing to the user.
set the ToolTip of Btn "Import FusionCharts Files" to \ "Click Here To Import" & cr & "FusionCharts Files" When the “Erase File Exported #” button is clicked:
On the Win when the “Export FusionCharts Files” button is clicked, the FusionCharts files are exported as shown below in Internet Explorer:
FusionCharts ImportExport Stack Scripts
/-- -- Author: Andy Piddock -- Creation Date: mm/dd/2007 -- About These Scripts: -- Close Stack -- Cleanup Fields -- Get Folder Content -- Quit Routines -- History -- Modifier: William Roger Moseid -- Date: 06/24/2010 -- Added Script Header -- Added Andy's Quit Scripts -- Added Setup Win /Mac SpecialFolders Configuration --/ -- Get folder contents function folder_content tFolder local olddir local tFiles put the defaultfolder into olddir set the defaultfolder to tFolder put the files into tFiles set the defaultfolder to olddir return tFiles end folder_content on preOpenStack -- Set Win or Mac SpecialFolders Configuration -- i.e., if "Mac" is not in the platform then put "28" into Fld "tSF#_Code" put "Win SpecialFolders Number:" into Fld "LblSF#_Code" else -- Is Mac put "temp" into Fld "tSF#_Code" put "Mac SpecialFolders Code:" into Fld "LblSF#_Code" end if end preOpenStack on closeStack -- Delete Temporary Folder revDeleteFolder Fld "FldSFPath" //Uncomment if exe made //clear_fields quitMyProject pass closeStack end closeStack Figure 18a Stack Scripts
-Quit routines on quitMyProject local myStacks local myMsgs local myDontClose lock messages -- Stop using stacks put the stacksInUse into myStacks repeat for each line myStack in myStacks stop using stack myStack end repeat -- Stacks put the openStacks into myStacks put "message box,home,tool,Message Box,revTools,revMenubar" \ & comma & the short name of me into myDontClose repeat for each line myStack in myStacks if myStack is not among the items of myDontClose then \ close stack myStack end repeat -- Messages put the pendingmessages into myMsgs repeat for each line myMsg in myMsgs cancel item 1 of myMsg end repeat set the backdrop to none close me if the environment is not "development" then quit end if end quitMyProjectnd quitMyProject Figure 18b – Stack Scripts /-- Author: Mark Weider, William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: -- Empties The Special Folder Path Table -- Clears The Filename Lists -- Puts The Folder Path Code, If Any, In -- The Special Folder Path Field -- History -- Modifier: William Roger Moseid -- Date: 06/25/2010 -- Added Script Header & Comments -- Added DropShadow Logic & Cursor Setup -- Added Background Color For Mac -- Added Cursor Setup --/ on preOpenStack global tEraseDropShadow, tSetDropShadow -- Set DropShadow Hues put "255,255,255" into tEraseDropShadow put "100,100,100" into tSetDropShadow -- Set Win or Mac SpecialFolders Configuration -- i.e., -- if "Mac" is not in the platform then put "28" into Fld "tSF#_Code" put "Win SpecialFolders Number:" into Fld "LblSF#_Code" else -- Is Mac put "temp" into Fld "tSF#_Code" put "Mac SpecialFolders Code:" into Fld "LblSF#_Code" -- Set Win Type Color set backgroundColor of this card to 231, 238, 241 end if -- Cursor Setup set the cursor to hand set the lockCursor to true end preOpenStack Figure 19 – Card Script
-- Author: Mark Weider, William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: -- Empties The Special Folder Path Table -- Clears The Filename Lists -- Puts The Folder Path Code, If Any, In The Special Folder -- Path Field -- History -- Modifier: William Roger Moseid -- Date: 06/05/2010 -- Added Script Header & Comments -- Added Answer Folder Logic -- Added FusionCharts Folder ID Check -- Added DropShadow Visual Feedback Logic --/ on mouseUp global tEraseDropShadow global tSetDropShadow local tMyPath local tMyFiles -- Set User Visual Feedback File Name List Access Is Started set the dropShadow["color"] of Btn "File Name List" to \ tEraseDropShadow set the dropShadow["color"] of btn "Erase File Name List" to \ tEraseDropSHadow -- Clear Out Any Previous File Names put empty into button "File Name List" -- Set User Visual Feedback File Name List Access Is Started set the highlight of Btn "Get File Names List" to false -- Query User To Select FusionCharts Import Folder Answer Folder "Select Files Folder" put it into tMyPath set Folder to tMyPath -- Make Sure Ihe FusionCharts Folder Really Exists if there is a folder tMyPath then -- Get The List Of Files In The Source Directory put folder_content(tMyPath) into tMyFiles -- Is It A FusionCharts Import Folder? If "FCColors.js" is not in tMyFiles then answer "FusionCharts Import Folder Not Found" else -- Filter System File If Mac if "Mac" is in the platform then -- Clear Mac System File Name filter tmyfiles without ".DS_Store" end if Figure 20a – Get File Names List -- Prepare To Set ToolTip (File Name List) put tMyFiles into button "File Name List" set the ToolTip of Btn "File Name List" to tMyFiles -- Set FusionCharts Selected Folder Path put tMyPath into Fld "theFilePath" wait 1 sec -- Setup User Visual Feedback That FileName List Is -- Obtained set the dropShadow["color"] of btn "File Name List" to \ tSetDropSHadow set the dropShadow["color"] of btn \ "Erase File Name List" to tSetDropSHadow set the highlight of Btn "Get File Names List" to true set the ToolTip of Btn "Erase File Name List" to \ "Click Here To Erase" & cr & "The File Name List" set the toolTip of Btn "Get File Names List" to empty -- Restore Cursor After Accessing FusionCharts Import -- Folder set the cursor to hand set the lockCursor to true end if end if end mouseUpd if end mouseUp Figure 20b – Get File Names List
-- Author: William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: -- Erases File Name List In Btn File Name List ToolTip -- Erases Btn File Name List DropShadow -- Erases Btn Erase File Name List DropShadow -- History -- Modifier: William Roger Moseid -- Date: 06/23/2010 -- Added Script Header & Comments -- Added Tool Tip & Erase DropShadow Logic --/ on mouseUp global tEraseDropShadow -- Show User FileName List, ToolTip, Highlight & DropShadows -- Erased set the highlight of Btn "Get File Names List" to false set the toolTip of btn "File Name List" to empty set the toolTip of btn "Erase File Name List" to empty set the DropShadow["color"] of btn "File Name List" to \ tEraseDropShadow set the DropShadow["color"] of btn "Erase File Name List" to \ tEraseDropShadow end mouseUp /-- Author: Mark Weider, William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: -- Handler: Import FusionCharts File Handler -- Inputs 19 FusionCharts files into This Stack in the -- Custom Property Set: cChartFiles -- URL: tFilePath is the Source Of The FusionCharts Files -- FldSFPath is the Destination Of The FusionCharts Files -- History -- Modifier: William Roger Moseid -- Date: 06/16/2010 -- Added Script Header & Comments -- Added tCount For Amount Of Files Imported -- Added Logic For:: -- Highlight Control for Buttons: -- "Get File Names List", "Import FusionCharts Files", -- ExportFusionCHarts Files -- DropShadow Control & ToolTips for Buttons: -- "File Name List", "# of Files Imported", # "# of Files Imported" --/ on mouseUp global tEraseDropShadow global tSetDropShadow local tChartFolder local tFilePath local tCharts local tCount local tAllCustomProperties -- Alert User File Import Has Started set the highlight of btn "Import FusionCharts Files" to false set the dropShadow["color"] of btn "# of Files Imported" to \ tEraseDropShadow set the dropShadow["color"] of btn "Erase Files Imported #" \ to tEraseDropShadow wait 1 sec -- Clear Out All Files From The Previous Import put the custompropertysets of this stack into \ tAllCustomProperties filter tAllCustomProperties without "cChartFiles" set the custompropertysets of this stack to \ tAllCustomProperties put field "theFilePath" into tChartFoldern Figure 22a – Import FusionCharts Files
-- Get The List Of Files To Import put folder_content(field "theFilePath") into tCharts if "Mac" is in the platform then -- Clear System File Name filter tCharts without ".DS_Store" end if repeat for each line tFileName in tCharts put tChartFolder & "/" & tFileName into tFilePath -- Store Each File & -- Compress Files To Reduce Stack Space set the cChartFiles[tFileName] of this stack to \ compress(url ("binfile:" & tFilePath)) add 1 to tCount end repeat -- Set ToolTip For # Of Files Imported set the ToolTip of Btn "# of Files Imported" to tCount & \ " Files Imported" -- Alert User, File Import Completed Visual Feedback set the highlight of btn "Import FusionCharts Files" to True set the ToolTip of Btn "Erase File Name List" to \ "Click, Erase Files Imported #" set the dropShadow["color"] of btn "# of Files Imported" to \ tSetDropShadow set the dropShadow["color"] of btn "Erase Files Imported #" \ to tSetDropShadow end mouseUp Figure 22b – Import FusionCharts Files -- Author: William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: -- Erases Btn Import FusionCharts Files Highlight -- Erases Btn # of Files Imported ToolTup -- Erases Btn # of Files Imported DropShadow -- Erases Btn Erase Files Imported DropShadow -- History -- Modifier: William Roger Moseid -- Date: 06/23/2010 -- Added Script Header & Comments -- Added Tool Tip & Erase DropShadow Logic --/ on mouseUp global tEraseDropShadow -- Show User: # of Files Imported, ToolTip, Highlight & # DropShadows Erased set the highlight of Btn "Import FusionCharts Files" to false set the ToolTip of Btn "Import FusionCharts Files" to \ "Click Here To Import" & cr & "FusionCharts Files" set the toolTip of Btn "Erase Files Imported #" to empty set the toolTip of Btn "# of Files Imported" to empty set the DropShadow["color"] of btn "# of Files Imported" to \ tEraseDropShadow set the DropShadow["color"] of btn "Erase Files Imported #" \ to tEraseDropShadow end mouseUp Figure 23 – Erase Files Imported # on mouseUp global tSetDropShadow global tEraseDropShadow local tCount local tFilePath local tFolder local tKeys local tSFNumber -- Setup DropShadow Logic (Visual Export File Progress To User) set the DropShadow["color"] of btn "# of Files Exported" to \ tEraseDropShadow set the DropShadow["color"] of btn "Erase Files Exported #" \ to tEraseDropShadow -- Create Destination Folder if Doesn't Exist put specialFolderPath(Fld "tSF#_Code") & kDestinationFolder \ into tFolder if there is no folder tFolder then create folder tFolder end if -- Setup Visual Export File Progress To User set the highlight of btn "Export FusionCharts Files" to false -- Allow The User To See Highlight Change wait for 1 seconds -- Assemble The Export URL For Mac/Win put specialFolderPath(Fld "tSF#_Code") & kDestinationFolder \ into tFilePath -- Display Destination Path put tFilePath into fld "FldSFPath" Figure 24a – Export FusionCharts Files -- Export FusionCharts Files -- Get File List Stored In CustomProperties put the customkeys["cChartFiles"] of this stack into tKeys repeat for each line tLine in tKeys -- Decompress Files During Export -- (Compressed File During Import Into CustomProperties) put decompress(the cChartFiles[tLine] of this stack) into URL \ ("binfile:" & tFilePath & tLine) add 1 to tCount end repeat -- Set ToolTip (# of Files Exported) set the ToolTip of Btn "# of Files Exported" to tCount & \ " Files Exported" -- Visual Feedback To User File Export Completed set the ToolTip of Btn "Erase Files Exported #" to \ "Click Here To Erase & cr & Files Exported #" set the DropShadow["color"] of btn "# of Files Exported" to \ tSetDropShadow set the DropShadow["color"] of btn "Erase Files Exported #" \ to tSetDropShadow set the highlight of btn "Export FusionCharts Files" to true end mouseUp Figure 24b – Export FusionCharts Files -- Author: William Roger Moseid -- Creation Date: 04/03/2010 -- About This Script: of Btn "Export FusionCharts Files" to false set the toolTip of Btn "# of Files Exported" to empty set the DropShadow["color"] of btn "# of Files Exported" to \ tEraseDropShadow set the DropShadow["color"] of btn "Erase Files Exported #" \ to tEraseDropShadow end mouseUp -- Erases Btn Export FusionCharts Files Highlight -- Erases Btn # of Files Exported -- Erases Btn # of Files Exported DropShadow -- Erases Btn Erase File Name List Exported # DropShadow -- History -- Modifier: William Roger Moseid -- Date: 06/23/2010 -- Added Script Header & Comments -- Added Tool Tip & Erase DropShadow Logic --/ on mouseUp global tEraseDropShadow Set The ToolTip For The Get File Names List Button set the ToolTip of Btn "Get File Names List" to \ "Click Here To Erase" & cr & "The Files Exported #" set the toolTip of Btn "# of Files Exported" to empty set the DropShadow["color"] of btn "# of Files Exported" to \ tEraseDropShadow set the DropShadow["color"] of btn "Erase Files Exported #" \ to tEraseDropShadow end mouseUp Figure 25 – Erase Files Exported #
|
|