Results 1 to 4 of 4

Thread: difference between form and view

  1. #1
    Join Date
    Sep 2004
    Posts
    4

    Default difference between form and view

    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

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    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

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    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:

    Code:
    public abstract class ComponentInterceptor implements AWTEventListener {
    	
    	public ComponentInterceptor() {
    		Toolkit.getDefaultToolkit().addAWTEventListener(this, 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

  4. #4
    Join Date
    Sep 2004
    Posts
    4

    Default

    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

Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  3. Replies: 3
    Last Post: Apr 29th, 2005, 06:09 AM
  4. Replies: 1
    Last Post: Jan 19th, 2005, 05:35 AM
  5. Replies: 10
    Last Post: Sep 3rd, 2004, 07:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •