This method ignores the
style, or other value searching mechanisms. In most of case, we don’t
need it. It is used for some special cases for performance optimization
purpose.
yves
From:
eclipse-incubator-e4-dev-bounces@xxxxxxxxxxx
[mailto:eclipse-incubator-e4-dev-bounces@xxxxxxxxxxx] On Behalf Of Kevin McGuire
Sent: Tuesday, April 08, 2008
11:20 PM
To: E4 developer list
Subject: RE:
[eclipse-incubator-e4-dev] Initial discussiononthe'modelled'workbenchUI
Yves, what's the design motivation of supporting public
getLocalValue()? It seems that the behaviour of "when asked, I
either return my local copy of the property because someone set it previously,
or I get it from the defaults" is the right behaviour and the existance of
locally stored values shouldn't be exposed publically.
Kevin
"Yves YANG"
<yves.yang@xxxxxxxxxxx>
Sent
by: eclipse-incubator-e4-dev-bounces@xxxxxxxxxxx
04/07/2008 04:28 PM
Please
respond to
E4 developer list <eclipse-incubator-e4-dev@xxxxxxxxxxx>
|
|
To
|
"'E4 developer list'"
<eclipse-incubator-e4-dev@xxxxxxxxxxx>
|
cc
|
|
Subject
|
RE: [eclipse-incubator-e4-dev]
Initial discussion onthe'modelled'workbenchUI
|
|
>public
class UIElement {
> private Style style;
>
> private class WrappedStyle
extends Style {
> private HashMap
ownMap = new HashMap();
>
> private
WrappedStyle(Style style) {
>
this.style = style;
> }
>
> public String
get(String name) {
> if(
ownMap.contains(name) ) {
>
return ownMap.get(name);
> }
> }
>
> public void
set(String name, String value) {
>
ownMap.put(name,value);
> }
> }
>
> // Allows reading without the
need to wrap
> public String
getStyleAttribute(String name) {
> return
style.get(name)
> }
>
>
> public String
setStyleAttribute(String name, String value) {
>
getStyle().set(name,value);
> }
>
> public Style getStyle() {
> if( !( style instanceof
WrappedStyle ) ) {
>
this.style = new WrappedStyle(this.style);
> }
>
> return style;
> }
>}
In general, we have the same idea.
Here is what I suggest:
public class UIElement {
private Style style;
private HashMap ownMap = new
HashMap();
// Allows reading without the need to
wrap
public Object getValue(String name) {
if (ownMap.containsKey(name)) {
return
ownMap.get(name);
}
return getDefaultValue(name);
}
protected Object getDefaultValue
(String name) {
if (style != null) {
return
style.get(name);
}
return null;
}
public Object getLocalValue(String
name) {
return ownMap.get(name);
}
public boolean hasLocalValue(String
name) {
return
ownMap.containsKey(name);
}
public void unsetValue(String name) {
ownMap.remove(name);
}
public void setValue(String name,
Object value) {
ownMap.set(name,
value);
}
public Style getStyle() {
return style;
}
}
Style is subclass UIElement.
yves
_______________________________________________
eclipse-incubator-e4-dev mailing list
eclipse-incubator-e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipse-incubator-e4-dev