/************************************************************************** * * @@@BUILDINFO@@@ 24scripts-2.jsx 2.0.1.67 15-May-2007 * Copyright 2006-2007 Adobe Systems Incorporated * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of * Adobe Systems Incorporated and its suppliers, if any. The intellectual * and technical concepts contained herein are proprietary to Adobe Systems * Incorporated and its suppliers and may be covered by U.S. and Foreign * Patents,patents in process,and are protected by trade secret or copyright * law. Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained from * Adobe Systems Incorporated. **************************************************************************/ // Code to add to the Scripts pane // The output field of the scripts pane is a list box. The array scriptIDs // takes a list of all script IDs. This list is used during Document.onSave() // to determine if a document belongs to a target app and whether that app // should receive a PutScript message. // Get the script IDs and populate the Scripts pane. Each line contains // two words. The first, is the display name, while the second word is the // script ID. The script ID must be a path name if it starts with '/' or '~'. If // it starts with anything else but a '(' (which is reserved for new scripts), // it is app specific, and the app will have to supply the script on request. // Application-supplied script IDs should be system unique. // The "info" property is an object with script IDs as property names. Each // object has the properties displayName, scriptID, status and readOnly. If a script // is not executable, the status is "noexec". The object is also attached to // the list item. scripts = null; app.createScripts = function( where, suppresPrefs, remote ) { // // create window // scripts = new Window( "dockpalette { \ text:'$$$/ESToolkit/Panes/Scripts/Title=Scripts', \ properties: \ { \ defaultVisibility : true, \ flyoutmenu:true, \ name:'scripts', \ icon : '#PScripts_N', \ rollover : '#PScripts_R', \ " + where + " \ }, \ preferredSize: [100, 100], \ margins : 2, \ spacing : 2, \ orientation : 'column', \ \ targetGroup : Group \ { \ alignment : ['fill','top'], \ orientation: 'row', \ margins:0, \ \ targets: DropDownList \ { \ preferredSize: [40, 20], \ alignment : ['fill','fill'] \ helpTip : '$$$/ESToolkit/Panes/Scripts/htTargets=Select a target application.' \ }, \ engines: DropDownList \ { \ preferredSize: [40, 20], \ alignment : ['fill','fill'] \ helpTip : '$$$/ESToolkit/Panes/Scripts/htEngine=Select an engine of the selected target application.' \ } \ }, \ output: TreeView \ { \ preferredSize: [10, 20], \ alignment: ['fill', 'fill' ] \ } \ infogrp : Group \ { \ orientation : 'row', \ margins : 0, \ spacing : 0, \ alignment : ['fill','bottom'], \ pathField: EditText \ { \ properties : { readonly: true }, \ alignment : ['fill','bottom'], \ characters : 40 \ }, \ sizeBoxSpacer : Group \ { \ alignment : ['right','bottom'], \ preferredSize : [14,1] \ } \ } \ }"); scripts.id = "scripts"; scripts.menuText = localize ("$$$/ESToolkit/Menu/Window/Scripts/Title=&Scripts"); /////////////////////////////////////////////////////////////////////////////// // // shortcuts // scripts.targetDDL = scripts.targetGroup.targets; scripts.engineDDL = scripts.targetGroup.engines; scripts.pathField = scripts.infogrp.pathField; scripts.currentFavorite = PrefUtils.getValue ('prefs.scripts.favorite', 'String'); /////////////////////////////////////////////////////////////////////////////// // // flyout menu // var item = new MenuElement( 'command', '$$$/ESToolkit/Panes/Scripts/Flyout/Refresh=Refresh', "at the end of scripts/flyout", "scripts/flyout/refresh" ); item.scripts = scripts; item.onSelect = function() { scripts.targetGroup.fillScripts(); } item = new MenuElement( 'command', '$$$/ESToolkit/Panes/Scripts/Flyout/AddFav=Add Favorite...', "---at the end of scripts/flyout", "scripts/flyout/addfav" ); item.onSelect = function() { var newItem = scripts.favorites.dialog(); if( newItem ) { newItem = scripts.favorites.add( newItem.name, newItem.path, false, newItem.filter, newItem.recursive ); if( scripts.favorites ) { // // if the "Favorites" target is selected then // force updating the engines popup // var sel = scripts.targetDDL.selection; scripts.targetDDL.selection = null; scripts.targetDDL.selection = sel; // // after that select the new added favorite // scripts.engineDDL.selection = null; for( var i=0; i 0 ) scripts.targetDDL.items[0].favorites = favorites; if( scripts.targetDDL.selection && scripts.targetDDL.selection == scripts.targetDDL.items[0] ) { var oldSel = scripts.engineDDL.selection; scripts.engineDDL.removeAll(); for( var i=0; i 0 ) ? ( '-' + BridgeTalk.appLocale ) : '' ); var targets = targetMgr.getTargets(); for( var i=0; i 0 && engine.length > 0 ) { this.parent.requestingScripts = true; app.scheduleTask( 'scripts.getScriptsFor( "' + target + '","' + engine + '");scripts.requestingScripts=false;scripts.setEnabled(true);', 1, false ); } else this.window.setEnabled( true ); } } else this.window.setEnabled( true ); } scripts.targetGroup.validateFavorite = function( favorite ) { var ret = true; this.window.setStatusText(); if( favorite && !Folder( favorite.path ).exists ) { ret = false; addDelayedTask( this.window.erase ); this.window.setStatusText( localize( '$$$/CT/ExtendScript/Errors/Err48=File or folder does not exist' ), true ); } return ret; } scripts.setStatusText = function( text, error ) { var winGfx = this.pathField.graphics; if( error ) { var redColorPen = winGfx.newPen (winGfx.PenType.SOLID_COLOR, [1, 0, 0], 1); winGfx.foregroundColor = redColorPen; } else winGfx.foregroundColor = null; if( !text ) text = ' '; this.pathField.text = text; } //----------------------------------------------------------------------------- // // scripts.getScriptsFor(...) // // Purpose: get scripts for target&engine // //----------------------------------------------------------------------------- scripts.getScriptsFor = function( targetName, engineName ) { this.window.blockTargetGroup++; this.awaitScriptList = true; this.getScriptListFor( targetName, engineName, this ); } //----------------------------------------------------------------------------- // // scripts.getScriptListFor(...) // // Purpose: [static] Request list of script for target&engine, notify client if received // //----------------------------------------------------------------------------- scripts.getScriptListFor = function( targetName, engineName, clientObj ) { var bt = BridgeTalk.create( targetName, "GetScripts" ); bt.headers.Engine = engineName; bt.clientObj = clientObj; bt.onOwnError = function (bt) { if( this.clientObj ) { var target = this.target.replace( '#estk', '' ); this.clientObj.onNotify( 'getScriptListFor', null, target, this.engineName ); } } bt.onOwnResult = function(bt) { var target = this.target.replace( '#estk', '' ); // clear all lists var infoArray = []; var reply = bt.splitBody(); for( var i=0; i 0 ) this.engines.selection = 0; this.window.blockTargetGroup--; } this.fillScripts(); this.targets.oldSelection = this.targets.selection; } else { this.window.setEnabled( true ); if( !this.targets.oldSelection ) this.targets.oldSelection = 0; this.targets.selection = this.targets.oldSelection; } } } scripts.setCurrentFavorite = function() { var items = this.engineDDL.items; // Preset to 0 (Default). This will then take care of the favorite not being found. // In that case, it always reverts to Default (also covers localization) var sel = 0; for (var i = 0; i < items.length; i++) { if (items[i].text == this.currentFavorite) { sel = i; break; } } this.engineDDL.selection = sel; } /////////////////////////////////////////////////////////////////////////////// // // initialize palette // // // register for broadcasts // globalBroadcaster.registerClient( scripts ); targetMgr.registerClient( scripts ); Debugger.registerClient( scripts ); // // first fill favorites // if( !scripts.favorites ) scripts.favorites = favorites; scripts.requestingScripts = false; scripts.blockTargetGroup = 0; scripts.info = {}; scripts.show(); panes.push(scripts); scripts.initialized = true; }