XRCed Data Model
Data model used by XRCed is using a set of classes providing interface to the DOM objects. This allows easy manipulation of arbitrary fragments of the XRC file while caching only the editable data in the interface objects.
XRC file has the following structure:
<?xml version="1.0" ?> <resource> <object class="class_name" name="XRC_id"> <property_name>property_value</property_name> ... </object> </resource>
Where property_name stands for property name tags such as 'label', 'orientation', etc.
After parsing XRC into DOM (using xml.dom.minidom module) one 'xxx' object is generated for each <object> element, instantiating a class derived from xxx.Object base class (in module 'xxx'). For properties there is a base class class xxx.Property and specific derived classes such as xxx.FontProperty.
Module 'components' contains classes derived from xxxObject, which provide specific interface to various interface elements. This module is populated at run-time from the installed 'xxx-plugins' by the plugin manager subsystem.
I desided to use ModelViewPresenter paradigm for refactoring (in the limits of my grasp of this subject). The image below presents an overview of the new design.
- collection of objects managing interface elements, and associated event handlers.
- global model object used to interface XML and other data files.
- global presenter object, stores additional data needed for editing, view generation and updates Model when needed.
global listener AKA interactor object. It has Install method to setup event handlers to the view objects. The events are received by Listener and propagated to Presenter or processed in-place.
- can be considered a part of presenter. Stores data related to loadable components, component registration tasks. Used by view objects to generate interface for attribute panel, menus and tool panels.