|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.miginfocom.calendar.activity.ActivityDepository
public class ActivityDepository
A class that is the focal point of all activity exchange events and updates. I/O filters can be registered.
An app-global ActivityList is maintained as a live object that everyone can register listeners on.
Clients (E.g. DefaultDateArea) can register subscriptions to date ranges. Those subscriptions
can be reead by ActivityIOPlugin for instance and they can then start to send
update events to this synchronizer when information becomes available or are changed in any way.
| Field Summary | |
|---|---|
static java.lang.String |
PROP_SUBSCR_ADDED
Property for when a subscription has been added. |
static java.lang.String |
PROP_SUBSCR_REMOVED
Property for when a subscription has been removed. |
| Constructor Summary | |
|---|---|
protected |
ActivityDepository()
Protected constructor. |
| Method Summary | |
|---|---|
void |
addActivityListListener(TimeSpanListListener l,
boolean asWeakRef)
Deprecated. Use #addDepositoryListener instead. Notification during synchronized block could lead to dead-locks. |
void |
addBrokedActivities(java.util.Collection c,
java.lang.Object source)
Calls addBrokedActivities(java.util.Collection, Object, int) with TimeSpanListEvent.ADDED. |
void |
addBrokedActivities(java.util.Collection c,
java.lang.Object source,
int eventType)
Adds a number of activities to the list. |
void |
addBrokedActivity(Activity a,
java.lang.Object source)
Calls addBrokedActivity(com.miginfocom.calendar.activity.Activity, Object, int) with TimeSpanListEvent.ADDED. |
void |
addBrokedActivity(Activity a,
java.lang.Object source,
int eventType)
Adds an activity to the list. |
void |
addDepositoryListener(TimeSpanListListener l)
Adds a listener that listens to all adds and removes in the depository. |
void |
addDepositoryListener(TimeSpanListListener l,
boolean asWeakRef)
Adds a listener that listens to all adds and removes in the depository. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a listener that listens to all handeled activities of type AbstractActivity and subclasses. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
Adds a listener that listens to all handeled activities of type AbstractActivity and subclasses. |
void |
addSubscription(ActivitySubscription s)
Adds the subscription and notifies the listeners. |
void |
addSubscriptionListener(java.beans.PropertyChangeListener l)
Adds a listener that listens to all changes in the subscriptions for this depository. |
void |
addSubscriptionListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
Adds a listener that listens to all changes in the subscriptions for this depository. |
void |
fireDepositoryChanged(Activity a,
java.lang.Object source,
int eventType)
|
void |
fireDepositoryChanged(TimeSpan[] acts,
java.lang.Object source,
int eventType)
|
void |
fireManualDepositoryListChanged(TimeSpan[] timeSpans,
int type,
DateRangeI dateRange)
Deprecated. Use #fireDepositoryChanged instead. Notification during synchronized block could lead to dead-locks. |
ActivityList |
getActivities()
Returns a new list with all the activities in this depository. |
Activity |
getActivity(java.lang.Object id)
Returns the activity with the id from a locally mainained HashMap, so it will be very fast. |
ActivityResolver |
getActivityResolver()
Returns the current resolver. |
TimeSpanList[] |
getActivityViewLists(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange)
A direct transfer to ActivityList.getActivityViewLists(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI) |
TimeSpanList[] |
getActivityViewLists(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange,
Filter filter)
A direct transfer to ActivityList.getActivityViewLists(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI, Filter) |
TimeSpanList |
getActivityViews(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange,
Filter filter)
A direct transfer to ActivityList.getActivityViews(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI, Filter) |
java.util.List |
getBrokedActivities()
Returns a new list with all Activity objects that are cuurently beeing broked (i.e. |
int |
getBrokedActivityCount()
Returns the number of broked activities in the depository. |
ActivityResolver |
getCurrentActivityResolver()
Returns the current resolver. |
java.lang.Class |
getEnforceIDClass()
Returns the id class type that always should be used as id for the coategories. |
static ActivityDepository |
getInstance()
Returns an instance of this class using the defulat null context. |
static ActivityDepository |
getInstance(java.lang.String context)
Returns an instance of this class. |
java.util.logging.Logger |
getLogger()
Returns the current logger or null if none is set. |
ActivitySubscription[] |
getSubscriptions()
Returns a new list will all current substriptions. |
static Activity[] |
loadActivities(java.io.InputStream in,
java.beans.ExceptionListener listener,
boolean isZipped)
Reads an XML input stream and returns a list of |
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
void |
removeActivityListListener(TimeSpanListListener l)
Deprecated. Use #removeDepositoryListener instead. Notification during synchronized block could lead to dead-locks. |
void |
removeAllBrokedActivities()
Removes all currently broked activities. |
void |
removeAllSubscriptions()
Removes all subscriptions one by one and notifies the listeners. |
void |
removeBrokedActivities(java.util.Collection c)
Remove Activitys from the list. |
void |
removeBrokedActivities(java.util.Collection c,
int eventType)
Remove Activitys from the list. |
boolean |
removeBrokedActivity(Activity a)
Remove an activity from the list. |
boolean |
removeBrokedActivity(Activity act,
int eventType)
Remove an activity from the list. |
Activity |
removeBrokedActivityById(java.lang.Object id)
Remove an activity from the list. |
Activity |
removeBrokedActivityById(java.lang.Object actID,
int eventType)
Remove an activity from the list. |
void |
removeDepositoryListener(TimeSpanListListener l)
Removes the listener if it exists locally. |
static boolean |
removeInstance(java.lang.String context)
Remove the depository from the list of depositories managed. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
|
void |
removeSubscription(ActivitySubscription s)
Removes a subscription and notifies the listeners. |
void |
removeSubscriptionListener(java.beans.PropertyChangeListener l)
|
void |
removeSubscriptions(java.lang.Object source)
Removes all subscriptions associated with source (by identity). |
Activity |
resolve(Activity currentActivity,
Activity addingActivity,
java.lang.Object adder)
Should resolve the situation where a new activty is added to the depository when there's onr there with the same ID already- |
static void |
saveActivities(Activity[] activites,
java.io.OutputStream os,
java.beans.ExceptionListener listener,
boolean zipIt)
Saves the mappings to file using XMLEncoder. |
void |
setActivityResolver(ActivityResolver activityResolver)
Sets the resolver. |
static void |
setDepository(java.lang.String context,
ActivityDepository depository)
Sets the synchronizeronizer to synchronizeronizer. |
void |
setEnforceIDClass(java.lang.Class enforceIDClass)
Sets the id class type that always should be used as id for the coategories. |
void |
setLogger(java.util.logging.Logger logger)
Set the current logger. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PROP_SUBSCR_ADDED
public static final java.lang.String PROP_SUBSCR_REMOVED
| Constructor Detail |
|---|
protected ActivityDepository()
| Method Detail |
|---|
public static final ActivityDepository getInstance()
null context. Creates the instance the first time. After that
it can't be changed to another implementation with setDepository(String, ActivityDepository).
Returns the depository for the default null context.
public static final ActivityDepository getInstance(java.lang.String context)
setDepository(String, ActivityDepository).
context - The context to return the depository for. May be anything and are just used as a key. null is the default one.
The context is used so that there can be more than one depository. Every depository contains its own set of activities.
public static boolean removeInstance(java.lang.String context)
context -
true if the depository was found and removed. false if there was no depository found.
public static Activity[] loadActivities(java.io.InputStream in,
java.beans.ExceptionListener listener,
boolean isZipped)
throws java.io.IOException
in - The stream to read from. Will be closed.listener - The listener for exceptions thrown by the XMLDecoder.isZipped - If in doesn't support mark/reset there is no way to test if the stream
is zipped. If so this value will be used. If the stream does support mark/reset the value is gotten from the stream
and this argument is not used.
null.
java.io.IOException
public static void saveActivities(Activity[] activites,
java.io.OutputStream os,
java.beans.ExceptionListener listener,
boolean zipIt)
throws java.io.IOException
XMLEncoder.
Since the data that will be persisted to the output stream is including the information that is added to the mappings, and custom class types must be
JavaBean-persistable (see XMLEncoder or have a delegate registered with
IOUtil.setDelegate(Class, java.beans.PersistenceDelegate).
activites - The activities to save.os - The output stream to save the XML to. Closes it!!listener - The listener for exceptions thrown by the XMLEncoder.zipIt - If set to true the output stream is ziped with level 9. This will reduce the size a lot.
java.io.IOException
public static void setDepository(java.lang.String context,
ActivityDepository depository)
synchronizeronizer. This method must be called before any call to getInstance(String) is ever made
or a UnsupportedOperationException is thrown since the depository isn't "hot swappable" in the current implementation.
This also means that this method can only be called once.
depository - The depository to use. Not null.context - The context to register this depository under. null is the default one. The context is used so that there can be more than one depository.
Every depository contains its own set of activities.public java.lang.Class getEnforceIDClass()
null if no check.public void setEnforceIDClass(java.lang.Class enforceIDClass)
enforceIDClass - The class type. null will turn of the ID class type check.public java.util.logging.Logger getLogger()
null if none is set.
null if none is set.public void setLogger(java.util.logging.Logger logger)
null to diable logging (default)
logger - The new logger or null to diable logging (default)public Activity getActivity(java.lang.Object id)
HashMap, so it will be very fast.
id - The id of the activity.
Activity or null if there was no activity with that id maintained by the depository.public ActivityList getActivities()
public int getBrokedActivityCount()
public ActivityResolver getActivityResolver()
null this object
(which is a ActivityResolver) will just choose the newest one (modification date wise).
null.public void setActivityResolver(ActivityResolver activityResolver)
null this object (which is a ActivityResolver) will just choose the newest one
(modification date wise).
activityResolver - The new resolver. Can be null.public ActivityResolver getCurrentActivityResolver()
null as getActivityResolver() might. This methods returns
this if not other resolver is returned.
null.
public Activity resolve(Activity currentActivity,
Activity addingActivity,
java.lang.Object adder)
ActivityResolver
resolve in interface ActivityResolvercurrentActivity - The current activity in the depository.addingActivity - The activity to be added. Has the same id as currentActivity.adder - The source responsible for adding addingActivity. Can for instance be an
ActivityIOPlugin
If null nothing is added and currentActivity should normally still be in the depository.
The normal course of action is to merge the activities, if needed, and return currentActivity.
If the current activity is returned this mean it has been updated and an event is thrown. If null is returned
nothing has been changed.
public void addSubscription(ActivitySubscription s)
A subscription only denotes a date range that is of interested for a source. For instance a IOFiler might use the subscriptions to optimize what activities to load.
s - The subscription to add.addSubscriptionListener(java.beans.PropertyChangeListener, boolean),
PROP_SUBSCR_ADDEDpublic void removeSubscription(ActivitySubscription s)
s - The subscription to remove.addSubscriptionListener(java.beans.PropertyChangeListener, boolean),
PROP_SUBSCR_REMOVEDpublic void removeAllSubscriptions()
addSubscriptionListener(java.beans.PropertyChangeListener, boolean),
PROP_SUBSCR_REMOVEDpublic void removeSubscriptions(java.lang.Object source)
source (by identity).
source - The subscription that has this source will be removed.addSubscriptionListener(java.beans.PropertyChangeListener, boolean),
PROP_SUBSCR_REMOVEDpublic ActivitySubscription[] getSubscriptions()
null.addPropertyChangeListener(java.beans.PropertyChangeListener, boolean)
public TimeSpanList[] getActivityViewLists(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange)
ActivityList.getActivityViewLists(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI)
public TimeSpanList[] getActivityViewLists(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange,
Filter filter)
ActivityList.getActivityViewLists(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI, Filter)
public TimeSpanList getActivityViews(javax.swing.JComponent parent,
InteractionListener iListener,
DateRangeI withinRange,
Filter filter)
ActivityList.getActivityViews(javax.swing.JComponent, com.miginfocom.ashape.interaction.InteractionListener, com.miginfocom.util.dates.DateRangeI, Filter)
public void addBrokedActivities(java.util.Collection c,
java.lang.Object source)
addBrokedActivities(java.util.Collection, Object, int) with TimeSpanListEvent.ADDED.
source - The source object that is adding the activity.c - The collection to add
public void addBrokedActivities(java.util.Collection c,
java.lang.Object source,
int eventType)
addBrokedActivity(Activity, Object) for every activity since they
have to be checked so that there are no activity with the same ID. If there is the resolver have to deal with that
problem.
source - The source object that is adding the activity.c - The collection to addeventType - E.g. TimeSpanListEvent.ADDED. Denotes if the add was due to a creation or
if the activitiy(ies) should just be handled by the depository and was created elsewhere. Use -1 to not send any events at all.
public void addBrokedActivity(Activity a,
java.lang.Object source)
addBrokedActivity(com.miginfocom.calendar.activity.Activity, Object, int) with TimeSpanListEvent.ADDED.
a - The activity to addsource - The source object that is adding the activity.addBrokedActivity(Activity, Object, int)
public void addBrokedActivity(Activity a,
java.lang.Object source,
int eventType)
If an activity with the same ID already exist the registered activity resolver will be invoked. The old one can be removed
and the new added or nothing will happen depending on the resolver. If a remove/add operation is done the event type
TimeSpanListEvent.EXCHANGED will be used instead of the value for eventType.
If the resolver chooses to instead change the old activity to be like the new one normal change events will be fired since no
add/remove operation is happening.
a - The activity to addsource - The source object that is adding the activity.eventType - E.g. TimeSpanListEvent.ADDED_CREATED. Denotes if the add was due to a creation or
of the activitiy(ies) should just be handled by the depository and was created elsewhere. Use -1 to not send any events at all, not even
for exchanges.public boolean removeBrokedActivity(Activity a)
a - The activity to remove.
public boolean removeBrokedActivity(Activity act,
int eventType)
act - The activity to remove.eventType - E.g. TimeSpanListEvent.REMOVED_DELETED. Denotes if the add was due to a deletion or
if the activitiy(ies) should just be removed from the depository for other reasons, such as they arenot requered in memory any more.
Use -1 to not send any events at all.
public Activity removeBrokedActivityById(java.lang.Object id)
id - The activity to remove.
null if the id was not beeing broked.
public Activity removeBrokedActivityById(java.lang.Object actID,
int eventType)
actID - The activity to remove.eventType - E.g. TimeSpanListEvent.REMOVED_DELETED. Denotes if the add was due to a deletion or
if the activitiy(ies) should just be removed from the depository for other reasons, such as they arenot requered in memory any more.
Use -1 to not send any events at all.
null if the id was not beeing broked.public void removeBrokedActivities(java.util.Collection c)
Activitys from the list. The activities are not deleted, it is only removed from handling by the broker.
c - The activities to add.
public void removeBrokedActivities(java.util.Collection c,
int eventType)
Activitys from the list. The activities are not deleted, it is only removed from handling by the broker.
c - The activities to add.eventType - E.g. TimeSpanListEvent.REMOVED_DELETED. Denotes if the add was due to a deletion or
if the activitiy(ies) should just be removed from the depository for other reasons, such as they arenot requered in memory any more.
Use -1 to not send any events at all.public void removeAllBrokedActivities()
TimeSpanListEvent.REMOVED.
public java.util.List getBrokedActivities()
Activity objects that are cuurently beeing broked (i.e. handled) by this depository.
Changes in the depository will not be reflected in the list after its creation.
null but can be empty.Arrays.asList(T...)public void addSubscriptionListener(java.beans.PropertyChangeListener l)
Also fires events when a subscription has been added/removed.
See PROP_xxx in this class.
l - The listeneraddSubscriptionListener(PropertyChangeListener, boolean)
public void addSubscriptionListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
See PROP_xxx in this class.
l - The listenerasWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since
the garbage collector can collect the listener if it is only referenced from this list.addSubscriptionListener(PropertyChangeListener, boolean)public void removeSubscriptionListener(java.beans.PropertyChangeListener l)
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
AbstractActivity and subclasses. Note that classes
that only implement Activity have to call AbstractActivity.fireStaticPropertyChangeEvent(java.beans.PropertyChangeEvent)
to fire the static notification.
Does not from version 5.5.5 fire subscription change events. See addSubscriptionListener(java.beans.PropertyChangeListener, boolean)
See PROP_xxx in this class.
l - The listeneraddPropertyChangeListener(PropertyChangeListener, boolean)
public void addPropertyChangeListener(java.beans.PropertyChangeListener l,
boolean asWeakRef)
AbstractActivity and subclasses. Note that classes
that only implement Activity have to call AbstractActivity.fireStaticPropertyChangeEvent(java.beans.PropertyChangeEvent)
to fire the static notification.
Does not from version 5.5.5 fire subscription change events. See addSubscriptionListener(java.beans.PropertyChangeListener, boolean)
See PROP_xxx in this class.
l - The listenerasWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since
the garbage collector can collect the listener if it is only referenced from this list.
addDepositoryListener(com.miginfocom.util.dates.TimeSpanListListener, boolean)public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange in interface java.beans.PropertyChangeListenerpublic void addDepositoryListener(TimeSpanListListener l)
l - The listeneraddDepositoryListener(TimeSpanListListener, boolean)
public void addDepositoryListener(TimeSpanListListener l,
boolean asWeakRef)
l - The listenerasWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since
the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.
public void removeDepositoryListener(TimeSpanListListener l)
l - The listener.
public void fireDepositoryChanged(Activity a,
java.lang.Object source,
int eventType)
public void fireDepositoryChanged(TimeSpan[] acts,
java.lang.Object source,
int eventType)
public void addActivityListListener(TimeSpanListListener l,
boolean asWeakRef)
TimeSpanList.addTimeSpanListListener(com.miginfocom.util.dates.TimeSpanListListener, boolean)
public void removeActivityListListener(TimeSpanListListener l)
TimeSpanList.removeTimeSpanListListener(com.miginfocom.util.dates.TimeSpanListListener)
l - The listener to remove
public void fireManualDepositoryListChanged(TimeSpan[] timeSpans,
int type,
DateRangeI dateRange)
TimeSpanListEvent. If for instance a recurring activity was added its recurrency range is not included
in the normal notification date range. A manual event needs to be fired for this.
timeSpans - The affected time spans.type - If added or removed. E.g. TimeSpanListEvent.REMOVED.dateRange - The total date span affected.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||