|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.miginfocom.ashape.interaction.AbstractInteractor
com.miginfocom.calendar.activity.ActivityInteractor
public class ActivityInteractor
An Interactor that can listen to property and state changes in an Activity.
This class is also resposible for template text expansion. You can use, for instance, "$startTime$" in a text for an activity
and it will be expanded for every activity to the start time of that activity. There are public static fields in this class that
starts with TEMPL_xxx and those are the build in template texts. You can use .getName() on them to get the actual
string. If the template does not match any of the build in strings a generic template of the activity will be fetched, matching
the template without the dollar signs. The value of that property converted to a string with .toString() will be expanded inplace
of the template. Also see setStaticOverride(String, com.miginfocom.util.PropertyKey, com.miginfocom.ashape.interaction.OverrideFilter)
for yet another way to handle template texts, even dynamically.
| Field Summary | |
|---|---|
protected ActivityView |
activityView
The activity to monitor. |
protected InteractionBroker |
broker
The broker to interact with. |
static PropertyKey |
PROPERTY
A trigger to interact with the activitys properties. |
static PropertyKey |
STATE
A trigger to interact with the activitys states. |
static PropertyKey |
TEMPL_DESCRIPTION
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the description of the contained activity view. |
static PropertyKey |
TEMPL_DURATION
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the duration of the contained activity view. |
static PropertyKey |
TEMPL_END_TIME_EXCL
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the end time (excluding) of the contained activity view. |
static PropertyKey |
TEMPL_END_TIME_INCL
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the end time (including) of the contained activity view. |
static PropertyKey |
TEMPL_LOCATION
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the description of the contained activity view. |
static PropertyKey |
TEMPL_START_TIME
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the start time of the contained activity view. |
static PropertyKey |
TEMPL_SUMMARY
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the summary of the contained activity view. |
static PropertyKey |
TEMPL_TIME_ZONE_LONG
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return a human readable time zone in a longer format. |
static PropertyKey |
TEMPL_TIME_ZONE_SHORT
Template text (a variable) that when sent into getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return a human readable time zone in a shorter format. |
| Fields inherited from class com.miginfocom.ashape.interaction.AbstractInteractor |
|---|
TRIGGER_ONCE |
| Fields inherited from interface com.miginfocom.ashape.interaction.Interactor |
|---|
TEMPLATE_CHAR |
| Constructor Summary | |
|---|---|
ActivityInteractor(ActivityView activityView,
InteractionBroker broker,
java.util.Collection interactions)
Constructor |
|
| Method Summary | |
|---|---|
void |
addInteraction(Interaction inter)
Adds an interaction. |
protected void |
checkInteractions()
Checks all interations and see if they are valid and if so, execute broker.handleCommand(). |
boolean |
containsProperty(PropertyKey property)
Empty implementation that always return false. |
ActivityView |
getActivityView()
Returns the contained ActivityView |
java.text.DateFormat |
getDateTimeFormat()
Returns the format object used to format start and/or end date/times. |
static java.text.DateFormat |
getDefaultDateTimeFormat()
Returns the default format object used to format start and/or end date/times that is used for new ActivityInteractors. |
static java.lang.String |
getDefaultDurationFormat()
Returns the duration format used by all newly created ActivityInteractors. |
java.lang.String |
getDurationFormat()
Returns the string used for formatting duration. |
java.lang.Object |
getInteracted()
Returns the object that this interactor is currently interacting with. |
InteractionBroker |
getInteractionBroker()
Returns the interaction broker for this interactor. |
java.lang.Object |
getOverride(java.lang.String name,
PropertyKey property,
java.lang.Object def)
Handles the overrider as specified in Interactor.getOverride(String, PropertyKey, Object). |
java.lang.Object |
getProperty(PropertyKey property)
Empty implementation. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
static OverrideFilter |
removeStaticOverride(java.lang.String name,
PropertyKey property)
Removes the static override filter. |
void |
setDateTimeFormat(java.text.DateFormat dateTimeFormat)
Sets the format object used to format start and/or end date/times. |
static void |
setDefaultDateTimeFormat(java.text.DateFormat format)
Sets the format object used to format start and/or end date/times. |
static void |
setDefaultDurationFormat(java.lang.String format)
Sets the duration format used by all newly created ActivityInteractors. |
void |
setDurationFormat(java.lang.String durationFormat)
Sets the string to use for formatting duration. |
static OverrideFilter |
setStaticOverride(java.lang.String name,
PropertyKey property,
OverrideFilter filter)
Adds a static override filter that will be asked to return a possibly new or derived object for the name/PropName
combination. |
| Methods inherited from class com.miginfocom.ashape.interaction.AbstractInteractor |
|---|
addInteractions, addOverride, addOverrideListener, addOverrideListener, fireOverrideChanged, getInteractions, getOverrideById, isOverridden, keyEventPost, keyEventPre, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseEventPost, mouseEventPre, mouseExited, mouseMoved, mousePressed, mouseReleased, processEvent, removeInteraction, removeOverride, removeOverrideById, removeOverrideListener, setInteractions, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final PropertyKey TEMPL_START_TIME
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the start time of the contained activity view.
The value that can be used in a text is "$startTime$" and it will be expanded.
setDateTimeFormat(java.text.DateFormat)public static final PropertyKey TEMPL_END_TIME_INCL
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the end time (including) of the contained activity view.
The value that can be used in a text is "$endTimeIncl$" and it will be expanded.
setDateTimeFormat(java.text.DateFormat)public static final PropertyKey TEMPL_END_TIME_EXCL
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the end time (excluding) of the contained activity view.
The value that can be used in a text is "$endTimeExcl$" and it will be expanded.
setDateTimeFormat(java.text.DateFormat)public static final PropertyKey TEMPL_DURATION
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the duration of the contained activity view.
The value that can be used in a text is "$duration$" and it will be expanded.
setDurationFormat(String)public static final PropertyKey TEMPL_SUMMARY
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the summary of the contained activity view.
The value that can be used in a text is "$summary$" and it will be expanded.
public static final PropertyKey TEMPL_DESCRIPTION
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the description of the contained activity view.
The value that can be used in a text is "$description$" and it will be expanded.
public static final PropertyKey TEMPL_LOCATION
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return the description of the contained activity view.
The value that can be used in a text is "$location$" and it will be expanded.
public static final PropertyKey TEMPL_TIME_ZONE_SHORT
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return a human readable time zone in a shorter format.
The value that can be used in a text is "$timeZoneShort$" and it will be expanded.
public static final PropertyKey TEMPL_TIME_ZONE_LONG
getOverride(java.lang.String, PropertyKey, java.lang.Object)
will return a human readable time zone in a longer format.
The value that can be used in a text is "$timeZoneLong$" and it will be expanded.
public static final PropertyKey PROPERTY
public static final PropertyKey STATE
protected final InteractionBroker broker
protected final ActivityView activityView
| Constructor Detail |
|---|
public ActivityInteractor(ActivityView activityView,
InteractionBroker broker,
java.util.Collection interactions)
activityView - The activity to monitor. Will be return as the "interacted".broker - The broker to execute commandsinteractions - The interactions installed to start with| Method Detail |
|---|
public InteractionBroker getInteractionBroker()
InteractorDefaultCommands.
getInteractionBroker in interface Interactornull if there is not broker.public java.lang.Object getInteracted()
Interactor
getInteracted in interface Interactornull.
public java.lang.Object getOverride(java.lang.String name,
PropertyKey property,
java.lang.Object def)
AbstractInteractorInteractor.getOverride(String, PropertyKey, Object). If propName is
surounded with Interactor.TEMPLATE_CHAR characters (e.g. "$summary$") and the object returned from Interactor.getInteracted() is
instance of PropertyProvider the returned override will be the property returned from the interacted.
If the object to be returned (i.e. is stored as an override) is a OverrideFilter that filter will be asked to return the
object instead and it is given the "interacted" object as the "subject". See Interactor.getInteracted()
getOverride in interface InteractorgetOverride in class AbstractInteractorname - The target name. May for instance be the name of a sub shape in an AShape.property - The name of the property. May for instance be a property name of an AShape. E.g. AShape.A_FONTdef - The default object returned if no override
def if there are none.public void addInteraction(Interaction inter)
Interactor
addInteraction in interface InteractoraddInteraction in class AbstractInteractorinter - The interaction to add-protected void checkInteractions()
broker.handleCommand().
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange in interface java.beans.PropertyChangeListenerpublic java.lang.Object getProperty(PropertyKey property)
AbstractInteractorpropertyName .
getProperty in interface PropertyProvidergetProperty in class AbstractInteractorproperty - The property.
null.public boolean containsProperty(PropertyKey property)
AbstractInteractorfalse. Override to to provide meaningful return value.
containsProperty in interface PropertyProvidercontainsProperty in class AbstractInteractorproperty - The property.
public java.lang.String getDurationFormat()
DateUtil.getDurationString(java.util.Calendar, java.util.Calendar, boolean, String)
for an explanation of how the string is formatted.
null.public void setDurationFormat(java.lang.String durationFormat)
DateUtil.getDurationString(java.util.Calendar, java.util.Calendar, boolean, String)
for an explanation of how the string should be formatted.
durationFormat - The new duration format. Not null.public static java.lang.String getDefaultDurationFormat()
ActivityInteractors.
DateUtil.getDurationString(java.util.Calendar, java.util.Calendar, boolean, String)
for an explanation fo the format. Not null.public static void setDefaultDurationFormat(java.lang.String format)
ActivityInteractors.
format - The format. See DateUtil.getDurationString(java.util.Calendar, java.util.Calendar, boolean, String)
for an explanation fo the format. Not null.public static java.text.DateFormat getDefaultDateTimeFormat()
ActivityInteractors.
null.public static void setDefaultDateTimeFormat(java.text.DateFormat format)
format - The new format. Not null.public java.text.DateFormat getDateTimeFormat()
null.public void setDateTimeFormat(java.text.DateFormat dateTimeFormat)
dateTimeFormat - The new format. Not null.public ActivityView getActivityView()
ActivityView
ActivityView
public static OverrideFilter setStaticOverride(java.lang.String name,
PropertyKey property,
OverrideFilter filter)
name/PropName
combination. The filter will always be fed a ActivityView as subject.
If there is another filter for the name/propName combination it will be replaced.
It is from version 5.5.13 possible to add an override for template texts as well. You can for instance add code like this to expand a template text for an AShape any way you'd like:
ActivityInteractor.setStaticOverride(AShapeUtil.DEFAULT_TITLE_TEXT_SHAPE_NAME, PropertyKey.getKey("$firstLetterOfSummary$"), new OverrideFilter() {
public Object getOverride(Object subject, Object defaultObject)
{
Activity activity = ((ActivityView) subject).getModel();
return activity.getSummary().substring(0, 1); // As an example
}
});
name - The name. Normally a name of a subshape in a RootAShape. E.g. "backgroundShape"property - The name of the property. Normally a property name of an AShape. E.g. AShape.A_PAINT
OverrideFilter or null if none.
public static OverrideFilter removeStaticOverride(java.lang.String name,
PropertyKey property)
name - The name. Normally a name of a subshape in a RootAShape. E.g. "backgroundShape"property - The name of the property. Normally a property name of an AShape. E.g. AShape.A_PAINT
OverrideFilter or null if none.setStaticOverride(String, PropertyKey, com.miginfocom.ashape.interaction.OverrideFilter)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||