Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] Methods of BeanProxyAdapter


Hi Janak,


"Janak Mulani" <janak.mulani@xxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

11/03/2005 09:20 PM

Please respond to
Discussions people developing code for the Visual Editor project

To
"ve-Dev@Eclipse. Org" <ve-dev@xxxxxxxxxxx>
cc
Subject
RE:  [ve-dev] Methods of BeanProxyAdapter





Hi Rich,

Thanks for your help.

More questions:

1. Now I am able to see the widgets on the canvas and also see the effects
of property changes immediately. However, there is one problem. If I close
the Visual Class and open it again, I don't see anything. It requires at
least 3-4 presses of "synch/refresh" button before I can see the images on
the canvas. Could you please explain this behavior? Isn't initial parsing
same as refresh? If not then why are multiple refreshes required? Shouldn't
the first refresh itself do the job?


--- RLK I did recently find an ordering problem with SWT Shell because the addToFreeForm was called AFTER the shell was instantiated in the initial refresh. This meant that the shell took its default visibility value of false, and so didn't show any of the children. This only happened because by default SWT Shells are not visible. You need to explicitly make them visible.

But the only other difference that I can think of between the first time and the rest is that the first time the entire EMF model is built up without having any beans instantiated on the remote vm. Then one by one the top-level beans are instantiated. First the "thisPart" bean, then each freeform bean in order they are found in. There could be some ordering problem of the beans being instantiated. The rest of the time all of the beans are instantiated as the changes occur.

2. Expressions

An _expression_ is a sort of collection where we put many method invocations.
All the methods are executed in the sequence they have been put in the
_expression_ when he _expression_ is invoked.

So if I instantiate a Bean in the target VM and I want to set some
properties on it at creation time, I put all such methods in the same
_expression_.

Is there a way of doing conditional execution of methods in an _expression_?
I.e. suppose a method returns a Boolean value, and based on the value I want
to execute certain methods, how do I test the result of such a method. For
example, for a table, I want to set a model on it in the Target VM if it
does not already have a model. So the _expression_ has:
- call isTableModelSet on table's _expression_ IProxy
- the above method returns a boolean, based on its value...
- call setTableModel on table's IProxy


--- RLK There are two ways, depending on the complexity of the code. If you need to do some pretty complex stuff, then what you do is have a class with static methods on it added to the remote vm path (for example org.eclipse.ve.internal.jfc.vm.JMenuManager, adding a JMenu item is complicated because it could be a String, an Action, or a JButton, so we put all of that complicated code directly on the remote vm and instead of trying to do it directly from the IDE, we instead do an IExpression method invoke on the static method in this class and pass in the necessary parms).

But there are simple tests available in IExpressions too. You use the createIfElse _expression_. For example the following:

        IExpression exp = proxyFactory.createExpression();
        IProxy valueToTest = exp.createInfixExpression(ForExpression.ROOT_EXPRESSION, InfixOperator.IN_EQUALS, 0);
        exp.createPrimitiveLiteral(ForExpression.INFIX_LEFT, (byte) 3);
        exp.createPrimitiveLiteral(ForExpression.INFIX_RIGHT, (short) 3);
        exp.createIfElse(true);
        exp.createProxyExpression(ForExpression.IF_CONDITION, valueToTest);
                ExpressionProxy trueProxy = exp.createProxyAssignmentExpression(ForExpression.ROOTEXPRESSION);
                exp.createInfixExpression(ForExpression.ASSIGNMENT_RIGHT, InfixOperator.IN_PLUS, 0);
                exp.createPrimitiveLiteral(ForExpression.INFIX_LEFT, (byte) 3);
                exp.createPrimitiveLiteral(ForExpression.INFIX_RIGHT, (short) 3);
        exp.createBlockBegin();
                ExpressionProxy falseProxy = exp.createProxyAssignmentExpression(ForExpression.ROOTEXPRESSION);                
                exp.createInfixExpression(ForExpression.ASSIGNMENT_RIGHT, InfixOperator.IN_MINUS, 0);
                exp.createPrimitiveLiteral(ForExpression.INFIX_LEFT, (byte) 3);
                exp.createPrimitiveLiteral(ForExpression.INFIX_RIGHT, (short) 3);
        exp.createBlockEnd();

Is equivalent to:

        boolean valueToTest = ((byte) 3) == ((short) 3);
        if (valueToTest)
                int trueResult = ((byte) 3) + ((short) 3);
        else {
                int falseResult = ((byte) 3) - ((short) 3);
        }

3.

In VE 1.0, to refer to a proxy, IBeanProxy was used, and to obtain a method
proxy class name was not needed, only method name was needed. E.g.

IMethodProxy method = widgetProxy.getTypeProxy().getMethodProxy("aMethod");
// widgetProxy is of type IBeanProxy

So this code could be used for all the widgets that had getModel method.

In VE 1.1, in _expression_ IProxy is used to refer to widget' proxy. To get a
method, we need to provide class name and method name

// widgetProxy is of type IProxy
IProxyMethod method =
widgetProxy.getProxyFactoryRegistry().getMethodPro
xyFactory().getMethodProxy(
                                                      "AClass",
                                                      "aMethod", new String[] {});

Since a class name is required, it is not possible to use the same stmt to
get methods of same name for different widgets.

Is there an alternative way of getting a method from an IProxy without
specifying class name?


--- RLK No there isn't a direct way because you don't know what the class type is; it hasn't been evaluated yet. But it shouldn't matter in the case of the "AClass" is a superclass of all of the possible types. Even if you got the method proxy for AClass, it is still valid to use that proxy against BClass if BClass is a subclass of AClass.

There is a way to do it at evaluation time, but it has overhead because it won't take advantage of caching. It will look up the method each and every time you do it. When use the IProxyMethod's, these are cached and only looked up once.

        _expression_.createMethodInvocation(ForExpression.ROOT_EXPRESSION, "getTable", true, 0);
        _expression_.createProxyExpression(ForExpression.METHOD_RECEIVER, widgetIProxy);

Thanks and regards,

Janak

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

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


Back to the top