Skip navigation
Currently Being Moderated

SnpCreateTabbedPaletteScriptUI not working. Help me.

Apr 23, 2012 10:00 AM

Tags: #tabbed #snpcreatetabbedpalettescriptui #pallete

I want to have a new pallete window on my bridge and the SnpCreateTabbedPaletteScriptUI script from SDK samples helped.

 

But only when I try it from running from Extendedscript Toolkit CS5.

 

When I put it on running from Bridge startup scripts, it doesn't work anymore.

I guess it has to do with the windows7 itself??? But I don't know.

I'm running as administrator.

 

 

 

The SnpCreateTabbedPaletteScriptUI code:

////////////////////////////////////////////////////////////////////////////
// ADOBE SYSTEMS INCORPORATED
// Copyright 2008 Adobe Systems Incorporated
// All Rights Reserved
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the
// terms of the Adobe license agreement accompanying it.  If you have received this file from a
// source other than Adobe, then your use, modification, or distribution of it requires the prior
// written permission of Adobe.
/////////////////////////////////////////////////////////////////////////////
 
/** 
 @fileoverview Shows how to create a TabbedPalette in Bridge with ScriptUI components.
 @class Shows how to create a TabbedPalette in Bridge with ScriptUI components.

 <h4>Usage</h4>

<ol>
<li>    Run the snippet in the ExtendScript Toolkit (see Readme.txt), with Bridge CS5 as the target.
<li>You should find that a tabbed palette has been added to the Bridge browser window.
</ol>

 <h4>Description</h4>

 <p>Adds a script-defined tabbed palette to the Bridge browser window.  

 <p>The palette is of the "script" type, and contains ScriptUI components,
 text fields and buttons. The buttons have event handlers that 
 change the values in the text fields.

 <p>The new palette appears in the default upper-left position in the browser. It can be 
  dragged to other positions. <br />
  
 @see SnpCreateWebTabbedPalette

 @constructor Constructor.
 */ 
function SnpCreateTabbedPaletteScriptUI()
{
    /**
     The context in which this snippet can run.
     @type String
    */
    this.requiredContext = "\tExecute against Bridge main engine.\nBridge must not be running";
    $.level = 1; // Debugging level
    this.paletteRefs = null;
}
 
 
/**
 Functional part of this snippet.  

 Creates the TabbedPalette object, defining the content with 
 ScriptUI components, and adds the palette to all open Bridge browser windows.
    @return True if the snippet ran as expected, false otherwise.  
    @type Boolean
*/
SnpCreateTabbedPaletteScriptUI.prototype.run = function()
{
    
    var retval = true;
    if(!this.canRun())
    {
        retval = false;    
        return retval;
    }
    this.paletteRefs = new Array();
    var wrapper = this;
    // Create and add the TabbedPalette object and its contents. 
    function addScriptPalette(doc)
    {
        // Create the TabbedPalette object, of type "script"
        var scriptPalette = new TabbedPalette( doc, "SnpCreateTabbedPaletteScriptUI", "SnpSUIPalette", "script" );
        wrapper.paletteRefs.push(scriptPalette);    
        // Create a ScriptUI panel to be displayed as the tab contents.
        var tbPanel = scriptPalette.content.add('panel', [25,15,255,130], 'The Panel');
 
        // Add the UI components to the ScriptUI panel
        tbPanel.txtFieldLbl = tbPanel.add('statictext', [15,15,105,35], 'Times Clicked:');
        tbPanel.txtField = tbPanel.add('edittext', [115,15,215,35], '0');
        tbPanel.addBtn = tbPanel.add('button', [15,65,105,85], 'Add');
        tbPanel.subBtn = tbPanel.add('button', [120, 65, 210, 85], "Sub");
 
        // Define event listeners that implement behavior for the UI components
        tbPanel.addBtn.onClick = function()
        {
            var txt = tbPanel.txtField;
            txt.text = parseInt(txt.text) + 1;
        }
        
        tbPanel.subBtn.onClick = function()
        {
            var txt = tbPanel.txtField;
            txt.text = parseInt(txt.text) - 1;
        }
    }
 
    // Add the palette to all open Bridge browser windows
    for(var i = 0;i < app.documents.length;i++)
    {
        addScriptPalette(app.documents[i]);
    }
 
 
    return retval;
 
}
 
/**
  Determines whether snippet can be run given current context.  The snippet 
  fails if these preconditions are not met:
  <ul>
  <li> Must be running in Bridge
  </ul>

  @return True is this snippet can run, false otherwise
  @type boolean
*/
SnpCreateTabbedPaletteScriptUI.prototype.canRun = function()
{    
    
    // Must run in Bridge 
    if(BridgeTalk.appName == "bridge") 
    {
        return true;        
    }
    
    // Fail if these preconditions are not met.  
    // Bridge must be running,
    $.writeln("ERROR:: Cannot run SnpCreateTabbedPaletteScriptUI");
    $.writeln(this.requiredContext);
    return false;
    
}
 
/**
 "main program": construct an anonymous instance and run it
  as long as we are not unit-testing this snippet.
*/
if(typeof(SnpCreateTabbedPaletteScriptUI_unitTest) == "undefined") {
    new SnpCreateTabbedPaletteScriptUI().run();
}
 
Replies
  • Currently Being Moderated
    Apr 23, 2012 12:29 PM   in reply to Pedro Marques

    The problem is that it is only written to be run from ExtendScript Toolkit.

    You are referencing app.document this has not been created so the script will fail, you would need to use an eventHandler to check if the document has loaded and then it might need a delay.

    See: Adobe Bridge CS5 JavaScript Reference.pdf Page 44

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 3:51 PM   in reply to Pedro Marques

    Yes you could call the script from a menu item..

    Change...

     

     

    if(typeof(SnpCreateTabbedPaletteScriptUI_unitTest) == "undefined") {
        new SnpCreateTabbedPaletteScriptUI().run();
        }
    
    

     

    To:-

     

     

    var newCommand = new MenuElement( "command", "SNP Test", "at the end of tools" , "xxxx" );
    newCommand.onSelect = function () { 
    if(typeof(SnpCreateTabbedPaletteScriptUI_unitTest) == "undefined") {
        new SnpCreateTabbedPaletteScriptUI().run();
        }
    }
    
    

     

    You can then start it from the tools menu.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 12:41 PM   in reply to Pedro Marques

    Where is this file saved at?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 12:59 PM   in reply to Gonterman1201

    The script is in the sdksamples folder of the Bridge SDK that can be downloaded from..

    http://www.adobe.com/devnet/bridge.html

     

    To install the script in Bridge.

    Start Bridge

    Edit - Preferences -Startup Scripts

    At the bottom click the "Reveal Button" this will open the folder where the script should be placed.

    Close and restart Bridge.

    Accept the new script.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 1:14 PM   in reply to Paul Riggott

    I should see SNP Test in tools when I open the program right? I don't think this is working. I am in CS6 on a mac.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 1:20 PM   in reply to Gonterman1201

    If you have made the above changes, saved it in the correct folder and accepted the script, then yes you should.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 1:25 PM   in reply to Paul Riggott

    Screen shot 2012-12-19 at 3.30.07 PM.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 1:31 PM   in reply to Gonterman1201

    The script is not showing, this could be because you have not closed and re-started Bridge or there are errors in the script, or it has the wrong extension.

     

    If you click "Reveal My Startup Scripts" it should open the folder and the script should be there.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 31, 2012 8:03 AM   in reply to Paul Riggott

    Ok I tried it in CS5 and it worked just as you said it would. However it did not work in CS6. That is were I ran into problems. So it maybe that it is erroring in CS6.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 15, 2013 10:37 AM   in reply to Paul Riggott

    If I delete the tab and then try to run the script again from the tools menu. I get an error on this line.

            var scriptPalette = new TabbedPalette( doc, "SnpCreateTabbedPaletteScriptUI", "SnpSUIPalette", "script" );

    Its saying that it is a bad argument list. I am wondering when the tab is deleted what has changed?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 15, 2013 10:52 AM   in reply to Gonterman1201

    Because it has not been removed from Bridge, it has just been closed, the panel can be shown again by going to :-

    Window - SnpCreateTabbedPaletteScriptUI Panel and selecting it.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 15, 2013 10:57 AM   in reply to Paul Riggott

    Thanks Paul!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points