Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315649

Summary: [CSS] "Useless" Dependency on org.apache.commons.beanutils
Product: [Eclipse Project] e4 Reporter: Thomas Schindl <tom.schindl>
Component: UIAssignee: Thomas Schindl <tom.schindl>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: azerr, bokowski, gheorghe, john.arthorne, pwebster
Version: 0.9   
Target Milestone: 1.0 RC0   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch + TestCase
none
Patch to remove bean utils from build
none
Remove beanutils and commons.logging none

Description Thomas Schindl CLA 2010-06-03 14:57:56 EDT
We currently include org.apache.commons.beanutils only to call 1 Method of the a helper class in there. I don't think this justify bringing in this bundle dependency
Comment 1 Thomas Schindl CLA 2010-06-03 15:13:53 EDT
Angelo, I guess you know best what property types can get passed in there. If they are simply none-nested types then we can replace it through a very very simple property lookup.
Comment 2 Angelo ZERR CLA 2010-06-03 16:23:46 EDT
Hi Tom,

I think we can remove this dependency and manage PropertyUtils#getproperty wich use reflection to retrieve the value of a getter of a POJO. As you said, PropertyUtils from Apache Beanutils is used into the only method SWTElement#getAttribute like this : 

---------------------------------------------
public String getAttribute(String attr) {
	Widget widget = getWidget();
	if (attr.equals("style")) {
		return swtStyles;
	}
	Object o = widget.getData(attr.toLowerCase());
	if (o != null)
		return o.toString();
	try {
		o = PropertyUtils.getProperty(widget, attr);
		if (o != null)wxx
			return o.toString();
	} catch (Exception e) {
		// e.printStackTrace();
	}
	return "";
}
---------------------------------------------


This method is used to get attribute value of the widget. So you can write this CSS : 

---------------------------------------------
Text[enabled=true] {
  color:red;
}
---------------------------------------------

SWTElement#getAttribute is called with enabled attr parameter. Code o = PropertyUtils.getProperty(widget, attr); will return the value of 'enabled' property of the SWT Widget (Widget#isEnabled()).

Hope my explanation will help you.

Regards Angelo

(In reply to comment #1)
> Angelo, I guess you know best what property types can get passed in there. If
> they are simply none-nested types then we can replace it through a very very
> simple property lookup.
Comment 3 Thomas Schindl CLA 2010-06-03 16:44:25 EDT
Created attachment 171021 [details]
Patch + TestCase

Thanks Angelo that's what I expected it is doing. Attached is an implementation which even supports nested beans.
Comment 4 Thomas Schindl CLA 2010-06-03 16:58:38 EDT
released the patch and test case to HEAD
Comment 5 Thomas Schindl CLA 2010-06-03 17:01:34 EDT
Paul, John if not completely mistaken this means we don't need org.apache.commons.beanutils anymore because the only dependency was in css.swt.

I think we can remove it from our css.feature, .product-Files, ...
Comment 6 John Arthorne CLA 2010-06-03 17:23:35 EDT
Created attachment 171036 [details]
Patch to remove bean utils from build
Comment 7 John Arthorne CLA 2010-06-03 17:28:19 EDT
Created attachment 171037 [details]
Remove beanutils and commons.logging

Without beanutils, there is nobody in e4 using commons.logging.