MiG InfoCom MiG Calendar JavaBeans Guide User Manual

Page 41

Advertising
background image

MiG InfoCom AB

Another way that can be used if there are different looks
(e.g. colors) depending on the Category the activities
belongs to (an activity can belong to any number of
categories) is this:

CategoryDepository.setOverride(<categoryID>, <targetSubshapeName>,

<propertyName>, <new value>);

for example:

CategoryDepository.setOverride(susanID, "defaultBackground", AShape.A_PAINT,

Color.PINK);

A more generic and flexible way is the new static generic
overriders introduced in v5.2.

For instance to set a yellow border on all recurring events:

ActivityInteractor.setStaticOverride("defaultOutline", AShape.A_PAINT,
new OverrideFilter() {

public Object getOverride(Object subject, Object defaultObject) {
if (((ActivityView) subject).getModel().isRecurrent()) {

return Color.YELLOW;
} else {

return defaultObject;
}

}
});

Since you have the Activity at hand you can base your
override on anything you like, such as for instance the value
of a custom property in the Activity. One of the things you
need to know for the above to work is the name of the sub
shape to target. If you create your own AShape that's no
problem since you are in control of everything, including the
names. The default shape created by the framework has
constants for the names. They are unlikely to change and
should be referenced.

public static final String DEFAULT_CONTAINER_SHAPE_NAME
public static final String DEFAULT_BACKGROUND_SHAPE_NAME

public static final String DEFAULT_TITLE_TEXT_SHAPE_NAME
public static final String DEFAULT_MAIN_TEXT_SHAPE_NAME

public static final String DEFAULT_OUTLINE_SHAPE_NAME
public static final String DEFAULT_SHADOW_SHAPE_SHAPE_NAME

MiG Calendar JavaBeans Guide

Page 41 / 45

Advertising