PDA

View Full Version : difference between form and view


tsquires
Oct 3rd, 2004, 09:57 PM
Hi,

a little background - in the last swing app I wrote (which was a *long* time ago) I attached a mouse listener to a JTree so that nodes were selected on a right-click, to mimic windows select-before-popup behaviour.

After tinkering with RCP for a while I thought I'd try to implement the same behaviour as an interceptor (as an excercise to get to grips with RCP) in the petclinic - ensuring that *any* JTree in the app would get the desired behaviour.

Alas, it would seem that the views in petclinic aren't plumbed in so that FormComponentInterceptors can be hooked up.

This leaves me a bit confused now about the differences and relationships of views and forms.

Is there anyone with an understanding of how this all fits together that would be willing to educate me?

Thanks,
Trevor

oliverhutchison
Oct 3rd, 2004, 11:54 PM
Trevor,

a FormComponentInterceptor is resposible for postprocessing components created for a specific FormModel not postprocessing of components in general. We don't currently provide any kind of plugable interceptor functionality for the general case though it would be a nice feature to add.

Ollie

oliverhutchison
Oct 4th, 2004, 02:37 AM
Trevor,

the folowing class could be uses a general component interceptor. You'll need to provide your own implmentation of the postProcessComponent(JComponent comp) method:

public abstract class ComponentInterceptor implements AWTEventListener {

public ComponentInterceptor() {
Toolkit.getDefaultToolkit().addAWTEventListener(th is, AWTEvent.CONTAINER_EVENT_MASK);
}

public abstract void postProcessComponent(JComponent comp);

public void eventDispatched(AWTEvent e) {
if (e.getSource() instanceof JComponent) {
JComponent comp = (JComponent) e.getSource();
if (comp.getClientProperty("intercepted") == null) {
comp.putClientProperty("intercepted", Boolean.TRUE);
postProcessComponent(comp);
}
}
}
}

Ollie

tsquires
Oct 4th, 2004, 05:29 PM
Hi Oliver,

your last response was very enlightening, I hadn't considered doing it like that. I appreciate the effort.

However, I'm still a bit in the dark about the relationship between views and forms (because of the apparent differences in the way they are assembled).

As I'm typing this, the following occurs to me: is it as simple as... RCP forms are like HTML forms and Views are like - umm - HTML pages?

Thanks,
Trevor