Package bluej.extensions2.event
Class ClassEvent
- java.lang.Object
-
- bluej.extensions2.event.ClassEvent
-
- All Implemented Interfaces:
ExtensionEvent
public class ClassEvent extends java.lang.Object implements ExtensionEvent
This class encapsulates events which occur on BlueJ classes.
The following events can occur:
STATE_CHANGED - the compile state changed (either from uncompiled to compiled, or from compiled to uncompiled)
CHANGED_NAME - the class has changed name.
REMOVED - the class has been removed.
In the case of STATE_CHANGED there are three possible sitations:
- isClassCompiled() returns true: the class has been compiled successfully. Editing the class will switch to one of the next two states.
- isClassCompiled() returns false and hasError() returns true: the class has been compiled and was found to have an error. If the user edits the class, it will either switch directly to the first state (if they fix it and the compile occurs quickly) or the next state (if we are awaiting the compile).
- isClassCompiled() returns false, and hasError() returns false: the class has been edited and is awaiting the next compile. When the next compile occurs, the state will be changed to one of the above two states.
- Author:
- Davin McCall
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassEvent.EventTypeTypes of class events.
-
Constructor Summary
Constructors Constructor Description ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass)Constructs a new ClassEvent object for aClassEvent.EventType.REMOVEDevent.ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, boolean isCompiled, boolean hasError)Constructs a new ClassEvent object for aClassEvent.EventType.STATE_CHANGEDevent.ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, java.lang.String oldName)Constructs a new ClassEvent object for aClassEvent.EventType.CHANGED_NAMEevent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BClassgetBClass()Gets the class on which the event occurred.ClassEvent.EventTypegetEventType()Gets the event type.java.lang.StringgetOldName()Gets the old class name.BPackagegetPackage()Returns the package to which the class that caused this event belongs.booleanhasError()Checks whether the class for which the event occurred has compilation errors.booleanisClassCompiled()Checks whether the class for which the event occurred is compiled.
-
-
-
Constructor Detail
-
ClassEvent
public ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, boolean isCompiled, boolean hasError)Constructs a new ClassEvent object for aClassEvent.EventType.STATE_CHANGEDevent.- Parameters:
bluejPackage- aPackageobject that contains the compiled class.bClass- aBClassobject wrapping the compiled class.isCompiled- boolean indicating whether the class is compiled (true) or not.hasError- boolean indicating whether the last compilation gave an error and the class not has been edited since (true).
-
ClassEvent
public ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, java.lang.String oldName)Constructs a new ClassEvent object for aClassEvent.EventType.CHANGED_NAMEevent.- Parameters:
bluejPackage- aPackageobject that contains the renamed class.bClass- aBClassobject wrapping the class which was renamed (refers to the new name).
-
ClassEvent
public ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass)Constructs a new ClassEvent object for aClassEvent.EventType.REMOVEDevent.- Parameters:
bluejPackage- aPackageobject that contained the removed class.bClass- aBClassobject wrapping the class which was removed.
-
-
Method Detail
-
getEventType
public ClassEvent.EventType getEventType()
Gets the event type.- Returns:
- The
ClassEvent.EventTypevalue associated with this ClassEvent.
-
isClassCompiled
public boolean isClassCompiled()
Checks whether the class for which the event occurred is compiled. Valid forClassEvent.EventType.STATE_CHANGEDevent.- Returns:
Trueif the class is compiled,falseotherwise.
-
hasError
public boolean hasError()
Checks whether the class for which the event occurred has compilation errors. Valid forClassEvent.EventType.STATE_CHANGEDevent if isClassCompiled() returns false.- Returns:
Trueif the class has compilation errors,falseotherwise.
-
getPackage
public BPackage getPackage()
Returns the package to which the class that caused this event belongs.- Returns:
- A
BPackageobject wrapping the package to which the class that caused this event belongs.
-
getBClass
public BClass getBClass()
Gets the class on which the event occurred.- Returns:
- A
BClassobject wrapping the class on which this event occurred.
-
getOldName
public java.lang.String getOldName()
Gets the old class name. Valid forClassEvent.EventType.CHANGED_NAMEevent.
-
-