## Extending Boa Constructor

Boa IDE can be extended by registering new Components, Controllers or Explorers.

Here is a backaground to the classes involved.

### Companions

For every control/object that can participate in the Designer, there has to be a Companion class. Companions implement the interfaces needed to interact with the Inspector and the Designer, basically the design-time behaviour. Companions can also define/override new properties for an object not picked up through reflection.

### Properties

Properties are defined by introspection and Companion classes.

e.g. When a wxTextCtrl is inspected in the Designer, the following is found by introspection:

    wxTextCtrl.GetValue()
    wxTextCtrl.SetValue(value)

So a Property named Value will be picked up automatically.

During introspection it's getter is called and the type is inspected. Simple types like ints, string, etc are handled automatically.

When a property is a reference to an object (for which the getter could possibly return None) or some other type which cannot be determined by introspection alone, a property definition must be added the associated companion class. Update the editors attribute. It's a dictionary of this format:

    PropertyName: PropertyEditorClass

Property values can be 'routed' in many ways.

CtrlRoute | Get and Set maps directly to component Get and Set. This type is automatically picked up by inspection.
CompnRoute | Get and Set maps to Companion Get and Set. Used when you need to fully customise a property. Used when the Get and Set methods of the control do not map to Get*, Set*, e.g. Show() and IsShown(). Used when new (possibly computed) properties are needed for which there are no methods on the component.
EventRoute | Used by Event definitions.
IndexRoute | Used by collection editor properties. Get and Set maps to Companion Get and Set with index.
NameRoute | Used when a property is split up into a set of flags. Get and Set maps to Companion Get and Set with name.

For property names which are not picked up by inspection the properties method can be overridden. Here you extend the inherited property dictionary.
Format:

    ProperyName: (RouteType, Getter, Setter)

There is also support for enumerated types, dependant properties, linked properties, non persisting, multi parameter and completely custom properties which overrides everything down to code generation (e.g. Anchors/Constraints).

### Property Editors

PropertyEditor classes are associated with types or property names.

They only focus on editing values and don't interface with the object whose properties they edit.

In the edit method a PropertyEditor should create an InspectorEditorControl derived class that will be used by the Inspector.

### Explorer Nodes

Explorer nodes plug into Models to provide their transport (storage). Various transports are defined by default, filesystem, FTP, etc.

### MVC Pattern

The Boa IDE is built on the Model-View-Controller pattern.

Here is a quick rundown of the roles:

### Models

Models usually represent the different types of source files. In the Editor the Model is the object in the top level notebook. Users do not perform actions on the Model directly but works through Views or Controllers.

To add a new model you need to do the following:

- Derive a new model class from EditorModels.EditorModel or a descendant.
- Add a 24x24 png image to Images/Palette. This will be used on the New palette page.
  It must have the same name as the modelIdentifier class attribute.
- Add a 16x16 png image to Images/Modules. This will be used as the IDE notebook and Explorer images.
  It must have the same name as the bitmap class attribute. Also, an image index must be allocated with Models.EditorUtils.imgIdxRange and set to the idx class attribute.
- Derive an new Controller from Controller.BaseEditorController or a descendant.
  Set the Controller's Model class attribute to reference your Model class.
- If additional views are needed, derive from an existing View and associate it with the Controller via the Controller's DefaultViews and AdditionalViews class attributes.

There are many examples of how to do this, e.g. see Plug-ins/PascalSupport.plug-in.py for a self contained example.

### Views

Views are visual classes that display or edit Models. In the Editor, Views plug into the Model in a second level notebook. Actions on the View are published to the Editor under the 'Edit' menu.

To add a new view to a model you need to do the following:

- Derive a new view class from Views.EditorViews.EditorView or a descendant.
- Add the view to the Controller class associated with the model.
  There are two tuples defining the views of the model, Controller.DefaultViews and Controller.AdditionalViews. Add your new view to one of them.

### Controllers

Controllers are a gateway between the user and the Model. Controllers are also factories for Models and manage the creation from the Palette and recreation from file. Controllers also publish the available Model actions to the Editor as Toolbar buttons or Menu items under the 'File' menu.

The Controller classes should also handle GUI code and interactions with the IDE like refreshing, dialog boxes and status indications.

### Plug-ins

New non-core Boa extensions should be added as plug-ins.
All modules in the Plug-ins directory of the form *.plug-in.py will be executed at startup.
If there is a Plug-ins directory defined in your resource config directory, it's modules will also be executed. You may also spesify another additional plug-in directory by setting Preferences->Plug-ins->Core support->extraPluginPath.

Boa Constructor - Application Help - Extending Boa Constructor