Below is an example demonstrating how you can copy the interface of another channel (i.e., General Release, Public Build, Publishing Build, Private Build, Dev Build) to the build executing the script.
// Define an anonymous function; // serves as our main loop, // limits the scope of variables (function(){ // Define "globals" for identifying the script var g_sScript = getScriptFileName(); var g_oFileInfo = new DzFileInfo( g_sScript ); /*********************************************************************/ // String : A function for prompting the user to pick from a list function promptUserChoice( sLabel, aChoices ) { // Create a basic dialog var wDlg = new DzBasicDialog(); // Get the wrapped widget for the dialog var oDlgWgt = wDlg.getWidget(); // Get the name of this file var sName = g_oFileInfo.baseName(); // Set the title of the dialog wDlg.caption = sName.replace( /_/g, " " ); // Strip the space for a settings key var sKey = String("%1Dlg").arg( sName.replace( / /g, "" ) ); // Set an [unique] object name on the wrapped dialog widget; // this is used for recording position and size separately // from all other [uniquely named] DzBasicDialog instances oDlgWgt.objectName = sKey; // Create a label var wLabel = new DzLabel( wDlg ); // Set its text wLabel.text = sLabel; // Add the widget to the dialog wDlg.addWidget( wLabel ); // Create a combobox var wChoicesCmb = new DzComboBox( wDlg ); // Populate the choices wChoicesCmb.addItems( aChoices ); // Add the widget to the dialog wDlg.addWidget( wChoicesCmb ); // Get the minimum size for the dialog var sizeHint = oDlgWgt.minimumSizeHint; // Set the fixed size to the minimum size wDlg.setFixedSize( sizeHint.width, sizeHint.height ); // If the user cancels the dialog if( !wDlg.exec() ){ // We are done... return ""; } // return the user's choice return wChoicesCmb.currentText; }; /*********************************************************************/ // void : A function to load an interface file; if it is in the list function loadInterfaceFile( aFiles, sPath, sFilename ) { // Get the index of the filename in the list var nIdx = aFiles.indexOf( sFilename ); // If the filename is not in the list if( nIdx < 0 ){ // We are done. return; } // Construct the path to the file var sFilePath = [ sPath, sFilename ].join("/"); // Get the action manager var oActionMgr = MainWindow.getActionMgr(); // Load the file oActionMgr.loadInterfaceFile( sFilePath ); }; /*********************************************************************/ // void : A function to load an interface file; if it is in the list function loadLayoutFile( aFiles, sPath, sFilename ) { // Get the index of the filename in the list var nIdx = aFiles.indexOf( sFilename ); // If the filename is not in the list if( nIdx < 0 ){ // We are done. return; } // Construct the path to the file var sFilePath = [ sPath, sFilename ].join("/"); // Get the pane manager var oPaneMgr = MainWindow.getPaneMgr(); // Load the file oPaneMgr.restoreLayout( sFilePath, true ); }; /*********************************************************************/ // Get the application data directory var oAppDataDir = new DzDir( App.getAppDataPath() ); // Get the words in the application name var aAppName = App.appName.split(" "); // Get the numbers in the version var aVersion = App.versionString.split("."); // Construct the name of the (general release) application data folder var sFolderName = String("%1%2").arg( aAppName[ aAppName.length - 1 ] ).arg( aVersion[ 0 ] ); // Initialize to the application data directory var oCopyDataDir = new DzDir( oAppDataDir.path() ); // Go up a directory oCopyDataDir.cdUp(); // Get a list of the directory names that start with the prefix we want var aAppDataDirs = oCopyDataDir.entryList( String("%1*").arg( sFolderName ), DzDir.Dirs ); // Get the index of the current directory in the list var nSelf = aAppDataDirs.indexOf( oAppDataDir.dirName() ); // Remove the current directory from the list aAppDataDirs.splice( nSelf, 1 ); // Prompt the user for which channel to copy from var sFolder = promptUserChoice( qsTr("Copy Actions and Layout from:"), aAppDataDirs ); // If the user cancelled if( sFolder.isEmpty() ){ // We are done... return; } // Change the directory to the one chosen by the user oCopyDataDir.cd( sFolder ); // Define file names var sCustomActions = "customactions.dsx"; var sActionsFile = "actions.dsx"; var sMenusFile = "menus.dsx"; var sToolbarsFile = "toolbars.dsx"; var sLayoutFile = "layout.dsx"; // Define a list of filters var aFilters = [ sCustomActions, sActionsFile, sMenusFile, sToolbarsFile, sLayoutFile ]; // Get the list of files that match the filters var aFiles = oCopyDataDir.entryList( aFilters, DzDir.Files ); // Get the path of the directory being copied from var sPath = oCopyDataDir.path(); // Load interface files in the proper order; actions, menus, toolbars loadInterfaceFile( aFiles, sPath, sCustomActions ); loadInterfaceFile( aFiles, sPath, sActionsFile ); loadInterfaceFile( aFiles, sPath, sMenusFile ); loadInterfaceFile( aFiles, sPath, sToolbarsFile ); // Load the layout loadLayoutFile( aFiles, sPath, sLayoutFile ); // Finalize the function and invoke })();