3D PLM Enterprise Architecture |
Webtop |
Creating a CommandCreating a new command and adding it in a CATlet workshop |
Use Case |
AbstractThis article shows how to create a Command in the Portal. |
This use case is intended to show how to create a new Command and how to add it to a CATlet Workshop.
[Top]
The FoodStoreSelectionCommand is a use case of the CAAJApplicationFrame.edu framework that illustrates the creation of a new Command and its integration in the Portal application. This use case uses the Command, CommandBeanInfo and CSO class of the PortalBase framework.
A command can be considered as an extension of your CATlet. It allows to add interactive actions to a CATlet, without modifying the CATlet. A command is a functionality which can be started with an icon selection by the end user. The command can do a treatment and stop, or launching interactive dialog with the end user.
[Top]
![]() |
The FoodStoreSelectionCommand use case creates a new command which listens to user interactions with food items and updates the content of the current selection managed by the CSO object associated with the CATlet. This use case shows how to create and add commands to a CATlet. |
[Top]
To launch the FoodStoreSelectionCommand, you will need to set up the build time environment, then compile FoodStoreSelectionCommand and FoodStoreCATlet along with their prerequisites, set up the run time environment, and then execute the use case [1].
Specify the FilePrefix CAAGw0 in the Portal launching command, logon to the Portal and do the following steps:
[Top]
The FoodStoreSelectionCommand use case is one part of the Food Store use case. It is made of 2 classes named FoodStoreSelectionCommand and FoodStoreSelectionBeanInfo located in the CAAGw0FoodStore.mj module of the CAAJApplicationFrame.edu framework:
Windows | InstallRootDirectory\CAAJApplicationFrame.edu\CAAGw0FoodStore.mj\ |
Unix | InstallRootDirectory/CAAJApplicationFrame.edu/CAAGw0FoodStore.mj/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
Top]
To create the FoodStoreSelectionCommand, there are five steps:
# | Step | Where |
---|---|---|
1 | Create the selection command class file | FoodStoreSelectionCommand.java |
2 | Create the selection command BeanInfo class file | FoodStoreSelectionCommandBeanInfo.java |
3 | Create the Workshop file for the CATlet commands description | FoodStoreCATlet.workshop |
4 | Associate the Workshop file to the CATlet | CAAGw0CATletList.xml |
[Top]
The FoodStoreSelectionCommand file is as follows:
package com.dassault_systemes.japplicationframe.caa.catlet.command; ... public class FoodStoreSelectionCommand extends Command implements FoodListener { public FoodStoreSelectionCommand() { // --- initializes fields ... } public void initialize() { cso = getMasterCATlet().getCSO(); // --- subscribes to FoodEvents from the view ((FoodStoreView)getMasterCATlet().getView()).addFoodListener(this); } public void cleanup() { cso = null; // --- subscribes to FoodEvents from the view ((FoodStoreView)getMasterCATlet().getView()).removeFoodListener(this); } public void start() { // --- does specific code for command start (called when the Command Represenation is selected ... } public void stop() { // --- does specific code for command stop (called when the Command Represenation is unselected ... } public void foodCategorySelected(FoodEvent evt) { } public void foodItemSelected(FoodEvent evt) { // --- add or remove item containing in the FoodEvent from the CSO ... } ... } |
FoodStoreSelectionCommand derives from basic Command class. It implements the Command abstract methods initialize(), start(), stop(), and resume() called during the creation, activation, deactivation and destruction of the Command.
The life cycle of a command is a follow: When a end user selects the command representation (in this use case, a round button in the right toolbar) the command is created, and called successively on initialize and start methods. The command does its action, and after informs the CommandSelector (with an event), that it has finished its works. Then the command is called successively on the stop and cleanup methods, and it is destroyed. When a command is selected, it can be interrupted by a new selected command. In this case the first command is called on suspend, and will be called on resume as soon as the second command is finished.
[Top]
The FoodStoreSelectionCommandBeanInfo is as follows:
package com.dassault_systemes.japplicationframe.caa.catlet.command; ... public class FoodStoreSelectionCommandBeanInfo extends CommandBeanInfo { ... public BeanDescriptor getBeanDescriptor() { BeanDescriptor desc=super.getBeanDescriptor(); desc.setDisplayName(FoodStoreLanguage.getWidgetsString("Select")); return desc; } public Image getIcon(int iconKind) { // --- creates and returns the command icons for the specified iconKind ... } ... } |
FoodStoreSelectionCommandBeanInfo derives from CommandBeanInfo. It overrides the getIcon() and getBeanDescriptor() methods of the CommandBeanInfo, in order to specify its icons representation and its NLS display name for the end user.
Top]
The commands of a CATlet are described in a Workshop file, structured as a Java properties file. The FoodStoreCATlet.workshop contains the FoodStoreCATlet toolbar description with the Selection command. The FoodStoreCATlet is as follows:
# --- FoodStoreCATlet workshop description --- CATWorkshop=FoodStoreWorkshop FoodStoreWorkshop.Title=FoodStoreCATlet FoodStoreWorkshop.ResourceFile=basewidgets FoodStoreWorkshop.RightToolbar=Container1 FoodStoreWorkshop.DefaultHeader=Header1 # --- Header description --- Header1.CommandClass=com.dassault_systemes.japplicationframe.caa.catlet.command.FoodStoreSelectionCommand Header1.Classname=com.dassault_systemes.catweb.base.catlet.command.PermanentCommandHeader Header1.Icon=Resources/I_Select.gif Header1.IconFocus=Resources/IF_Select.gif ... # --- Right toolbar description --- Container1.Type=CmdContainer Container1.Title=caddie Commands Container1.Child=Starter1 Starter1.Type=CmdStarter Starter1.Header=Header1 Starter1.Next=Starter2 ... |
The Food Store Workshop file header defines the Header1 as the default selected header, so it defines the FoodStoreSelectionCommand as the default selected command. A command does not need to manage its representation. The view of a command is managed by the command header, which can use the default representation if no one is specified in the Workshop file (no declaration of Header.Classname for the command). In the use case, the Command Header associated to the Selection command is the PermanentCommandHeader. This header specifies that the selection command is not destroyed when unselected, unlike default command header (CmdHeader) which creates the command when it is selected and destroys it when it is unselected (See how to create your customize Command Header [2])
[Top]
The link between Workshop file and CATlet is done in the CATletList configuration file as follow.
... <CATlet icon="Resources/I_Wk13.gif" label="Food store" label.fr="Alimentation" label.en="Food store" label.de="Food store" label.ja="Food store" help="" help.fr="" help.en="" help.de="" help.ja="" workshop="FoodStoreCATlet.workshop" url="bean://com.dassault_systemes.japplicationframe.caa.catlet.FoodStoreCATlet"> </CATlet>... |
The FoodStoreCATlet.workshop is automatically read by the application, and the commands is created and added to the toolbar of the CATlet without modification of the CATlet.
[Top]
A command can be considered as an extension of your CATlet. It allows to add interactive actions to a CATlet, without modifying the CATlet. A command is a functionality which can be started with an icon selection by the end user. The command can do a treatment and stop, or launching interactive dialog with the end user. This use case show how to create a new command, the needed classes and how to associate a Command to a CATlet. The commands extend the Command class, and override the abstract methods of the creation, activation, deactivation and destruction. A command does not need to manage its representation. The view of a command is managed by the command header (See how to create your customize Command Header [2]).
[Top]
[1] | Building and Launching a CAA Enovia V5 Use Case |
[2] | Creating a customize Command Header |
[Top] |
Version: 1 [Sep 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.