|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
|
|
simple xml editorHello.
I'd like to develop a simple xml editor based on netbeans platform for a particular xml schema, something like the ide has for the web.xml file.. Just the explorer, the navigator, the editor and the output window. I have to say that even though I've been using netbeans since early 2001 for java development, I'm a beginner with module development. I just started working on the module with netbeans ide 5.0 (but tomorrow I'll upgrade to 5.5) and using the wizard, have already made a new file type for my xml namespace. Launching the new application, I see that my xml files are recognized, as the icon I set for this file type is shown. The first problem is that the new fileType seams to not have inherited all the functionalities used for xml files. 1) the well formed and validate buttons in the editor are disabled. 2) the navigator doesn't show anything But the editor still uses highlighting and colors.. Of course, when editing an xml file that doesn't use an xml schema the well formed and validate buttons are again enabled and the navigator again shows its content. How can I add all features present for plain xml files to my file type? I also would appreciate any hints and directions you could give me on how to implement the editor (wizards, apis, files to edit, etc..) Best regards. -- Roberto |
|
|
Re: simple xml editorRoberto Nunnari wrote:
> 1) the well formed and validate buttons in the editor are disabled. I think you need to add CheckXMLSupport and ValidateXMLSupport cookies to your DataObject. Here is a wiki page describing how to do that - http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType. > 2) the navigator doesn't show anything You probably need to register a navigator panel implementation for your mime type. I think you could reuse the panel registered for text/xml files. The registration will have to be done on your XML layer and should be looking something like this: <folder name="Navigator"> <folder name="Panels"> <folder name="text"> <folder name="your-mime-type"> <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> </folder> </folder> </folder> </folder> Just for a reference here is a description of Navigator API - http://www.netbeans.org/download/dev/javadoc/org-netbeans-spi-navigator/index.html?overview-summary.html. You probably won't need it unless you want to implement your own navigator panel. Good luck, -vita |
|
|
Re: simple xml editorIf you are creating a new file type for an xml document, provide the MIME type ending with +xml. MIME types likeHope this helps, -ernie Roberto Nunnari wrote: Hello. |
|
|
Re: simple xml editor
Hi Roberto,
I hope you are creating a new file type for an xml document which ends with +xml. MIME types like text/???+xml
are used in the IDE to represent an XML document. Creating a filetype
like this, IDE will treat your files as an XML
document. Netbeans Editor will provide all functionality like code
highlighting, indent, code folding, code completion and any other to
your xml document. To get the schema based code completion for your xml files, you have to install enterprise pack. Once you install NB enterprise pack, run your module project, and create new file (that is your xml document). In your xml document, provide the value for schemaLocation attribute which will be the relative or absolute location of your schema file. Just doing this will give you the schema support for your xml files. Please note that Currently schema-based code completion for xml files works only if we provide value for 'schemaLocation' attribute and the value should be relative or absolute path of xsd file on the filesystem. Schema based Code Completion is not available through XML catalog. I have filed an issue (fix in progress) on Netbeans XML component to provide Schema based Code Completion through XML catalog. To get validate, checkXml, Transformable support, you have to add the following code to your DataObject. Refer this link for the same http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType CookieSet cookies = getCookieSet();To get the Navigator support for your xml files Add following code in your layer.xml file (with your xml MIME type) <folder name="Navigator">Thanks & Regards, Vivek ------------------------------------ http://www.netbeans.org/ http://www.sun.com/ ------------------------------------ Roberto Nunnari wrote: Hello. Just the explorer, the navigator, the editor and the output window. 2) the navigator doesn't show anything
|
|
|
Re: simple xml editorVivek Jain wrote:
> Hi Roberto, Hi Vivek, > > I hope you are creating a new file type for an xml document which ends > with +xml. MIME types like |text/???+xml| are used in the IDE to I used text/x-sposi+xml Is that correct? > represent an XML document. Creating a filetype like this, IDE will treat > your files as an XML document. Netbeans Editor will provide all > functionality like code highlighting, indent, code folding, code > completion and any other to your xml document. Yes.. That works just fine. > > To get the schema based code completion for your xml files, you have to > install enterprise pack. Once you install NB enterprise pack, run your I haven't checked code completion, yet. > module project, and create new file (that is your xml document). In your > xml document, provide the value for schemaLocation attribute which will > be the relative or absolute location of your schema file. Just doing > this will give you the schema support for your xml files. The xml is correct, as I can validate it using other tools.. But.. here's how my xml file starts: <?xml version="1.0" encoding="UTF-8"?> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi http://www.nunnisoft.ch/schemas/sposi01.xsd" xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... > > Please note that Currently schema-based code completion for xml files > works only if we provide value for 'schemaLocation' attribute and the > value should be relative or absolute path of xsd file on the filesystem. > Schema based Code Completion is not available through XML catalog. I > have filed an issue > <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in progress) > on Netbeans XML component to provide Schema based Code Completion > through XML catalog. > > To get validate, checkXml, Transformable support, you have to add the > following code to your DataObject. Refer this link for the same > http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType > > CookieSet cookies = getCookieSet(); > cookieManager = new DataObjectCookieManager(this, cookies); > cookies.add((Node.Cookie) DataEditorSupport.create(this, > getPrimaryEntry(), cookies)); > > InputSource is = DataObjectAdapters.inputSource(this); > Source source = DataObjectAdapters.source(this); > > cookies.add(new CheckXMLSupport(is)); > cookies.add(new ValidateXMLSupport(is)); > cookies.add(new TransformableSupport(source)); > > To get the Navigator support for your xml files Add following code in > your layer.xml file (with your xml MIME type) > > <folder name="Navigator"> > <folder name="Panels"> > <folder name="text"> > <folder name="MIME_TYPE"> > <file > name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> > </folder> > </folder> > </folder> > </folder> > Ok. Thanks a lot to all who answered my question. I'll try that as soon as possible and let you know the result. Best regards. Roberto > Thanks & Regards, > Vivek > ------------------------------------ > http://www.netbeans.org/ > http://www.sun.com/ > ------------------------------------ > > Roberto Nunnari wrote: >> Hello. >> >> I'd like to develop a simple xml editor based on netbeans platform for >> a particular xml schema, something like the ide has for the web.xml file. >> Just the explorer, the navigator, the editor and the output window. >> >> I have to say that even though I've been using netbeans since early >> 2001 for java development, I'm a beginner with module development. >> >> I just started working on the module with netbeans ide 5.0 (but >> tomorrow I'll upgrade to 5.5) and using the wizard, have already made >> a new file type for my xml namespace. >> >> Launching the new application, I see that my xml files are recognized, >> as the icon I set for this file type is shown. >> >> The first problem is that the new fileType seams to not have inherited >> all the functionalities used for xml files. >> >> 1) the well formed and validate buttons in the editor are disabled. >> 2) the navigator doesn't show anything >> >> But the editor still uses highlighting and colors.. >> >> Of course, when editing an xml file that doesn't use an xml schema the >> well formed and validate buttons are again enabled and the >> navigator again shows its content. >> >> How can I add all features present for plain xml files to my file type? >> >> I also would appreciate any hints and directions you could give me on >> how to implement the editor (wizards, apis, files to edit, etc..) >> >> Best regards. >> >> -- >> Roberto |
|
|
Re: simple xml editorI added the Enterprise pack but the ide still cannot find the
following classes: import org.netbeans.modules.xml.core.XMLDataObjectLook; import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; import org.netbeans.modules.xml.core.sync.Synchronizator; import org.netbeans.modules.xml.core.text.TextEditorSupport; import org.netbeans.spi.xml.cookies.CheckXMLSupport; import org.netbeans.spi.xml.cookies.DataObjectAdapters; import org.netbeans.spi.xml.cookies.ValidateXMLSupport; Where are the above classes? Best regards. Roberto Roberto Nunnari wrote: > Vivek Jain wrote: >> Hi Roberto, > > Hi Vivek, > > >> >> I hope you are creating a new file type for an xml document which ends >> with +xml. MIME types like |text/???+xml| are used in the IDE to > > I used text/x-sposi+xml > Is that correct? > > >> represent an XML document. Creating a filetype like this, IDE will >> treat your files as an XML document. Netbeans Editor will provide all >> functionality like code highlighting, indent, code folding, code >> completion and any other to your xml document. > > Yes.. That works just fine. > > >> >> To get the schema based code completion for your xml files, you have >> to install enterprise pack. Once you install NB enterprise pack, run your > > I haven't checked code completion, yet. > > >> module project, and create new file (that is your xml document). In >> your xml document, provide the value for schemaLocation attribute >> which will be the relative or absolute location of your schema file. >> Just doing this will give you the schema support for your xml files. > > The xml is correct, as I can validate it using other tools.. > But.. here's how my xml file starts: > > <?xml version="1.0" encoding="UTF-8"?> > <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi > http://www.nunnisoft.ch/schemas/sposi01.xsd" > xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > ... > > >> >> Please note that Currently schema-based code completion for xml files >> works only if we provide value for 'schemaLocation' attribute and the >> value should be relative or absolute path of xsd file on the >> filesystem. Schema based Code Completion is not available through XML >> catalog. I have filed an issue >> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >> progress) on Netbeans XML component to provide Schema based Code >> Completion through XML catalog. >> >> To get validate, checkXml, Transformable support, you have to add the >> following code to your DataObject. Refer this link for the same >> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >> >> CookieSet cookies = getCookieSet(); >> cookieManager = new DataObjectCookieManager(this, cookies); >> cookies.add((Node.Cookie) DataEditorSupport.create(this, >> getPrimaryEntry(), cookies)); >> InputSource is = >> DataObjectAdapters.inputSource(this); >> Source source = DataObjectAdapters.source(this); >> cookies.add(new CheckXMLSupport(is)); >> cookies.add(new ValidateXMLSupport(is)); >> cookies.add(new TransformableSupport(source)); >> >> To get the Navigator support for your xml files Add following code in >> your layer.xml file (with your xml MIME type) >> >> <folder name="Navigator"> >> <folder name="Panels"> >> <folder name="text"> >> <folder name="MIME_TYPE"> >> <file >> >> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >> >> </folder> >> </folder> >> </folder> >> </folder> >> > > Ok. Thanks a lot to all who answered my question. > I'll try that as soon as possible and let you know the result. > > Best regards. > Roberto > > >> Thanks & Regards, >> Vivek >> ------------------------------------ >> http://www.netbeans.org/ >> http://www.sun.com/ >> ------------------------------------ >> >> Roberto Nunnari wrote: >>> Hello. >>> >>> I'd like to develop a simple xml editor based on netbeans platform >>> for a particular xml schema, something like the ide has for the >>> web.xml file. Just the explorer, the navigator, the editor and the >>> output window. >>> >>> I have to say that even though I've been using netbeans since early >>> 2001 for java development, I'm a beginner with module development. >>> >>> I just started working on the module with netbeans ide 5.0 (but >>> tomorrow I'll upgrade to 5.5) and using the wizard, have already made >>> a new file type for my xml namespace. >>> >>> Launching the new application, I see that my xml files are >>> recognized, as the icon I set for this file type is shown. >>> >>> The first problem is that the new fileType seams to not have >>> inherited all the functionalities used for xml files. >>> >>> 1) the well formed and validate buttons in the editor are disabled. >>> 2) the navigator doesn't show anything >>> >>> But the editor still uses highlighting and colors.. >>> >>> Of course, when editing an xml file that doesn't use an xml schema >>> the well formed and validate buttons are again enabled and the >>> navigator again shows its content. >>> >>> How can I add all features present for plain xml files to my file type? >>> >>> I also would appreciate any hints and directions you could give me on >>> how to implement the editor (wizards, apis, files to edit, etc..) >>> >>> Best regards. >>> >>> -- >>> Roberto |
|
|
Re: simple xml editorRoberto Nunnari wrote:
> I added the Enterprise pack but the ide still cannot find the > following classes: > > import org.netbeans.modules.xml.core.XMLDataObjectLook; > import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; > import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; > import org.netbeans.modules.xml.core.sync.Synchronizator; > import org.netbeans.modules.xml.core.text.TextEditorSupport; I'm not sure about these. Why do you need them? > import org.netbeans.spi.xml.cookies.CheckXMLSupport; > import org.netbeans.spi.xml.cookies.DataObjectAdapters; > import org.netbeans.spi.xml.cookies.ValidateXMLSupport; These ones should be in xml/api module. It should be enough to just type the name of one of those classes in the Add Module Dependency dialog. If it's not working, there might be something wrong with the Netbeans platform you are using for development. -vita |
|
|
Re: simple xml editorHi Roberto,
Your module require an implementation dependency on 'XML Core' for following packages: import org.netbeans.modules.xml.core.XMLDataObjectLook; import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; import org.netbeans.modules.xml.core.sync.Synchronizator; import org.netbeans.modules.xml.core.text.TextEditorSupport; Also add dependency on 'XML Tools API' for remaining packages: import org.netbeans.spi.xml.cookies.CheckXMLSupport; import org.netbeans.spi.xml.cookies.DataObjectAdapters; import org.netbeans.spi.xml.cookies.ValidateXMLSupport; Thanks, Vivek http://www.netbeans.org/ http://www.sun.com/ Roberto Nunnari wrote: > I added the Enterprise pack but the ide still cannot find the > following classes: > > import org.netbeans.modules.xml.core.XMLDataObjectLook; > import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; > import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; > import org.netbeans.modules.xml.core.sync.Synchronizator; > import org.netbeans.modules.xml.core.text.TextEditorSupport; > import org.netbeans.spi.xml.cookies.CheckXMLSupport; > import org.netbeans.spi.xml.cookies.DataObjectAdapters; > import org.netbeans.spi.xml.cookies.ValidateXMLSupport; > > Where are the above classes? > > Best regards. > Roberto > > > Roberto Nunnari wrote: >> Vivek Jain wrote: >>> Hi Roberto, >> >> Hi Vivek, >> >> >>> >>> I hope you are creating a new file type for an xml document which >>> ends with +xml. MIME types like |text/???+xml| are used in the IDE to >> >> I used text/x-sposi+xml >> Is that correct? >> >> >>> represent an XML document. Creating a filetype like this, IDE will >>> treat your files as an XML document. Netbeans Editor will provide >>> all functionality like code highlighting, indent, code folding, code >>> completion and any other to your xml document. >> >> Yes.. That works just fine. >> >> >>> >>> To get the schema based code completion for your xml files, you have >>> to install enterprise pack. Once you install NB enterprise pack, run >>> your >> >> I haven't checked code completion, yet. >> >> >>> module project, and create new file (that is your xml document). In >>> your xml document, provide the value for schemaLocation attribute >>> which will be the relative or absolute location of your schema file. >>> Just doing this will give you the schema support for your xml files. >> >> The xml is correct, as I can validate it using other tools.. >> But.. here's how my xml file starts: >> >> <?xml version="1.0" encoding="UTF-8"?> >> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >> http://www.nunnisoft.ch/schemas/sposi01.xsd" >> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >> ... >> >> >>> >>> Please note that Currently schema-based code completion for xml >>> files works only if we provide value for 'schemaLocation' attribute >>> and the value should be relative or absolute path of xsd file on the >>> filesystem. Schema based Code Completion is not available through >>> XML catalog. I have filed an issue >>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>> progress) on Netbeans XML component to provide Schema based Code >>> Completion through XML catalog. >>> >>> To get validate, checkXml, Transformable support, you have to add >>> the following code to your DataObject. Refer this link for the same >>> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>> >>> CookieSet cookies = getCookieSet(); >>> cookieManager = new DataObjectCookieManager(this, cookies); >>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>> getPrimaryEntry(), cookies)); >>> InputSource is = >>> DataObjectAdapters.inputSource(this); >>> Source source = DataObjectAdapters.source(this); >>> cookies.add(new CheckXMLSupport(is)); >>> cookies.add(new ValidateXMLSupport(is)); >>> cookies.add(new TransformableSupport(source)); >>> >>> To get the Navigator support for your xml files Add following code >>> in your layer.xml file (with your xml MIME type) >>> >>> <folder name="Navigator"> >>> <folder name="Panels"> >>> <folder name="text"> >>> <folder name="MIME_TYPE"> >>> <file >>> >>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>> >>> </folder> >>> </folder> >>> </folder> >>> </folder> >>> >> >> Ok. Thanks a lot to all who answered my question. >> I'll try that as soon as possible and let you know the result. >> >> Best regards. >> Roberto >> >> >>> Thanks & Regards, >>> Vivek >>> ------------------------------------ >>> http://www.netbeans.org/ >>> http://www.sun.com/ >>> ------------------------------------ >>> >>> Roberto Nunnari wrote: >>>> Hello. >>>> >>>> I'd like to develop a simple xml editor based on netbeans platform >>>> for a particular xml schema, something like the ide has for the >>>> web.xml file. Just the explorer, the navigator, the editor and the >>>> output window. >>>> >>>> I have to say that even though I've been using netbeans since early >>>> 2001 for java development, I'm a beginner with module development. >>>> >>>> I just started working on the module with netbeans ide 5.0 (but >>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>> made a new file type for my xml namespace. >>>> >>>> Launching the new application, I see that my xml files are >>>> recognized, as the icon I set for this file type is shown. >>>> >>>> The first problem is that the new fileType seams to not have >>>> inherited all the functionalities used for xml files. >>>> >>>> 1) the well formed and validate buttons in the editor are disabled. >>>> 2) the navigator doesn't show anything >>>> >>>> But the editor still uses highlighting and colors.. >>>> >>>> Of course, when editing an xml file that doesn't use an xml schema >>>> the well formed and validate buttons are again enabled and the >>>> navigator again shows its content. >>>> >>>> How can I add all features present for plain xml files to my file >>>> type? >>>> >>>> I also would appreciate any hints and directions you could give me >>>> on how to implement the editor (wizards, apis, files to edit, etc..) >>>> >>>> Best regards. >>>> >>>> -- >>>> Roberto |
|
|
Re: simple xml editorHi Vivek.
I went to my module properties --> Libraries and Add Dependency - XML Core - XML Tools API Now the 'Fix imports' command gets correctly all the packages but trying to compile fails with the following errors: package org.netbeans.modules.xml.core.cookies does not exist package org.netbeans.modules.xml.core.sync does not exist What do I get wrong? Vivek Jain wrote: > Hi Roberto, > > Your module require an implementation dependency on 'XML Core' for > following packages: > import org.netbeans.modules.xml.core.XMLDataObjectLook; > import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; > import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; > import org.netbeans.modules.xml.core.sync.Synchronizator; > import org.netbeans.modules.xml.core.text.TextEditorSupport; > > Also add dependency on 'XML Tools API' for remaining packages: > import org.netbeans.spi.xml.cookies.CheckXMLSupport; > import org.netbeans.spi.xml.cookies.DataObjectAdapters; > import org.netbeans.spi.xml.cookies.ValidateXMLSupport; > > Thanks, > Vivek > > http://www.netbeans.org/ > http://www.sun.com/ > > > > Roberto Nunnari wrote: >> I added the Enterprise pack but the ide still cannot find the >> following classes: >> >> import org.netbeans.modules.xml.core.XMLDataObjectLook; >> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >> import org.netbeans.modules.xml.core.sync.Synchronizator; >> import org.netbeans.modules.xml.core.text.TextEditorSupport; >> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >> >> Where are the above classes? >> >> Best regards. >> Roberto >> >> >> Roberto Nunnari wrote: >>> Vivek Jain wrote: >>>> Hi Roberto, >>> >>> Hi Vivek, >>> >>> >>>> >>>> I hope you are creating a new file type for an xml document which >>>> ends with +xml. MIME types like |text/???+xml| are used in the IDE to >>> >>> I used text/x-sposi+xml >>> Is that correct? >>> >>> >>>> represent an XML document. Creating a filetype like this, IDE will >>>> treat your files as an XML document. Netbeans Editor will provide >>>> all functionality like code highlighting, indent, code folding, code >>>> completion and any other to your xml document. >>> >>> Yes.. That works just fine. >>> >>> >>>> >>>> To get the schema based code completion for your xml files, you have >>>> to install enterprise pack. Once you install NB enterprise pack, run >>>> your >>> >>> I haven't checked code completion, yet. >>> >>> >>>> module project, and create new file (that is your xml document). In >>>> your xml document, provide the value for schemaLocation attribute >>>> which will be the relative or absolute location of your schema file. >>>> Just doing this will give you the schema support for your xml files. >>> >>> The xml is correct, as I can validate it using other tools.. >>> But.. here's how my xml file starts: >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >>> http://www.nunnisoft.ch/schemas/sposi01.xsd" >>> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>> ... >>> >>> >>>> >>>> Please note that Currently schema-based code completion for xml >>>> files works only if we provide value for 'schemaLocation' attribute >>>> and the value should be relative or absolute path of xsd file on the >>>> filesystem. Schema based Code Completion is not available through >>>> XML catalog. I have filed an issue >>>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>>> progress) on Netbeans XML component to provide Schema based Code >>>> Completion through XML catalog. >>>> >>>> To get validate, checkXml, Transformable support, you have to add >>>> the following code to your DataObject. Refer this link for the same >>>> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>>> >>>> CookieSet cookies = getCookieSet(); >>>> cookieManager = new DataObjectCookieManager(this, cookies); >>>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>>> getPrimaryEntry(), cookies)); >>>> InputSource is = >>>> DataObjectAdapters.inputSource(this); >>>> Source source = DataObjectAdapters.source(this); >>>> cookies.add(new CheckXMLSupport(is)); >>>> cookies.add(new ValidateXMLSupport(is)); >>>> cookies.add(new TransformableSupport(source)); >>>> >>>> To get the Navigator support for your xml files Add following code >>>> in your layer.xml file (with your xml MIME type) >>>> >>>> <folder name="Navigator"> >>>> <folder name="Panels"> >>>> <folder name="text"> >>>> <folder name="MIME_TYPE"> >>>> <file >>>> >>>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>>> >>>> </folder> >>>> </folder> >>>> </folder> >>>> </folder> >>>> >>> >>> Ok. Thanks a lot to all who answered my question. >>> I'll try that as soon as possible and let you know the result. >>> >>> Best regards. >>> Roberto >>> >>> >>>> Thanks & Regards, >>>> Vivek >>>> ------------------------------------ >>>> http://www.netbeans.org/ >>>> http://www.sun.com/ >>>> ------------------------------------ >>>> >>>> Roberto Nunnari wrote: >>>>> Hello. >>>>> >>>>> I'd like to develop a simple xml editor based on netbeans platform >>>>> for a particular xml schema, something like the ide has for the >>>>> web.xml file. Just the explorer, the navigator, the editor and the >>>>> output window. >>>>> >>>>> I have to say that even though I've been using netbeans since early >>>>> 2001 for java development, I'm a beginner with module development. >>>>> >>>>> I just started working on the module with netbeans ide 5.0 (but >>>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>>> made a new file type for my xml namespace. >>>>> >>>>> Launching the new application, I see that my xml files are >>>>> recognized, as the icon I set for this file type is shown. >>>>> >>>>> The first problem is that the new fileType seams to not have >>>>> inherited all the functionalities used for xml files. >>>>> >>>>> 1) the well formed and validate buttons in the editor are disabled. >>>>> 2) the navigator doesn't show anything >>>>> >>>>> But the editor still uses highlighting and colors.. >>>>> >>>>> Of course, when editing an xml file that doesn't use an xml schema >>>>> the well formed and validate buttons are again enabled and the >>>>> navigator again shows its content. >>>>> >>>>> How can I add all features present for plain xml files to my file >>>>> type? >>>>> >>>>> I also would appreciate any hints and directions you could give me >>>>> on how to implement the editor (wizards, apis, files to edit, etc..) >>>>> >>>>> Best regards. >>>>> >>>>> -- >>>>> Roberto |
|
|
Re: simple xml editorVitezslav Stejskal wrote:
> Roberto Nunnari wrote: >> I added the Enterprise pack but the ide still cannot find the >> following classes: >> >> import org.netbeans.modules.xml.core.XMLDataObjectLook; >> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >> import org.netbeans.modules.xml.core.sync.Synchronizator; >> import org.netbeans.modules.xml.core.text.TextEditorSupport; > I'm not sure about these. Why do you need them? They're used in the java code shown in the page you first pointed me to.. > >> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; > These ones should be in xml/api module. It should be enough to just type > the name of one of those classes in the Add Module Dependency dialog. If > it's not working, there might be something wrong with the Netbeans > platform you are using for development. See the messages in this thread. Vivek has answered how to add them.. but I still have trouble with DataObjectCookieManager and Synchronizator. Best regards. Roberto > > -vita |
|
|
Re: simple xml editorHi Vivek.
I'm not sure what this means, but I found this in org.netbeans.modules.xml.core.META-INF.MANIFEST.MF ... OpenIDE-Module-Public-Packages: org.netbeans.modules.xml.api.*, org.ne tbeans.modules.xml.api.model.*, org.netbeans.modules.xml.spi.dom.* ... If that lists the packages that are publicly usable then DataObjectCookieManager and Synchronizator are not usable.. Anyways.. taking out DataObjectCookieManager and Synchronizator from my code, gives me an application that compiles and run, but just like before, I don't get generic xml functionalities for my xml flavor. Is the following correct? I put this at the end of layer.xml: <folder name="Navigator"> <folder name="Panels"> <folder name="text"> <folder name="text/x-sposi+xml"> <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> </folder> </folder> </folder> </folder> </filesystem> If not, please correct me. Best regards. Roberto Vivek Jain wrote: > Hi Roberto, > > Your module require an implementation dependency on 'XML Core' for > following packages: > import org.netbeans.modules.xml.core.XMLDataObjectLook; > import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; > import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; > import org.netbeans.modules.xml.core.sync.Synchronizator; > import org.netbeans.modules.xml.core.text.TextEditorSupport; > > Also add dependency on 'XML Tools API' for remaining packages: > import org.netbeans.spi.xml.cookies.CheckXMLSupport; > import org.netbeans.spi.xml.cookies.DataObjectAdapters; > import org.netbeans.spi.xml.cookies.ValidateXMLSupport; > > Thanks, > Vivek > > http://www.netbeans.org/ > http://www.sun.com/ > > > > Roberto Nunnari wrote: >> I added the Enterprise pack but the ide still cannot find the >> following classes: >> >> import org.netbeans.modules.xml.core.XMLDataObjectLook; >> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >> import org.netbeans.modules.xml.core.sync.Synchronizator; >> import org.netbeans.modules.xml.core.text.TextEditorSupport; >> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >> >> Where are the above classes? >> >> Best regards. >> Roberto >> >> >> Roberto Nunnari wrote: >>> Vivek Jain wrote: >>>> Hi Roberto, >>> >>> Hi Vivek, >>> >>> >>>> >>>> I hope you are creating a new file type for an xml document which >>>> ends with +xml. MIME types like |text/???+xml| are used in the IDE to >>> >>> I used text/x-sposi+xml >>> Is that correct? >>> >>> >>>> represent an XML document. Creating a filetype like this, IDE will >>>> treat your files as an XML document. Netbeans Editor will provide >>>> all functionality like code highlighting, indent, code folding, code >>>> completion and any other to your xml document. >>> >>> Yes.. That works just fine. >>> >>> >>>> >>>> To get the schema based code completion for your xml files, you have >>>> to install enterprise pack. Once you install NB enterprise pack, run >>>> your >>> >>> I haven't checked code completion, yet. >>> >>> >>>> module project, and create new file (that is your xml document). In >>>> your xml document, provide the value for schemaLocation attribute >>>> which will be the relative or absolute location of your schema file. >>>> Just doing this will give you the schema support for your xml files. >>> >>> The xml is correct, as I can validate it using other tools.. >>> But.. here's how my xml file starts: >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >>> http://www.nunnisoft.ch/schemas/sposi01.xsd" >>> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>> ... >>> >>> >>>> >>>> Please note that Currently schema-based code completion for xml >>>> files works only if we provide value for 'schemaLocation' attribute >>>> and the value should be relative or absolute path of xsd file on the >>>> filesystem. Schema based Code Completion is not available through >>>> XML catalog. I have filed an issue >>>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>>> progress) on Netbeans XML component to provide Schema based Code >>>> Completion through XML catalog. >>>> >>>> To get validate, checkXml, Transformable support, you have to add >>>> the following code to your DataObject. Refer this link for the same >>>> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>>> >>>> CookieSet cookies = getCookieSet(); >>>> cookieManager = new DataObjectCookieManager(this, cookies); >>>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>>> getPrimaryEntry(), cookies)); >>>> InputSource is = >>>> DataObjectAdapters.inputSource(this); >>>> Source source = DataObjectAdapters.source(this); >>>> cookies.add(new CheckXMLSupport(is)); >>>> cookies.add(new ValidateXMLSupport(is)); >>>> cookies.add(new TransformableSupport(source)); >>>> >>>> To get the Navigator support for your xml files Add following code >>>> in your layer.xml file (with your xml MIME type) >>>> >>>> <folder name="Navigator"> >>>> <folder name="Panels"> >>>> <folder name="text"> >>>> <folder name="MIME_TYPE"> >>>> <file >>>> >>>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>>> >>>> </folder> >>>> </folder> >>>> </folder> >>>> </folder> >>>> >>> >>> Ok. Thanks a lot to all who answered my question. >>> I'll try that as soon as possible and let you know the result. >>> >>> Best regards. >>> Roberto >>> >>> >>>> Thanks & Regards, >>>> Vivek >>>> ------------------------------------ >>>> http://www.netbeans.org/ >>>> http://www.sun.com/ >>>> ------------------------------------ >>>> >>>> Roberto Nunnari wrote: >>>>> Hello. >>>>> >>>>> I'd like to develop a simple xml editor based on netbeans platform >>>>> for a particular xml schema, something like the ide has for the >>>>> web.xml file. Just the explorer, the navigator, the editor and the >>>>> output window. >>>>> >>>>> I have to say that even though I've been using netbeans since early >>>>> 2001 for java development, I'm a beginner with module development. >>>>> >>>>> I just started working on the module with netbeans ide 5.0 (but >>>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>>> made a new file type for my xml namespace. >>>>> >>>>> Launching the new application, I see that my xml files are >>>>> recognized, as the icon I set for this file type is shown. >>>>> >>>>> The first problem is that the new fileType seams to not have >>>>> inherited all the functionalities used for xml files. >>>>> >>>>> 1) the well formed and validate buttons in the editor are disabled. >>>>> 2) the navigator doesn't show anything >>>>> >>>>> But the editor still uses highlighting and colors.. >>>>> >>>>> Of course, when editing an xml file that doesn't use an xml schema >>>>> the well formed and validate buttons are again enabled and the >>>>> navigator again shows its content. >>>>> >>>>> How can I add all features present for plain xml files to my file >>>>> type? >>>>> >>>>> I also would appreciate any hints and directions you could give me >>>>> on how to implement the editor (wizards, apis, files to edit, etc..) >>>>> >>>>> Best regards. >>>>> >>>>> -- >>>>> Roberto |
|
|
Re: simple xml editorGreat Vivek!
I didn't notice before, because I stopped checking if it was working after verifying that the navigator is still empty.. but checking again.. **XML well formed and XML validation now work!** I just had to take away DataObjectCookieManager and Synchronizator from your code and now well-formed and validation checks work! Now I still have to get the navigator show and let navigate the xml elements of my xml flavor documents. For navigator to work, I tried to modify layer.xml as you said, but for sure I did miss something.. Could you please tell me what's wrong with my layer.xml? You can see it here: http://www.nunnisoft.ch/downloads/layer.xml Thank you and best regards. Roberto Vivek Jain wrote: > Hi Roberto, > > Your module require an implementation dependency on 'XML Core' for > following packages: > import org.netbeans.modules.xml.core.XMLDataObjectLook; > import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; > import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; > import org.netbeans.modules.xml.core.sync.Synchronizator; > import org.netbeans.modules.xml.core.text.TextEditorSupport; > > Also add dependency on 'XML Tools API' for remaining packages: > import org.netbeans.spi.xml.cookies.CheckXMLSupport; > import org.netbeans.spi.xml.cookies.DataObjectAdapters; > import org.netbeans.spi.xml.cookies.ValidateXMLSupport; > > Thanks, > Vivek > > http://www.netbeans.org/ > http://www.sun.com/ > > > > Roberto Nunnari wrote: >> I added the Enterprise pack but the ide still cannot find the >> following classes: >> >> import org.netbeans.modules.xml.core.XMLDataObjectLook; >> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >> import org.netbeans.modules.xml.core.sync.Synchronizator; >> import org.netbeans.modules.xml.core.text.TextEditorSupport; >> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >> >> Where are the above classes? >> >> Best regards. >> Roberto >> >> >> Roberto Nunnari wrote: >>> Vivek Jain wrote: >>>> Hi Roberto, >>> >>> Hi Vivek, >>> >>> >>>> >>>> I hope you are creating a new file type for an xml document which >>>> ends with +xml. MIME types like |text/???+xml| are used in the IDE to >>> >>> I used text/x-sposi+xml >>> Is that correct? >>> >>> >>>> represent an XML document. Creating a filetype like this, IDE will >>>> treat your files as an XML document. Netbeans Editor will provide >>>> all functionality like code highlighting, indent, code folding, code >>>> completion and any other to your xml document. >>> >>> Yes.. That works just fine. >>> >>> >>>> >>>> To get the schema based code completion for your xml files, you have >>>> to install enterprise pack. Once you install NB enterprise pack, run >>>> your >>> >>> I haven't checked code completion, yet. >>> >>> >>>> module project, and create new file (that is your xml document). In >>>> your xml document, provide the value for schemaLocation attribute >>>> which will be the relative or absolute location of your schema file. >>>> Just doing this will give you the schema support for your xml files. >>> >>> The xml is correct, as I can validate it using other tools.. >>> But.. here's how my xml file starts: >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >>> http://www.nunnisoft.ch/schemas/sposi01.xsd" >>> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>> ... >>> >>> >>>> >>>> Please note that Currently schema-based code completion for xml >>>> files works only if we provide value for 'schemaLocation' attribute >>>> and the value should be relative or absolute path of xsd file on the >>>> filesystem. Schema based Code Completion is not available through >>>> XML catalog. I have filed an issue >>>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>>> progress) on Netbeans XML component to provide Schema based Code >>>> Completion through XML catalog. >>>> >>>> To get validate, checkXml, Transformable support, you have to add >>>> the following code to your DataObject. Refer this link for the same >>>> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>>> >>>> CookieSet cookies = getCookieSet(); >>>> cookieManager = new DataObjectCookieManager(this, cookies); >>>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>>> getPrimaryEntry(), cookies)); >>>> InputSource is = >>>> DataObjectAdapters.inputSource(this); >>>> Source source = DataObjectAdapters.source(this); >>>> cookies.add(new CheckXMLSupport(is)); >>>> cookies.add(new ValidateXMLSupport(is)); >>>> cookies.add(new TransformableSupport(source)); >>>> >>>> To get the Navigator support for your xml files Add following code >>>> in your layer.xml file (with your xml MIME type) >>>> >>>> <folder name="Navigator"> >>>> <folder name="Panels"> >>>> <folder name="text"> >>>> <folder name="MIME_TYPE"> >>>> <file >>>> >>>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>>> >>>> </folder> >>>> </folder> >>>> </folder> >>>> </folder> >>>> >>> >>> Ok. Thanks a lot to all who answered my question. >>> I'll try that as soon as possible and let you know the result. >>> >>> Best regards. >>> Roberto >>> >>> >>>> Thanks & Regards, >>>> Vivek >>>> ------------------------------------ >>>> http://www.netbeans.org/ >>>> http://www.sun.com/ >>>> ------------------------------------ >>>> >>>> Roberto Nunnari wrote: >>>>> Hello. >>>>> >>>>> I'd like to develop a simple xml editor based on netbeans platform >>>>> for a particular xml schema, something like the ide has for the >>>>> web.xml file. Just the explorer, the navigator, the editor and the >>>>> output window. >>>>> >>>>> I have to say that even though I've been using netbeans since early >>>>> 2001 for java development, I'm a beginner with module development. >>>>> >>>>> I just started working on the module with netbeans ide 5.0 (but >>>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>>> made a new file type for my xml namespace. >>>>> >>>>> Launching the new application, I see that my xml files are >>>>> recognized, as the icon I set for this file type is shown. >>>>> >>>>> The first problem is that the new fileType seams to not have >>>>> inherited all the functionalities used for xml files. >>>>> >>>>> 1) the well formed and validate buttons in the editor are disabled. >>>>> 2) the navigator doesn't show anything >>>>> >>>>> But the editor still uses highlighting and colors.. >>>>> >>>>> Of course, when editing an xml file that doesn't use an xml schema >>>>> the well formed and validate buttons are again enabled and the >>>>> navigator again shows its content. >>>>> >>>>> How can I add all features present for plain xml files to my file >>>>> type? >>>>> >>>>> I also would appreciate any hints and directions you could give me >>>>> on how to implement the editor (wizards, apis, files to edit, etc..) >>>>> >>>>> Best regards. >>>>> >>>>> -- >>>>> Roberto |
|
|
Clicking TopComponent tab eventHi Everybody,
Is there a way to differentiate between a case when a user clicks on TopComponent tab and other cases when TopComponent gets activated programmatically? I want to do some action only in case a user clicks TopComponent tab, so TopComponent.componentActivated() doesn't do a job for me. Thank you, Kate |
|
|
Re: simple xml editor
Hi Roberto, please see my comments inline...
Regards, Vivek http://www.netbeans.org/ http://www.sun.com/ Roberto Nunnari wrote: Great Vivek!package org.netbeans.modules.xml.core.cookies does not exist package org.netbeans.modules.xml.core.sync does not exist Just adding simple dependency will not work because these API's are not public. To use these packages, you need establish implementation dependency or become friend of XML Core. BTW, I have filed an issue 91617 to make these API public. To add implementation dependency, go to Module Properties -> Libraries -> XML Core -> Edit and select Implementation Version. This will solve the problem. Regards, Vivek The entry for navigator panel in your layer.xml should look like following, and it will work: <folder name="Navigator"> <folder name="Panels"> <folder name="text"> <folder name="x-sposi+xml"> <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> </folder> </folder> </folder> </folder>
|
|
|
Re: Clicking TopComponent tab eventI don't know if there's a better way, but maybe adding a mouse
listener to the TopComponent would work. On 1/22/07, Kate Dvortsova <kate.dvortsova@...> wrote: > Hi Everybody, > > Is there a way to differentiate between a case when a user clicks on > TopComponent tab and other cases when TopComponent gets activated > programmatically? > > I want to do some action only in case a user clicks TopComponent tab, so > TopComponent.componentActivated() doesn't do a job for me. > > Thank you, > > Kate > > > > -- -- Tom Wheeler http://www.tomwheeler.com/ |
|
|
Re: Clicking TopComponent tab eventTom Wheeler wrote:
> I don't know if there's a better way, but maybe adding a mouse > listener to the TopComponent would work. not really. The tab is not part of TC. So you won't get the events. I don't think there is a clean way of doing it. a possible workaround would be to override the requestActive() and componentActivated() methods and try to guess when the activation was a result of programatic call, rather then UI event. Not sure it's bulletproof or even possible to do though.. Milos > > On 1/22/07, Kate Dvortsova <kate.dvortsova@...> wrote: >> Hi Everybody, >> >> Is there a way to differentiate between a case when a user clicks on >> TopComponent tab and other cases when TopComponent gets activated >> programmatically? >> >> I want to do some action only in case a user clicks TopComponent tab, so >> TopComponent.componentActivated() doesn't do a job for me. >> >> Thank you, >> >> Kate >> >> >> >> > > |
|
|
Re: simple xml editorThe navigator problem was solved, too! The problem was that
<folder name="text/x-sposi+xml"> should have been <folder name="x-sposi+xml"> Now the editor.. Having said that I want to end up with an editor similar to the one the ide has for the web.xml file, what direction should I take? Make a new Window Component? Should I extend TopComponent and then add the xml check and highlighting features of the platform, extend the existing xml editor class and then add my other views to the component or else? Best regards. Roberto Roberto Nunnari wrote: > Hi Vivek. > > I'm not sure what this means, but I found this in > org.netbeans.modules.xml.core.META-INF.MANIFEST.MF > ... > OpenIDE-Module-Public-Packages: org.netbeans.modules.xml.api.*, org.ne > tbeans.modules.xml.api.model.*, org.netbeans.modules.xml.spi.dom.* > ... > > If that lists the packages that are publicly usable then > DataObjectCookieManager and Synchronizator are not usable.. > > Anyways.. taking out DataObjectCookieManager and Synchronizator > from my code, gives me an application that compiles and run, > but just like before, I don't get generic xml functionalities > for my xml flavor. > > Is the following correct? > I put this at the end of layer.xml: > > <folder name="Navigator"> > <folder name="Panels"> > <folder name="text"> > <folder name="text/x-sposi+xml"> > <file > name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> > </folder> > </folder> > </folder> > </folder> > </filesystem> > > If not, please correct me. > > Best regards. > Roberto > > > > Vivek Jain wrote: >> Hi Roberto, >> >> Your module require an implementation dependency on 'XML Core' for >> following packages: >> import org.netbeans.modules.xml.core.XMLDataObjectLook; >> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >> import org.netbeans.modules.xml.core.sync.Synchronizator; >> import org.netbeans.modules.xml.core.text.TextEditorSupport; >> >> Also add dependency on 'XML Tools API' for remaining packages: >> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >> >> Thanks, >> Vivek >> >> http://www.netbeans.org/ >> http://www.sun.com/ >> >> >> >> Roberto Nunnari wrote: >>> I added the Enterprise pack but the ide still cannot find the >>> following classes: >>> >>> import org.netbeans.modules.xml.core.XMLDataObjectLook; >>> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >>> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >>> import org.netbeans.modules.xml.core.sync.Synchronizator; >>> import org.netbeans.modules.xml.core.text.TextEditorSupport; >>> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >>> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >>> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >>> >>> Where are the above classes? >>> >>> Best regards. >>> Roberto >>> >>> >>> Roberto Nunnari wrote: >>>> Vivek Jain wrote: >>>>> Hi Roberto, >>>> >>>> Hi Vivek, >>>> >>>> >>>>> >>>>> I hope you are creating a new file type for an xml document which >>>>> ends with +xml. MIME types like |text/???+xml| are used in the IDE to >>>> >>>> I used text/x-sposi+xml >>>> Is that correct? >>>> >>>> >>>>> represent an XML document. Creating a filetype like this, IDE will >>>>> treat your files as an XML document. Netbeans Editor will provide >>>>> all functionality like code highlighting, indent, code folding, >>>>> code completion and any other to your xml document. >>>> >>>> Yes.. That works just fine. >>>> >>>> >>>>> >>>>> To get the schema based code completion for your xml files, you >>>>> have to install enterprise pack. Once you install NB enterprise >>>>> pack, run your >>>> >>>> I haven't checked code completion, yet. >>>> >>>> >>>>> module project, and create new file (that is your xml document). In >>>>> your xml document, provide the value for schemaLocation attribute >>>>> which will be the relative or absolute location of your schema >>>>> file. Just doing this will give you the schema support for your xml >>>>> files. >>>> >>>> The xml is correct, as I can validate it using other tools.. >>>> But.. here's how my xml file starts: >>>> >>>> <?xml version="1.0" encoding="UTF-8"?> >>>> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >>>> http://www.nunnisoft.ch/schemas/sposi01.xsd" >>>> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>>> ... >>>> >>>> >>>>> >>>>> Please note that Currently schema-based code completion for xml >>>>> files works only if we provide value for 'schemaLocation' attribute >>>>> and the value should be relative or absolute path of xsd file on >>>>> the filesystem. Schema based Code Completion is not available >>>>> through XML catalog. I have filed an issue >>>>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>>>> progress) on Netbeans XML component to provide Schema based Code >>>>> Completion through XML catalog. >>>>> >>>>> To get validate, checkXml, Transformable support, you have to add >>>>> the following code to your DataObject. Refer this link for the same >>>>> http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>>>> >>>>> CookieSet cookies = getCookieSet(); >>>>> cookieManager = new DataObjectCookieManager(this, >>>>> cookies); >>>>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>>>> getPrimaryEntry(), cookies)); >>>>> InputSource is = >>>>> DataObjectAdapters.inputSource(this); >>>>> Source source = DataObjectAdapters.source(this); >>>>> cookies.add(new CheckXMLSupport(is)); >>>>> cookies.add(new ValidateXMLSupport(is)); >>>>> cookies.add(new TransformableSupport(source)); >>>>> >>>>> To get the Navigator support for your xml files Add following code >>>>> in your layer.xml file (with your xml MIME type) >>>>> >>>>> <folder name="Navigator"> >>>>> <folder name="Panels"> >>>>> <folder name="text"> >>>>> <folder name="MIME_TYPE"> >>>>> <file >>>>> >>>>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>>>> >>>>> </folder> >>>>> </folder> >>>>> </folder> >>>>> </folder> >>>>> >>>> >>>> Ok. Thanks a lot to all who answered my question. >>>> I'll try that as soon as possible and let you know the result. >>>> >>>> Best regards. >>>> Roberto >>>> >>>> >>>>> Thanks & Regards, >>>>> Vivek >>>>> ------------------------------------ >>>>> http://www.netbeans.org/ >>>>> http://www.sun.com/ >>>>> ------------------------------------ >>>>> >>>>> Roberto Nunnari wrote: >>>>>> Hello. >>>>>> >>>>>> I'd like to develop a simple xml editor based on netbeans platform >>>>>> for a particular xml schema, something like the ide has for the >>>>>> web.xml file. Just the explorer, the navigator, the editor and the >>>>>> output window. >>>>>> >>>>>> I have to say that even though I've been using netbeans since >>>>>> early 2001 for java development, I'm a beginner with module >>>>>> development. >>>>>> >>>>>> I just started working on the module with netbeans ide 5.0 (but >>>>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>>>> made a new file type for my xml namespace. >>>>>> >>>>>> Launching the new application, I see that my xml files are >>>>>> recognized, as the icon I set for this file type is shown. >>>>>> >>>>>> The first problem is that the new fileType seams to not have >>>>>> inherited all the functionalities used for xml files. >>>>>> >>>>>> 1) the well formed and validate buttons in the editor are disabled. >>>>>> 2) the navigator doesn't show anything >>>>>> >>>>>> But the editor still uses highlighting and colors.. >>>>>> >>>>>> Of course, when editing an xml file that doesn't use an xml schema >>>>>> the well formed and validate buttons are again enabled and the >>>>>> navigator again shows its content. >>>>>> >>>>>> How can I add all features present for plain xml files to my file >>>>>> type? >>>>>> >>>>>> I also would appreciate any hints and directions you could give me >>>>>> on how to implement the editor (wizards, apis, files to edit, etc..) >>>>>> >>>>>> Best regards. >>>>>> >>>>>> -- >>>>>> Roberto |
|
|
Re: Clicking TopComponent tab eventTom Wheeler wrote:
> I don't know if there's a better way, but maybe adding a mouse > listener to the TopComponent would work. Hi, Kate, What are you trying to do - i.e. what behavior should be different if the tab is clicked? There might be a way to do whatever it is some other way. I can't say I recommend it, but in a pinch, an AWTEventListener checking event.getSource() instanceof TabDisplayer will find such events (but activation will happen later on another cycle of the event queue, so to detect it your listener would need to remember SwingUtilities.getAncestorOfClass (theTabDisplayer, TabbedContainer.class), and see if it is the same object as SwingUtilities.getAncestorOfClass (yourTopComponent, TabbedContainer.class), but forget the value if any mouse event is received for some other component (or if virtually anything else happens in the interim - this sort of thing is not reliable - it's easy to accidentally think an activation ten minutes later is the fulfillment of a misidentified mouse click). This sort of thing is not nice to do, and AWTEventListeners are a sledgehammer to kill a mosquito. So I'd like to understand just what the requirement is here - what is supposed to happen or be different about mouse-based activation (and does keyboard-based activation [ctrl-tab] count too? Is it really mouse clicks you want, or to detect explicit user-triggered activation? What for?)? -Tim > On 1/22/07, Kate Dvortsova <kate.dvortsova@...> wrote: >> Hi Everybody, >> >> Is there a way to differentiate between a case when a user clicks on >> TopComponent tab and other cases when TopComponent gets activated >> programmatically? >> >> I want to do some action only in case a user clicks TopComponent tab, so >> TopComponent.componentActivated() doesn't do a job for me. >> >> Thank you, >> >> Kate >> >> >> >> > > |
|
|
Re: simple xml editorHi Vivek
Thank you again for your support. But I don't understand why I need to have my DataObject class implement XMLDataObjectLook.. In fact the module seams to work well (well formed and validation checks) without implementing XMLDataObjectLook. Here's my class: public class Sposi01DataObject extends MultiDataObject { public Sposi01DataObject(FileObject pf, Sposi01DataLoader loader) throws DataObjectExistsException, IOException { super(pf, loader); CookieSet cookies = getCookieSet(); cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies)); InputSource is = DataObjectAdapters.inputSource(this); cookies.add(new CheckXMLSupport(is)); cookies.add(new ValidateXMLSupport(is)); } protected Node createNodeDelegate() { return new Sposi01DataNode(this); } } It seams that to get the desired result, I just need to call cookies.add() with CheckXMLSupport and ValidateXMLSupport.. Am I missing anything? Next week I'll have more time to work on this project, and I'll need to work on the specialized editor.. so here comes again my question: Having said that I want to end up with an editor similar to the one the ide has for the web.xml file (ie one view with the xml editor, and others with panels, labels and text fields), what direction should I take? Best regards. Roberto Vivek Jain wrote: > Hi Roberto, please see my comments inline... > > Regards, > Vivek > > http://www.netbeans.org/ > http://www.sun.com/ > > > > Roberto Nunnari wrote: >> Great Vivek! >> >> I didn't notice before, because I stopped checking if it was >> working after verifying that the navigator is still empty.. >> but checking again.. >> >> **XML well formed and XML validation now work!** >> >> I just had to take away DataObjectCookieManager and Synchronizator >> from your code and now well-formed and validation checks work! > package org.netbeans.modules.xml.core.cookies does not exist > package org.netbeans.modules.xml.core.sync does not exist > > Just adding simple dependency will not work because these API's are not > public. To use these packages, you need establish implementation > dependency or become friend of XML Core. BTW, I have filed an issue > 91617 <http://www.netbeans.org/issues/show_bug.cgi?id=91617> to make > these API public. > To add implementation dependency, go to Module Properties -> Libraries > -> XML Core -> Edit and select Implementation Version. This will solve > the problem. > > Regards, > Vivek >> >> Now I still have to get the navigator show and let navigate >> the xml elements of my xml flavor documents. >> >> For navigator to work, I tried to modify layer.xml as you said, >> but for sure I did miss something.. >> >> Could you please tell me what's wrong with my layer.xml? >> You can see it here: http://www.nunnisoft.ch/downloads/layer.xml > The entry for navigator panel in your layer.xml should look like > following, and it will work: > > <folder name="Navigator"> > <folder name="Panels"> > <folder name="text"> > <folder name="x-sposi+xml"> > <file > name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> > </folder> > </folder> > </folder> > </folder> >> >> Thank you and best regards. >> Roberto >> >> >> Vivek Jain wrote: >>> Hi Roberto, >>> >>> Your module require an implementation dependency on 'XML Core' for >>> following packages: >>> import org.netbeans.modules.xml.core.XMLDataObjectLook; >>> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >>> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >>> import org.netbeans.modules.xml.core.sync.Synchronizator; >>> import org.netbeans.modules.xml.core.text.TextEditorSupport; >>> >>> Also add dependency on 'XML Tools API' for remaining packages: >>> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >>> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >>> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >>> >>> Thanks, >>> Vivek >>> >>> http://www.netbeans.org/ >>> http://www.sun.com/ >>> >>> >>> >>> Roberto Nunnari wrote: >>>> I added the Enterprise pack but the ide still cannot find the >>>> following classes: >>>> >>>> import org.netbeans.modules.xml.core.XMLDataObjectLook; >>>> import org.netbeans.modules.xml.core.cookies.DataObjectCookieManager; >>>> import org.netbeans.modules.xml.core.sync.DataObjectSyncSupport; >>>> import org.netbeans.modules.xml.core.sync.Synchronizator; >>>> import org.netbeans.modules.xml.core.text.TextEditorSupport; >>>> import org.netbeans.spi.xml.cookies.CheckXMLSupport; >>>> import org.netbeans.spi.xml.cookies.DataObjectAdapters; >>>> import org.netbeans.spi.xml.cookies.ValidateXMLSupport; >>>> >>>> Where are the above classes? >>>> >>>> Best regards. >>>> Roberto >>>> >>>> >>>> Roberto Nunnari wrote: >>>>> Vivek Jain wrote: >>>>>> Hi Roberto, >>>>> >>>>> Hi Vivek, >>>>> >>>>> >>>>>> >>>>>> I hope you are creating a new file type for an xml document which >>>>>> ends with +xml. MIME types like |text/???+xml| are used in the >>>>>> IDE to >>>>> >>>>> I used text/x-sposi+xml >>>>> Is that correct? >>>>> >>>>> >>>>>> represent an XML document. Creating a filetype like this, IDE will >>>>>> treat your files as an XML document. Netbeans Editor will provide >>>>>> all functionality like code highlighting, indent, code folding, >>>>>> code completion and any other to your xml document. >>>>> >>>>> Yes.. That works just fine. >>>>> >>>>> >>>>>> >>>>>> To get the schema based code completion for your xml files, you >>>>>> have to install enterprise pack. Once you install NB enterprise >>>>>> pack, run your >>>>> >>>>> I haven't checked code completion, yet. >>>>> >>>>> >>>>>> module project, and create new file (that is your xml document). >>>>>> In your xml document, provide the value for schemaLocation >>>>>> attribute which will be the relative or absolute location of your >>>>>> schema file. Just doing this will give you the schema support for >>>>>> your xml files. >>>>> >>>>> The xml is correct, as I can validate it using other tools.. >>>>> But.. here's how my xml file starts: >>>>> >>>>> <?xml version="1.0" encoding="UTF-8"?> >>>>> <sp:Sposi xsi:schemaLocation="http://www.nunnisoft.ch/schemas/sposi >>>>> http://www.nunnisoft.ch/schemas/sposi01.xsd" >>>>> xmlns:sp="http://www.nunnisoft.ch/schemas/sposi" >>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>>>> ... >>>>> >>>>> >>>>>> >>>>>> Please note that Currently schema-based code completion for xml >>>>>> files works only if we provide value for 'schemaLocation' >>>>>> attribute and the value should be relative or absolute path of xsd >>>>>> file on the filesystem. Schema based Code Completion is not >>>>>> available through XML catalog. I have filed an issue >>>>>> <http://www.netbeans.org/issues/show_bug.cgi?id=91333> (fix in >>>>>> progress) on Netbeans XML component to provide Schema based Code >>>>>> Completion through XML catalog. >>>>>> >>>>>> To get validate, checkXml, Transformable support, you have to add >>>>>> the following code to your DataObject. Refer this link for the >>>>>> same http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType >>>>>> >>>>>> CookieSet cookies = getCookieSet(); >>>>>> cookieManager = new DataObjectCookieManager(this, >>>>>> cookies); >>>>>> cookies.add((Node.Cookie) DataEditorSupport.create(this, >>>>>> getPrimaryEntry(), cookies)); >>>>>> InputSource is = >>>>>> DataObjectAdapters.inputSource(this); >>>>>> Source source = DataObjectAdapters.source(this); >>>>>> cookies.add(new CheckXMLSupport(is)); >>>>>> cookies.add(new ValidateXMLSupport(is)); >>>>>> cookies.add(new TransformableSupport(source)); >>>>>> >>>>>> To get the Navigator support for your xml files Add following code >>>>>> in your layer.xml file (with your xml MIME type) >>>>>> >>>>>> <folder name="Navigator"> >>>>>> <folder name="Panels"> >>>>>> <folder name="text"> >>>>>> <folder name="MIME_TYPE"> >>>>>> <file >>>>>> >>>>>> name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/> >>>>>> >>>>>> </folder> >>>>>> </folder> >>>>>> </folder> >>>>>> </folder> >>>>>> >>>>> >>>>> Ok. Thanks a lot to all who answered my question. >>>>> I'll try that as soon as possible and let you know the result. >>>>> >>>>> Best regards. >>>>> Roberto >>>>> >>>>> >>>>>> Thanks & Regards, >>>>>> Vivek >>>>>> ------------------------------------ >>>>>> http://www.netbeans.org/ >>>>>> http://www.sun.com/ >>>>>> ------------------------------------ >>>>>> >>>>>> Roberto Nunnari wrote: >>>>>>> Hello. >>>>>>> >>>>>>> I'd like to develop a simple xml editor based on netbeans >>>>>>> platform for a particular xml schema, something like the ide has >>>>>>> for the web.xml file. Just the explorer, the navigator, the >>>>>>> editor and the output window. >>>>>>> >>>>>>> I have to say that even though I've been using netbeans since >>>>>>> early 2001 for java development, I'm a beginner with module >>>>>>> development. >>>>>>> >>>>>>> I just started working on the module with netbeans ide 5.0 (but >>>>>>> tomorrow I'll upgrade to 5.5) and using the wizard, have already >>>>>>> made a new file type for my xml namespace. >>>>>>> >>>>>>> Launching the new application, I see that my xml files are >>>>>>> recognized, as the icon I set for this file type is shown. >>>>>>> >>>>>>> The first problem is that the new fileType seams to not have >>>>>>> inherited all the functionalities used for xml files. >>>>>>> >>>>>>> 1) the well formed and validate buttons in the editor are disabled. >>>>>>> 2) the navigator doesn't show anything >>>>>>> >>>>>>> But the editor still uses highlighting and colors.. >>>>>>> >>>>>>> Of course, when editing an xml file that doesn't use an xml >>>>>>> schema the well formed and validate buttons are again enabled and >>>>>>> the >>>>>>> navigator again shows its content. >>>>>>> >>>>>>> How can I add all features present for plain xml files to my file >>>>>>> type? >>>>>>> >>>>>>> I also would appreciate any hints and directions you could give >>>>>>> me on how to implement the editor (wizards, apis, files to edit, >>>>>>> etc..) >>>>>>> >>>>>>> Best regards. >>>>>>> >>>>>>> -- >>>>>>> Roberto |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |