Package bluej.extensions2
Class MenuGenerator
- java.lang.Object
-
- bluej.extensions2.MenuGenerator
-
public class MenuGenerator extends java.lang.Object
Extensions which wish to add a menu item to BlueJ's menus should register an instance of MenuGenerator with the BlueJ proxy object.A MenuGenerator provides a set of functions which can be called back by BlueJ to request the actual menu items which will be displayed, and to indicate that a particular menu item is about to be displayed, so that an extension can (e.g.) enable or disable appropriate items.
Note that the MenuItem which is returned by the extension can itself be a Menu, allowing extensions to build more complex menu structures, but that the "notify" methods below will only be called for the item which has actually been added, and not any subsidiary items.
Note that the MenuGenerator's get*MenuItem() methods:
- may be called more than once during a BlueJ session, they should return a new set of MenuItems for each invocation. This is a restriction required by the JavaFX implementation, which does not allow sharing of MenuItems between menus. Of course, ActionEvent's handlers can be shared between all of the appropriate MenuItems.
- may not be called between the registration of a new MenuGenerator and the display of a menu. That is to say old menu items may still be active for previously registered menus, despite the registration of a new MenuGenerator.
- will be called at least once for every menu which is displayed.
- Author:
- Damiano Bolla, University of Kent at Canterbury. January 2003
-
-
Constructor Summary
Constructors Constructor Description MenuGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.scene.control.MenuItem
getClassMenuItem(BClass bClass)
Returns the MenuItem to be added to the BlueJ Class menu Extensions should not retain references to the menu items created.javafx.scene.control.MenuItem
getObjectMenuItem(BObject bObject)
Returns the MenuItem to be added to the BlueJ Object menu.javafx.scene.control.MenuItem
getPackageMenuItem(BPackage bPackage)
Returns the MenuItem to be added to the BlueJ Package menu.javafx.scene.control.MenuItem
getToolsMenuItem(BPackage bPackage)
Returns the MenuItem to be added to the BlueJ Tools menu.void
notifyPostClassMenu(BClass bClass, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a class menu added by an extension is about to be displayed.void
notifyPostObjectMenu(BObject bObject, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when an object menu added by an extension is about to be displayed.void
notifyPostPackageMenu(BPackage bPackage, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a package menu added by an extension is about to be displayed.void
notifyPostToolsMenu(BPackage bPackage, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a tools menu added by an extension is about to be displayed.
-
-
-
Method Detail
-
getToolsMenuItem
public javafx.scene.control.MenuItem getToolsMenuItem(BPackage bPackage)
Returns the MenuItem to be added to the BlueJ Tools menu. Extensions should not retain references to the menu items created.- Parameters:
bPackage
- aBPackage
object wrapping the BlueJ package with which this menu item will be associated.- Returns:
- This method should return a
MenuItem
object to be added to the Tools menu for this extensions,null
is returned by default.
-
getPackageMenuItem
public javafx.scene.control.MenuItem getPackageMenuItem(BPackage bPackage)
Returns the MenuItem to be added to the BlueJ Package menu. Extensions should not retain references to the menu items created.- Parameters:
bPackage
- aBPackage
object wrapping the BlueJ package with which this menu item will be associated.- Returns:
- This method should return a
MenuItem
object to be added to the Ppackage menu for this extensions,null
is returned by default.
-
getClassMenuItem
public javafx.scene.control.MenuItem getClassMenuItem(BClass bClass)
Returns the MenuItem to be added to the BlueJ Class menu Extensions should not retain references to the menu items created.- Parameters:
bClass
- aBClass
object wrapping the BlueJ class with which this menu item will be associated.- Returns:
- This method should return a
MenuItem
object to be added to the Class menu for this extensions,null
is returned by default.
-
getObjectMenuItem
public javafx.scene.control.MenuItem getObjectMenuItem(BObject bObject)
Returns the MenuItem to be added to the BlueJ Object menu. Extensions should not retain references to the menu items created.- Parameters:
bObject
- aBObject
object wrapping the BlueJ Object with which this menu item will be associated.- Returns:
- This method should return a
MenuItem
object to be added to the Object menu for this extensions,null
is returned by default.
-
notifyPostToolsMenu
public void notifyPostToolsMenu(BPackage bPackage, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a tools menu added by an extension is about to be displayed. An extension can use this notification to decide whether to enable/disable menu items and so on.- Parameters:
bPackage
- aBPackage
object wrapping the BlueJ package for which this menu is to be displayed.menuItem
- aMenuItem
object about to be be displayed (as provided by the extension in a previous call togetToolsMenuItem(BPackage)
).
-
notifyPostPackageMenu
public void notifyPostPackageMenu(BPackage bPackage, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a package menu added by an extension is about to be displayed. An extension can use this notification to decide whether to enable/disable menu items and so on.- Parameters:
bPackage
- aBPackage
object wrapping the BlueJ package for which this menu is to be displayed.menuItem
- aMenuItem
object about to be be displayed (as provided by the extension in a previous call togetPackageMenuItem(BPackage)
).
-
notifyPostClassMenu
public void notifyPostClassMenu(BClass bClass, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when a class menu added by an extension is about to be displayed. An extension can use this notification to decide whether to enable/disable menu items and so on.- Parameters:
bClass
- aBClass
object wrapping the BlueJ class for which this menu is to be displayed.menuItem
- aMenuItem
object about to be be displayed (as provided by the extension in a previous call togetClassMenuItem(BClass)
).
-
notifyPostObjectMenu
public void notifyPostObjectMenu(BObject bObject, javafx.scene.control.MenuItem menuItem)
Called by BlueJ when an object menu added by an extension is about to be displayed. An extension can use this notification to decide whether to enable/disable menu items and so on.- Parameters:
bObject
- aBObject
object wrapping the BlueJ object for which this menu is to be displayed.menuItem
- aMenuItem
object about to be be displayed (as provided by the extension in a previous call togetObjectMenuItem(BObject)
).
-
-