An XML Editor in 3 Steps (Without Any Coding)

Three steps to an XML editor from scratch without your needing to do any coding at all:

  1. Go to File | New Project and create a NetBeans Platform application (or use the Maven archetype and open it in the IDE of your choice).

  2. Right-click the application, choose Properties, and go to the Libraries panel.
    • In "platform11", add a checkmark for "Favorites".
    • In "ide12", add a checkmark for "XML Text Editor" and then click the "Resolve" button.

  3. Run the application, open the Favorites window (Window | Favorites), find your XML file, double-click it, and then it opens in the XML editor.

And here's your XML editor:

And now you can add/remove menu items, toolbar buttons, etc. You can brand the title bar, splash screen, etc. You can create a distribution (from menu items in the IDE) for ZIP distribution or a web start distribution. And you can add new modules with new features. Or remove existing modules to end up with the XML editor of your dreams.

Comments:

Thanks!!!!!!

Posted by lakmal on January 15, 2010 at 01:59 PM PST #

When I try these steps, New / Open File are disabled. How do you turn them on? Is it possible to point the Favorites or Files pane to a different place in the file system?

Posted by John Leed on January 26, 2010 at 12:26 AM PST #

Hi Geertjan.

Thanks again for your nice tutorials.
Bummer that this one doesn't work for me.

Starting the platform fails with this message:
Warning - could not install some modules: Editor Code Templates - The module named org.netbeans.spi.editor.hints/0-1 was needed and not found. Project UI API - None of the modules providing the capability org.netbeans.modules.project.uiapi.ActionsFactory could be installed. Project UI API - None of the modules providing the capability org.netbeans.modules.project.uiapi.OpenProjectsTrampoline could be installed. Project UI API - None of the modules providing the capability org.netbeans.modules.project.uiapi.ProjectChooserFactory could be installed. Classpath APIs - The module named org.openide.execution was needed and not found. Project UI - The module named org.netbeans.core.execution/1 was needed and not found. Project UI - The module named org.netbeans.modules.favorites/1 was needed and not found. Common Scripting Language API (new) - The module named org.netbeans.spi.editor.hints/0-1 was needed and not found. 9 further modules could not be installed due to the above problems.

Any idea what the reason might be?

Running on a Mac JDK 1.6, NetBeans 6.8.

Too good to be true that the NB platform comes with tameable complexity to make one use it for future applications ...

Marcus

Posted by Marcus on January 26, 2010 at 05:30 AM PST #

Marcus, maybe do a clean and build. Are you sure you followed the steps above? I.e., did you really click the "Resolve" button?

John Leed, for additional features, you'll need to enable additional modules. If you want to have the Files window or Favorites window to open somewhere else (assuming I'm correct in interpreting that as being your requirement), see this tutorial:
http://platform.netbeans.org/tutorials/nbm-htmleditor.html

Posted by Geertjan Wielenga on January 26, 2010 at 11:28 PM PST #

I followed the instructions and got an harmless exception the first time I double-clicked on the xml node. The file editor opened and everything else is fine.

Thanks ! :-)

Posted by Vincent Cantin on January 29, 2010 at 01:01 PM PST #

I got another exception when I triggered the auto-completion on a xml pom file (was in the "packaging" tag). NetBeans might not be fully tested to work in small pieces. We should test the platform more in the netcat program.

Exception:
java.lang.NullPointerException
at org.netbeans.modules.xml.text.bracematch.XMLBraceMatcher.findTokenAtContext(XMLBraceMatcher.java:221)
at org.netbeans.modules.xml.text.bracematch.XMLBraceMatcher.hasEndTag(XMLBraceMatcher.java:426)
at org.netbeans.modules.xml.text.completion.XMLCompletionQuery.query(XMLCompletionQuery.java:143)
at org.netbeans.modules.xml.text.completion.XMLCompletionProvider$Query.query(XMLCompletionProvider.java:114)
at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:602)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1084)
Caused: org.openide.util.RequestProcessor$FastItem: task failed due to

Posted by Vincent Cantin on January 29, 2010 at 01:04 PM PST #

there is no "platform11" or "ide12" anymore. i managed to get it sort of working anyways but ive got no syntax highlighting, no closing-tag suggestion etc. looks like the xml editor is a jtextfield.
is there a complete list of needed modules one must add to such a project or do i have to try and error the hundrets of modules?

Posted by camikusch on February 07, 2011 at 04:42 PM PST #

Regarding "Open File": Geertjan posted September 2011 about it:
https://blogs.oracle.com/geertjan/entry/open_file_dialog_in_the

Posted by Victor on February 28, 2013 at 07:38 AM PST #

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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today