XML Editor in Source View of MultiView Component (Part 1)

You want the source view of your multiview editor to display an XML file in the NetBeans XML Editor? Nothing simpler—take the following steps:

  1. Download and install this plugin from the Plugin Portal.

  2. Go to the New Project dialog, find the "Abc MultiView Sample" in Samples | NetBeans Modules and complete the wizard.

  3. 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" 
            <ext name="xml"/>
            <resolver mime="text/x-abc+xml">
                    <element name="bla"/>

  4. Then go to the layer.xml file and change "x-abc" to to "x-abc+xml", in line 6 and in line 70.

  5. 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">
        <task2 default="job1">

  6. 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!


One more time thanks for your bright light Geerjan !

Posted by hippopotame on May 02, 2010 at 12:11 AM PDT #

I second the previous comment! Your blog comes up on almost all of my NB Platform google searches. Thanks for the wonderful example.

Posted by Matthew Maurer on July 16, 2010 at 01:02 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« May 2016