Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Commit intercept for dropped components?


Hi,

The layout edit policy gets called to create the appropriate commands to do the actual action:
  • getAddCommand(Request) when a component is being added (i.e. it exists already and is being moved from some other parent to this parent)
  • getOrphanChildrenCommand(Request)  when a component is being removed from a component because it will be added later to another component
  • getMoveChildrenCommand(Request) when a component is being moved within the same parent
  • getCreateCommand(Request) when a component is being created and dropped on the parent (in this case the component did not exist before)

As I recall, your internal model is basically the info describing the current state of the FormLayoutEditPolicy. My suggestion is that when a change occurs, you simply mark your current model as stale. And then the next time you need the data you can reconstruct it. That will be safer than trying to keep up with the individual changes as they occur. The changes will be flying in, you may get several in a row for the same component, so it is better to just mark the entire state as state and then rebuild it the first time the user needs anything from it, like for a drop or remove.

Now how do we determine that it is stale. The simplest way we be if there is anytime the container has been validated (which happens whenever a child is added/removed/given a new constraint), then it is marked stale. This is easiest though it may mark it stale when it really doesn't need to. But the structure should be quick to rebuild and it doesn't need to be rebuilt until next time it is needed. The way to do that is:

In your FormLayoutEditPolicy:

private class FormLayoutComponentListener extends VisualComponentAdapter {
        public void componentValidated() {
                ...mark your internal data has stale...
        }
}

private FormLayoutComponentListener componentListener = new FormLayoutComponentListener();

public void activate() {
        super.activate();
        ControlProxyAdapter beanProxy = (ControlProxyAdapter) BeanProxyUtilities.getBeanProxyHost((IJavaObjectInstance) getHost().getModel());
        if (beanProxy != null)
                beanProxy.addComponentListener(componentListener);
}

public void deactivate() {
        ControlProxyAdapter beanProxy = (ControlProxyAdapter) BeanProxyUtilities.getBeanProxyHost((IJavaObjectInstance) getHost().getModel());
        if (beanProxy != null)
                beanProxy.removeComponentListener(componentListener);
}


Rich



Gerald Rosenberg <gerald@xxxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

06/22/2006 01:14 PM

Please respond to
Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

To
Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>
cc
Subject
[ve-dev] Commit intercept for dropped components?





Working with FlowLayoutEditPolicy as a prototype for FormLayoutEditPolicy.  

Looks like I can use
"getCreateCommand(CreateRequest aRequest)", etc. as intercepts to supply candidate constraints computed based on the request/editpart parameter.  The computation is made against an internal model of available/used constraints.

Looks like I can use "
createListener() ... new EditPartListener.Stub()" to recognize add and remove component events.  This will allow me to commit a corresponding update to my internal model.

What can I use as an intercept to recognize completion of a component move *within* a container?  Need a commit trigger to update my model.

Also, should I be getting "removingChild" and "childAdded" events when moving a component between containers?  When crossing between the containers, VE does switch from issuing
"getMoveChildrenCommand" to issuing "getOrphanChildrenCommand" and "createAddCommand".  On the mouse button release, I am not getting any events -- should remove and add events be generated at this point?

Thanks,
Gerald
_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top