This sample shows how to extend the Delphi IDE with the IOTAActionServices interface of ToolsAPI. IOTAActionServices performs basic file operations.
You can find the ActionServices sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples and then navigate to Delphi\VCL\ToolsAPI\ActionServices
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/Delphi/VCL/ToolsAPI/ActionServices/
This application creates and installs a wizard that perform these basic operations:
- open a project
- open, close, save, and reload a file
The wizard creates a form that displays all the open files in a list box and allows the user to perform operations on files by clicking the buttons in the tool bar located to the right. All the operations are performed within the IDE.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open ActionSv.dproj.
- Build ActionSv.bpl.
- Install ActionSv.bpl.
- Select Help > Test Action Services to run the wizard.
Implementation for the form shown when the wizard is executed.
The wizard class.
- TForm2 represents the form that is displayed when the wizard executes.
- TActionServices represents the wizard class.
- WizMain unit contains an initialization and finalization section. The initialization is responsible for adding the wizard to the BorlandIDEServices variable and the finalization is responsible for removing it.
- To perform the desired file actions, IOTAActionServices functions are used: OpenFile, OpenProject, ReloadFile, SaveFile, CloseFile. The BorlandIDEServices variable is first cast to IOTAActionServices and then the necessary function is called. For example, to save the file that is selected in the list box the next code is used:
(BorlandIDEServices as IOTAActionServices).SaveFile(ListBox1.Items[ListBox1.ItemIndex]);
- TActionServices is derived from IOTAWizard and IOTAMenuWizard, therefore it needs to implement all the functions of its ancestors: GetIDString, GetName, GetState and Execute from IOTAWizard and GetMenuText from IOTAMenuWizard.
- Being a menu wizard, the action services wizard is automatically added to the Help menu.