Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 First BlueJ Day, Houston, Texas, 1st March 2006 Writing BlueJ Extensions Ian Utting University of Kent.

Similar presentations


Presentation on theme: "1 First BlueJ Day, Houston, Texas, 1st March 2006 Writing BlueJ Extensions Ian Utting University of Kent."— Presentation transcript:

1 1 First BlueJ Day, Houston, Texas, 1st March 2006 Writing BlueJ Extensions Ian Utting University of Kent

2 2 First BlueJ Day, Houston, Texas, 1st March 2006 Aims of the Extensions API To allow you to do programmatically what users can do through the BlueJ GUI: –Add menu items to the BlueJ GUI for packages, classes and objects –Create and interrogate projects, packages, classes and objects (and their BlueJ GUI representations) –Interact with source code through the editor

3 3 First BlueJ Day, Houston, Texas, 1st March 2006 Why? To allow you to extend BlueJ with stuff only you need (or you only need sometimes) To use BlueJ as a tool for researching student behaviour (As a source of undergraduate projects)

4 4 First BlueJ Day, Houston, Texas, 1st March 2006 Overview – an Extension is: A single jar file containing (at least) a class which extends bluej.extensions.Extension (the Jar’s MainClass attribute should name this class) The Jar can be installed system-wide, per-user or per-project. Tip: don’t rely on external class libraries, bundle them with your extension

5 5 First BlueJ Day, Houston, Texas, 1st March 2006 abstract class Extension Provides (and requires) version and compatibility information. Requires: –abstract void startup(BlueJ bluej) called when the extension can start –void terminate() called when the extension is about to be unloaded Watch out: version request calls can occur at any time, don’t use static initialisers of heavyweight constructors.

6 6 First BlueJ Day, Houston, Texas, 1st March 2006 class BlueJ Acts as a proxy for the BlueJ application Allows an extension to: –Create and open BlueJ projects, and identify the “current” package –Add Listeners for various events –Get/set persistent properties –Register menu and preference panel generators

7 7 First BlueJ Day, Houston, Texas, 1st March 2006 Menus Extensions can add a menu item (or sub-menu) to the Tools, Class and Object menus. Don’t share them, or hold onto them, or rely on when BlueJ might ask for them. BlueJ will call you back on the notifyPost methods just before displaying your menu (so you can enable/disable your items).

8 8 First BlueJ Day, Houston, Texas, 1st March 2006 BProject and BPackage Represent BlueJ’s view of projects and packages As with BlueJ itself, most of the action is in packages Through BPackage, you can retrieve, create and delete new classes and objects, including BlueJ’s representations of them

9 9 First BlueJ Day, Houston, Texas, 1st March 2006 BClass, BObject, BMethod, etc. Manipulate BlueJ’s set of classes and objects Invoke methods (and constructors) and place the resulting objects on the bench Designed to look like Java reflection, and backed up by real reflection (but watch out for side effects when using real reflection)

10 10 First BlueJ Day, Houston, Texas, 1st March 2006 Watching what users are doing Using a standard listener mechanism, an extension can find out when: –packages are opened or closed –classes are compiled (and what happened) –objects are invoked

11 11 First BlueJ Day, Houston, Texas, 1st March 2006 Interacting with the Editor Many possible extensions want more interaction with the user during code creation We provide an interface to the BlueJ editor for a class, for manipulating text A “property” mechanism allows an extension to interact with a modified editor for more detailed interaction

12 12 First BlueJ Day, Houston, Texas, 1st March 2006 More information The Extensions API documentation, and an example, are at: www.bluej.org/extensions/extensions.html#write If you want to get involved in an existing extension, consider the Project Exporter at: bluej-project-exporter.dev.java.net Remember: BlueJ extensions make great student projects!


Download ppt "1 First BlueJ Day, Houston, Texas, 1st March 2006 Writing BlueJ Extensions Ian Utting University of Kent."

Similar presentations


Ads by Google