5 Replies Latest reply on Jul 13, 2010 1:30 PM by evolphin

    Generic way to get Document object for CS products

    evolphin Level 1

      Just going through the CS SDK documentation it appears, for each product - Photoshop, InDesign, Illustrator, InCopy - one has to

      get hold of a Document object that is tied to each product. In other words com.adobe.illustrator.Document for Illustrator and so on.

       

      It would be a life saver to have a base Document class that provides common properties across al CS products, ad have product

      specific Document class inherit from the common Document base class. That way developers could write more generic code

      that doesn't need to couple with the specific application so tightly. Is there such a class already ? Didn't find it in the CS SDK docs

      or the sdk itself.

       

      Also beyond the 4 products (Photoshop, InDesign, Illustrator, InCopy) how does one get hold of Document object for Flash Pro etc.

      Are there plans to add ActionScript support beyond the 4 products ?  There are ~ 15 products in CS and it seems we need to now use

      CS SDK and the old C++ sdk for the unsupported products in CS SDK, make sit hard to write apps that are cross platform and

      work seemlessly with all CS products.

       

       

      --

      Oliver A @ Evolphin

      http://www.evolphin.com

        • 1. Re: Generic way to get Document object for CS products
          Harbs. Level 6

          The CSAW libraries (for InDesign Illustrator, Photoshop, and Bridge), are based on the scripting models of each product. I would imagine that it would be a rather difficult job to create ActionScript classes that would work in the differing scripting models.

           

          If you need generic methods, calling ExtendScript functions might be an easier workaround.

           

          As for other products, you can call scripting function for the ones which have scripting support.

           

          Harbs

          • 2. Re: Generic way to get Document object for CS products
            evolphin Level 1

            In Computer Science we say all problems can be solved by one more level of indirection . While each product has

            different scripting models, why can't a generic base class bridge them via a delegation pattern that invokes the product specific document method

            for common properties like document path, document folder etc. Product specific methods can be implemented as they are now I am just

            talking about common methods.

             

            For e.g.

             

               com.adobe.product.Document.getDocumentPath() ----> via derived clas soverride will call photoshop.Document.getDocumentPath()

             

            If generic base class is hard to implement how about a common interface to shield us from product specific details when not needed ?

             

            What we need is a generic interface or abstract class that provides gettters for common properties. This is OOPS 101, am I missing something

            here ?

             

            Again I am not saying this will work fo rall properties just for a few common properties would be a good start..

             

            ---


            Oliver @ A

            http://www.evolphin.com

            • 3. Re: Generic way to get Document object for CS products
              Harbs. Level 6

              I don't think you are missing something, but I'm pretty sure it'll be a lot of work to implement. We do have a pretty easy workaround (i.e. using ExtendScript when the ActionScript classes don't offer the level of functionality you might want).

               

              It all boils down to priorities. Personally, I would much prefer for the engineers to work on all the bugs as well as add the long list of additional functionality, rather than work on CSAW generality.

               

              If you want this badly enough, you could probably create your own wrapper classes...

               

              Harbs

              • 4. Re: Generic way to get Document object for CS products
                James Boag Adobe Employee

                You can also call the ActionScript libraries untyped, which will let you use common functions in a way which will work across applications. Though you'd need to do a little application specific work to get the app object in the first place, from there you can type it as an Object and then call anything without compiler errors (though you'll need to be careful to avoid runtime errors for missing functions).

                 

                The reason why we haven't created common DOM classes is because, sadly, very little is genuinely identical. For example, while all of the products have a Document.open(...) API, the parameters passed in vary between all of them - and so the signature of this function is different in each. As in ActionScript (and ECMAScript generally) you can only have one function of a specific name, we cannot make Document.open(...) a generic API that would work in all products without effectively removing functionality.

                 

                We could add (for example) Document.genericOpen(...) but this feels like it would simply add confusion rather than help matters.

                 

                Best,

                 

                James

                • 5. Re: Generic way to get Document object for CS products
                  evolphin Level 1

                  I do realize that parameters can be dfferent for setters or mutators so it doesn't make sense to

                  abstract them to a common interface.

                   

                  That said, Adobe should consider a lot of us are writing workflow related tools for Adobe Suite and

                  just the basic getters on current open document -

                   

                  document directory

                  document title

                  document file path

                  document save

                  document lock

                   

                  Will go a long way in writing a generic plugin. So again by all means do not abstract out every method

                  just the basic core methods. Even an open() with a file name would suffice in the interface. More specific

                  open methods can stay with their product specific class.It would not add confusion as a factory method

                  could return the abstract class instance but underneath its really the derived class instance that can

                  be narrowed to if I want more specific function to invoke.

                   

                  This will allow developers to use generic methods where they can. For the apps we are writing it would be

                  a life saver. Something to consider for future CS SDK...