com.miginfocom.calendar.activity
Interface Activity

All Superinterfaces:
AdjustingPropertyConsumer, Categorizable, java.lang.Comparable, java.util.EventListener, java.beans.PropertyChangeListener, PropertyConsumer, PropertyObservable, PropertyProvider, StateObservable, TimeSpan
All Known Implementing Classes:
AbstractActivity, DefaultActivity

public interface Activity
extends java.lang.Comparable, TimeSpan, PropertyObservable, StateObservable, Categorizable, java.beans.PropertyChangeListener, AdjustingPropertyConsumer

An interface defining what the most basic activity should manage. Modelled after an RFC 2445 (iCalendar) event/to do.


Field Summary
 
Fields inherited from interface com.miginfocom.util.states.StateObservable
GROUP_TOGGLE, SPRING, TOGGLE
 
Method Summary
 void addProperties(java.util.Map properties, java.lang.Boolean fireChangeEvent)
          Adds all properties to this activity relplacing any key/value that is already there.
 void addPropertiesSilent(java.util.Map properties, java.lang.Boolean fireChangeEvent)
          Transfer to setProperties(java.util.Map, Boolean) but should catch the PropertyVetoException.
 void clearLayoutNeededFlag()
          Clears flag.
 boolean containsProperty(PropertyKey property)
          Returns if a property exists.
 boolean equalProperties(Activity a)
          Return if both Activities's properties are equal.
 ImmutableDateRange getBaseDateRange()
          Returns the date range that this activity spans, disregarding possible recurrence.
 ActivityView getBaseView(javax.swing.JComponent parent, InteractionListener iListener)
          Should NOT be called from client code!
 java.lang.Long getCreatedByStorageDate()
          Returns the creation date (when actually created by the server or storage) in milliseconds (UTC)
 java.lang.Long getCreatedDateByClientDate()
          Returns the creation date (when created by the client) in milliseconds (UTC)
 DateRangeI getDateRangeForReading()
          Returns same as getBaseDateRange()
 java.lang.String getDescription()
          Returns the description of this Activity
 java.lang.Object getID()
          Returns the ID Object that should identify this Activity.
 long getLastModified()
          Returns the last modified date in milliseconds (UTC).
 int getLayerIndex()
          Returns the layer in which to layout and paint this activity.
 java.lang.String getLayoutContext()
          Returns the an optional context interpretable by the object that is to layout this activity.
 java.lang.String getLocation()
          Returns the location of this Activity
 java.lang.String getPaintContext()
          Returns the an optional context interpretable by the object that is to paint this activity.
 java.util.Map getProperties()
          Returns a shallow copy of all properties for this activity.
 java.lang.Object getProperty(PropertyKey property)
          Returns a property for this Activity
 Recurrence getRecurrence()
          Returns the recurrecy object assiciated with this Activity.
 java.lang.String getSummary()
          Returns a breief summary (on line normally) of this Activity
 ActivityView[] getViews(javax.swing.JComponent parent, InteractionListener iListener, DateRangeI withinRange)
          Should NOT be called from client code!
 void invalidateViews()
          Removes all cached paint optimizations for this activity's views so that they will be recreated next paint run.
 boolean isEnabled()
          Retunrns if the Activity is enabled
 boolean isLayoutNeeded()
          Returns whether this activity needs to be layout, normally after changing date range
 boolean isRecurrent()
          Returns if this Activity is happening more than once
 java.lang.Object removeProperty(PropertyKey property)
          Removes a property for this Activity.
 void setBaseDateRange(ImmutableDateRange dateRange)
          Sets a new date range for this activity.
 void setDescription(java.lang.String descr)
          Sets the description for this Activity.
 boolean setEnabled(boolean b)
          Sets if the Activity should be enabled.
 void setID(java.lang.Object idObject)
          Set the ID Object that should be tied to this Activity.
 void setLastModified(long millis)
          Sets the last modified to a specific value.
 void setLayerIndex(int ix)
          Sets the layer in which to layout and paint this activity.
 void setLayoutContext(java.lang.String paintContext)
          Sets an optional paint context interpretable by the object that is to layout this activity.
 void setLocation(java.lang.String location)
          Sets the location for this Activity.
 void setPaintContext(java.lang.String paintContext)
          Sets an optional paint context used when painting this activity
 void setProperties(java.util.Map props)
          Sets the properties for this activity bu calling setPropertiesSilent(java.util.Map, java.lang.Boolean).
 void setProperties(java.util.Map properties, java.lang.Boolean fireChangeEvent)
          Replaces all properties in this activity with properties.
 void setPropertiesSilent(java.util.Map properties, java.lang.Boolean fireChangeEvent)
          Transfer to setProperties(java.util.Map, Boolean) but should catch the PropertyVetoException.
 java.lang.Object setProperty(PropertyKey property, java.lang.Object prop, java.lang.Boolean fireChangeEvent)
          Sets a property for this Activity.
 java.lang.Object setPropertySilent(PropertyKey property, java.lang.Object prop, java.lang.Boolean fireChangeEvent)
          Transfer to setProperty(PropertyKey, Object, Boolean) but should catch the PropertyVetoException.
 void setRecurrence(Recurrence rec)
          Sets the recurrecy object assiciated with this Activity.
 void setSummary(java.lang.String summary)
          Sets the summary for this Activity.
 
Methods inherited from interface com.miginfocom.util.dates.TimeSpan
getDateRangeClone, getWritableDateRange
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface com.miginfocom.util.PropertyObservable
addPropertyListener, addPropertyListener, isIgnorePropertyEvents, removePropertyListener, setIgnorePropertyEvents
 
Methods inherited from interface com.miginfocom.util.states.StateObservable
getGroupToggleContext, getHandledStates, getSettableStates, getStates, getStateType, isHandlingStates, isMultiState, setGroupToggleContext
 
Methods inherited from interface com.miginfocom.calendar.category.Categorizable
addCategoryID, getCategoryIDs, isCategory, removeCategoryID, setCategoryIDs
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface com.miginfocom.util.AdjustingPropertyConsumer
endAdjusting, isAdjusting, rollbackAdjusting, startAdjusting
 
Methods inherited from interface com.miginfocom.util.PropertyConsumer
removeProperty, removePropertySilent
 

Method Detail

getBaseDateRange

ImmutableDateRange getBaseDateRange()
Returns the date range that this activity spans, disregarding possible recurrence. The startDate of this date range is also known as "dtstart" in RFC 2445. Returns the actual contained object.

Returns:
The date range (not cloned) that this activity spans, disregarding possible recurrence. Never null.

setBaseDateRange

void setBaseDateRange(ImmutableDateRange dateRange)
                      throws java.beans.PropertyVetoException
Sets a new date range for this activity. Only sets if it doesn't equals the old value.

Parameters:
dateRange - The ew date range. Never null and should be sorted. Start <= end.
Throws:
java.beans.PropertyVetoException - If the new date range couldn't be set on this for some reason.

getDateRangeForReading

DateRangeI getDateRangeForReading()
Returns same as getBaseDateRange()

Specified by:
getDateRangeForReading in interface TimeSpan
Returns:
Same as getBaseDateRange()

getCreatedDateByClientDate

java.lang.Long getCreatedDateByClientDate()
Returns the creation date (when created by the client) in milliseconds (UTC)

Returns:
The creation date (when created by the client) in milliseconds (UTC). May be null.

getCreatedByStorageDate

java.lang.Long getCreatedByStorageDate()
Returns the creation date (when actually created by the server or storage) in milliseconds (UTC)

Returns:
The creation date (when actually created by the server or storage) in milliseconds (UTC). May be null.

getLastModified

long getLastModified()
Returns the last modified date in milliseconds (UTC). Updated automatically when a property changes.

Returns:
The last modified date in milliseconds (UTC). not null.

setLastModified

void setLastModified(long millis)
Sets the last modified to a specific value. This should only be made during the setup process of the activity and is handled automatically whenever a property is changed later on.

Parameters:
millis - The millis as standard.

getSummary

java.lang.String getSummary()
Returns a breief summary (on line normally) of this Activity

Returns:
A breief summary (on line normally) of this Activity. May be null.

setSummary

void setSummary(java.lang.String summary)
Sets the summary for this Activity.

This is a convenience for:

setProperty(PROP_SUMMARY, summary, null);

And thus will not throw an exception if vetoed.

Parameters:
summary - The summary for this Activity.

getDescription

java.lang.String getDescription()
Returns the description of this Activity

Returns:
The description of this Activity. May be null.

setDescription

void setDescription(java.lang.String descr)
Sets the description for this Activity.

This is a convenience for:

setProperty(PROP_DESCRIPTION, descr, null);

And thus will not throw an exception if vetoed.

Parameters:
descr - The description for this Activity.

getLocation

java.lang.String getLocation()
Returns the location of this Activity

Returns:
The location of this Activity. May be null.

setLocation

void setLocation(java.lang.String location)
Sets the location for this Activity.

This is a convenience for:

setProperty(PROP_LOCATION, location, null);

And thus will not throw an exception if vetoed.

Parameters:
location - The location for this Activity.

getProperty

java.lang.Object getProperty(PropertyKey property)
Returns a property for this Activity

Specified by:
getProperty in interface PropertyProvider
Parameters:
property - The property key to return the property for.
Returns:
The property. Can be null.

getProperties

java.util.Map getProperties()
Returns a shallow copy of all properties for this activity.

Returns:
A shallow copy of all properties for this activity.

setProperties

void setProperties(java.util.Map props)
Sets the properties for this activity bu calling setPropertiesSilent(java.util.Map, java.lang.Boolean). This extra methis of for making this class a bean.

Parameters:
props - Must contain a map from PropertyKey to the properties.

setPropertySilent

java.lang.Object setPropertySilent(PropertyKey property,
                                   java.lang.Object prop,
                                   java.lang.Boolean fireChangeEvent)
Transfer to setProperty(PropertyKey, Object, Boolean) but should catch the PropertyVetoException. It should not set the property if an exception is thrown and return null.

Specified by:
setPropertySilent in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
prop - The property to set for this object.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Returns:
The old object, may be null.

setProperty

java.lang.Object setProperty(PropertyKey property,
                             java.lang.Object prop,
                             java.lang.Boolean fireChangeEvent)
                             throws java.beans.PropertyVetoException
Sets a property for this Activity. All other properties in this class is actually stored as propertied, but they have convenience getters/setters and static property names. With this method you can store arbitrary objects in the activity.

Note that if the PropertyKey defines a value class type it should be checked in this setter and an ClassCastException is thrown if prop is of wrong class type. See PropertyKey.getValueClass().

Specified by:
setProperty in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
prop - The property for this Activity.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Returns:
The old object, may be null.
Throws:
java.beans.PropertyVetoException - If the property couldn't be set on this for some reason.

setPropertiesSilent

void setPropertiesSilent(java.util.Map properties,
                         java.lang.Boolean fireChangeEvent)
Transfer to setProperties(java.util.Map, Boolean) but should catch the PropertyVetoException. It should not set the property if an exception is thrown.


setProperties

void setProperties(java.util.Map properties,
                   java.lang.Boolean fireChangeEvent)
                   throws java.beans.PropertyVetoException
Replaces all properties in this activity with properties. properties must at least contain enough information to make the activity valid.

Note that if the PropertyKeys defines a value class type it should be checked in this method and an ClassCastException is thrown if a value is of the wrong class type. See PropertyKey.getValueClass().

The Property change event will contain a null property name and null for both old and new values.

Parameters:
properties - The properties to set. Not null. Keys must be PropertyKeys.
fireChangeEvent - If Booleagfxn.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Throws:
java.beans.PropertyVetoException

addPropertiesSilent

void addPropertiesSilent(java.util.Map properties,
                         java.lang.Boolean fireChangeEvent)
Transfer to setProperties(java.util.Map, Boolean) but should catch the PropertyVetoException. It should not set the property if an exception is thrown.


addProperties

void addProperties(java.util.Map properties,
                   java.lang.Boolean fireChangeEvent)
                   throws java.beans.PropertyVetoException
Adds all properties to this activity relplacing any key/value that is already there.

Note that if the PropertyKeys defines a value class type it should be checked in this method and an ClassCastException is thrown if a value is of the wrong class type. See PropertyKey.getValueClass().

The Property change event will contain a null property name and null for both old and new values.

Parameters:
properties - The properties to add. Not null. Keys must be PropertyKeys.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Throws:
java.beans.PropertyVetoException

removeProperty

java.lang.Object removeProperty(PropertyKey property)
Removes a property for this Activity. If property isn't set, the method returnes null.

Fires a change event if the key currently exists.

Parameters:
property - The property key that denotes the property.
Returns:
The removed property. Can be null.

containsProperty

boolean containsProperty(PropertyKey property)
Returns if a property exists.

Specified by:
containsProperty in interface PropertyProvider
Parameters:
property - The property key that denotes the property.
Returns:
If the property exits

getID

java.lang.Object getID()
Returns the ID Object that should identify this Activity.

Returns:
The ID object, can be null.

setID

void setID(java.lang.Object idObject)
Set the ID Object that should be tied to this Activity. Can be used freely but should be used to identyfy this range among others. Must be Serializable for serialization of this whole activity to be possible.

This is a convenience for:

setProperty(PROP_ID_OBJECT, idObject, null);

And thus will not throw an exception if vetoed.

Parameters:
idObject - The ID object, can be null.

getRecurrence

Recurrence getRecurrence()
Returns the recurrecy object assiciated with this Activity.

Returns:
The recurrecy object or null if this Activity has not recurrence.

setRecurrence

void setRecurrence(Recurrence rec)
Sets the recurrecy object assiciated with this Activity.

Parameters:
rec - The recurrecy object or null if this Activity should have not recurrence.

isRecurrent

boolean isRecurrent()
Returns if this Activity is happening more than once

Returns:
if this Activity is happening more than once

isEnabled

boolean isEnabled()
Retunrns if the Activity is enabled

Returns:
If the Activity is enabled

setEnabled

boolean setEnabled(boolean b)
Sets if the Activity should be enabled.

This is a convenience for:

setProperty(PROP_ENABLED, Boolean.FALSE, null);

And thus will not throw an exception if vetoed.

Parameters:
b - true if enabled
Returns:
true if the value was changed

isLayoutNeeded

boolean isLayoutNeeded()
Returns whether this activity needs to be layout, normally after changing date range

Returns:
true if so.

clearLayoutNeededFlag

void clearLayoutNeededFlag()
Clears flag. Normally when layout of this activity is done.


getPaintContext

java.lang.String getPaintContext()
Returns the an optional context interpretable by the object that is to paint this activity.

Returns:
An optional context for the object that is to paint this activity.. null by default
See Also:
ActivityViewRenderer

setPaintContext

void setPaintContext(java.lang.String paintContext)
Sets an optional paint context used when painting this activity

Parameters:
paintContext - The optional paint context used when painting this activity. Can be null for default behaviour.

getLayoutContext

java.lang.String getLayoutContext()
Returns the an optional context interpretable by the object that is to layout this activity.

Returns:
An optional context for the object that is to paint this activity.. null by default
See Also:
ActivityViewRenderer

setLayoutContext

void setLayoutContext(java.lang.String paintContext)
Sets an optional paint context interpretable by the object that is to layout this activity.

Parameters:
paintContext - The optional paint context interpretable by the object that is to layout this activity. Can be null for default behaviour.

getLayerIndex

int getLayerIndex()
Returns the layer in which to layout and paint this activity. Normally 0-1000. Lower layer indexes will be painted first.

Returns:
The layer in which to layout and paint this activity.

setLayerIndex

void setLayerIndex(int ix)
Sets the layer in which to layout and paint this activity. Normally 0-1000. Lower layer indexes will be painted first.

Parameters:
ix - The layer in which to layout and paint this activity.

getViews

ActivityView[] getViews(javax.swing.JComponent parent,
                        InteractionListener iListener,
                        DateRangeI withinRange)
Should NOT be called from client code!

Returns all views for this Activity for parent. If the Activity is recurrent, there normally are multiple views (one for every recurrent event). If no recurrence is defined, the length of the returned array is always 0 or 1 depending on wheter the base date range touches (overlaps) withinRange or not.

If both parent and withinRange are equal in subsequent calls, the view list are cached and returned immediately.

Parameters:
parent - An object to identify in which context the views are to be returned for. Since an Activity can reside in many views (same Activity painted in more than one JComponent) this object is used to tell them apart. The DateArea that paints the Activity is normally used as the view context.

null can be used and if so will anways return new views, not cached.

iListener - The listener to InteractionEvents. Can be null.
NOTE! This iListener will be set on the views.
withinRange - All returned ActivityViews must thouch (overlap in some way) withinRange. Must not be null since it whould return an infinite number of view for a recurring event that has no distinct end.
Returns:
All views for this Activity, filtered by parent and withinRange-. Never null and no null elements.

getBaseView

ActivityView getBaseView(javax.swing.JComponent parent,
                         InteractionListener iListener)
Should NOT be called from client code!

Returns the view for the base date range. This method does not take recurrence into account at all.

Parameters:
parent - An object to identify in which context the views are to be returned for. Since an Activity can reside in many views (same Activity painted in more than one JComponent) this object is used to tell them apart. The DateArea that paints the Activity is normally used as the view context.

null can be used and if so will anways return new views, not cached.

iListener - The listener to InteractionEvents. Can be null.
NOTE! This iListener will be set on the views.
Returns:
Returns the view for the base date range. Never null.

invalidateViews

void invalidateViews()
Removes all cached paint optimizations for this activity's views so that they will be recreated next paint run.

See Also:
ActivityView.invalidate()

equalProperties

boolean equalProperties(Activity a)
Return if both Activities's properties are equal.

Parameters:
a - The other activity
Returns:
true if equal.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.