This simple but useful plug-in allows you to quickly add any file that is open in the Delphi editor to your current project. It eliminates the need to call up the Project Manager or Package Editor, select the Add feature and navigate to the file you wish to include. All of this is now handled with a simple mouse click.
This plug-in registers a new CodeRush command, QuickAddFileToProject, that is responsible for adding the active file in the Delphi source code editor to the current project. This command can be bound to a keystoke for instant access from the editor or a Delphi form.
In addition, a new menu item, "Add File To Project", is added to the IDE's context menu. When this new menu item is selected, the QuickAddFileToProject command is executed and the file being edited is added to the current project.
Suppose you have a project loaded in Delphi. Along with this project, you have one or more other units that are not owned by the project. In the screenshot below, the package for this plug-in loaded, with its main source file AddFileToProject6.PAS open; with it are two unrelated units (Unit1.PAS and RushIntf.PAS).
Now suppose we wish to add one of these "orphan" units, Unit1.PAS for instance, to our current project; what would we do? Well that depends on whether we are working with a standard project (*.dpr) or a package (*.dpk). The examples below assume the file Unit1.PAS is open and active in the Delphi IDE.
Working With a DPR
When working on a standard Delphi project, we have to perform the following steps:
Open the Project Manager
Right-Click on the project to display the Context menu
Select the Add... option to display a File Open dialog box
Navigate to the correct file
Click OK to add the file
Of course, there are some shortcuts.
We could bypass opening the Project Manager and use the Delphi shortcut Shift-F11. This will jump us straight to the dialog box where we still have to navigate and select a file.
And if the file we wish to add to our project is active in the IDE editor, the File Open dialog box defaults to the location of that file, making navigation even easier. But we still have to select the file and click OK to accept it.
Working With a DPK
When working on a Delphi package, things are a little different. We have to:
Open the Package Edtior
Right-Click on the package to display its Context menu
Select the Add... option to display the Add dialog
Either type in the full path to our desired file or click Browse to navigate to the correct file. Unfortunately, this time browsing does not default to the path of the file being edited.
Click OK to add the file
Again, there are some shortcuts.
We could bypass opening the Package Edtior and use the Delphi shortcut Shift-F11. This will jump us straight to the Add dialog where we still have to navigate and select a file. Or, if the Package Editor is open, we could simply click on the Add to package button. This will also bring us to the Add dialog. Unfortunately, both of these options still require the developer to navigate to the file and click OK to accept it.
Working With a This Plug-In
Using this plug-in, all one must do is right-click anywhere in the Delphi Editor to add the current unit to the project. Say we are working with the following package:
Right-clicking brings up the IDE's context menu. Notice the new menu item added to it:
Selecting this menu item immediately adds the file from the editor to our project, as the screenshot below shows. Note that this plug-in is smart enough to add our file to the appropriate location in a package (it won't add the PAS file to the Requires section).
The following transient message is displayed after successfully adding the file to your project:
If the process fails for some reason, an appropriate error message will be displayed instead.
This plug-in has one simple requirement. The files worked with have to exist on disk; that is they have to have been saved at least once.
Copyright 2007 Ackerson Software, All Rights Reserved.
Quick Add File To Project
Author: Rich Ackerson
Created: April 13, 2007
Plug-In Type: Standard
Options Page: No
This plug-in is currently supported.
This plug-in is not the property of Developer Express; it is the sole property of its author. As such, Developer Express cannot be held liable for any incidental damages that may be related to the usage of this plug-in.