Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] fieldname change and reload

Hi Sri,

Here are the details.

Scenario:
---------

SWT - A Shell contains a button. Rename the button.

VE 1.0.1 and Eclipse 3.0.1.

Issue
-----

There is an NPE in primAddControl() while parsing the exprn:

remBut = new Button(sShell, SWT.NONE);

VE tries to add the button to the shell, but the ProxyAdapter for the button
is null in Class:
ShellProxyAdapter(CompositeProxyAdapter).primAddControl(IJavaObjectInstance)
line: 123

IBeanProxyHost controlProxyHost =
BeanProxyUtilities.getBeanProxyHost(aControl);
((ControlProxyAdapter)controlProxyHost).setParentProxyHost(this);

Stack:
------

ShellProxyAdapter(CompositeProxyAdapter).primAddControl(IJavaObjectInstance)
line: 122
ShellProxyAdapter(CompositeProxyAdapter).addControl(IJavaObjectInstance,
int) line: 99
ShellProxyAdapter(CompositeProxyAdapter).applied(EStructuralFeature, Object,
int) line: 53
ShellProxyAdapter(BeanProxyAdapter).notifyChanged(Notification) line: 118
JavaObjectInstance(BasicNotifierImpl).eNotify(Notification) line: 225
EcoreEList$Dynamic(EcoreEList).dispatchNotification(Notification) line: 211
EcoreEList$Dynamic(NotifyingListImpl).addUnique(int, Object) line: 344
EcoreEList$Dynamic(BasicEList).add(int, Object) line: 644
SWTConstructorDecoderHelper.createControlFeature() line: 131
SWTConstructorDecoderHelper.decode() line: 157
SWTControlDecoder(AbstractExpressionDecoder).decode() line: 144
CodeExpressionRef.decodeExpression() line: 292
BDMMerger.createNewExpression(CodeExpressionRef, CodeMethodRef, boolean)
line: 710
BDMMerger.addNewExpression(CodeExpressionRef) line: 728
BDMMerger.processExpressions(Collection, Collection) line: 578
BDMMerger.updateBeanPartRegularExpressions() line: 857
BDMMerger.mergeAllBeans() line: 784
BDMMerger.merge() line: 92
JavaSourceTranslator$SharedToLocalUpdater.merge(IBeanDeclModel,
IBeanDeclModel, ICancelMonitor) line: 388
JavaSourceTranslator$SharedToLocalUpdater.handleParseable(CompilationUnit,
ICompilationUnit, ICancelMonitor) line: 434
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor) line: 503
StrategyWorker.run() line: 115
Thread.run() line: 534
-----

The NPE is caught in SWTControlDecoder(AbstractExpressionDecoder).decode()
line: 146:

try {
	result = fhelper.decode();
} catch (Exception e) {
	JavaVEPlugin.log(e.getMessage(), Level.FINEST);
}
----

So the SimpleAttributeDecoderHelper.decode() is called.

It Throws a CodeGen exception SimpleAttributeDecoderHelper.addFeature()
line: 289:

 PropertyDecorator pd = fFmapper.getDecorator();
 if (pd == null)
     throw new CodeGenException("Invalid PropertyDecorator"); //$NON-NLS-1$

-------

This CodeGenException is caught by
BDMMerger.addNewExpression(CodeExpressionRef) line: 732

	CodeExpressionRef newExp = createNewExpression(updateExp,
                           mainMethod,
                           !updateExp.isStateSet
                          (CodeExpressionRef.STATE_NO_MODEL));
} catch (CodeGenException e) {
	JavaVEPlugin.log(e, Level.WARNING) ;
	return false;
}

-----

It returns false implying that merger failed and reload is required in
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor) line: 503:

							reloadRequired = reloadRequired || !handleParseable(ast,
fWorkingCopy, monitor);
							fireParseError(false);
						}

						....

						if(reloadRequired){
							Reload(disp, monitor);
						}

-----

This forces reload; the model is built again and the image on the canvas is
refreshed corectly (button is shown within the shell).

-------

The case of ULC:
---------------

In the case of ULC, while decoding the expression:

boxpane.set(0, 0, 1, 1, com.ulcjava.base.shared.IDefaults.BOX_LEFT_CENTER,
getButton());

where,

boxpane = a BoxPane
getButton() = returns the ULC Button whose field name is being changed and
hence the getter method name is being changed.

set method= adds the button to the boxpane with constraints
0,0,1,1,BOX_LEFT_CENTER.
---


While adding the button to the boxpane, the ProxyAdapter for Button is not
found and there is an NPE. So the SimpleAttributeDecoderHelper.decode() is
called.

But it does not throw a CodeGenException but instead returns false:

if ((exp instanceof Assignment) ||
	((exp instanceof MethodInvocation) &&
((MethodInvocation)exp).arguments().size() == 1))
	return (addFeature());
else {
	CodeGenUtil.logParsingError(fExpr.toString(),
fbeanPart.getInitMethod().getMethodName(), "Invalid Format",false) ;
//$NON-NLS-1$
	return (false);
}

-----

Since there is no CodeGenException, the merger is assumed to be successful
and subsequently there is no reload in
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor).

Because no reload is done, the button is shown outside of the boxpane. Then
we do a manual reload, the code is parsed again, the model is built, and the
canavs is refreshed correctly with button in the boxpane.

----

Questions:

1. Why is SimpleAttributeDecoderHelper.decode() be called by default if the
Expression's Decoder helper throws an NPE?

2. Shouldn't SimpleAttributeDecoderHelper.decode() throw a CodeGenException
for the statement?

3. SimpleAttributeDecoderHelper.decode() looks for assignment stmt or arg
count == 1. but in our case (set stmt above) it is neither an assignment and
nor does it have arg count = 1. What is the logic behind this? Is it not too
specific to Swing/SWT?

4. The logic of model merge failure and subsequent forced reload relies on a
CodeGenException. Is this correct? If so it should be ensured that at every
point of failure during parsing of code a CodeGenException is thrown.

-----------

I hope the above explanation helps you to track down the problem.

Thanks and regards,

Janak




-----Original Message-----
From: ve-dev-admin@xxxxxxxxxxx [mailto:ve-dev-admin@xxxxxxxxxxx]On Behalf Of
Srimanth Gunturi
Sent: Wednesday, December 01, 2004 3:45 AM
To: ve-dev@xxxxxxxxxxx
Subject: Re: [ve-dev] fieldname change and reload



Hello Janak,
        When one renames a component (foo->bar) in the source, the update
mechanism being at a
low level treats it as a removal of the bean 'foo' and the addition of bean
'bar'. Now regarding a reload,
if the update mechanism found that it was not able to merge a change into
the visual (exception, failing
condition etc.) it performs a reload from scratch. It looks like when you
had the null proxy adapter for the
ULCButton, the merge mechanism didnt think it was a failed update and
happily went on without a reload -
the consequence of which was that you didnt see a ULCButton. In the case of
SWT the NPE might have
happened at a different place/stage such that the update mechanism knew of a
problem and called the
reload from scratch. I would be thankful if you could provide like a stack
trace of where this problem
seems to be occuring in VE so that we can correct it.
Regards,
Sri.




"Janak Mulani" <janak.mulani@xxxxxxxxx>
Sent by: ve-dev-admin@xxxxxxxxxxx
11/29/2004 10:41 AM Please respond to
ve-dev

To"ve-Dev@Eclipse. Org" <ve-dev@xxxxxxxxxxx>
cc
Subject[ve-dev] fieldname change and reload







Dear VE Team,

With your help and guidance we are almost ready with our release. We really
appreciate your help and thank you for the same.

However, there is one problem:

Scenario:

We have a container (ULCBoxPane) and a ULCButton in it.

If we rename the fieldname for ULCButton, VE does refresh children by
reparsing the code. However, while reparsing and adding the child
(ULCButton) to the container (ULCBoxPane), it is not able to find the
ProxyAdapter for ULCButton and neither it is able to create it
(eInternalResource() returns null because eDirectResource is null for the
button eobject and even the eInternalContainer is null).

It seems that button is removed from the model but not added back.

Could you please tell why the PA is not created during the reload after
rename of fieldname?

We need to do an explicit reload to see the button within the container
after rename. This time again, during the reload while adding the child, it
doesnot find ProxyAdapter, however it is able to create it from the
eContainer's resource.

This behavior has been observed for both VE 1.0.1 and VE 1.0.1.1.


While debugging SWT:

I saw similar behavior, PA in primAddControl is null and there is an
exception. However, the model is built subsequently and the canvas is
repainted correctly.

What is it that is triggreing auto reload in the case of SWT? Are we missing
something?

Thanks and regards,

Janak


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



Back to the top