[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
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