You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Pete Whelpton <pe...@gmail.com> on 2018/09/29 12:25:46 UTC

[NBP] Some annoying questions..

Hello all :) Apologies in advance for the newbie NBP questions.  I have
already been through the NBP API documentation and Netbeans sources, which
is how I've got to where I am, but I'm a bit stumped now.  Any pointers, no
matter how small, gratefully received!


1)    Modular approach for project customizers (and sharing settings
between Modules)

    * I have a module suite with a Project module, and two modules for
supported File Types, Nss and Tda
    * In the project module, I have a class that implements
AuxillaryProperties and reads/writes a .properties file.  This class is
registered in the Project Lookup
    * In the File Type modules, I have registered customizer panels with
@ProjectCustomizer.CompositeCategoryProvider.Registration

    Q1)  ProjectUtils.getPreferences() returns null.  Why?  Looking at the
NB source, it seems like the factory creates the backing store by first
checking for an implementation of AuxillaryConfiguration in the
ProjectLookup, then for AuxillaryProperties.  I have an implementation of
AuxillaryProperties, so I'm not sure why it doesn't work.

    I can get the properties by looking up AuxillaryProperties from in
Project lookup injected into the customizer panels - but the Netbeans API
documentation says not to directly use this interface...

    Q2)  How to save changes for each panel?  I think that each panel
somehow needs to listen to the okOptionLister and implement its own save
operation, but that Listener is up in the Project.


2) My Module Suite will no longer build unless I do a Clean & Build.
Regular build fails with the following error:

    error: Refused to write invalid generated-layer.xml:
org.xml.sax.SAXParseException; lineNumber: 174; columnNumber: 43; The
element type "file" must be terminated by the matching end-tag "</file>".

    The only generated-layer.xml file is the one for the Nss module.  The
XML around line 174 is:

        <folder name="Preprocessor Directives">
            <file name="DirectiveInclude.xml">
                <!--org.peedeeboy.oens.nss--><![CDATA[<!DOCTYPE
editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' '
http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>
                <editor_palette_item version="1.1">
                    <body>  <![CDATA[#include "filename"]]]]><![CDATA[>
</body>
                        <icon16
urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
                        <icon32
urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />

<inline-description><display-name>Include</display-name><tooltip> <![CDATA[
Include external .nss
script]]]]><![CDATA[></tooltip></inline-description></editor_palette_item>]]></file>
        </folder>


    Q3) Why would this fail to be generated correctly on a Build, but not
on a Clean and Build?


3) My NSS file type should always be opened/saved in CP-1252 encoding, with
Windows line endings

    Q4) Where to implement this?  To try and get some clues, I've been
looking through the NB sources for how NB gets the encoding property for
Java projects and uses it for reading/writes .java files, but I haven't
found it...


Thanks and apologies again!

P

Re: [NBP] Some annoying questions..

Posted by Pete Whelpton <pe...@gmail.com>.
Picked up a copy.  Between your book and Gail's book, I've figured out now
how to add a ProxyLookup to my DataObject containing my custom
FileEncodingQueryImplementation class.

Everything seems to work ok :)

Thanks for your time


P


On Sun, Sep 30, 2018 at 9:45 AM Geertjan Wielenga
<ge...@googlemail.com.invalid> wrote:

> In general, advisable to use Lookup instead of Cookies, please get
> leanpub.com/nbp4beginners.
>
> Gj
>
> On Sun, Sep 30, 2018 at 10:28 AM Pete Whelpton <pe...@gmail.com>
> wrote:
>
>> Thanks Geertjan :)
>>
>> I've made the repo public for the moment, in case anyone wants to take a
>> look:
>> https://bitbucket.org/peedeeboy/odyssey-engine-netbeans-solution/src/development/
>> I can try and knock together a simple application for Q1) if anyone is
>> interested in helping.  It seems like I'm missing something obvious in the
>> way NBP is designed.
>>
>> Re: Q4, always opening a file in a specific encoding, I think I've
>> figured that part out:
>>
>> * Extend FileEncodingQueryImplementation and override the getEncoding()
>> method to return the Charset of choice (windows-1252)
>> * Register this in the DataObject's lookup.  I'm using this in the DO
>> constructor:
>> CookieSet cookies = getCookieSet();
>>         cookies.assign(FileEncodingQueryImplementation.class,
>>                 new NssFileEncodingQueryImplementation());
>>
>> Not sure about forcing windows line endings yet, but I'll keep trying...
>>
>>
>>
>> P
>>
>>
>>
>> On Sun, Sep 30, 2018 at 9:00 AM Geertjan Wielenga
>> <ge...@googlemail.com.invalid> wrote:
>>
>>> All these questions are hard to answer theoretically -- i.e., if you
>>> have something on GitHub that reproduces these problems, someone can look
>>> at them and help, i.e., create a simple NetBeans Platform application that
>>> contains these problematic areas and then someone can advise.
>>>
>>> Gj
>>>
>>> On Sat, Sep 29, 2018 at 2:25 PM Pete Whelpton <pe...@gmail.com>
>>> wrote:
>>>
>>>>
>>>> Hello all :) Apologies in advance for the newbie NBP questions.  I have
>>>> already been through the NBP API documentation and Netbeans sources, which
>>>> is how I've got to where I am, but I'm a bit stumped now.  Any pointers, no
>>>> matter how small, gratefully received!
>>>>
>>>>
>>>> 1)    Modular approach for project customizers (and sharing settings
>>>> between Modules)
>>>>
>>>>     * I have a module suite with a Project module, and two modules for
>>>> supported File Types, Nss and Tda
>>>>     * In the project module, I have a class that implements
>>>> AuxillaryProperties and reads/writes a .properties file.  This class is
>>>> registered in the Project Lookup
>>>>     * In the File Type modules, I have registered customizer panels
>>>> with @ProjectCustomizer.CompositeCategoryProvider.Registration
>>>>
>>>>     Q1)  ProjectUtils.getPreferences() returns null.  Why?  Looking at
>>>> the NB source, it seems like the factory creates the backing store by first
>>>> checking for an implementation of AuxillaryConfiguration in the
>>>> ProjectLookup, then for AuxillaryProperties.  I have an implementation of
>>>> AuxillaryProperties, so I'm not sure why it doesn't work.
>>>>
>>>>     I can get the properties by looking up AuxillaryProperties from in
>>>> Project lookup injected into the customizer panels - but the Netbeans API
>>>> documentation says not to directly use this interface...
>>>>
>>>>     Q2)  How to save changes for each panel?  I think that each panel
>>>> somehow needs to listen to the okOptionLister and implement its own save
>>>> operation, but that Listener is up in the Project.
>>>>
>>>>
>>>> 2) My Module Suite will no longer build unless I do a Clean & Build.
>>>> Regular build fails with the following error:
>>>>
>>>>     error: Refused to write invalid generated-layer.xml:
>>>> org.xml.sax.SAXParseException; lineNumber: 174; columnNumber: 43; The
>>>> element type "file" must be terminated by the matching end-tag "</file>".
>>>>
>>>>     The only generated-layer.xml file is the one for the Nss module.
>>>> The XML around line 174 is:
>>>>
>>>>         <folder name="Preprocessor Directives">
>>>>             <file name="DirectiveInclude.xml">
>>>>                 <!--org.peedeeboy.oens.nss--><![CDATA[<!DOCTYPE
>>>> editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' '
>>>> http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>
>>>>                 <editor_palette_item version="1.1">
>>>>                     <body>  <![CDATA[#include "filename"]]]]><![CDATA[>
>>>> </body>
>>>>                         <icon16
>>>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>>>                         <icon32
>>>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>>>
>>>> <inline-description><display-name>Include</display-name><tooltip> <![CDATA[
>>>> Include external .nss
>>>> script]]]]><![CDATA[></tooltip></inline-description></editor_palette_item>]]></file>
>>>>         </folder>
>>>>
>>>>
>>>>     Q3) Why would this fail to be generated correctly on a Build, but
>>>> not on a Clean and Build?
>>>>
>>>>
>>>> 3) My NSS file type should always be opened/saved in CP-1252 encoding,
>>>> with Windows line endings
>>>>
>>>>     Q4) Where to implement this?  To try and get some clues, I've been
>>>> looking through the NB sources for how NB gets the encoding property for
>>>> Java projects and uses it for reading/writes .java files, but I haven't
>>>> found it...
>>>>
>>>>
>>>> Thanks and apologies again!
>>>>
>>>> P
>>>>
>>>

Re: [NBP] Some annoying questions..

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
In general, advisable to use Lookup instead of Cookies, please get
leanpub.com/nbp4beginners.

Gj

On Sun, Sep 30, 2018 at 10:28 AM Pete Whelpton <pe...@gmail.com> wrote:

> Thanks Geertjan :)
>
> I've made the repo public for the moment, in case anyone wants to take a
> look:
> https://bitbucket.org/peedeeboy/odyssey-engine-netbeans-solution/src/development/
> I can try and knock together a simple application for Q1) if anyone is
> interested in helping.  It seems like I'm missing something obvious in the
> way NBP is designed.
>
> Re: Q4, always opening a file in a specific encoding, I think I've figured
> that part out:
>
> * Extend FileEncodingQueryImplementation and override the getEncoding()
> method to return the Charset of choice (windows-1252)
> * Register this in the DataObject's lookup.  I'm using this in the DO
> constructor:
> CookieSet cookies = getCookieSet();
>         cookies.assign(FileEncodingQueryImplementation.class,
>                 new NssFileEncodingQueryImplementation());
>
> Not sure about forcing windows line endings yet, but I'll keep trying...
>
>
>
> P
>
>
>
> On Sun, Sep 30, 2018 at 9:00 AM Geertjan Wielenga
> <ge...@googlemail.com.invalid> wrote:
>
>> All these questions are hard to answer theoretically -- i.e., if you have
>> something on GitHub that reproduces these problems, someone can look at
>> them and help, i.e., create a simple NetBeans Platform application that
>> contains these problematic areas and then someone can advise.
>>
>> Gj
>>
>> On Sat, Sep 29, 2018 at 2:25 PM Pete Whelpton <pe...@gmail.com>
>> wrote:
>>
>>>
>>> Hello all :) Apologies in advance for the newbie NBP questions.  I have
>>> already been through the NBP API documentation and Netbeans sources, which
>>> is how I've got to where I am, but I'm a bit stumped now.  Any pointers, no
>>> matter how small, gratefully received!
>>>
>>>
>>> 1)    Modular approach for project customizers (and sharing settings
>>> between Modules)
>>>
>>>     * I have a module suite with a Project module, and two modules for
>>> supported File Types, Nss and Tda
>>>     * In the project module, I have a class that implements
>>> AuxillaryProperties and reads/writes a .properties file.  This class is
>>> registered in the Project Lookup
>>>     * In the File Type modules, I have registered customizer panels with
>>> @ProjectCustomizer.CompositeCategoryProvider.Registration
>>>
>>>     Q1)  ProjectUtils.getPreferences() returns null.  Why?  Looking at
>>> the NB source, it seems like the factory creates the backing store by first
>>> checking for an implementation of AuxillaryConfiguration in the
>>> ProjectLookup, then for AuxillaryProperties.  I have an implementation of
>>> AuxillaryProperties, so I'm not sure why it doesn't work.
>>>
>>>     I can get the properties by looking up AuxillaryProperties from in
>>> Project lookup injected into the customizer panels - but the Netbeans API
>>> documentation says not to directly use this interface...
>>>
>>>     Q2)  How to save changes for each panel?  I think that each panel
>>> somehow needs to listen to the okOptionLister and implement its own save
>>> operation, but that Listener is up in the Project.
>>>
>>>
>>> 2) My Module Suite will no longer build unless I do a Clean & Build.
>>> Regular build fails with the following error:
>>>
>>>     error: Refused to write invalid generated-layer.xml:
>>> org.xml.sax.SAXParseException; lineNumber: 174; columnNumber: 43; The
>>> element type "file" must be terminated by the matching end-tag "</file>".
>>>
>>>     The only generated-layer.xml file is the one for the Nss module.
>>> The XML around line 174 is:
>>>
>>>         <folder name="Preprocessor Directives">
>>>             <file name="DirectiveInclude.xml">
>>>                 <!--org.peedeeboy.oens.nss--><![CDATA[<!DOCTYPE
>>> editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' '
>>> http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>
>>>                 <editor_palette_item version="1.1">
>>>                     <body>  <![CDATA[#include "filename"]]]]><![CDATA[>
>>> </body>
>>>                         <icon16
>>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>>                         <icon32
>>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>>
>>> <inline-description><display-name>Include</display-name><tooltip> <![CDATA[
>>> Include external .nss
>>> script]]]]><![CDATA[></tooltip></inline-description></editor_palette_item>]]></file>
>>>         </folder>
>>>
>>>
>>>     Q3) Why would this fail to be generated correctly on a Build, but
>>> not on a Clean and Build?
>>>
>>>
>>> 3) My NSS file type should always be opened/saved in CP-1252 encoding,
>>> with Windows line endings
>>>
>>>     Q4) Where to implement this?  To try and get some clues, I've been
>>> looking through the NB sources for how NB gets the encoding property for
>>> Java projects and uses it for reading/writes .java files, but I haven't
>>> found it...
>>>
>>>
>>> Thanks and apologies again!
>>>
>>> P
>>>
>>

Re: [NBP] Some annoying questions..

Posted by Pete Whelpton <pe...@gmail.com>.
Thanks Geertjan :)

I've made the repo public for the moment, in case anyone wants to take a
look:
https://bitbucket.org/peedeeboy/odyssey-engine-netbeans-solution/src/development/
I can try and knock together a simple application for Q1) if anyone is
interested in helping.  It seems like I'm missing something obvious in the
way NBP is designed.

Re: Q4, always opening a file in a specific encoding, I think I've figured
that part out:

* Extend FileEncodingQueryImplementation and override the getEncoding()
method to return the Charset of choice (windows-1252)
* Register this in the DataObject's lookup.  I'm using this in the DO
constructor:
CookieSet cookies = getCookieSet();
        cookies.assign(FileEncodingQueryImplementation.class,
                new NssFileEncodingQueryImplementation());

Not sure about forcing windows line endings yet, but I'll keep trying...



P



On Sun, Sep 30, 2018 at 9:00 AM Geertjan Wielenga
<ge...@googlemail.com.invalid> wrote:

> All these questions are hard to answer theoretically -- i.e., if you have
> something on GitHub that reproduces these problems, someone can look at
> them and help, i.e., create a simple NetBeans Platform application that
> contains these problematic areas and then someone can advise.
>
> Gj
>
> On Sat, Sep 29, 2018 at 2:25 PM Pete Whelpton <pe...@gmail.com> wrote:
>
>>
>> Hello all :) Apologies in advance for the newbie NBP questions.  I have
>> already been through the NBP API documentation and Netbeans sources, which
>> is how I've got to where I am, but I'm a bit stumped now.  Any pointers, no
>> matter how small, gratefully received!
>>
>>
>> 1)    Modular approach for project customizers (and sharing settings
>> between Modules)
>>
>>     * I have a module suite with a Project module, and two modules for
>> supported File Types, Nss and Tda
>>     * In the project module, I have a class that implements
>> AuxillaryProperties and reads/writes a .properties file.  This class is
>> registered in the Project Lookup
>>     * In the File Type modules, I have registered customizer panels with
>> @ProjectCustomizer.CompositeCategoryProvider.Registration
>>
>>     Q1)  ProjectUtils.getPreferences() returns null.  Why?  Looking at
>> the NB source, it seems like the factory creates the backing store by first
>> checking for an implementation of AuxillaryConfiguration in the
>> ProjectLookup, then for AuxillaryProperties.  I have an implementation of
>> AuxillaryProperties, so I'm not sure why it doesn't work.
>>
>>     I can get the properties by looking up AuxillaryProperties from in
>> Project lookup injected into the customizer panels - but the Netbeans API
>> documentation says not to directly use this interface...
>>
>>     Q2)  How to save changes for each panel?  I think that each panel
>> somehow needs to listen to the okOptionLister and implement its own save
>> operation, but that Listener is up in the Project.
>>
>>
>> 2) My Module Suite will no longer build unless I do a Clean & Build.
>> Regular build fails with the following error:
>>
>>     error: Refused to write invalid generated-layer.xml:
>> org.xml.sax.SAXParseException; lineNumber: 174; columnNumber: 43; The
>> element type "file" must be terminated by the matching end-tag "</file>".
>>
>>     The only generated-layer.xml file is the one for the Nss module.  The
>> XML around line 174 is:
>>
>>         <folder name="Preprocessor Directives">
>>             <file name="DirectiveInclude.xml">
>>                 <!--org.peedeeboy.oens.nss--><![CDATA[<!DOCTYPE
>> editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' '
>> http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>
>>                 <editor_palette_item version="1.1">
>>                     <body>  <![CDATA[#include "filename"]]]]><![CDATA[>
>> </body>
>>                         <icon16
>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>                         <icon32
>> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>>
>> <inline-description><display-name>Include</display-name><tooltip> <![CDATA[
>> Include external .nss
>> script]]]]><![CDATA[></tooltip></inline-description></editor_palette_item>]]></file>
>>         </folder>
>>
>>
>>     Q3) Why would this fail to be generated correctly on a Build, but not
>> on a Clean and Build?
>>
>>
>> 3) My NSS file type should always be opened/saved in CP-1252 encoding,
>> with Windows line endings
>>
>>     Q4) Where to implement this?  To try and get some clues, I've been
>> looking through the NB sources for how NB gets the encoding property for
>> Java projects and uses it for reading/writes .java files, but I haven't
>> found it...
>>
>>
>> Thanks and apologies again!
>>
>> P
>>
>

Re: [NBP] Some annoying questions..

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
All these questions are hard to answer theoretically -- i.e., if you have
something on GitHub that reproduces these problems, someone can look at
them and help, i.e., create a simple NetBeans Platform application that
contains these problematic areas and then someone can advise.

Gj

On Sat, Sep 29, 2018 at 2:25 PM Pete Whelpton <pe...@gmail.com> wrote:

>
> Hello all :) Apologies in advance for the newbie NBP questions.  I have
> already been through the NBP API documentation and Netbeans sources, which
> is how I've got to where I am, but I'm a bit stumped now.  Any pointers, no
> matter how small, gratefully received!
>
>
> 1)    Modular approach for project customizers (and sharing settings
> between Modules)
>
>     * I have a module suite with a Project module, and two modules for
> supported File Types, Nss and Tda
>     * In the project module, I have a class that implements
> AuxillaryProperties and reads/writes a .properties file.  This class is
> registered in the Project Lookup
>     * In the File Type modules, I have registered customizer panels with
> @ProjectCustomizer.CompositeCategoryProvider.Registration
>
>     Q1)  ProjectUtils.getPreferences() returns null.  Why?  Looking at the
> NB source, it seems like the factory creates the backing store by first
> checking for an implementation of AuxillaryConfiguration in the
> ProjectLookup, then for AuxillaryProperties.  I have an implementation of
> AuxillaryProperties, so I'm not sure why it doesn't work.
>
>     I can get the properties by looking up AuxillaryProperties from in
> Project lookup injected into the customizer panels - but the Netbeans API
> documentation says not to directly use this interface...
>
>     Q2)  How to save changes for each panel?  I think that each panel
> somehow needs to listen to the okOptionLister and implement its own save
> operation, but that Listener is up in the Project.
>
>
> 2) My Module Suite will no longer build unless I do a Clean & Build.
> Regular build fails with the following error:
>
>     error: Refused to write invalid generated-layer.xml:
> org.xml.sax.SAXParseException; lineNumber: 174; columnNumber: 43; The
> element type "file" must be terminated by the matching end-tag "</file>".
>
>     The only generated-layer.xml file is the one for the Nss module.  The
> XML around line 174 is:
>
>         <folder name="Preprocessor Directives">
>             <file name="DirectiveInclude.xml">
>                 <!--org.peedeeboy.oens.nss--><![CDATA[<!DOCTYPE
> editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' '
> http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>
>                 <editor_palette_item version="1.1">
>                     <body>  <![CDATA[#include "filename"]]]]><![CDATA[>
> </body>
>                         <icon16
> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>                         <icon32
> urlvalue="org/peedeeboy/oens/nss/icons/edit-number.png" />
>
> <inline-description><display-name>Include</display-name><tooltip> <![CDATA[
> Include external .nss
> script]]]]><![CDATA[></tooltip></inline-description></editor_palette_item>]]></file>
>         </folder>
>
>
>     Q3) Why would this fail to be generated correctly on a Build, but not
> on a Clean and Build?
>
>
> 3) My NSS file type should always be opened/saved in CP-1252 encoding,
> with Windows line endings
>
>     Q4) Where to implement this?  To try and get some clues, I've been
> looking through the NB sources for how NB gets the encoding property for
> Java projects and uses it for reading/writes .java files, but I haven't
> found it...
>
>
> Thanks and apologies again!
>
> P
>