Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public interface ScheduleModel

Known subtypesAbstractScheduleModel, CalendarScheduleModel, DefaultScheduleModel

What a Scheduler shows and edits.

A view asks for the items of the range on screen every time it paints, so getItems has to be cheap: a model that loads from a server answers from what it has and fires a change when more arrives. setVisibleRange is how it learns what to load.

DefaultScheduleModel holds items in memory, and CalendarScheduleModel reads a calendar source. Extend AbstractScheduleModel for one of your own.

Methods

public abstract List<ScheduleResource> getResources()The resources, in the order they are shown.
public abstract void getItems(long from, long to, List<ScheduleItem> out)Adds every item with any part inside [from, to) to out.
public abstract void setVisibleRange(long from, long to)Told by a view whenever the range it shows changes, with a margin around it.
public abstract boolean updateItem(ScheduleItem item, long start, long end, String resourceId)Moves or resizes an item, and gives it to another resource when resourceId differs from the one it has.
public abstract ScheduleItem createItem(long start, long end, String resourceId)Creates an item for a range the user dragged out on empty space.
public abstract boolean removeItem(ScheduleItem item)Removes an item.
public abstract void addChangeListener(ScheduleChangeListener l)
public abstract void removeChangeListener(ScheduleChangeListener l)

Method details

getResources

public abstract List<ScheduleResource> getResources()
The resources, in the order they are shown. Empty for a schedule that is one person’s.

getItems

public abstract void getItems(long from, long to, List<ScheduleItem> out)
Adds every item with any part inside [from, to) to out.

setVisibleRange

public abstract void setVisibleRange(long from, long to)
Told by a view whenever the range it shows changes, with a margin around it. A model that keeps everything in memory ignores it.

updateItem

public abstract boolean updateItem(ScheduleItem item, long start, long end, String resourceId)
Moves or resizes an item, and gives it to another resource when resourceId differs from the one it has.

Returns

false when the model refuses the change; the view puts the item back

createItem

public abstract ScheduleItem createItem(long start, long end, String resourceId)
Creates an item for a range the user dragged out on empty space.

Returns

the new item, or null when the model does not create items this way

removeItem

public abstract boolean removeItem(ScheduleItem item)
Removes an item.

Returns

false when the model refuses

addChangeListener

public abstract void addChangeListener(ScheduleChangeListener l)

removeChangeListener

public abstract void removeChangeListener(ScheduleChangeListener l)