package com.onaro.sanscreen.client.view.grouping; import java.util.HashSet; import java.util.Set; import org.eclipse.core.runtime.IAdaptable; import com.onaro.client.swing.table.functional.IFunction; import com.onaro.sanscreen.client.view.tabular.AdaptablesTabularTableModel; import com.onaro.util.jfc.date.TimeSpan; import com.onaro.util.jfc.date.TimeSpanProvider; public abstract class TimeScopedTableModel extends AdaptablesTabularTableModel { private static final long serialVersionUID = 1L; private Set>> timeScopedFunctions = new HashSet>>(); private TimeSpanProvider timeSpanProvider; public TimeScopedTableModel() { timeSpanProvider = new TimeSpanProvider(); } /** * Register a time scoped function. Columns that make use of this function will be updated with the * models time scope changes. * * @param functionClass * @param timeScopedFunction */ public > void registerTimeScopedFunction(Class functionClass, TimeScopedBulkFunction timeScopedFunction) { timeScopedFunctions.add(functionClass); timeScopedFunction.setTimeSpanProvider(timeSpanProvider); getFunctionRegistry().register(functionClass, timeScopedFunction); } public boolean hasTimeScope() { TimeSpan timeSpan = timeSpanProvider.getTimeSpan(); return timeSpan != null && timeSpan.getFromTime() != null && timeSpan.getToTime() != null; } public void setTimeScope(TimeSpan timeSpan) { timeSpanProvider.setTimeSpan(timeSpan); } public TimeSpanProvider getTimeSpanProvider() { return timeSpanProvider; } }