Developing Plug-Ins for NetBeans

  • 1,707 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,707
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
46
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Developing Plug-Ins for NetBeans Tim Boudreau Staff Engineer Sun Microsystems TM SM NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 2. Agenda ● NetBeans Overview ● Plug-In Development Support ● Architectural Background ● Developing a Plug-In NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 3. Modular Design NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 4. Everything is a Plug-In NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 5. What is a plug-in (module) ● A jar file with some special manifest entries OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 6. What is a plug-in (module) ● Module code-name OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 7. What is a plug-in (module) ● What version of the main APIs does it need OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 8. What is a plug-in (module) ● Modules have version numbers OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 9. What is a plug-in (module) ● Modules can expose APIs OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 10. What is a plug-in (module) ● Modules can use APIs from other modules OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 11. What is a plug-in (module) ● Everything is localized OpenIDE-Module: org.netbeans.modules.project.ant/1 OpenIDE-Module-IDE-Dependencies: IDE/1 > 4.48 OpenIDE-Module-Specification-Version: 1.6 OpenIDE-Module-Implementation-Version: 050219 OpenIDE-Module-Public-Packages: org.netbeans.api.project.ant.*, org.ne tbeans.spi.project.ant.* OpenIDE-Module-Module-Dependencies: org.netbeans.modules.projectapi/1, org.netbeans.modules.queries/1, org.openide.loaders OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bun dle.properties NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 12. Anatomy of a Module NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 13. Plugin Support in NetBeans 4.2 ● NetBeans Plugin Projects ● New Plugin Template ● API class templates ● Build Plugins outside source tree – Deploy to ● Separate Binary ● Platform-only Binary ● Current IDE DEMO: Creating a Plugin NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 14. How the Hello World module works ● Installs a layer file which – Is merged into the system (configuration) filesystem – Defines a virtual filesystem fragment – Installs an instance file ● Points to a standard Swing Action NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 15. Filesystems API ● FileObjects: Abstraction over java.io.File – “Files” may not be on disk ● XML ● Remote (FTP, NFS) ● Database, etc. – Support ● Listening for changes ● Ad-hoc “attributes” (key-value pairs) ● Live in a FileSystem – a namespace ● Used for both config data + user's files NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 16. Filesystems – virtual files NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 17. XML Filesystems – very virtual files NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 18. Layered Filesystem NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 19. System (configuration) Filesystem NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 20. A Tour of the System Filesystem DEMO: Browsing the layer file and System FS NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 21. DataObjects wrap Files NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 22. DataSystems API ● DataObjects – wrap 1 or more FileObjects – “Typed” files – knows what the content is ● Different DataObject types for different MIME types – Programmatic access to file contents ● Structural or parsed representation of contents ● Support for editing, etc. ● DataLoaders – Factories for DataObject – Recognize and claim FileObjects by extension or contents NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 23. DataSystems NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 24. Nodes API ● Presentation layer on top of DataObjects – add – Icon, display name, menu actions, properties, child nodes ● Generic hierarchy API ● Displayed to user with the Explorer API – Tree, List, Combo, Menu, TreeTable and other views ● Don't have to represent files NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 25. From Files to Nodes NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 26. Factory Relationships – Files to Nodes NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 27. Lookup Patterns ● “Glue” between disparate APIs ● Common pattern: To ask an object for an implementation of some interface – SomeObject.getLookup().lookup (SomeIFace.class); – SomeObject.getCookie (SomeIFace.class); NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 28. Lookup API ● A way to find objects (dependency injection) ● Global singletons ● Lookup.getDefault().lookup (SomeInterface.class) ● Objects belonging to another object ● node.getLookup().lookup (SomeInterface.class) ● dataObject.getCookie (SomeInterface.class) ● Why lookup? ● Lazy instantiation – create on demand ● Evolution ● Its hard to add/remove methods ● Its easy to change what lives in an object's Lookup NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 29. Global Lookup Registration ● Instance file in system filesystem: <folder name=”services”> <file name=”org-foo-mymodule-MyService.instance”/> </folder> ● META-INF/services entry in jar: ● A single file that names the interface implemented ● META-INF/services/org.openide.ErrorManager ● With a single line of text naming the implementation class ● com.mycom.mymodule.MyErrorManagerImpl NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 30. getLookup() vs. getCookie() ● Newer idiom ● someobject.getLookup().lookup (SomeClass.class) ● Older idiom ● someobject.getCookie (SomeClass.class) ● Principle difference ● Lookup is more generic ● Objects in a Lookup don't have to implement the marker interface Node.Cookie NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 31. Povray NetBeansTM Software Day at 2005 JavaOneSM Conference
  • 32. Developing Plug-Ins for NetBeans Tim Boudreau Staff Engineer Sun Microsystems NetBeansTM Software Day at 2005 JavaOneSM Conference NetBeansTM Software Day at 2005 JavaOneSM Conference