38

Click here to load reader

Extending NetBeans IDE

Embed Size (px)

DESCRIPTION

Learn how to extend NetBeans IDE for fun and profit!

Citation preview

Page 1: Extending NetBeans IDE

1

Page 2: Extending NetBeans IDE

2

Getting Started Extending NetBeans IDE (Learn how to create NetBeans plugins for fun and profit!)

Page 3: Extending NetBeans IDE

3

Me

Twitter: @geertjanw

Facebook: www.facebook.com/geertjanw

E-Mail: [email protected]

Page 4: Extending NetBeans IDE

4

Free Tool Box

HTML

JavaScript

CSS

Java EE

NetBeans

Page 5: Extending NetBeans IDE

5

What is NetBeans?

Ready to use out of the box

Support for latest Java

specifications & standards

Support for HTML,

JavaScript, and CSS

Intuitive workflow

Debugger, Profiler,

Editing & Refactoring Tools

Binaries and ZIPs for Mac OS,

Linux, and Windows

Simply download and run on any operating system!

Increase Developer Productivity

Page 6: Extending NetBeans IDE

6

What is NetBeans?

Works out of the box

Freely available

Open source

Support for Java standards &

other popular platforms, such as HTML5

Deeply integrated Maven support

Extensible Java desktop framework

Powerful, award winning GUI Builder

Profiling and debugging tools

Customizable and extensible

Increase Developer Productivity

Page 7: Extending NetBeans IDE

7

What is NetBeans?

Works out of the box

Freely available

Open source

Support for Java standards &

other popular platforms, such as HTML5

Deeply integrated Maven support

Extensible Java desktop framework

Powerful, award winning GUI Builder

Profiling and debugging tools

Customizable and extensible

Task: What are your favorite two features in NetBeans IDE?

Increase Developer Productivity

Page 8: Extending NetBeans IDE

8

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Page 9: Extending NetBeans IDE

9

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Windows Positions Groups

Page 10: Extending NetBeans IDE

10

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Options Window Primary Tabs Secondary Tabs Windows

Positions Groups

Page 11: Extending NetBeans IDE

11

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Options Window Primary Tabs Secondary Tabs Windows

Positions Groups

Progress Bar Status Bar Output

Page 12: Extending NetBeans IDE

12

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Options Window Primary Tabs Secondary Tabs Windows

Positions Groups

Progress Bar Status Bar Output

Files Editors Popup Menus

Page 13: Extending NetBeans IDE

13

NetBeans IDE

Menu Items Toolbar Buttons Keyboard Shortcuts

Options Window Primary Tabs Secondary Tabs Windows

Positions Groups

Progress Bar Status Bar Output

Files Editors Popup Menus

Projects External Tools

Page 14: Extending NetBeans IDE

14

Key Concepts

Module

Action

Filesystem

TopComponent

Options Window

Lookup

Page 15: Extending NetBeans IDE

15

Module

Most features in NetBeans IDE are found within a single module.

If a feature is complex and consists of different parts, it consists of multiple modules.

A module is:

– a JAR file

– with special manifest entries

– distributed as an NBM file

Page 16: Extending NetBeans IDE

16

Module

Most features in NetBeans IDE are found within a single module.

If a feature is complex and consists of different parts, it consists of multiple modules.

A module is:

– a JAR file

– with special manifest entries

– distributed as an NBM file

Task: Choose your favorite two modules in Tools | Plugins | Available Plugins.

Page 17: Extending NetBeans IDE

17

Workshop

Let’s create a module!

Page 18: Extending NetBeans IDE

18

Actions

Actions are invoked from menu items, toolbar buttons, and keyboard shortcuts.

Actions consist of

– ActionListener

– Display name

– Icon

Some actions are always enabled and some actions are contextually enabled.

Page 19: Extending NetBeans IDE

19

Actions

Actions are invoked from menu items, toolbar buttons, and keyboard shortcuts.

Actions consist of

– ActionListener

– Display name

– Icon

Some actions are always enabled and some actions are contextually enabled.

Task: Find two always enabled actions and two contextually enabled actions

…and explain why!

Page 20: Extending NetBeans IDE

20

Filesystem

Features in modules are registered in an XML file called “layer.xml” file.

Each module has at most one “layer.xml” file.

Entries in the “layer.xml” file:

– Come from annotations in Java classes.

– Come from manually typing in the file.

When NetBeans IDE starts, it merges all “layer.xml” files and creates the filesystem.

The filesystem has fixed folders, e.g., “Menu” and “Toolbars”.

Page 21: Extending NetBeans IDE

21

Workshop

Let’s create an Action and register it in the Filesystem!

Page 22: Extending NetBeans IDE

22

Workshop

Try to create an Action without using a wizard!

Page 23: Extending NetBeans IDE

23

Workshop

Create a new Module that registers an Action in the Toolbar!

Page 24: Extending NetBeans IDE

24

TopComponents

TopComponents are windows.

Windows are displayed in modes, i.e., positions or tabs.

Predefined modes include “editor”, “explorer”, “output”, and “properties”.

Annotations on the TopComponent define its default Mode.

Page 25: Extending NetBeans IDE

25

TopComponents

TopComponents are windows.

Windows are displayed in modes, i.e., positions or tabs.

Predefined modes include “editor”, “explorer”, “output”, and “properties”.

Annotations on the TopComponent define its default Mode.

Task: Identify three windows displayed by default in

the “explorer”, “editor”, and “output” mode.

Page 26: Extending NetBeans IDE

26

Workshop

Let’s create a TopComponent!

Page 27: Extending NetBeans IDE

27

Workshop

Try to create a TopComponent without using a wizard!

Page 28: Extending NetBeans IDE

28

Options Window

The Options window is a centralized dialog for all customizations in NetBeans IDE.

Each module can contribute new panels to the Options window.

There are primary panels and secondary panels.

Changes in the Options window can be persisted across restarts of NetBeans IDE.

Page 29: Extending NetBeans IDE

29

Options Window

The Options window is a centralized dialog for all customizations in NetBeans IDE.

Each module can contribute new panels to the Options window.

There are primary panels and secondary panels.

Changes in the Options window can be persisted across restarts of NetBeans IDE.

Task: Go to the Miscellaneous category in the Options window and

make the tabs of NetBeans IDE appear along the bottom and

then experiment with other settings you find there.

Page 30: Extending NetBeans IDE

30

Workshop

Let’s create a new Options panel!

Page 31: Extending NetBeans IDE

31

Lookup

Lookup provides context sensitivity to NetBeans IDE.

Task: Make a change in an editor and look at what happens to the Save button.

Click the Save button and notice what happens.

Do you think the Save button is in the same module as the editor?

Try to make some guesses about how it works.

Page 32: Extending NetBeans IDE

32

Lookup

Lookup provides context sensitivity to NetBeans IDE.

Task: Make a change in an editor and look at what happens to the Save button.

Click the Save button and notice what happens.

Do you think the Save button is in the same module as the editor?

Try to make some guesses about how it works.

Context sensitivity is provided by an event listening mechanism:

– The Save action is listening to the global context for a typed object.

– When a change is made in the editor, the typed object is published into the global context.

– The Save action calls a method on the type.

Page 33: Extending NetBeans IDE

33

Workshop

Let’s listen to the global context for Projects!

Page 34: Extending NetBeans IDE

34

Workshop

Display information about all the selected projects

in a window displayed in the Properties mode.

Page 35: Extending NetBeans IDE

35

Summary

Page 36: Extending NetBeans IDE

36

Key Concepts

Module

Action

Filesystem

TopComponent

Options Window

Lookup

Page 37: Extending NetBeans IDE

37

Me

Twitter: @geertjanw

Facebook: www.facebook.com/geertjanw

E-Mail: [email protected]

Page 38: Extending NetBeans IDE

38