### Worksets

Worksets allow you to organize files you are working on into groups for easy access. It also allows you to generate makefiles, use source control commands, etc. Worksets are implemented as a plugin, using the public plugin API (in other words, if you don't like the way they work, you can write your own).

#### Creating a workset

To create a new workset, choose the New Workset menu item in the File Menu.

You may then drag&drop files into the new window from the Tracker.

When you drag the file CDEngine.cpp into the Workset window, an New Group is automatically created and the file is added to it.

You may alternatively drag an entire folder into the workset window:

##### Add as group dialog

After you drag an entire folder to the worksets window, you are presented with a dialog in which you may name the new group that gets created and you may choose which types of files in the dropped folders to add to the new group in the workset. By default the group will be named identically to the name of the folder you dragged into the window.

In our example we choose to only add .cpp files to the first group and we leave the group named CDButton. All of the .cpp files from the folder get added.

Besides allowing you to automatically add files to a group, dragging a folder into the workset window associates the pathname of the folder with the group. This is useful for opening the folder of the group later.

Next we will add the .rsrc file, into a separate group. We can create a new empty group by using the New group menu item in the Workset window File menu:

Rename the new group Resources and drag the CDButton.rsrc file into it. We can then add yet another group, this time we call it Misc and add some header files that are not really part of the application we are trying to build, but we use them often and it will be convenient to have them as a reference. Also, we can add the makefile for the application if we already have one.

##### Edit group name dialog

The Edit group name dialog in the above example can be opened by selecting the group and using the Alt-E shortcut or by selecting it from the group context menu. Note that you may choose whether a given group gets included in a makefile. Since none of the files in the Misc group are source files used to build our example binary, we select not to include them here.

Also, you may choose the directory the group belongs to. If you add the group by dragging a folder into the workset window, the folder automatically becomes the group's directory. If you create a new group using the New group menu item, the group has no directory associated with it. If a group has a directory associated, you may double click the group item and the directory will open in the Tracker. Also, you may update the contents of a group by hitting the Update button - you will get the Add group dialog and will be able to select which types of files you want to add - c/cpp files, headers, makefiles, etc. This way you may easily add files to a group that were added to a folder after you created the group.

Also, note that the Dragger.h and View.h files have a lock icon - they are read-only. You may use the context menu to make them writable or to check them out if you are using a source control system. If your source control system locks files that you do not have checked out, the lock icon is a conveninet way of finding out which files are checked out at a glance.

#### Info panel

If you click on a file or a group with the middle mouse button or if you hold down the Control key while clicking, you get an info panel:

#### File context menu

If you click on a file or a group with the right mouse button or if you hold down the Alt key while clicking, you get the context menu:

Open (also hitting Return or double-clicking a file) will open the selected files in a document window. If the files are not text files, they get opened by their preferred application (resource files in FileTypes, etc.). Remove (also Alt-T and Backspace) will remove them from the workset. The rest of the commands in the context menu are completely configurable. Included are commands that allow you to check the selected files in and out using a source control system, turn the writable bit on and off by using chmod and touching the files to force a recompile.
To Edit the items or add new ones, open your UserStartup file and edit the lines that contain AddToWorksetsFileContextMenu, AddToWorksetsGroupContextMenu and AddToWorksetsContextMenu:

    AddToWorksetsFileContextMenu -name 'Check out' 'cho $SELECTED_DOCUMENTS' -worksheet -appendToEnd
    AddToWorksetsFileContextMenu -name 'Cancel check out' 'chcan $SELECTED_DOCUMENTS' -worksheet -appendToEnd
    AddToWorksetsFileContextMenu -name 'Make read only' 'chmod -w $SELECTED_DOCUMENTS'
    AddToWorksetsContextMenu -name 'Paste path' '$SELECTED_DOCUMENTS' -worksheet -pasteOnly

The AddToWorksetsFileContextMenu, AddToWorksetsGroupContextMenu and AddToWorksetsContextMenu commands work much like the commands in the Execute command dialog. The syntax is similar:

    AddToWorksetsFileContextMenu [-name <commandName>] '<someCommand>' [-worksheet] [-appendToEnd] [-pasteOnly]

AddToWorksetsFileContextMenu adds items only to the file context menu, AddToWorksetsGropuContextMenu adds items only to the group context menu, AddToWorksetsContextMenu adds items both to the group and the file context menu. `-worksheet` is used to specify that the command gets executed in the worksheet rather than in the background. `-appendToEnd` is used in conjunction with the `-worksheet` command and ensures that the command gets pasted to the end of the worksheet, rather than into the current selection. `-pasteOnly` causes the command to not get executed - the user has to hit return to get it executed.

The following variables are currently supported by the execute dialog syntax:

$SELECTED_DOCUMENTS | get the paths to all the selected documents/groups
$WORKSHEET $WORKSHEET_DIR | get the worksheet path and the worksheet parent path
$EDDIE $EDDIE_HOME | get the Eddie app path and the Eddie app parent path

#### Group context menu

Group context menu works like the file context menu - you may open it by selecting a group and right-clicking or Alt-clicking on the item. If a group has a directory associated with it, Open (also hitting Return) will open the corresponding folder in the Tracker. Edit name (Alt-E) will bring up the Edit group name dialog.

#### Generating a makefile

The Worksets window allows you to create or update a makefile. It includes lists of all the source files from your workset into the makefile. The lists are grouped into sublists, belonging to the individual groups. Depending on your build setup, you may use the $(SRCS) variable to build all your sources or the individual sublists if you are building separate library or archive files from the different source tree subdirectories. Note that in our resulting makefile there is also a list for $(RSRCS) - resource files.

If you have the makefile open in an Eddie window, the resulting text will be pasted directly into the window.

Eddie generates the following lists if the corresponding file types are included:

$(SRCS) | list of .cpp and .c files
$(RSRCS) | list of resource files (created by FileTypes, etc.)
$(REZSOURCES) | list of .r files for the resource compiler
$(ASMSOURCES) | list of .a, .s assembly files
$(MISCSOURCES) | Other (.l, .y, etc.)

Once the makefile is generated, you may make changes to it and later, after you have added more files to your workset, use Export makefile again. All your changes will be preserved - Eddie only edits the text in between the # @src->@ and # @<-src@ lines.

##### Which makefile gets selected

When you invoke the Export makefile command, Eddie looks into the parent directory of your workset to find a file named makefile or Makefile. If it finds one, it inserts the generated portion of the makefile inside the # @src->@ and # @<-src@ lines or appends it to the end. If there is no makefile yet, it will use a makefile template - ~/config/settings/Eddie/MakefileTemplate. This file is generated the first time you use the Export makefile command. Once you have a template file in your settings folder, you may edit it any way you like. The default MakefileTemplate is compatible with version 2.0 of the generic makefile included with sample source code from the Be DTS. The MakefileTemplate gets copied into your workspace parent directory and the generated makefile commands get inserted into it.

Export Makefile As... lets you specify which makefile to export into.

##### Deciding which groups are included in makefile generation

You may want to not include some files in the resulting makefile - you may have them in the workset just for reference. To do that, place them in a group that has the Include in make checkbox turned off. Anything in a group like that will be ignored when generating a makefile. In fact the only group that has the Include in make checkbox turned on by default is one created by dragging a folder into the workset window. You may turn this checkbox on and off in the Edit group name dialog.

##### Importing into a workset

You may use the Import From... to populate a workset. Currently you may import from a makefile generated by using the Export makefile.... You may also import from other makefiles that were not generated by Eddie. This only works though if the makefile contains a list of source files assigned to the variable SRCS and a list of resources assigned to RSRCS.

##### Importing from a BeIDE project

You may also use the Import From... menu item to import from a BeIDE project file. The Workset window opens the selected project in BeIDE and uses scripting commands to import the files from the project.

##### Editing a workset as text

A workset is stored internally as a text file. While you should be able to do any alterations to the workset by using the workset UI, you may edit the workset as text. You may force Eddie to open a workset as a text file by dragging a workset file onto an open Eddie window and holding down the Alt and Win keys.

#### Workset window keyboard shortcuts

Alt-T, Backspace | Remove item from workset
Tab | Select next item using alphabetical order
Shift-Tab | Select previous item using alphabetical order
Alt-E | Group item only - show the edit group dialog
type several letters | Select the item, starting with the letters typed