You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@royale.apache.org by Serkan Taş <se...@likyateknoloji.com> on 2019/11/25 20:54:55 UTC

TextConverter method call

Hi,

TextConverter has a method named /setFormatsToDefault(//)/ and called 
while the application is loaded  - I guess automatically because I could 
not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

         // register standard importers and exporters
         setFormatsToDefault();

         /** @private */
         static public function setFormatsToDefault():void    // No PMD
         {
             _descriptors = [];
             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
PlainTextExporter, "air:text");
         }


Flex :

         // register standard importers and exporters
         setFormatsToDefault();

         /** @private */
         static tlf_internal function setFormatsToDefault():void    // 
No PMD
         {
             _descriptors = [];
             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
PlainTextExporter, "air:text");
         }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan

Re: TextConverter method call

Posted by se...@likyateknoloji.com.
Alıntı Serkan Taş <se...@likyateknoloji.com>:

> Hi Alex,
>
> TextConverter :  
> https://drive.google.com/open?id=1_6-rBQqTISbeoLvS2-yV8bSFkvS_ApxZ
>
> It is working without any excepiton, but still can not show the text  
> in TextArea.
>
> Going to try to find-out why...
>
> Thank,
> Serkan
>
> 27.11.2019 08:57 tarihinde Alex Harui yazdı:
>> By deferring the initialization of _descriptors until it is  
>> actually needed, the code allows FormatDescriptor to get loaded.   
>> If the initialization code that needs FormatDescriptor runs too  
>> soon, then FormatDescriptor won't have been loaded yet.
>>
>> At least, that's the theory,
>> -Alex
>>
>> On 11/26/19, 9:50 PM, "serkan.tas@likyateknoloji.com"  
>> <se...@likyateknoloji.com> wrote:
>>
>>     Hi Alex,
>>          Sorry for inconvenience. I was just sent it before leaving  
>> home in the
>>     morning. I am going to send you the real code and check your sample
>>     later today.
>>          But I did not understand the what should I do for FormatDescriptor.
>>          Is there a workaround ?
>>


-- 
Serkan Taş
Mobil : +90 532 250 07 71
Likya Bilgi Teknolojileri
ve İletişim Hiz. Ltd. Şti.
www.likyateknoloji.com

--------------------------------------
Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
etmez.

This electronic mail and any files transmitted with it are intended  
for the private use of  the persons named above. If you received this  
message in error, forwarding, copying or use of any of the information  
is strictly prohibited. Please immediately notify the sender and  
delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
Ltd. Şti. does not accept legal responsibility for the contents of  
this message.
--------------------------------------


Re: TextConverter method call

Posted by Serkan Taş <se...@likyateknoloji.com>.
Hi Alex,

TextConverter : 
https://drive.google.com/open?id=1_6-rBQqTISbeoLvS2-yV8bSFkvS_ApxZ

It is working without any excepiton, but still can not show the text in 
TextArea.

Going to try to find-out why...

Thank,
Serkan

27.11.2019 08:57 tarihinde Alex Harui yazdı:
> By deferring the initialization of _descriptors until it is actually needed, the code allows FormatDescriptor to get loaded.  If the initialization code that needs FormatDescriptor runs too soon, then FormatDescriptor won't have been loaded yet.
>
> At least, that's the theory,
> -Alex
>
> On 11/26/19, 9:50 PM, "serkan.tas@likyateknoloji.com" <se...@likyateknoloji.com> wrote:
>
>      Hi Alex,
>      
>      Sorry for inconvenience. I was just sent it before leaving home in the
>      morning. I am going to send you the real code and check your sample
>      later today.
>      
>      But I did not understand the what should I do for FormatDescriptor.
>      
>      Is there a workaround ?
>      


Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
By deferring the initialization of _descriptors until it is actually needed, the code allows FormatDescriptor to get loaded.  If the initialization code that needs FormatDescriptor runs too soon, then FormatDescriptor won't have been loaded yet.

At least, that's the theory,
-Alex

On 11/26/19, 9:50 PM, "serkan.tas@likyateknoloji.com" <se...@likyateknoloji.com> wrote:

    Hi Alex,
    
    Sorry for inconvenience. I was just sent it before leaving home in the  
    morning. I am going to send you the real code and check your sample  
    later today.
    
    But I did not understand the what should I do for FormatDescriptor.
    
    Is there a workaround ?
    
    
    Alıntı Alex Harui <ah...@adobe.com>:
    
    > That link took me to the FormatDescriptor class.
    >
    > The FormatDescriptor exception is a side-effect of having naked  
    > static initialization code.  We want to defer static initialization  
    > until it is really needed so that the load order of classes doesn’t  
    > matter as much (or at all).
    >
    > My current opinion (again without spending too much time thinking  
    > about it) is to convert the var into a get function.  Most other  
    > methods in TextConverter access _descriptor and thus would  
    > initialize it just-in-time as it is needed.  Something like:
    >
    >         Static private var __descriptors:Array;
    >
    >         static public function get _descriptors():Array
    >         {
    >               If (!__descriptors) {
    >                 _descriptors = [];
    >                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
    >                 addFormat(TEXT_FIELD_HTML_FORMAT,  
    > TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
    >                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text", __descriptors);
    >             }
    >       }
    >
    > And add an optional last param to addFormat to specify the array to  
    > add to, so it doesn’t access the getter during initialization.
    >
    > HTH,
    > -Alex
    >
    > From: Serkan Taş <se...@likyateknoloji.com>
    > Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
    > Date: Tuesday, November 26, 2019 at 8:14 PM
    > To: "users@royale.apache.org" <us...@royale.apache.org>
    > Subject: Re: TextConverter method call
    >
    > Alex, I have implemented in other way, here it is : ====>  
    > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=WI3lFGqAmrxWpR6M3kf6L%2FIIZZkIRoJAmNDX2zNcCvs%3D&amp;reserved=0<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=WI3lFGqAmrxWpR6M3kf6L%2FIIZZkIRoJAmNDX2zNcCvs%3D&amp;reserved=0>
    >
    > But I have another exception in other thread , can you check it ?
    >
    > subject : "org.apache.royale.textLayout.conversion.FormatDescriptor  
    > is not a constructor"
    > 27.11.2019 01:34 tarihinde Alex Harui yazdı:
    > Nevermind, that won’t work in this case.  I think you still need to  
    > initialize _descriptors with a static initializer.  I think I would  
    > use an internal version of addFormat for doing that.  Or maybe  
    > manually code _descriptors as a get/set.
    >
    > HTH,
    > -Alex
    >
    > From: Alex Harui <ah...@adobe.com>
    > Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Date: Tuesday, November 26, 2019 at 2:22 PM
    > To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Subject: Re: TextConverter method call
    >
    > Yes, probably a good idea, in which I case I would just use a dummy  
    > initializer
    >
    >         /** @private */
    >         static public function setFormatsToDefault():Boolean    // No PMD
    >         {
    >             _descriptors = [];
    >             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT);
    >             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
    >  TextFieldHtmlExporter, null);
    >             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text");
    >             return true;
    >         }
    >         static public var _descriptors:Array;
    >         static private var formatsSet:Boolean = setFormatsToDefault()
    >
    >
    >
    >
    > From: Serkan Taş  
    > <se...@likyateknoloji.com>
    > Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Date: Tuesday, November 26, 2019 at 11:44 AM
    > To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Subject: Re: TextConverter method call
    >
    > Do I have to keep addFormat and addFormatAt compatible for external  
    > usage, because they are public may be called from other classes ?
    > 26.11.2019 21:15 tarihinde Alex Harui yazdı:
    > It “should” but we are not fully supporting “naked code” (code not  
    > in methods) right now.  I’ve never liked the pattern and I’m not  
    > sure all minifiers know how to handle it, so the easiest answer for  
    > now is to rewrite the pattern.
    >
    > One way to rewrite is to have setFormatDefaults return an array and  
    > initialize _descriptors.  Something like:
    >
    >         // register standard importers and exporters
    >         setFormatsToDefault();
    >
    >         /** @private */
    >         static public function setFormatsToDefault():Array    // No PMD
    >         {
    >             var arr:Array = [];
    >             addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT);
    >             addFormat(arr, TEXT_FIELD_HTML_FORMAT,  
    > TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
    >             addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text");
    >             return arr;
    >         }
    >         static public var _descriptors:Array = setFormatsToDefault()
    >
    > You’ll have to change addFormat to accept the array to modify.
    >
    > HTH,
    > -Alex
    >
    > From: Serkan Taş  
    > <se...@likyateknoloji.com>
    > Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Date: Tuesday, November 26, 2019 at 9:13 AM
    > To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Subject: Re: TextConverter method call
    >
    > Unfortunately there is not a getter for the property, but the call  
    > for setFormatsToDefault is in the class body.
    >
    >         public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";
    >
    >         // Descriptors - ordered list of all FormatDescriptors
    >         /** @private */
    >         static public var _descriptors:Array = [];
    >
    >         // register standard importers and exporters
    >         setFormatsToDefault();
    >
    >         /** @private */
    >         static public function setFormatsToDefault():void    // No PMD
    >         {
    >             _descriptors = [];
    >             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT);
    >             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
    >  TextFieldHtmlExporter, null);
    >             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text");
    >         }
    >
    >
    > Shouldn't it be called while the class is initialized ?
    >
    > Thanks,
    > Serkan
    > 26.11.2019 08:06 tarihinde Alex Harui yazdı:
    > Without looking at more of the code, I’m guessing there is a  
    > “descriptors” property that returns the “_descriptors” array.  If  
    > that’s the case, then I would add a check to the descriptors getter  
    > to check if _descriptors has been initialized and if not, call  
    > setFormatsToDefault.
    >
    > -Alex
    >
    > From: Serkan Taş  
    > <se...@likyateknoloji.com>
    > Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Date: Monday, November 25, 2019 at 12:55 PM
    > To: "users@royale.apache.org"<ma...@royale.apache.org>  
    > <us...@royale.apache.org>
    > Subject: TextConverter method call
    >
    > Hi,
    >
    > TextConverter has a method named setFormatsToDefault() and called  
    > while the application is loaded  - I guess automatically because I  
    > could not find any reference - in Flex, but never called in Royale.
    >
    > Source piece Royale  :
    >
    >         // register standard importers and exporters
    >         setFormatsToDefault();
    >
    >         /** @private */
    >         static public function setFormatsToDefault():void    // No PMD
    >         {
    >             _descriptors = [];
    >             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT);
    >             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
    >  TextFieldHtmlExporter, null);
    >             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text");
    >         }
    >
    >
    > Flex :
    >
    >         // register standard importers and exporters
    >         setFormatsToDefault();
    >
    >         /** @private */
    >         static tlf_internal function setFormatsToDefault():void    // No PMD
    >         {
    >             _descriptors = [];
    >             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT);
    >             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
    >  TextFieldHtmlExporter, null);
    >             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text");
    >         }
    >
    > How should be the mechanism for the flow in Royale ?
    >
    > Thanks,
    > Serkan
    
    
    -- 
    Serkan Taş
    Mobil : +90 532 250 07 71
    Likya Bilgi Teknolojileri
    ve İletişim Hiz. Ltd. Şti.
    https://nam04.safelinks.protection.outlook.com/?url=www.likyateknoloji.com&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=eSy9IgwkT8Cw8o4%2B045B8dnxpw2qrVNQoSuCTj7UmoE%3D&amp;reserved=0
    
    --------------------------------------
    Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
    yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
    taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
    içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
    kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
    siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
    mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
    etmez.
    
    This electronic mail and any files transmitted with it are intended  
    for the private use of  the persons named above. If you received this  
    message in error, forwarding, copying or use of any of the information  
    is strictly prohibited. Please immediately notify the sender and  
    delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
    Ltd. Şti. does not accept legal responsibility for the contents of  
    this message.
    --------------------------------------
    
    


Re: TextConverter method call

Posted by se...@likyateknoloji.com.
Hi Alex,

Sorry for inconvenience. I was just sent it before leaving home in the  
morning. I am going to send you the real code and check your sample  
later today.

But I did not understand the what should I do for FormatDescriptor.

Is there a workaround ?


Alıntı Alex Harui <ah...@adobe.com>:

> That link took me to the FormatDescriptor class.
>
> The FormatDescriptor exception is a side-effect of having naked  
> static initialization code.  We want to defer static initialization  
> until it is really needed so that the load order of classes doesn’t  
> matter as much (or at all).
>
> My current opinion (again without spending too much time thinking  
> about it) is to convert the var into a get function.  Most other  
> methods in TextConverter access _descriptor and thus would  
> initialize it just-in-time as it is needed.  Something like:
>
>         Static private var __descriptors:Array;
>
>         static public function get _descriptors():Array
>         {
>               If (!__descriptors) {
>                 _descriptors = [];
>                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
>                 addFormat(TEXT_FIELD_HTML_FORMAT,  
> TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
>                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text", __descriptors);
>             }
>       }
>
> And add an optional last param to addFormat to specify the array to  
> add to, so it doesn’t access the getter during initialization.
>
> HTH,
> -Alex
>
> From: Serkan Taş <se...@likyateknoloji.com>
> Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
> Date: Tuesday, November 26, 2019 at 8:14 PM
> To: "users@royale.apache.org" <us...@royale.apache.org>
> Subject: Re: TextConverter method call
>
> Alex, I have implemented in other way, here it is : ====>  
> https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&data=02%7C01%7Caharui%40adobe.com%7Cf1bcbef8545341e8ec6e08d772f049d8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104248674874151&sdata=Aw7jIEhZttahHiV5zlDJjKC7X0Rkz10E0W2l0QiZKT0%3D&reserved=0>
>
> But I have another exception in other thread , can you check it ?
>
> subject : "org.apache.royale.textLayout.conversion.FormatDescriptor  
> is not a constructor"
> 27.11.2019 01:34 tarihinde Alex Harui yazdı:
> Nevermind, that won’t work in this case.  I think you still need to  
> initialize _descriptors with a static initializer.  I think I would  
> use an internal version of addFormat for doing that.  Or maybe  
> manually code _descriptors as a get/set.
>
> HTH,
> -Alex
>
> From: Alex Harui <ah...@adobe.com>
> Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Date: Tuesday, November 26, 2019 at 2:22 PM
> To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Subject: Re: TextConverter method call
>
> Yes, probably a good idea, in which I case I would just use a dummy  
> initializer
>
>         /** @private */
>         static public function setFormatsToDefault():Boolean    // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
>  TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text");
>             return true;
>         }
>         static public var _descriptors:Array;
>         static private var formatsSet:Boolean = setFormatsToDefault()
>
>
>
>
> From: Serkan Taş  
> <se...@likyateknoloji.com>
> Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Date: Tuesday, November 26, 2019 at 11:44 AM
> To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Subject: Re: TextConverter method call
>
> Do I have to keep addFormat and addFormatAt compatible for external  
> usage, because they are public may be called from other classes ?
> 26.11.2019 21:15 tarihinde Alex Harui yazdı:
> It “should” but we are not fully supporting “naked code” (code not  
> in methods) right now.  I’ve never liked the pattern and I’m not  
> sure all minifiers know how to handle it, so the easiest answer for  
> now is to rewrite the pattern.
>
> One way to rewrite is to have setFormatDefaults return an array and  
> initialize _descriptors.  Something like:
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():Array    // No PMD
>         {
>             var arr:Array = [];
>             addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(arr, TEXT_FIELD_HTML_FORMAT,  
> TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>             addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text");
>             return arr;
>         }
>         static public var _descriptors:Array = setFormatsToDefault()
>
> You’ll have to change addFormat to accept the array to modify.
>
> HTH,
> -Alex
>
> From: Serkan Taş  
> <se...@likyateknoloji.com>
> Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Date: Tuesday, November 26, 2019 at 9:13 AM
> To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Subject: Re: TextConverter method call
>
> Unfortunately there is not a getter for the property, but the call  
> for setFormatsToDefault is in the class body.
>
>         public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";
>
>         // Descriptors - ordered list of all FormatDescriptors
>         /** @private */
>         static public var _descriptors:Array = [];
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():void    // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
>  TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text");
>         }
>
>
> Shouldn't it be called while the class is initialized ?
>
> Thanks,
> Serkan
> 26.11.2019 08:06 tarihinde Alex Harui yazdı:
> Without looking at more of the code, I’m guessing there is a  
> “descriptors” property that returns the “_descriptors” array.  If  
> that’s the case, then I would add a check to the descriptors getter  
> to check if _descriptors has been initialized and if not, call  
> setFormatsToDefault.
>
> -Alex
>
> From: Serkan Taş  
> <se...@likyateknoloji.com>
> Reply-To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Date: Monday, November 25, 2019 at 12:55 PM
> To: "users@royale.apache.org"<ma...@royale.apache.org>  
> <us...@royale.apache.org>
> Subject: TextConverter method call
>
> Hi,
>
> TextConverter has a method named setFormatsToDefault() and called  
> while the application is loaded  - I guess automatically because I  
> could not find any reference - in Flex, but never called in Royale.
>
> Source piece Royale  :
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():void    // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
>  TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text");
>         }
>
>
> Flex :
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static tlf_internal function setFormatsToDefault():void    // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
>  TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text");
>         }
>
> How should be the mechanism for the flow in Royale ?
>
> Thanks,
> Serkan


-- 
Serkan Taş
Mobil : +90 532 250 07 71
Likya Bilgi Teknolojileri
ve İletişim Hiz. Ltd. Şti.
www.likyateknoloji.com

--------------------------------------
Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
etmez.

This electronic mail and any files transmitted with it are intended  
for the private use of  the persons named above. If you received this  
message in error, forwarding, copying or use of any of the information  
is strictly prohibited. Please immediately notify the sender and  
delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
Ltd. Şti. does not accept legal responsibility for the contents of  
this message.
--------------------------------------


Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
That link took me to the FormatDescriptor class.

The FormatDescriptor exception is a side-effect of having naked static initialization code.  We want to defer static initialization until it is really needed so that the load order of classes doesn’t matter as much (or at all).

My current opinion (again without spending too much time thinking about it) is to convert the var into a get function.  Most other methods in TextConverter access _descriptor and thus would initialize it just-in-time as it is needed.  Something like:

        Static private var __descriptors:Array;

        static public function get _descriptors():Array
        {
              If (!__descriptors) {
                _descriptors = [];
                addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
                addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
                addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text", __descriptors);
            }
      }

And add an optional last param to addFormat to specify the array to add to, so it doesn’t access the getter during initialization.

HTH,
-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 8:14 PM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: TextConverter method call

Alex, I have implemented in other way, here it is : ====> https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&data=02%7C01%7Caharui%40adobe.com%7Cf1bcbef8545341e8ec6e08d772f049d8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104248674874151&sdata=Aw7jIEhZttahHiV5zlDJjKC7X0Rkz10E0W2l0QiZKT0%3D&reserved=0>

But I have another exception in other thread , can you check it ?

subject : "org.apache.royale.textLayout.conversion.FormatDescriptor is not a constructor"
27.11.2019 01:34 tarihinde Alex Harui yazdı:
Nevermind, that won’t work in this case.  I think you still need to initialize _descriptors with a static initializer.  I think I would use an internal version of addFormat for doing that.  Or maybe manually code _descriptors as a get/set.

HTH,
-Alex

From: Alex Harui <ah...@adobe.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 2:22 PM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: Re: TextConverter method call

Yes, probably a good idea, in which I case I would just use a dummy initializer

        /** @private */
        static public function setFormatsToDefault():Boolean    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return true;
        }
        static public var _descriptors:Array;
        static private var formatsSet:Boolean = setFormatsToDefault()




From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: Re: TextConverter method call

Do I have to keep addFormat and addFormatAt compatible for external usage, because they are public may be called from other classes ?
26.11.2019 21:15 tarihinde Alex Harui yazdı:
It “should” but we are not fully supporting “naked code” (code not in methods) right now.  I’ve never liked the pattern and I’m not sure all minifiers know how to handle it, so the easiest answer for now is to rewrite the pattern.

One way to rewrite is to have setFormatDefaults return an array and initialize _descriptors.  Something like:

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():Array    // No PMD
        {
            var arr:Array = [];
            addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(arr, TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return arr;
        }
        static public var _descriptors:Array = setFormatsToDefault()

You’ll have to change addFormat to accept the array to modify.

HTH,
-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: Re: TextConverter method call

Unfortunately there is not a getter for the property, but the call for setFormatsToDefault is in the class body.

        public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

        // Descriptors - ordered list of all FormatDescriptors
        /** @private */
        static public var _descriptors:Array = [];

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a “descriptors” property that returns the “_descriptors” array.  If that’s the case, then I would add a check to the descriptors getter to check if _descriptors has been initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the application is loaded  - I guess automatically because I could not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan

















Re: TextConverter method call

Posted by Serkan Taş <se...@likyateknoloji.com>.
Alex, I have implemented in other way, here it is : ====> 
https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B

But I have another exception in other thread , can you check it ?

subject : "org.apache.royale.textLayout.conversion.FormatDescriptor is 
not a constructor"

27.11.2019 01:34 tarihinde Alex Harui yazdı:
>
> Nevermind, that won’t work in this case.  I think you still need to 
> initialize _descriptors with a static initializer.  I think I would 
> use an internal version of addFormat for doing that.  Or maybe 
> manually code _descriptors as a get/set.
>
> HTH,
>
> -Alex
>
> *From: *Alex Harui <ah...@adobe.com>
> *Reply-To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Date: *Tuesday, November 26, 2019 at 2:22 PM
> *To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Subject: *Re: TextConverter method call
>
> Yes, probably a good idea, in which I case I would just use a dummy 
> initializer
>
>         /** @private */
>         static public function setFormatsToDefault():Boolean    // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
> TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
> PlainTextExporter, "air:text");
>
>             return true;
>         }
>         static public var _descriptors:Array;
>
>         static private var formatsSet:Boolean = setFormatsToDefault()
>
>
> *From: *Serkan Taş <se...@likyateknoloji.com>
> *Reply-To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Date: *Tuesday, November 26, 2019 at 11:44 AM
> *To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Subject: *Re: TextConverter method call
>
> Do I have to keep addFormat and addFormatAt compatible for external 
> usage, because they are public may be called from other classes ?
>
> 26.11.2019 21:15 tarihinde Alex Harui yazdı:
>
>     It “should” but we are not fully supporting “naked code” (code not
>     in methods) right now.  I’ve never liked the pattern and I’m not
>     sure all minifiers know how to handle it, so the easiest answer
>     for now is to rewrite the pattern.
>
>     One way to rewrite is to have setFormatDefaults return an array
>     and initialize _descriptors.  Something like:
>
>             // register standard importers and exporters
>             setFormatsToDefault();
>
>             /** @private */
>             static public function setFormatsToDefault():Array    //
>     No PMD
>             {
>                 var arr:Array = [];
>                 addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>     TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                 addFormat(arr, TEXT_FIELD_HTML_FORMAT,
>     TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                 addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter,
>     PlainTextExporter, "air:text");
>
>     return arr;
>             }
>             static public var _descriptors:Array = setFormatsToDefault()
>
>     You’ll have to change addFormat to accept the array to modify.
>
>     HTH,
>
>     -Alex
>
>     *From: *Serkan Taş <se...@likyateknoloji.com>
>     <ma...@likyateknoloji.com>
>     *Reply-To: *"users@royale.apache.org"
>     <ma...@royale.apache.org> <us...@royale.apache.org>
>     <ma...@royale.apache.org>
>     *Date: *Tuesday, November 26, 2019 at 9:13 AM
>     *To: *"users@royale.apache.org" <ma...@royale.apache.org>
>     <us...@royale.apache.org> <ma...@royale.apache.org>
>     *Subject: *Re: TextConverter method call
>
>     Unfortunately there is not a getter for the property, but the call
>     for setFormatsToDefault is in the class body.
>
>             public static const TEXT_LAYOUT_FORMAT:String =
>     "textLayoutFormat";
>
>             // Descriptors - ordered list of all FormatDescriptors
>             /** @private */
>             static public var _descriptors:Array = [];
>
>             // register standard importers and exporters
>             setFormatsToDefault();
>
>             /** @private */
>             static public function setFormatsToDefault():void // No PMD
>             {
>                 _descriptors = [];
>                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>     TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                 addFormat(TEXT_FIELD_HTML_FORMAT,
>     TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
>     PlainTextExporter, "air:text");
>             }
>
>
>     Shouldn't it be called while the class is initialized ?
>
>     Thanks,
>     Serkan
>
>     26.11.2019 08:06 tarihinde Alex Harui yazdı:
>
>         Without looking at more of the code, I’m guessing there is a
>         “descriptors” property that returns the “_descriptors” array. 
>         If that’s the case, then I would add a check to the
>         descriptors getter to check if _descriptors has been
>         initialized and if not, call setFormatsToDefault.
>
>         -Alex
>
>         *From: *Serkan Taş <se...@likyateknoloji.com>
>         <ma...@likyateknoloji.com>
>         *Reply-To: *"users@royale.apache.org"
>         <ma...@royale.apache.org> <us...@royale.apache.org>
>         <ma...@royale.apache.org>
>         *Date: *Monday, November 25, 2019 at 12:55 PM
>         *To: *"users@royale.apache.org"
>         <ma...@royale.apache.org> <us...@royale.apache.org>
>         <ma...@royale.apache.org>
>         *Subject: *TextConverter method call
>
>         Hi,
>
>         TextConverter has a method named /setFormatsToDefault()/ and
>         called while the application is loaded  - I guess
>         automatically because I could not find any reference - in
>         Flex, but never called in Royale.
>
>         Source piece Royale  :
>
>         // register standard importers and exporters
>                 setFormatsToDefault();
>
>                 /** @private */
>                 static public function setFormatsToDefault():void   
>         // No PMD
>                 {
>                     _descriptors = [];
>                     addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>         TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                     addFormat(TEXT_FIELD_HTML_FORMAT,
>         TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                     addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
>         PlainTextExporter, "air:text");
>                 }
>
>
>         Flex :
>
>         // register standard importers and exporters
>                 setFormatsToDefault();
>
>                 /** @private */
>                 static tlf_internal function
>         setFormatsToDefault():void    // No PMD
>                 {
>                     _descriptors = [];
>                     addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>         TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                     addFormat(TEXT_FIELD_HTML_FORMAT,
>         TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                     addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
>         PlainTextExporter, "air:text");
>                 }
>
>         How should be the mechanism for the flow in Royale ?
>
>         Thanks,
>         Serkan
>
>
>
>
>
>
>
>
>
>
>


Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
Nevermind, that won’t work in this case.  I think you still need to initialize _descriptors with a static initializer.  I think I would use an internal version of addFormat for doing that.  Or maybe manually code _descriptors as a get/set.

HTH,
-Alex

From: Alex Harui <ah...@adobe.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 2:22 PM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: TextConverter method call

Yes, probably a good idea, in which I case I would just use a dummy initializer

        /** @private */
        static public function setFormatsToDefault():Boolean    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return true;
        }
        static public var _descriptors:Array;
        static private var formatsSet:Boolean = setFormatsToDefault()



From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: TextConverter method call

Do I have to keep addFormat and addFormatAt compatible for external usage, because they are public may be called from other classes ?
26.11.2019 21:15 tarihinde Alex Harui yazdı:
It “should” but we are not fully supporting “naked code” (code not in methods) right now.  I’ve never liked the pattern and I’m not sure all minifiers know how to handle it, so the easiest answer for now is to rewrite the pattern.

One way to rewrite is to have setFormatDefaults return an array and initialize _descriptors.  Something like:

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():Array    // No PMD
        {
            var arr:Array = [];
            addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(arr, TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return arr;
        }
        static public var _descriptors:Array = setFormatsToDefault()

You’ll have to change addFormat to accept the array to modify.

HTH,
-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: Re: TextConverter method call

Unfortunately there is not a getter for the property, but the call for setFormatsToDefault is in the class body.

        public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

        // Descriptors - ordered list of all FormatDescriptors
        /** @private */
        static public var _descriptors:Array = [];

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a “descriptors” property that returns the “_descriptors” array.  If that’s the case, then I would add a check to the descriptors getter to check if _descriptors has been initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the application is loaded  - I guess automatically because I could not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan












Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
Yes, probably a good idea, in which I case I would just use a dummy initializer

        /** @private */
        static public function setFormatsToDefault():Boolean    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return true;
        }
        static public var _descriptors:Array;
        static private var formatsSet:Boolean = setFormatsToDefault()


From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: TextConverter method call

Do I have to keep addFormat and addFormatAt compatible for external usage, because they are public may be called from other classes ?
26.11.2019 21:15 tarihinde Alex Harui yazdı:
It “should” but we are not fully supporting “naked code” (code not in methods) right now.  I’ve never liked the pattern and I’m not sure all minifiers know how to handle it, so the easiest answer for now is to rewrite the pattern.

One way to rewrite is to have setFormatDefaults return an array and initialize _descriptors.  Something like:

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():Array    // No PMD
        {
            var arr:Array = [];
            addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(arr, TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return arr;
        }
        static public var _descriptors:Array = setFormatsToDefault()

You’ll have to change addFormat to accept the array to modify.

HTH,
-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: Re: TextConverter method call

Unfortunately there is not a getter for the property, but the call for setFormatsToDefault is in the class body.

        public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

        // Descriptors - ordered list of all FormatDescriptors
        /** @private */
        static public var _descriptors:Array = [];

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a “descriptors” property that returns the “_descriptors” array.  If that’s the case, then I would add a check to the descriptors getter to check if _descriptors has been initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the application is loaded  - I guess automatically because I could not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan









Re: TextConverter method call

Posted by Serkan Taş <se...@likyateknoloji.com>.
Do I have to keep addFormat and addFormatAt compatible for external 
usage, because they are public may be called from other classes ?

26.11.2019 21:15 tarihinde Alex Harui yazdı:
>
> It “should” but we are not fully supporting “naked code” (code not in 
> methods) right now.  I’ve never liked the pattern and I’m not sure all 
> minifiers know how to handle it, so the easiest answer for now is to 
> rewrite the pattern.
>
> One way to rewrite is to have setFormatDefaults return an array and 
> initialize _descriptors.  Something like:
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():Array // No PMD
>         {
>             var arr:Array = [];
>             addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(arr, TEXT_FIELD_HTML_FORMAT, 
> TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>             addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, 
> PlainTextExporter, "air:text");
>
>             return arr;
>         }
>         static public var _descriptors:Array = setFormatsToDefault()
>
> You’ll have to change addFormat to accept the array to modify.
>
> HTH,
>
> -Alex
>
> *From: *Serkan Taş <se...@likyateknoloji.com>
> *Reply-To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Date: *Tuesday, November 26, 2019 at 9:13 AM
> *To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Subject: *Re: TextConverter method call
>
> Unfortunately there is not a getter for the property, but the call for 
> setFormatsToDefault is in the class body.
>
>         public static const TEXT_LAYOUT_FORMAT:String = 
> "textLayoutFormat";
>
>         // Descriptors - ordered list of all FormatDescriptors
>         /** @private */
>         static public var _descriptors:Array = [];
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():void // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
> TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
> PlainTextExporter, "air:text");
>         }
>
>
> Shouldn't it be called while the class is initialized ?
>
> Thanks,
> Serkan
>
> 26.11.2019 08:06 tarihinde Alex Harui yazdı:
>
>     Without looking at more of the code, I’m guessing there is a
>     “descriptors” property that returns the “_descriptors” array.  If
>     that’s the case, then I would add a check to the descriptors
>     getter to check if _descriptors has been initialized and if not,
>     call setFormatsToDefault.
>
>     -Alex
>
>     *From: *Serkan Taş <se...@likyateknoloji.com>
>     <ma...@likyateknoloji.com>
>     *Reply-To: *"users@royale.apache.org"
>     <ma...@royale.apache.org> <us...@royale.apache.org>
>     <ma...@royale.apache.org>
>     *Date: *Monday, November 25, 2019 at 12:55 PM
>     *To: *"users@royale.apache.org" <ma...@royale.apache.org>
>     <us...@royale.apache.org> <ma...@royale.apache.org>
>     *Subject: *TextConverter method call
>
>     Hi,
>
>     TextConverter has a method named /setFormatsToDefault()/ and
>     called while the application is loaded  - I guess automatically
>     because I could not find any reference - in Flex, but never called
>     in Royale.
>
>     Source piece Royale  :
>
>     // register standard importers and exporters
>             setFormatsToDefault();
>
>             /** @private */
>             static public function setFormatsToDefault():void    // No PMD
>             {
>                 _descriptors = [];
>                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>     TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                 addFormat(TEXT_FIELD_HTML_FORMAT,
>     TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
>     PlainTextExporter, "air:text");
>             }
>
>
>     Flex :
>
>     // register standard importers and exporters
>             setFormatsToDefault();
>
>             /** @private */
>             static tlf_internal function setFormatsToDefault():void   
>     // No PMD
>             {
>                 _descriptors = [];
>                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
>     TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>                 addFormat(TEXT_FIELD_HTML_FORMAT,
>     TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
>                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
>     PlainTextExporter, "air:text");
>             }
>
>     How should be the mechanism for the flow in Royale ?
>
>     Thanks,
>     Serkan
>
>
>
>


Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
It “should” but we are not fully supporting “naked code” (code not in methods) right now.  I’ve never liked the pattern and I’m not sure all minifiers know how to handle it, so the easiest answer for now is to rewrite the pattern.

One way to rewrite is to have setFormatDefaults return an array and initialize _descriptors.  Something like:

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():Array    // No PMD
        {
            var arr:Array = [];
            addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(arr, TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
            return arr;
        }
        static public var _descriptors:Array = setFormatsToDefault()

You’ll have to change addFormat to accept the array to modify.

HTH,
-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: TextConverter method call

Unfortunately there is not a getter for the property, but the call for setFormatsToDefault is in the class body.

        public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

        // Descriptors - ordered list of all FormatDescriptors
        /** @private */
        static public var _descriptors:Array = [];

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a “descriptors” property that returns the “_descriptors” array.  If that’s the case, then I would add a check to the descriptors getter to check if _descriptors has been initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<ma...@royale.apache.org> <us...@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the application is loaded  - I guess automatically because I could not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan





Re: TextConverter method call

Posted by Serkan Taş <se...@likyateknoloji.com>.
Unfortunately there is not a getter for the property, but the call for 
setFormatsToDefault is in the class body.

         public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

         // Descriptors - ordered list of all FormatDescriptors
         /** @private */
         static public var _descriptors:Array = [];

         // register standard importers and exporters
         setFormatsToDefault();

         /** @private */
         static public function setFormatsToDefault():void    // No PMD
         {
             _descriptors = [];
             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
PlainTextExporter, "air:text");
         }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan

26.11.2019 08:06 tarihinde Alex Harui yazdı:
>
> Without looking at more of the code, I’m guessing there is a 
> “descriptors” property that returns the “_descriptors” array.  If 
> that’s the case, then I would add a check to the descriptors getter to 
> check if _descriptors has been initialized and if not, call 
> setFormatsToDefault.
>
> -Alex
>
> *From: *Serkan Taş <se...@likyateknoloji.com>
> *Reply-To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Date: *Monday, November 25, 2019 at 12:55 PM
> *To: *"users@royale.apache.org" <us...@royale.apache.org>
> *Subject: *TextConverter method call
>
> Hi,
>
> TextConverter has a method named /setFormatsToDefault()/ and called 
> while the application is loaded  - I guess automatically because I 
> could not find any reference - in Flex, but never called in Royale.
>
> Source piece Royale  :
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static public function setFormatsToDefault():void // No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
> TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
> PlainTextExporter, "air:text");
>         }
>
>
> Flex :
>
>         // register standard importers and exporters
>         setFormatsToDefault();
>
>         /** @private */
>         static tlf_internal function setFormatsToDefault():void    // 
> No PMD
>         {
>             _descriptors = [];
>             addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
> TextLayoutExporter, TEXT_LAYOUT_FORMAT);
>             addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
> TextFieldHtmlExporter, null);
>             addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, 
> PlainTextExporter, "air:text");
>         }
>
> How should be the mechanism for the flow in Royale ?
>
> Thanks,
> Serkan
>


Re: TextConverter method call

Posted by Alex Harui <ah...@adobe.com>.
Without looking at more of the code, I’m guessing there is a “descriptors” property that returns the “_descriptors” array.  If that’s the case, then I would add a check to the descriptors getter to check if _descriptors has been initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş <se...@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the application is loaded  - I guess automatically because I could not find any reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan