BDT: Set a Source File Extension
BDT recognizes and treats certain files as BBj source code files. This means the files will, by default, open with the BBj CodeEditor, and can run as either GUI or BUI BBj programs from inside of Eclipse/BDT.
Three factors are necessary for this recognition, and all three must be true:
-
The file must have a file extension associated with the BBj Source File content type.
-
The file must exist inside a BBj Project.
-
The file must be included in the Source Path for that BBj Project.
Recognized File Extensions
BDT automatically recognizes files with predefined extensions as having the BBj Source File content type. To see the list of these recognized extensions in MS Windows, go to Window > Preferences, select General > Content Types, and in the Content types listbox, expand and select the Text > BBj Source File entry as shown in Figure 1:
Figure 1. Content Types in Eclipse
The predefined file extensions are listed in the File associations listbox. They are locked so that they cannot be removed, but you can add your own file extensions to that list. To add your own file extension to the list, follow these steps:
-
In the Content Types preferences window, select the Text > BBj Source File entry selected as shown in Figure 1.
-
Click the [Add...] button next to the File associations listbox (the highlighted button in Figure 1). This opens the Define New Content Type Association window shown in Figure 2.
Figure 2. Adding a Content Type Association for *.sbj Files
-
Enter your desired extension, as *.<extension>, in the Content type field in Figure 2. For demonstration, Figure 2 creates a file association for the *.sbj file extension, but you may choose any file extension not already set in Eclipse.
-
Once you have entered the extension, click the [OK] button followed by the [Apply and close] button. The File associations window will show the new association without a padlock icon (see Figure 3 below).
Figure 3. The New File Association for *.sbj Files
In a BBj Project
Remember that even with the new file extension, your BBj Source Files must be contained in a BBj Project for BDT to offer the BBj CodeEditor and run them. The reason for this is that only BBj Projects have a Source Path, which is an explicit list of all of the files in that project that it should treat as BBj source code. We’ll cover that part in a minute. For now, just be aware that your BBj Source Files need to be somewhere in a BBj Project — they can be in the root folder or any subfolder you create under that root folder. In our example (see Figure 4 below), our clock.sbj and cowsAndDogs.sbj files are in a subfolder named src, in MyBBjProject:
Figure 4. BBj Source Files in the MyBBjProject Project
In the Source Path
BDT relies on an explicit list of the files to know which files it should treat as BBj source code. For a detailed explanation, see the BDT Resources Model help document. Now that you have added a file association for your files (the .sbj extension in this demo), BDT will recognize any files with that extension that you add to a BBj Project in the future. Because it will recognize them, it will automatically add them to the Source Path for you. But you may need to manually add to the Source Path any .sbj files already in a BBj Project. The BDT Resources Model help document explains how to do this; for now, just know that you can right-click your .sbj files in the BDT Explorer and select Source Path > Include to make that change. If Include is not offered as a menu item, the file is already included in the Source Path.
In Figure 4, you can tell that our clock.sbj and cowsAndDogs.sbj files have a recognized .sbj file extension (by the BBj file icon), but they are not yet included in the Source Path (they are in italics font).
Mission Accomplished
Once you have met all three of these requirements, you should be able to double-click any new .sbj file and have Eclipse open it in a BBj CodeEditor — ready for you to edit or even run in BBj.