netbeans:NetBeans Selection Management Tutorial I—Using a TopComponent's Lookup来源: 发布时间:星期四, 2009年1月8日 浏览:11次 评论:0
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. Introduction to Selection "Selection" is an important concept for any non-trivial application. NetBeans has two basic concepts of selection—the contents of the focused TopComponent's Lookup, and the focused TopComponent's activated Node(s). Here you will deal _disibledevent="NetBeans Selection Management Tutorial I—Using a TopComponent's Lookup" /> Providing More Than One Object This is all well and good for decoupling, but isn't providing this one object from your component a bit like having a Map that only contains one key and one value? The answer is, yes, it is like that. Where this technique becomes even more powerful is when you provide multiple objects from multiple APIs. As an example, it is very common in NetBeans to provide context sensitive actions. A ![]() ![]() ![]() ![]() ![]() As you may have noticed, context sensitivity was one option in the New Action wizard. The actions currently generated by the wizard actually use a way of doing this that pre-dates Lookup; the Lookup-based way of doing such context sensitive actions is described in the developer FAQ. So the pattern in practice is to provide more than just a single object from your component's Lookup—d ![]() ![]() ![]() ![]() ![]() ![]() Miscellaneous Things Worth Noticing While not directly related to the topic of this tutorial, it's worth noticing that ![]() If you do not want this behavior, there are two other choices. Override the following method on MyEditor to cause editors never to be reopened on restart: public If you want to persist the components that are open but discard those that have been closed, ![]() Note, though, that part of what is serialized to disk is the location of your component in the ![]() ![]() Optional Clean-Up The module template, by default, assumes you will want to use the layer.xml file to ![]() ![]() Expand the Important Files node of the My API project Double click the Module Man ![]() Delete the following line from the man ![]() OpenIDE-Module-Layer: org/myorg/myapi/layer.xml Then delete the corresponding layer.xml file in org.myorg.myapi 0
相关文章
读者评论发表评论 |
|