XML Editor in Source View of MultiView Component (Part 1)
By Geertjan-Oracle on Apr 28, 2010
- Download and install this plugin from the Plugin Portal.
- Go to the New Project dialog, find the "Abc MultiView Sample" in Samples | NetBeans Modules and complete the wizard.
- In the Projects window, open "AbcResolver.xml" and replace its content with the following:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd"> <MIME-resolver> <file> <ext name="xml"/> <resolver mime="text/x-abc+xml"> <xml-rule> <element name="bla"/> </xml-rule> </resolver> </file> </MIME-resolver>
- Then go to the layer.xml file and change "x-abc" to to "x-abc+xml", in line 6 and in line 70.
- Somewhere on your hard drive, create a file with ".xml" as the file extension and then define its content as follows:
<bla name="hello" default="task1"> <description>Describes tasks and related jobs.</description> <task1 default="job1"> <name>blabla1</name> <job1>hmmm1</job1> <job2>hmmm2</job2> </task1> <task2 default="job1"> <name>blabla2</name> <job1>hmmm3</job1> <job2>hmmm4</job2> </task2> </bla>
- Run the application, go to the Favorites window, open the file you created above and then you should see this in the Text view:
You have now modified the sample module so that it supports an XML file by opening it in the NetBeans XML Editor, which wasn't needed by the non-XML file that the sample supports by default. Learn from the source code and apply to your own scenario. Stir briskly and eat while hot.
In other news. Now read part 2 of this series!