Ide/Code Experts
IDE |
---|
Visual Prolog IDE contains several Code Experts:
- The Project Settings feature, which generates all the default code, resources, and make-scripts for an application. It also handles modifications of project settings.
- The Source Browser is used for searching of Visual Prolog names used in the edited project. This searching is accomplished in all files registered in this project.
- The Insert feature simplifies inserting of standard Visual Prolog program elements into the editing source code.
- The Code Expert is a nearly deprecated tool, which is today only used to control menu bindings for the Task Window in an MDI application. In a project that contains old migrated resources it can also lay a rtole for these.
Source Browser
The main aim of this tool is multi-file searching for Visual Prolog names used in the project. Displayed in the Source Browser dialog information is gathered by the compiler while compiling of the project files. Therefore, to update the "browse"information about any modifications in source files you need to recompile these files (Build menu commands can be used).
Search Results
The central pane of the Source Browser dialog displays Visual Prolog names, which are found in the project.
Type in some string into the Search for box and press Enter to activate the search operation.
After the search will be accomplished the central pane of the Source Browser dialog will display the tree of classes, interfaces, and class implementations in which the Search has found program items (of selected types) with names containing the specified substring. All items are prefixed with the same icons, which are used in the Project window. Clicking plus icons before a class/interface/implementation you can unfold it and see names, which are found in it.
Double-click any name will open the correspondent file in the text editor and jumps to this name.
When in the central pane of the dialog, the right mouse button will open the pop-up menu containing 2 commands:
- Go to Declaration
- This command jumps to the declaration of the selected name.
- Go to Definition
- This command jumps to the definition of the selected name.
Options
Search for:
- Here you enter a string to search for. The search string can be specified by selecting a substring in the text editor before calling the Source Browser dialog. The selected text will appear in the Search for box.
The Source Browser will search for the specified substring in any place of names (not only in the beginning). It will display all names containing this substring.
Search in:
- Selection in this group of check and radio buttons determines types of user defined names that will be displayed in main pane of the Source Browser dialog. Here you can select:
- All
- If you check ON the All check box, the Source Browser dialog will search the specified substring among all program items. In this case, any other check boxes will be disabled.
- The program item types you can specify in this group box are:
- Predicates
- Specifies to search among predicates.
- Facts
- Specifies to search among facts.
- Domains
- Specifies to search among domains.
- Constants
- Specifies to search among constants.
- Classes
- Specifies to search among class names.
- Interfaces
- Specifies to search among interface names.
- Also you can select whether search for declarations or definitions of names or for both declarations and definitions of names:
- Declaration
- Specifies to search only for declarations of items.
- Definition
- Specifies to search only for definitions of items.
- Both
- Specifies to search both for definitions and declarations of items.
Stay Open
- When it is checked OFF, then double-click (or select the Locate) any name will opens the correspondent file in the text editor and jumps to this name. The Source Browser dialog will be closed.
If this check box is checked ON, then the Source Browser dialog will NOT be closed when double-click (or select the Locate) a name.
Use Regular Expressions
- See Regular Expressions for details.
Insert Commands
The Insert menu commands simplify insertion of Visual Prolog program elements into the editing source code. Most of these commands use Browse information generated by the compiler. Therefore, in order to your new names appears in the dialogs of the Insert menu commands, you need to compile the editing file using the Build | Compile (or Ctrl+F7) command.
Constant
- Invokes the Insert Constant dialog containing a list of names of all constants gathered in the browse information while compilation of the project modules.
pi [math::]
- Each line contains a constant name followed by the name of a class or an interface in which this constant is defined. Constant names in the list are sorted alphabetically.
Select the required constant name and press OK. The selected constant name, preceded with the name of a class or an interface in which this constant is declared, will be inserted into your code. For example:
math::pi
Domain
- Invokes the Insert Domain dialog containing a list of names of all domains gathered in the browse information while compilation of the project modules.
windef_list [vpiDomains::]
- Each line contains a domain name followed by the name of a class or an interface in which this domain is defined. Domain names in the list are sorted alphabetically.
Select the required domain name and press OK. The selected domain name, preceded with the name of a class or an interface in which this domain is declared, will be inserted into your code. For example:
vpiDomains::windef_list
Class
- Invokes the Insert Class dialog containing a list of names of all classes gathered in the browse information while compilation of the project modules.
Each line contains a class name. Class names in the list are sorted alphabetically.
Select the required class name and press OK. The selected class name will be inserted into your code. For example:
vpiCommonDialogs
Interface
- Invokes the Insert Interface dialog containing a list of names of all interfaces gathered in the browse information while compilation of the project modules.
Each line contains an interface name. Interface names in the list are sorted alphabetically.
Select the required interface name and press OK. The selected name will be inserted into your code. For example:
outputStream_string
Predicate
- Invokes the Insert Predicate dialog containing a list of names of predicates gathered in the browse information while compilation of the project modules.
cursorremove(Win), [vpiEditor::] ... cbgetmetafile() -> MetaFile, [vpi::]
- Each line contains a predicate (or a function) name followed by the name of a class or an interface in which this predicate (function) is declared. Predicate (function) names in the list are sorted alphabetically. Function names are followed by names of return values, like this: cbgetmetafile() -> MetaFile.
Select the required predicate (function) and press OK. A pattern of the default call of the predicate (function), preceded with the name of a class (or an interface) in which it is declared, will be inserted into your code. For example:
vpiEditor::cursorremove(Win), ... MetaFile = vpi::cbgetmetafile(),
Fact
- Is enabled only when an edited file is a class implementation.
- Invokes the Insert Fact dialog containing names of facts and fact variables declared in the edited class implementation. Each line contains a fact or a fact variable. Names in the list are sorted alphabetically.
- Select the required fact or the fact variable and press OK. A pattern of the default call of a fact or a fact variable will be inserted into your code.
Qualification
- To use this command you should previously select some name.
- Invokes the Scopes for 'selectedName' dialog containing a list of scopes (names of interfaces and classes) in which the selected name is declared.
Insert New GUID
- Generates a new GUID value and inserts it into the current position.
RGB Value
- Invokes the common Color dialog. In this dialog you can select the desired color and press OK. The constant (if it is declared in the vpiDomains class), for example vpiDomains::color_Black, or an explicit numeric value of the selected color, for example 0x808040, will be inserted into your code.
Font Name
- Invokes the common Font dialog. In this dialog you can select the desired font name and the font size and press OK. Descriptions of the selected font name and the font size will be inserted into your code, for example:
"Times New Roman", 12
File Name
- Invokes the common Get & Insert File Name dialog. In this dialog you can browse and select the desired file name and press OK. The selected filename with an absolute path will be inserted into your code, for example:
@"C:\Vip6_Tests\My_Test\TaskWindow\Toolbar\Toolbars.ph"
Directory Name
- Invokes the common Set New Directory dialog. In this dialog you can browse and select the desired directory and press OK. The absolute path to the selected directory will be inserted into your code, for example:
@"C:\Vip6_Tests\My_Test\TaskWindow\"
Include File
- Invokes the common Get & Insert File Name dialog. In this dialog you can browse and select the desired file name and press OK. The selected filename with the path relative to the project Include Directories (as they are specified in the Directories tab of the Project Settings dialog) will be inserted into your code, for example:
#include @"TaskWindow\Toolbar\Toolbars.ph"
Date Stamp
- Inserts the current date comment into the current position. The date string is formatted according to the default short date format for the computer locale. For example:
24.09.08
Code Expert
The Code Expert is a nearly deprecated tool, which is today only used to control menu bindings for the Task Window in an MDI application. In a project that contains old migrated resources it can also play a role for these.
"Modern" dialogs, forms and custom controls are handled by the
You can activate the Code Expert when the focus is in the IDE Designer by selecting the Code Expert command in the mouse pop-up menu (or in the View menu, or alternatively by clicking the Ctrl+Shift+W hot key). Also you can activate the Code Expert when the focus is in the Project window and one of dialog or window type resource files is selected. Otherwise, the Code Expert command is disabled or the IDE displays the warning that the selected file is not associated with a dialog, window, form, or IDE control.
The name of the selected dialog or window file is displayed in the Code Expert title. On the picture below it is TaskWindow.
In the upper line of the Code Expert you see 3 radio buttons: All, Handled and Unhandled. Selecting among them you can specify which type of events will be displayed in the central pane:
All
- All events coming to the dialog or the window are displayed.
Handled
- Only events that are caught (Handled) by the correspondent listener or responder are displayed.
Unhandled
- Only events that are not caught (Unhandled) by the correspondent listener or responder are displayed.
In the central pane of the Code Expert dialog you see the tree of events that come to this dialog or form. Notice that the event tree displays all possible events that can come to a dialog or a form. So for some dialogs/windows the event tree can display some extra events that never come to these dialogs/forms. For example, if a dialog does not have scroll bars, its listener never receives HScroll and VScroll, but you can see these events in the event tree.
Handled events are marked with , and names of handler predicates are displayed after event names. Unhandled events are marked with .
Notice that the code for the predicate generatedInitialize is 100% automatically maintained by the Code Expert. You MUST NOT make any manual correction of this predicate since any your corrections will be overwritten while the resource compilation. You can also see this code is surrounded with special comments do not update it manually
In the central pane you can see the following groups of events:
- Window
- These are the events that came to the dialog/window as a whole entity.
- Menu
- This group of events exist only for forms. These are the events that came to the form from the menu.
- Scroll Bar
- These are the events that came to the dialog/form from the dialog/form scroll bars. Notice that these are not events from the scroll bar controls that you place inside dialogs/forms (events from the scroll bar controls you can see in the Control group of events).
- Control
- These are the events that came to the dialog/form from controls placed in the dialog/form.
- Key
- This group of events exist only for windows. These are the keyboard events.
- Mouse
- These are the events that came to the dialog/form from the mouse.
- Miscellaneous
- These are the miscellaneous events that do not fit to any of the previous types. They are timer, end session events and etc.
The Window, Menu, Scroll Bar, Control, Key, Mouse and Miscellaneous nodes in the events tree can be preceded with the or icons. Pressing on these icons expands or collapses the correspondent node.
In the bottom of the Code Expert there are 2 buttons Add / Delete and Set:
Add / Delete
- When an event selected in the event tree is Unhandled, this button has the caption Add. By pressing this button, you can add  the clause handling this event into the dialog/form. In addition, the default declaration and definition for the event handling predicate are generated.
When the selected event is Handled, then this button has the caption Delete. Pressing the Delete button, you can delete the clause handling this event from the dialog/form.
Set
- This button is enabled only when the selected event is Handled. Using the Set button, you can change the name of the event handling predicate. The clause for the new listener will be generated appropriately. However, the Code Expert will not delete/change code for the previously used listener.
Notice that when the selected event is Unhandled, the Set button is disabled, but in spite of this, you can type in the desired name of listener into the edit control. This name will be used instead of the default name when you press the Add button.
There are some advantages and some disadvantages to using the Code Expert. The main disadvantage is that the code experts insert some extra comments, which used to locate the source code at a later time. However the advantages are:
- It saves a lot of typing.
- It gives a standardized way of handling things, which other Prolog programmers will know.
- You know your application from the user interface; then by using the code experts, you can easily come to the source code through selection of the user interface component.
The Code Expert can automatically update the source code, when the layout or attributes of a user interface component are modified. This automatic updating is always done only inside comment brackets marked by:
% This code is maintained by the IDE. Do not update it manually ....% Some code handled by the Code Expert % end of automatic code