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" 
    "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>

  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">
           <name>blabla1</name>
           <job1>hmmm1</job1>
           <job2>hmmm2</job2>
        </task1>
        <task2 default="job1">
           <name>blabla2</name>
           <job1>hmmm3</job1>
           <job2>hmmm4</job2>
        </task2>
    </bla>

  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!

Comments:

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
About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today