bluej.extensions
Class BlueJ

java.lang.Object
  extended by bluej.extensions.BlueJ

public final class BlueJ
extends java.lang.Object

A proxy object which provides services to BlueJ extensions. From this class an extension can obtain the projects and packages which BlueJ is currently displayng and the classes and objects they contain. Fields and methods of these objects can be inspected and invoked using an API based on Java's reflection API. Every effort has been made to retain the logic of the Reflection API and to provide methods that behave in a very similar way.

 BlueJ
   |
   +---- BProject
             |
             +---- BPackage
                      |
                      +--------- BClass
                      |            |
                      +- BObject   + BConstructor
                                   |      |
                                   |      +- BObject
                                   |
                                   +---- BMethod
                                   |      |
                                   |      +- BObject
                                   |
                                   +---- BField

 
Attempts to invoke methods on a BlueJ object made by an extension after its terminate() method has been called will result in an (unchecked) ExtensionUnloadedException being thrown.

Version:
$Id: BlueJ.java 7526 2010-05-11 04:18:57Z davmac $

Field Summary
static int ME_PROJECT
           
static int SE_PROJECT
           
 
Method Summary
 void addApplicationListener(ApplicationListener listener)
          Registers a listener for application events.
 void addClassListener(ClassListener listener)
          Register a listener for class events.
 void addCompileListener(CompileListener listener)
          Registers a listener for compile events.
 void addExtensionEventListener(ExtensionEventListener listener)
          Registers a listener for all the events generated by BlueJ.
 void addInvocationListener(InvocationListener listener)
          Registers a listener for invocation events.
 void addPackageListener(PackageListener listener)
          Registers a listener for package events.
 java.lang.String getBlueJPropertyString(java.lang.String property, java.lang.String def)
          Returns a property from BlueJ's properties, or the given default value if the property is not currently set.
 java.awt.Frame getCurrentFrame()
          Returns the current frame being displayed.
 BPackage getCurrentPackage()
          Returns the currently selected package.
 java.lang.String getExtensionPropertyString(java.lang.String property, java.lang.String def)
          Return a property associated with this extension from the standard BlueJ property repository.
 java.lang.String getLabel(java.lang.String key)
          Returns the language-dependent label with the given key.
 MenuGenerator getMenuGenerator()
          Returns the currently registered menu generator
 BProject[] getOpenProjects()
          Returns all currently open projects.
 PreferenceGenerator getPreferenceGenerator()
          Returns the currently registered preference generator.
 java.io.File getSystemLibDir()
          Returns the path of the <BLUEJ_HOME>/lib system directory.
 java.io.File getUserConfigDir()
          Returns the path of the user configuration directory.
 BProject newProject(java.io.File directory)
          Creates a new BlueJ project.
 BProject newProject(java.io.File directory, int projectType)
          Creates a new BlueJ project.
 BProject openProject(java.io.File directory)
          Opens a project.
 void removeApplicationListener(ApplicationListener listener)
          Removes the specified listener so that it no longer receives events.
 void removeClassListener(ClassListener listener)
          Removes the specified class listener so no that it no longer receives class events.
 void removeCompileListener(CompileListener listener)
          Removes the specified listener so that it no longer receives events.
 void removeExtensionEventListener(ExtensionEventListener listener)
          Removes the specified listener so that it no longer receives events.
 void removeInvocationListener(InvocationListener listener)
          Removes the specified listener so no that it no longer receives events.
 void removePackageListener(PackageListener listener)
          Removes the specified listener so that it no longer receives events.
 void setExtensionPropertyString(java.lang.String property, java.lang.String value)
          Sets a property associated with this extension into the standard BlueJ property repository.
 void setMenuGenerator(MenuGenerator menuGen)
          Install a new menu generator for this extension.
 void setPreferenceGenerator(PreferenceGenerator prefGen)
          Install a new preference panel for this extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SE_PROJECT

public static final int SE_PROJECT
See Also:
Constant Field Values

ME_PROJECT

public static final int ME_PROJECT
See Also:
Constant Field Values
Method Detail

openProject

public final BProject openProject(java.io.File directory)
Opens a project.

Parameters:
directory - Where the project is stored.
Returns:
the BProject that describes the newly opened project, or null if it cannot be opened.

newProject

public BProject newProject(java.io.File directory,
                           int projectType)
Creates a new BlueJ project.

Parameters:
directory - where you want the project be placed, it must be writable.
projectType - the type of project, such as ME or SE.
Returns:
the newly created BProject if successful, null otherwise.

newProject

public BProject newProject(java.io.File directory)
Creates a new BlueJ project.

Parameters:
directory - where you want the project be placed, it must be writable.
Returns:
the newly created BProject if successful, null otherwise.

getOpenProjects

public BProject[] getOpenProjects()
Returns all currently open projects. Returns an empty array if no projects are open.

Returns:
The openProjects value

getCurrentPackage

public BPackage getCurrentPackage()
Returns the currently selected package. The current package is the one that is currently selected by the user interface. It can return null if there is no currently open package.

Returns:
The currentPackage value

getCurrentFrame

public java.awt.Frame getCurrentFrame()
Returns the current frame being displayed. Can be used (e.g.) as a "parent" frame for positioning modal dialogs. If there is a package currently open, it's probably better to use its getFrame() method to provide better placement.

Returns:
The currentFrame value

setMenuGenerator

public void setMenuGenerator(MenuGenerator menuGen)
Install a new menu generator for this extension. If you want to delete a previously installed menu, then set it to null

Parameters:
menuGen - The new menuGenerator value

getMenuGenerator

public MenuGenerator getMenuGenerator()
Returns the currently registered menu generator

Returns:
The menuGenerator value

setPreferenceGenerator

public void setPreferenceGenerator(PreferenceGenerator prefGen)
Install a new preference panel for this extension. If you want to delete a previously installed preference panel, then set it to null

Parameters:
prefGen - a class instance that implements the PreferenceGenerator interface.

getPreferenceGenerator

public PreferenceGenerator getPreferenceGenerator()
Returns the currently registered preference generator.

Returns:
The preferenceGenerator value

getSystemLibDir

public java.io.File getSystemLibDir()
Returns the path of the <BLUEJ_HOME>/lib system directory. This can be used to locate systemwide configuration files. Having the directory you can then locate a file within it.

Returns:
The systemLibDir value

getUserConfigDir

public java.io.File getUserConfigDir()
Returns the path of the user configuration directory. This can be used to locate user dependent information. Having the directory you can then locate a file within it.

Returns:
The userConfigDir value

getBlueJPropertyString

public java.lang.String getBlueJPropertyString(java.lang.String property,
                                               java.lang.String def)
Returns a property from BlueJ's properties, or the given default value if the property is not currently set.

Parameters:
property - The name of the required global property
def - The default value to use if the property cannot be found.
Returns:
the value of the property.

getExtensionPropertyString

public java.lang.String getExtensionPropertyString(java.lang.String property,
                                                   java.lang.String def)
Return a property associated with this extension from the standard BlueJ property repository. You must use the setExtensionPropertyString to write any property that you want stored. You can then come back and retrieve it using this function.

Parameters:
property - The name of the required global property.
def - The default value to use if the property cannot be found.
Returns:
the value of that property.

setExtensionPropertyString

public void setExtensionPropertyString(java.lang.String property,
                                       java.lang.String value)
Sets a property associated with this extension into the standard BlueJ property repository. The property name does not need to be fully qualified since a prefix will be prepended to it.

Parameters:
property - The name of the required global property
value - the required value of that property.

getLabel

public java.lang.String getLabel(java.lang.String key)
Returns the language-dependent label with the given key. The search order is to look first in the extension's label files and if the requested label is not found in the BlueJ system label files. Extensions' labels are stored in a Property format and must be jarred together with the extension. The path searched is equivalent to the bluej/lib/[language] style used for the BlueJ system labels. E.g. to create a set of labels which can be used by English, Italian and German users of an extension, the following files would need to be present in the extension's Jar file:
 lib/english/label
 lib/italian/label
 lib/german/label
 
The files named label would contain the actual label key/value pairs.

Parameters:
key - Description of the Parameter
Returns:
The label value

addExtensionEventListener

public void addExtensionEventListener(ExtensionEventListener listener)
Registers a listener for all the events generated by BlueJ.


removeExtensionEventListener

public void removeExtensionEventListener(ExtensionEventListener listener)
Removes the specified listener so that it no longer receives events.


addApplicationListener

public void addApplicationListener(ApplicationListener listener)
Registers a listener for application events.


removeApplicationListener

public void removeApplicationListener(ApplicationListener listener)
Removes the specified listener so that it no longer receives events.


addPackageListener

public void addPackageListener(PackageListener listener)
Registers a listener for package events.


removePackageListener

public void removePackageListener(PackageListener listener)
Removes the specified listener so that it no longer receives events.


addCompileListener

public void addCompileListener(CompileListener listener)
Registers a listener for compile events.


removeCompileListener

public void removeCompileListener(CompileListener listener)
Removes the specified listener so that it no longer receives events.


addInvocationListener

public void addInvocationListener(InvocationListener listener)
Registers a listener for invocation events.


removeInvocationListener

public void removeInvocationListener(InvocationListener listener)
Removes the specified listener so no that it no longer receives events.


addClassListener

public void addClassListener(ClassListener listener)
Register a listener for class events.

Parameters:
listener -

removeClassListener

public void removeClassListener(ClassListener listener)
Removes the specified class listener so no that it no longer receives class events.



BlueJ homepage