3D PLM PPR Hub Open Gateway |
Product Modeler |
Creating a Product WorkbenchImplementing the CATIPRDWorkshopConfiguration Interface |
Use Case |
AbstractThis article presents the CAAPuiPRDWorkshopConfig use case which illustrates how to create a Product workbench. |
By implementing the CATIPRDWorkshopConfiguration, you can implement a complete Product Structure workshop with its toolbar and commands.
[Top]
CAAPuiPRDWorkshopConfig is a use case of the CAAProductStructureUI.edu framework that illustrates the ProductStructureUI framework capabilities.
[Top]
The goal of CAAPuiPRDWorkshopConfig is to demonstrate how to implement the CATIPRDWorkshopConfiguration interface. It consists of the following parts:
Our workbench which is represented by the
CAA Workbench menu entry, is now available in the Infrastructure solutions.
If activated, it behaves like the Product Structure workbench except that we
have a new toolbar with a command represented by the
icon.
[Top]
To launch CAAPuiPRDWorkshopConfig:
#CAAPuiPRDWorkshopConfig use case CATApplicationFrame CAAIPuiPRDWorkshopConfigFactory libCAAPuiPRDWorkshopConfig CAAPuiPRDWorkshopConfig CATIPRDWorkshopConfiguration libCAAPuiPRDWorkshopConfig |
[Top]
CAAPuiPRDWorkshopConfig code is located in the CAAPuiPRDWorkshopConfig.m module of the CAAProductStructureUI.edu framework.
[Top]
There are three parts in CAAPuiPRDWorkshopConfig:
We will now detail each of those sections:
[Top]
The implementation of CATIPRDWorkshopConfiguration is provided by our CAAPuiPRDWorkshopConfig class. Its purpose is to create the workbench, the toolbar and to do the layout the commands on it. Four methods need be defined:
... class CAAPuiPRDWorkshopConfig: public CATBaseUnknown { CATDeclareClass; public: // Standard constructors and destructors for an implementation class // ----------------------------------------------------------------- CAAPuiPRDWorkshopConfig (); virtual ~CAAPuiPRDWorkshopConfig (); /** * @see ApplicationFrame.CATIWorkbench#CreateCommands */ void CreateCommands(); /** * @see ApplicationFrame.CATIWorkbench#CreateWorkbench */ CATCmdWorkbench *CreateWorkbench(); /** * @see ApplicationFrame.CATIWorkbench#GetAddinInterface */ CATClassId GetAddinInterface(); /** * @see ApplicationFrame.CATIWorkbench#GetCustomInterfaces */ void GetCustomInterfaces (CATListPV *iDefaultIIDList, CATListPV *iCustomIIDList); private: // The copy constructor and the equal operator must not be implemented // ------------------------------------------------------------------- CAAPuiPRDWorkshopConfig (CAAPuiPRDWorkshopConfig &); CAAPuiPRDWorkshopConfig& operator=(CAAPuiPRDWorkshopConfig&); }; ... |
The CreateWorkbench method is called to create the workbench, the toolbar(s) and the command(s) of the toolbar(s).
The purpose of the CreateCommands method is to create all the command headers of our toolbar. Our command header class CAAPuiPRDWorkshopConfigHeader, is defined by way of the MacDeclareHeader macro.
Here a command named CAAPuiPRDWorkshopConfigCmd1 is created. It is located in the CAAPuiPRDWorkshopConfig shared library and its class is CAAPuiPRDWorkshopConfigCmd. The ShowProduct identifier will be used to locate resources related to this command.
The purpose of the GetAddinInterface method is to return the interface name to be implemented by all addin toolbar.
... CATClassId CAAPuiPRDWorkshopConfig::GetAddinInterface () { // Returns the interface name to implement an Addin to this workbench. return "CAAIPuiPRDWorkshopConfigAddin"; } ... |
GetCustomInterfaces is not used but nevertheless be implemented as an empty function.
... void CAAPuiPRDWorkshopConfig::GetCustomInterfaces (CATListPV *iDefaultIIDList, CATListPV *iCustomIIDList) { // should be empty! } ... |
[Top]
The command that gets executed must be of a class named CAAPuiPRDWorkshopConfigCmd as specified by CAAPuiPRDWorkshopConfig::CreateCommands. This class must also derives from the CATCommand class. The only method we need to override is the Activate method.
... class CAAPuiPRDWorkshopConfigCmd: public CATCommand { public: CAAPuiPRDWorkshopConfigCmd(); virtual ~CAAPuiPRDWorkshopConfigCmd(); /** * Activates our command. * @param iFromClient * The command that requests to activate the current one. * @param iEvtDat * The notification sent. */ virtual CATStatusChangeRC Activate(CATCommand * iFromClient, CATNotification * iEvtDat); }; ... |
In the Activate method, we just get the current window and display its title in a dialog box
... CATStatusChangeRC CAAPuiPRDWorkshopConfigCmd::Activate(CATCommand *iFromClient, CATNotification *iEvtDat) { CAAPuiPRDWorkshopConfigTRACE (">> CAAPuiPRDWorkshopConfigCmd::Activate"); CATApplicationFrame *pApplication = CATApplicationFrame::GetFrame(); if (NULL != pApplication) { CATDlgWindow * pMainWindow = pApplication->GetMainWindow(); CATDlgNotify *pNotifyDlg = new CATDlgNotify (pMainWindow, "CAAPuiPRDWorkshopConfig", CATDlgNfyOK); if (NULL != pNotifyDlg) { pNotifyDlg->DisplayBlocked ("Hello World!", "CAAPuiPRDWorkshopConfig UseCase"); pNotifyDlg->RequestDelayedDestruction(); } } RequestDelayedDestruction(); CAAPuiPRDWorkshopConfigTRACE ("<< CAAPuiPRDWorkshopConfigCmd::Activate"); return CATStatusChangeRCCompleted; } ... |
Now that we have completed the code implementation, we need to take care of the user interface with the help of resource files.
[Top]
There are three visible objects: the workbench, the toolbar and its command.
All files are located in the install_root/CAAProductStructureUI.edu/CNext/resources/msgcatalog/ directory, except the bitmaps for the icons which are in install_root/CAAProductStructureUI.edu/CNext/resources/graphic/icons/normal
The title of the CAAPuiPRDWorkshopConfig workbench is defined by the CAAPuiPRDWorkshopConfig.CATNls file:
CAAPuiPRDWorkshopConfig.Title = "CAA Workbench"; CAAPuiPRDWorkshopConfig.Help = "CAA Workbench (CAAPuiPRDWorkshopConfig use case)"; CAAPuiPRDWorkshopConfig.ShortHelp = "CAA Workbench"; ...Its position in the start menu and icon file name are defined by the CAAPuiPRDWorkshopConfig.CATRsc file:
CAAPuiPRDWorkshopConfig.Category = "Infrastructure"; CAAPuiPRDWorkshopConfig.Icon.NormalRep = "CAAPuiPRDWorkshopConfig_I";CAAPuiPRDWorkshopConfig_I.gif represents the workbench icon:
The title of the toolbar named CAAPuiPRDWorkshopConfigToolbar is also defined by the CAAPuiPRDWorkshopConfig.CATNls file:
CAAPuiPRDWorkshopConfigToolbar.Title = "CAA Toolbar 3";
The command:
The command CAAPuiPRDWorkshopConfigCmd1 are defined by three files:
CAAPuiPRDWorkshopConfigHeader.CATNls defines the screen tip, the documentation line and the command prompt input:
CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Title = "cmd3"; CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Help = "cmd3 long help text"; CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.ShortHelp = "cmd3 info"; |
CAAPuiPRDWorkshopConfigHeader.CATRsc defines the icon file name for the command:
CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Icon.Normal="CAAPuiPRDWorkshopConfigCmd_I"; |
CAAPuiPRDWorkshopConfig_I.gif defines the icon:
[Top]
This use case has demonstrated how to create a toolbar with a command:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | Application Frame Overview |
[3] | The CAA Command Model |
[4] | Creating a Workbench |
[5] | Creating an Add-in |
[Top] |
Version: 1 [Aug 2004] | Document revised |
Version: 1 [Oct 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.