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 class
ClassEvent.EventType
Types of class events.
-
Constructor Summary
Constructors Constructor Description ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass)
Constructs a new ClassEvent object for aClassEvent.EventType.REMOVED
event.ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, boolean isCompiled, boolean hasError)
Constructs a new ClassEvent object for aClassEvent.EventType.STATE_CHANGED
event.ClassEvent(bluej.pkgmgr.Package bluejPackage, BClass bClass, java.lang.String oldName)
Constructs a new ClassEvent object for aClassEvent.EventType.CHANGED_NAME
event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BClass
getBClass()
Gets the class on which the event occurred.ClassEvent.EventType
getEventType()
Gets the event type.java.lang.String
getOldName()
Gets the old class name.BPackage
getPackage()
Returns the package to which the class that caused this event belongs.boolean
hasError()
Checks whether the class for which the event occurred has compilation errors.boolean
isClassCompiled()
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_CHANGED
event.- Parameters:
bluejPackage
- aPackage
object that contains the compiled class.bClass
- aBClass
object 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_NAME
event.- Parameters:
bluejPackage
- aPackage
object that contains the renamed class.bClass
- aBClass
object 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.REMOVED
event.- Parameters:
bluejPackage
- aPackage
object that contained the removed class.bClass
- aBClass
object wrapping the class which was removed.
-
-
Method Detail
-
getEventType
public ClassEvent.EventType getEventType()
Gets the event type.- Returns:
- The
ClassEvent.EventType
value associated with this ClassEvent.
-
isClassCompiled
public boolean isClassCompiled()
Checks whether the class for which the event occurred is compiled. Valid forClassEvent.EventType.STATE_CHANGED
event.- Returns:
True
if the class is compiled,false
otherwise.
-
hasError
public boolean hasError()
Checks whether the class for which the event occurred has compilation errors. Valid forClassEvent.EventType.STATE_CHANGED
event if isClassCompiled() returns false.- Returns:
True
if the class has compilation errors,false
otherwise.
-
getPackage
public BPackage getPackage()
Returns the package to which the class that caused this event belongs.- Returns:
- A
BPackage
object 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
BClass
object wrapping the class on which this event occurred.
-
getOldName
public java.lang.String getOldName()
Gets the old class name. Valid forClassEvent.EventType.CHANGED_NAME
event.
-
-