netbeans:NetBeans Nodes API Tutorial

  This tutorial shows how to make use of some of the features of the Nodes API in NetBeans. It shows how to do the following:

  Decorate Nodes with icons

  Use HTML markup to enhance how Nodes are displayed

  Create properties for display in the property sheet

  Provide Actions from Nodes

  This tutorial is ended as a follow-on to the NetBeans Selection Management Tutorial, which covers how Lookup is used in managing selection in the NetBeans windowing system, and its follow-on tutorial which demonstrates how to use the Nodes API in managing selection.

  As its basis, this tutorial uses the source code created in the first tutorial and enhanced further in the second. If you have not yet done these tutorials, it is recommended to do them first.

  To follow this tutorial, you need the software and resources listed in the following table.

Software or Resource Version Required
NetBeans IDE version version 6.1 or

  version 6.0
Java Developer Kit (JDK) version 6 or

  version 5



  Optionally, for troubleshooting purposes, you can download the completed sample.

  Creating a Node sub  As mentioned in the previous tutorial, Nodes are presentation objects. That means that they are not a data model themselves—rather, they are a presentation layer for an underlying data model. In the Projects or Files windows in the NetBeans IDE, you can see Nodes used in a where the underlying data model is files _disibledevent="NetBeans Nodes API Tutorial" />

  General Property Sheet Caveats  If you used NetBeans 3.6 or earlier, you may notice that older versions of NetBeans employed the property sheet very heavily as a core element of the UI, whereas it's not so prevalent today. The reason is simple: property sheet based UIs are not terribly user-friendly. That doesn't mean don't use the property sheet, but use it judiciously. If you have the option of providing a customizer with a nice GUI, do so—your users will thank you.

  And you have an enormous number of properties on one object, try to find some overall tings that encapsulate the most probable combinations of tings. For example, think of what the tings for a tool for managing imports on a Java can be—you can provide egers for ting the threshold number of usages of a package required for wildcard imports, the threshold number of uses of a fully qualied name required before importing it at all, and lots of other numbers ad nauseum. Or you can ask yourself the question, what is the user trying to do?. In this , it's either going to be getting rid of import statements or getting rid of fully qualied names. So probably tings of low noise, medium noise and high noise where "noise" refers to the amount of fully qualied /package names in the edited source file would do just as well and be much easier to use. Where you can make le simpler for the user, do so.

  Review of Concepts  This tutorial has sought to get across the following ideas:

  Nodes are a presentation layer

  The display names of Nodes can be customized using a limited sub of HTML

  Nodes have icons, and you can provide custom icons for nodes you create

  Nodes have Actions; an Action which implements Presenter.Popup can provide its own component to display in a popup menu; the same is true for menu items using Presenter.Menu, and toolbar items using Presenter.Toolbar

  Nodes have properties, which can be displayed on the property sheet

Tags:  netbeanside6.5 netbeanside netbeans6.5 netbeans

延伸阅读

最新评论

发表评论