Package bluej.extensions2
Class BlueJ
- java.lang.Object
-
- bluej.extensions2.BlueJ
-
public final class BlueJ extends java.lang.ObjectA 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 | +---- BFieldAttempts to invoke methods on a BlueJ object made by an extension after itsterminate()method has been called will result in an (unchecked)ExtensionUnloadedExceptionbeing thrown.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddApplicationListener(ApplicationListener listener)Registers a listener for application events.voidaddClassListener(ClassListener listener)Registers a listener for class events.voidaddCompileListener(CompileListener listener)Registers a listener for compile events.voidaddExtensionEventListener(ExtensionEventListener listener)Registers a listener for all the events generated by BlueJ.voidaddExternalFileLaunchers(java.util.List<ExternalFileLauncher> launchers)Appends a list of ExternalFileLauncher objects in BlueJ's list of external file launchers.voidaddInvocationFinishedListener(InvocationFinishedListener listener)Registers a listener for invocation finished events.voidaddPackageListener(PackageListener listener)Registers a listener for package events.java.lang.StringgetBlueJPropertyString(java.lang.String property, java.lang.String def)Returns a property from BlueJ's properties.BPackagegetCurrentPackage()Returns the current package.javafx.stage.StagegetCurrentWindow()Returns the current JavaFX Stage being displayed.java.lang.StringgetDataCollectionUniqueID()Returns the data-collection user ID.java.lang.StringgetExtensionPropertyString(java.lang.String property, java.lang.String def)Returns a property associated with this extension from the standard BlueJ property repository.java.lang.StringgetLabel(java.lang.String key)Returns the language-dependent label with the given key.MenuGeneratorgetMenuGenerator()Returns the currently registered menu generatorBProject[]getOpenProjects()Returns all currently open projects.PreferenceGeneratorgetPreferenceGenerator()Returns the currently registered preference generator.java.io.FilegetSystemLibDir()Returns the path of the<BLUEJ_HOME>/libsystem directory.java.io.FilegetUserConfigDir()Returns the path of the user configuration directory.BProjectnewProject(java.io.File directory)Creates a new BlueJ project.BProjectopenProject(java.io.File directory)Opens a BlueJ project.voidremoveApplicationListener(ApplicationListener listener)Removes the listener specified listener so that it no longer receives application events.voidremoveClassListener(ClassListener listener)Removes the specified class listener so no that it no longer receives class events.voidremoveCompileListener(CompileListener listener)Removes the specified listener so that it no longer receives compile events.voidremoveExtensionEventListener(ExtensionEventListener listener)Removes the specified listener so that it no longer receives events.voidremoveInvocationFinishedListener(InvocationFinishedListener listener)Removes the specified listener so no that it no longer receives invocation finished events.voidremovePackageListener(PackageListener listener)Removes the specified listener so that it no longer receives package events.voidsetExtensionPropertyString(java.lang.String property, java.lang.String value)Sets a property associated with this extension into the standard BlueJ property repository.voidsetMenuGenerator(MenuGenerator menuGen)Installs a new menu generator for this extension.voidsetPreferenceGenerator(PreferenceGenerator prefGen)Installs a new preference panel for this extension.voidsetScopeHighlightStrength(int strength)Sets the scope highlighting strength across all Java editors.
-
-
-
Method Detail
-
openProject
public final BProject openProject(java.io.File directory)
Opens a BlueJ project.- Parameters:
directory- location where the project is stored.- Returns:
- A
BProjectthat wraps the newly opened project, ornullif it cannot be opened.
-
newProject
public BProject newProject(java.io.File directory)
Creates a new BlueJ project.- Parameters:
directory- location where the project will be stored, it must be writable.- Returns:
- A
BProjectobject wrapping the newly created project if successful,nullotherwise.
-
getOpenProjects
public BProject[] getOpenProjects()
Returns all currently open projects.- Returns:
- An array of
BProjectobjects representing opened projects, empty array if no project are opened.
-
getCurrentPackage
public BPackage getCurrentPackage()
Returns the current package. The current package is the one that is currently selected by the user interface.- Returns:
- A
BPackageobject wrapping the current package,nullif there is no currently open package.
-
getCurrentWindow
public javafx.stage.Stage getCurrentWindow()
Returns the current JavaFX Stage 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 itsBPackage.getWindow()method to provide better placement.- Returns:
- A
Stageobject representing the current JavaFX Stage object
-
setMenuGenerator
public void setMenuGenerator(MenuGenerator menuGen)
Installs a new menu generator for this extension.- Parameters:
menuGen- a newMenuGenerator,nullto delete a previously installed menu.
-
getMenuGenerator
public MenuGenerator getMenuGenerator()
Returns the currently registered menu generator
-
setPreferenceGenerator
public void setPreferenceGenerator(PreferenceGenerator prefGen)
Installs a new preference panel for this extension.- Parameters:
prefGen- a class instance that implements thePreferenceGeneratorinterface,nullto delete a previously installed preference panel.
-
getPreferenceGenerator
public PreferenceGenerator getPreferenceGenerator()
Returns the currently registered preference generator.
-
addExternalFileLaunchers
public final void addExternalFileLaunchers(java.util.List<ExternalFileLauncher> launchers)
Appends a list of ExternalFileLauncher objects in BlueJ's list of external file launchers. This method must be called withinExtension.startup(BlueJ)for BlueJ to be able to retrieve the launcher(s). Calling it anywhere else will produce no effect in BlueJ. Adding launchers will not replace previously added launchers by the extension. Note that for a same external file type, the last extension loaded by BlueJ will overwrite a previously register launcher. Therefore, there is no guarantee that this extension's launcher will not be overwritten by another extension..- Parameters:
launchers- a list ofExternalFileLauncherto be registered in BlueJ.
-
getSystemLibDir
public java.io.File getSystemLibDir()
Returns the path of the<BLUEJ_HOME>/libsystem directory. This can be used to locate system-wide configuration files. A file can then be located within this directory.
-
getUserConfigDir
public java.io.File getUserConfigDir()
Returns the path of the user configuration directory. This can be used to locate user dependent information. A file can then be located within this directory.
-
getDataCollectionUniqueID
public java.lang.String getDataCollectionUniqueID()
Returns the data-collection user ID. Used by extensions that aim to augment the BlueJ data collection project.- Returns:
- the user ID, as read from the properties file.
-
getBlueJPropertyString
public java.lang.String getBlueJPropertyString(java.lang.String property, java.lang.String def)Returns a property from BlueJ's properties.- Parameters:
property- the name of the required global propertydef- the default value to use if the property cannot be found.- Returns:
- The requested property's value, or the default value if the property is not currently set.
-
getExtensionPropertyString
public java.lang.String getExtensionPropertyString(java.lang.String property, java.lang.String def)Returns a property associated with this extension from the standard BlueJ property repository. Extensions must usesetExtensionPropertyString(String, String)to write any property that should be stored.- 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, or the default value if the property is not currently set.
-
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 propertyvalue- the required value of that property (or null to remove the 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'slabelfiles and if the requested label is not found in the BlueJ systemlabelfiles. 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 namedlabelwould contain the actual label key/value pairs.- Parameters:
key- the name of the required label- Returns:
- The label value.
-
addExtensionEventListener
public void addExtensionEventListener(ExtensionEventListener listener)
Registers a listener for all the events generated by BlueJ.- Parameters:
listener- anExtensionEventListenerobject to register.
-
removeExtensionEventListener
public void removeExtensionEventListener(ExtensionEventListener listener)
Removes the specified listener so that it no longer receives events.- Parameters:
listener- anExtensionEventListenerobject to unregister.
-
addApplicationListener
public void addApplicationListener(ApplicationListener listener)
Registers a listener for application events.- Parameters:
listener- anApplicationListenerobject to register.
-
removeApplicationListener
public void removeApplicationListener(ApplicationListener listener)
Removes the listener specified listener so that it no longer receives application events.- Parameters:
listener- anApplicationListenerobject to unregister.
-
addPackageListener
public void addPackageListener(PackageListener listener)
Registers a listener for package events.- Parameters:
listener- anPackageListenerobject to register.
-
removePackageListener
public void removePackageListener(PackageListener listener)
Removes the specified listener so that it no longer receives package events.- Parameters:
listener- anPackageListenerobject to unregister.
-
addCompileListener
public void addCompileListener(CompileListener listener)
Registers a listener for compile events.- Parameters:
listener- anCompileListenerobject to register.
-
removeCompileListener
public void removeCompileListener(CompileListener listener)
Removes the specified listener so that it no longer receives compile events.- Parameters:
listener- anCompileListenerobject to unregister.
-
addInvocationFinishedListener
public void addInvocationFinishedListener(InvocationFinishedListener listener)
Registers a listener for invocation finished events.- Parameters:
listener- anInvocationFinishedListenerobject to register.
-
removeInvocationFinishedListener
public void removeInvocationFinishedListener(InvocationFinishedListener listener)
Removes the specified listener so no that it no longer receives invocation finished events.- Parameters:
listener- anInvocationFinishedListenerobject to unregister.
-
addClassListener
public void addClassListener(ClassListener listener)
Registers a listener for class events.- Parameters:
listener- anClassListenerobject to register.
-
removeClassListener
public void removeClassListener(ClassListener listener)
Removes the specified class listener so no that it no longer receives class events.- Parameters:
listener- anClassListenerobject to unregister.
-
setScopeHighlightStrength
public void setScopeHighlightStrength(int strength)
Sets the scope highlighting strength across all Java editors. This is how opaque or transparent the coloured boxes are that appear for classes, methods, control flow constructs, etc. *- Parameters:
strength- The highlighting strength: 0 means off, 20 means full, and then it's a sliding scale inbetween.- Since:
- Extension API 3.2 (BlueJ 5.0.2)
-
-