Download A Software Lifecycle for Building Groupware Applications: Building

Transcript
APPENDIX C. THE THYME WIDGET TUTORIAL
210
package widgettest.message;
import gump.share.TypeEnumeration;
public class SharedTreeActionType extends TypeEnumeration {
public static final SharedTreeActionType ADD_NODE =
new SharedTreeActionType(‘‘ADD_NODE’’);
public SharedTreeActionType(String id) {
super(id);
}
}
Figure C.3: Partial implementation of SharedTreeActionType
NOTE: All classes you create should be saved in the package widgettest.bloc.
If you use an IDE such as IntelliJ or Eclipse they may create a wrong package name.
C.5.1
The ActionType
The first step is to implement the ActionType class for the JTree. This class is used
by messages to specify what type of action should be taken based on the message’s
payload.
Name this new class SharedTreeActionType and place it in the message subdirectory. Its package should be widgettest.message. This class provides constant,
type enumerated variable values for use in the message. The actions that this class
defines are add, delete, and change nodes. Optionally, the shared JTree may also
define methods to lock and unlock a node.
A partial implementation of this class is shown in Figure C.3.
C.5.2
The Message
The second step is to create the message for the JTree. This class is passed between
shared JTree models. The message contains an action type and a payload. All