This page last changed on Apr 30, 2007 by scytacki.
The view/controller system in OTrunk is a bit tangled up right now. Here is a list of its different parts and how they are used. This is excluding the OTController classes which are really similar in functionality to these classes but they haven't been merged yet.
- views are really controllers. So most of these classes which start with OTView really should be OTController.
- swing specific - many of these classes are specific to using swing JComponents. This framework should support swt and xhtml based views.
- overlap between the OTViewContainer and OTViewFactory.
- view lookup - looking up views too restrictive once there are several views for the same object.
- OTViewContainer - an interface to the container of a view.
- OTViewFactory - creates views from objects given the type of view.
- OTViewService - the ot object used to configure a view factory in the otml file.
- OTViewContainerListener - notifies when the current object of a container changes
- OTView - parent of all views
- OTObjectView - creates and synchronizes a JComponent from an ot object
- OTXHTMLView - generates xhtml from an ot object
- OTMultiUserView - provides a special display of an ot object which aggregates multiple users
- OTViewFactoryAware - used by views which want access to the view factory
- OTXHTMLHelper - provided to OTXHTMLViews so they can create bitmaps of JComponents and ot objects.
- OTFrame - represents a window in the display.
The idea of the OTViewContainer is to provide a service to view objects. It is supposed to be used for:
- so the view can replace itself in its container.
- so the view can get views of objects it references.
- so the view can open a new frame with a particular object.
public void setCurrentObject(OTObject pfObject, OTFrame otFrame);
public OTObject getCurrentObject();
public JComponent getComponent(OTObject otObject, boolean editable);
- implemented by
- not used by OTLayout but it should be: OTLayout makes a new component and embeds it into the document without implementing a OTViewContainer to give to it.
This method changes the object displayed in the current container if the otFrame is null. If otFrame is not null then it replaces the object displayed in that frame. The only time the frame functionality is currently used is in hyperlink event handling.
- Views that call it:
- OTDocumentObjectView implements OTViewContainer and delegates setCurrentObject to the parent container if the otFrame is not null. This might be able to use OTViewContainerPanel.
- OTDocumentView calls setCurrentObject when a hyperlink is clicked.
- PfDocumentViewXHTML calls setCurrentObject when a hyperlink is clicked.
- A number of classes use the OTViewContainerPanel, and call the setCurrentObject method on it. These classes are not technically view objects so it is a bit confusing that they call a method on this interface. However they all the need the same functionality.
- The setCurrentObject method does not specify a view.
- It is implemented in three places slightly differently.
- there is a OTFrameManager interface now, so that can be used by the views with hyper links, and the otFrame can be removed from setCurrentObject.
- there should only be one swing implementation of this.
- this is not used by a view, the places where it is used could be fixed so it isnt used. But it seems useful to keep this symmetry.
This method gets a component from the view container it could be fully replaced by methods in the viewfactory.
It has an editable flag which is not general enough. Just like the setCurrentObject above it doesn't allow specifying the type of view which should be used.
OTViewContainer is currently passed to a view though OTObjectView.initialize(). In most of these views it is just bloat because they never use it. it is referenced 105 times Instead there should be a OTViewContainerAware interface which views implement that need to access the view container. Currently the only views that need this are
the hyperlink views. The getComponent method will be removed.
The unsolved problem is how to let a caller of setCurrentObject specify a particular view.
public OTViewFactory createChildViewFactory();
public void setUserList(Vector userList);
public JComponent getComponent(OTObject otObject, OTViewContainer container, boolean editable);
public abstract OTView getView(OTObject otObject, Class viewInterface);
public OTObjectView getObjectView(OTObject otObject, OTViewContainer container);
public void addViewEntry(Class objectClass, Class viewClass);
There is only one implementation of the view factory: OTViewFactoryImpl
This is currently only used by the reportviewer. It is used so a special child view factory can be setup which has a set of users. Which will then make the viewFactory try to create a OTMultiUserView instead of a OTObjectView. It is a child of the main view factory so it can inherit all the view entries of the parent.
This is only used by the reportviewer.
This is used by the 3 implementations of OTViewContainer and by the PfViewPrinter. PfViewPrinter is an application which takes an otml file and generates a set of images from it. getComponent is called to get a component to be printed.
This is most configurable way to get a view. It takes an otObject and a viewInterface. It is used by:
- OTMLtoXMLConverter to get a view to be turned into an image. It first looks for a view that implements OTPrintDimensions. And if not then it looks for an OTObjectView.
- OTViewFactoryImpl uses it to implement getObjectView by looking for an OTObjectView and then calling initialize.
- OTDocumentView uses it to look for an XHTML view of embedded objects. If an object has this kind of view that is used instead of the JComponent view.
- PfResponseTextService also looks for an XHTML view of the response object it is working with. This is because responses have xhtml views, and can have embedded objects like the OTDocumentView
- OTViewFactoryImpl uses this to implement getComponent.
- OTViewContainerPanel uses this to implement setCurrentObject
- OTMLToXHTMLConverter uses it to get the main view which it will be saving, it doesn't use getView for some reason. it also uses getObjectView to get the component view to be turned into an image. It has to use both getView and getObjectView because otherwise initialize is not called.
- OTViewService uses this to setup the viewfactory with viewEntries
- initialize being called by getObjectView makes it unclear which method to use when.
public void initialize(OTObject otObject, OTViewContainer viewContainer);
public JComponent getComponent(boolean editable);
public void viewClosed();