3 Replies Latest reply on Feb 20, 2011 10:41 PM by Harbs.

    Datagrid Image Renderer Broken in CS SDK but not Flex project

    StevenErat Level 1

      Within a Photoshop Extension, I have a DataGrid which has an inline custom image renderer whose dataprovider is an ArrayCollection called "photos"  representing a list of photos and some metadata properties.  One of the properties "fileName" is concatenated with a path to a thumbnail image such as source="{'LR_AUTO/imported/thumbs/' + data.fileName}".

       

      The dataprovider is bound to a LCDS DataService. When the extension is first launched, the dataservice initializes the dataprovider with the existing values for the "photos" arraycollection.  The thumbnail images are correctly shown.

       

      However, when the DataService receives a new row and updates the photos dataprovider, the datagrid's new row shows a broken image for the thumbnail even though the path is correct.  I have dumped the photos dataprovider and verified that all information is correct.  When I close Photoshop and relaunch it from Flash Builder, once again LCDS initializes the photos ArrayCollection and THEN the thumbnail that previously showed as broken show up correctly.

       

      I have a ColdFusion Directory Watcher Gateway that watches a directory where Lightroom auto-imports images from a tethered capture session.  When the camera sends Lightroom a new image, the new image is processed by Lightroom and moved to a target directory, and since ColdFusion's Directory Watcher is watching that targeted directory, ColdFusion will create a thumbnail image in a subfolder and notifiy LCDS that of the new image and related metadata.

       

      *** This is the interesting part *** When Lightroom places new images in the target directory, this is propogated to the Photoshop Extension's datagrid, and the new row shows up as described earlier, showing a broken image for the thumbnail.  BUT, instead of Lightroom, if I manually copy images to the folder where ColdFusion is watching, then exact same code path is exectuted and in the Photoshop Datagrid the new row appears and THE THUMBNAIL IMAGE shows up correctly.

       

      The difference seems to be only in how the images are put in the original target location.  The problem is when Lightroom puts them there, but it works when I put them there as a user.

       

      *** More Interesting Info *** I have the Flex code for the Photoshop Extension duplicated in a standalone, non-CSSDK project using Flex 3.4 which I launch in a browser.  I have mirrored the code in the Photoshop extension, but in this manner, the problem does not exist.  With plain Flex 3.4 in a browser, whenever LCDS notifies the datagrid of a new photo record, the datagrid's new row ALWAYS shows the thumbnail correctly.

       

      A primary difference in how the thumbnail image is rendered is that in a browser, the Flex 3.4 project accesses the image assets over the network, however, in the Photoshop Extension, the image asset WITH THE SAME RELATIVE PATH is accessed over the local file system.

      source="{'LR_AUTO/imported/thumbs/' + data.fileName}"

       

      So in the case of the browser, this path is a relative URL and the image is retrieved over HTTP, however, in the PS Extension, the same path represents a file system path relative to the project folder.

       

      Unfortunately, because the Flash Player (including APE) cannot access BOTH the network and the local filesystem, so I cannot change the Extension to use network access.

       

      ** The important part to remember is that when I stop the Flash Builder debug session and close Photoshop, then relaunch the debug with Photoshop, then all the images show up correctly in the Extension.

       

      Your advice is appreciated.


      Thank you!

      Steve

       

       

       

      ====================================================

      Environment

      ====================================================

      Photoshop CS5 Extended 12.01 x32

      Flash Builder 4

      CS SDK 1.02

      Extension Builder SDK 3.4

      MacBook Pro / OS X 10.5 / Intel Core 2 Duo 2.66 GHz / Procs: 1 / Cores: 2 / Memory: 8 GB

      App configured for Photoshop CS5 and Photoshop CS5 Extended

       

       

      ====================================================

      NewsAgencyPhotoshop.mxml

      ====================================================

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="com.stevenerat.news.*"
                      horizontalScrollPolicy="off" verticalScrollPolicy="off" verticalGap="0"
                      layout="vertical" horizontalAlign="left"  backgroundColor="#353535"
                      historyManagementEnabled="false"
                      creationComplete="init();">
         
      ....
         
          <mx:Script>

      .....
                  public function handlePhotoClick(data:Object):void {
                      this.PreviewImageWindow = PreviewImage(PopUpManager.createPopUp(this,PreviewImage,true));
                      var filePath:String = data.dirPath + data.fileName;
                      PreviewImageWindow.addEventListener("imageOpenEvent",imageOpenListener);
                      PreviewImageWindow.addEventListener("imageCloseEvent",imageCloseListener);
                      PreviewImageWindow.addEventListener("imageSavedEvent",imageSaveListener);
                      PreviewImageWindow.setFileName(data.fileName);
                      PreviewImageWindow.setFilePath(filePath);
                      PreviewImageWindow.y = 0;
                      PreviewImageWindow.x = 0;
                  }    

              ]]>
          </mx:Script>
         
          <mx:ArrayCollection id="photos"/>
         
          <NewsPhoto/>
         
          <mx:DataService id="ds" destination="NewsAgencyPhotos" autoSyncEnabled="true" autoCommit="true" conflict="conflictHandler(event)"/>
         
          <mx:Label text="News Agency Photos" fontSize="20" paddingBottom="30"/>
         
          <mx:Label text="Available Images" fontSize="15"/>
          <mx:DataGrid id="photoIPTC" dataProvider="{photos}" editable="true" width="220" rowCount="5" rowHeight="75" wordWrap="true">
              <mx:columns>
                  <mx:DataGridColumn headerText="id" dataField="fileName" width="40" editable="false" sortDescending="true"/>
                  <mx:DataGridColumn dataField="psLock" width="65" headerText="Status" editable="false" editorDataField="value">
                      <mx:itemEditor>
                          <mx:Component>
                              <mx:ComboBox editable="false">
                                  <mx:dataProvider>
                                      <mx:String>New</mx:String>
                                      <mx:String>Open</mx:String>
                                      <mx:String>Edited</mx:String>
                                  </mx:dataProvider>
                              </mx:ComboBox>
                          </mx:Component>
                      </mx:itemEditor>
                  </mx:DataGridColumn>
                  <mx:DataGridColumn headerText="Photo" dataField="fileName" width="80" editable="false">
                      <mx:itemRenderer>
                          <mx:Component>
                              <mx:HBox horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                  <mx:Image click="outerDocument.handlePhotoClick(data);" source="{'LR_AUTO/imported/thumbs/' + data.fileName}" width="75" height="75"/>
                              </mx:HBox>
                          </mx:Component>
                      </mx:itemRenderer>
                  </mx:DataGridColumn>
              </mx:columns>
          </mx:DataGrid>
      </mx:Application>

       

       

       

       

       

      ====================================================

      A DUMP OF THE DATAPROVIDER

      in this case, one array item existed when launched, then a second was added

      while running.  The first has its thumbnail show, the second item has broken image

      ====================================================

       

      ------------------DUMP----------------------------
      (mx.collections::ArrayCollection)#0
        filterFunction = (null)
        length = 2
        list = (mx.data::DataList)#1
          fillParameters = (Array)#2
          length = 2
          localItems = (Array)#3
            [0] (com.stevenerat.news::NewsPhoto)#4
              aperture = "F10"
              cameraLens = "EF24-70mm f/2.8L USM"
              cameraModel = "Canon EOS 7D"
              city = ""
              copyrightNotice = "¬© Steven Erat 2011"
              country = ""
              creator = "Steven Erat"
              description = ""
              dirPath = "/Users/stevenerat/LR_AUTO/imported/"
              fileName = "ERAT_STEVEN_20110122_162.jpg"
              focalLen = "42.0 mm"
              headline = ""
              id = 1
              iso = "100"
              keywords = "Alt, Dramatic, Fashion, Girl, Glamorous, Glamour, Inked, Model, Portrait, SOPHA"
              psLock = "New"
              shutterSpeed = "1/128 sec"
              state = ""
            [1] (com.stevenerat.news::NewsPhoto)#5
              aperture = "F10"
              cameraLens = "EF24-70mm f/2.8L USM"
              cameraModel = "Canon EOS 7D"
              city = ""
              copyrightNotice = "¬© Steven Erat 2011"
              country = ""
              creator = "Steven Erat"
              description = ""
              dirPath = "/Users/stevenerat/LR_AUTO/imported/"
              fileName = "ERAT_STEVEN_20110122_163.jpg"
              focalLen = "42.0 mm"
              headline = ""
              id = 2
              iso = "100"
              keywords = "Alt, Dramatic, Fashion, Girl, Glamorous, Glamour, Inked, Model, Portrait, SOPHA"
              psLock = "New"
              shutterSpeed = "1/128 sec"
              state = ""
          uid = "8BAC025E-60D1-11F1-3654-44BDB0D218CE"
          view = (mx.collections::ArrayCollection)#6
            filterFunction = (null)
            length = 2
            list = (mx.data::DataList)#1
            sort = (null)
            source = (null)
        sort = (null)
        source = (null)
      ------------------END_DUMP------------------------

        • 1. Re: Datagrid Image Renderer Broken in CS SDK but not Flex project
          StevenErat Level 1

          I expected that if my extension uses the local filesystem AND the network that I would get a Security Sandbox Exception as I recently described in this thread:

          http://forums.adobe.com/thread/791918?tstart=0

           

          However, I just tried changing my datagrid image renderer to access the thumbnail via HTTP and the thumbnail issue after Lightroom export does not happen.

           

                      <mx:DataGridColumn headerText="Photo" dataField="fileName" width="80" editable="false">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:HBox horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                      <mx:Image click="outerDocument.handlePhotoClick(data);" source="{'http://localhost:8500/LR_AUTO/imported/thumbs/' + data.fileName}" width="75" height="75"/>
                                  </mx:HBox>
                              </mx:Component>
                          </mx:itemRenderer>
                      </mx:DataGridColumn>

           

          Furthermore, I can also open the image via the Photoshop DOM, and it does open correctly.  It seems that I do have a solution now, although I'm not certain as to why I'm not getting a Security Sandbox Exception as I described in the other post.


          Thanks for reading.

          • 2. Re: Datagrid Image Renderer Broken in CS SDK but not Flex project
            StevenErat Level 1

            It just occurred to me that in my thread regarding the Security Sandbox Exception, I had been attempting to use network access for an Image source in one view, and local disk access for Image source in another.

             

            My current workaround for the thumbnail issue described at first above is to use network access for the image source, and then later in the Photoshop DOM I can reference the local file system to open an image document.  It had been my expectation that this would not work after having used network access.

             

            Its my speculation that because CSAW is an ActionScript wrapper to native code in Photoshop, that the native code is accessing the local file system, not the APE player, therefore circumventing the mixed mode image access and not violating the APE Sandbox Security model.

             

            Its all good.

            • 3. Re: Datagrid Image Renderer Broken in CS SDK but not Flex project
              Harbs. Level 6

              I don't know what was happening with your sandbox error, but CS SDK extensions do not have Flash Player security restrictions. They use the same policies as AIR applications which can access both network and the local file system...

               

              Harbs